Search is not available for this dataset
text
string
meta
dict
-- Andreas, 2019-05-03, issue #3742, reported by nad -- -- Regression introduced in 2.5.2: -- -- getConstInfo applied to abstract constructor D.c -- in metaOccurs check throws funny "not in scope" error for D.c record Σ (A : Set) (B : A → Set₁) : Set₁ where mutual abstract data D (A : Set) : Set where c : D A F : Set → Set₁ F A = Σ _ λ (_ : D A) → Set -- Should succeed.
{ "alphanum_fraction": 0.617721519, "avg_line_length": 18.8095238095, "ext": "agda", "hexsha": "0df0fc06a48c0c6f85f8ba561a3d519a3ac927d3", "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/Issue3742.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/Issue3742.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3742.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": 134, "size": 395 }
------------------------------------------------------------------------ -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Props.AbelianGroup (g : AbelianGroup) where open AbelianGroup g import Relation.Binary.EqReasoning as EqR; open EqR setoid open import Data.Function open import Data.Product private lemma : ∀ x y → x ∙ y ∙ x ⁻¹ ≈ y lemma x y = begin x ∙ y ∙ x ⁻¹ ≈⟨ comm _ _ ⟨ ∙-pres-≈ ⟩ refl ⟩ y ∙ x ∙ x ⁻¹ ≈⟨ assoc _ _ _ ⟩ y ∙ (x ∙ x ⁻¹) ≈⟨ refl ⟨ ∙-pres-≈ ⟩ proj₂ inverse _ ⟩ y ∙ ε ≈⟨ proj₂ identity _ ⟩ y ∎ -‿∙-comm : ∀ x y → x ⁻¹ ∙ y ⁻¹ ≈ (x ∙ y) ⁻¹ -‿∙-comm x y = begin x ⁻¹ ∙ y ⁻¹ ≈⟨ comm _ _ ⟩ y ⁻¹ ∙ x ⁻¹ ≈⟨ sym $ lem ⟨ ∙-pres-≈ ⟩ refl ⟩ x ∙ (y ∙ (x ∙ y) ⁻¹ ∙ y ⁻¹) ∙ x ⁻¹ ≈⟨ lemma _ _ ⟩ y ∙ (x ∙ y) ⁻¹ ∙ y ⁻¹ ≈⟨ lemma _ _ ⟩ (x ∙ y) ⁻¹ ∎ where lem = begin x ∙ (y ∙ (x ∙ y) ⁻¹ ∙ y ⁻¹) ≈⟨ sym $ assoc _ _ _ ⟩ x ∙ (y ∙ (x ∙ y) ⁻¹) ∙ y ⁻¹ ≈⟨ sym $ assoc _ _ _ ⟨ ∙-pres-≈ ⟩ refl ⟩ x ∙ y ∙ (x ∙ y) ⁻¹ ∙ y ⁻¹ ≈⟨ proj₂ inverse _ ⟨ ∙-pres-≈ ⟩ refl ⟩ ε ∙ y ⁻¹ ≈⟨ proj₁ identity _ ⟩ y ⁻¹ ∎
{ "alphanum_fraction": 0.3719512195, "avg_line_length": 35.4594594595, "ext": "agda", "hexsha": "88f4fba8078cdad9aef3f480d7edea82b1e0f9b2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Algebra/Props/AbelianGroup.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Algebra/Props/AbelianGroup.agda", "max_line_length": 73, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Algebra/Props/AbelianGroup.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 564, "size": 1312 }
-- Andreas, 2016-11-03, issue #2211 -- The occurs check did not take variables labeled as `UnusedArg` -- on the left hand side into consideration. -- {-# OPTIONS -v tc.check.term:40 #-} -- {-# OPTIONS -v tc.meta:45 #-} -- {-# OPTIONS -v tc.polarity:20 #-} open import Agda.Builtin.Equality open import Common.Nat cong : ∀{A B : Set}(f : A → B) (x y : A) → x ≡ y → f x ≡ f y cong _ _ _ refl = refl data ⊥ : Set where ⊥-elim : ∀{A : Set} → ⊥ {- unused arg -} → A ⊥-elim () data Fin : Nat → Set where zero : {n : Nat} → Fin (suc n) suc : {n : Nat} (i : Fin n) → Fin (suc n) toNat : ∀ {n} → Fin n → Nat toNat zero = 0 toNat (suc i) = suc (toNat i) tighten : ∀ n (x : Fin (suc n)) (neq : (toNat x ≡ n → ⊥) {- unused arg x-}) → Fin n tighten zero zero neq = ⊥-elim (neq refl) tighten (suc n) zero neq = zero tighten zero (suc ()) tighten (suc n) (suc x) neq = suc (tighten n x (λ p → neq (cong suc _ _ p))) tighten-correct : ∀ n (x : Fin (suc n)) (neq : toNat x ≡ n → ⊥) → toNat (tighten n x neq) ≡ toNat x tighten-correct zero zero neq = ⊥-elim (neq refl) tighten-correct (suc n) zero neq = refl tighten-correct zero (suc ()) tighten-correct (suc n) (suc x) neq = cong suc _ _ (tighten-correct n x (λ p → neq (cong Nat.suc _ _ p))) -- ERROR WAS: -- Cannot instantiate ... because it contains the variable neg ... -- Should succeed. {- term _62 n x neq (toNat (tighten n x (λ p → neq (cong suc p)))) := suc (toNat (tighten n x (λ p → neq (cong suc p)))) term _62 n x neq (toNat x) := toNat (suc x) after kill analysis metavar = _62 kills = [False,False,True,False] kills' = [ru(False),ru(False),ru(True),ru(False)] oldType = (n₁ : Nat) (x₁ : Fin (suc n₁)) (neq₁ : toNat (suc x₁) ≡ suc n₁ → ⊥) → Nat → Nat newType = (n₁ : Nat) → Fin (suc n₁) → Nat → Nat actual killing new meta: _69 kills : [ru(False),ru(False),ru(True),ru(False)] inst : _62 := _69 @3 n neq term _69 n x (toNat (tighten n x (λ p → neq (cong suc p)))) := suc (toNat (tighten n x (λ p → neq (cong suc p)))) Here, the variable neq on the lhs was not considered eligible for occurrence on the rhs since it is contained in an unused arg only. -}
{ "alphanum_fraction": 0.5179282869, "avg_line_length": 33.4666666667, "ext": "agda", "hexsha": "4a3ea03d92ba84874d98a5ac2169f34552095cd8", "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/Issue2211.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/Issue2211.agda", "max_line_length": 95, "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/Issue2211.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": 838, "size": 2510 }
-- Minimal implicational modal logic, PHOAS approach, initial encoding module Pi.BoxMp where open import Lib using (Nat; suc) -- Types infixr 0 _=>_ data Ty : Set where UNIT : Ty _=>_ : Ty -> Ty -> Ty BOX : Ty -> Ty -- Context and truth judgement with modal depth Cx : Set1 Cx = Ty -> Nat -> Set isTrue : Ty -> Nat -> Cx -> Set isTrue a d tc = tc a d -- Terms module BoxMp where infixl 1 _$_ data Tm (d : Nat) (tc : Cx) : Ty -> Set where var : forall {a} -> isTrue a d tc -> Tm d tc a lam' : forall {a b} -> (isTrue a d tc -> Tm d tc b) -> Tm d tc (a => b) _$_ : forall {a b} -> Tm d tc (a => b) -> Tm d tc a -> Tm d tc b box : forall {a} -> Tm (suc d) tc a -> Tm d tc (BOX a) unbox' : forall {>d a b} -> Tm d tc (BOX a) -> (isTrue a >d tc -> Tm d tc b) -> Tm d tc b lam'' : forall {d tc a b} -> (Tm d tc a -> Tm d tc b) -> Tm d tc (a => b) lam'' f = lam' \x -> f (var x) unbox'' : forall {d >d tc a b} -> Tm d tc (BOX a) -> (Tm >d tc a -> Tm d tc b) -> Tm d tc b unbox'' x f = unbox' x \y -> f (var y) syntax lam'' (\a -> b) = lam a => b syntax unbox'' x' (\x -> y) = unbox x' as x => y Thm : Ty -> Set1 Thm a = forall {d tc} -> Tm d 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 f' => lam x' => unbox f' as f => unbox x' as x => box (f $ x) aT : forall {a} -> Thm (BOX a => a) aT = lam x' => unbox x' as x => x a4 : forall {a} -> Thm (BOX a => BOX (BOX a)) a4 = lam x' => unbox x' as x => box (box x) t1 : forall {a} -> Thm (a => BOX (a => a)) t1 = lam _ => box (lam y => y)
{ "alphanum_fraction": 0.4766146993, "avg_line_length": 23.0256410256, "ext": "agda", "hexsha": "d90755fbc3eac74420341856d6f68f94083eddbf", "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/Pi/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/Pi/BoxMp.agda", "max_line_length": 94, "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/Pi/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": 706, "size": 1796 }
module Numeric.Nat.Properties where open import Prelude hiding (less-antisym; less-antirefl; leq-antisym) open import Prelude.Nat.Properties public open import Tactic.Nat --- Subtraction --- sub-less : {a b : Nat} → a ≤ b → b - a + a ≡ b sub-less {zero} _ = auto sub-less {suc a} (diff! k) = auto sub-underflow : (a b : Nat) → a ≤ b → a - b ≡ 0 sub-underflow a ._ (diff! k) = auto sub-leq : (a b : Nat) → a - b ≤ a sub-leq a b with compare a b sub-leq a ._ | less (diff! k) = diff a auto sub-leq a .a | equal refl = diff a auto sub-leq ._ b | greater (diff! k) = diff b auto --- LessNat --- fast-diff : {a b : Nat} → a < b → a < b fast-diff {a} {b} a<b = diff (b - suc a) (eraseEquality $ by (sub-less {suc a} {b} (by a<b))) {-# INLINE fast-diff #-} infixr 0 _⟨<⟩_ _⟨≤⟩_ _⟨<⟩_ : ∀ {x y z} → LessNat x y → LessNat y z → LessNat x z diff! a ⟨<⟩ diff! b = diff (suc (b + a)) auto less-antirefl : ∀ {a b : Nat} → a < b → ¬ (a ≡ b) less-antirefl (diff! k) eq = refute eq less-not-geq : ∀ {a b : Nat} → a < b → b ≤ a → ⊥ less-not-geq (diff d eq) (diff! d₁) = refute eq less-raa : {a b : Nat} → ¬ (suc a > b) → a < b less-raa {a} {b} a≱b with compare a b less-raa a≱b | less a<b = a<b less-raa a≱b | equal refl = ⊥-elim (a≱b auto) less-raa a≱b | greater a>b = ⊥-elim (a≱b (by a>b)) _⟨≤⟩_ : {a b c : Nat} → a ≤ b → b ≤ c → a ≤ c diff! k ⟨≤⟩ diff! k₁ = auto private leq-mul-r′ : ∀ a b → NonZero b → a ≤ a * b leq-mul-r′ _ zero () leq-mul-r′ a (suc b) _ = auto leq-mul-r : ∀ a b {{_ : NonZero b}} → a ≤ a * b leq-mul-r a b = fast-diff (leq-mul-r′ _ b it) -- Used for the well-founded induction over factorisation. less-mul-l : {a b : Nat} → a > 1 → b > 1 → a < a * b less-mul-l (diff! k) (diff! j) = auto less-mul-r : {a b : Nat} → a > 1 → b > 1 → b < a * b less-mul-r (diff! k) (diff! j) = auto add-nonzero-l : ∀ a b {{_ : NonZero a}} → NonZero (a + b) add-nonzero-l zero b {{}} add-nonzero-l (suc a) b = _ add-nonzero-r : ∀ a b {{_ : NonZero b}} → NonZero (a + b) add-nonzero-r zero zero {{}} add-nonzero-r zero (suc b) = _ add-nonzero-r (suc a) b = _ mul-nonzero : ∀ a b {{nza : NonZero a}} {{nzb : NonZero b}} → NonZero (a * b) mul-nonzero zero b {{nza = ()}} mul-nonzero (suc a) zero {{nzb = ()}} mul-nonzero (suc a) (suc b) = _ mul-nonzero-l : ∀ a b {{_ : NonZero (a * b)}} → NonZero a mul-nonzero-l 0 _ {{}} mul-nonzero-l (suc _) _ = _ mul-nonzero-r : ∀ a b {{_ : NonZero (a * b)}} → NonZero b mul-nonzero-r a b {{nz}} = mul-nonzero-l b a {{transport NonZero auto nz}} mul-unit-l : ∀ a b {{_ : NonZero b}} → a * b ≡ b → a ≡ 1 mul-unit-l 1 _ _ = refl mul-unit-l 0 .0 {{}} refl mul-unit-l (suc (suc a)) zero {{}} _ mul-unit-l (suc (suc a)) (suc b) ab=b = refute ab=b mul-unit-r : ∀ a b {{_ : NonZero a}} → a * b ≡ a → b ≡ 1 mul-unit-r a b ab=a = mul-unit-l b a (mul-commute b a ⟨≡⟩ ab=a)
{ "alphanum_fraction": 0.5484210526, "avg_line_length": 30.6451612903, "ext": "agda", "hexsha": "154a7855ba2cdee8ca58f969940ea98fb569527e", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/Properties.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/Properties.agda", "max_line_length": 93, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1187, "size": 2850 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Morphisms {o ℓ e} (C : Category o ℓ e) where open import Level open import Relation.Binary using (IsEquivalence; Setoid) open Category C Mono : ∀ {A B} → (f : A ⇒ B) → Set _ Mono {A} f = ∀ {C} → (g₁ g₂ : C ⇒ A) → f ∘ g₁ ≡ f ∘ g₂ → g₁ ≡ g₂ Epi : ∀ {B A} → (f : A ⇒ B) → Set _ Epi {B} f = ∀ {C} → (g₁ g₂ : B ⇒ C) → g₁ ∘ f ≡ g₂ ∘ f → g₁ ≡ g₂ record Iso {A B} (f : A ⇒ B) (g : B ⇒ A) : Set (o ⊔ ℓ ⊔ e) where field .isoˡ : g ∘ f ≡ id .isoʳ : f ∘ g ≡ id infix 4 _≅_ record _≅_ (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where field f : A ⇒ B g : B ⇒ A .iso : Iso f g .isoˡ : _ isoˡ = Iso.isoˡ iso .isoʳ : _ isoʳ = Iso.isoʳ iso infix 4 _ⓘ_ _ⓘ_ : ∀ {X Y Z} → Y ≅ Z → X ≅ Y → X ≅ Z G ⓘ F = record { f = G.f ∘ F.f ; g = F.g ∘ G.g ; iso = record { isoˡ = begin (F.g ∘ G.g) ∘ (G.f ∘ F.f) ↓⟨ assoc ⟩ F.g ∘ (G.g ∘ (G.f ∘ F.f)) ↑⟨ refl ⟩∘⟨ assoc ⟩ F.g ∘ (G.g ∘ G.f) ∘ F.f ↓⟨ refl ⟩∘⟨ G.isoˡ ⟩∘⟨ refl ⟩ F.g ∘ (id ∘ F.f) ↓⟨ refl ⟩∘⟨ identityˡ ⟩ F.g ∘ F.f ↓⟨ F.isoˡ ⟩ id ∎ ; isoʳ = begin (G.f ∘ F.f) ∘ (F.g ∘ G.g) ↓⟨ assoc ⟩ G.f ∘ (F.f ∘ (F.g ∘ G.g)) ↑⟨ refl ⟩∘⟨ assoc ⟩ G.f ∘ (F.f ∘ F.g) ∘ G.g ↓⟨ refl ⟩∘⟨ F.isoʳ ⟩∘⟨ refl ⟩ G.f ∘ (id ∘ G.g) ↓⟨ refl ⟩∘⟨ identityˡ ⟩ G.f ∘ G.g ↓⟨ G.isoʳ ⟩ id ∎ } } where module F = _≅_ F module G = _≅_ G open Iso open Equiv open HomReasoning idⁱ : ∀ {A} → A ≅ A idⁱ {A} = record { f = id ; g = id ; iso = record { isoˡ = identityˡ ; isoʳ = identityˡ } } reverseⁱ : ∀ {A B} → A ≅ B → B ≅ A reverseⁱ A≅B = record { f = A≅B.g ; g = A≅B.f ; iso = record { isoˡ = A≅B.isoʳ ; isoʳ = A≅B.isoˡ } } where module A≅B = _≅_ A≅B ≅-is-equivalence : IsEquivalence _≅_ ≅-is-equivalence = record { refl = idⁱ ; sym = reverseⁱ ; trans = λ x y → y ⓘ x } ≅-setoid : Setoid o (o ⊔ ℓ ⊔ e) ≅-setoid = record { Carrier = Obj ; _≈_ = _≅_ ; isEquivalence = ≅-is-equivalence } -- equality of isos induced from arrow equality -- could just use a pair, but this way is probably clearer record _≡ⁱ_ {A B : Obj} (i j : A ≅ B) : Set (o ⊔ ℓ ⊔ e) where open _≅_ field f-≡ : f i ≡ f j g-≡ : g i ≡ g j .≡ⁱ-is-equivalence : ∀ {A B} → IsEquivalence (_≡ⁱ_ {A} {B}) ≡ⁱ-is-equivalence = record { refl = record { f-≡ = refl; g-≡ = refl } ; sym = λ x → record { f-≡ = sym (f-≡ x); g-≡ = sym (g-≡ x) } ; trans = λ x y → record { f-≡ = trans (f-≡ x) (f-≡ y); g-≡ = trans (g-≡ x) (g-≡ y) } } where open Equiv open _≡ⁱ_ {- ≡ⁱ-setoid : ∀ {A B} → Setoid (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) ≡ⁱ-setoid {A} {B} = record { Carrier = A ≅ B; _≈_ = _≡ⁱ_; isEquivalence = ≡ⁱ-is-equivalence } -} -- groupoid with only isos Isos : Category o (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Isos = record { Obj = Obj ; _⇒_ = _≅_ ; _≡_ = _≡ⁱ_ ; id = idⁱ ; _∘_ = _ⓘ_ ; assoc = λ {A B C D f g h} → record { f-≡ = assoc; g-≡ = sym assoc } ; identityˡ = λ {A B f} → record { f-≡ = identityˡ; g-≡ = identityʳ } ; identityʳ = λ {A B f} → record { f-≡ = identityʳ; g-≡ = identityˡ } ; equiv = ≡ⁱ-is-equivalence ; ∘-resp-≡ = λ {A B C f h g i} f≡ⁱh g≡ⁱi → record { f-≡ = ∘-resp-≡ (f-≡ f≡ⁱh) (f-≡ g≡ⁱi) ; g-≡ = ∘-resp-≡ (g-≡ g≡ⁱi) (g-≡ f≡ⁱh) } } where open Equiv open _≡ⁱ_ -- heterogeneous equality of isos open Heterogeneous Isos public using () renaming (_∼_ to _∼ⁱ_; ≡⇒∼ to ≡⇒∼ⁱ; ∼⇒≡ to ∼⇒≡ⁱ; refl to ∼ⁱ-refl; sym to ∼ⁱ-sym; trans to ~ⁱ-trans; ∘-resp-∼ to ∘-resp-∼ⁱ; ∘-resp-∼ˡ to ∘-resp-∼ⁱˡ; ∘-resp-∼ʳ to ∘-resp-∼ⁱʳ; domain-≣ to domain-≣ⁱ; codomain-≣ to codomain-≣ⁱ) private f-∼′ : ∀ {A B} {i : A ≅ B} {A′ B′} {j : A′ ≅ B′} (eq : i ∼ⁱ j) → Heterogeneous._∼_ C (_≅_.f i) (_≅_.f j) f-∼′ (≡⇒∼ⁱ eq) = ≡⇒∼ (f-≡ eq) where open Heterogeneous C open _≡ⁱ_ g-∼′ : ∀ {A B} {i : A ≅ B} {A′ B′} {j : A′ ≅ B′} (eq : i ∼ⁱ j) → Heterogeneous._∼_ C (_≅_.g i) (_≅_.g j) g-∼′ (≡⇒∼ⁱ eq) = ≡⇒∼ (g-≡ eq) where open Heterogeneous C open _≡ⁱ_ heqⁱ : ∀ {A B} (i : A ≅ B) {A′ B′} (j : A′ ≅ B′) → let open _≅_ in let open Heterogeneous C in f i ∼ f j → g i ∼ g j → i ∼ⁱ j heqⁱ i j (Heterogeneous.≡⇒∼ eq-f) (Heterogeneous.≡⇒∼ eq-g) = ≡⇒∼ⁱ {f = i} {g = j} (record { f-≡ = eq-f; g-≡ = eq-g })
{ "alphanum_fraction": 0.4674731796, "avg_line_length": 24.7514124294, "ext": "agda", "hexsha": "aa68414734407c850ab49c5e971a8361cc33764b", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Morphisms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Morphisms.agda", "max_line_length": 262, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Morphisms.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 2309, "size": 4381 }
{-# OPTIONS --safe --cubical #-} module Data.Pi.Base where open import Level Π : (A : Type a) (B : A → Type b) → Type _ Π A B = (x : A) → B x ∀′ : {A : Type a} (B : A → Type b) → Type _ ∀′ {A = A} B = Π A B infixr 4.5 ∀-syntax ∀-syntax : ∀ {a b} {A : Type a} (B : A → Type b) → Type (a ℓ⊔ b) ∀-syntax = ∀′ syntax ∀-syntax (λ x → e) = ∀[ x ] e infixr 4.5 Π⦂-syntax Π⦂-syntax : (A : Type a) (B : A → Type b) → Type (a ℓ⊔ b) Π⦂-syntax = Π syntax Π⦂-syntax t (λ x → e) = Π[ x ⦂ t ] e
{ "alphanum_fraction": 0.4918032787, "avg_line_length": 20.3333333333, "ext": "agda", "hexsha": "7f2ff93c8e6d4361ac34e7537b2b73e8502b09b7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Pi/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Pi/Base.agda", "max_line_length": 64, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Pi/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 242, "size": 488 }
module Thesis.IntChanges where open import Data.Integer.Base open import Relation.Binary.PropositionalEquality open import Thesis.Changes open import Theorem.Groups-Nehemiah private intCh = ℤ instance intCS : ChangeStructure ℤ intCS = record { Ch = ℤ ; ch_from_to_ = λ dv v1 v2 → v1 + dv ≡ v2 ; isCompChangeStructure = record { isChangeStructure = record { _⊕_ = _+_ ; fromto→⊕ = λ dv v1 v2 v2≡v1+dv → v2≡v1+dv ; _⊝_ = _-_ ; ⊝-fromto = λ a b → n+[m-n]=m {a} {b} } ; _⊚_ = λ da1 da2 → da1 + da2 ; ⊚-fromto = i⊚-fromto } } where i⊚-fromto : (a1 a2 a3 : ℤ) (da1 da2 : intCh) → a1 + da1 ≡ a2 → a2 + da2 ≡ a3 → a1 + (da1 + da2) ≡ a3 i⊚-fromto a1 a2 a3 da1 da2 a1+da1≡a2 a2+da2≡a3 rewrite sym (associative-int a1 da1 da2) | a1+da1≡a2 = a2+da2≡a3
{ "alphanum_fraction": 0.5953827461, "avg_line_length": 25.71875, "ext": "agda", "hexsha": "989b59e731c3c1cb3b1c5220314c2c5b27f7151b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/IntChanges.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/IntChanges.agda", "max_line_length": 70, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/IntChanges.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 371, "size": 823 }
-- {-# OPTIONS -v tc.lhs.unify:50 #-} module Issue81 where data ⊥ : Set where data D : Set where d : D c : D data E : Set where e : E ⌜_⌝ : E -> D ⌜ e ⌝ = c data R : D -> E -> Set where Val : (v : E) -> R ⌜ v ⌝ v foo : R d e -> ⊥ foo ()
{ "alphanum_fraction": 0.4722222222, "avg_line_length": 11.4545454545, "ext": "agda", "hexsha": "11f557662f7ec9b9b1be6780610e2929157cd5b1", "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/Issue81.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/Issue81.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/Succeed/Issue81.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": 115, "size": 252 }
open import Agda.Primitive open import Agda.Builtin.Sigma variable ℓ₁ ℓ₂ : Level is-universal-element : {X : Set ℓ₁} {A : X → Set ℓ₂} → Σ X A → Set (ℓ₁ ⊔ ℓ₂) is-universal-element {ℓ₁} {ℓ₂} {X} {A} (x , a) = ∀ y → A y fails : {X : Set ℓ₁} {A : X → Set ℓ₂} (x : X) (a : A x) → is-universal-element {A = _} (x , a) → (y : X) → A y -- a is yellow fails {ℓ₁} {ℓ₂} {X = X} {A} x a u y = u y works : ∀ {ℓ₁} {ℓ₂} {X : Set ℓ₁} {A : X → Set ℓ₂} (x : X) (a : A x) → is-universal-element {A = _} (x , a) → (y : X) → A y works x a u y = u y
{ "alphanum_fraction": 0.5045703839, "avg_line_length": 30.3888888889, "ext": "agda", "hexsha": "42558235e1ebad232addad99555e1bf5972dd8c1", "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/Issue3519.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/Issue3519.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3519.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": 266, "size": 547 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.HSpace renaming (HSpaceStructure to HSS) open import homotopy.Freudenthal open import homotopy.IterSuspensionStable import homotopy.Pi2HSusp as Pi2HSusp open import homotopy.EM1HSpace open import homotopy.EilenbergMacLane1 module homotopy.EilenbergMacLane where -- EM(G,n) when G is π₁(A,a₀) module EMImplicit {i} {X : Ptd i} {{_ : is-connected 0 (de⊙ X)}} {{_ : has-level 1 (de⊙ X)}} (H-X : HSS X) where private A = de⊙ X a₀ = pt X ⊙EM : (n : ℕ) → Ptd i ⊙EM O = ⊙Ω X ⊙EM (S n) = ⊙Trunc ⟨ S n ⟩ (⊙Susp^ n X) module _ (n : ℕ) where EM = de⊙ (⊙EM n) EM-level : (n : ℕ) → has-level ⟨ n ⟩ (EM n) EM-level O = ⟨⟩ EM-level (S n) = ⟨⟩ instance EM-conn : (n : ℕ) → is-connected ⟨ n ⟩ (EM (S n)) EM-conn n = Trunc-preserves-conn (⊙Susp^-conn' n) {- π (S k) (EM (S n)) (embase (S n)) == π k (EM n) (embase n) where k > 0 and n = S (S n') -} module Stable (k n : ℕ) (indexing : S k ≤ S (S n)) where private SSn : ℕ SSn = S (S n) lte : ⟨ S k ⟩ ≤T ⟨ SSn ⟩ lte = ⟨⟩-monotone-≤ $ indexing Skle : S k ≤ (S n) *2 Skle = ≤-trans indexing (lemma n) where lemma : (n' : ℕ) → S (S n') ≤ (S n') *2 lemma O = inl idp lemma (S n') = ≤-trans (≤-ap-S (lemma n')) (inr ltS) private module SS = Susp^StableSucc k (S n) Skle (⊙Susp^ (S n) X) {{⊙Susp^-conn' (S n)}} abstract stable : πS (S k) (⊙EM (S SSn)) ≃ᴳ πS k (⊙EM SSn) stable = πS (S k) (⊙EM (S SSn)) ≃ᴳ⟨ πS-Trunc-fuse-≤-iso _ _ _ (≤T-ap-S lte) ⟩ πS (S k) (⊙Susp^ SSn X) ≃ᴳ⟨ SS.stable ⟩ πS k (⊙Susp^ (S n) X) ≃ᴳ⟨ πS-Trunc-fuse-≤-iso _ _ _ lte ⁻¹ᴳ ⟩ πS k (⊙EM SSn) ≃ᴳ∎ module BelowDiagonal where π₁ : (n : ℕ) → πS 0 (⊙EM (S (S n))) ≃ᴳ 0ᴳ π₁ n = contr-iso-0ᴳ (πS 0 (⊙EM (S (S n)))) (connected-at-level-is-contr {{raise-level-≤T (≤T-ap-S (≤T-ap-S (-2≤T ⟨ n ⟩₋₂))) (Trunc-level {n = 0})}}) -- some clutter here arises from the definition of <; -- any simple way to avoid this? πS-below : (k n : ℕ) → (S k < n) → πS k (⊙EM n) ≃ᴳ 0ᴳ πS-below 0 .2 ltS = π₁ 0 πS-below 0 .3 (ltSR ltS) = π₁ 1 πS-below 0 (S (S n)) (ltSR (ltSR _)) = π₁ n πS-below (S k) ._ ltS = πS-below k _ ltS ∘eᴳ Stable.stable k k (inr ltS) πS-below (S k) ._ (ltSR ltS) = πS-below k _ (ltSR ltS) ∘eᴳ Stable.stable k (S k) (inr (ltSR ltS)) πS-below (S k) ._ (ltSR (ltSR ltS)) = πS-below k _ (ltSR (ltSR ltS)) ∘eᴳ Stable.stable k (S (S k)) (inr (ltSR (ltSR ltS))) πS-below (S k) (S (S (S n))) (ltSR (ltSR (ltSR lt))) = πS-below k _ (<-cancel-S (ltSR (ltSR (ltSR lt)))) ∘eᴳ Stable.stable k n (inr (<-cancel-S (ltSR (ltSR (ltSR lt))))) module OnDiagonal where π₁ : πS 0 (⊙EM 1) ≃ᴳ πS 0 X π₁ = πS-Trunc-fuse-≤-iso 0 1 X ≤T-refl private module Π₂ = Pi2HSusp H-X π₂ : πS 1 (⊙EM 2) ≃ᴳ πS 0 X π₂ = Π₂.π₂-Susp ∘eᴳ πS-Trunc-fuse-≤-iso 1 2 (⊙Susp X) ≤T-refl πS-diag : (n : ℕ) → πS n (⊙EM (S n)) ≃ᴳ πS 0 X πS-diag 0 = π₁ πS-diag 1 = π₂ πS-diag (S (S n)) = πS-diag (S n) ∘eᴳ Stable.stable (S n) n ≤-refl module AboveDiagonal where πS-above : ∀ (k n : ℕ) → (n < S k) → πS k (⊙EM n) ≃ᴳ 0ᴳ πS-above k n lt = contr-iso-0ᴳ (πS k (⊙EM n)) (inhab-prop-is-contr [ idp^ (S k) ] {{Trunc-preserves-level 0 (Ω^-level -1 (S k) _ (raise-level-≤T (lemma lt) (EM-level n)))}}) where lemma : {k n : ℕ} → n < k → ⟨ n ⟩ ≤T (⟨ k ⟩₋₂ +2+ -1) lemma ltS = inl (! (+2+-comm _ -1)) lemma (ltSR lt) = ≤T-trans (lemma lt) (inr ltS) module Spectrum where private module Π₂ = Pi2HSusp H-X spectrum0 : ⊙Ω (⊙EM 1) ⊙≃ ⊙EM 0 spectrum0 = ⊙Ω (⊙EM 1) ⊙≃⟨ ≃-to-⊙≃ (Trunc=-equiv _ _) idp ⟩ ⊙Trunc 0 (⊙Ω X) ⊙≃⟨ ≃-to-⊙≃ (unTrunc-equiv _) idp ⟩ ⊙Ω X ⊙≃∎ spectrum1 : ⊙Ω (⊙EM 2) ⊙≃ ⊙EM 1 spectrum1 = ⊙Ω (⊙EM 2) ⊙≃⟨ ≃-to-⊙≃ (Trunc=-equiv _ _) idp ⟩ ⊙Trunc 1 (⊙Ω (⊙Susp X)) ⊙≃⟨ Π₂.⊙eq ⟩ ⊙EM 1 ⊙≃∎ private instance sconn : (n : ℕ) → is-connected ⟨ S n ⟩ (de⊙ (⊙Susp^ (S n) X)) sconn n = ⊙Susp^-conn' (S n) kle : (n : ℕ) → ⟨ S (S n) ⟩ ≤T ⟨ n ⟩ +2+ ⟨ n ⟩ kle O = inl idp kle (S n) = ≤T-trans (≤T-ap-S (kle n)) (≤T-trans (inl (! (+2+-βr ⟨ n ⟩ ⟨ n ⟩))) (inr ltS)) module FS (n : ℕ) = FreudenthalEquiv ⟨ n ⟩₋₁ ⟨ S (S n) ⟩ (kle n) (⊙Susp^ (S n) X) spectrumSS : (n : ℕ) → ⊙Ω (⊙EM (S (S (S n)))) ⊙≃ ⊙EM (S (S n)) spectrumSS n = ⊙Ω (⊙EM (S (S (S n)))) ⊙≃⟨ ≃-to-⊙≃ (Trunc=-equiv _ _) idp ⟩ ⊙Trunc ⟨ S (S n) ⟩ (⊙Ω (⊙Susp^ (S (S n)) X)) ⊙≃⟨ FS.⊙eq n ⊙⁻¹ ⟩ ⊙EM (S (S n)) ⊙≃∎ abstract spectrum : (n : ℕ) → ⊙Ω (⊙EM (S n)) ⊙≃ ⊙EM n spectrum 0 = spectrum0 spectrum 1 = spectrum1 spectrum (S (S n)) = spectrumSS n module EMExplicit {i} (G : AbGroup i) where module HSpace = EM₁HSpace G open EMImplicit HSpace.H-⊙EM₁ public open BelowDiagonal public using (πS-below) πS-diag : (n : ℕ) → πS n (⊙EM (S n)) ≃ᴳ AbGroup.grp G πS-diag n = π₁-EM₁ (AbGroup.grp G) ∘eᴳ OnDiagonal.πS-diag n open AboveDiagonal public using (πS-above) open Spectrum public using (spectrum)
{ "alphanum_fraction": 0.4824656544, "avg_line_length": 28.3692307692, "ext": "agda", "hexsha": "92b23093834931255ecd8dbc90a05acc79057090", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/EilenbergMacLane.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/EilenbergMacLane.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/EilenbergMacLane.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2594, "size": 5532 }
------------------------------------------------------------------------------ -- Definition of the gcd of two natural numbers using the Euclid's algorithm ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.GCD.Total.GCD where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities ------------------------------------------------------------------------------ -- In GHC ≥ 7.2.1 the gcd is a total function, i.e. gcd 0 0 = 0. postulate gcd : D → D → D gcd-eq : ∀ m n → gcd m n ≡ (if (iszero₁ n) then m else (if (iszero₁ m) then n else (if (gt m n) then gcd (m ∸ n) n else gcd m (n ∸ m)))) {-# ATP axiom gcd-eq #-}
{ "alphanum_fraction": 0.3807654563, "avg_line_length": 33.9666666667, "ext": "agda", "hexsha": "0850c7b1655f2471132e2a59c5ca5ef8289e33b4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Total/GCD.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Total/GCD.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/GCD/Total/GCD.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": 215, "size": 1019 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition open import Setoids.Setoids open import Setoids.DirectSum open import Setoids.Subset open import Graphs.Definition open import Sets.FinSet.Definition open import Sets.FinSet.Lemmas open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Sets.EquivalenceRelations open import Graphs.PathGraph module Graphs.UnionGraph where unionGraph : {a b c d e f : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) {W' : Set d} {W : Setoid {d} {e} W'} (H : Graph f W) → Graph (c ⊔ f) (directSumSetoid V W) Graph._<->_ (unionGraph {c = c} {f = f} G H) (inl v) (inl v2) = embedLevel {c} {f} (Graph._<->_ G v v2) Graph._<->_ (unionGraph G H) (inl v) (inr w) = False' Graph._<->_ (unionGraph G H) (inr w) (inl v) = False' Graph._<->_ (unionGraph {c = c} {f = f} G H) (inr w) (inr w2) = embedLevel {f} {c} (Graph._<->_ H w w2) Graph.noSelfRelation (unionGraph G H) (inl v) (v=v ,, _) = Graph.noSelfRelation G v v=v Graph.noSelfRelation (unionGraph G H) (inr w) (w=w ,, _) = Graph.noSelfRelation H w w=w Graph.symmetric (unionGraph G H) {inl x} {inl y} (x=y ,, _) = Graph.symmetric G x=y ,, record {} Graph.symmetric (unionGraph G H) {inr x} {inr y} (x=y ,, _) = Graph.symmetric H x=y ,, record {} Graph.wellDefined (unionGraph G H) {inl x} {inl y} {inl z} {inl w} (x=y ,, _) (y=z ,, _) (z=w ,, _) = Graph.wellDefined G x=y y=z z=w ,, record {} Graph.wellDefined (unionGraph G H) {inr x} {inr y} {inr z} {inr w} (x=y ,, _) (y=z ,, _) (z=w ,, _) = Graph.wellDefined H x=y y=z z=w ,, record {}
{ "alphanum_fraction": 0.6543723974, "avg_line_length": 56.0333333333, "ext": "agda", "hexsha": "135230a1056a1bfe05451aa7e21d23817914c392", "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": "Graphs/UnionGraph.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": "Graphs/UnionGraph.agda", "max_line_length": 174, "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": "Graphs/UnionGraph.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": 606, "size": 1681 }
{-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc:10 #-} -- {-# OPTIONS -v tc.with:40 #-} -- Andreas, 2014-11-26 -- Reported by twanvl data Unit : Set where unit : Unit module Mod₁ (t : Unit) where postulate Thing : Set module Mod₂ (u : Unit) where open Mod₁ unit record Foo : Set where field foo : Thing → Thing bar : Thing → Thing bar a with foo a ... | x = x -- checkInternal stumbles over -- (λ u₁ → Thing) {u} : Setω -- which is an internal representation of Thing, to be precise -- Mod₂._.Thing u which expands to Mod₁.Thing unit -- More complete transcript: -- checking internal Thing : Setω -- reduction on defined ident. in anonymous module -- x = Issue1332.Mod₂._.Thing -- v = Def Issue1332.Mod₁.Thing [Apply []r(Con Issue1332.Unit.unit(inductive)[] [])] -- elimView of Thing -- v = Def Issue1332.Mod₂._.Thing [Apply []r{Var 1 []}] -- reduction on defined ident. in anonymous module -- x = Issue1332.Mod₂._.Thing -- v = Def Issue1332.Mod₁.Thing [Apply []r(Con Issue1332.Unit.unit(inductive)[] [])] -- elimView (projections reduced) of Thing -- reduction on defined ident. in anonymous module -- x = Issue1332.Mod₂._.Thing -- v = Lam (ArgInfo {argInfoHiding = NotHidden, argInfoRelevance = Relevant, argInfoColors = []}) (Abs "u" Def Issue1332.Mod₁.Thing [Apply []r(Con Issue1332.Unit.unit(inductive)[] [])]) -- checking spine -- ( -- λ u₁ → Thing -- : -- (u₁ : Thing) → Set -- ) -- [$ {u}] -- : -- Setω -- /home/abel/agda/test/bugs/Issue1332.agda:23,5-24,16 -- Expected a visible argument, but found a hidden argument -- when checking that the type (a : Thing) → Thing → Thing of the -- generated with function is well-formed
{ "alphanum_fraction": 0.6548672566, "avg_line_length": 27.3387096774, "ext": "agda", "hexsha": "0ae9a4e74375d0d4b98ca23ca0ccb7886a29b6c4", "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/Issue1332.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/Issue1332.agda", "max_line_length": 185, "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/Issue1332.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": 524, "size": 1695 }
------------------------------------------------------------------------------ -- Totality of natural numbers addition ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.AddTotality where open import FOTC.Base open import FOTC.Data.Nat ------------------------------------------------------------------------------ module InductionPrinciple where -- Interactive proof using the induction principle for natural numbers. +-N : ∀ {m n} → N m → N n → N (m + n) +-N {m} {n} Nm Nn = N-ind A A0 is Nm where A : D → Set A i = N (i + n) A0 : A zero A0 = subst N (sym (+-0x n)) Nn is : ∀ {i} → A i → A (succ₁ i) is {i} Ai = subst N (sym (+-Sx i n)) (nsucc Ai) -- Combined proof using the induction principle. -- -- The translation is -- ∀ p. app₁(p,zero) → -- (∀ x. app₁(n,x) → app₁(p,x) → app₁(p,appFn(succ,x))) → -- N-ind -- (∀ x. app₁(n,x) → app₁(p,x)) ---------------------------------------------------------------- -- ∀ x y. app₁(n,x) → app₁(n,y) → app₁(n,appFn(appFn(+,x),y)) -- +-N -- Because the ATPs don't handle induction, them cannot prove this -- postulate. postulate +-N' : ∀ {m n} → N m → N n → N (m + n) -- {-# ATP prove +-N' N-ind #-} module Instance where -- Interactive proof using an instance of the induction principle. +-N-ind : ∀ {n} → N (zero + n) → (∀ {m} → N (m + n) → N (succ₁ m + n)) → ∀ {m} → N m → N (m + n) +-N-ind {n} = N-ind (λ i → N (i + n)) +-N : ∀ {m n} → N m → N n → N (m + n) +-N {n = n} Nm Nn = +-N-ind A0 is Nm where A0 : N (zero + n) A0 = subst N (sym (+-0x n)) Nn is : ∀ {m} → N (m + n) → N (succ₁ m + n) is {m} Ai = subst N (sym (+-Sx m n)) (nsucc Ai) -- Combined proof using an instance of the induction principle. postulate +-N' : ∀ {m n} → N m → N n → N (m + n) {-# ATP prove +-N' +-N-ind #-}
{ "alphanum_fraction": 0.4294507576, "avg_line_length": 32.4923076923, "ext": "agda", "hexsha": "d71e6a9ab42479cf2456e8b882bdbd094da09aca", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/AddTotality.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/AddTotality.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/AddTotality.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": 669, "size": 2112 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.Function open import lib.NType open import lib.PathGroupoid open import lib.Relation open import lib.types.Coproduct open import lib.types.Empty module lib.types.Nat where infixl 80 _+_ _+_ : ℕ → ℕ → ℕ 0 + n = n (S m) + n = S (m + n) {-# BUILTIN NATPLUS _+_ #-} abstract +-unit-r : (m : ℕ) → m + 0 == m +-unit-r 0 = idp +-unit-r (S m) = ap S (+-unit-r m) +-βr : (m n : ℕ) → m + (S n) == S (m + n) +-βr 0 n = idp +-βr (S m) n = ap S (+-βr m n) +-comm : (m n : ℕ) → m + n == n + m +-comm m 0 = +-unit-r m +-comm m (S n) = +-βr m n ∙ ap S (+-comm m n) +-assoc : (k m n : ℕ) → (k + m) + n == k + (m + n) +-assoc 0 m n = idp +-assoc (S k) m n = ap S (+-assoc k m n) -- the [+] is like [ℕ-S^] ℕ-S^' : ℕ → ℕ → ℕ ℕ-S^' O n = n ℕ-S^' (S m) n = ℕ-S^' m (S n) ℕ-pred : ℕ → ℕ ℕ-pred 0 = 0 ℕ-pred (S n) = n abstract ℕ-S-is-inj : is-inj (S :> (ℕ → ℕ)) ℕ-S-is-inj n m p = ap ℕ-pred p ℕ-S-≠ : ∀ {n m : ℕ} (p : n ≠ m) → S n ≠ S m :> ℕ ℕ-S-≠ {n} {m} p = p ∘ ℕ-S-is-inj n m private ℕ-S≠O-type : ℕ → Type₀ ℕ-S≠O-type O = Empty ℕ-S≠O-type (S n) = Unit ℕ-S≠O : (n : ℕ) → S n ≠ O ℕ-S≠O n p = transport ℕ-S≠O-type p unit ℕ-O≠S : (n : ℕ) → (O ≠ S n) ℕ-O≠S n p = ℕ-S≠O n (! p) ℕ-has-dec-eq : has-dec-eq ℕ ℕ-has-dec-eq O O = inl idp ℕ-has-dec-eq O (S n) = inr (ℕ-O≠S n) ℕ-has-dec-eq (S n) O = inr (ℕ-S≠O n) ℕ-has-dec-eq (S n) (S m) with ℕ-has-dec-eq n m ℕ-has-dec-eq (S n) (S m) | inl p = inl (ap S p) ℕ-has-dec-eq (S n) (S m) | inr ¬p = inr (ℕ-S-≠ ¬p) ℕ-is-set : is-set ℕ ℕ-is-set = dec-eq-is-set ℕ-has-dec-eq instance ℕ-level : {n : ℕ₋₂} → has-level (S (S n)) ℕ ℕ-level {⟨-2⟩} = ℕ-is-set ℕ-level {n = S n} = raise-level (S (S n)) ℕ-level {- Inequalities -} infix 40 _<_ _≤_ data _<_ : ℕ → ℕ → Type₀ where ltS : {m : ℕ} → m < (S m) ltSR : {m n : ℕ} → m < n → m < (S n) _≤_ : ℕ → ℕ → Type₀ m ≤ n = Coprod (m == n) (m < n) -- experimental: [lteE] [lteS] [lteSR] lteE : {m : ℕ} → m ≤ m lteE = inl idp lteS : {m : ℕ} → m ≤ S m lteS = inr ltS lteSR : {m n : ℕ} → m ≤ n → m ≤ (S n) lteSR (inl idp) = lteS lteSR (inr lt) = inr (ltSR lt) -- properties of [<] O<S : (m : ℕ) → O < S m O<S O = ltS O<S (S m) = ltSR (O<S m) O≤ : (m : ℕ) → O ≤ m O≤ O = inl idp O≤ (S m) = inr (O<S m) ≮O : ∀ n → ¬ (n < O) ≮O _ () S≰O : ∀ n → ¬ (S n ≤ O) S≰O _ (inl ()) S≰O _ (inr ()) <-trans : {m n k : ℕ} → m < n → n < k → m < k <-trans lt₁ ltS = ltSR lt₁ <-trans lt₁ (ltSR lt₂) = ltSR (<-trans lt₁ lt₂) ≤-refl : {m : ℕ} → m ≤ m ≤-refl = lteE ≤-trans : {m n k : ℕ} → m ≤ n → n ≤ k → m ≤ k ≤-trans (inl idp) lte₂ = lte₂ ≤-trans lte₁ (inl idp) = lte₁ ≤-trans (inr lt₁) (inr lt₂) = inr (<-trans lt₁ lt₂) private test₀ : {m n : ℕ} (m≤n : m ≤ n) → lteSR m≤n == ≤-trans m≤n lteS test₀ (inl idp) = idp test₀ (inr lt) = idp <-ap-S : {m n : ℕ} → m < n → S m < S n <-ap-S ltS = ltS <-ap-S (ltSR lt) = ltSR (<-ap-S lt) ≤-ap-S : {m n : ℕ} → m ≤ n → S m ≤ S n ≤-ap-S (inl p) = inl (ap S p) ≤-ap-S (inr lt) = inr (<-ap-S lt) <-cancel-S : {m n : ℕ} → S m < S n → m < n <-cancel-S ltS = ltS <-cancel-S (ltSR lt) = <-trans ltS lt ≤-cancel-S : {m n : ℕ} → S m ≤ S n → m ≤ n ≤-cancel-S (inl p) = inl (ap ℕ-pred p) ≤-cancel-S (inr lt) = inr (<-cancel-S lt) <-dec : Decidable _<_ <-dec _ O = inr (≮O _) <-dec O (S m) = inl (O<S m) <-dec (S n) (S m) with <-dec n m <-dec (S n) (S m) | inl p = inl (<-ap-S p) <-dec (S n) (S m) | inr ¬p = inr (¬p ∘ <-cancel-S) ≤-dec : Decidable _≤_ ≤-dec O m = inl (O≤ m) -- important for the current cohomology development ≤-dec (S n) O = inr (S≰O n) ≤-dec (S n) (S m) with ≤-dec n m ≤-dec (S n) (S m) | inl p = inl (≤-ap-S p) ≤-dec (S n) (S m) | inr ¬p = inr (¬p ∘ ≤-cancel-S) abstract <-to-≠ : {m n : ℕ} → m < n → m ≠ n <-to-≠ {m = O} ltS = ℕ-O≠S _ <-to-≠ {m = O} (ltSR lt) = ℕ-O≠S _ <-to-≠ {m = S m} {n = O} () <-to-≠ {m = S m} {n = S n} lt = ℕ-S-≠ (<-to-≠ (<-cancel-S lt)) <-to-≱ : {m n : ℕ} → m < n → ¬ (n ≤ m) <-to-≱ m<n (inl idp) = <-to-≠ m<n idp <-to-≱ m<n (inr n<m) = <-to-≠ (<-trans m<n n<m) idp <-has-all-paths : {m n : ℕ} → has-all-paths (m < n) <-has-all-paths = <-has-all-paths' idp where <-has-all-paths' : {m n₁ n₂ : ℕ} (eqn : n₁ == n₂) (lt₁ : m < n₁) (lt₂ : m < n₂) → PathOver (λ n → m < n) eqn lt₁ lt₂ <-has-all-paths' eqn ltS ltS = transport (λ eqn₁ → PathOver (_<_ _) eqn₁ ltS ltS) (prop-has-all-paths idp eqn) idp <-has-all-paths' idp ltS (ltSR lt₂) = ⊥-rec (<-to-≠ lt₂ idp) <-has-all-paths' idp (ltSR lt₁) ltS = ⊥-rec (<-to-≠ lt₁ idp) <-has-all-paths' idp (ltSR lt₁) (ltSR lt₂) = ap ltSR (<-has-all-paths' idp lt₁ lt₂) instance <-is-prop : {m n : ℕ} → is-prop (m < n) <-is-prop = all-paths-is-prop <-has-all-paths ≤-has-all-paths : {m n : ℕ} → has-all-paths (m ≤ n) ≤-has-all-paths = λ{ (inl eq₁) (inl eq₂) → ap inl (prop-has-all-paths eq₁ eq₂); (inl eq) (inr lt) → ⊥-rec (<-to-≠ lt eq); (inr lt) (inl eq) → ⊥-rec (<-to-≠ lt eq); (inr lt₁) (inr lt₂) → ap inr (<-has-all-paths lt₁ lt₂)} instance ≤-is-prop : {m n : ℕ} → is-prop (m ≤ n) ≤-is-prop = all-paths-is-prop ≤-has-all-paths <-+-l : {m n : ℕ} (k : ℕ) → m < n → (k + m) < (k + n) <-+-l O lt = lt <-+-l (S k) lt = <-ap-S (<-+-l k lt) ≤-+-l : {m n : ℕ} (k : ℕ) → m ≤ n → (k + m) ≤ (k + n) ≤-+-l k (inl p) = inl (ap (λ t → k + t) p) ≤-+-l k (inr lt) = inr (<-+-l k lt) <-+-r : {m n : ℕ} (k : ℕ) → m < n → (m + k) < (n + k) <-+-r k ltS = ltS <-+-r k (ltSR lt) = ltSR (<-+-r k lt) ≤-+-r : {m n : ℕ} (k : ℕ) → m ≤ n → (m + k) ≤ (n + k) ≤-+-r k (inl p) = inl (ap (λ t → t + k) p) ≤-+-r k (inr lt) = inr (<-+-r k lt) <-witness : {m n : ℕ} → (m < n) → Σ ℕ (λ k → S k + m == n) <-witness ltS = (O , idp) <-witness (ltSR lt) = let w' = <-witness lt in (S (fst w') , ap S (snd w')) ≤-witness : {m n : ℕ} → (m ≤ n) → Σ ℕ (λ k → k + m == n) ≤-witness (inl p) = (O , p) ≤-witness (inr lt) = let w' = <-witness lt in (S (fst w') , snd w') -- Double infix 120 _*2 _*2 : ℕ → ℕ O *2 = O (S n) *2 = S (S (n *2)) *2-increasing : (m : ℕ) → (m ≤ m *2) *2-increasing O = inl idp *2-increasing (S m) = ≤-trans (≤-ap-S (*2-increasing m)) (inr ltS) *2-monotone-< : {m n : ℕ} → m < n → m *2 < n *2 *2-monotone-< ltS = ltSR ltS *2-monotone-< (ltSR lt) = ltSR (ltSR (*2-monotone-< lt)) *2-monotone-≤ : {m n : ℕ} → m ≤ n → m *2 ≤ n *2 *2-monotone-≤ (inl p) = inl (ap _*2 p) *2-monotone-≤ (inr lt) = inr (*2-monotone-< lt) -- Trichotomy ℕ-trichotomy : (m n : ℕ) → (m == n) ⊔ ((m < n) ⊔ (n < m)) ℕ-trichotomy O O = inl idp ℕ-trichotomy O (S n) = inr (inl (O<S n)) ℕ-trichotomy (S m) O = inr (inr (O<S m)) ℕ-trichotomy (S m) (S n) with ℕ-trichotomy m n ℕ-trichotomy (S m) (S n) | inl m=n = inl (ap S m=n) ℕ-trichotomy (S m) (S n) | inr (inl m<n) = inr (inl (<-ap-S m<n)) ℕ-trichotomy (S m) (S n) | inr (inr m>n) = inr (inr (<-ap-S m>n))
{ "alphanum_fraction": 0.4735692442, "avg_line_length": 27.0354330709, "ext": "agda", "hexsha": "ea28161e2d811dc933f10d989e15971d9173839c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Nat.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3442, "size": 6867 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Basic definitions for morphisms between algebraic structures ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Core module Relation.Binary.Morphism.Definitions {a} (A : Set a) -- The domain of the morphism {b} (B : Set b) -- The codomain of the morphism where open import Algebra.Core open import Function.Base open import Level using (Level) private variable ℓ₁ ℓ₂ : Level ------------------------------------------------------------------------ -- Basic definitions Homomorphic₂ : Rel A ℓ₁ → Rel B ℓ₂ → (A → B) → Set _ Homomorphic₂ _∼₁_ _∼₂_ ⟦_⟧ = ∀ {x y} → x ∼₁ y → ⟦ x ⟧ ∼₂ ⟦ y ⟧ ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.3 Morphism : Set _ Morphism = A → B {-# WARNING_ON_USAGE Morphism "Warning: Morphism was deprecated in v1.3. Please use the standard function notation (e.g. A → B) instead." #-}
{ "alphanum_fraction": 0.4829229547, "avg_line_length": 26.2291666667, "ext": "agda", "hexsha": "9b7793982ae5ee6a7fbf5720f6dc34f737f7ee05", "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/Relation/Binary/Morphism/Definitions.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/Relation/Binary/Morphism/Definitions.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/Relation/Binary/Morphism/Definitions.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": 281, "size": 1259 }
open import Common.Equality open import Common.Prelude renaming (Nat to ℕ) infixr 4 _,_ infix 4 ,_ record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ ,_ : {A : Set} {B : A → Set} {x : A} → B x → Σ A B , y = _ , y should-be-accepted : Σ ℕ λ i → Σ ℕ λ j → Σ (i ≡ j) λ _ → Σ ℕ λ k → j ≡ k should-be-accepted = 5 , , refl , , refl _⊕_ : ℕ → ℕ → ℕ _⊕_ = _+_ _↓ : ℕ → ℕ _↓ = pred infixl 6 _⊕_ infix 6 _↓ should-also-be-accepted : ℕ should-also-be-accepted = 1 ⊕ 0 ↓ ⊕ 1 ↓ ⊕ 1 ⊕ 1 ↓ parses-correctly : should-also-be-accepted ≡ 1 parses-correctly = refl
{ "alphanum_fraction": 0.5725806452, "avg_line_length": 17.7142857143, "ext": "agda", "hexsha": "e1382697eb692a7d0db16e1e47e3cc8bd3f79425", "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/Prefix-Right-Postfix-Left.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/Prefix-Right-Postfix-Left.agda", "max_line_length": 72, "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/Prefix-Right-Postfix-Left.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": 277, "size": 620 }
module Prelude.Level where postulate Level : Set zero : Level suc : Level → Level max : Level → Level → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} {-# BUILTIN LEVELMAX max #-}
{ "alphanum_fraction": 0.604743083, "avg_line_length": 19.4615384615, "ext": "agda", "hexsha": "7ad740be5b55d10b3d18262aab86eb910d0141e8", "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/epic/Prelude/Level.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/epic/Prelude/Level.agda", "max_line_length": 31, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/epic/Prelude/Level.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": 71, "size": 253 }
module Issue705 where module A where data A : Set where open A open A
{ "alphanum_fraction": 0.7297297297, "avg_line_length": 9.25, "ext": "agda", "hexsha": "c33eff7b08d9908837fb08f4c97824b3a81914ec", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue705.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue705.agda", "max_line_length": 21, "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/fail/Issue705.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": 21, "size": 74 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.FinSetoids where -- Category of Finite Setoids, as a sub-category of Setoids open import Level open import Data.Fin.Base using (Fin) open import Data.Nat.Base using (ℕ) open import Data.Product using (Σ) open import Function.Bundles using (Inverse) open import Relation.Unary using (Pred) open import Relation.Binary.Bundles using (Setoid; module Setoid) import Relation.Binary.PropositionalEquality as ≡ open import Categories.Category.Core using (Category) open import Categories.Category.Construction.ObjectRestriction open import Categories.Category.Instance.Setoids -- The predicate that will be used IsFiniteSetoid : {c ℓ : Level} → Pred (Setoid c ℓ) (c ⊔ ℓ) IsFiniteSetoid X = Σ ℕ (λ n → Inverse X (≡.setoid (Fin n))) -- The actual Category FinSetoids : (c ℓ : Level) → Category (suc (c ⊔ ℓ)) (c ⊔ ℓ) (c ⊔ ℓ) FinSetoids c ℓ = ObjectRestriction (Setoids c ℓ) IsFiniteSetoid
{ "alphanum_fraction": 0.7544409613, "avg_line_length": 35.4444444444, "ext": "agda", "hexsha": "8c8099bb401b09ceb3d9029855698ba52aab91ec", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/FinSetoids.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/FinSetoids.agda", "max_line_length": 67, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/FinSetoids.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 264, "size": 957 }
module HeapPropertiesDefs where open import Silica import Relation.Binary.PropositionalEquality as Eq import Context open import Data.List.Relation.Unary.All import Relation.Unary import Data.List.Properties import Data.List open import Data.Sum open import Data.Maybe open import Data.List.Membership.DecSetoid ≡-decSetoid open import Data.List.Relation.Unary.Any open import Data.Empty open TypeEnvContext --============= Consistency ============== -- Relates typing environments and object references to lists of all types of possible references. -- For now, this is ordered; perhaps that is too strong and I should use <Set> instead. data _⟷_ : Type → Type → Set where symCompat : ∀ {T₁ T₂ : Type} → T₁ ⟷ T₂ --------- → T₂ ⟷ T₁ unownedCompat : ∀ {C C' : Id} → ∀ {perm perm' : Perm} → perm ≡ Unowned → C ≡ C' -------------------------------------------------------------- → contractType (tc C perm) ⟷ contractType (tc C' perm') sharedCompat : ∀ {t t' : Tc} → Tc.perm t ≡ Shared → Tc.perm t' ≡ Shared → Tc.contractName t ≡ Tc.contractName t' ---------------- → contractType t ⟷ contractType t' voidCompat : ---------------------- base Void ⟷ base Void booleanCompat : ---------------------- base Boolean ⟷ base Boolean -- ============= DEFINITIONS OF HEAP CONSISTENCY =============== ctxTypes : TypeEnv → ObjectRef → List Type ctxTypes ∅ _ = [] ctxTypes (Δ , o' ⦂ T) o with o ≟ o' ... | yes eq = [ T ] ... | no nEq = ctxTypes Δ o envTypesHelper : IndirectRefEnv → TypeEnv → ObjectRef → List Type envTypesHelper IndirectRefContext.∅ Δ o = [] envTypesHelper (IndirectRefContext._,_⦂_ ρ l (objVal o')) Δ o with (o' ≟ o) | (TypeEnvContext.lookup Δ l) ... | yes _ | just T = (T ∷ (envTypesHelper ρ Δ o)) ... | _ | _ = envTypesHelper ρ Δ o envTypesHelper (IndirectRefContext._,_⦂_ ρ l v) Δ o = envTypesHelper ρ Δ o makeEnvTypesList : RuntimeEnv → StaticEnv → ObjectRef → List Type makeEnvTypesList Σ Δ o = envTypesHelper (RuntimeEnv.ρ Σ) (StaticEnv.locEnv Δ) o -- The List IndirectRef is a list of locations that have already been used in previous calls (and are forbidden to be used again). data EnvTypes : RuntimeEnv → StaticEnv → ObjectRef → List IndirectRef → List Type → Set where envTypesConcatMatchFound : ∀ {R l T μ ρ φ ψ forbiddenRefs} → (Δ : StaticEnv) → (o : ObjectRef) → EnvTypes (re μ ρ φ ψ) Δ o (l ∷ forbiddenRefs) R → (StaticEnv.locEnv Δ) ∋ l ⦂ T → l ∉ forbiddenRefs → EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o)) φ ψ) Δ o forbiddenRefs (T ∷ R) envTypesConcatMatchNotFound : ∀ {R l μ ρ φ ψ forbiddenRefs} → (Δ : StaticEnv) → (o : ObjectRef) → EnvTypes (re μ ρ φ ψ) Δ o forbiddenRefs R → l ∉dom (StaticEnv.locEnv Δ) → EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o)) φ ψ) Δ o forbiddenRefs R envTypesConcatMismatch : ∀ {R l μ ρ φ ψ forbiddenRefs} → (Δ : StaticEnv) → (o o' : ObjectRef) → o ≢ o' → EnvTypes (re μ ρ φ ψ) Δ o forbiddenRefs R -- Mismatch in ρ, so keep looking in the rest of ρ → EnvTypes (re μ (ρ IndirectRefContext., l ⦂ (objVal o')) φ ψ) Δ o forbiddenRefs R envTypesEmpty : ∀ {μ φ ψ Δ o forbiddenRefs} → EnvTypes (re μ Context.∅ φ ψ) Δ o forbiddenRefs [] record RefTypes (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : Set where field oTypesList : List Type -- Corresponds to types from the o's in Δ. oTypes : ctxTypes (StaticEnv.objEnv Δ) o ≡ oTypesList envTypesList : List Type envTypes : EnvTypes Σ Δ o [] envTypesList fieldTypesList : List Type -- Corresponds to types from fields inside μ data IsConnectedTypeList : List Type → Set where emptyTypeList : ∀ {D} → D ≡ [] ---------- → IsConnectedTypeList D consTypeList : ∀ {T D} → All (λ T' → (T ⟷ T')) D → IsConnectedTypeList D ------------------------ → IsConnectedTypeList (T ∷ D) data IsConnectedEnvAndField (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : RefTypes Σ Δ o → Set where envTypesConnected : (R : RefTypes Σ Δ o) → IsConnectedTypeList (RefTypes.envTypesList R) → IsConnectedTypeList (RefTypes.fieldTypesList R) → All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.envTypesList R) -- all of the l types are connected to all of the field types ---------------------------------------------- → IsConnectedEnvAndField Σ Δ o R envFieldInversion1 : ∀ {Σ Δ o R} → IsConnectedEnvAndField Σ Δ o R → IsConnectedTypeList (RefTypes.envTypesList R) envFieldInversion1 (envTypesConnected R env f envField) = env envFieldInversion2 : ∀ {Σ Δ o R} → IsConnectedEnvAndField Σ Δ o R → IsConnectedTypeList (RefTypes.fieldTypesList R) envFieldInversion2 (envTypesConnected R env f envField) = f envFieldInversion3 : ∀ {Σ Δ o R} → IsConnectedEnvAndField Σ Δ o R → All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.envTypesList R) envFieldInversion3 (envTypesConnected R env f envField) = envField data IsConnected (Σ : RuntimeEnv) (Δ : StaticEnv) (o : ObjectRef) : RefTypes Σ Δ o → Set where isConnected : (R : RefTypes Σ Δ o) → IsConnectedTypeList (RefTypes.oTypesList R) → All (λ T → All (λ T' → T ⟷ T') (RefTypes.fieldTypesList R)) (RefTypes.oTypesList R) -- all of the o types are connected to all of the field types → All (λ T → All (λ T' → T ⟷ T') (RefTypes.envTypesList R)) (RefTypes.oTypesList R) -- all of the o types are connected to all of the l types → IsConnectedEnvAndField Σ Δ o R ---------------------------------------------- → IsConnected Σ Δ o R refFieldTypesHelper : ObjectRefEnv → StaticEnv → ObjectRef → List Type refFieldTypesHelper ObjectRefContext.∅ Δ o = [] refFieldTypesHelper (ObjectRefContext._,_⦂_ μ o' obj) Δ o = refFieldTypesHelper μ Δ o -- TODO; this is bogus! refFieldTypes : RuntimeEnv → StaticEnv → ObjectRef → List Type refFieldTypes Σ Δ o = refFieldTypesHelper (RuntimeEnv.μ Σ) Δ o -- ================================ OVERALL HEAP CONSISTENCY =========================== data ReferenceConsistency : RuntimeEnv → StaticEnv → ObjectRef → Set where referencesConsistent : ∀ {Σ : RuntimeEnv} → ∀ {Δ : StaticEnv} → ∀ {o : ObjectRef} → ∃[ RT ] (IsConnected Σ Δ o RT) -- TODO: add subtype constraint: C <: (refTypes Σ Δ o) --------------------------- → ReferenceConsistency Σ Δ o -- Inversion for reference consistency: connectivity referencesConsistentImpliesConnectivity : ∀ {Σ Δ o} → ReferenceConsistency Σ Δ o → ∃[ RT ] (IsConnected Σ Δ o RT) referencesConsistentImpliesConnectivity (referencesConsistent ic) = ic ------------ Global Consistency ----------- -- I'm going to need the fact that if an expression typechecks, and I find a location in it, then the location can be looked -- up in the runtime environment. But every location in the expression has to also be in the typing context, so I can state this -- without talking about expressions at all. data _&_ok : RuntimeEnv → StaticEnv → Set where ok : ∀ {Σ : RuntimeEnv} → ∀ (Δ : StaticEnv) → (∀ (l : IndirectRef) → ((StaticEnv.locEnv Δ) ∋ l ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ voidVal))) → (∀ (l : IndirectRef) → ((StaticEnv.locEnv Δ) ∋ l ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ boolVal b))) → (∀ (l : IndirectRef) → ∀ (T : Tc) → (StaticEnv.locEnv Δ) ∋ l ⦂ (contractType T) -- If a location is in Δ and has contract reference type... → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ))) -- then location can be looked up in Σ... ) → (∀ o → o ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ o) -- TODO: add remaining antecedents --------------------------- → Σ & Δ ok -- Inversion for global consistency: reference consistency refConsistency : ∀ {Σ : RuntimeEnv} → ∀ {Δ : StaticEnv} → ∀ {o : ObjectRef} → ∀ {l : IndirectRef} → Σ & Δ ok → (∀ o → o ObjectRefContext.∈dom RuntimeEnv.μ Σ → ReferenceConsistency Σ Δ o) refConsistency (ok Δ _ _ _ rc) = rc -- Inversion for global consistency : location lookup for a particular location -- If l is in Δ and Σ & Δ ok, then l can be found in Σ.ρ. locLookup : ∀ {Σ : RuntimeEnv} → ∀ {Δ : StaticEnv} → ∀ {l : IndirectRef} → ∀ {T : Tc} → Σ & Δ ok → (StaticEnv.locEnv Δ) ∋ l ⦂ (contractType T) → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ))) locLookup (ok Δ _ _ lContainment rc) lInDelta@(Z {Δ'} {x} {contractType a}) = lContainment x a lInDelta locLookup (ok Δ _ _ lContainment rc) lInDelta@(S {Δ'} {x} {y} {contractType a} {b} nEq xInRestOfDelta) = lContainment x a lInDelta voidLookup : ∀ {Σ : RuntimeEnv} → ∀ {Δ : StaticEnv} → ∀ {l : IndirectRef} → Σ & Δ ok → (StaticEnv.locEnv Δ) ∋ l ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ voidVal) voidLookup (ok Δ voidContainment _ _ _) voidType@(Z {Δ'} {l} {a}) = voidContainment l voidType voidLookup (ok Δ voidContainment _ _ _) voidType@(S {Δ'} {l} {y} {a} {b} nEq lInRestOfDelta) = voidContainment l voidType boolLookup : ∀ {Σ : RuntimeEnv} → ∀ {Δ : StaticEnv} → ∀ {l : IndirectRef} → Σ & Δ ok → (StaticEnv.locEnv Δ) ∋ l ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l ⦂ boolVal b) boolLookup (ok Δ _ boolContainment _ _) boolType@(Z {Δ'} {l} {a}) = boolContainment l boolType boolLookup (ok Δ _ boolContainment _ _) boolType@(S {Δ'} {l} {y} {a} {b} nEq lInRestOfDelta) = boolContainment l boolType
{ "alphanum_fraction": 0.5270153634, "avg_line_length": 47.4836065574, "ext": "agda", "hexsha": "cabd5b92d8c1396ad756f9dcd89aa7375bf57da2", "lang": "Agda", "max_forks_count": 11, "max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z", "max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z", "max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ivoysey/Obsidian", "max_forks_repo_path": "formalization/heapPropertiesDefs.agda", "max_issues_count": 259, "max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z", "max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "ivoysey/Obsidian", "max_issues_repo_path": "formalization/heapPropertiesDefs.agda", "max_line_length": 173, "max_stars_count": 79, "max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ivoysey/Obsidian", "max_stars_repo_path": "formalization/heapPropertiesDefs.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z", "max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z", "num_tokens": 3137, "size": 11586 }
open import Issue983-Bad
{ "alphanum_fraction": 0.84, "avg_line_length": 12.5, "ext": "agda", "hexsha": "740bf5594a55cc48cb05f4ae2d6cd72d73dab0a4", "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/Issue983.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/Issue983.agda", "max_line_length": 24, "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/Issue983.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 7, "size": 25 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Groups.Sn where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Connected open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Prelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.Pushout open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2 ; map to sMap) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) hiding (map) open import Cubical.Relation.Nullary open import Cubical.Data.Sum hiding (map) open import Cubical.Data.Empty renaming (rec to ⊥-rec) open import Cubical.Data.Bool open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc) open import Cubical.Data.Nat open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec) open import Cubical.Data.Unit open import Cubical.Homotopy.Connected open import Cubical.Algebra.Group infixr 31 _□_ _□_ : _ _□_ = compGroupIso open GroupEquiv open vSES open GroupIso open GroupHom open BijectionIso Sn-connected : (n : ℕ) (x : typ (S₊∙ (suc n))) → ∥ pt (S₊∙ (suc n)) ≡ x ∥₁ Sn-connected zero = toPropElim (λ _ → propTruncIsProp) ∣ refl ∣₁ Sn-connected (suc zero) = suspToPropElim base (λ _ → propTruncIsProp) ∣ refl ∣₁ Sn-connected (suc (suc n)) = suspToPropElim north (λ _ → propTruncIsProp) ∣ refl ∣₁ suspensionAx-Sn : (n m : ℕ) → GroupIso (coHomGr (2 + n) (S₊ (2 + m))) (coHomGr (suc n) (S₊ (suc m))) suspensionAx-Sn n m = Iso+Hom→GrIso (compIso (setTruncIso (invIso funSpaceSuspIso)) helperIso) funIsHom where helperIso : Iso ∥ (Σ[ x ∈ coHomK (2 + n) ] Σ[ y ∈ coHomK (2 + n) ] (S₊ (suc m) → x ≡ y)) ∥₂ (coHom (suc n) (S₊ (suc m))) Iso.fun helperIso = sRec setTruncIsSet (uncurry (coHomK-elim _ (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelPlus' {n = n} 2 setTruncIsSet) (uncurry (coHomK-elim _ (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelPlus' {n = n} 2 setTruncIsSet) λ f → ∣ (λ x → ΩKn+1→Kn (suc n) (f x)) ∣₂)))) Iso.inv helperIso = sMap λ f → (0ₖ _) , (0ₖ _ , λ x → Kn→ΩKn+1 (suc n) (f x)) Iso.rightInv helperIso = coHomPointedElim _ (ptSn (suc m)) (λ _ → setTruncIsSet _ _) λ f fId → cong ∣_∣₂ (funExt (λ x → Iso.leftInv (Iso-Kn-ΩKn+1 _) (f x))) Iso.leftInv helperIso = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) (uncurry (coHomK-elim _ (λ _ → isProp→isOfHLevelSuc (suc n) (isPropΠ λ _ → setTruncIsSet _ _)) (uncurry (coHomK-elim _ (λ _ → isProp→isOfHLevelSuc (suc n) (isPropΠ λ _ → setTruncIsSet _ _)) λ f → cong ∣_∣₂ (ΣPathP (refl , ΣPathP (refl , (λ i x → Iso.rightInv (Iso-Kn-ΩKn+1 (suc n)) (f x) i)))))))) theFun : coHom (2 + n) (S₊ (2 + m)) → coHom (suc n) (S₊ (suc m)) theFun = Iso.fun (compIso (setTruncIso (invIso funSpaceSuspIso)) helperIso) funIsHom : (x y : coHom (2 + n) (S₊ (2 + m))) → theFun (x +ₕ y) ≡ theFun x +ₕ theFun y funIsHom = coHomPointedElimSⁿ _ _ (λ _ → isPropΠ λ _ → setTruncIsSet _ _) λ f → coHomPointedElimSⁿ _ _ (λ _ → setTruncIsSet _ _) λ g → cong ∣_∣₂ (funExt λ x → cong (ΩKn+1→Kn (suc n)) (sym (∙≡+₂ n (f x) (g x))) ∙ ΩKn+1→Kn-hom (suc n) (f x) (g x)) H⁰-Sⁿ≅ℤ : (n : ℕ) → GroupIso (coHomGr 0 (S₊ (suc n))) intGroup H⁰-Sⁿ≅ℤ zero = H⁰-connected base (Sn-connected 0) H⁰-Sⁿ≅ℤ (suc n) = H⁰-connected north (Sn-connected (suc n)) -- -- ---------------------------------------------------------------------- --- We will need to switch between Sⁿ defined using suspensions and using pushouts --- in order to apply Mayer Vietoris. S1Iso : Iso S¹ (Pushout {A = Bool} (λ _ → tt) λ _ → tt) S1Iso = S¹IsoSuspBool ⋄ invIso PushoutSuspIsoSusp coHomPushout≅coHomSn : (n m : ℕ) → GroupIso (coHomGr m (S₊ (suc n))) (coHomGr m (Pushout {A = S₊ n} (λ _ → tt) λ _ → tt)) coHomPushout≅coHomSn zero m = Iso+Hom→GrIso (setTruncIso (domIso S1Iso)) (sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl)) coHomPushout≅coHomSn (suc n) m = Iso+Hom→GrIso (setTruncIso (domIso (invIso PushoutSuspIsoSusp))) (sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl)) -------------------------- H⁰(S⁰) ----------------------------- S0→Int : (a : Int × Int) → S₊ 0 → Int S0→Int a true = fst a S0→Int a false = snd a H⁰-S⁰≅ℤ×ℤ : GroupIso (coHomGr 0 (S₊ 0)) (dirProd intGroup intGroup) fun (map H⁰-S⁰≅ℤ×ℤ) = sRec (isSet× isSetInt isSetInt) λ f → (f true) , (f false) isHom (map H⁰-S⁰≅ℤ×ℤ) = sElim2 (λ _ _ → isSet→isGroupoid (isSet× isSetInt isSetInt) _ _) λ a b → refl inv H⁰-S⁰≅ℤ×ℤ a = ∣ S0→Int a ∣₂ rightInv H⁰-S⁰≅ℤ×ℤ _ = refl leftInv H⁰-S⁰≅ℤ×ℤ = sElim (λ _ → isSet→isGroupoid setTruncIsSet _ _) λ f → cong ∣_∣₂ (funExt (λ {true → refl ; false → refl})) ------------------------- H¹(S⁰) ≅ 0 ------------------------------- private Hⁿ-S0≃Kₙ×Kₙ : (n : ℕ) → Iso (S₊ 0 → coHomK (suc n)) (coHomK (suc n) × coHomK (suc n)) Iso.fun (Hⁿ-S0≃Kₙ×Kₙ n) f = (f true) , (f false) Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) true = a Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) false = b Iso.rightInv (Hⁿ-S0≃Kₙ×Kₙ n) a = refl Iso.leftInv (Hⁿ-S0≃Kₙ×Kₙ n) b = funExt λ {true → refl ; false → refl} isContrHⁿ-S0 : (n : ℕ) → isContr (coHom (suc n) (S₊ 0)) isContrHⁿ-S0 n = isContrRetract (Iso.fun (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n))) (Iso.inv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n))) (Iso.leftInv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n))) (isContrHelper n) where isContrHelper : (n : ℕ) → isContr (∥ (coHomK (suc n) × coHomK (suc n)) ∥₂) fst (isContrHelper zero) = ∣ (0₁ , 0₁) ∣₂ snd (isContrHelper zero) = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ y → elim2 {B = λ x y → ∣ (0₁ , 0₁) ∣₂ ≡ ∣(x , y) ∣₂ } (λ _ _ → isOfHLevelPlus {n = 2} 2 setTruncIsSet _ _) (toPropElim2 (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y) isContrHelper (suc zero) = ∣ (0₂ , 0₂) ∣₂ , sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ y → elim2 {B = λ x y → ∣ (0₂ , 0₂) ∣₂ ≡ ∣(x , y) ∣₂ } (λ _ _ → isOfHLevelPlus {n = 2} 3 setTruncIsSet _ _) (suspToPropElim2 base (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y) isContrHelper (suc (suc n)) = ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂ , sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ y → elim2 {B = λ x y → ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂ ≡ ∣(x , y) ∣₂ } (λ _ _ → isProp→isOfHLevelSuc (4 + n) (setTruncIsSet _ _)) (suspToPropElim2 north (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y) H¹-S⁰≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) (S₊ 0)) trivialGroup H¹-S⁰≅0 n = IsoContrGroupTrivialGroup (isContrHⁿ-S0 n) ------------------------- H²(S¹) ≅ 0 ------------------------------- Hⁿ-S¹≅0 : (n : ℕ) → GroupIso (coHomGr (2 + n) (S₊ 1)) trivialGroup Hⁿ-S¹≅0 n = IsoContrGroupTrivialGroup (isOfHLevelRetractFromIso 0 helper (_ , helper2)) where helper : Iso ⟨ coHomGr (2 + n) (S₊ 1)⟩ ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂ helper = compIso (setTruncIso IsoFunSpaceS¹) IsoSetTruncateSndΣ helper2 : (x : ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂) → ∣ ∣ north ∣ , ∣ refl ∣₂ ∣₂ ≡ x helper2 = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) (uncurry (trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isProp→isOfHLevelSuc (3 + n) (setTruncIsSet _ _)) (suspToPropElim (ptSn (suc n)) (λ _ → isPropΠ λ _ → setTruncIsSet _ _) (sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ p → cong ∣_∣₂ (ΣPathP (refl , isContr→isProp helper3 _ _)))))) where helper4 : isConnected (n + 3) (hLevelTrunc (4 + n) (S₊ (2 + n))) helper4 = subst (λ m → isConnected m (hLevelTrunc (4 + n) (S₊ (2 + n)))) (+-comm 3 n) (isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (3 + n) 1)) (sphereConnected (2 + n))) helper3 : isContr ∥ ∣ north ∣ ≡ ∣ north ∣ ∥₂ helper3 = isOfHLevelRetractFromIso 0 setTruncTrunc2Iso (isConnectedPath 2 (isConnectedSubtr 3 n helper4) _ _) -- --------------- H¹(Sⁿ), n ≥ 1 -------------------------------------------- H¹-Sⁿ≅0 : (n : ℕ) → GroupIso (coHomGr 1 (S₊ (2 + n))) trivialGroup H¹-Sⁿ≅0 zero = IsoContrGroupTrivialGroup isContrH¹S² where isContrH¹S² : isContr ⟨ coHomGr 1 (S₊ 2) ⟩ isContrH¹S² = ∣ (λ _ → ∣ base ∣) ∣₂ , coHomPointedElim 0 north (λ _ → setTruncIsSet _ _) λ f p → cong ∣_∣₂ (funExt λ x → sym p ∙∙ sym (spoke f north) ∙∙ spoke f x) H¹-Sⁿ≅0 (suc n) = IsoContrGroupTrivialGroup isContrH¹S³⁺ⁿ where anIso : Iso ⟨ coHomGr 1 (S₊ (3 + n)) ⟩ ∥ (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1)) ∥₂ anIso = setTruncIso (codomainIso (invIso (truncIdempotentIso (4 + n) (isOfHLevelPlus' {n = 1 + n} 3 (isOfHLevelTrunc 3))))) isContrH¹S³⁺ⁿ-ish : (f : (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1))) → ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂ isContrH¹S³⁺ⁿ-ish f = ind (f north) refl where ind : (x : hLevelTrunc (4 + n) (coHomK 1)) → x ≡ f north → ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂ ind = trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelPlus' {n = (3 + n)} 1 (setTruncIsSet _ _)) (trElim (λ _ → isOfHLevelΠ 3 λ _ → isOfHLevelPlus {n = 1} 2 (setTruncIsSet _ _)) (toPropElim (λ _ → isPropΠ λ _ → setTruncIsSet _ _) λ p → cong ∣_∣₂ (funExt λ x → p ∙∙ sym (spoke f north) ∙∙ spoke f x))) isContrH¹S³⁺ⁿ : isContr ⟨ coHomGr 1 (S₊ (3 + n)) ⟩ isContrH¹S³⁺ⁿ = isOfHLevelRetractFromIso 0 anIso (∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ , sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) isContrH¹S³⁺ⁿ-ish) --------- H¹(S¹) ≅ ℤ ------- {- Idea : H¹(S¹) := ∥ S¹ → K₁ ∥₂ ≃ ∥ S¹ → S¹ ∥₂ ≃ ∥ S¹ × ℤ ∥₂ ≃ ∥ S¹ ∥₂ × ∥ ℤ ∥₂ ≃ ℤ -} coHom1S1≃ℤ : GroupIso (coHomGr 1 (S₊ 1)) intGroup coHom1S1≃ℤ = theIso where F = Iso.fun S¹→S¹≡S¹×Int F⁻ = Iso.inv S¹→S¹≡S¹×Int theIso : GroupIso (coHomGr 1 (S₊ 1)) intGroup fun (map theIso) = sRec isSetInt (λ f → snd (F f)) isHom (map theIso) = coHomPointedElimS¹2 _ (λ _ _ → isSetInt _ _) λ p q → (λ i → winding (guy ∣ base ∣ (cong S¹map (help p q i)))) ∙∙ (λ i → winding (guy ∣ base ∣ (congFunct S¹map p q i))) ∙∙ winding-hom (guy ∣ base ∣ (cong S¹map p)) (guy ∣ base ∣ (cong S¹map q)) where guy = basechange2⁻ ∘ S¹map help : (p q : Path (coHomK 1) ∣ base ∣ ∣ base ∣) → cong₂ _+ₖ_ p q ≡ p ∙ q help p q = cong₂Funct _+ₖ_ p q ∙ (λ i → cong (λ x → rUnitₖ 1 x i) p ∙ cong (λ x → lUnitₖ 1 x i) q) inv theIso a = ∣ (F⁻ (base , a)) ∣₂ rightInv theIso a = cong snd (Iso.rightInv S¹→S¹≡S¹×Int (base , a)) leftInv theIso = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f → cong ((sRec setTruncIsSet ∣_∣₂) ∘ sRec setTruncIsSet λ x → ∣ F⁻ (x , (snd (F f))) ∣₂) (Iso.inv PathIdTrunc₀Iso (isConnectedS¹ (fst (F f)))) ∙ cong ∣_∣₂ (Iso.leftInv S¹→S¹≡S¹×Int f) ---------------------------- Hⁿ(Sⁿ) ≅ ℤ , n ≥ 1 ------------------- Hⁿ-Sⁿ≅ℤ : (n : ℕ) → GroupIso (coHomGr (suc n) (S₊ (suc n))) intGroup Hⁿ-Sⁿ≅ℤ zero = coHom1S1≃ℤ Hⁿ-Sⁿ≅ℤ (suc n) = suspensionAx-Sn n n □ Hⁿ-Sⁿ≅ℤ n -------------- Hⁿ(Sᵐ) ≅ ℤ for n , m ≥ 1 with n ≠ m ---------------- Hⁿ-Sᵐ≅0 : (n m : ℕ) → ¬ (n ≡ m) → GroupIso (coHomGr (suc n) (S₊ (suc m))) trivialGroup Hⁿ-Sᵐ≅0 zero zero pf = ⊥-rec (pf refl) Hⁿ-Sᵐ≅0 zero (suc m) pf = H¹-Sⁿ≅0 m Hⁿ-Sᵐ≅0 (suc n) zero pf = Hⁿ-S¹≅0 n Hⁿ-Sᵐ≅0 (suc n) (suc m) pf = suspensionAx-Sn n m □ Hⁿ-Sᵐ≅0 n m λ p → pf (cong suc p)
{ "alphanum_fraction": 0.5372670807, "avg_line_length": 44.6013513514, "ext": "agda", "hexsha": "c1a6624c00acc26dc70bfdfad58a6c12c66af29b", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Sn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "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": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Sn.agda", "max_line_length": 133, "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/ZCohomology/Groups/Sn.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5381, "size": 13202 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The basic code for equational reasoning with two relations: -- equality and some other ordering. ------------------------------------------------------------------------ -- -- See `Data.Nat.Properties` or `Relation.Binary.Reasoning.PartialOrder` -- for examples of how to instantiate this module. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Base.Double {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_∼_ : Rel A ℓ₂} (isPreorder : IsPreorder _≈_ _∼_) where open import Data.Product using (proj₁; proj₂) open import Level using (Level; _⊔_; Lift; lift) open import Function.Base using (case_of_; id) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (True; toWitness) open IsPreorder isPreorder ------------------------------------------------------------------------ -- A datatype to hide the current relation type infix 4 _IsRelatedTo_ data _IsRelatedTo_ (x y : A) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where nonstrict : (x∼y : x ∼ y) → x IsRelatedTo y equals : (x≈y : x ≈ y) → x IsRelatedTo y ------------------------------------------------------------------------ -- A record that is used to ensure that the final relation proved by the -- chain of reasoning can be converted into the required relation. data IsEquality {x y} : x IsRelatedTo y → Set (a ⊔ ℓ₁ ⊔ ℓ₂) where isEquality : ∀ x≈y → IsEquality (equals x≈y) IsEquality? : ∀ {x y} (x≲y : x IsRelatedTo y) → Dec (IsEquality x≲y) IsEquality? (nonstrict _) = no λ() IsEquality? (equals x≈y) = yes (isEquality x≈y) extractEquality : ∀ {x y} {x≲y : x IsRelatedTo y} → IsEquality x≲y → x ≈ y extractEquality (isEquality x≈y) = x≈y ------------------------------------------------------------------------ -- Reasoning combinators -- See `Relation.Binary.Reasoning.Base.Partial` for the design decisions -- behind these combinators. infix 1 begin_ begin-equality_ infixr 2 step-∼ step-≈ step-≈˘ step-≡ step-≡˘ _≡⟨⟩_ infix 3 _∎ -- Beginnings of various types of proofs begin_ : ∀ {x y} (r : x IsRelatedTo y) → x ∼ y begin (nonstrict x∼y) = x∼y begin (equals x≈y) = reflexive x≈y begin-equality_ : ∀ {x y} (r : x IsRelatedTo y) → {s : True (IsEquality? r)} → x ≈ y begin-equality_ r {s} = extractEquality (toWitness s) -- Step with the main relation step-∼ : ∀ (x : A) {y z} → y IsRelatedTo z → x ∼ y → x IsRelatedTo z step-∼ x (nonstrict y∼z) x∼y = nonstrict (trans x∼y y∼z) step-∼ x (equals y≈z) x∼y = nonstrict (∼-respʳ-≈ y≈z x∼y) -- Step with the setoid equality step-≈ : ∀ (x : A) {y z} → y IsRelatedTo z → x ≈ y → x IsRelatedTo z step-≈ x (nonstrict y∼z) x≈y = nonstrict (∼-respˡ-≈ (Eq.sym x≈y) y∼z) step-≈ x (equals y≈z) x≈y = equals (Eq.trans x≈y y≈z) -- Flipped step with the setoid equality step-≈˘ : ∀ x {y z} → y IsRelatedTo z → y ≈ x → x IsRelatedTo z step-≈˘ x y∼z x≈y = step-≈ x y∼z (Eq.sym x≈y) -- Step with non-trivial propositional equality step-≡ : ∀ (x : A) {y z} → y IsRelatedTo z → x ≡ y → x IsRelatedTo z step-≡ x (nonstrict y∼z) x≡y = nonstrict (case x≡y of λ where refl → y∼z) step-≡ x (equals y≈z) x≡y = equals (case x≡y of λ where refl → y≈z) -- Flipped step with non-trivial propositional equality step-≡˘ : ∀ x {y z} → y IsRelatedTo z → y ≡ x → x IsRelatedTo z step-≡˘ x y∼z x≡y = step-≡ x y∼z (sym x≡y) -- Step with trivial propositional equality _≡⟨⟩_ : ∀ (x : A) {y} → x IsRelatedTo y → x IsRelatedTo y x ≡⟨⟩ x≲y = x≲y -- Termination step _∎ : ∀ x → x IsRelatedTo x x ∎ = equals Eq.refl -- Syntax declarations syntax step-∼ x y∼z x∼y = x ∼⟨ x∼y ⟩ y∼z syntax step-≈ x y∼z x≈y = x ≈⟨ x≈y ⟩ y∼z syntax step-≈˘ x y∼z y≈x = x ≈˘⟨ y≈x ⟩ y∼z syntax step-≡ x y∼z x≡y = x ≡⟨ x≡y ⟩ y∼z syntax step-≡˘ x y∼z y≡x = x ≡˘⟨ y≡x ⟩ y∼z
{ "alphanum_fraction": 0.5869344179, "avg_line_length": 33.9137931034, "ext": "agda", "hexsha": "f30636ba6436a378e3fd77354816d21423813e52", "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/Relation/Binary/Reasoning/Base/Double.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/Relation/Binary/Reasoning/Base/Double.agda", "max_line_length": 84, "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/Relation/Binary/Reasoning/Base/Double.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": 1463, "size": 3934 }
{-# OPTIONS --allow-unsolved-metas #-} module Issue501 where record ⊤ : Set where constructor tt data _⊎_ (A : Set) (B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B [_,_] : ∀ {A : Set} {B : Set} {C : A ⊎ B → Set} → ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) → ((x : A ⊎ B) → C x) [ f , g ] (inj₁ x) = f x [ f , g ] (inj₂ y) = g y ------------------------------------------------------------------------ Pow : Set → Set₁ Pow X = X → Set -- Replacing /Pow I/ with /X → Set/ below makes the file load. -- data _:=_ {I : Set}(A : Set)(i : I) : I → Set where data _:=_ {I : Set}(A : Set)(i : I) : Pow I where ⟨_⟩ : (x : A) → (A := i) i postulate S : Set s : S D : Pow S → Pow S P : Pow S m : D P s _>>=_ : ∀ {A B s} → D A s → (∀ {s} → A s → D B s) → D B s p : D P s p = m >>= λ k → [ (λ { ⟨ x ⟩ → {!!} }) , {!!} ] {!!}
{ "alphanum_fraction": 0.3765227021, "avg_line_length": 23.7631578947, "ext": "agda", "hexsha": "984c6f49de66ad190ab24156dbe82cd74f837ad6", "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/Issue501.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/Issue501.agda", "max_line_length": 72, "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/Issue501.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": 380, "size": 903 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties satisfied by meet semilattices ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Lattice module Relation.Binary.Properties.MeetSemilattice {c ℓ₁ ℓ₂} (M : MeetSemilattice c ℓ₁ ℓ₂) where open MeetSemilattice M import Algebra.FunctionProperties as P; open P _≈_ open import Data.Product open import Function using (flip) open import Relation.Binary open import Relation.Binary.Properties.Poset poset import Relation.Binary.Properties.JoinSemilattice as J -- The dual construction is a join semilattice. dualIsJoinSemilattice : IsJoinSemilattice _≈_ (flip _≤_) _∧_ dualIsJoinSemilattice = record { isPartialOrder = invIsPartialOrder ; supremum = infimum } dualJoinSemilattice : JoinSemilattice c ℓ₁ ℓ₂ dualJoinSemilattice = record { _∨_ = _∧_ ; isJoinSemilattice = dualIsJoinSemilattice } open J dualJoinSemilattice public using (isAlgSemilattice; algSemilattice) renaming ( ∨-monotonic to ∧-monotonic ; ∨-cong to ∧-cong ; ∨-comm to ∧-comm ; ∨-assoc to ∧-assoc ; ∨-idempotent to ∧-idempotent ; x≤y⇒x∨y≈y to y≤x⇒x∧y≈y )
{ "alphanum_fraction": 0.6329787234, "avg_line_length": 28, "ext": "agda", "hexsha": "2509e1d93ec2bad2c914129a7e98a7e0a3ba6284", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/MeetSemilattice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 389, "size": 1316 }
{-# OPTIONS --safe #-} module Cubical.Data.Int.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Transport open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Empty open import Cubical.Data.Nat hiding (+-assoc ; +-comm ; ·-comm) renaming (_·_ to _·ℕ_; _+_ to _+ℕ_ ; ·-assoc to ·ℕ-assoc) open import Cubical.Data.Bool open import Cubical.Data.Sum open import Cubical.Data.Int.Base open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq sucPred : ∀ i → sucℤ (predℤ i) ≡ i sucPred (pos zero) = refl sucPred (pos (suc n)) = refl sucPred (negsuc n) = refl predSuc : ∀ i → predℤ (sucℤ i) ≡ i predSuc (pos n) = refl predSuc (negsuc zero) = refl predSuc (negsuc (suc n)) = refl injPos : ∀ {a b : ℕ} → pos a ≡ pos b → a ≡ b injPos {a} h = subst T h refl where T : ℤ → Type₀ T (pos x) = a ≡ x T (negsuc _) = ⊥ injNegsuc : ∀ {a b : ℕ} → negsuc a ≡ negsuc b → a ≡ b injNegsuc {a} h = subst T h refl where T : ℤ → Type₀ T (pos _) = ⊥ T (negsuc x) = a ≡ x posNotnegsuc : ∀ (a b : ℕ) → ¬ (pos a ≡ negsuc b) posNotnegsuc a b h = subst T h 0 where T : ℤ → Type₀ T (pos _) = ℕ T (negsuc _) = ⊥ negsucNotpos : ∀ (a b : ℕ) → ¬ (negsuc a ≡ pos b) negsucNotpos a b h = subst T h 0 where T : ℤ → Type₀ T (pos _) = ⊥ T (negsuc _) = ℕ discreteℤ : Discrete ℤ discreteℤ (pos n) (pos m) with discreteℕ n m ... | yes p = yes (cong pos p) ... | no p = no (λ x → p (injPos x)) discreteℤ (pos n) (negsuc m) = no (posNotnegsuc n m) discreteℤ (negsuc n) (pos m) = no (negsucNotpos n m) discreteℤ (negsuc n) (negsuc m) with discreteℕ n m ... | yes p = yes (cong negsuc p) ... | no p = no (λ x → p (injNegsuc x)) isSetℤ : isSet ℤ isSetℤ = Discrete→isSet discreteℤ -pos : ∀ n → - (pos n) ≡ neg n -pos zero = refl -pos (suc n) = refl -neg : ∀ n → - (neg n) ≡ pos n -neg zero = refl -neg (suc n) = refl -Involutive : ∀ z → - (- z) ≡ z -Involutive (pos n) = cong -_ (-pos n) ∙ -neg n -Involutive (negsuc n) = refl sucℤ+pos : ∀ n m → sucℤ (m +pos n) ≡ (sucℤ m) +pos n sucℤ+pos zero m = refl sucℤ+pos (suc n) m = cong sucℤ (sucℤ+pos n m) predℤ+negsuc : ∀ n m → predℤ (m +negsuc n) ≡ (predℤ m) +negsuc n predℤ+negsuc zero m = refl predℤ+negsuc (suc n) m = cong predℤ (predℤ+negsuc n m) sucℤ+negsuc : ∀ n m → sucℤ (m +negsuc n) ≡ (sucℤ m) +negsuc n sucℤ+negsuc zero m = (sucPred _) ∙ (sym (predSuc _)) sucℤ+negsuc (suc n) m = _ ≡⟨ sucPred _ ⟩ m +negsuc n ≡[ i ]⟨ predSuc m (~ i) +negsuc n ⟩ (predℤ (sucℤ m)) +negsuc n ≡⟨ sym (predℤ+negsuc n (sucℤ m)) ⟩ predℤ (sucℤ m +negsuc n) ∎ predℤ+pos : ∀ n m → predℤ (m +pos n) ≡ (predℤ m) +pos n predℤ+pos zero m = refl predℤ+pos (suc n) m = _ ≡⟨ predSuc _ ⟩ m +pos n ≡[ i ]⟨ sucPred m (~ i) + pos n ⟩ (sucℤ (predℤ m)) +pos n ≡⟨ sym (sucℤ+pos n (predℤ m))⟩ (predℤ m) +pos (suc n) ∎ predℤ-pos : ∀ n → predℤ(- (pos n)) ≡ negsuc n predℤ-pos zero = refl predℤ-pos (suc n) = refl predℤ+ : ∀ m n → predℤ (m + n) ≡ (predℤ m) + n predℤ+ m (pos n) = predℤ+pos n m predℤ+ m (negsuc n) = predℤ+negsuc n m +predℤ : ∀ m n → predℤ (m + n) ≡ m + (predℤ n) +predℤ m (pos zero) = refl +predℤ m (pos (suc n)) = (predSuc (m + pos n)) ∙ (cong (_+_ m) (sym (predSuc (pos n)))) +predℤ m (negsuc n) = refl sucℤ+ : ∀ m n → sucℤ (m + n) ≡ (sucℤ m) + n sucℤ+ m (pos n) = sucℤ+pos n m sucℤ+ m (negsuc n) = sucℤ+negsuc n m +sucℤ : ∀ m n → sucℤ (m + n) ≡ m + (sucℤ n) +sucℤ m (pos n) = refl +sucℤ m (negsuc zero) = sucPred _ +sucℤ m (negsuc (suc n)) = (sucPred (m +negsuc n)) ∙ (cong (_+_ m) (sym (sucPred (negsuc n)))) pos0+ : ∀ z → z ≡ pos 0 + z pos0+ (pos zero) = refl pos0+ (pos (suc n)) = cong sucℤ (pos0+ (pos n)) pos0+ (negsuc zero) = refl pos0+ (negsuc (suc n)) = cong predℤ (pos0+ (negsuc n)) negsuc0+ : ∀ z → predℤ z ≡ negsuc 0 + z negsuc0+ (pos zero) = refl negsuc0+ (pos (suc n)) = (sym (sucPred (pos n))) ∙ (cong sucℤ (negsuc0+ _)) negsuc0+ (negsuc zero) = refl negsuc0+ (negsuc (suc n)) = cong predℤ (negsuc0+ (negsuc n)) ind-comm : {A : Type₀} (_∙_ : A → A → A) (f : ℕ → A) (g : A → A) (p : ∀ {n} → f (suc n) ≡ g (f n)) (g∙ : ∀ a b → g (a ∙ b) ≡ g a ∙ b) (∙g : ∀ a b → g (a ∙ b) ≡ a ∙ g b) (base : ∀ z → z ∙ f 0 ≡ f 0 ∙ z) → ∀ z n → z ∙ f n ≡ f n ∙ z ind-comm _∙_ f g p g∙ ∙g base z 0 = base z ind-comm _∙_ f g p g∙ ∙g base z (suc n) = z ∙ f (suc n) ≡[ i ]⟨ z ∙ p {n} i ⟩ z ∙ g (f n) ≡⟨ sym ( ∙g z (f n)) ⟩ g (z ∙ f n) ≡⟨ cong g IH ⟩ g (f n ∙ z) ≡⟨ g∙ (f n) z ⟩ g (f n) ∙ z ≡[ i ]⟨ p {n} (~ i) ∙ z ⟩ f (suc n) ∙ z ∎ where IH = ind-comm _∙_ f g p g∙ ∙g base z n ind-assoc : {A : Type₀} (_·_ : A → A → A) (f : ℕ → A) (g : A → A) (p : ∀ a b → g (a · b) ≡ a · (g b)) (q : ∀ {c} → f (suc c) ≡ g (f c)) (base : ∀ m n → (m · n) · (f 0) ≡ m · (n · (f 0))) (m n : A) (o : ℕ) → m · (n · (f o)) ≡ (m · n) · (f o) ind-assoc _·_ f g p q base m n 0 = sym (base m n) ind-assoc _·_ f g p q base m n (suc o) = m · (n · (f (suc o))) ≡[ i ]⟨ m · (n · q {o} i) ⟩ m · (n · (g (f o))) ≡[ i ]⟨ m · (p n (f o) (~ i)) ⟩ m · (g (n · (f o))) ≡⟨ sym (p m (n · (f o)))⟩ g (m · (n · (f o))) ≡⟨ cong g IH ⟩ g ((m · n) · (f o)) ≡⟨ p (m · n) (f o) ⟩ (m · n) · (g (f o)) ≡[ i ]⟨ (m · n) · q {o} (~ i) ⟩ (m · n) · (f (suc o)) ∎ where IH = ind-assoc _·_ f g p q base m n o +Comm : ∀ m n → m + n ≡ n + m +Comm m (pos n) = ind-comm _+_ pos sucℤ refl sucℤ+ +sucℤ pos0+ m n +Comm m (negsuc n) = ind-comm _+_ negsuc predℤ refl predℤ+ +predℤ negsuc0+ m n +Assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o +Assoc m n (pos o) = ind-assoc _+_ pos sucℤ +sucℤ refl (λ _ _ → refl) m n o +Assoc m n (negsuc o) = ind-assoc _+_ negsuc predℤ +predℤ refl +predℤ m n o -- Compose sucPathℤ with itself n times. Transporting along this -- will be addition, transporting with it backwards will be subtraction. -- Use this to define _+'_ for which is easier to prove -- isEquiv (λ n → n +' m) since _+'_ is defined by transport sucPathℤ : ℤ ≡ ℤ sucPathℤ = ua (sucℤ , isoToIsEquiv (iso sucℤ predℤ sucPred predSuc)) addEq : ℕ → ℤ ≡ ℤ addEq zero = refl addEq (suc n) = (addEq n) ∙ sucPathℤ predPathℤ : ℤ ≡ ℤ predPathℤ = ua (predℤ , isoToIsEquiv (iso predℤ sucℤ predSuc sucPred)) subEq : ℕ → ℤ ≡ ℤ subEq zero = refl subEq (suc n) = (subEq n) ∙ predPathℤ _+'_ : ℤ → ℤ → ℤ m +' pos n = transport (addEq n) m m +' negsuc n = transport (subEq (suc n)) m +'≡+ : _+'_ ≡ _+_ +'≡+ i m (pos zero) = m +'≡+ i m (pos (suc n)) = sucℤ (+'≡+ i m (pos n)) +'≡+ i m (negsuc zero) = predℤ m +'≡+ i m (negsuc (suc n)) = predℤ (+'≡+ i m (negsuc n)) -- -- compPath (λ i → (+'≡+ i (predℤ m) (negsuc n))) (sym (predℤ+negsuc n m)) i isEquivAddℤ' : (m : ℤ) → isEquiv (λ n → n +' m) isEquivAddℤ' (pos n) = isEquivTransport (addEq n) isEquivAddℤ' (negsuc n) = isEquivTransport (subEq (suc n)) isEquivAddℤ : (m : ℤ) → isEquiv (λ n → n + m) isEquivAddℤ = subst (λ add → (m : ℤ) → isEquiv (λ n → add n m)) +'≡+ isEquivAddℤ' -- below is an alternate proof of isEquivAddℤ for comparison -- We also have two useful lemma here. minusPlus : ∀ m n → (n - m) + m ≡ n minusPlus (pos zero) n = refl minusPlus (pos 1) = sucPred minusPlus (pos (suc (suc m))) n = sucℤ ((n +negsuc (suc m)) +pos (suc m)) ≡⟨ sucℤ+pos (suc m) _ ⟩ sucℤ (n +negsuc (suc m)) +pos (suc m) ≡[ i ]⟨ sucPred (n +negsuc m) i +pos (suc m) ⟩ (n - pos (suc m)) +pos (suc m) ≡⟨ minusPlus (pos (suc m)) n ⟩ n ∎ minusPlus (negsuc zero) = predSuc minusPlus (negsuc (suc m)) n = predℤ (sucℤ (sucℤ (n +pos m)) +negsuc m) ≡⟨ predℤ+negsuc m _ ⟩ predℤ (sucℤ (sucℤ (n +pos m))) +negsuc m ≡[ i ]⟨ predSuc (sucℤ (n +pos m)) i +negsuc m ⟩ sucℤ (n +pos m) +negsuc m ≡⟨ minusPlus (negsuc m) n ⟩ n ∎ plusMinus : ∀ m n → (n + m) - m ≡ n plusMinus (pos zero) n = refl plusMinus (pos (suc m)) = minusPlus (negsuc m) plusMinus (negsuc m) = minusPlus (pos (suc m)) private alternateProof : (m : ℤ) → isEquiv (λ n → n + m) alternateProof m = isoToIsEquiv (iso (λ n → n + m) (λ n → n - m) (minusPlus m) (plusMinus m)) -Cancel : ∀ z → z - z ≡ 0 -Cancel z = cong (_- z) (pos0+ z) ∙ plusMinus z (pos zero) pos+ : ∀ m n → pos (m +ℕ n) ≡ pos m + pos n pos+ zero zero = refl pos+ zero (suc n) = pos (zero +ℕ suc n) ≡⟨ +Comm (pos (suc n)) (pos zero) ⟩ pos zero + pos (suc n) ∎ pos+ (suc m) zero = pos (suc (m +ℕ zero)) ≡⟨ cong pos (cong suc (+-zero m)) ⟩ pos (suc m) + pos zero ∎ pos+ (suc m) (suc n) = pos (suc m +ℕ suc n) ≡⟨ cong pos (cong suc (+-suc m n)) ⟩ sucℤ (pos (suc (m +ℕ n))) ≡⟨ cong sucℤ (cong sucℤ (pos+ m n)) ⟩ sucℤ (sucℤ (pos m + pos n)) ≡⟨ sucℤ+ (pos m) (sucℤ (pos n)) ⟩ pos (suc m) + pos (suc n) ∎ negsuc+ : ∀ m n → negsuc (m +ℕ n) ≡ negsuc m - pos n negsuc+ zero zero = refl negsuc+ zero (suc n) = negsuc (zero +ℕ suc n) ≡⟨ negsuc0+ (negsuc n) ⟩ negsuc zero + negsuc n ≡⟨ cong (negsuc zero +_) (-pos (suc n)) ⟩ negsuc zero - pos (suc n) ∎ negsuc+ (suc m) zero = negsuc (suc m +ℕ zero) ≡⟨ cong negsuc (cong suc (+-zero m)) ⟩ negsuc (suc m) - pos zero ∎ negsuc+ (suc m) (suc n) = negsuc (suc m +ℕ suc n) ≡⟨ cong negsuc (sym (+-suc m (suc n))) ⟩ negsuc (m +ℕ suc (suc n)) ≡⟨ negsuc+ m (suc (suc n)) ⟩ negsuc m - pos (suc (suc n)) ≡⟨ sym (+predℤ (negsuc m) (negsuc n)) ⟩ predℤ (negsuc m + negsuc n ) ≡⟨ predℤ+ (negsuc m) (negsuc n) ⟩ negsuc (suc m) - pos (suc n) ∎ neg+ : ∀ m n → neg (m +ℕ n) ≡ neg m + neg n neg+ zero zero = refl neg+ zero (suc n) = neg (zero +ℕ suc n) ≡⟨ +Comm (neg (suc n)) (pos zero) ⟩ neg zero + neg (suc n) ∎ neg+ (suc m) zero = neg (suc (m +ℕ zero)) ≡⟨ cong neg (cong suc (+-zero m)) ⟩ neg (suc m) + neg zero ∎ neg+ (suc m) (suc n) = neg (suc m +ℕ suc n) ≡⟨ negsuc+ m (suc n) ⟩ neg (suc m) + neg (suc n) ∎ ℕ-AntiComm : ∀ m n → m ℕ- n ≡ - (n ℕ- m) ℕ-AntiComm zero zero = refl ℕ-AntiComm zero (suc n) = refl ℕ-AntiComm (suc m) zero = refl ℕ-AntiComm (suc m) (suc n) = suc m ℕ- suc n ≡⟨ ℕ-AntiComm m n ⟩ - (suc n ℕ- suc m) ∎ pos- : ∀ m n → m ℕ- n ≡ pos m - pos n pos- zero zero = refl pos- zero (suc n) = zero ℕ- suc n ≡⟨ +Comm (negsuc n) (pos zero) ⟩ pos zero - pos (suc n) ∎ pos- (suc m) zero = refl pos- (suc m) (suc n) = suc m ℕ- suc n ≡⟨ pos- m n ⟩ pos m - pos n ≡⟨ sym (sucPred (pos m - pos n)) ⟩ sucℤ (predℤ (pos m - pos n)) ≡⟨ cong sucℤ (+predℤ (pos m) (- pos n)) ⟩ sucℤ (pos m + predℤ (- (pos n))) ≡⟨ cong sucℤ (cong (pos m +_) (predℤ-pos n)) ⟩ sucℤ (pos m + negsuc n) ≡⟨ sucℤ+negsuc n (pos m) ⟩ pos (suc m) - pos (suc n) ∎ -AntiComm : ∀ m n → m - n ≡ - (n - m) -AntiComm (pos n) (pos m) = pos n - pos m ≡⟨ sym (pos- n m) ⟩ n ℕ- m ≡⟨ ℕ-AntiComm n m ⟩ - (m ℕ- n) ≡⟨ cong -_ (pos- m n) ⟩ - (pos m - pos n) ∎ -AntiComm (pos n) (negsuc m) = pos n - negsuc m ≡⟨ +Comm (pos n) (pos (suc m)) ⟩ pos (suc m) + pos n ≡⟨ sym (pos+ (suc m) n) ⟩ pos (suc m +ℕ n) ≡⟨ sym (-neg (suc m +ℕ n)) ⟩ - neg (suc m +ℕ n) ≡⟨ cong -_ (neg+ (suc m) n) ⟩ - (neg (suc m) + neg n) ≡⟨ cong -_ (cong (negsuc m +_) (sym (-pos n))) ⟩ - (negsuc m - pos n) ∎ -AntiComm (negsuc n) (pos m) = negsuc n - pos m ≡⟨ sym (negsuc+ n m) ⟩ negsuc (n +ℕ m) ≡⟨ cong -_ (pos+ (suc n) m) ⟩ - (pos (suc n) + pos m) ≡⟨ cong -_ (+Comm (pos (suc n)) (pos m)) ⟩ - (pos m - negsuc n) ∎ -AntiComm (negsuc n) (negsuc m) = negsuc n - negsuc m ≡⟨ +Comm (negsuc n) (pos (suc m)) ⟩ pos (suc m) + negsuc n ≡⟨ sym (pos- (suc m) (suc n)) ⟩ suc m ℕ- suc n ≡⟨ ℕ-AntiComm (suc m) (suc n) ⟩ - (suc n ℕ- suc m) ≡⟨ cong -_ (pos- (suc n) (suc m)) ⟩ - (pos (suc n) - pos (suc m)) ≡⟨ cong -_ (+Comm (pos (suc n)) (negsuc m)) ⟩ - (negsuc m - negsuc n) ∎ -Dist+ : ∀ m n → - (m + n) ≡ (- m) + (- n) -Dist+ (pos n) (pos m) = - (pos n + pos m) ≡⟨ cong -_ (sym (pos+ n m)) ⟩ - pos (n +ℕ m) ≡⟨ -pos (n +ℕ m) ⟩ neg (n +ℕ m) ≡⟨ neg+ n m ⟩ neg n + neg m ≡⟨ cong (neg n +_) (sym (-pos m)) ⟩ neg n + (- pos m) ≡⟨ cong (_+ (- pos m)) (sym (-pos n)) ⟩ (- pos n) + (- pos m) ∎ -Dist+ (pos n) (negsuc m) = - (pos n + negsuc m) ≡⟨ sym (-AntiComm (pos (suc m)) (pos n)) ⟩ pos (suc m) - pos n ≡⟨ +Comm (pos (suc m)) (- pos n) ⟩ (- pos n) + (- negsuc m) ∎ -Dist+ (negsuc n) (pos m) = - (negsuc n + pos m) ≡⟨ cong -_ (+Comm (negsuc n) (pos m)) ⟩ - (pos m + negsuc n) ≡⟨ sym (-AntiComm (- negsuc n) (pos m)) ⟩ (- negsuc n) + (- pos m) ∎ -Dist+ (negsuc n) (negsuc m) = - (negsuc n + negsuc m) ≡⟨ cong -_ (sym (neg+ (suc n) (suc m))) ⟩ - neg (suc n +ℕ suc m) ≡⟨ pos+ (suc n) (suc m) ⟩ (- negsuc n) + (- negsuc m) ∎ -- multiplication pos·negsuc : (n m : ℕ) → pos n · negsuc m ≡ - (pos n · pos (suc m)) pos·negsuc zero m = refl pos·negsuc (suc n) m = (λ i → negsuc m + (pos·negsuc n m i)) ∙ sym (-Dist+ (pos (suc m)) (pos n · pos (suc m))) negsuc·pos : (n m : ℕ) → negsuc n · pos m ≡ - (pos (suc n) · pos m) negsuc·pos zero m = refl negsuc·pos (suc n) m = cong ((- pos m) +_) (negsuc·pos n m) ∙ sym (-Dist+ (pos m) (pos m + (pos n · pos m))) negsuc·negsuc : (n m : ℕ) → negsuc n · negsuc m ≡ pos (suc n) · pos (suc m) negsuc·negsuc zero m = refl negsuc·negsuc (suc n) m = cong (pos (suc m) +_) (negsuc·negsuc n m) ·Comm : (x y : ℤ) → x · y ≡ y · x ·Comm (pos n) (pos m) = lem n m where lem : (n m : ℕ) → (pos n · pos m) ≡ (pos m · pos n) lem zero zero = refl lem zero (suc m) i = +Comm (lem zero m i) (pos zero) i lem (suc n) zero i = +Comm (pos zero) (lem n zero i) i lem (suc n) (suc m) = (λ i → pos (suc m) + (lem n (suc m) i)) ∙∙ +Assoc (pos (suc m)) (pos n) (pos m · pos n) ∙∙ (λ i → sucℤ+ (pos m) (pos n) (~ i) + (pos m · pos n)) ∙∙ (λ i → +Comm (pos m) (pos (suc n)) i + (pos m · pos n)) ∙∙ sym (+Assoc (pos (suc n)) (pos m) (pos m · pos n)) ∙∙ (λ i → pos (suc n) + (pos m + (lem n m (~ i)))) ∙∙ λ i → pos (suc n) + (lem (suc n) m i) ·Comm (pos n) (negsuc m) = pos·negsuc n m ∙∙ cong -_ (·Comm (pos n) (pos (suc m))) ∙∙ sym (negsuc·pos m n) ·Comm (negsuc n) (pos m) = sym (pos·negsuc m n ∙∙ cong -_ (·Comm (pos m) (pos (suc n))) ∙∙ sym (negsuc·pos n m)) ·Comm (negsuc n) (negsuc m) = negsuc·negsuc n m ∙∙ ·Comm (pos (suc n)) (pos (suc m)) ∙∙ sym (negsuc·negsuc m n) ·Rid : (x : ℤ) → x · 1 ≡ x ·Rid x = ·Comm x 1 private distrHelper : (x y z w : ℤ) → (x + y) + (z + w) ≡ ((x + z) + (y + w)) distrHelper x y z w = +Assoc (x + y) z w ∙∙ cong (_+ w) (sym (+Assoc x y z) ∙∙ cong (x +_) (+Comm y z) ∙∙ +Assoc x z y) ∙∙ sym (+Assoc (x + z) y w) ·DistR+ : (x y z : ℤ) → x · (y + z) ≡ x · y + x · z ·DistR+ (pos zero) y z = refl ·DistR+ (pos (suc n)) y z = cong ((y + z) +_) (·DistR+ (pos n) y z) ∙ distrHelper y z (pos n · y) (pos n · z) ·DistR+ (negsuc zero) y z = -Dist+ y z ·DistR+ (negsuc (suc n)) y z = cong₂ _+_ (-Dist+ y z) (·DistR+ (negsuc n) y z) ∙ distrHelper (- y) (- z) (negsuc n · y) (negsuc n · z) ·DistL+ : (x y z : ℤ) → (x + y) · z ≡ x · z + y · z ·DistL+ x y z = ·Comm (x + y) z ∙∙ ·DistR+ z x y ∙∙ cong₂ _+_ (·Comm z x) (·Comm z y) -DistL· : (b c : ℤ) → - (b · c) ≡ - b · c -DistL· (pos zero) c = refl -DistL· (pos (suc n)) (pos m) = sym (negsuc·pos n m) -DistL· (pos (suc zero)) (negsuc m) = -Dist+ (negsuc m) (pos zero · negsuc m) ∙ cong (pos (suc m) +_) (-DistL· (pos zero) (negsuc m)) -DistL· (pos (suc (suc n))) (negsuc m) = -Dist+ (negsuc m) (pos (suc n) · negsuc m) ∙ cong (pos (suc m) +_) (-DistL· (pos (suc n)) (negsuc m)) -DistL· (negsuc zero) c = -Involutive c -DistL· (negsuc (suc n)) c = -Dist+ (- c) (negsuc n · c) ∙∙ cong (_+ (- (negsuc n · c))) (-Involutive c) ∙∙ cong (c +_) (-DistL· (negsuc n) c) -DistR· : (b c : ℤ) → - (b · c) ≡ b · - c -DistR· b c = cong (-_) (·Comm b c) ∙∙ -DistL· c b ∙∙ ·Comm (- c) b ·Assoc : (a b c : ℤ) → (a · (b · c)) ≡ ((a · b) · c) ·Assoc (pos zero) b c = refl ·Assoc (pos (suc n)) b c = cong ((b · c) +_) (·Assoc (pos n) b c) ∙∙ cong₂ _+_ (·Comm b c) (·Comm (pos n · b) c) ∙∙ sym (·DistR+ c b (pos n · b)) ∙ sym (·Comm _ c) ·Assoc (negsuc zero) = -DistL· ·Assoc (negsuc (suc n)) b c = cong ((- (b · c)) +_) (·Assoc (negsuc n) b c) ∙∙ cong (_+ ((negsuc n · b) · c)) (-DistL· b c) ∙∙ sym (·DistL+ (- b) (negsuc n · b) c) minus≡0- : (x : ℤ) → - x ≡ (0 - x) minus≡0- x = +Comm (- x) 0 -- Absolute values abs→⊎ : (x : ℤ) (n : ℕ) → abs x ≡ n → (x ≡ pos n) ⊎ (x ≡ - pos n) abs→⊎ x n = J (λ n _ → (x ≡ pos n) ⊎ (x ≡ - pos n)) (help x) where help : (x : ℤ) → (x ≡ pos (abs x)) ⊎ (x ≡ - pos (abs x)) help (pos n) = inl refl help (negsuc n) = inr refl ⊎→abs : (x : ℤ) (n : ℕ) → (x ≡ pos n) ⊎ (x ≡ - pos n) → abs x ≡ n ⊎→abs (pos n₁) n (inl x₁) = cong abs x₁ ⊎→abs (negsuc n₁) n (inl x₁) = cong abs x₁ ⊎→abs x zero (inr x₁) = cong abs x₁ ⊎→abs x (suc n) (inr x₁) = cong abs x₁
{ "alphanum_fraction": 0.4987755567, "avg_line_length": 36.8886554622, "ext": "agda", "hexsha": "9c8f316c89f5b472d9cd2fd52dc8af46aae10d8f", "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/Data/Int/Properties.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/Data/Int/Properties.agda", "max_line_length": 94, "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/Data/Int/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8454, "size": 17559 }
{- Constructor-headedness and projection-likeness don't play well together. Unless they are kept apart or their differences can be reconciled this example will leave unsolved metas. The problem is that invoking constructor-headedness on a projection-like the dropped arguments won't be checked (or rather, the type of the eliminatee, which is where the dropped arguments live, isn't checked). -} module ProjectionLikeAndConstructorHeaded where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ data Fin : ℕ → Set where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) data ⊥ : Set where record ⊤ : Set where data Dec (P : Set) : Set where yes : ( p : P) → Dec P no : (¬p : P → ⊥) → Dec P data Bool : Set where false true : Bool T : Bool → Set T true = ⊤ T false = ⊥ ⌊_⌋ : ∀ {P : Set} → Dec P → Bool ⌊ yes _ ⌋ = true ⌊ no _ ⌋ = false True : ∀ {P : Set} → Dec P → Set True Q = T ⌊ Q ⌋ toWitness : ∀ {P : Set} {Q : Dec P} → True Q → P toWitness {Q = yes p} _ = p toWitness {Q = no _} () postulate _≤_ : ℕ → ℕ → Set fromℕ≤ : ∀ {m n} → m ≤ n → Fin n _≤?_ : ∀ n m → Dec (n ≤ m) #_ : ∀ m {n} {m<n : True (m ≤? n)} → Fin n #_ m {n} {m<n = m<n} = fromℕ≤ {_} {n} (toWitness {_ ≤ n} {_} m<n)
{ "alphanum_fraction": 0.5802861685, "avg_line_length": 24.6666666667, "ext": "agda", "hexsha": "51677b14eb09e921efcb810eb6b8e9d56e3b9fc0", "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/ProjectionLikeAndConstructorHeaded.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/ProjectionLikeAndConstructorHeaded.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/ProjectionLikeAndConstructorHeaded.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": 480, "size": 1258 }
-- Andreas, 2016-07-29, issue #1720 reported by Mietek Bak {-# OPTIONS --double-check #-} postulate A : Set B : A → Set a0 : A b0 : B a0 record R (a1 : A) (b1 : B a1) : Set where field fa : A a : A a = {!a1!} field fb : B fa b : B {!!} b = {!b1!} field f : A -- Problem: -- Interaction points are doubled.
{ "alphanum_fraction": 0.5280235988, "avg_line_length": 12.5555555556, "ext": "agda", "hexsha": "92420bde059f02cb99e2935f48da9bd31c607e9a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/interaction/Issue1720-2.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/interaction/Issue1720-2.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/interaction/Issue1720-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 134, "size": 339 }
------------------------------------------------------------------------------ -- A stronger (maybe invalid) principle for ≈-coind ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Relation.Binary.Bisimilarity.Type where open import FOTC.Base open import FOTC.Base.List open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ -- A stronger (maybe invalid) principle for ≈-coind. postulate ≈-stronger-coind : ∀ (B : D → D → Set) {xs ys} → (B xs ys → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ B xs' ys') → B xs ys → xs ≈ ys
{ "alphanum_fraction": 0.4150058617, "avg_line_length": 35.5416666667, "ext": "agda", "hexsha": "9a002968f50a0fb6b8bd8f9967ad28646545d03e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Relation/Binary/Bisimilarity/Type.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Relation/Binary/Bisimilarity/Type.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Relation/Binary/Bisimilarity/Type.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": 204, "size": 853 }
open import Data.Product using ( _×_ ; _,_ ) open import FRP.LTL.ISet.Core using ( ISet ; MSet ; [_] ; _⇛_ ; _,_ ) open import FRP.LTL.Time using ( _+_ ; +-resp-≤ ; +-resp-< ) open import FRP.LTL.Time.Bound using ( Time∞ ; +∞ ; fin ; _≼_ ; _≺_ ; +∞-top ; ≤-impl-≼ ; t≺+∞ ; ≺-impl-⋡ ; ≺-impl-< ; <-impl-≺ ) open import FRP.LTL.Time.Interval using ( Interval ; [_⟩ ; _⊑_ ; _~_ ; _⌢_∵_ ; _,_ ) open import FRP.LTL.Util using ( ⊥-elim ) open import Relation.Binary.PropositionalEquality using ( refl ) module FRP.LTL.ISet.Next where -- ○ A is "A holds at the next point in time" next : Time∞ → Time∞ next +∞ = +∞ next (fin t) = fin (t + 1) next-resp-≼ : ∀ {t u} → (t ≼ u) → (next t ≼ next u) next-resp-≼ +∞-top = +∞-top next-resp-≼ (≤-impl-≼ t≤u) = ≤-impl-≼ (+-resp-≤ t≤u 1) next-resp-≺ : ∀ {t u} → (t ≺ u) → (next t ≺ next u) next-resp-≺ {+∞} t≺u = ⊥-elim (≺-impl-⋡ t≺u +∞-top) next-resp-≺ {fin t} {+∞} t≺u = t≺+∞ next-resp-≺ {fin t} {fin u} t≺u = <-impl-≺ (+-resp-< (≺-impl-< t≺u) 1) Next : MSet → MSet Next (A , split , subsum) = (○A , ○split , ○subsum) where ○A : Interval → Set ○A [ s≺t ⟩ = A [ next-resp-≺ s≺t ⟩ ○split : ∀ i j i~j → ○A (i ⌢ j ∵ i~j) → (○A i × ○A j) ○split [ s≺t ⟩ [ t≺u ⟩ refl = split [ next-resp-≺ s≺t ⟩ [ next-resp-≺ t≺u ⟩ refl ○subsum : ∀ i j → (i ⊑ j) → ○A j → ○A i ○subsum [ s≺t ⟩ [ r≺u ⟩ (r≼s , t≼u) = subsum [ next-resp-≺ s≺t ⟩ [ next-resp-≺ r≺u ⟩ (next-resp-≼ r≼s , next-resp-≼ t≼u) ○ : ISet → ISet ○ ([ A ]) = [ Next A ] ○ (A ⇛ B) = Next A ⇛ ○ B
{ "alphanum_fraction": 0.4983734548, "avg_line_length": 34.9318181818, "ext": "agda", "hexsha": "eeabcebf589e6e22d457fbd884cd864e07c3073c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_line_length": 95, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/ISet/Next.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 796, "size": 1537 }
-- Intuitionistic logic, PHOAS approach, initial encoding module Pi.I (Indiv : Set) where -- Types data Ty : Set Pred : Set Pred = Indiv -> Ty infixl 2 _&&_ infixl 1 _||_ infixr 0 _=>_ data Ty where UNIT : Ty _=>_ : Ty -> Ty -> Ty _&&_ : Ty -> Ty -> Ty _||_ : Ty -> Ty -> Ty FALSE : Ty FORALL : Pred -> Ty EXISTS : Pred -> Ty infixr 0 _<=>_ _<=>_ : Ty -> Ty -> Ty a <=> b = (a => b) && (b => a) NOT : Ty -> Ty NOT a = a => FALSE TRUE : Ty TRUE = FALSE => FALSE -- Context and truth/individual judgement data El : Set where mkTrue : Ty -> El mkIndiv : Indiv -> El Cx : Set1 Cx = El -> Set isTrue : Ty -> Cx -> Set isTrue a tc = tc (mkTrue a) isIndiv : Indiv -> Cx -> Set isIndiv x tc = tc (mkIndiv x) -- Terms module I where infixl 2 _$$_ infixl 1 _$_ data Tm (tc : Cx) : Ty -> Set where var : forall {a} -> isTrue a tc -> Tm tc a lam' : forall {a b} -> (isTrue a tc -> Tm tc b) -> Tm tc (a => b) _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b) fst : forall {a b} -> Tm tc (a && b) -> Tm tc a snd : forall {a b} -> Tm tc (a && b) -> Tm tc b left : forall {a b} -> Tm tc a -> Tm tc (a || b) right : forall {a b} -> Tm tc b -> Tm tc (a || b) case' : forall {a b c} -> Tm tc (a || b) -> (isTrue a tc -> Tm tc c) -> (isTrue b tc -> Tm tc c) -> Tm tc c pi' : forall {p} -> (forall {x} -> isIndiv x tc -> Tm tc (p x)) -> Tm tc (FORALL p) _$$_ : forall {p x} -> Tm tc (FORALL p) -> isIndiv x tc -> Tm tc (p x) sig' : forall {p x} -> isIndiv x tc -> Tm tc (p x) -> Tm tc (EXISTS p) split' : forall {p x a} -> Tm tc (EXISTS p) -> (isTrue (p x) tc -> Tm tc a) -> Tm tc a abort : forall {a} -> Tm tc FALSE -> Tm tc a lam'' : forall {tc a b} -> (Tm tc a -> Tm tc b) -> Tm tc (a => b) lam'' f = lam' \x -> f (var x) case'' : forall {tc a b c} -> Tm tc (a || b) -> (Tm tc a -> Tm tc c) -> (Tm tc b -> Tm tc c) -> Tm tc c case'' xy f g = case' xy (\x -> f (var x)) (\y -> g (var y)) split'' : forall {tc p x a} -> Tm tc (EXISTS p) -> (Tm tc (p x) -> Tm tc a) -> Tm tc a split'' x f = split' x \y -> f (var y) syntax lam'' (\a -> b) = lam a => b syntax pair' x y = [ x , y ] syntax case'' xy (\x -> z1) (\y -> z2) = case xy of x => z1 or y => z2 syntax pi' (\x -> px) = pi x => px syntax sig' x px = [ x ,, px ] syntax split'' x (\y -> z) = split x as y => z Thm : Ty -> Set1 Thm a = forall {tc} -> Tm tc a open I public -- Example theorems t214 : forall {p q : Pred} -> Thm ( FORALL (\x -> p x || NOT (p x)) && FORALL (\x -> p x => EXISTS (\y -> q y)) => FORALL (\x -> EXISTS (\y -> p x => q y))) t214 = lam fg => pi x => case fst fg $$ x of px => split snd fg $$ x $ px as qy => [ x ,, lam _ => qy ] or npx => [ x ,, lam px => abort (npx $ px) ] l5 : forall {a} -> Thm (a && FALSE <=> FALSE) l5 = [ lam xnt => snd xnt , lam nt => abort nt ] l10 : forall {a} -> Thm (a || FALSE <=> a) l10 = [ lam xnt => case xnt of x => x or nt => abort nt , lam x => left x ] l20 : forall {a} -> Thm ((FALSE => a) <=> TRUE) l20 = [ lam _ => lam nt => nt , lam _ => lam nt => abort nt ]
{ "alphanum_fraction": 0.4349525405, "avg_line_length": 27.5538461538, "ext": "agda", "hexsha": "4a4423f17d49d7de62a12b074cb1ecb7fd1dd595", "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/Pi/I.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/Pi/I.agda", "max_line_length": 114, "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/Pi/I.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": 1361, "size": 3582 }
{-# OPTIONS --cubical --allow-unsolved-metas --postfix-projections #-} module Data.Row where open import Prelude open import Data.Nat.Properties using (snotz) open import Data.Bool.Properties using (isPropT) infixr 5 _∷_ data Row (A : Type a) : Type a where [] : Row A _∷_ : A → Row A → Row A swap : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs record Alg {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where constructor algebra field [_]_∷_⟨_⟩ : (x : A) → (xs : Row A) → (P⟨xs⟩ : P xs) → P (x ∷ xs) [_][] : P [] private _∷_⟨_⟩ = [_]_∷_⟨_⟩ Swap-Coh : Type _ Swap-Coh = ∀ x y xs (P⟨xs⟩ : P xs) → PathP (λ i → P (swap x y xs i)) (x ∷ (y ∷ xs) ⟨ y ∷ xs ⟨ P⟨xs⟩ ⟩ ⟩) (y ∷ (x ∷ xs) ⟨ x ∷ xs ⟨ P⟨xs⟩ ⟩ ⟩) open Alg infixr 2 ψ record ψ {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where constructor elim field alg : Alg A P field swap-coh : Swap-Coh alg [_] : ∀ xs → P xs [ [] ] = [ alg ][] [ x ∷ xs ] = [ alg ] x ∷ xs ⟨ [ xs ] ⟩ [ swap x y xs i ] = swap-coh x y xs [ xs ] i syntax ψ ty (λ v → e) = ψ[ v ⦂ ty ] e open ψ record ψ-prop {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where constructor elim-prop field p-alg : Alg A P is-prop : ∀ xs → isProp (P xs) prop-swap-coh : Swap-Coh p-alg prop-swap-coh x y xs P⟨xs⟩ = toPathP (is-prop _ (transp (λ i → P (swap x y xs i)) i0 _) _) to-elim : ψ A P to-elim = elim p-alg prop-swap-coh ∥_∥⇓ : ∀ xs → P xs ∥_∥⇓ = [ to-elim ] syntax ψ-prop ty (λ v → e) = ψ[ v ⦂ ty ]∥ e ∥ open ψ-prop foldr : (f : A → B → B) (n : B) (p : ∀ x y xs → f x (f y xs) ≡ f y (f x xs)) → Row A → B foldr f n p = [ elim (algebra (λ x _ xs → f x xs) n) (λ x y _ → p x y) ] length : Row A → ℕ length = foldr (const suc) zero λ _ _ _ → refl infixr 5 _∈_ _∉_ _∈_ : A → Row A → Type _ x ∈ xs = ∃ ys × (x ∷ ys ≡ xs) _∉_ : A → Row A → Type _ x ∉ xs = ¬ (x ∈ xs) union-alg : (ys : Row A) → ψ[ xs ⦂ A ] Row A [ union-alg ys .alg ] x ∷ xs ⟨ P⟨xs⟩ ⟩ = x ∷ P⟨xs⟩ [ union-alg ys .alg ][] = ys union-alg ys .swap-coh x y xs pxs = swap x y pxs _∪_ : Row A → Row A → Row A xs ∪ ys = [ union-alg ys ] xs open import Data.List using (List; _∷_; []) import Data.List as List unorder : List A → Row A unorder = List.foldr _∷_ [] infix 4 _↭_ _↭_ : List A → List A → Type _ xs ↭ ys = unorder xs ≡ unorder ys ↭-refl : {xs : List A} → xs ↭ xs ↭-refl = refl ↭-sym : {xs ys : List A} → xs ↭ ys → ys ↭ xs ↭-sym = sym ↭-trans : {xs ys zs : List A} → xs ↭ ys → ys ↭ zs → xs ↭ zs ↭-trans = _;_ ↭-swap : ∀ {x y : A} {xs} → x ∷ y ∷ xs ↭ y ∷ x ∷ xs ↭-swap = swap _ _ _ open import Relation.Nullary.Decidable.Logic module _ (_≟_ : Discrete A) where _⁻ : A → ψ[ xs ⦂ A ] Row A [ (x ⁻) .alg ] y ∷ xs ⟨ P⟨xs⟩ ⟩ = if does (x ≟ y) then xs else y ∷ P⟨xs⟩ [ (x ⁻) .alg ][] = [] (x ⁻) .swap-coh y z xs pxs with x ≟ y | x ≟ z (x ⁻) .swap-coh y z xs pxs | no _ | no _ = swap y z pxs (x ⁻) .swap-coh y z xs pxs | no _ | yes _ = refl (x ⁻) .swap-coh y z xs pxs | yes _ | no _ = refl (x ⁻) .swap-coh y z xs pxs | yes x≡y | yes x≡z = cong (Row._∷ xs) (sym x≡z ; x≡y) rem-cons : ∀ x xs → [ x ⁻ ] (x ∷ xs) ≡ xs rem-cons x xs with x ≟ x ... | yes _ = refl ... | no ¬p = ⊥-elim (¬p refl) rem-swap : ∀ x y xs → x ≢ y → x ∷ [ y ⁻ ] xs ≡ [ y ⁻ ] (x ∷ xs) rem-swap x y xs x≢y with y ≟ x rem-swap x y xs x≢y | yes x≡y = ⊥-elim (x≢y (sym x≡y)) rem-swap x y xs x≢y | no _ = refl ∷-inj : ∀ x xs ys → x ∷ xs ≡ x ∷ ys → xs ≡ ys ∷-inj x xs ys p with x ≟ x | cong [ x ⁻ ] p ∷-inj x xs ys p | yes _ | q = q ∷-inj x xs ys p | no ¬p | q = ⊥-elim (¬p refl) elem-push : ∀ x y (xs : Row A) → x ≢ y → x ∉ xs → x ∉ y ∷ xs elem-push x y xs x≢y x∉xs (ys , x∷ys≡y∷xs) = let q = rem-swap x y ys x≢y ; cong [ y ⁻ ] x∷ys≡y∷xs ; rem-cons y xs in x∉xs ([ y ⁻ ] ys , q) elem-alg : ∀ x → Alg A (λ xs → Dec (x ∈ xs)) [ elem-alg x ] y ∷ xs ⟨ P⟨xs⟩ ⟩ = disj (λ x≡y → (xs , cong (_∷ xs) x≡y)) (λ { (ys , x∷ys≡xs) → y ∷ ys , swap x y ys ; cong (y ∷_) x∷ys≡xs }) (elem-push x y xs) (x ≟ y) P⟨xs⟩ [ elem-alg x ][] = no (snotz ∘ cong length ∘ snd)
{ "alphanum_fraction": 0.4951124145, "avg_line_length": 28.8169014085, "ext": "agda", "hexsha": "528face292b3ad9b69329ad41ea632f03ae6604c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Row.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Row.agda", "max_line_length": 175, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Row.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1963, "size": 4092 }
-- Andreas, 2012-09-24 Ensure that size successor is monotone -- Andreas, 2015-03-16 SizeUniv is still imperfect, so we need type-in-type -- here to work around the conflation of sLub and the PTS rule. {-# OPTIONS --type-in-type #-} module SizeSucMonotone where open import Common.Size data Bool : Set where true false : Bool -- T should be monotone in its second arg T : Bool → Size → Set T true i = (Size< i → Bool) → Bool T false i = (Size< (↑ i) → Bool) → Bool test : {x : Bool}{i : Size}{j : Size< i} → T x j → T x i test h = h
{ "alphanum_fraction": 0.6563071298, "avg_line_length": 24.8636363636, "ext": "agda", "hexsha": "99b4c71603bec37160e423e636b9fadf3574592d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/SizeSucMonotone.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/SizeSucMonotone.agda", "max_line_length": 75, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/SizeSucMonotone.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": 174, "size": 547 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Dependent product combinators for setoid equality preserving -- functions ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Function.Dependent.Setoid where open import Data.Product open import Data.Product.Relation.Binary.Pointwise.Dependent open import Relation.Binary open import Function open import Function.Equality as F using (_⟶_; _⟨$⟩_) open import Function.Equivalence as Eq using (Equivalence; _⇔_; module Equivalence) open import Function.Injection as Inj using (Injection; Injective; _↣_; module Injection) open import Function.Inverse as Inv using (Inverse; _↔_; module Inverse) open import Function.LeftInverse as LeftInv using (LeftInverse; _↞_; _LeftInverseOf_; _RightInverseOf_; module LeftInverse) open import Function.Surjection as Surj using (Surjection; _↠_; module Surjection) open import Relation.Binary as B open import Relation.Binary.Indexed.Heterogeneous using (IndexedSetoid) open import Relation.Binary.Indexed.Heterogeneous.Construct.At using (_atₛ_) open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- Properties related to "relatedness" ------------------------------------------------------------------------ private subst-cong : ∀ {i a p} {I : Set i} {A : I → Set a} (P : ∀ {i} → A i → A i → Set p) {i i′} {x y : A i} (i≡i′ : i ≡ i′) → P x y → P (P.subst A i≡i′ x) (P.subst A i≡i′ y) subst-cong P P.refl p = p ⟶ : ∀ {a₁ a₂ b₁ b₁′ b₂ b₂′} {A₁ : Set a₁} {A₂ : Set a₂} {B₁ : IndexedSetoid A₁ b₁ b₁′} (B₂ : IndexedSetoid A₂ b₂ b₂′) (f : A₁ → A₂) → (∀ {x} → (B₁ atₛ x) ⟶ (B₂ atₛ (f x))) → setoid (P.setoid A₁) B₁ ⟶ setoid (P.setoid A₂) B₂ ⟶ {A₁ = A₁} {A₂} {B₁} B₂ f g = record { _⟨$⟩_ = fg ; cong = fg-cong } where open B.Setoid (setoid (P.setoid A₁) B₁) using () renaming (_≈_ to _≈₁_) open B.Setoid (setoid (P.setoid A₂) B₂) using () renaming (_≈_ to _≈₂_) open B using (_=[_]⇒_) fg = map f (_⟨$⟩_ g) fg-cong : _≈₁_ =[ fg ]⇒ _≈₂_ fg-cong (P.refl , ∼) = (P.refl , F.cong g ∼) module _ {a₁ a₂ b₁ b₁′ b₂ b₂′} {A₁ : Set a₁} {A₂ : Set a₂} where equivalence : {B₁ : IndexedSetoid A₁ b₁ b₁′} {B₂ : IndexedSetoid A₂ b₂ b₂′} (A₁⇔A₂ : A₁ ⇔ A₂) → (∀ {x} → _⟶_ (B₁ atₛ x) (B₂ atₛ (Equivalence.to A₁⇔A₂ ⟨$⟩ x))) → (∀ {y} → _⟶_ (B₂ atₛ y) (B₁ atₛ (Equivalence.from A₁⇔A₂ ⟨$⟩ y))) → Equivalence (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) equivalence {B₁} {B₂} A₁⇔A₂ B-to B-from = record { to = ⟶ B₂ (_⟨$⟩_ (to A₁⇔A₂)) B-to ; from = ⟶ B₁ (_⟨$⟩_ (from A₁⇔A₂)) B-from } where open Equivalence equivalence-↞ : (B₁ : IndexedSetoid A₁ b₁ b₁′) {B₂ : IndexedSetoid A₂ b₂ b₂′} (A₁↞A₂ : A₁ ↞ A₂) → (∀ {x} → Equivalence (B₁ atₛ (LeftInverse.from A₁↞A₂ ⟨$⟩ x)) (B₂ atₛ x)) → Equivalence (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) equivalence-↞ B₁ {B₂} A₁↞A₂ B₁⇔B₂ = equivalence (LeftInverse.equivalence A₁↞A₂) B-to B-from where B-to : ∀ {x} → _⟶_ (B₁ atₛ x) (B₂ atₛ (LeftInverse.to A₁↞A₂ ⟨$⟩ x)) B-to = record { _⟨$⟩_ = λ x → Equivalence.to B₁⇔B₂ ⟨$⟩ P.subst (IndexedSetoid.Carrier B₁) (P.sym $ LeftInverse.left-inverse-of A₁↞A₂ _) x ; cong = F.cong (Equivalence.to B₁⇔B₂) ∘ subst-cong (λ {x} → IndexedSetoid._≈_ B₁ {x} {x}) (P.sym (LeftInverse.left-inverse-of A₁↞A₂ _)) } B-from : ∀ {y} → _⟶_ (B₂ atₛ y) (B₁ atₛ (LeftInverse.from A₁↞A₂ ⟨$⟩ y)) B-from = Equivalence.from B₁⇔B₂ equivalence-↠ : {B₁ : IndexedSetoid A₁ b₁ b₁′} (B₂ : IndexedSetoid A₂ b₂ b₂′) (A₁↠A₂ : A₁ ↠ A₂) → (∀ {x} → Equivalence (B₁ atₛ x) (B₂ atₛ (Surjection.to A₁↠A₂ ⟨$⟩ x))) → Equivalence (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) equivalence-↠ {B₁ = B₁} B₂ A₁↠A₂ B₁⇔B₂ = equivalence (Surjection.equivalence A₁↠A₂) B-to B-from where B-to : ∀ {x} → _⟶_ (B₁ atₛ x) (B₂ atₛ (Surjection.to A₁↠A₂ ⟨$⟩ x)) B-to = Equivalence.to B₁⇔B₂ B-from : ∀ {y} → _⟶_ (B₂ atₛ y) (B₁ atₛ (Surjection.from A₁↠A₂ ⟨$⟩ y)) B-from = record { _⟨$⟩_ = λ x → Equivalence.from B₁⇔B₂ ⟨$⟩ P.subst (IndexedSetoid.Carrier B₂) (P.sym $ Surjection.right-inverse-of A₁↠A₂ _) x ; cong = F.cong (Equivalence.from B₁⇔B₂) ∘ subst-cong (λ {x} → IndexedSetoid._≈_ B₂ {x} {x}) (P.sym (Surjection.right-inverse-of A₁↠A₂ _)) } injection : {B₁ : IndexedSetoid A₁ b₁ b₁′} (B₂ : IndexedSetoid A₂ b₂ b₂′) → (A₁↣A₂ : A₁ ↣ A₂) → (∀ {x} → Injection (B₁ atₛ x) (B₂ atₛ (Injection.to A₁↣A₂ ⟨$⟩ x))) → Injection (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) injection {B₁ = B₁} B₂ A₁↣A₂ B₁↣B₂ = record { to = to ; injective = inj } where to = ⟶ B₂ (Injection.to A₁↣A₂ ⟨$⟩_) (Injection.to B₁↣B₂) inj : Injective to inj (x , y) = Injection.injective A₁↣A₂ x , lemma (Injection.injective A₁↣A₂ x) y where lemma : ∀ {x x′} {y : IndexedSetoid.Carrier B₁ x} {y′ : IndexedSetoid.Carrier B₁ x′} → x ≡ x′ → (eq : IndexedSetoid._≈_ B₂ (Injection.to B₁↣B₂ ⟨$⟩ y) (Injection.to B₁↣B₂ ⟨$⟩ y′)) → IndexedSetoid._≈_ B₁ y y′ lemma P.refl = Injection.injective B₁↣B₂ left-inverse : (B₁ : IndexedSetoid A₁ b₁ b₁′) {B₂ : IndexedSetoid A₂ b₂ b₂′} → (A₁↞A₂ : A₁ ↞ A₂) → (∀ {x} → LeftInverse (B₁ atₛ (LeftInverse.from A₁↞A₂ ⟨$⟩ x)) (B₂ atₛ x)) → LeftInverse (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) left-inverse B₁ {B₂} A₁↞A₂ B₁↞B₂ = record { to = Equivalence.to eq ; from = Equivalence.from eq ; left-inverse-of = left } where eq = equivalence-↞ B₁ A₁↞A₂ (LeftInverse.equivalence B₁↞B₂) left : Equivalence.from eq LeftInverseOf Equivalence.to eq left (x , y) = LeftInverse.left-inverse-of A₁↞A₂ x , IndexedSetoid.trans B₁ (LeftInverse.left-inverse-of B₁↞B₂ _) (lemma (P.sym (LeftInverse.left-inverse-of A₁↞A₂ x))) where lemma : ∀ {x x′ y} (eq : x ≡ x′) → IndexedSetoid._≈_ B₁ (P.subst (IndexedSetoid.Carrier B₁) eq y) y lemma P.refl = IndexedSetoid.refl B₁ surjection : {B₁ : IndexedSetoid A₁ b₁ b₁′} (B₂ : IndexedSetoid A₂ b₂ b₂′) → (A₁↠A₂ : A₁ ↠ A₂) → (∀ {x} → Surjection (B₁ atₛ x) (B₂ atₛ (Surjection.to A₁↠A₂ ⟨$⟩ x))) → Surjection (setoid (P.setoid A₁) B₁) (setoid (P.setoid A₂) B₂) surjection B₂ A₁↠A₂ B₁↠B₂ = record { to = Equivalence.to eq ; surjective = record { from = Equivalence.from eq ; right-inverse-of = right } } where eq = equivalence-↠ B₂ A₁↠A₂ (Surjection.equivalence B₁↠B₂) right : Equivalence.from eq RightInverseOf Equivalence.to eq right (x , y) = Surjection.right-inverse-of A₁↠A₂ x , IndexedSetoid.trans B₂ (Surjection.right-inverse-of B₁↠B₂ _) (lemma (P.sym $ Surjection.right-inverse-of A₁↠A₂ x)) where lemma : ∀ {x x′ y} (eq : x ≡ x′) → IndexedSetoid._≈_ B₂ (P.subst (IndexedSetoid.Carrier B₂) eq y) y lemma P.refl = IndexedSetoid.refl B₂ -- See also Data.Product.Function.Dependent.Setoid.WithK.inverse.
{ "alphanum_fraction": 0.5533333333, "avg_line_length": 38.4422110553, "ext": "agda", "hexsha": "54f5eaf5d8f9ad4366a1d6ad8f8ac63a10f9f408", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/Dependent/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/Dependent/Setoid.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/Dependent/Setoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2914, "size": 7650 }
module Error-in-imported-module.M where Foo : Set Foo = Set
{ "alphanum_fraction": 0.737704918, "avg_line_length": 12.2, "ext": "agda", "hexsha": "25e36f832b83ee5a5aa0217a7164bf49fa8b306d", "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/Error-in-imported-module/M.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/Error-in-imported-module/M.agda", "max_line_length": 39, "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/Error-in-imported-module/M.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": 17, "size": 61 }
{-# OPTIONS --without-K --safe #-} module Bundles where open import Algebra.Core open import Relation.Binary open import Level open import Algebra.Bundles open import Algebra.Structures open import Structures ------------------------------------------------------------------------ -- Bundles with 1 binary operation ------------------------------------------------------------------------ record IdempotentMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isIdempotentMagma : IsIdempotentMagma _≈_ _∙_ open IsIdempotentMagma isIdempotentMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record AlternateMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isAlternateMagma : IsAlternateMagma _≈_ _∙_ open IsAlternateMagma isAlternateMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record FlexibleMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isFlexibleMagma : IsFlexibleMagma _≈_ _∙_ open IsFlexibleMagma isFlexibleMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record MedialMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isMedialMagma : IsMedialMagma _≈_ _∙_ open IsMedialMagma isMedialMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record SemimedialMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isSemimedialMagma : IsSemimedialMagma _≈_ _∙_ open IsSemimedialMagma isSemimedialMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record LatinQuasigroup c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isLatinQuasigroup : IsLatinQuasigroup _≈_ _∙_ open IsLatinQuasigroup isLatinQuasigroup public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (_≉_; rawMagma) record InverseSemigroup c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier isInverseSemigroup : IsInverseSemigroup _≈_ _∙_ open IsInverseSemigroup isInverseSemigroup public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (_≉_; rawMagma) ------------------------------------------------------------------------ -- Bundles with 1 binary operation and 1 element ------------------------------------------------------------------------ record LeftUnitalMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier isLeftUnitalMagma : IsLeftUnitalMagma _≈_ _∙_ ε open IsLeftUnitalMagma isLeftUnitalMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) record RightUnitalMagma c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier ε : Carrier isRightUnitalMagma : IsRightUnitalMagma _≈_ _∙_ ε open IsRightUnitalMagma isRightUnitalMagma public magma : Magma c ℓ magma = record { isMagma = isMagma } open Magma magma public using (rawMagma) ------------------------------------------------------------------------ -- Bundles with 2 binary operations, 1 unary operation & 1 element ------------------------------------------------------------------------ record NonAssociativeRing c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isNonAssociativeRing : IsNonAssociativeRing _≈_ _+_ _*_ -_ 0# 1# open IsNonAssociativeRing isNonAssociativeRing public +-abelianGroup : AbelianGroup _ _ +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } open AbelianGroup +-abelianGroup public using () renaming (group to +-group; invertibleMagma to +-invertibleMagma; invertibleUnitalMagma to +-invertibleUnitalMagma) ------------------------------------------------------------------------ -- Bundles with 3 binary operation and 1 element ------------------------------------------------------------------------ record Pique c ℓ : Set (suc (c ⊔ ℓ)) where infixl 7 _∙_ infixl 7 _\\_ infixl 7 _//_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier isPique : IsPique _≈_ _∙_ _\\_ _//_ ε open IsPique isPique public record LeftBolLoop c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier isLeftBolLoop : IsLeftBolLoop _≈_ _∙_ _\\_ _//_ ε open IsLeftBolLoop isLeftBolLoop public loop : Loop _ _ loop = record { isLoop = isLoop } open Loop loop public using (quasigroup) record RightBolLoop c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier isRightBolLoop : IsRightBolLoop _≈_ _∙_ _\\_ _//_ ε open IsRightBolLoop isRightBolLoop public loop : Loop _ _ loop = record { isLoop = isLoop } open Loop loop public using (quasigroup) record MoufangLoop c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _∙_ : Op₂ Carrier _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier isMoufangLoop : IsMoufangLoop _≈_ _∙_ _\\_ _//_ ε open IsMoufangLoop isMoufangLoop public loop : Loop _ _ loop = record { isLoop = isLoop } open Loop loop public using (quasigroup)
{ "alphanum_fraction": 0.5728554642, "avg_line_length": 24.7563636364, "ext": "agda", "hexsha": "d930f984ebf2c94418db112bfcb8fcf1169707a9", "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": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/Agda-Algebra", "max_forks_repo_path": "src/Bundles.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_issues_repo_issues_event_max_datetime": "2022-01-31T18:19:52.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-02T20:50:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/Agda-Algebra", "max_issues_repo_path": "src/Bundles.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/Agda-Algebra", "max_stars_repo_path": "src/Bundles.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2271, "size": 6808 }
module Issue4267.M where record R : Set₂ where field f : Set₁
{ "alphanum_fraction": 0.6811594203, "avg_line_length": 11.5, "ext": "agda", "hexsha": "01104ee89f0bea38abf4a48d085397dee5b6408c", "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/Issue4267/M.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/Issue4267/M.agda", "max_line_length": 24, "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/Issue4267/M.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": 23, "size": 69 }
open import Nat open import Prelude open import core open import contexts open import lemmas-consistency open import lemmas-ground open import progress-checks open import canonical-boxed-forms open import canonical-value-forms open import canonical-indeterminate-forms open import ground-decidable open import htype-decidable module progress where -- this is a little bit of syntactic sugar to avoid many layer nested Inl -- and Inrs that you would get from the more literal transcription of the -- consequent of progress data ok : (d : ihexp) (Δ : hctx) → Set where S : ∀{d Δ} → Σ[ d' ∈ ihexp ] (d ↦ d') → ok d Δ I : ∀{d Δ} → d indet → ok d Δ BV : ∀{d Δ} → d boxedval → ok d Δ progress : {Δ : hctx} {d : ihexp} {τ : htyp} → Δ , ∅ ⊢ d :: τ → ok d Δ -- constants progress TAConst = BV (BVVal VConst) -- variables progress (TAVar x₁) = abort (somenotnone (! x₁)) -- lambdas progress (TALam _ wt) = BV (BVVal VLam) -- applications progress (TAAp wt1 wt2) with progress wt1 | progress wt2 -- if the left steps, the whole thing steps progress (TAAp wt1 wt2) | S (_ , Step x y z) | _ = S (_ , Step (FHAp1 x) y (FHAp1 z)) -- if the left is indeterminate, step the right progress (TAAp wt1 wt2) | I i | S (_ , Step x y z) = S (_ , Step (FHAp2 x) y (FHAp2 z)) -- if they're both indeterminate, step when the cast steps and indet otherwise progress (TAAp wt1 wt2) | I x | I x₁ with canonical-indeterminate-forms-arr wt1 x progress (TAAp wt1 wt2) | I x | I y | CIFACast (_ , _ , _ , _ , _ , refl , _ , _ ) = S (_ , Step FHOuter ITApCast FHOuter) progress (TAAp wt1 wt2) | I x | I y | CIFAEHole (_ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FIndet y)) progress (TAAp wt1 wt2) | I x | I y | CIFANEHole (_ , _ , _ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FIndet y)) progress (TAAp wt1 wt2) | I x | I y | CIFAAp (_ , _ , _ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FIndet y)) progress (TAAp wt1 wt2) | I x | I y | CIFACastHole (_ , refl , refl , refl , _ ) = I (IAp (λ _ _ _ _ _ ()) x (FIndet y)) progress (TAAp wt1 wt2) | I x | I y | CIFAFailedCast (_ , _ , refl , _ ) = I (IAp (λ _ _ _ _ _ ()) x (FIndet y)) -- similar if the left is indetermiante but the right is a boxed val progress (TAAp wt1 wt2) | I x | BV x₁ with canonical-indeterminate-forms-arr wt1 x progress (TAAp wt1 wt2) | I x | BV y | CIFACast (_ , _ , _ , _ , _ , refl , _ , _ ) = S (_ , Step FHOuter ITApCast FHOuter) progress (TAAp wt1 wt2) | I x | BV y | CIFAEHole (_ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FBoxedVal y)) progress (TAAp wt1 wt2) | I x | BV y | CIFANEHole (_ , _ , _ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FBoxedVal y)) progress (TAAp wt1 wt2) | I x | BV y | CIFAAp (_ , _ , _ , _ , _ , refl , _) = I (IAp (λ _ _ _ _ _ ()) x (FBoxedVal y)) progress (TAAp wt1 wt2) | I x | BV y | CIFACastHole (_ , refl , refl , refl , _ ) = I (IAp (λ _ _ _ _ _ ()) x (FBoxedVal y)) progress (TAAp wt1 wt2) | I x | BV y | CIFAFailedCast (_ , _ , refl , _ ) = I (IAp (λ _ _ _ _ _ ()) x (FBoxedVal y)) -- if the left is a boxed value, inspect the right progress (TAAp wt1 wt2) | BV v | S (_ , Step x y z) = S (_ , Step (FHAp2 x) y (FHAp2 z)) progress (TAAp wt1 wt2) | BV v | I i with canonical-boxed-forms-arr wt1 v ... | CBFLam (_ , _ , refl , _) = S (_ , Step FHOuter ITLam FHOuter) ... | CBFCastArr (_ , _ , _ , refl , _ , _) = S (_ , Step FHOuter ITApCast FHOuter) progress (TAAp wt1 wt2) | BV v | BV v₂ with canonical-boxed-forms-arr wt1 v ... | CBFLam (_ , _ , refl , _) = S (_ , Step FHOuter ITLam FHOuter) ... | CBFCastArr (_ , _ , _ , refl , _ , _) = S (_ , Step FHOuter ITApCast FHOuter) -- empty holes are indeterminate progress (TAEHole _ _ ) = I IEHole -- nonempty holes step if the innards step, indet otherwise progress (TANEHole xin wt x₁) with progress wt ... | S (_ , Step x y z) = S (_ , Step (FHNEHole x) y (FHNEHole z)) ... | I x = I (INEHole (FIndet x)) ... | BV x = I (INEHole (FBoxedVal x)) -- casts progress (TACast wt con) with progress wt -- step if the innards step progress (TACast wt con) | S (_ , Step x y z) = S (_ , Step (FHCast x) y (FHCast z)) -- if indet, inspect how the types in the cast are realted by consistency: -- if they're the same, step by ID progress (TACast wt TCRefl) | I x = S (_ , Step FHOuter ITCastID FHOuter) -- if first type is hole progress (TACast {τ1 = τ1} wt TCHole1) | I x with τ1 progress (TACast wt TCHole1) | I x | b = I (ICastGroundHole GBase x) progress (TACast wt TCHole1) | I x | ⦇-⦈ = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt TCHole1) | I x | τ11 ==> τ12 with ground-decidable (τ11 ==> τ12) progress (TACast wt TCHole1) | I x₁ | .⦇-⦈ ==> .⦇-⦈ | Inl GHole = I (ICastGroundHole GHole x₁) progress (TACast wt TCHole1) | I x₁ | τ11 ==> τ12 | Inr x = S (_ , Step FHOuter (ITGround (MGArr (ground-arr-not-hole x))) FHOuter) -- if second type is hole progress (TACast wt (TCHole2 {b})) | I x with canonical-indeterminate-forms-hole wt x progress (TACast wt (TCHole2 {b})) | I x | CIFHEHole (_ , _ , _ , refl , f) = I (ICastHoleGround (λ _ _ ()) x GBase) progress (TACast wt (TCHole2 {b})) | I x | CIFHNEHole (_ , _ , _ , _ , _ , refl , _ ) = I (ICastHoleGround (λ _ _ ()) x GBase) progress (TACast wt (TCHole2 {b})) | I x | CIFHAp (_ , _ , _ , refl , _ ) = I (ICastHoleGround (λ _ _ ()) x GBase) progress (TACast wt (TCHole2 {b})) | I x | CIFHCast (_ , τ , refl , _) with htype-dec τ b progress (TACast wt (TCHole2 {b})) | I x₁ | CIFHCast (_ , .b , refl , _ , grn , _) | Inl refl = S (_ , Step FHOuter (ITCastSucceed grn ) FHOuter) progress (TACast wt (TCHole2 {b})) | I x₁ | CIFHCast (_ , _ , refl , π2 , grn , _) | Inr x = S (_ , Step FHOuter (ITCastFail grn GBase x) FHOuter) progress (TACast wt (TCHole2 {⦇-⦈}))| I x = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt (TCHole2 {τ11 ==> τ12})) | I x with ground-decidable (τ11 ==> τ12) progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x₁ | Inl GHole with canonical-indeterminate-forms-hole wt x₁ progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x | Inl GHole | CIFHEHole (_ , _ , _ , refl , _) = I (ICastHoleGround (λ _ _ ()) x GHole) progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x | Inl GHole | CIFHNEHole (_ , _ , _ , _ , _ , refl , _) = I (ICastHoleGround (λ _ _ ()) x GHole) progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x | Inl GHole | CIFHAp (_ , _ , _ , refl , _ ) = I (ICastHoleGround (λ _ _ ()) x GHole) progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x | Inl GHole | CIFHCast (_ , ._ , refl , _ , GBase , _) = S (_ , Step FHOuter (ITCastFail GBase GHole (λ ())) FHOuter ) progress (TACast wt (TCHole2 {.⦇-⦈ ==> .⦇-⦈})) | I x | Inl GHole | CIFHCast (_ , ._ , refl , _ , GHole , _) = S (_ , Step FHOuter (ITCastSucceed GHole) FHOuter) progress (TACast wt (TCHole2 {τ11 ==> τ12})) | I x₁ | Inr x = S (_ , Step FHOuter (ITExpand (MGArr (ground-arr-not-hole x))) FHOuter) -- if both are arrows progress (TACast wt (TCArr {τ1} {τ2} {τ1'} {τ2'} c1 c2)) | I x with htype-dec (τ1 ==> τ2) (τ1' ==> τ2') progress (TACast wt (TCArr c1 c2)) | I x₁ | Inl refl = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt (TCArr c1 c2)) | I x₁ | Inr x = I (ICastArr x x₁) -- boxed value cases, inspect how the casts are realted by consistency -- step by ID if the casts are the same progress (TACast wt TCRefl) | BV x = S (_ , Step FHOuter ITCastID FHOuter) -- if left is hole progress (TACast wt (TCHole1 {τ = τ})) | BV x with ground-decidable τ progress (TACast wt TCHole1) | BV x₁ | Inl g = BV (BVHoleCast g x₁) progress (TACast wt (TCHole1 {b})) | BV x₁ | Inr x = abort (x GBase) progress (TACast wt (TCHole1 {⦇-⦈})) | BV x₁ | Inr x = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt (TCHole1 {τ1 ==> τ2})) | BV x₁ | Inr x with (htype-dec (τ1 ==> τ2) (⦇-⦈ ==> ⦇-⦈)) progress (TACast wt (TCHole1 {.⦇-⦈ ==> .⦇-⦈})) | BV x₂ | Inr x₁ | Inl refl = BV (BVHoleCast GHole x₂) progress (TACast wt (TCHole1 {τ1 ==> τ2})) | BV x₂ | Inr x₁ | Inr x = S (_ , Step FHOuter (ITGround (MGArr x)) FHOuter) -- if right is hole progress {τ = τ} (TACast wt TCHole2) | BV x with canonical-boxed-forms-hole wt x progress {τ = τ} (TACast wt TCHole2) | BV x | d' , τ' , refl , gnd , wt' with htype-dec τ τ' progress (TACast wt TCHole2) | BV x₁ | d' , τ , refl , gnd , wt' | Inl refl = S (_ , Step FHOuter (ITCastSucceed gnd) FHOuter) progress {τ = τ} (TACast wt TCHole2) | BV x₁ | _ , _ , refl , _ , _ | Inr _ with ground-decidable τ progress (TACast wt TCHole2) | BV x₂ | _ , _ , refl , gnd , _ | Inr x₁ | Inl x = S(_ , Step FHOuter (ITCastFail gnd x (flip x₁)) FHOuter) progress (TACast wt TCHole2) | BV x₂ | _ , _ , refl , _ , _ | Inr x₁ | Inr x with notground x progress (TACast wt TCHole2) | BV x₃ | _ , _ , refl , _ , _ | Inr _ | Inr _ | Inl refl = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt TCHole2) | BV x₃ | _ , _ , refl , _ , _ | Inr _ | Inr x | Inr (_ , _ , refl) = S(_ , Step FHOuter (ITExpand (MGArr (ground-arr-not-hole x))) FHOuter ) -- if both arrows progress (TACast wt (TCArr {τ1} {τ2} {τ1'} {τ2'} c1 c2)) | BV x with htype-dec (τ1 ==> τ2) (τ1' ==> τ2') progress (TACast wt (TCArr c1 c2)) | BV x₁ | Inl refl = S (_ , Step FHOuter ITCastID FHOuter) progress (TACast wt (TCArr c1 c2)) | BV x₁ | Inr x = BV (BVArrCast x x₁) -- failed casts progress (TAFailedCast wt y z w) with progress wt progress (TAFailedCast wt y z w) | S (d' , Step x a q) = S (_ , Step (FHFailedCast x) a (FHFailedCast q)) progress (TAFailedCast wt y z w) | I x = I (IFailedCast (FIndet x) y z w) progress (TAFailedCast wt y z w) | BV x = I (IFailedCast (FBoxedVal x) y z w)
{ "alphanum_fraction": 0.5876861966, "avg_line_length": 61.0303030303, "ext": "agda", "hexsha": "aed144b98a9cd7754a6c7d22803e1601d31212cf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "progress.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "progress.agda", "max_line_length": 174, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "progress.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 3957, "size": 10070 }
module Main where import Data.Any import Data.Boolean import Data.Either -- import Data.List -- import Data.ListNonEmpty -- import Data.ListSized import Data.Option -- import Data.Proofs import Data.Tuple import Lang.Instance import Lang.Irrelevance import Lang.Size import Logic -- import Logic.Classical -- import Logic.Computability -- import Logic.Names -- import Logic.Predicate -- import Logic.Predicate.Theorems -- import Logic.Propositional -- import Logic.Propositional.Theorems import Lvl import Numeral.Integer -- import Numeral.Integer.Proofs import Numeral.Natural import Relator.Equals -- import Relator.Equals.Proofs import Syntax.Function -- import Syntax.Number import Type import Type.Cubical import Type.Cubical.Path import Type.Cubical.Path.Proofs import Type.Dependent import Type.Properties.Empty -- import Type.Properties.Empty.Proofs import Type.Quotient -- import Type.Singleton -- import Type.Singleton.Proofs -- import Type.Size -- import Type.Size.Proofs import Type.Properties.Singleton -- import Type.Properties.Singleton.Proofs
{ "alphanum_fraction": 0.8094339623, "avg_line_length": 23.5555555556, "ext": "agda", "hexsha": "8768e2c5558fe22ef3335593d3d3034c55908d3d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Mathematical/Main.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Mathematical/Main.agda", "max_line_length": 42, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Mathematical/Main.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": 249, "size": 1060 }
{-# OPTIONS --without-K --safe #-} module Util.HoTT.Homotopy where open import Relation.Binary using (IsEquivalence) open import Util.Prelude open import Util.Relation.Binary.PropositionalEquality using (cong-app) module _ {α β} {A : Set α} {B : A → Set β} where _~_ : (f g : ∀ a → B a) → Set (α ⊔ℓ β) f ~ g = ∀ a → f a ≡ g a ~-refl : ∀ {f} → f ~ f ~-refl a = refl ~-sym : ∀ {f g} → f ~ g → g ~ f ~-sym f~g a = sym (f~g a) ~-trans : ∀ {f g h} → f ~ g → g ~ h → f ~ h ~-trans f~g g~h a = trans (f~g a) (g~h a) ~-IsEquivalence : IsEquivalence _~_ ~-IsEquivalence = record { refl = ~-refl ; sym = ~-sym ; trans = ~-trans } ≡→~ : ∀ {f g} → f ≡ g → f ~ g ≡→~ = cong-app
{ "alphanum_fraction": 0.5269886364, "avg_line_length": 20.7058823529, "ext": "agda", "hexsha": "5a3f33c4ced297a93c161d8d7b1a05bfc22ea645", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Util/HoTT/Homotopy.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Util/HoTT/Homotopy.agda", "max_line_length": 76, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Util/HoTT/Homotopy.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 292, "size": 704 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim` open import Function.Base using (_∋_; _$_; it; typeOf) open import Cubical.Foundations.Logic renaming ( inl to inlᵖ ; inr to inrᵖ ; _⇒_ to infixr 0 _⇒_ -- shifting by -6 ; _⇔_ to infixr -2 _⇔_ -- ; ∃[]-syntax to infix -4 ∃[]-syntax -- ; ∃[∶]-syntax to infix -4 ∃[∶]-syntax -- ; ∀[∶]-syntax to infix -4 ∀[∶]-syntax -- ; ∀[]-syntax to infix -4 ∀[]-syntax -- ) -- open import Cubical.Data.Unit.Base using (Unit) open import Cubical.HITs.PropositionalTruncation.Base -- ∣_∣ open import Utils open import MoreLogic.Reasoning open import MoreLogic.Definitions renaming ( _ᵗ⇒_ to infixr 0 _ᵗ⇒_ ; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax ; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax ; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax ; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax ; Σᵖ[]-syntax to infix -4 Σᵖ[]-syntax ; Σᵖ[∶]-syntax to infix -4 Σᵖ[∶]-syntax ) hiding (≡ˢ-syntax) open import MoreLogic.Properties open import MorePropAlgebra.Definitions hiding (_≤''_) open import MorePropAlgebra.Consequences open import MorePropAlgebra.Structures open import MorePropAlgebra.Bundles module MorePropAlgebra.Properties.PartiallyOrderedField {ℓ ℓ'} (assumptions : PartiallyOrderedField {ℓ} {ℓ'}) (let _≡ˢ_ = λ(x y : PartiallyOrderedField.Carrier assumptions) → MoreLogic.Definitions.≡ˢ-syntax x y {PartiallyOrderedField.is-set assumptions} infixl 4 _≡ˢ_ ) where import MorePropAlgebra.Properties.AlmostPartiallyOrderedField module AlmostPartiallyOrderedField'Properties = MorePropAlgebra.Properties.AlmostPartiallyOrderedField record { PartiallyOrderedField assumptions } module AlmostPartiallyOrderedField' = AlmostPartiallyOrderedField record { PartiallyOrderedField assumptions } -- ( AlmostPartiallyOrderedField') = AlmostPartiallyOrderedField ∋ record { PartiallyOrderedField assumptions } -- open PartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) import MorePropAlgebra.Booij2020 open MorePropAlgebra.Booij2020.Chapter4 (record { PartiallyOrderedField assumptions }) open +-<-ext+·-preserves-<⇒ (PartiallyOrderedField.+-<-ext assumptions) (PartiallyOrderedField.·-preserves-< assumptions) -- open AlmostPartiallyOrderedField' open MorePropAlgebra.Properties.AlmostPartiallyOrderedField (record { PartiallyOrderedField assumptions }) open AlmostPartiallyOrderedField' using (_#_; _≤_) open PartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) hiding (_#_; _≤_) abstract #-tight : ∀ a b → [ ¬(a # b) ] → a ≡ b; _ : [ isTightˢ''' _#_ is-set ]; _ = #-tight #-tight = isTightˢ'''⇔isAntisymˢ _<_ is-set <-asym .snd ≤-antisym +-#-ext : ∀ w x y z → [ (w + x) # (y + z) ] → [ (w # y) ⊔ (x # z) ]; _ : [ is-+-#-Extensional _+_ _#_ ]; _ = +-#-ext -- Consider the case w + x < y + z, so that we can use (†) to obtain w < y ∨ x < z, -- which gives w # y ∨ x # z in either case. +-#-ext w x y z (inl w+x<y+z) = case +-<-ext _ _ _ _ w+x<y+z as (w < y) ⊔ (x < z) ⇒ ((w # y) ⊔ (x # z)) of λ { (inl w<y) → inlᵖ (inl w<y) ; (inr x<z) → inrᵖ (inl x<z) } -- The case w + x > y + z is similar. +-#-ext w x y z (inr y+z<w+x) = case +-<-ext _ _ _ _ y+z<w+x as (y < w) ⊔ (z < x) ⇒ ((w # y) ⊔ (x # z)) of λ { (inl y<w) → inlᵖ (inr y<w) ; (inr z<x) → inrᵖ (inr z<x) } ¬≤⇒≢ : ∀ x y → [ ¬(x ≤ y) ] → [ ¬(x ≡ˢ y) ] ¬≤⇒≢ x y ¬x≤y x≡y = ¬x≤y (subst (λ p → [ x ≤ p ]) x≡y (≤-refl x)) ≢⇒¬¬# : ∀ x y → [ ¬(x ≡ˢ y) ] → [ ¬ ¬(x # y) ] ≢⇒¬¬# x y x≢y = contraposition (¬ (x # y)) (x ≡ˢ y) (#-tight x y) x≢y -- x ≤ y → x # y → x < y -- x ≤ y ≡ ¬(y ≤ x) -- ¬(x # y) → x ≡ y ¬≤⇒¬¬# : ∀ x y → [ (¬(x ≤ y)) ⇒ ¬ ¬ (x # y) ] ¬≤⇒¬¬# x y ¬x≤y = ≢⇒¬¬# x y $ ¬≤⇒≢ x y ¬x≤y ¬≤≡¬¬< : ∀ x y → ¬(x ≤ y) ≡ ¬ ¬ (y < x) ¬≤≡¬¬< x y = refl min-≤' : ∀ x y → [ (min x y ≤ x) ⊓ (min x y ≤ y) ] min-≤' x y = is-min x y (min x y) .fst (≤-refl (min x y)) ¬¬<-trans : ∀ x y z → [ ¬ ¬ (x < y) ] → [ ¬ ¬ (y < z) ] → [ ¬ ¬ (x < z) ] ¬¬<-trans x y z ¬¬x<y ¬¬y<z = ( contraposition (¬ (x < z)) (¬ ((x < y) ⊓ (y < z))) $ contraposition ((x < y) ⊓ (y < z)) (x < z) $ uncurryₚ (x < y) (y < z) (x < z) (<-trans x y z) ) (⊓¬¬⇒¬¬⊓ (x < y) (y < z) ¬¬x<y ¬¬y<z) ¬¬<-irrefl : ∀ x → [ ¬ ¬ ¬(x < x) ] ¬¬<-irrefl x = ¬¬-intro (¬(x < x)) (<-irrefl x) -- lem : ∀ (x y z : F) → {! !} -- lem x y z = let f : [ x < y ] → [ (x < z) ⊔ (z < y) ] -- f p = <-cotrans x y p z -- contraposition ((z ≤ x) ⊓ (y ≤ z)) (y ≤ x) $ -- _ = {! !} -- in {! contraposition (x < y) ((x < z) ⊔ (z < y)) f ∘ deMorgan₂-back (x < z) (z < y) !} -- foo : ∀(x y z w : F) → [ w < min (x · z) (y · z) ] → [ w < min x y · z ] -- foo x y z w = {! <-cotrans w (min x y) ? x !} -- foo : ∀(x y z w : F) → [ w < min (x · z) (y · z) ] → [ w < min x y · z ] min-<-⊔ : ∀ x y z → [ min x y < z ] → [ (x < z) ⊔ (y < z) ] min-<-⊔ x y z mxy<z = case <-cotrans (min x y) z mxy<z x as (min x y < x) ⊔ (x < z) ⇒ (x < z) ⊔ (y < z) of λ { (inl p) → case <-cotrans (min x y) z mxy<z y as (min x y < y) ⊔ (y < z) ⇒ (x < z) ⊔ (y < z) of λ { (inl q) → -- We know that -- x ≤ min(x, y) ⇔ x ≤ x ∧ x ≤ y, -- y ≤ min(x, y) ⇔ y ≤ x ∧ y ≤ y. -- By the fact that min(x, y) < x and min(x, y) < y, the left hand sides of these claims are false, -- and hence we have ¬(x ≤ y) and ¬(y ≤ x), which together contradict that < is transitive and -- irreflexive. let (mxy≤x , mxy≤y) = is-min x y (min x y) .fst (<-irrefl (min x y)) r = contraposition ((x ≤ x) ⊓ (x ≤ y)) (¬ (min x y < x)) (is-min x y x .snd) (¬¬-intro (min x y < x) p) ¬x≤y = implication (x ≤ x) (x ≤ y) r (≤-refl x) s = contraposition ((y ≤ x) ⊓ (y ≤ y)) (¬ (min x y < y)) (is-min x y y .snd) (¬¬-intro (min x y < y) q) ¬y≤x = ¬-⊓-distrib (y ≤ x) (y ≤ y) s .snd (≤-refl y) in ⊥-elim {A = λ _ → [ (x < z) ⊔ (y < z) ]} $ ¬¬<-irrefl x (¬¬<-trans x y x ¬y≤x ¬x≤y) ; (inr q) → inrᵖ q } ; (inr p) → inlᵖ p } -- is this provable? -- min-≤-⊔ : ∀ x y z → [ min x y ≤ z ] → [ (x ≤ z) ⊔ (y ≤ z) ] -- min-≤-⊔ x y z mxy≤z = {! !} -- lem : ∀ w x y z → [ w ≤ (x + z) ] → [ w ≤ (y + z) ] → [ w ≤ (min x y + z) ] -- lem w x y z w≤x+z w≤y+z mxy+z<w = {! +-<-ext (min x y) z 0f w !} -- Properties.PartiallyOrderedField assumptions -- opens PartiallyOrderedField assumptions -- opens IsPartiallyOrderedField is-PartiallyOrderedField public -- opens IsAlmostPartiallyOrderedField is-AlmostPartiallyOrderedField public -- contains definition of _#_ -- becomes `_#_` -- opens MorePropAlgebra.Properties.AlmostPartiallyOrderedField assumptions -- opens AlmostPartiallyOrderedField assumptions -- opens IsAlmostPartiallyOrderedField is-AlmostPartiallyOrderedField public -- contains definition of _#_ -- becomes `AlmostPartiallyOrderedField'._#_` -- all these become `_#_` -- _#_ -- PartiallyOrderedField._#_ assumptions -- IsPartiallyOrderedField._#_ (PartiallyOrderedField.is-PartiallyOrderedField assumptions) -- IsAlmostPartiallyOrderedField._#_ (IsPartiallyOrderedField.is-AlmostPartiallyOrderedField (PartiallyOrderedField.is-PartiallyOrderedField assumptions)) -- but -- PartiallyOrderedField._#_ (record { PartiallyOrderedField assumptions }) -- becomes -- PartiallyOrderedField._#_ record { Carrier = F ; 0f = 0f ; 1f = 1f ; _+_ = _+_ ; -_ = -_ ; _·_ = _·_ ; min = min ; max = max ; _<_ = _<_ ; is-PartiallyOrderedField = is-PartiallyOrderedField } -- when we define -- foo = PartiallyOrderedField ∋ (record { PartiallyOrderedField assumptions }) -- then -- PartiallyOrderedField._#_ foo -- becomes -- (foo PartiallyOrderedField.# x) -- foo = PartiallyOrderedField ∋ (record { PartiallyOrderedField assumptions }) -- -- test : ∀ x y → [ (PartiallyOrderedField._#_ foo) x y ] -- test = {! ·-inv'' !}
{ "alphanum_fraction": 0.5452755906, "avg_line_length": 49.3485714286, "ext": "agda", "hexsha": "cfecf023cd75274da24d406962ff6e5076905d99", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Properties/PartiallyOrderedField.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Properties/PartiallyOrderedField.agda", "max_line_length": 197, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Properties/PartiallyOrderedField.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 3358, "size": 8636 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Summation.Nat.Properties where -- agda-stdlib open import Algebra import Algebra.Operations.CommutativeMonoid as CommutativeMonoidOperations open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Solver open import Relation.Binary.PropositionalEquality open import Function.Base -- agda-misc open import Math.NumberTheory.Summation.Generic open import Math.NumberTheory.Summation.Generic.Properties import Math.NumberTheory.Summation.Nat.Properties.Lemma as Lemma -- DO NOT change this line open MonoidSummation (Semiring.+-monoid *-+-semiring) open CommutativeMonoidOperations (Semiring.+-commutativeMonoid *-+-semiring) -- TODO? rename _≈_ to _≡_ this is tedious open SemiringSummationProperties *-+-semiring public renaming ( Σ<-const to Σ<-const-× ; Σ≤-const to Σ≤-const-× ; Σ<range-const to Σ<range-const-× ; Σ≤range-const to Σ≤range-const-× ) -- TODO move somewhere private m×n≡m*n : ∀ m n → m × n ≡ m * n m×n≡m*n zero n = refl m×n≡m*n (suc m) n = cong (n +_) $ m×n≡m*n m n Σ<-const : ∀ m n → Σ< m (λ _ → n) ≡ m * n Σ<-const m n = begin-equality Σ< m (λ _ → n) ≡⟨ Σ<-const-× m n ⟩ m × n ≡⟨ m×n≡m*n m n ⟩ m * n ∎ where open ≤-Reasoning Σ≤-const : ∀ m n → Σ≤ m (λ _ → n) ≡ suc m * n Σ≤-const m n = Σ<-const (suc m) n Σ<range-const : ∀ m n x → Σ<range m n (const x) ≡ (n ∸ m) * x Σ<range-const m n x = trans (Σ<range-const-× m n x) (m×n≡m*n (n ∸ m) x) Σ≤range-const : ∀ m n x → Σ≤range m n (const x) ≡ (suc n ∸ m) * x Σ≤range-const m n x = Σ<range-const m (suc n) x 2*Σ≤[n,id]≡n*[1+n] : ∀ n → 2 * Σ≤ n id ≡ n * (suc n) 2*Σ≤[n,id]≡n*[1+n] zero = refl 2*Σ≤[n,id]≡n*[1+n] (suc n) = begin-equality 2 * Σ≤ (suc n) id ≡⟨⟩ 2 * (Σ≤ n id + suc n) ≡⟨ *-distribˡ-+ 2 (Σ≤ n id) (suc n) ⟩ 2 * Σ≤ n id + 2 * suc n ≡⟨ cong (_+ 2 * suc n) $ 2*Σ≤[n,id]≡n*[1+n] n ⟩ n * suc n + 2 * suc n ≡⟨ sym $ *-distribʳ-+ (suc n) n 2 ⟩ (n + 2) * suc n ≡⟨ *-comm (n + 2) (suc n) ⟩ suc n * (n + 2) ≡⟨ cong (suc n *_) $ +-comm n 2 ⟩ suc n * suc (suc n) ∎ where open ≤-Reasoning 6*Σ≤[n,^2]≡n*[1+n]*[1+2*n] : ∀ n → 6 * Σ≤ n (_^ 2) ≡ n * (1 + n) * (1 + 2 * n) 6*Σ≤[n,^2]≡n*[1+n]*[1+2*n] 0 = refl 6*Σ≤[n,^2]≡n*[1+n]*[1+2*n] (suc n) = begin-equality 6 * Σ≤ (suc n) (_^ 2) ≡⟨⟩ 6 * (Σ≤ n (_^ 2) + suc n ^ 2) ≡⟨ *-distribˡ-+ 6 (Σ≤ n (_^ 2)) (suc n ^ 2) ⟩ 6 * Σ≤ n (_^ 2) + 6 * (suc n ^ 2) ≡⟨ cong (_+ 6 * (suc n ^ 2)) $ 6*Σ≤[n,^2]≡n*[1+n]*[1+2*n] n ⟩ n * (1 + n) * (1 + 2 * n) + 6 * ((1 + n) ^ 2) ≡⟨ Lemma.lemma₁ n ⟩ (1 + n) * (2 + n) * (1 + 2 * (1 + n)) ∎ where open ≤-Reasoning -- Arithmetic sequence {- 2*Σ<[n,i→d+a*i]≡??? : ∀ n d a → 2 * Σ< n (λ i → d + a * i) ≡ n * (2 * d + a * suc n) 2*Σ<[n,i→d+a*i]≡??? n d a = begin-equality 2 * Σ< n (λ i → d + a * i) ≡⟨ {! !} ⟩ 2 * (Σ< n (λ _ → d) + Σ< n (λ i → a * i)) 2 * (n * d + a * Σ< n id) 2 * (n * d) + 2 * (a * Σ< n id) 2 * n * d + a * (2 * Σ< n id) 2 * n * d + a * (n * suc n) n * (2 * d + a * suc n) ∎ where oepn ≤-Reasoning -}
{ "alphanum_fraction": 0.5095480586, "avg_line_length": 34.152173913, "ext": "agda", "hexsha": "0512f7f3f1bd49f4925b74776f9205cedd0eb395", "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/Summation/Nat/Properties.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/Summation/Nat/Properties.agda", "max_line_length": 110, "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/Summation/Nat/Properties.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": 1572, "size": 3142 }
-- Andreas, 2013-02-21, example by Andres Sicard Ramirez module Issue782 where open import Common.Prelude renaming (zero toz; suc tos; Nat toℕ) f : ℕ → ℕ f z = z f (s n) = z
{ "alphanum_fraction": 0.6777777778, "avg_line_length": 20, "ext": "agda", "hexsha": "0ec46e1680495b8a1afdb8f787da152b76630398", "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/Issue782.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/Issue782.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue782.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": 63, "size": 180 }
------------------------------------------------------------------------------ -- Proving properties without using pattern matching on refl ------------------------------------------------------------------------------ {-# OPTIONS --no-pattern-matching #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} module FOT.PA.Axiomatic.Standard.NoPatternMatchingOnRefl where open import PA.Axiomatic.Standard.Base ------------------------------------------------------------------------------ -- From PA.Axiomatic.Standard.PropertiesI -- Congruence properties succCong : ∀ {m n} → m ≡ n → succ m ≡ succ n succCong {m} h = subst (λ t → succ m ≡ succ t) h refl +-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o +-leftCong {m} {o = o} h = subst (λ t → m + o ≡ t + o) h refl +-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o +-rightCong {m} {n} h = subst (λ t → m + n ≡ m + t) h refl
{ "alphanum_fraction": 0.4438669439, "avg_line_length": 35.6296296296, "ext": "agda", "hexsha": "674a0d0793543fb6add1369ef1198318ee24a9c2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/PA/Axiomatic/Standard/NoPatternMatchingOnRefl.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/PA/Axiomatic/Standard/NoPatternMatchingOnRefl.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/PA/Axiomatic/Standard/NoPatternMatchingOnRefl.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": 244, "size": 962 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Algebra.Signature module Fragment.Algebra.Properties where open import Fragment.Algebra.Algebra open import Fragment.Algebra.Free open import Level using (Level) open import Data.Nat using (ℕ) open import Data.Vec using (Vec; []; _∷_) private variable a ℓ : Level mutual map-extend : ∀ {Σ O a n} → {A : Set a} → Vec (Term Σ A) n → Vec (Term (Σ ⦅ O ⦆) A) n map-extend [] = [] map-extend (x ∷ xs) = extend x ∷ map-extend xs extend : ∀ {Σ O} → {A : Set a} → Term Σ A → Term (Σ ⦅ O ⦆) A extend (atom x) = atom x extend (term f xs) = term (oldₒ f) (map-extend xs) forgetₒ : ∀ {Σ O} → Algebra (Σ ⦅ O ⦆) {a} {ℓ} → Algebra Σ {a} {ℓ} forgetₒ {Σ = Σ} A = record { ∥_∥/≈ = ∥ A ∥/≈ ; ∥_∥/≈-isAlgebra = forget-isAlgebra } where forget-⟦_⟧ : Interpretation Σ ∥ A ∥/≈ forget-⟦ f ⟧ x = A ⟦ oldₒ f ⟧ x forget-⟦⟧-cong : Congruence Σ ∥ A ∥/≈ forget-⟦_⟧ forget-⟦⟧-cong f x = (A ⟦ oldₒ f ⟧-cong) x forget-isAlgebra : IsAlgebra Σ ∥ A ∥/≈ forget-isAlgebra = record { ⟦_⟧ = forget-⟦_⟧ ; ⟦⟧-cong = forget-⟦⟧-cong }
{ "alphanum_fraction": 0.4958238421, "avg_line_length": 29.2666666667, "ext": "agda", "hexsha": "31faa976d2240ccdf63a98d55978859ed534faaa", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Algebra/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Algebra/Properties.agda", "max_line_length": 65, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Algebra/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 502, "size": 1317 }
{-# OPTIONS --type-in-type #-} {-# OPTIONS --no-termination-check #-} -- In this post we'll consider how to define and generalize fixed-point combinators for families of -- mutually recursive functions. Both in the lazy and strict settings. module FixN where open import Function open import Relation.Binary.PropositionalEquality open import Data.Nat.Base open import Data.Bool.Base -- This module is parameterized by `even` and `odd` functions and defines the `Test` type -- which is used below for testing particular `even` and `odd`. module Test (even : ℕ -> Bool) (odd : ℕ -> Bool) where open import Data.List.Base open import Data.Product using (_,′_) Test : Set Test = ( map even (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []) ,′ map odd (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []) ) ≡ ( true ∷ false ∷ true ∷ false ∷ true ∷ false ∷ [] ,′ false ∷ true ∷ false ∷ true ∷ false ∷ true ∷ [] ) -- Brings `Test : (ℕ -> Bool) -> (ℕ -> Bool) -> Set` in scope. open Test module Classic where open import Data.Product -- We can use the most straightforward fixed-point operator in order to get mutual recursion. {-# TERMINATING #-} fix : ∀ {A} -> (A -> A) -> A fix f = f (fix f) -- We instantiate `fix` to be defined over a pair of functions. I.e. a generic fixed-point -- combinator for a family of two mutually recursive functions has this type signature: -- `∀ {A B} -> (A × B -> A × B) -> A × B` which is an instance of `∀ {A} -> (A -> A) -> A`. -- Here is the even-and-odd example. -- `even` is denoted as the first element of the resulting tuple, `odd` is the second. evenAndOdd : (ℕ -> Bool) × (ℕ -> Bool) evenAndOdd = fix $ λ p -> -- `even` returns `true` on `0` and calls `odd` on `suc` (λ { 0 -> true ; (suc n) -> proj₂ p n }) -- `odd` returns `false` on `0` and calls `even` on `suc` , (λ { 0 -> false ; (suc n) -> proj₁ p n }) even : ℕ -> Bool even = proj₁ evenAndOdd odd : ℕ -> Bool odd = proj₂ evenAndOdd test : Test even odd test = refl -- And that's all. -- This Approach -- 1. relies on laziness -- 2. relies on tuples -- 3. allows to encode a family of arbitrary number of mutually recursive functions -- of possibly distinct types -- There is one pitfall, though, if we write this in Haskell: -- evenAndOdd :: ((Int -> Bool), (Int -> Bool)) -- evenAndOdd = fix $ \(even, odd) -> -- ( (\n -> n == 0 || odd (n - 1)) -- , (\n -> n /= 0 && even (n - 1)) -- ) -- we'll get an infinite loop, because matching over tuples is strict in Haskell (in Agda it's lazy) -- which means that in order to return a tuple, you must first compute it to whnf, which is a loop. -- This is what the author of [1] stumpled upon. The fix is simple, though: just use lazy matching -- (aka irrefutable pattern) like this: -- evenAndOdd = fix $ \(~(even, odd)) -> ... -- In general, that's a good approach for a lazy language, but Plutus Core is a strict one (so far), -- so we need something else. Besides, we can do some pretty cool generalizations, so let's do them. module PartlyUncurried2 where open import Data.Product -- It is clear that we can transform -- ∀ {A B} -> (A × B -> A × B) -> A × B -- into -- ∀ {A B R} -> (A × B -> A × B) -> (A -> B -> R) -> R -- by Church-encoding `A × B` into `∀ {R} -> (A -> B -> R) -> R`. -- However in our case we can also transform -- A × B -> A × B -- into -- ∀ {Q} -> (A -> B -> Q) -> A -> B -> Q -- Ignoring the former transformation right now, but performing the latter we get the following: fix2 : ∀ {A B} -> (∀ {Q} -> (A -> B -> Q) -> A -> B -> Q) -> A × B fix2 f = f (λ x y -> x) (proj₁ (fix2 f)) (proj₂ (fix2 f)) , f (λ x y -> y) (proj₁ (fix2 f)) (proj₂ (fix2 f)) -- `f` is what was of the `A × B -> A × B` type previously, but now instead of receiving a tuple -- and defining a tuple, `f` receives a selector and two values of types `A` and `B`. The values -- represent the functions being defined, while the selector is needed in order to select one of -- these functions. -- Consider the example: evenAndOdd : (ℕ -> Bool) × (ℕ -> Bool) evenAndOdd = fix2 $ λ select even odd -> select (λ { 0 -> true ; (suc n) -> odd n }) (λ { 0 -> false ; (suc n) -> even n }) -- `select` is only instantiated to either `λ x y -> x` or `λ x y -> y` which allow us -- to select the branch we want to go in. When defining the `even` function, we want to go in -- the first branch and thus instantiate `select` with `λ x y -> x`. When defining `odd`, -- we want the second branch and thus instantiate `select` with `λ x y -> y`. -- All these instantiations happen in the `fix2` function itself. -- It is instructive to inline `fix2` and `select` along with the particular selectors. We get: evenAndOdd-inlined : (ℕ -> Bool) × (ℕ -> Bool) evenAndOdd-inlined = defineEven (proj₁ evenAndOdd-inlined) (proj₂ evenAndOdd-inlined) , defineOdd (proj₁ evenAndOdd-inlined) (proj₂ evenAndOdd-inlined) where defineEven : (ℕ -> Bool) -> (ℕ -> Bool) -> ℕ -> Bool defineEven even odd = λ { 0 -> true ; (suc n) -> odd n } defineOdd : (ℕ -> Bool) -> (ℕ -> Bool) -> ℕ -> Bool defineOdd even odd = λ { 0 -> false ; (suc n) -> even n } -- I.e. each definition is parameterized by both functions and this is just the same fixed point -- of a tuple of functions that we've seen before. test : Test (proj₁ evenAndOdd) (proj₂ evenAndOdd) test = refl test-inlined : Test (proj₁ evenAndOdd-inlined) (proj₂ evenAndOdd-inlined) test-inlined = refl module Uncurried where -- We can now do another twist and turn `A × B` into `∀ {R} -> (A -> B -> R) -> R` which finally -- allows us to get rid of tuples: fix2 : ∀ {A B R} -> (∀ {Q} -> (A -> B -> Q) -> A -> B -> Q) -> (A -> B -> R) -> R fix2 f k = k (fix2 f (f λ x y -> x)) (fix2 f (f λ x y -> y)) -- `k` is the continuation that represents a Church-encoded tuple returned as the result. -- But... if `k` is just another way to construct a tuple, how are we not keeping `f` outside of -- recursion? Previously it was `fix f = f (fix f)` or -- fix2 f = f (λ x y -> x) (proj₁ (fix2 f)) (proj₂ (fix2 f)) -- , f (λ x y -> y) (proj₁ (fix2 f)) (proj₂ (fix2 f)) -- i.e. `f` is always an outermost call and recursive calls are somewhere inside. But in the -- definition above `f` is inside the recursive call. How is that? Watch the hands: -- fix2 f k [1] -- = k (fix2 f (f λ x y -> x)) (fix2 f (f λ x y -> y)) [2] -- ~ k (fix2 f (f (λ x y -> x))) (fix2 f (f (λ x y -> y))) [3] -- ~ k (f (λ x y -> x) (fix2 f (f λ x y -> x)) (fix2 f (f λ x y -> y))) -- (f (λ x y -> y) (fix2 f (f λ x y -> y)) (fix2 f (f λ x y -> y))) -- [1] unfold the definition of `fix2` -- [2] add parens around selectors for clarity -- [3] unfold the definition of `fix` in both the arguments of `k` -- The result is very similar to the one from the previous section -- (quoted in the snippet several lines above). -- And the test: evenAndOdd : ∀ {R} -> ((ℕ -> Bool) -> (ℕ -> Bool) -> R) -> R evenAndOdd = fix2 $ λ select even odd -> select (λ { 0 -> true ; (suc n) -> odd n }) (λ { 0 -> false ; (suc n) -> even n }) test : Test (evenAndOdd λ x y -> x) (evenAndOdd λ x y -> y) test = refl -- It is straighforward to define a fixed-point combinator for a family of three mutually -- recursive functions: fix3 : ∀ {A B C R} -> (∀ {Q} -> (A -> B -> C -> Q) -> A -> B -> C -> Q) -> (A -> B -> C -> R) -> R fix3 f k = k (fix3 f (f λ x y z -> x)) (fix3 f (f λ x y z -> y)) (fix3 f (f λ x y z -> z)) -- The pattern is clear and we can abstract it. module UncurriedGeneral where -- The type signatures of the fixed point combinators from the above -- ∀ {A B} -> (∀ {Q} -> (A -> B -> Q) -> A -> B -> Q) -> ∀ {R} -> (A -> B -> R) -> R -- ∀ {A B C} -> (∀ {Q} -> (A -> B -> C -> Q) -> A -> B -> C -> Q) -> ∀ {R} -> (A -> B -> C -> R) -> R -- (`∀ {R}` is moved slightly righter than what it was previously, because it helps readability below) -- can be generalized to -- ∀ {F} -> (∀ {Q} -> F Q -> F Q) -> ∀ {R} -> F R -> R -- with `F` being `λ X -> A -> B -> X` in the first case and `λ X -> A -> B -> C -> X` in the second. -- That's fact (1). -- Now let's look at the definitions. There we see -- fix2 f k = k (fix2 f (f λ x y -> x)) (fix2 f (f λ x y -> y)) -- fix3 f k = k (fix3 f (f λ x y z -> x)) (fix3 f (f λ x y z -> y)) (fix3 f (f λ x y z -> z)) -- i.e. each recursive call is parameterized by the `f` that never changes, but also by -- the `f` applied to a selector and selectors do change. Thus the -- λ selector -> fix2 f (f selector) -- λ selector -> fix3 f (f selector) -- parts can be abstracted into something like -- λ selector -> fixSome f (f selector) -- where `fixSome` can be both `fix2` and `fix3` depending on what you instantiate it with. -- Then we only need combinators that duplicate the recursive case an appropriate number of times -- (2 for `fix2` and 3 for `fix3`) and supply a selector to each of the duplicates. That's fact (2). -- And those combinators have to be of the same type, so we can pass them to the generic -- fixed-point combinator we're deriving. -- To infer the type of those combinators we start by looking at the types of -- λ selector -> fix2 f (f selector) -- λ selector -> fix3 f (f selector) -- which are -- ∀ {Q} -> (A -> B -> Q) -> Q -- ∀ {Q} -> (A -> B -> C -> Q) -> Q -- correspondingly. I.e. the unifying type of -- λ selector -> fixSome f (f selector) -- is `∀ {Q} -> F Q -> Q`. -- Therefore, the combinators receive something of type `∀ {Q} -> F Q -> Q` and return something of -- type `∀ {R} -> F R -> R` (the same type, just alpha-converted for convenience), because that's -- what `fix2` and `fix3` and thus the generic fixed-point combinator return. -- I.e. the whole unifying type of those combinators is -- (∀ {R} -> (∀ {Q} -> F Q -> Q) -> F R -> R) -- That's fact (3). -- Assembling everything together, we arrive at fixBy : ∀ {F : Set -> Set} -> ((∀ {Q} -> F Q -> Q) -> ∀ {R} -> F R -> R) -- by fact (3) -> (∀ {Q} -> F Q -> F Q) -> ∀ {R} -> F R -> R -- by fact (1) fixBy by f = by (fixBy by f ∘ f) -- by fact (2) -- Let's now implement particular `by`s: by2 : ∀ {A B} -> (∀ {Q} -> (A -> B -> Q) -> Q) -> ∀ {R} -> (A -> B -> R) -> R by2 r k = k (r λ x y -> x) (r λ x y -> y) by3 : ∀ {A B C} -> (∀ {Q} -> (A -> B -> C -> Q) -> Q) -> ∀ {R} -> (A -> B -> C -> R) -> R by3 r k = k (r λ x y z -> x) (r λ x y z -> y) (r λ x y z -> z) -- and fixed-points combinators from the previous section in terms of what we derived in this one: fix2 : ∀ {A B} -> (∀ {Q} -> (A -> B -> Q) -> A -> B -> Q) -> ∀ {R} -> (A -> B -> R) -> R fix2 = fixBy by2 fix3 : ∀ {A B C} -> (∀ {Q} -> (A -> B -> C -> Q) -> A -> B -> C -> Q) -> ∀ {R} -> (A -> B -> C -> R) -> R fix3 = fixBy by3 -- That's it. One `fixBy` to rule them all. The final test: evenAndOdd : ∀ {R} -> ((ℕ -> Bool) -> (ℕ -> Bool) -> R) -> R evenAndOdd = fix2 $ λ select even odd -> select (λ { 0 -> true ; (suc n) -> odd n }) (λ { 0 -> false ; (suc n) -> even n }) test : Test (evenAndOdd λ x y -> x) (evenAndOdd λ x y -> y) test = refl module LazinessStrictness where open UncurriedGeneral using (fixBy) -- So what about strictness? `fixBy` is generic enough to allow both lazy and strict derivatives. -- The version of strict `fix2` looks like this in Haskell: -- apply :: (a -> b) -> a -> b -- apply = ($!) -- fix2 -- :: ((a1 -> b1) -> (a2 -> b2) -> a1 -> b1) -- -> ((a1 -> b1) -> (a2 -> b2) -> a2 -> b2) -- -> ((a1 -> b1) -> (a2 -> b2) -> r) -> r -- fix2 f g k = k -- (\x1 -> f `apply` fix2 f g (\x y -> x) `apply` fix2 f g (\x y -> y) `apply` x1) -- (\x2 -> g `apply` fix2 f g (\x y -> x) `apply` fix2 f g (\x y -> y) `apply` x2) -- This is just like the Z combinator is of type `((a -> b) -> a -> b) -> a -> b`, so that it can -- be used to get fixed points of functions in a strict language where the Y combinator loops forever. -- The version of `fix2` that works in a strict language can be defined as follows: by2' : ∀ {A₁ B₁ A₂ B₂} -> (∀ {Q} -> ((A₁ -> B₁) -> (A₂ -> B₂) -> Q) -> Q) -> ∀ {R} -> ((A₁ -> B₁) -> (A₂ -> B₂) -> R) -> R by2' r k = k (λ x₁ -> r λ f₁ f₂ -> f₁ x₁) (λ x₂ -> r λ f₁ f₂ -> f₂ x₂) fix2' : ∀ {A₁ B₁ A₂ B₂} -> (∀ {Q} -> ((A₁ -> B₁) -> (A₂ -> B₂) -> Q) -> (A₁ -> B₁) -> (A₂ -> B₂) -> Q) -> ∀ {R} -> ((A₁ -> B₁) -> (A₂ -> B₂) -> R) -> R fix2' = fixBy by2' -- The difference is that in by2 : ∀ {A B} -> (∀ {Q} -> (A -> B -> Q) -> Q) -> ∀ {R} -> (A -> B -> R) -> R by2 r k = k (r λ x y -> x) (r λ x y -> y) -- both calls to `r` are forced before `k` returns, while in `by2'` additional lambdas that bind -- `x₁` and `x₂` block the recursive calls from being forced, so `k` at some point can decide not to -- recurse anymore (i.e. not to force recursive calls) and return a result instead. module ComputeUncurriedGeneral where -- You might wonder whether we can define a single `fixN` which receives a natural number and -- computes the appropriate fixed-point combinator of mutually recursive functions. E.g. -- fixN 2 ~> fix2 -- fixN 3 ~> fix3 -- So that we do not even need to specify `by2` and `by3` by ourselves. Yes we can do that, see [2] -- (the naming is slightly different there). -- Moreover, we can assign a type to `fixN` in pure System Fω, see [3]. module References where -- [1] "Mutual Recursion in Final Encoding", Andreas Herrmann -- https://aherrmann.github.io/programming/2016/05/28/mutual-recursion-in-final-encoding/ -- [2] https://gist.github.com/effectfully/b3185437da14322c775f4a7691b6fe1f#file-mutualfixgenericcompute-agda -- [3] https://gist.github.com/effectfully/b3185437da14322c775f4a7691b6fe1f#file-mutualfixgenericcomputenondep-agda
{ "alphanum_fraction": 0.5584079463, "avg_line_length": 40.2704225352, "ext": "agda", "hexsha": "5a62e25677a7123579e2fd7955a1ea580f73716c", "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": "9177aee383e368154b4c7bc1863fb9746f7cfe42", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jbgi/plutus", "max_forks_repo_path": "docs/fomega/mutual-term-level-recursion/FixN.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9177aee383e368154b4c7bc1863fb9746f7cfe42", "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": "jbgi/plutus", "max_issues_repo_path": "docs/fomega/mutual-term-level-recursion/FixN.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "9177aee383e368154b4c7bc1863fb9746f7cfe42", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jbgi/plutus", "max_stars_repo_path": "docs/fomega/mutual-term-level-recursion/FixN.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4815, "size": 14296 }
module Basic.Compiler.CorrectTo where open import Data.List open import Relation.Binary.PropositionalEquality open import Basic.Compiler.Code open import Basic.AST open import Basic.BigStep open import Utils.Decidable {- Lemma 3.21 One half of the correctness proof for the compiler. The proof here is a bit neater than the one in the book. The book uses exercises 3.19 and 3.4 to concatenate instruction lists, while I use my _▷*<>_, which does the same in one step. Otherwise the proofs are the same, and there's not much space for variations. -} 𝓒-correct-to : ∀ {n}{S : St n}{s s'} → ⟨ S , s ⟩⟱ s' → ⟨ 𝓒⟦ S ⟧ˢ , [] , s ⟩▷*⟨ [] , [] , s' ⟩ 𝓒-correct-to (ass {_}{x}{a}) = 𝓒-Exp-nat a ▷*<> STORE x ∷ done 𝓒-correct-to skip = NOOP ∷ done 𝓒-correct-to (a , b) = 𝓒-correct-to a ▷*<> 𝓒-correct-to b 𝓒-correct-to (if-true {s = s}{b = b} x p) with 𝓒-Exp-bool {e = []}{s = s} b ... | condition rewrite T→≡true x = condition ▷*<> BRANCH-[] ∷ 𝓒-correct-to p 𝓒-correct-to (if-false {s = s}{b = b} x p) with 𝓒-Exp-bool {e = []}{s = s} b ... | condition rewrite F→≡false x = condition ▷*<> BRANCH-[] ∷ 𝓒-correct-to p 𝓒-correct-to (while-true {s}{b = b} x p k) with 𝓒-Exp-bool {e = []}{s = s} b ... | condition rewrite T→≡true x = LOOP ∷ condition ▷*<> BRANCH-[] ∷ 𝓒-correct-to p ▷*<> 𝓒-correct-to k 𝓒-correct-to (while-false {s}{S}{b} x) with 𝓒-Exp-bool {e = []}{s = s} b ... | condition rewrite F→≡false x = LOOP ∷ condition ▷*<> BRANCH-[] ∷ NOOP ∷ done
{ "alphanum_fraction": 0.6237288136, "avg_line_length": 32.0652173913, "ext": "agda", "hexsha": "631fe72bfcbdcd7b93c91780b242a4628f89dfd7", "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": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_path": "Basic/Compiler/CorrectTo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "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": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_path": "Basic/Compiler/CorrectTo.agda", "max_line_length": 93, "max_stars_count": 8, "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_path": "Basic/Compiler/CorrectTo.agda", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "num_tokens": 582, "size": 1475 }
-- Paths in a graph {-# OPTIONS --safe #-} module Cubical.Data.Graph.Path where open import Cubical.Data.Graph.Base open import Cubical.Data.List.Base hiding (_++_) open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Data.Sigma.Base hiding (Path) open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude hiding (Path) module _ {ℓv ℓe : Level} where module _ (G : Graph ℓv ℓe) where data Path : (v w : Node G) → Type (ℓ-max ℓv ℓe) where pnil : ∀ {v} → Path v v pcons : ∀ {v w x} → Path v w → Edge G w x → Path v x -- Path concatenation ccat : ∀ {v w x} → Path v w → Path w x → Path v x ccat P pnil = P ccat P (pcons Q e) = pcons (ccat P Q) e private _++_ = ccat infixr 20 _++_ -- Some properties pnil++ : ∀ {v w} (P : Path v w) → pnil ++ P ≡ P pnil++ pnil = refl pnil++ (pcons P e) = cong (λ P → pcons P e) (pnil++ _) ++assoc : ∀ {v w x y} (P : Path v w) (Q : Path w x) (R : Path x y) → (P ++ Q) ++ R ≡ P ++ (Q ++ R) ++assoc P Q pnil = refl ++assoc P Q (pcons R e) = cong (λ P → pcons P e) (++assoc P Q R) -- Paths as lists pathToList : ∀ {v w} → Path v w → List (Σ[ x ∈ Node G ] Σ[ y ∈ Node G ] Edge G x y) pathToList pnil = [] pathToList (pcons P e) = (_ , _ , e) ∷ (pathToList P) -- Path v w is a set -- Lemma 4.2 of https://arxiv.org/abs/2112.06609 module _ (isSetNode : isSet (Node G)) (isSetEdge : ∀ v w → isSet (Edge G v w)) where -- This is called ̂W (W-hat) in the paper PathWithLen : ℕ → Node G → Node G → Type (ℓ-max ℓv ℓe) PathWithLen 0 v w = Lift {j = ℓe} (v ≡ w) PathWithLen (suc n) v w = Σ[ k ∈ Node G ] (PathWithLen n v k × Edge G k w) isSetPathWithLen : ∀ n v w → isSet (PathWithLen n v w) isSetPathWithLen 0 _ _ = isOfHLevelLift 2 (isProp→isSet (isSetNode _ _)) isSetPathWithLen (suc n) _ _ = isSetΣ isSetNode λ _ → isSet× (isSetPathWithLen _ _ _) (isSetEdge _ _) isSet-ΣnPathWithLen : ∀ {v w} → isSet (Σ[ n ∈ ℕ ] PathWithLen n v w) isSet-ΣnPathWithLen = isSetΣ isSetℕ (λ _ → isSetPathWithLen _ _ _) Path→PathWithLen : ∀ {v w} → Path v w → Σ[ n ∈ ℕ ] PathWithLen n v w Path→PathWithLen pnil = 0 , lift refl Path→PathWithLen (pcons P e) = suc (Path→PathWithLen P .fst) , _ , Path→PathWithLen P .snd , e PathWithLen→Path : ∀ {v w} → Σ[ n ∈ ℕ ] PathWithLen n v w → Path v w PathWithLen→Path (0 , q) = subst (Path _) (q .lower) pnil PathWithLen→Path (suc n , _ , pwl , e) = pcons (PathWithLen→Path (n , pwl)) e Path→PWL→Path : ∀ {v w} P → PathWithLen→Path {v} {w} (Path→PathWithLen P) ≡ P Path→PWL→Path {v} pnil = substRefl {B = Path v} pnil Path→PWL→Path (pcons P x) = cong₂ pcons (Path→PWL→Path _) refl isSetPath : ∀ v w → isSet (Path v w) isSetPath v w = isSetRetract Path→PathWithLen PathWithLen→Path Path→PWL→Path isSet-ΣnPathWithLen
{ "alphanum_fraction": 0.5695750892, "avg_line_length": 37.5975609756, "ext": "agda", "hexsha": "d8122924c2b111360a637fe8e9a0411f6b9f3218", "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/Data/Graph/Path.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/Data/Graph/Path.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/Graph/Path.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 1144, "size": 3083 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathGroupoid open import lib.PathFunctor open import lib.path-seq.Concat open import lib.path-seq.Reasoning module lib.path-seq.Inversion {i} {A : Type i} where seq-! : {a a' : A} → a =-= a' → a' =-= a seq-! [] = [] seq-! (p ◃∙ s) = seq-! s ∙▹ ! p seq-!-∙▹ : {a a' a'' : A} (s : a =-= a') (q : a' == a'') → seq-! (s ∙▹ q) == ! q ◃∙ seq-! s seq-!-∙▹ [] q = idp seq-!-∙▹ (p ◃∙ s) q = ap (_∙▹ ! p) (seq-!-∙▹ s q) seq-!-seq-! : {a a' : A} (s : a =-= a') → seq-! (seq-! s) == s seq-!-seq-! [] = idp seq-!-seq-! (p ◃∙ s) = seq-! (seq-! s ∙▹ ! p) =⟨ seq-!-∙▹ (seq-! s) (! p) ⟩ ! (! p) ◃∙ seq-! (seq-! s) =⟨ ap2 _◃∙_ (!-! p) (seq-!-seq-! s) ⟩ p ◃∙ s =∎ !-∙-seq : {a a' : A} (s : a =-= a') → ! (↯ s) ◃∎ =ₛ seq-! s !-∙-seq [] = =ₛ-in idp !-∙-seq (p ◃∙ s) = ! (↯ (p ◃∙ s)) ◃∎ =ₛ₁⟨ ap ! (↯-∙∙ (p ◃∎) s) ⟩ ! (p ∙ ↯ s) ◃∎ =ₛ⟨ =ₛ-in {t = ! (↯ s) ◃∙ ! p ◃∎} (!-∙ p (↯ s)) ⟩ ! (↯ s) ◃∙ ! p ◃∎ =ₛ⟨ 0 & 1 & !-∙-seq s ⟩ seq-! s ∙▹ ! p ∎ₛ ∙-!-seq : {a a' : A} (s : a =-= a') → seq-! s =ₛ ! (↯ s) ◃∎ ∙-!-seq s = !ₛ (!-∙-seq s) !-=ₛ : {a a' : A} {s t : a =-= a'} (e : s =ₛ t) → seq-! s =ₛ seq-! t !-=ₛ {s = s} {t = t} e = seq-! s =ₛ⟨ ∙-!-seq s ⟩ ! (↯ s) ◃∎ =ₛ₁⟨ ap ! (=ₛ-out e) ⟩ ! (↯ t) ◃∎ =ₛ⟨ !-∙-seq t ⟩ seq-! t ∎ₛ seq-!-inv-l : {a a' : A} (s : a =-= a') → seq-! s ∙∙ s =ₛ [] seq-!-inv-l s = =ₛ-in $ ↯ (seq-! s ∙∙ s) =⟨ ↯-∙∙ (seq-! s) s ⟩ ↯ (seq-! s) ∙ ↯ s =⟨ ap (_∙ ↯ s) (=ₛ-out (∙-!-seq s)) ⟩ ! (↯ s) ∙ ↯ s =⟨ !-inv-l (↯ s) ⟩ idp =∎ seq-!-inv-r : {a a' : A} (s : a =-= a') → s ∙∙ seq-! s =ₛ [] seq-!-inv-r s = =ₛ-in $ ↯ (s ∙∙ seq-! s) =⟨ ↯-∙∙ s (seq-! s) ⟩ ↯ s ∙ ↯ (seq-! s) =⟨ ap (↯ s ∙_) (=ₛ-out (∙-!-seq s)) ⟩ ↯ s ∙ ! (↯ s) =⟨ !-inv-r (↯ s) ⟩ idp =∎
{ "alphanum_fraction": 0.3300546448, "avg_line_length": 23.4615384615, "ext": "agda", "hexsha": "f7518e02072e87ac637dca74c6c5fb048d8bc4ac", "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": "core/lib/path-seq/Inversion.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": "core/lib/path-seq/Inversion.agda", "max_line_length": 56, "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": "core/lib/path-seq/Inversion.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": 1162, "size": 1830 }
module Avionics.List where open import Data.Bool using (Bool; true; false; T) open import Data.List as List using (List; []; _∷_; any) open import Data.List.Relation.Unary.Any using (Any; here; there) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_; inspect; [_]; refl) open import Avionics.Bool using (≡→T) ≡→any : ∀ {a} {A : Set a} (f) (ns : List A) → any f ns ≡ true → Any (T ∘ f) ns --→ Any (λ x → T (f x)) ns ≡→any f [] () ≡→any f (n ∷ ns) any-f-⟨n∷ns⟩≡true with f n | inspect f n ... | true | [ fn≡t ] = here (≡→T fn≡t) ... | false | _ = there (≡→any f ns any-f-⟨n∷ns⟩≡true) any→≡ : ∀ {a} {A : Set a} (f) (ns : List A) → Any (T ∘ f) ns → any f ns ≡ true any→≡ f (n ∷ _) (here _) with f n ... | true = refl -- or: T→≡ [*proof*from*here*] any→≡ f (n ∷ ns) (there Any[T∘f]ns) with f n ... | true = refl ... | false = any→≡ f ns Any[T∘f]ns any-map : ∀ {A B : Set} {p : B → Set} {ls : List A} (f : A → B) → Any p (List.map f ls) → Any (p ∘ f) ls --any-map {ls = []} _ () any-map {ls = l ∷ ls} f (here pb) = here pb any-map {ls = l ∷ ls} f (there pb) = there (any-map f pb) any-map-rev : ∀ {A B : Set} {p : B → Set} {ls : List A} (f : A → B) → Any (p ∘ f) ls → Any p (List.map f ls) any-map-rev {ls = l ∷ ls} f (here pb) = here pb any-map-rev {ls = l ∷ ls} f (there pb) = there (any-map-rev f pb)
{ "alphanum_fraction": 0.5137931034, "avg_line_length": 32.9545454545, "ext": "agda", "hexsha": "2e1c4a16b3287b59508d7cf449f195e67c1fe747", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_forks_event_min_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "RPI-WCL/safety-envelopes-sentinels", "max_forks_repo_path": "agda/Avionics/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "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": "RPI-WCL/safety-envelopes-sentinels", "max_issues_repo_path": "agda/Avionics/List.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "RPI-WCL/safety-envelopes-sentinels", "max_stars_repo_path": "agda/Avionics/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 581, "size": 1450 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The Either type which calls out to Haskell via the FFI ------------------------------------------------------------------------ {-# OPTIONS --without-K #-} module Foreign.Haskell.Either where open import Level open import Data.Sum.Base using (_⊎_; inj₁; inj₂) private variable a b : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Definition data Either (A : Set a) (B : Set b) : Set (a ⊔ b) where left : A → Either A B right : B → Either A B {-# FOREIGN GHC type AgdaEither l1 l2 a b = Either a b #-} {-# COMPILE GHC Either = data MAlonzo.Code.Foreign.Haskell.Either.AgdaEither (Left | Right) #-} ------------------------------------------------------------------------ -- Conversion toForeign : A ⊎ B → Either A B toForeign (inj₁ a) = left a toForeign (inj₂ b) = right b fromForeign : Either A B → A ⊎ B fromForeign (left a) = inj₁ a fromForeign (right b) = inj₂ b
{ "alphanum_fraction": 0.4740321058, "avg_line_length": 26.475, "ext": "agda", "hexsha": "5b28c6eeb7fe67a80ddf76d33fcb9850cb5f7056", "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/Foreign/Haskell/Either.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/Foreign/Haskell/Either.agda", "max_line_length": 95, "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/Foreign/Haskell/Either.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": 253, "size": 1059 }
{-# OPTIONS --without-K --safe #-} -- Definition of Monoidal Category -- Big design decision that differs from the previous version: -- Do not go through "Functor.Power" to encode variables and work -- at the level of NaturalIsomorphisms, instead work at the object/morphism -- level, via the more direct _⊗₀_ _⊗₁_ _⊗- -⊗_. -- The original design needed quite a few contortions to get things working, -- but these are simply not needed when working directly with the morphisms. -- -- Smaller design decision: export some items with long names -- (unitorˡ, unitorʳ and associator), but internally work with the more classical -- short greek names (λ, ρ and α respectively). module Categories.Category.Monoidal where open import Categories.Category.Monoidal.Core public
{ "alphanum_fraction": 0.7616580311, "avg_line_length": 40.6315789474, "ext": "agda", "hexsha": "5831f84d13d42c93dd26d269a1b30eb5f13e8d3b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 189, "size": 772 }
module TicketServer where open import IO using (run; putStrLn; mapM′; _>>_) open import Coinduction using (♯_) open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Pos as ℕ⁺ using (ℕ⁺; suc; NumberPos) open import Data.String using (String) open import Data.List using (List; []; _∷_; map) open import Data.Colist using (fromList) open import Function using (_$_; _∘_) open import Data.Environment open import nodcap.Base open import nodcap.Typing open import nodcap.Norm open import nodcap.Show renaming (showTerm to show) open import nodcap.NF.Show renaming (showTerm to showNF) Ticket UserId Sale Receipt : Type Ticket = ⊥ ⊕ ⊥ UserId = 𝟏 ⊕ 𝟏 Sale = UserId ⊸ Ticket Receipt = UserId ⊗ Ticket ticket₁ ticket₂ : {Γ : Environment} → ⊢ Γ → ⊢ Ticket ∷ Γ ticket₁ x = sel₁ (wait x) ticket₂ x = sel₂ (wait x) sale₁ sale₂ : {Γ : Environment} → ⊢ Γ → ⊢ Sale ∷ Receipt ∷ Γ sale₁ x = recv $ exch (bbl []) $ ticket₁ $ exch (bbl []) $ send ax (ticket₁ x) sale₂ x = recv $ exch (bbl []) $ ticket₂ $ exch (bbl []) $ send ax (ticket₂ x) client₁ client₂ : ⊢ Sale ^ ∷ [] client₁ = send (sel₁ halt) (case halt halt) client₂ = send (sel₂ halt) (case halt halt) server : ⊢ ?[ suc (suc zero) ] Sale ∷ Receipt ∷ Receipt ∷ 𝟏 ∷ [] server = cont $ mk?₁ $ exch (bwd (_ ∷ []) (_ ∷ [])) $ sale₁ $ mk?₁ $ sale₂ $ halt clients : ⊢ ![ 2 ] (Sale ^) ∷ [] clients = pool (mk!₁ client₁) (mk!₁ client₂) main = run (mapM′ putStrLn (fromList strs)) where proc = cut server clients strs = "Process:" ∷ show proc ∷ "Result:" ∷ map showNF (nfND proc) -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.6205003051, "avg_line_length": 21.8533333333, "ext": "agda", "hexsha": "6b92918472db353438edcbefdb9c5f076fa7bcf4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/TicketServer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "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": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/TicketServer.agda", "max_line_length": 64, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/TicketServer.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 574, "size": 1639 }
postulate A : Set F : (A : Set₁) → (A → A → Set) → Set syntax F A (λ x y → B) = y , y ⟨ A ∼ B ⟩ x
{ "alphanum_fraction": 0.427184466, "avg_line_length": 17.1666666667, "ext": "agda", "hexsha": "d5aab7a483cd3232e08b43544ca1d4c7c2a8d581", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue394-2.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue394-2.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue394-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 51, "size": 103 }
module Cats.Category.Slice where open import Data.Product using (_,_ ; proj₁ ; proj₂) open import Level open import Relation.Binary using (IsEquivalence ; _Preserves₂_⟶_⟶_) open import Cats.Category module _ {lo la l≈} (C : Category lo la l≈) (X : Category.Obj C) where infixr 9 _∘_ infixr 4 _≈_ private module C = Category C module ≈ = C.≈ record Obj : Set (lo ⊔ la) where constructor mkObj field {Dom} : C.Obj arr : Dom C.⇒ X open Obj record _⇒_ (f g : Obj) : Set (la ⊔ l≈) where field dom : Dom f C.⇒ Dom g commute : arr f C.≈ arr g C.∘ dom open _⇒_ record _≈_ {A B} (F G : A ⇒ B) : Set l≈ where -- [1] constructor ≈-i field dom : dom F C.≈ dom G -- [1] This could also be defined as -- -- F ≈ G = dom F C.≈ dom G -- -- but Agda was then giving me very strange unsolved metas in _/_ below. id : ∀ {A} → A ⇒ A id = record { dom = C.id ; commute = ≈.sym C.id-r } _∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C) _∘_ {F} {G} {H} record { dom = F-dom ; commute = F-commute} record { dom = G-dom ; commute = G-commute} = record { dom = F-dom C.∘ G-dom ; commute = begin arr F ≈⟨ G-commute ⟩ arr G C.∘ G-dom ≈⟨ C.∘-resp-l F-commute ⟩ (arr H C.∘ F-dom) C.∘ G-dom ≈⟨ C.assoc ⟩ arr H C.∘ F-dom C.∘ G-dom ∎ } where open C.≈-Reasoning ≈-equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B}) ≈-equiv = record { refl = ≈-i ≈.refl ; sym = λ { (≈-i eq) → ≈-i (≈.sym eq) } ; trans = λ { (≈-i eq₁) (≈-i eq₂) → ≈-i (≈.trans eq₁ eq₂) } } ∘-preserves-≈ : ∀ {A B C} → _∘_ {A} {B} {C} Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_ ∘-preserves-≈ (≈-i eq₁) (≈-i eq₂) = ≈-i (C.∘-resp eq₁ eq₂) id-identity-r : ∀ {A B} {F : A ⇒ B} → F ∘ id ≈ F id-identity-r = ≈-i C.id-r id-identity-l : ∀ {A B} {F : A ⇒ B} → id ∘ F ≈ F id-identity-l = ≈-i C.id-l ∘-assoc : ∀ {A B C D} {F : C ⇒ D} {G : B ⇒ C} {H : A ⇒ B} → (F ∘ G) ∘ H ≈ F ∘ (G ∘ H) ∘-assoc = ≈-i C.assoc instance _/_ : Category (la ⊔ lo) (l≈ ⊔ la) l≈ _/_ = record { Obj = Obj ; _⇒_ = _⇒_ ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = ≈-equiv ; ∘-resp = ∘-preserves-≈ ; id-r = id-identity-r ; id-l = id-identity-l ; assoc = ∘-assoc } open Category _/_ using (IsTerminal ; IsUnique ; ∃!-intro) One : Obj One = mkObj C.id One-Terminal : IsTerminal One One-Terminal Y@(mkObj f) = ∃!-intro F _ F-Unique where F : Y ⇒ One F = record { dom = f ; commute = C.≈.sym C.id-l } F-Unique : IsUnique F F-Unique {record { dom = g ; commute = commute }} _ = ≈-i (≈.trans commute C.id-l)
{ "alphanum_fraction": 0.4725663717, "avg_line_length": 21.7307692308, "ext": "agda", "hexsha": "c224a7491be6881531e9d9c74a4ede05b3cab0f6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Slice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Slice.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Slice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1194, "size": 2825 }
-- An Agda implementation of the n queens program from the nofib -- benchmark. Very inefficient, uses unary natural numbers instead of -- machine integers. module N-queens where open import Category.Monad open import Coinduction open import Data.Bool hiding (_≟_) open import Data.Char hiding (_≟_) open import Data.Fin using (#_) open import Data.Digit open import Data.Integer as Z using (+_; _⊖_) open import Data.List as List open import Data.Maybe as Maybe open import Data.Nat open import Data.Nat.Show open import Data.String as String using (String) open import Data.Unit hiding (_≟_) open import Function open import IO using (IO) import IO.Primitive as Primitive open import Relation.Nullary.Decidable ------------------------------------------------------------------------ -- Things missing from the standard library take_[_…] : ℕ → ℕ → List ℕ take zero [ n …] = [] take suc k [ n …] = n ∷ take k [ suc n …] [_…_] : ℕ → ℕ → List ℕ [ m … n ] with compare m n [ .(suc (n + k)) … n ] | greater .n k = [] [ m … .m ] | equal .m = [ m ] [ m … .(suc (m + k)) ] | less .m k = take (2 + k) [ m …] guard : Bool → List ⊤ guard true = [ _ ] guard false = [] postulate getArgs′ : Primitive.IO (List String) {-# IMPORT System.Environment #-} {-# COMPILED getArgs′ System.Environment.getArgs #-} getArgs : IO (List String) getArgs = lift getArgs′ where open IO read : List Char → Maybe ℕ read [] = nothing read ds = fromDigits ∘ reverse <$> mapM Maybe.monad charToDigit ds where open RawMonad Maybe.monad charToDigit : Char → Maybe (Digit 10) charToDigit '0' = just (# 0) charToDigit '1' = just (# 1) charToDigit '2' = just (# 2) charToDigit '3' = just (# 3) charToDigit '4' = just (# 4) charToDigit '5' = just (# 5) charToDigit '6' = just (# 6) charToDigit '7' = just (# 7) charToDigit '8' = just (# 8) charToDigit '9' = just (# 9) charToDigit _ = nothing ------------------------------------------------------------------------ -- The main program nsoln : ℕ → ℕ nsoln nq = length (gen nq) where open RawMonad List.monad safe : ℕ → ℕ → List ℕ → Bool safe x d [] = true safe x d (q ∷ l) = not ⌊ x ≟ q ⌋ ∧ not ⌊ x ≟ q + d ⌋ ∧ not ⌊ + x Z.≟ q ⊖ d ⌋ ∧ -- Equivalent to previous line, because x ≥ 1: -- not ⌊ x ≟ q ∸ d ⌋ ∧ safe x (1 + d) l gen : ℕ → List (List ℕ) gen zero = [ [] ] gen (suc n) = gen n >>= λ b → [ 1 … nq ] >>= λ q → guard (safe q 1 b) >> return (q ∷ b) main = run (♯ getArgs >>= λ arg → ♯ main′ arg) where open IO main′ : List String → IO ⊤ main′ (arg ∷ []) with read (String.toList arg) ... | just n = putStrLn (show (nsoln n)) ... | nothing = return _ main′ _ = return _
{ "alphanum_fraction": 0.5374008962, "avg_line_length": 27.6285714286, "ext": "agda", "hexsha": "4c040deb586a667391a1dba4fc891a0e368fa44d", "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": "benchmark/nofib/N-queens.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "benchmark/nofib/N-queens.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "benchmark/nofib/N-queens.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 885, "size": 2901 }
------------------------------------------------------------------------ -- Logical equivalences ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Logical-equivalence where open import Prelude as P hiding (id) renaming (_∘_ to _⊚_) private variable a b p : Level @0 A B C D : Type a @0 P Q : A → Type p ------------------------------------------------------------------------ -- Logical equivalence -- A ⇔ B means that A and B are logically equivalent. infix 0 _⇔_ record _⇔_ {f t} (From : Type f) (To : Type t) : Type (f ⊔ t) where field to : From → To from : To → From ------------------------------------------------------------------------ -- Equivalence relation -- _⇔_ is an equivalence relation. id : A ⇔ A id = record { to = P.id ; from = P.id } inverse : A ⇔ B → B ⇔ A inverse A⇔B ._⇔_.to = let record { from = from } = A⇔B in from inverse A⇔B ._⇔_.from = let record { to = to } = A⇔B in to infixr 9 _∘_ _∘_ : B ⇔ C → A ⇔ B → A ⇔ C (f ∘ g) ._⇔_.to = let record { to = f-to } = f record { to = g-to } = g in f-to ⊚ g-to (f ∘ g) ._⇔_.from = let record { from = f-from } = f record { from = g-from } = g in g-from ⊚ f-from -- "Equational" reasoning combinators. infix -1 finally-⇔ infixr -2 step-⇔ -- For an explanation of why step-⇔ is defined in this way, see -- Equality.step-≡. step-⇔ : (@0 A : Type a) → B ⇔ C → A ⇔ B → A ⇔ C step-⇔ _ = _∘_ syntax step-⇔ A B⇔C A⇔B = A ⇔⟨ A⇔B ⟩ B⇔C finally-⇔ : (@0 A : Type a) (@0 B : Type b) → A ⇔ B → A ⇔ B finally-⇔ _ _ A⇔B = A⇔B syntax finally-⇔ A B A⇔B = A ⇔⟨ A⇔B ⟩□ B □ ------------------------------------------------------------------------ -- Preservation lemmas -- Note that all of the type arguments of these lemmas are erased. -- _⊎_ preserves logical equivalences. infixr 2 _×-cong_ _×-cong_ : A ⇔ C → B ⇔ D → A × B ⇔ C × D A⇔C ×-cong B⇔D = let record { to = to₁; from = from₁ } = A⇔C record { to = to₂; from = from₂ } = B⇔D in record { to = Σ-map to₁ to₂ ; from = Σ-map from₁ from₂ } -- ∃ preserves logical equivalences. ∃-cong : (∀ x → P x ⇔ Q x) → ∃ P ⇔ ∃ Q ∃-cong P⇔Q = record { to = λ (x , y) → x , let record { to = to } = P⇔Q x in to y ; from = λ (x , y) → x , let record { from = from } = P⇔Q x in from y } -- _⊎_ preserves logical equivalences. infixr 1 _⊎-cong_ _⊎-cong_ : A ⇔ C → B ⇔ D → A ⊎ B ⇔ C ⊎ D A⇔C ⊎-cong B⇔D = let record { to = to₁; from = from₁ } = A⇔C record { to = to₂; from = from₂ } = B⇔D in record { to = ⊎-map to₁ to₂ ; from = ⊎-map from₁ from₂ } -- The non-dependent function space preserves logical equivalences. →-cong : A ⇔ C → B ⇔ D → (A → B) ⇔ (C → D) →-cong A⇔C B⇔D = let record { to = to₁; from = from₁ } = A⇔C record { to = to₂; from = from₂ } = B⇔D in record { to = (to₂ ⊚_) ⊚ (_⊚ from₁) ; from = (from₂ ⊚_) ⊚ (_⊚ to₁) } -- Π preserves logical equivalences in its second argument. ∀-cong : ((x : A) → P x ⇔ Q x) → ((x : A) → P x) ⇔ ((x : A) → Q x) ∀-cong P⇔Q = record { to = λ f x → let record { to = to } = P⇔Q x in to (f x) ; from = λ f x → let record { from = from } = P⇔Q x in from (f x) } -- The implicit variant of Π preserves logical equivalences in its -- second argument. implicit-∀-cong : ({x : A} → P x ⇔ Q x) → ({x : A} → P x) ⇔ ({x : A} → Q x) implicit-∀-cong P⇔Q = record { to = λ f → let record { to = to } = P⇔Q in to f ; from = λ f → let record { from = from } = P⇔Q in from f } -- ↑ preserves logical equivalences. ↑-cong : B ⇔ C → ↑ a B ⇔ ↑ a C ↑-cong B⇔C = let record { to = to; from = from } = B⇔C in record { to = λ (lift x) → lift (to x) ; from = λ (lift x) → lift (from x) } -- _⇔_ preserves logical equivalences. ⇔-cong : A ⇔ B → C ⇔ D → (A ⇔ C) ⇔ (B ⇔ D) ⇔-cong {A = A} {B = B} {C = C} {D = D} A⇔B C⇔D = record { to = λ A⇔C → B ⇔⟨ inverse A⇔B ⟩ A ⇔⟨ A⇔C ⟩ C ⇔⟨ C⇔D ⟩□ D □ ; from = λ B⇔D → A ⇔⟨ A⇔B ⟩ B ⇔⟨ B⇔D ⟩ D ⇔⟨ inverse C⇔D ⟩□ C □ }
{ "alphanum_fraction": 0.4563822201, "avg_line_length": 24.3179190751, "ext": "agda", "hexsha": "f8b6fe6e21c27ff0b65ee8a63f79d6a335d938ed", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Logical-equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Logical-equivalence.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Logical-equivalence.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": 1749, "size": 4207 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.TLevel open import lib.types.Sigma open import lib.types.Pi module lib.types.Groupoid where record GroupoidStructure {i j} {El : Type i} (Arr : El → El → Type j) (_ : ∀ x y → has-level 0 (Arr x y)) : Type (lmax i j) where field ident : ∀ {x} → Arr x x inv : ∀ {x y} → Arr x y → Arr y x comp : ∀ {x y z} → Arr x y → Arr y z → Arr x z unit-l : ∀ {x y} (a : Arr x y) → comp ident a == a assoc : ∀ {x y z w} (a : Arr x y) (b : Arr y z) (c : Arr z w) → comp (comp a b) c == comp a (comp b c) inv-l : ∀ {x y } (a : Arr x y) → (comp (inv a) a) == ident private infix 80 _⊙_ _⊙_ = comp abstract inv-r : ∀ {x y} (a : Arr x y) → a ⊙ inv a == ident inv-r a = a ⊙ inv a =⟨ ! $ unit-l (a ⊙ inv a) ⟩ ident ⊙ (a ⊙ inv a) =⟨ ! $ inv-l (inv a) |in-ctx _⊙ (a ⊙ inv a) ⟩ (inv (inv a) ⊙ inv a) ⊙ (a ⊙ inv a) =⟨ assoc (inv (inv a)) (inv a) (a ⊙ inv a) ⟩ inv (inv a) ⊙ (inv a ⊙ (a ⊙ inv a)) =⟨ ! $ assoc (inv a) a (inv a) |in-ctx inv (inv a) ⊙_ ⟩ inv (inv a) ⊙ ((inv a ⊙ a) ⊙ inv a) =⟨ inv-l a |in-ctx (λ h → inv (inv a) ⊙ (h ⊙ inv a)) ⟩ inv (inv a) ⊙ (ident ⊙ inv a) =⟨ unit-l (inv a) |in-ctx inv (inv a) ⊙_ ⟩ inv (inv a) ⊙ inv a =⟨ inv-l (inv a) ⟩ ident =∎ unit-r : ∀ {x y} (a : Arr x y) → a ⊙ ident == a unit-r a = a ⊙ ident =⟨ ! (inv-l a) |in-ctx a ⊙_ ⟩ a ⊙ (inv a ⊙ a) =⟨ ! $ assoc a (inv a) a ⟩ (a ⊙ inv a) ⊙ a =⟨ inv-r a |in-ctx _⊙ a ⟩ ident ⊙ a =⟨ unit-l a ⟩ a =∎ record PreGroupoid i j : Type (lsucc (lmax i j)) where constructor groupoid field El : Type i Arr : El → El → Type j Arr-level : ∀ x y → has-level 0 (Arr x y) groupoid-struct : GroupoidStructure Arr Arr-level
{ "alphanum_fraction": 0.4585439838, "avg_line_length": 37.320754717, "ext": "agda", "hexsha": "db5b782861b558abb0cf173ac1c5a90a23fb5eb1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Groupoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Groupoid.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Groupoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 796, "size": 1978 }
-- Andreas, 2017-01-05, issue #2376 reporte by gallais -- Termination checker should eta-expand clauses to see more. -- This may have a slight performance penalty when computing call matrices, -- but not too big, as they are sparse. open import Agda.Builtin.Nat -- Arity ~ 300, still does not kill termination checker. T = Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat → Nat postulate t : T f : Nat → T g : Nat → Nat → T f = g 0 -- eta-expanded to f x ... = g 0 x ... g m zero = t g m (suc n) = f n
{ "alphanum_fraction": 0.5205417607, "avg_line_length": 48.152173913, "ext": "agda", "hexsha": "ef6410220b121a45caa1aee8cc9c8b5a2a731bed", "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/Issue2376.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/Issue2376.agda", "max_line_length": 75, "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/Issue2376.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": 756, "size": 2215 }
{-# OPTIONS --without-K --rewriting #-} module Generalize where data _≡_ {ℓ}{A : Set ℓ} (x : A) : A → Set ℓ where refl : x ≡ x infix 4 _≡_ {-# BUILTIN REWRITE _≡_ #-} ------------------------------------------------------------------ postulate Con : Set postulate Ty : (Γ : Con) → Set postulate Tms : (Γ Δ : Con) → Set postulate Tm : (Γ : Con)(A : Ty Γ) → Set ------------------------------------------------------------------ variable {Γ Δ Θ} : Con postulate • : Con -- • is \bub postulate _▹_ : ∀ Γ → Ty Γ → Con -- ▹ is \tw2 infixl 5 _▹_ variable {A B C} : Ty _ postulate _∘ᵀ_ : Ty Δ → Tms Γ Δ → Ty Γ infixl 6 _∘ᵀ_ variable {σ δ ν} : Tms _ _ postulate _∘_ : Tms Θ Δ → Tms Γ Θ → Tms Γ Δ infixr 7 _∘_ postulate id : Tms Γ Γ postulate ε : Tms Γ • postulate _,_ : (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) → Tms Γ (Δ ▹ A) infixl 5 _,_ postulate π₁ : Tms Γ (Δ ▹ A) → Tms Γ Δ variable {t u v} : Tm _ _ postulate π₂ : (σ : Tms Γ (Δ ▹ A)) → Tm Γ (A ∘ᵀ π₁ σ) postulate _∘ᵗ_ : Tm Δ A → (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) infixl 6 _∘ᵗ_ postulate ass : (σ ∘ δ) ∘ ν ≡ σ ∘ δ ∘ ν {-# REWRITE ass #-} postulate idl : id ∘ δ ≡ δ {-# REWRITE idl #-} postulate idr : δ ∘ id ≡ δ {-# REWRITE idr #-} postulate εη : δ ≡ ε -- can't rewrite, so we specialize this in the next two cases postulate εηid : id ≡ ε {-# REWRITE εηid #-} postulate εη∘ : ε ∘ δ ≡ ε {-# REWRITE εη∘ #-} postulate ,β₁ : π₁ (δ , t) ≡ δ {-# REWRITE ,β₁ #-} postulate ,β₂ : π₂ (δ , t) ≡ t {-# REWRITE ,β₂ #-} postulate ,η : (π₁ δ , π₂ δ) ≡ δ {-# REWRITE ,η #-} postulate [id]ᵀ : A ∘ᵀ id ≡ A {-# REWRITE [id]ᵀ #-} postulate [∘]ᵀ : A ∘ᵀ δ ∘ᵀ σ ≡ A ∘ᵀ δ ∘ σ {-# REWRITE [∘]ᵀ #-} postulate ,∘ : (δ , t) ∘ σ ≡ δ ∘ σ , t ∘ᵗ σ {-# REWRITE ,∘ #-} postulate [∘]ᵗ : t ∘ᵗ σ ∘ᵗ δ ≡ t ∘ᵗ σ ∘ δ {-# REWRITE [∘]ᵗ #-} postulate π₁∘ : π₁ δ ∘ σ ≡ π₁ (δ ∘ σ) {-# REWRITE π₁∘ #-} postulate π₂∘ : π₂ δ ∘ᵗ σ ≡ π₂ (δ ∘ σ) {-# REWRITE π₂∘ #-} postulate ∘id : t ∘ᵗ id ≡ t {-# REWRITE ∘id #-} _↑_ : ∀ σ A → Tms (Γ ▹ A ∘ᵀ σ) (Δ ▹ A) σ ↑ A = σ ∘ π₁ id , π₂ id ⟨_⟩ : Tm Γ A → Tms Γ (Γ ▹ A) ⟨ t ⟩ = id , t ------------------------------------------------------------------ postulate U : Ty Γ variable {a b c} : Tm _ U postulate El : Tm Γ U → Ty Γ postulate U[] : U ∘ᵀ σ ≡ U {-# REWRITE U[] #-} postulate El[] : El a ∘ᵀ σ ≡ El (a ∘ᵗ σ) {-# REWRITE El[] #-} ------------------------------------------------------------------ postulate Π : (a : Tm Γ U) → Ty (Γ ▹ El a) → Ty Γ postulate Π[] : Π a B ∘ᵀ σ ≡ Π (a ∘ᵗ σ) (B ∘ᵀ σ ↑ El a) {-# REWRITE Π[] #-} postulate app : Tm Γ (Π a B) → Tm (Γ ▹ El a) B postulate app[] : app t ∘ᵗ (σ ↑ El a) ≡ app (t ∘ᵗ σ) {-# REWRITE app[] #-}
{ "alphanum_fraction": 0.3801004394, "avg_line_length": 31.5445544554, "ext": "agda", "hexsha": "0b8d97bd7f99575ce628e48dcff6d47fc4d0b984", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Generalize.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Generalize.agda", "max_line_length": 102, "max_stars_count": 2, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Generalize.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 1309, "size": 3186 }
-- Andreas, 2020-05-18, issue #3933 -- -- Duplicate imports of the same modules should be cumulative, -- rather than overwriting the previous scope. {-# OPTIONS -v scope.import:10 #-} {-# OPTIONS -v scope:clash:20 #-} open import Agda.Builtin.Nat using () Nat = Agda.Builtin.Nat.Nat zero = Agda.Builtin.Nat.zero import Agda.Builtin.Nat using () works : Nat works = zero test : Agda.Builtin.Nat.Nat test = Agda.Builtin.Nat.zero -- Used to fail since the second import emptied -- the contents of module Agda.Builtin.Nat.
{ "alphanum_fraction": 0.7172675522, "avg_line_length": 21.9583333333, "ext": "agda", "hexsha": "9670af672367d0bbb714beca115db1d04504ab1a", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/Issue3933.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/Issue3933.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3933.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": 149, "size": 527 }
{-# OPTIONS --without-K --safe #-} module Cats.Category.Setoids.Facts where open import Cats.Category.Setoids.Facts.Exponential public using (hasExponentials) open import Cats.Category.Setoids.Facts.Initial public using (hasInitial) open import Cats.Category.Setoids.Facts.Limit public using (complete) open import Cats.Category.Setoids.Facts.Product public using (hasProducts ; hasBinaryProducts ; hasFiniteProducts) open import Cats.Category.Setoids.Facts.Terminal public using (hasTerminal) open import Cats.Category open import Cats.Category.Setoids using (Setoids) instance isCCC : ∀ {l} → IsCCC (Setoids l l) isCCC = record {}
{ "alphanum_fraction": 0.7779479326, "avg_line_length": 27.2083333333, "ext": "agda", "hexsha": "ad3aa0042f83bc6938c3f8c07befbb203352e977", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Category/Setoids/Facts.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/cats", "max_issues_repo_path": "Cats/Category/Setoids/Facts.agda", "max_line_length": 64, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Category/Setoids/Facts.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 155, "size": 653 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use Data.List.Relation.Unary.Any -- directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Any where open import Data.List.Relation.Unary.Any public {-# WARNING_ON_IMPORT "Data.List.Any was deprecated in v1.0. Use Data.List.Relation.Unary.Any instead." #-}
{ "alphanum_fraction": 0.5093167702, "avg_line_length": 26.8333333333, "ext": "agda", "hexsha": "827fa9d959f4f9cc4f57b9356a204ed7d93d0073", "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/Any.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/Any.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/Any.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": 87, "size": 483 }
{- 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 Optics.All open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Hash open import LibraBFT.Base.Types open import LibraBFT.Base.Encode open import LibraBFT.Base.ByteString open import LibraBFT.Base.PKCS open import LibraBFT.Impl.Base.Types open import LibraBFT.Impl.Consensus.Types.EpochIndep open import LibraBFT.Impl.Util.Crypto -- This module defines the types of messages that the implementation -- can send, along with properties defining ways in which votes can be -- represented in them, some useful functions, and definitions of how -- NetworkMsgs are signed. module LibraBFT.Impl.NetworkMsg where data NetworkMsg : Set where P : ProposalMsg → NetworkMsg V : VoteMsg → NetworkMsg C : CommitMsg → NetworkMsg P≢V : ∀ {p v} → P p ≢ V v P≢V () C≢V : ∀ {c v} → C c ≢ V v C≢V () V-inj : ∀ {vm1 vm2} → V vm1 ≡ V vm2 → vm1 ≡ vm2 V-inj refl = refl data _QC∈SyncInfo_ (qc : QuorumCert) (si : SyncInfo) : Set where withVoteSIHighQC : si ^∙ siHighestQuorumCert ≡ qc → qc QC∈SyncInfo si -- Note that we do not use the Lens here, because the Lens returns the siHighestQuorumcert in -- case siHighestCommitcert is nothing, and it was easier to directly handle the just case. We -- could use the Lens, and fix the proofs, but it seems simpler this way. withVoteSIHighCC : ₋siHighestCommitCert si ≡ just qc → qc QC∈SyncInfo si data _QC∈ProposalMsg_ (qc : QuorumCert) (pm : ProposalMsg) : Set where inProposal : pm ^∙ pmProposal ∙ bBlockData ∙ bdQuorumCert ≡ qc → qc QC∈ProposalMsg pm inPMSyncInfo : qc QC∈SyncInfo (pm ^∙ pmSyncInfo) → qc QC∈ProposalMsg pm data _QC∈CommitMsg_ (qc : QuorumCert) (cm : CommitMsg) : Set where withCommitMsg : cm ^∙ cmCert ≡ qc → qc QC∈CommitMsg cm data _QC∈NM_ (qc : QuorumCert) : NetworkMsg → Set where inP : ∀ {pm} → qc QC∈ProposalMsg pm → qc QC∈NM (P pm) inV : ∀ {vm} → qc QC∈SyncInfo (vm ^∙ vmSyncInfo) → qc QC∈NM (V vm) inC : ∀ {cm} → qc QC∈CommitMsg cm → qc QC∈NM (C cm) data _⊂Msg_ (v : Vote) : NetworkMsg → Set where vote∈vm : ∀ {si} → v ⊂Msg (V (VoteMsg∙new v si)) vote∈qc : ∀ {vs} {qc : QuorumCert} {nm} → vs ∈ qcVotes qc → rebuildVote qc vs ≈Vote v → qc QC∈NM nm → v ⊂Msg nm getEpoch : NetworkMsg → Epoch getEpoch (P p) = p ^∙ pmProposal ∙ bBlockData ∙ bdEpoch getEpoch (V (VoteMsg∙new v _)) = v ^∙ vEpoch getEpoch (C c) = c ^∙ cmEpoch -- Get the message's author, if it has one. Note that ProposalMsgs don't necessarily have -- authors; we care about the (honesty of) the author only for Proposals, not NilBlocks and -- Genesis. getAuthor : NetworkMsg → Maybe NodeId getAuthor (P p) with p ^∙ pmProposal ∙ bBlockData ∙ bdBlockType ...| Proposal _ auth = just auth ...| NilBlock = nothing ...| Genesis = nothing getAuthor (V v) = just (v ^∙ vmVote ∙ vAuthor) getAuthor (C c) = just (c ^∙ cmAuthor) ----------------------------------------------------------------------- -- Proof that network records are signable and may carry a signature -- ----------------------------------------------------------------------- Signed-pi-CommitMsg : (cm : CommitMsg) → (is1 is2 : (Is-just ∘ ₋cmSigMB) cm) → is1 ≡ is2 Signed-pi-CommitMsg (CommitMsg∙new _ _ _ _ .(just _)) (just _) (just _) = cong just refl instance -- A proposal message might carry a signature inside the block it -- is proposing. sig-ProposalMsg : WithSig ProposalMsg sig-ProposalMsg = record { Signed = Signed ∘ ₋pmProposal ; Signed-pi = Signed-pi-Blk ∘ ₋pmProposal ; isSigned? = isSigned? ∘ ₋pmProposal ; signature = signature ∘ ₋pmProposal ; signableFields = signableFields ∘ ₋pmProposal } sig-VoteMsg : WithSig VoteMsg sig-VoteMsg = record { Signed = Signed ∘ ₋vmVote ; Signed-pi = λ _ _ _ → Unit-pi ; isSigned? = isSigned? ∘ ₋vmVote ; signature = signature ∘ ₋vmVote ; signableFields = signableFields ∘ ₋vmVote } sig-CommitMsg : WithSig CommitMsg sig-CommitMsg = record { Signed = Is-just ∘ ₋cmSigMB ; Signed-pi = Signed-pi-CommitMsg ; isSigned? = λ cm → Maybe-Any-dec (λ _ → yes tt) (cm ^∙ cmSigMB) ; signature = λ { _ prf → to-witness prf } ; signableFields = λ cm → concat ( encode (cm ^∙ cmEpoch) ∷ encode (cm ^∙ cmAuthor) ∷ encode (cm ^∙ cmRound) ∷ encode (cm ^∙ cmCert) ∷ []) } --------------------------------------------------------- -- Network Records whose signatures have been verified -- --------------------------------------------------------- -- First we have to have some boilerplate to pattern match -- on the type of message to access the 'WithSig' instance -- on the fields... a bit ugly, but there's no other way, really. -- At least we quarantine them in a private block. private SignedNM : NetworkMsg → Set SignedNM (P x) = Signed x SignedNM (V x) = Signed x SignedNM (C x) = Signed x SignedNM-pi : ∀ (nm : NetworkMsg) → (is1 : SignedNM nm) → (is2 : SignedNM nm) → is1 ≡ is2 SignedNM-pi (P x) = Signed-pi x SignedNM-pi (V x) = Signed-pi x SignedNM-pi (C x) = Signed-pi x isSignedNM? : (nm : NetworkMsg) → Dec (SignedNM nm) isSignedNM? (P x) = isSigned? x isSignedNM? (V x) = isSigned? x isSignedNM? (C x) = isSigned? x signatureNM : (nm : NetworkMsg) → SignedNM nm → Signature signatureNM (P x) prf = signature x prf signatureNM (V x) prf = signature x prf signatureNM (C x) prf = signature x prf signableFieldsNM : NetworkMsg → ByteString signableFieldsNM (P x) = signableFields x signableFieldsNM (V x) = signableFields x signableFieldsNM (C x) = signableFields x instance sig-NetworkMsg : WithSig NetworkMsg sig-NetworkMsg = record { Signed = SignedNM ; Signed-pi = SignedNM-pi ; isSigned? = isSignedNM? ; signature = signatureNM ; signableFields = signableFieldsNM }
{ "alphanum_fraction": 0.5840892193, "avg_line_length": 39.7928994083, "ext": "agda", "hexsha": "c96bef920aa8243d578bb3cfa3bdbfede5484ff1", "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/Impl/NetworkMsg.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/Impl/NetworkMsg.agda", "max_line_length": 111, "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/Impl/NetworkMsg.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2057, "size": 6725 }
module Oscar.Data.Fin where open import Data.Fin public using (Fin; zero; suc) -- open import Oscar.Data.Fin.Core public -- --open import Data.Fin hiding (thin; thick; check) public -- --open import Data.Fin.Properties hiding (thin-injective; thick-thin; thin-check-id) public -- -- module _ where -- -- open import Data.Product -- -- open import Oscar.Data.Vec -- -- open import Data.Nat -- -- open import Function -- -- enumFin⋆ : ∀ n → ∃ λ (F : Vec (Fin n) n) → ∀ f → f ∈ F -- -- enumFin⋆ n = tabulate⋆ id -- -- open import Agda.Builtin.Equality -- -- open import Agda.Builtin.Nat -- -- open import Relation.Binary.PropositionalEquality -- -- open import Relation.Nullary -- -- open import Data.Product -- -- open import Data.Empty -- -- open import Function -- -- previous : ∀ {n} -> Fin (suc (suc n)) -> Fin (suc n) -- -- previous (suc x) = x -- -- previous zero = zero -- -- module Thin where -- -- fact1 : ∀ {n} x y z -> thin {n} x y ≡ thin x z -> y ≡ z -- -- fact1 zero y .y refl = refl -- -- fact1 (suc x) zero zero r = refl -- -- fact1 (suc x) zero (suc z) () -- -- fact1 (suc x) (suc y) zero () -- -- fact1 (suc x) (suc y) (suc z) r = cong suc (fact1 x y z (cong previous r)) -- -- fact2 : ∀ {n} x y -> ¬ thin {n} x y ≡ x -- -- fact2 zero y () -- -- fact2 (suc x) zero () -- -- fact2 (suc x) (suc y) r = fact2 x y (cong previous r) -- -- fact3 : ∀{n} x y -> ¬ x ≡ y -> ∃ λ y' -> thin {n} x y' ≡ y -- -- fact3 zero zero ne = ⊥-elim (ne refl) -- -- fact3 zero (suc y) _ = y , refl -- -- fact3 {zero} (suc ()) _ _ -- -- fact3 {suc n} (suc x) zero ne = zero , refl -- -- fact3 {suc n} (suc x) (suc y) ne with y | fact3 x y (ne ∘ cong suc) -- -- ... | .(thin x y') | y' , refl = suc y' , refl -- -- open import Data.Maybe -- -- open import Category.Functor -- -- open import Category.Monad -- -- import Level -- -- open RawMonad (Data.Maybe.monad {Level.zero}) -- -- open import Data.Sum -- -- _≡Fin_ : ∀ {n} -> (x y : Fin n) -> Dec (x ≡ y) -- -- zero ≡Fin zero = yes refl -- -- zero ≡Fin suc y = no λ () -- -- suc x ≡Fin zero = no λ () -- -- suc {suc _} x ≡Fin suc y with x ≡Fin y -- -- ... | yes r = yes (cong suc r) -- -- ... | no r = no λ e -> r (cong previous e) -- -- suc {zero} () ≡Fin _ -- -- module Thick where -- -- half1 : ∀ {n} (x : Fin (suc n)) -> check x x ≡ nothing -- -- half1 zero = refl -- -- half1 {suc _} (suc x) = cong ((_<$>_ suc)) (half1 x) -- -- half1 {zero} (suc ()) -- -- half2 : ∀ {n} (x : Fin (suc n)) y -> ∀ y' -> thin x y' ≡ y -> check x y ≡ just y' -- -- half2 zero zero y' () -- -- half2 zero (suc y) .y refl = refl -- -- half2 {suc n} (suc x) zero zero refl = refl -- -- half2 {suc _} (suc _) zero (suc _) () -- -- half2 {suc n} (suc x) (suc y) zero () -- -- half2 {suc n} (suc x) (suc .(thin x y')) (suc y') refl with check x (thin x y') | half2 x (thin x y') y' refl -- -- ... | .(just y') | refl = refl -- -- half2 {zero} (suc ()) _ _ _ -- -- fact1 : ∀ {n} (x : Fin (suc n)) y r -- -- -> check x y ≡ r -- -- -> x ≡ y × r ≡ nothing ⊎ ∃ λ y' -> thin x y' ≡ y × r ≡ just y' -- -- fact1 x y .(check x y) refl with x ≡Fin y -- -- fact1 x .x ._ refl | yes refl = inj₁ (refl , half1 x) -- -- ... | no el with Thin.fact3 x y el -- -- ... | y' , thinxy'=y = inj₂ (y' , ( thinxy'=y , half2 x y y' thinxy'=y ))
{ "alphanum_fraction": 0.5011594203, "avg_line_length": 36.7021276596, "ext": "agda", "hexsha": "0e4f27a30cdc743123c9c17d65b0b68bcca11c72", "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-2/Oscar/Data/Fin.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-2/Oscar/Data/Fin.agda", "max_line_length": 117, "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-2/Oscar/Data/Fin.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1278, "size": 3450 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathGroupoid {- This file contains various basic definitions and lemmas about functions (non-dependent [Pi] types) that do not belong anywhere else. -} module lib.Function where {- Basic lemmas about pointed maps -} -- concatenation ⊙∘-pt : ∀ {i j} {A : Type i} {B : Type j} {a₁ a₂ : A} (f : A → B) {b : B} → a₁ == a₂ → f a₂ == b → f a₁ == b ⊙∘-pt f p q = ap f p ∙ q infixr 80 _⊙∘_ _⊙∘_ : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (g : Y ⊙→ Z) (f : X ⊙→ Y) → X ⊙→ Z (g , gpt) ⊙∘ (f , fpt) = (g ∘ f) , ⊙∘-pt g fpt gpt ⊙∘-unit-l : ∀ {i j} {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → ⊙idf Y ⊙∘ f == f ⊙∘-unit-l (f , idp) = idp ⊙∘-unit-r : ∀ {i j} {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → f ⊙∘ ⊙idf X == f ⊙∘-unit-r f = idp {- Homotopy fibers -} module _ {i j} {A : Type i} {B : Type j} (f : A → B) where hfiber : (y : B) → Type (lmax i j) hfiber y = Σ A (λ x → f x == y) {- Note that [is-inj] is not a mere proposition. -} is-inj : Type (lmax i j) is-inj = (a₁ a₂ : A) → f a₁ == f a₂ → a₁ == a₂ preserves-≠ : Type (lmax i j) preserves-≠ = {a₁ a₂ : A} → a₁ ≠ a₂ → f a₁ ≠ f a₂ module _ {i j} {A : Type i} {B : Type j} {f : A → B} where abstract inj-preserves-≠ : is-inj f → preserves-≠ f inj-preserves-≠ inj ¬p q = ¬p (inj _ _ q) module _ {i j k} {A : Type i} {B : Type j} {C : Type k} {f : A → B} {g : B → C} where ∘-is-inj : is-inj g → is-inj f → is-inj (g ∘ f) ∘-is-inj g-is-inj f-is-inj a₁ a₂ = f-is-inj a₁ a₂ ∘ g-is-inj (f a₁) (f a₂) {- Maps between two functions -} record CommSquare {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁} (f₀ : A₀ → B₀) (f₁ : A₁ → B₁) (hA : A₀ → A₁) (hB : B₀ → B₁) : Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where constructor comm-sqr field commutes : ∀ a₀ → (hB ∘ f₀) a₀ == (f₁ ∘ hA) a₀ open CommSquare public
{ "alphanum_fraction": 0.520167627, "avg_line_length": 27.2714285714, "ext": "agda", "hexsha": "ede23164208b5d3fda7007541d0fc614f1c89913", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "core/lib/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "core/lib/Function.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "core/lib/Function.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 906, "size": 1909 }
{-# OPTIONS --without-K --exact-split --rewriting #-} open import lib.Basics open import lib.types.Bool module Graphs.Definition where {- A graph consists of types of Edges and Vertices together with two endpoint maps. We often just talk about the types and the endpoint maps are clear from the context (i.e. derived by instance resolution). -} record Graph {i j : ULevel} (E : Type i) (V : Type j) : Type (lmax i j) where constructor graph field π₀ : E → V π₁ : E → V open Graph ⦃...⦄ public -- see agda documentation on instance arguments
{ "alphanum_fraction": 0.6998223801, "avg_line_length": 31.2777777778, "ext": "agda", "hexsha": "e4b24ceb72bd169f524568b97308a13ec0402b12", "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/Graphs/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/Graphs/Definition.agda", "max_line_length": 86, "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/Graphs/Definition.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 153, "size": 563 }
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Free.Semilattice.Relation.Unary.All.Def where open import Prelude hiding (⊥; ⊤) open import Algebra.Construct.Free.Semilattice.Eliminators open import Algebra.Construct.Free.Semilattice.Definition open import Cubical.Foundations.HLevels open import Data.Empty.UniversePolymorphic open import HITs.PropositionalTruncation.Sugar open import HITs.PropositionalTruncation.Properties open import HITs.PropositionalTruncation open import Data.Unit.UniversePolymorphic private variable p : Level dup-◻ : (P : A → Type p) → (x : A) (xs : Type p) → (∥ P x ∥ × ∥ P x ∥ × xs) ⇔ (∥ P x ∥ × xs) dup-◻ P _ _ .fun = snd dup-◻ P _ _ .inv (x , xs) = x , x , xs dup-◻ P _ _ .rightInv (x , xs) = refl dup-◻ P _ _ .leftInv (x₁ , x₂ , xs) i .fst = squash x₂ x₁ i dup-◻ P _ _ .leftInv (x₁ , x₂ , xs) i .snd = (x₂ , xs) com-◻ : (P : A → Type p) → (x y : A) (xs : Type p) → (∥ P x ∥ × ∥ P y ∥ × xs) ⇔ (∥ P y ∥ × ∥ P x ∥ × xs) com-◻ P _ _ _ .fun (x , y , xs) = y , x , xs com-◻ P _ _ _ .inv (y , x , xs) = x , y , xs com-◻ P _ _ _ .leftInv (x , y , xs) = refl com-◻ P _ _ _ .rightInv (x , y , xs) = refl ◻′ : (P : A → Type p) → A ↘ hProp p [ ◻′ P ]-set = isSetHProp ([ ◻′ P ] x ∷ (xs , hxs)) .fst = ∥ P x ∥ × xs ([ ◻′ P ] x ∷ (xs , hxs)) .snd y z = ΣProp≡ (λ _ → hxs) (squash (fst y) (fst z)) [ ◻′ P ][] = ⊤ , λ x y _ → x [ ◻′ P ]-dup x xs = ΣProp≡ (λ _ → isPropIsProp) (isoToPath (dup-◻ P x (xs .fst))) [ ◻′ P ]-com x y xs = ΣProp≡ (λ _ → isPropIsProp) (isoToPath (com-◻ P x y (xs .fst))) ◻ : (P : A → Type p) → 𝒦 A → Type p ◻ P xs = [ ◻′ P ]↓ xs .fst isProp-◻ : ∀ {P : A → Type p} {xs} → isProp (◻ P xs) isProp-◻ {P = P} {xs = xs} = [ ◻′ P ]↓ xs .snd
{ "alphanum_fraction": 0.5617647059, "avg_line_length": 38.6363636364, "ext": "agda", "hexsha": "f6934fe2b30971240355266172f5d9050538cc9b", "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": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Def.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 754, "size": 1700 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Duality {o ℓ e} (C : Category o ℓ e) where open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Categories.Category.Cartesian open import Categories.Category.Cocartesian open import Categories.Category.Complete open import Categories.Category.Complete.Finitely open import Categories.Category.Cocomplete open import Categories.Category.Cocomplete.Finitely open import Categories.Object.Duality open import Categories.Diagram.Duality open import Categories.Functor private module C = Category C open C coCartesian⇒Cocartesian : Cartesian C.op → Cocartesian C coCartesian⇒Cocartesian Car = record { initial = op⊤⇒⊥ C terminal ; coproducts = record { coproduct = coProduct⇒Coproduct C product } } where open Cartesian Car Cocartesian⇒coCartesian : Cocartesian C → Cartesian C.op Cocartesian⇒coCartesian Co = record { terminal = ⊥⇒op⊤ C initial ; products = record { product = Coproduct⇒coProduct C coproduct } } where open Cocartesian Co coComplete⇒Cocomplete : ∀ {o′ ℓ′ e′} → Complete o′ ℓ′ e′ C.op → Cocomplete o′ ℓ′ e′ C coComplete⇒Cocomplete Com F = coLimit⇒Colimit C (Com F.op) where module F = Functor F Cocomplete⇒coComplete : ∀ {o′ ℓ′ e′} → Cocomplete o′ ℓ′ e′ C → Complete o′ ℓ′ e′ C.op Cocomplete⇒coComplete Coc F = Colimit⇒coLimit C (Coc F.op) where module F = Functor F coFinitelyComplete⇒FinitelyCocomplete : FinitelyComplete C.op → FinitelyCocomplete C coFinitelyComplete⇒FinitelyCocomplete FC = record { cocartesian = coCartesian⇒Cocartesian cartesian ; coequalizer = λ f g → coEqualizer⇒Coequalizer C (equalizer f g) } where open FinitelyComplete FC FinitelyCocomplete⇒coFinitelyComplete : FinitelyCocomplete C → FinitelyComplete C.op FinitelyCocomplete⇒coFinitelyComplete FC = record { cartesian = Cocartesian⇒coCartesian cocartesian ; equalizer = λ f g → Coequalizer⇒coEqualizer C (coequalizer f g) } where open FinitelyCocomplete FC module DualityConversionProperties where private op-involutive : Category.op C.op ≡ C op-involutive = refl coCartesian⇔Cocartesian : ∀(coCartesian : Cartesian C.op) → Cocartesian⇒coCartesian (coCartesian⇒Cocartesian coCartesian) ≡ coCartesian coCartesian⇔Cocartesian _ = refl coFinitelyComplete⇔FinitelyCocomplete : ∀(coFinComplete : FinitelyComplete C.op) → FinitelyCocomplete⇒coFinitelyComplete (coFinitelyComplete⇒FinitelyCocomplete coFinComplete) ≡ coFinComplete coFinitelyComplete⇔FinitelyCocomplete _ = refl
{ "alphanum_fraction": 0.7450244086, "avg_line_length": 32.8765432099, "ext": "agda", "hexsha": "2134f5bed58b293df9bb00ed5683bca7b6137381", "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/Category/Duality.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/Category/Duality.agda", "max_line_length": 91, "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/Category/Duality.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": 820, "size": 2663 }
{-# OPTIONS --cubical --allow-unsolved-metas #-} open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Nat pred : Nat → Nat pred (suc n) = n pred zero = zero data [0-1] : Set where 𝟎 𝟏 : [0-1] int : 𝟎 ≡ 𝟏 -- The following holes can be filled, so they should not cause a -- typechecking failure. 0=x : ∀ i → 𝟎 ≡ int i 0=x i = \ j → int {!!} si : {n m : Nat} → suc n ≡ suc m → n ≡ m si p i = pred (p {!!})
{ "alphanum_fraction": 0.5933806147, "avg_line_length": 19.2272727273, "ext": "agda", "hexsha": "7a5e6e020b32194156c1c90cc3c48fce3667b104", "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/Issue3511.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/Issue3511.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3511.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": 168, "size": 423 }
-- This test case seems to be due to Andreas Abel, Andrea Vezzosi and -- NAD. The code below should be rejected. open import Agda.Builtin.Size data SizeLt (i : Size) : Set where size : (j : Size< i) → SizeLt i -- Legal again in 2.5.1 getSize : ∀{i} → SizeLt i → Size getSize (size j) = j -- Structurally inductive (c), coinductive via sizes. data U (i : Size) : Set where c : ((s : SizeLt i) → U (getSize s)) → U i data ⊥ : Set where empty : U ∞ → ⊥ empty (c f) = empty (f (size ∞)) -- f x <= f < c f -- If U is a data type this should not be possible: inh : ∀ i → U i inh i = c λ{ (size j) → inh j } absurd : ⊥ absurd = empty (inh ∞)
{ "alphanum_fraction": 0.6064814815, "avg_line_length": 23.1428571429, "ext": "agda", "hexsha": "a9a5a214bbf22c22e371a90066fa63ab0d74ca17", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.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/Issue1946-1.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1946-1.agda", "max_line_length": 69, "max_stars_count": 2, "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/Issue1946-1.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 232, "size": 648 }
module hello-world where open import Agda.Builtin.IO using (IO) open import Agda.Builtin.Unit using (⊤) open import Agda.Builtin.String using (String) postulate putStrLn : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text as T #-} {-# COMPILE GHC putStrLn = putStrLn . T.unpack #-} main : IO ⊤ main = putStrLn "Hello world!"
{ "alphanum_fraction": 0.7194029851, "avg_line_length": 25.7692307692, "ext": "agda", "hexsha": "e8a017db376688316738937688e01b3c5a121b42", "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": "5b3afde25381d7aff75a6a231b90cf60dca5b826", "max_forks_repo_licenses": [ "CC-BY-3.0" ], "max_forks_repo_name": "tlringer/tlringer.github.io", "max_forks_repo_path": "classes/artifacts/1/hello-world.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5b3afde25381d7aff75a6a231b90cf60dca5b826", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-3.0" ], "max_issues_repo_name": "tlringer/tlringer.github.io", "max_issues_repo_path": "classes/artifacts/1/hello-world.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "5b3afde25381d7aff75a6a231b90cf60dca5b826", "max_stars_repo_licenses": [ "CC-BY-3.0" ], "max_stars_repo_name": "tlringer/tlringer.github.io", "max_stars_repo_path": "classes/artifacts/1/hello-world.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 84, "size": 335 }
module Bush where data Nat : Set where zero : Nat suc : Nat -> Nat {-# BUILTIN NATURAL Nat #-} _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) _^_ : (Set -> Set) -> Nat -> Set -> Set (F ^ zero) A = A (F ^ suc n) A = F ((F ^ n) A) data Bush (A : Set) : Set where leaf : Bush A node : A -> (Bush ^ 3) A -> Bush A elim : (P : (A : Set) -> Bush A -> Set) -> ((A : Set) -> P A leaf) -> ((A : Set)(x : A)(b : (Bush ^ 3) A) -> P ((Bush ^ 2) A) b -> P A (node x b)) -> (A : Set)(b : Bush A) -> P A b elim P l n A leaf = l A elim P l n A (node x b) = n A x b (elim P l n ((Bush ^ 2) A) b) iter : (P : (A : Set) -> Set) -> ((A : Set) -> P A) -> ((A : Set) -> A -> P ((Bush ^ 2) A) -> P A) -> (A : Set) -> Bush A -> P A iter P l n A leaf = l A iter P l n A (node x b) = n A x (iter P l n ((Bush ^ 2) A) b) data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A _++_ : {A : Set} -> List A -> List A -> List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) flatten : {A : Set}(n : Nat) -> (Bush ^ n) A -> List A flatten zero x = x :: [] flatten (suc n) leaf = [] flatten (suc n) (node x b) = flatten n x ++ flatten (3 + n) b -- Andreas, 2017-01-01, issue #1899. -- Normalize field types for positivity checking. record B (A : Set) : Set where coinductive field f : (B ^ 3) A
{ "alphanum_fraction": 0.4633260712, "avg_line_length": 24.1578947368, "ext": "agda", "hexsha": "9780991d64f40e9c81a81d7f561b05d3006d095d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Bush.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Bush.agda", "max_line_length": 63, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Bush.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": 547, "size": 1377 }
module nodcap.NF.Contract where open import Function using (_$_) open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Pos as ℕ⁺ open import Data.List as L using (List; []; _∷_; _++_) open import Data.Environment open import nodcap.Base open import nodcap.NF.Typing -- Lemma: -- We can contract n repetitions of A to an instance of ?[ n ] A, -- by induction on n. contract : {Γ : Environment} {A : Type} {n : ℕ⁺} → ⊢ⁿᶠ replicate⁺ n A ++ Γ → ---------------------- ⊢ⁿᶠ ?[ n ] A ∷ Γ contract {n = suc zero} x = mk?₁ x contract {n = suc (suc n)} x = cont {m = suc zero} $ exch (fwd [] (_ ∷ [])) $ contract $ exch (bwd [] (replicate⁺ (suc n) _)) $ mk?₁ x
{ "alphanum_fraction": 0.5904486252, "avg_line_length": 23.8275862069, "ext": "agda", "hexsha": "938f33b45d1a0674863822f64d43141bdb1caab2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/nodcap/NF/Contract.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "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": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/nodcap/NF/Contract.agda", "max_line_length": 67, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/nodcap/NF/Contract.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 248, "size": 691 }
module SizedIO.Base where open import Data.Maybe.Base open import Data.Sum renaming (inj₁ to left; inj₂ to right; [_,_]′ to either) open import Function --open import Level using (_⊔_) renaming (suc to lsuc) open import Size open import Data.List open import SizedIO.Object open import NativeIO open import Data.Product record IOInterface : Set₁ where field Command : Set Response : (m : Command) → Set open IOInterface public module _ (I : IOInterface ) (let C = Command I) (let R = Response I) where mutual record IO (i : Size) (A : Set) : Set where coinductive constructor delay field force : {j : Size< i} → IO' j A data IO' (i : Size) (A : Set) : Set where do' : (c : C) (f : R c → IO i A) → IO' i A return' : (a : A) → IO' i A data IO+ (i : Size) (A : Set) : Set where do' : (c : C) (f : R c → IO i A) → IO+ i A open IO public objectInterfToIOInterf : Interface → IOInterface objectInterfToIOInterf I .Command = I .Method objectInterfToIOInterf I .Response = I .Result ioInterfToObjectInterf : IOInterface → Interface ioInterfToObjectInterf I .Method = I .Command ioInterfToObjectInterf I .Result = I .Response module _ {I : IOInterface } (let C = Command I) (let R = Response I) where return : ∀{i}{A : Set} (a : A) → IO I i A return a .force = return' a do : ∀{i}{A : Set} (c : C) (f : R c → IO I i A) → IO I i A do c f .force = do' c f do1 : ∀{i} (c : C) → IO I i (R c) do1 c = do c return infixl 2 _>>=_ _>>='_ _>>_ mutual _>>='_ : ∀{i}{A B : Set}(m : IO' I i A) (k : A → IO I (↑ i) B) → IO' I i B do' c f >>=' k = do' c λ x → f x >>= k return' a >>=' k = (k a) .force _>>=_ : ∀{i}{A B : Set}(m : IO I i A) (k : A → IO I i B) → IO I i B (m >>= k) .force = m .force >>=' k _>>_ : ∀{i}{B : Set} (m : IO I i Unit) (k : IO I i B) → IO I i B m >> k = m >>= λ _ → k {-# NON_TERMINATING #-} translateIO : ∀{A : Set} → (translateLocal : (c : C) → NativeIO (R c)) → IO I ∞ A → NativeIO A translateIO translateLocal m = case (m .force {_}) of λ{ (do' c f) → (translateLocal c) native>>= λ r → translateIO translateLocal (f r) ; (return' a) → nativeReturn a } -- Recursion -- trampoline provides a generic form of loop (generalizing while/repeat). -- Starting at state s : S, step function f is iterated until it returns -- a result in A. fromIO+' : ∀{i}{A : Set} → IO+ I i A → IO' I i A fromIO+' (do' c f) = do' c f fromIO+ : ∀{i}{A : Set} → IO+ I i A → IO I i A fromIO+ (do' c f) .force = do' c f _>>=+'_ : ∀{i}{A B : Set}(m : IO+ I i A) (k : A → IO I i B) → IO' I i B do' c f >>=+' k = do' c λ x → f x >>= k _>>=+_ : ∀{i}{A B : Set}(m : IO+ I i A) (k : A → IO I i B) → IO I i B (m >>=+ k) .force = m >>=+' k mutual _>>+_ : ∀{i}{A B : Set}(m : IO I i (A ⊎ B)) (k : A → IO I i B) → IO I i B (m >>+ k) .force = m .force >>+' k _>>+'_ : ∀{j}{A B : Set} (m : IO' I j (A ⊎ B)) (k : A → IO I (↑ j) B) → IO' I j B do' c f >>+' k = do' c λ x → f x >>+ k return' (left a) >>+' k = k a .force return' (right b) >>+' k = return' b -- loop trampoline : ∀{i}{A S : Set} (f : S → IO+ I i (S ⊎ A)) (s : S) → IO I i A trampoline f s .force = case (f s) of \{ (do' c k) → do' c λ r → k r >>+ trampoline f } -- simple infinite loop forever : ∀{i}{A B : Set} → IO+ I i A → IO I i B forever (do' c f) .force = do' c λ r → f r >>= λ _ → forever (do' c f) whenJust : ∀{i}{A : Set} → Maybe A → (A → IO I i (Unit )) → IO I i Unit whenJust nothing k = return _ whenJust (just a) k = k a mutual mapIO : ∀ {i} → {I : IOInterface} → {A B : Set} → (A → B) → IO I i A → IO I i B mapIO f p .force = mapIO' f (p .force) mapIO' : ∀ {i} → {I : IOInterface} → {A B : Set} → (A → B) → IO' I i A → IO' I i B mapIO' f (do' c g) = do' c (λ r → mapIO f (g r)) mapIO' f (return' a) = return' (f a) sequenceIO : {i : IOInterface} → List (IO i ∞ Unit) → IO i ∞ Unit sequenceIO [] .force = return' unit sequenceIO (p ∷ l) = p >>= (λ _ → sequenceIO l) Return : {i : Size} → {int : IOInterface} → {A : Set} → A → IO int i A Return a .force = return' a Do : {i : Size} → {int : IOInterface} → (c : int .Command) → IO int i (int .Response c) Do c .force = do' c Return module _ {I : IOInterface } (let C = Command I) (let R = Response I) where mutual fmap : (i : Size) → {A B : Set} → (f : A → B) → IO I i A → IO I i B fmap i {A} {B} f p .force {j} = fmap' j {A} {B} f (p .force {j}) fmap' : (i : Size) → {A B : Set} → (f : A → B ) → IO' I i A → IO' I i B fmap' i {A} {B} f (do' c f₁) = do' c (λ r → fmap i {A} {B} f (f₁ r)) fmap' i {A} {B} f (return' a) = return' (f a) module _ (I : IOInterface ) (let C = I .Command) (let R = I .Response) where data IOind (A : Set) : Set where do'' : (c : C) (f : (r : R c) → IOind A) → IOind A return'' : (a : A) → IOind A _>>''_ : {I : IOInterface}(let C = I .Command)(let R = I .Response) {A B : Set} (p : IOind I A) (q : A → IOind I B) → IOind I B do'' c f >>'' q = do'' c (λ r → f r >>'' q) return'' a >>'' q = q a module _ {I : Interface } (let M = I .Method) (let R = I .Result) where translate : ∀{A : Set} → Object I → IOind (objectInterfToIOInterf I) A → A × Object I translate {A} obj (do'' c p) = obj .objectMethod c ▹ λ {(x , o') → translate {A} o' (p x) } translate {A} obj (return'' a) = a , obj
{ "alphanum_fraction": 0.4936289056, "avg_line_length": 28.9343434343, "ext": "agda", "hexsha": "1578a3592d9abbe56747d8fa0329a8a43d23f135", "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": "src/SizedIO/Base.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": "src/SizedIO/Base.agda", "max_line_length": 86, "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": "src/SizedIO/Base.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": 2214, "size": 5729 }
------------------------------------------------------------------------ -- Results relating different instances of certain axioms related to -- equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Equality.Instances-related where import Bijection open import Equality import Equivalence import Function-universe import H-level import H-level.Closure open import Logical-equivalence using (_⇔_) open import Prelude import Surjection private module E (e⁺ : ∀ e → Equivalence-relation⁺ e) where open Reflexive-relation′ (λ e → Equivalence-relation⁺.reflexive-relation (e⁺ e)) public -- All families of equality types that satisfy certain axioms are -- pointwise isomorphic. One of the families are used to define what -- "isomorphic" means. -- -- The isomorphisms map reflexivity to reflexivity in both directions. -- -- Hofmann and Streicher prove something similar in "The groupoid -- interpretation of type theory". all-equality-types-isomorphic : ∀ {e₁ e₂} (eq₁ : ∀ {a p} → Equality-with-J a p e₁) (eq₂ : ∀ {a p} → Equality-with-J a p e₂) → let open Bijection eq₁ in ∀ {a} {A : Type a} → ∃ λ (iso : {x y : A} → E._≡_ e₁ x y ↔ E._≡_ e₂ x y) → (∀ {x} → E._≡_ e₂ (_↔_.to iso (E.refl e₁ x)) (E.refl e₂ x)) × (∀ {x} → E._≡_ e₁ (_↔_.from iso (E.refl e₂ x)) (E.refl e₁ x)) all-equality-types-isomorphic {c₁} {c₂} eq₁ eq₂ = record { surjection = record { logical-equivalence = record { to = to c₂ eq₁ ; from = to c₁ eq₂ } ; right-inverse-of = to c₁ eq₂ ∘ to∘to _ _ eq₂ eq₁ } ; left-inverse-of = to∘to _ _ eq₁ eq₂ } , to-refl c₂ eq₁ , to-refl c₁ eq₂ where open E open module Eq {c} (eq : ∀ {a p} → Equality-with-J a p c) = Equality-with-J′ eq hiding (_≡_; refl) to : ∀ {c₁} c₂ (eq₁ : ∀ {a p} → Equality-with-J a p c₁) {a} {A : Type a} {x y : A} → _≡_ c₁ x y → _≡_ c₂ x y to c₂ eq₁ {x = x} x≡y = subst eq₁ (_≡_ c₂ x) x≡y (refl c₂ x) to-refl : ∀ {c₁} c₂ (eq₁ : ∀ {a p} → Equality-with-J a p c₁) {a} {A : Type a} {x : A} → _≡_ c₂ (to c₂ eq₁ (refl c₁ x)) (refl c₂ x) to-refl c₂ eq₁ = to c₂ eq₁ $ subst-refl eq₁ (_≡_ c₂ _) _ to∘to : ∀ c₁ c₂ (eq₁ : ∀ {a p} → Equality-with-J a p c₁) (eq₂ : ∀ {a p} → Equality-with-J a p c₂) → ∀ {a} {A : Type a} {x y : A} (x≡y : _≡_ c₁ x y) → _≡_ c₁ (to c₁ eq₂ (to c₂ eq₁ x≡y)) x≡y to∘to c₁ c₂ eq₁ eq₂ = elim eq₁ (λ {x y} x≡y → _≡_ c₁ (to c₁ eq₂ (to c₂ eq₁ x≡y)) x≡y) (λ x → to c₁ eq₂ (to c₂ eq₁ (refl c₁ x)) ≡⟨ cong eq₁ (to c₁ eq₂) (subst-refl eq₁ (_≡_ c₂ x) (refl c₂ x)) ⟩ to c₁ eq₂ (refl c₂ x) ≡⟨ to c₁ eq₂ $ subst-refl eq₂ (_≡_ c₁ x) (refl c₁ x) ⟩∎ refl c₁ x ∎) where open Derived-definitions-and-properties eq₁ using (step-≡; finally) module _ {congruence⁺} (eq : ∀ {a p} → Equality-with-J a p congruence⁺) where open Derived-definitions-and-properties eq open Function-universe eq hiding (_∘_) renaming (id to ⟨id⟩) open H-level.Closure eq open Surjection eq using (_↠_) private open module Eq = Equivalence eq using (_≃_) abstract -- The type Equality-with-J₀ a p reflexive-relation is -- contractible (given the assumptions in the telescope above, and -- assuming extensionality). A slight variant of this observation -- came up in a discussion between Thierry Coquand, Simon Huber -- and Nicolai Kraus. The proof is based on one due to Nicolai -- Kraus. Equality-with-J-contractible : ∀ {a p} → Extensionality (lsuc (a ⊔ p)) (a ⊔ lsuc p) → Contractible (Equality-with-J₀ a p (λ _ → reflexive-relation)) Equality-with-J-contractible {a} {p} ext = $⟨ contr ⟩ Contractible ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → Singleton d) ↝⟨ H-level.respects-surjection eq surj 0 ⟩ Contractible (Equality-with-J₀ a p (λ _ → reflexive-relation)) □ where I : Type a → Type a I A = ∃ λ (x : A) → ∃ λ (y : A) → x ≡ y to : ∀ {A} → A → I A to x = x , x , refl x ≃I : ∀ {A} → A ≃ I A ≃I = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = to ; from = proj₁ } ; right-inverse-of = λ q → let x , y , x≡y = q in cong (x ,_) $ Σ-≡,≡→≡ x≡y (subst (x ≡_) x≡y (refl x) ≡⟨ sym trans-subst ⟩ trans (refl x) x≡y ≡⟨ trans-reflˡ x≡y ⟩∎ x≡y ∎) } ; left-inverse-of = refl }) contr : Contractible ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → Singleton d) contr = Π-closure (lower-extensionality (lsuc p) lzero ext) 0 λ _ → Π-closure (lower-extensionality (lsuc a) (lsuc p) ext) 0 λ _ → Π-closure (lower-extensionality _ (lsuc p) ext) 0 λ _ → singleton-contractible _ surj : ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → Singleton d) ↠ Equality-with-J₀ a p (λ _ → reflexive-relation) surj = ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → Singleton d) ↔⟨⟩ ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → ∃ λ (j : (x : A) → P (to x)) → j ≡ d) ↔⟨ (∀-cong (lower-extensionality (lsuc p) lzero ext) λ _ → ∀-cong (lower-extensionality (lsuc a) (lsuc p) ext) λ _ → ∀-cong (lower-extensionality _ (lsuc p) ext) λ _ → ∃-cong λ _ → inverse $ Eq.extensionality-isomorphism (lower-extensionality _ _ ext)) ⟩ ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → ∃ λ (j : (x : A) → P (to x)) → (x : A) → j x ≡ d x) ↔⟨ (∀-cong (lower-extensionality (lsuc p) lzero ext) λ _ → ∀-cong (lower-extensionality (lsuc a) (lsuc p) ext) λ _ → ∀-cong (lower-extensionality _ (lsuc p) ext) λ _ → inverse $ Σ-cong (inverse $ Π-cong (lower-extensionality _ _ ext) ≃I λ _ → ⟨id⟩ {k = equivalence}) λ _ → ⟨id⟩ {k = equivalence}) ⟩ ((A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → ∃ λ (j : (q : I A) → P q) → (x : A) → j (to x) ≡ d x) ↔⟨ (∀-cong (lower-extensionality (lsuc p) lzero ext) λ _ → ∀-cong (lower-extensionality (lsuc a) (lsuc p) ext) λ _ → ΠΣ-comm) ⟩ ((A : Type a) (P : I A → Type p) → ∃ λ (j : (d : ∀ x → P (to x)) → (q : I A) → P q) → (d : ∀ x → P (to x)) (x : A) → j d (to x) ≡ d x) ↔⟨ (∀-cong (lower-extensionality (lsuc p) lzero ext) λ _ → ΠΣ-comm) ⟩ ((A : Type a) → ∃ λ (j : (P : I A → Type p) (d : ∀ x → P (to x)) → (q : I A) → P q) → (P : I A → Type p) (d : ∀ x → P (to x)) (x : A) → j P d (to x) ≡ d x) ↔⟨ ΠΣ-comm ⟩ (∃ λ (J : (A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) → (q : I A) → P q) → (A : Type a) (P : I A → Type p) (d : ∀ x → P (to x)) (x : A) → J A P d (to x) ≡ d x) ↝⟨ record { logical-equivalence = record { to = uncurry λ J Jβ → record { elim = λ P r x≡y → J _ (P ∘ proj₂ ∘ proj₂) r (_ , _ , x≡y) ; elim-refl = λ P r → Jβ _ (P ∘ proj₂ ∘ proj₂) r _ } ; from = λ eq → (λ A P d q → Equality-with-J₀.elim eq (λ x≡y → P (_ , _ , x≡y)) d (proj₂ (proj₂ q))) , (λ A P d x → Equality-with-J₀.elim-refl eq (λ x≡y → P (_ , _ , x≡y)) d) } ; right-inverse-of = refl } ⟩□ Equality-with-J₀ a p (λ _ → reflexive-relation) □ private -- A related example. It had been suggested that the two proofs -- proof₁ and proof₂ below might not be provably equal, but Simon -- Huber managed to prove that they are (using a slightly -- different type for elim-refl). module _ {a p} {A : Type a} (P : A → Type p) {x : A} (y : P x) where subst′ : {x y : A} (P : A → Type p) → x ≡ y → P x → P y subst′ P = elim (λ {u v} _ → P u → P v) (λ _ p → p) subst′-refl≡id : {x : A} (P : A → Type p) → subst′ P (refl x) ≡ id subst′-refl≡id P = elim-refl (λ {u v} _ → P u → P v) (λ _ p → p) proof₁ proof₂ : subst′ P (refl x) (subst′ P (refl x) y) ≡ subst′ P (refl x) y proof₁ = cong (_$ subst′ P (refl x) y) (subst′-refl≡id P) proof₂ = cong (subst′ P (refl x)) (cong (_$ y) (subst′-refl≡id P)) proof₁≡proof₂ : proof₁ ≡ proof₂ proof₁≡proof₂ = subst (λ (s : Singleton id) → ∀ y → cong (_$ proj₁ s y) (proj₂ s) ≡ cong (proj₁ s) (cong (_$ y) (proj₂ s))) (id , refl id ≡⟨ proj₂ (singleton-contractible _) _ ⟩∎ subst′ P (refl x) , subst′-refl≡id P ∎) (λ y → cong (_$ y) (refl id) ≡⟨ cong-id _ ⟩∎ cong id (cong (_$ y) (refl id)) ∎) y
{ "alphanum_fraction": 0.3928382431, "avg_line_length": 45.171314741, "ext": "agda", "hexsha": "845f96a1611678096fb92f33dd74f2badee5abe8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equality/Instances-related.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equality/Instances-related.agda", "max_line_length": 141, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equality/Instances-related.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": 3418, "size": 11338 }
module index where -- natural numbers --- additions import Nats.Add.Assoc using (nat-add-assoc) -- associative law import Nats.Add.Comm using (nat-add-comm) -- commutative law import Nats.Add.Invert using (nat-add-invert) -- a + a == b + b implies a == b using (nat-add-invert-1) -- a + 1 == b + 1 implies a == b --- multiplications import Nats.Multiply.Comm using (nat-multiply-comm) -- commutative law import Nats.Multiply.Distrib using (nat-multiply-distrib) -- distributive law import Nats.Multiply.Assoc using (nat-multiply-assoc) -- associative law -- integers --- some properties import Ints.Properties using (eq-int-to-nat) -- for natrual number a, + a == + a implis a == a using (eq-neg-int-to-nat) -- for natrual number a, - a == - a implis a == a using (eq-nat-to-int) -- for natrual number a, a == a implis + a == + a using (eq-neg-nat-to-int) -- for natrual number a, a == a implis - a == - a --- additions import Ints.Add.Comm using (int-add-comm) -- commutative law import Ints.Add.Assoc using (int-add-assoc) -- associative law import Ints.Add.Invert using (int-add-invert) -- a + a == b + b implis a == b -- non-negative rationals --- some properties import Rationals.Properties -- if b is not zero, n times b div b is the original number using (times-div-id) -- additions import Rationals.Add.Comm using (rational-add-comm) -- commutative law import Rationals.Add.Assoc using (rational-add-assoc) -- associative law -- multiplications import Rationals.Multiply.Comm using (rational-multiply-comm) -- commutative law -- logics --- the "and" relations import Logics.And using (and-comm) -- commutative law using (and-assoc) -- associative law --- the "or" relations import Logics.Or using (or-comm) -- commutative law using (or-assoc) -- associative law using (or-elim) -- elimination rule --- negations import Logics.Not -- law that negative twice will make a positive using (not-not) using (contrapositive) -- contrapositive -- vectors --- reverse twice gives the original vector import Vecs.Reverse using (vec-rev-rev-id) -- lists --- reverse twice gives the original vector import Lists.Reverse using (list-rev-rev-id) -- isomorphisms --- natrual numbers and others import Isos.NatLike using (iso-nat-vec) -- with vector using (iso-nat-list) -- with list --- trees import Isos.TreeLike using (iso-seven-tree-in-one) -- seven trees in one -- groups --- s3 group, xxx=e, yy=e, yx=xxy import Groups.Symm.S3 using (s3-property-1) -- given s3, prove xyx≡y
{ "alphanum_fraction": 0.6947492163, "avg_line_length": 26.8631578947, "ext": "agda", "hexsha": "2060ef76fba93a2703a258e394967a8f4db09f6d", "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/index.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/index.agda", "max_line_length": 77, "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/index.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": 772, "size": 2552 }
module sk where open import nat data comb : Set where S : comb K : comb app : comb → comb → comb data _↝_ : comb → comb → Set where ↝K : (a b : comb) → (app (app K a) b) ↝ a ↝S : (a b c : comb) → (app (app (app S a) b) c) ↝ (app (app a c) (app b c)) ↝Cong1 : {a a' : comb} (b : comb) → a ↝ a' → (app a b) ↝ (app a' b) ↝Cong2 : (a : comb) {b b' : comb} → b ↝ b' → (app a b) ↝ (app a b') size : comb → ℕ size S = 1 size K = 1 size (app a b) = suc (size a + size b)
{ "alphanum_fraction": 0.4968814969, "avg_line_length": 24.05, "ext": "agda", "hexsha": "28693917dd216a4b5f09fb2eb004ea486b20f309", "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": "sk.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": "sk.agda", "max_line_length": 77, "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": "sk.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 219, "size": 481 }
{-# OPTIONS --exact-split #-} module ExactSplitBerry where data Bool : Set where true false : Bool maj : Bool → Bool → Bool → Bool maj true true true = true maj x true false = x maj false y true = y maj true false z = z maj false false false = false
{ "alphanum_fraction": 0.6433823529, "avg_line_length": 20.9230769231, "ext": "agda", "hexsha": "90365403132d02fc0b4b8972e44caeee343a622e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/ExactSplitBerry.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/ExactSplitBerry.agda", "max_line_length": 31, "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/ExactSplitBerry.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": 78, "size": 272 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Product open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℚ using (ℚ) open import Data.Fin as Fin using (Fin; #_) open import Data.List module andGate-temp-output where postulate andGate : Tensor ℚ (2 ∷ []) → Tensor ℚ (1 ∷ []) Truthy : ℚ → Set Truthy x = x ℚ.≥ ℤ.+ 1 ℚ./ 2 Falsey : ℚ → Set Falsey x = x ℚ.≤ ℤ.+ 1 ℚ./ 2 ValidInput : ℚ → Set ValidInput x = ℤ.+ 0 ℚ./ 1 ℚ.≤ x × x ℚ.≤ ℤ.+ 1 ℚ./ 1 CorrectOutput : ℚ → (ℚ → Set) CorrectOutput x1 x2 = let y = andGate (x1 ∷ (x2 ∷ [])) (# 0) in (Truthy x1 × Truthy x2 → Truthy y) × ((Truthy x1 × Falsey x2 → Falsey y) × ((Falsey x1 × Truthy x2 → Falsey y) × (Falsey x1 × Falsey x2 → Falsey y))) abstract andGateCorrect : ∀ (x1 : ℚ) → ∀ (x2 : ℚ) → ValidInput x1 × ValidInput x2 → CorrectOutput x1 x2 andGateCorrect = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
{ "alphanum_fraction": 0.647257384, "avg_line_length": 31.1842105263, "ext": "agda", "hexsha": "a8732e4dc2e06ef99949855ccf181108bf1b5e95", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "test/Test/Compile/Golden/andGate/andGate-output.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "test/Test/Compile/Golden/andGate/andGate-output.agda", "max_line_length": 213, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "test/Test/Compile/Golden/andGate/andGate-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 435, "size": 1185 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to propositional list membership ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Membership.Propositional.Properties where open import Algebra.FunctionProperties using (Op₂; Selective) open import Category.Monad using (RawMonad) open import Data.Bool.Base using (Bool; false; true; T) open import Data.Fin using (Fin) open import Data.List as List open import Data.List.Relation.Unary.Any as Any using (Any; here; there) open import Data.List.Relation.Unary.Any.Properties open import Data.List.Membership.Propositional import Data.List.Membership.Setoid.Properties as Membershipₛ open import Data.List.Relation.Binary.Equality.Propositional using (_≋_; ≡⇒≋; ≋⇒≡) open import Data.List.Categorical using (monad) open import Data.Nat using (ℕ; zero; suc; pred; s≤s; _≤_; _<_; _≤?_) open import Data.Nat.Properties open import Data.Product hiding (map) open import Data.Product.Function.NonDependent.Propositional using (_×-cong_) import Data.Product.Function.Dependent.Propositional as Σ open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (module Equivalence) open import Function.Injection using (Injection; Injective; _↣_) open import Function.Inverse as Inv using (_↔_; module Inverse) import Function.Related as Related open import Function.Related.TypeIsomorphisms open import Relation.Binary hiding (Decidable) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; refl; sym; trans; cong; subst; →-to-⟶; _≗_) import Relation.Binary.Properties.DecTotalOrder as DTOProperties open import Relation.Unary using (_⟨×⟩_; Decidable) open import Relation.Nullary using (¬_; Dec; yes; no) open import Relation.Nullary.Negation private open module ListMonad {ℓ} = RawMonad (monad {ℓ = ℓ}) ------------------------------------------------------------------------ -- Publicly re-export properties from Core open import Data.List.Membership.Propositional.Properties.Core public ------------------------------------------------------------------------ -- Equality module _ {a} {A : Set a} where ∈-resp-≋ : ∀ {x} → (x ∈_) Respects _≋_ ∈-resp-≋ = Membershipₛ.∈-resp-≋ (P.setoid A) ∉-resp-≋ : ∀ {x} → (x ∉_) Respects _≋_ ∉-resp-≋ = Membershipₛ.∉-resp-≋ (P.setoid A) ------------------------------------------------------------------------ -- mapWith∈ module _ {a b} {A : Set a} {B : Set b} where mapWith∈-cong : ∀ (xs : List A) → (f g : ∀ {x} → x ∈ xs → B) → (∀ {x} → (x∈xs : x ∈ xs) → f x∈xs ≡ g x∈xs) → mapWith∈ xs f ≡ mapWith∈ xs g mapWith∈-cong [] f g cong = refl mapWith∈-cong (x ∷ xs) f g cong = P.cong₂ _∷_ (cong (here refl)) (mapWith∈-cong xs (f ∘ there) (g ∘ there) (cong ∘ there)) mapWith∈≗map : ∀ f xs → mapWith∈ xs (λ {x} _ → f x) ≡ map f xs mapWith∈≗map f xs = ≋⇒≡ (Membershipₛ.mapWith∈≗map (P.setoid A) (P.setoid B) f xs) ------------------------------------------------------------------------ -- map module _ {a b} {A : Set a} {B : Set b} (f : A → B) where ∈-map⁺ : ∀ {x xs} → x ∈ xs → f x ∈ map f xs ∈-map⁺ = Membershipₛ.∈-map⁺ (P.setoid A) (P.setoid B) (P.cong f) ∈-map⁻ : ∀ {y xs} → y ∈ map f xs → ∃ λ x → x ∈ xs × y ≡ f x ∈-map⁻ = Membershipₛ.∈-map⁻ (P.setoid A) (P.setoid B) map-∈↔ : ∀ {y xs} → (∃ λ x → x ∈ xs × y ≡ f x) ↔ y ∈ map f xs map-∈↔ {y} {xs} = (∃ λ x → x ∈ xs × y ≡ f x) ↔⟨ Any↔ ⟩ Any (λ x → y ≡ f x) xs ↔⟨ map↔ ⟩ y ∈ List.map f xs ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _++_ module _ {a} {A : Set a} {v : A} where ∈-++⁺ˡ : ∀ {xs ys} → v ∈ xs → v ∈ xs ++ ys ∈-++⁺ˡ = Membershipₛ.∈-++⁺ˡ (P.setoid A) ∈-++⁺ʳ : ∀ xs {ys} → v ∈ ys → v ∈ xs ++ ys ∈-++⁺ʳ = Membershipₛ.∈-++⁺ʳ (P.setoid A) ∈-++⁻ : ∀ xs {ys} → v ∈ xs ++ ys → (v ∈ xs) ⊎ (v ∈ ys) ∈-++⁻ = Membershipₛ.∈-++⁻ (P.setoid A) ∈-insert : ∀ xs {ys} → v ∈ xs ++ [ v ] ++ ys ∈-insert xs = Membershipₛ.∈-insert (P.setoid A) xs refl ∈-∃++ : ∀ {xs} → v ∈ xs → ∃₂ λ ys zs → xs ≡ ys ++ [ v ] ++ zs ∈-∃++ v∈xs with Membershipₛ.∈-∃++ (P.setoid A) v∈xs ... | ys , zs , _ , refl , eq = ys , zs , ≋⇒≡ eq ------------------------------------------------------------------------ -- concat module _ {a} {A : Set a} {v : A} where ∈-concat⁺ : ∀ {xss} → Any (v ∈_) xss → v ∈ concat xss ∈-concat⁺ = Membershipₛ.∈-concat⁺ (P.setoid A) ∈-concat⁻ : ∀ xss → v ∈ concat xss → Any (v ∈_) xss ∈-concat⁻ = Membershipₛ.∈-concat⁻ (P.setoid A) ∈-concat⁺′ : ∀ {vs xss} → v ∈ vs → vs ∈ xss → v ∈ concat xss ∈-concat⁺′ v∈vs vs∈xss = Membershipₛ.∈-concat⁺′ (P.setoid A) v∈vs (Any.map ≡⇒≋ vs∈xss) ∈-concat⁻′ : ∀ xss → v ∈ concat xss → ∃ λ xs → v ∈ xs × xs ∈ xss ∈-concat⁻′ xss v∈c with Membershipₛ.∈-concat⁻′ (P.setoid A) xss v∈c ... | xs , v∈xs , xs∈xss = xs , v∈xs , Any.map ≋⇒≡ xs∈xss concat-∈↔ : ∀ {xss : List (List A)} → (∃ λ xs → v ∈ xs × xs ∈ xss) ↔ v ∈ concat xss concat-∈↔ {xss} = (∃ λ xs → v ∈ xs × xs ∈ xss) ↔⟨ Σ.cong Inv.id $ ×-comm _ _ ⟩ (∃ λ xs → xs ∈ xss × v ∈ xs) ↔⟨ Any↔ ⟩ Any (Any (v ≡_)) xss ↔⟨ concat↔ ⟩ v ∈ concat xss ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- applyUpTo module _ {a} {A : Set a} where ∈-applyUpTo⁺ : ∀ (f : ℕ → A) {i n} → i < n → f i ∈ applyUpTo f n ∈-applyUpTo⁺ = Membershipₛ.∈-applyUpTo⁺ (P.setoid A) ∈-applyUpTo⁻ : ∀ {v} f {n} → v ∈ applyUpTo f n → ∃ λ i → i < n × v ≡ f i ∈-applyUpTo⁻ = Membershipₛ.∈-applyUpTo⁻ (P.setoid A) ------------------------------------------------------------------------ -- tabulate module _ {a} {A : Set a} where ∈-tabulate⁺ : ∀ {n} {f : Fin n → A} i → f i ∈ tabulate f ∈-tabulate⁺ = Membershipₛ.∈-tabulate⁺ (P.setoid A) ∈-tabulate⁻ : ∀ {n} {f : Fin n → A} {v} → v ∈ tabulate f → ∃ λ i → v ≡ f i ∈-tabulate⁻ = Membershipₛ.∈-tabulate⁻ (P.setoid A) ------------------------------------------------------------------------ -- filter module _ {a p} {A : Set a} {P : A → Set p} (P? : Decidable P) where ∈-filter⁺ : ∀ {x xs} → x ∈ xs → P x → x ∈ filter P? xs ∈-filter⁺ = Membershipₛ.∈-filter⁺ (P.setoid A) P? (P.subst P) ∈-filter⁻ : ∀ {v xs} → v ∈ filter P? xs → v ∈ xs × P v ∈-filter⁻ = Membershipₛ.∈-filter⁻ (P.setoid A) P? (P.subst P) ------------------------------------------------------------------------ -- _>>=_ module _ {ℓ} {A B : Set ℓ} where >>=-∈↔ : ∀ {xs} {f : A → List B} {y} → (∃ λ x → x ∈ xs × y ∈ f x) ↔ y ∈ (xs >>= f) >>=-∈↔ {xs = xs} {f} {y} = (∃ λ x → x ∈ xs × y ∈ f x) ↔⟨ Any↔ ⟩ Any (Any (y ≡_) ∘ f) xs ↔⟨ >>=↔ ⟩ y ∈ (xs >>= f) ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _⊛_ module _ {ℓ} {A B : Set ℓ} where ⊛-∈↔ : ∀ (fs : List (A → B)) {xs y} → (∃₂ λ f x → f ∈ fs × x ∈ xs × y ≡ f x) ↔ y ∈ (fs ⊛ xs) ⊛-∈↔ fs {xs} {y} = (∃₂ λ f x → f ∈ fs × x ∈ xs × y ≡ f x) ↔⟨ Σ.cong Inv.id (∃∃↔∃∃ _) ⟩ (∃ λ f → f ∈ fs × ∃ λ x → x ∈ xs × y ≡ f x) ↔⟨ Σ.cong Inv.id ((_ ∎) ⟨ _×-cong_ ⟩ Any↔) ⟩ (∃ λ f → f ∈ fs × Any (_≡_ y ∘ f) xs) ↔⟨ Any↔ ⟩ Any (λ f → Any (_≡_ y ∘ f) xs) fs ↔⟨ ⊛↔ ⟩ y ∈ (fs ⊛ xs) ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- _⊗_ module _ {ℓ} {A B : Set ℓ} where ⊗-∈↔ : ∀ {xs ys} {x : A} {y : B} → (x ∈ xs × y ∈ ys) ↔ (x , y) ∈ (xs ⊗ ys) ⊗-∈↔ {xs} {ys} {x} {y} = (x ∈ xs × y ∈ ys) ↔⟨ ⊗↔′ ⟩ Any (x ≡_ ⟨×⟩ y ≡_) (xs ⊗ ys) ↔⟨ Any-cong ×-≡×≡↔≡,≡ (_ ∎) ⟩ (x , y) ∈ (xs ⊗ ys) ∎ where open Related.EquationalReasoning ------------------------------------------------------------------------ -- length module _ {a} {A : Set a} where ∈-length : ∀ {x xs} → x ∈ xs → 1 ≤ length xs ∈-length = Membershipₛ.∈-length (P.setoid A) ------------------------------------------------------------------------ -- lookup module _ {a} {A : Set a} where ∈-lookup : ∀ xs i → lookup xs i ∈ xs ∈-lookup = Membershipₛ.∈-lookup (P.setoid A) ------------------------------------------------------------------------ -- foldr module _ {a} {A : Set a} {_•_ : Op₂ A} where foldr-selective : Selective _≡_ _•_ → ∀ e xs → (foldr _•_ e xs ≡ e) ⊎ (foldr _•_ e xs ∈ xs) foldr-selective = Membershipₛ.foldr-selective (P.setoid A) ------------------------------------------------------------------------ -- allFin ∈-allFin : ∀ {n} (k : Fin n) → k ∈ allFin n ∈-allFin = ∈-tabulate⁺ ------------------------------------------------------------------------ -- inits []∈inits : ∀ {a} {A : Set a} (as : List A) → [] ∈ inits as []∈inits [] = here refl []∈inits (a ∷ as) = here refl ------------------------------------------------------------------------ -- Other properties -- Only a finite number of distinct elements can be members of a -- given list. module _ {a} {A : Set a} where finite : (f : ℕ ↣ A) → ∀ xs → ¬ (∀ i → Injection.to f ⟨$⟩ i ∈ xs) finite inj [] fᵢ∈[] = ¬Any[] (fᵢ∈[] 0) finite inj (x ∷ xs) fᵢ∈x∷xs = excluded-middle helper where open Injection inj renaming (injective to f-inj) f : ℕ → A f = to ⟨$⟩_ not-x : ∀ {i} → f i ≢ x → f i ∈ xs not-x {i} fᵢ≢x with fᵢ∈x∷xs i ... | here fᵢ≡x = contradiction fᵢ≡x fᵢ≢x ... | there fᵢ∈xs = fᵢ∈xs helper : ¬ Dec (∃ λ i → f i ≡ x) helper (no fᵢ≢x) = finite inj xs (λ i → not-x (fᵢ≢x ∘ _,_ i)) helper (yes (i , fᵢ≡x)) = finite f′-inj xs f′ⱼ∈xs where f′ : ℕ → A f′ j with i ≤? j ... | yes i≤j = f (suc j) ... | no i≰j = f j ∈-if-not-i : ∀ {j} → i ≢ j → f j ∈ xs ∈-if-not-i i≢j = not-x (i≢j ∘ f-inj ∘ trans fᵢ≡x ∘ sym) lemma : ∀ {k j} → i ≤ j → ¬ (i ≤ k) → suc j ≢ k lemma i≤j i≰1+j refl = i≰1+j (≤-step i≤j) f′ⱼ∈xs : ∀ j → f′ j ∈ xs f′ⱼ∈xs j with i ≤? j ... | yes i≤j = ∈-if-not-i (<⇒≢ (s≤s i≤j)) ... | no i≰j = ∈-if-not-i (<⇒≢ (≰⇒> i≰j) ∘ sym) f′-injective′ : Injective {B = P.setoid A} (→-to-⟶ f′) f′-injective′ {j} {k} eq with i ≤? j | i ≤? k ... | yes _ | yes _ = P.cong pred (f-inj eq) ... | yes i≤j | no i≰k = contradiction (f-inj eq) (lemma i≤j i≰k) ... | no i≰j | yes i≤k = contradiction (f-inj eq) (lemma i≤k i≰j ∘ sym) ... | no _ | no _ = f-inj eq f′-inj = record { to = →-to-⟶ f′ ; injective = f′-injective′ } ------------------------------------------------------------------------ -- DEPRECATED ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 boolFilter-∈ : ∀ {a} {A : Set a} (p : A → Bool) (xs : List A) {x} → x ∈ xs → p x ≡ true → x ∈ boolFilter p xs boolFilter-∈ p [] () _ boolFilter-∈ p (x ∷ xs) (here refl) px≡true rewrite px≡true = here refl boolFilter-∈ p (y ∷ xs) (there pxs) px≡true with p y ... | true = there (boolFilter-∈ p xs pxs px≡true) ... | false = boolFilter-∈ p xs pxs px≡true {-# WARNING_ON_USAGE boolFilter-∈ "Warning: boolFilter was deprecated in v0.15. Please use filter instead." #-} -- Version 0.16 filter-∈ = ∈-filter⁺ {-# WARNING_ON_USAGE filter-∈ "Warning: filter-∈ was deprecated in v0.16. Please use ∈-filter⁺ instead." #-}
{ "alphanum_fraction": 0.4554145516, "avg_line_length": 34.5614035088, "ext": "agda", "hexsha": "9e91346e1a0e745ed0e7c45783840fe427edf0c0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional/Properties.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/Propositional/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4420, "size": 11820 }
------------------------------------------------------------------------ -- The derivative operator does not introduce any unneeded ambiguity ------------------------------------------------------------------------ module TotalParserCombinators.Derivative.LeftInverse where open import Codata.Musical.Notation open import Data.Maybe hiding (_>>=_) open import Data.Product open import Relation.Binary.PropositionalEquality open import Relation.Binary.HeterogeneousEquality using (refl) open import TotalParserCombinators.Derivative.Definition open import TotalParserCombinators.Derivative.SoundComplete import TotalParserCombinators.InitialBag as I open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics complete∘sound : ∀ {Tok R xs x s t} (p : Parser Tok R xs) (x∈ : x ∈ D t p · s) → complete (sound p x∈) ≡ x∈ complete∘sound token return = refl complete∘sound (p₁ ∣ p₂) (∣-left x∈p₁) rewrite complete∘sound p₁ x∈p₁ = refl complete∘sound (p₁ ∣ p₂) (∣-right ._ x∈p₂) rewrite complete∘sound p₂ x∈p₂ = refl complete∘sound (f <$> p) (<$> x∈p) rewrite complete∘sound p x∈p = refl complete∘sound (_⊛_ {fs = nothing} {xs = just _} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) rewrite complete∘sound p₁ f∈p₁′ = refl complete∘sound (_⊛_ {fs = just _} {xs = just _} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) rewrite complete∘sound p₁ f∈p₁′ = refl complete∘sound (_⊛_ {fs = just fs} {xs = just xs} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with (refl , f∈fs) ← Return⋆.sound fs f∈ret⋆ | refl ← Return⋆.complete∘sound fs f∈ret⋆ rewrite I.complete∘sound p₁ f∈fs | complete∘sound p₂ x∈p₂′ = refl complete∘sound (_⊛_ {fs = nothing} {xs = nothing} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) rewrite complete∘sound (♭ p₁) f∈p₁′ = refl complete∘sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) rewrite complete∘sound (♭ p₁) f∈p₁′ = refl complete∘sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with (refl , f∈fs) ← Return⋆.sound fs f∈ret⋆ | refl ← Return⋆.complete∘sound fs f∈ret⋆ rewrite I.complete∘sound (♭ p₁) f∈fs | complete∘sound p₂ x∈p₂′ = refl complete∘sound (_>>=_ {xs = nothing} {f = just _} p₁ p₂) (x∈p₁′ >>= y∈p₂x) rewrite complete∘sound p₁ x∈p₁′ = refl complete∘sound (_>>=_ {xs = just _} {f = just _} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) rewrite complete∘sound p₁ x∈p₁′ = refl complete∘sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with (refl , y∈xs) ← Return⋆.sound xs y∈ret⋆ | refl ← Return⋆.complete∘sound xs y∈ret⋆ rewrite I.complete∘sound p₁ y∈xs | complete∘sound (p₂ _) z∈p₂′y = refl complete∘sound (_>>=_ {xs = nothing} {f = nothing} p₁ p₂) (x∈p₁′ >>= y∈p₂x) rewrite complete∘sound (♭ p₁) x∈p₁′ = refl complete∘sound (_>>=_ {xs = just _} {f = nothing} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) rewrite complete∘sound (♭ p₁) x∈p₁′ = refl complete∘sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with (refl , y∈xs) ← Return⋆.sound xs y∈ret⋆ | refl ← Return⋆.complete∘sound xs y∈ret⋆ rewrite I.complete∘sound (♭ p₁) y∈xs | complete∘sound (p₂ _) z∈p₂′y = refl complete∘sound (nonempty p) x∈p = complete∘sound p x∈p complete∘sound (cast _ p) x∈p = complete∘sound p x∈p complete∘sound (return _) () complete∘sound fail ()
{ "alphanum_fraction": 0.5973211741, "avg_line_length": 59.4745762712, "ext": "agda", "hexsha": "53f1f783204038b5a87e5815b344ea0cc23b555c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/Derivative/LeftInverse.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Derivative/LeftInverse.agda", "max_line_length": 132, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Derivative/LeftInverse.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 1395, "size": 3509 }
-- 'Set' is no longer a keyword but a primitive defined in -- 'Agda.Primitive'. It is imported by default but this can be -- disabled with a flag: {-# OPTIONS --no-import-sorts #-} -- By importing Agda.Primitive explicitly we can rename 'Set' to -- something else: open import Agda.Primitive renaming (Set to Type) -- Now 'Set' is no longer in scope: -- test₁ = Set -- Error message: Not in scope: Set -- Instead it is now called 'Type'. Note that suffixed versions -- 'Type₁', 'Type₂', ... work as expected, as does 'Type ℓ' for a -- level 'ℓ'! Foo : Type₁ Foo = Type Bar : ∀ ℓ → Type (lsuc ℓ) Bar ℓ = Type ℓ -- We can now redefine Set however we want: open import Agda.Builtin.Equality open import Agda.Builtin.Sigma IsSet : ∀ {ℓ} → Type ℓ → Type ℓ IsSet X = {x y : X} (p q : x ≡ y) → p ≡ q Set : ∀ ℓ → Type (lsuc ℓ) Set ℓ = Σ (Type ℓ) IsSet
{ "alphanum_fraction": 0.6584507042, "avg_line_length": 25.8181818182, "ext": "agda", "hexsha": "19cf0d6eaf6fff40634c3b1235f8e7b7a187d0d7", "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/ByeByeSet.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/ByeByeSet.agda", "max_line_length": 65, "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/ByeByeSet.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": 278, "size": 852 }
-- {-# OPTIONS -v tc.conv:30 -v tc.conv.level:60 -v tc.meta.assign:15 #-} module UniversePolymorphism where open import Common.Level renaming (_⊔_ to max) data Nat : Set where zero : Nat suc : Nat → Nat infixr 40 _∷_ data Vec {i}(A : Set i) : Nat → Set i where [] : Vec {i} A zero _∷_ : ∀ {n} → A → Vec {i} A n → Vec {i} A (suc n) map : ∀ {n a b}{A : Set a}{B : Set b} → (A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs vec : ∀ {n a}{A : Set a} → A → Vec A n vec {zero} _ = [] vec {suc n} x = x ∷ vec x _<*>_ : ∀ {n a b}{A : Set a}{B : Set b} → Vec (A → B) n → Vec A n → Vec B n [] <*> [] = [] (f ∷ fs) <*> (x ∷ xs) = f x ∷ (fs <*> xs) flip : ∀ {a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B → C) → B → A → C flip f x y = f y x module Zip where Fun : ∀ {n a} → Vec (Set a) n → Set a → Set a Fun [] B = B Fun (A ∷ As) B = A → Fun As B app : ∀ {n m a}(As : Vec (Set a) n)(B : Set a) → Vec (Fun As B) m → Fun (map (flip Vec m) As) (Vec B m) app [] B bs = bs app (A ∷ As) B fs = λ as → app As B (fs <*> as) zipWith : ∀ {n m a}(As : Vec (Set a) n)(B : Set a) → Fun As B → Fun (map (flip Vec m) As) (Vec B m) zipWith As B f = app As B (vec f) zipWith₃ : ∀ {n a}{A B C D : Set a} → (A → B → C → D) → Vec A n → Vec B n → Vec C n → Vec D n zipWith₃ = zipWith (_ ∷ _ ∷ _ ∷ []) _ data Σ {a b}(A : Set a)(B : A → Set b) : Set (max a b) where _,_ : (x : A)(y : B x) → Σ A B fst : ∀ {a b}{A : Set a}{B : A → Set b} → Σ A B → A fst (x , y) = x snd : ∀ {a b}{A : Set a}{B : A → Set b}(p : Σ A B) → B (fst p) snd (x , y) = y -- Normal Σ List : ∀ {a} → Set a → Set a List A = Σ _ (Vec A) nil : ∀ {a}{A : Set a} → List A nil = _ , [] cons : ∀ {a}{A : Set a} → A → List A → List A cons x (_ , xs) = _ , x ∷ xs AnyList : ∀ {i} → Set (lsuc i) AnyList {i} = Σ (Set i) (List {i})
{ "alphanum_fraction": 0.4511873351, "avg_line_length": 26.3194444444, "ext": "agda", "hexsha": "cb3b80d4ad61c060046c8bc301109651d467d5b3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/UniversePolymorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/UniversePolymorphism.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/UniversePolymorphism.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 836, "size": 1895 }
open import Agda.Builtin.Nat data Fin : Nat → Set where zero : {n : Nat} → Fin (suc n) suc : {n : Nat} → Fin n → Fin (suc n) f : Fin 1 → Nat f zero = 0
{ "alphanum_fraction": 0.5297619048, "avg_line_length": 16.8, "ext": "agda", "hexsha": "c432408f81ad003d5d7f2ec6098b48d9c6498745", "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/NoAbsurdClause.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/NoAbsurdClause.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/Succeed/NoAbsurdClause.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": 67, "size": 168 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Sets.EquivalenceRelations open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals.Semiring open import Numbers.Integers.Integers open import Groups.Definition module Groups.Cyclic.Definition {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_·_ : A → A → A} (G : Group S _·_) where open Setoid S open Group G open Equivalence eq open import Groups.Lemmas G positiveEltPower : (x : A) (i : ℕ) → A positiveEltPower x 0 = Group.0G G positiveEltPower x (succ i) = x · (positiveEltPower x i) positiveEltPowerWellDefinedG : (x y : A) → (x ∼ y) → (i : ℕ) → (positiveEltPower x i) ∼ (positiveEltPower y i) positiveEltPowerWellDefinedG x y x=y 0 = reflexive positiveEltPowerWellDefinedG x y x=y (succ i) = +WellDefined x=y (positiveEltPowerWellDefinedG x y x=y i) positiveEltPowerCollapse : (x : A) (i j : ℕ) → Setoid._∼_ S ((positiveEltPower x i) · (positiveEltPower x j)) (positiveEltPower x (i +N j)) positiveEltPowerCollapse x zero j = Group.identLeft G positiveEltPowerCollapse x (succ i) j = transitive (symmetric +Associative) (+WellDefined reflexive (positiveEltPowerCollapse x i j)) elementPower : (x : A) (i : ℤ) → A elementPower x (nonneg i) = positiveEltPower x i elementPower x (negSucc i) = Group.inverse G (positiveEltPower x (succ i)) -- TODO: move this to lemmas elementPowerWellDefinedZ : (i j : ℤ) → (i ≡ j) → {g : A} → elementPower g i ≡ elementPower g j elementPowerWellDefinedZ i j i=j {g} = applyEquality (elementPower g) i=j elementPowerWellDefinedZ' : (i j : ℤ) → (i ≡ j) → {g : A} → (elementPower g i) ∼ (elementPower g j) elementPowerWellDefinedZ' i j i=j {g} = identityOfIndiscernablesRight _∼_ reflexive (elementPowerWellDefinedZ i j i=j) elementPowerWellDefinedG : (g h : A) → (g ∼ h) → {n : ℤ} → (elementPower g n) ∼ (elementPower h n) elementPowerWellDefinedG g h g=h {nonneg n} = positiveEltPowerWellDefinedG g h g=h n elementPowerWellDefinedG g h g=h {negSucc x} = inverseWellDefined (+WellDefined g=h (positiveEltPowerWellDefinedG g h g=h x)) record CyclicGroup : Set (m ⊔ n) where field generator : A cyclic : {a : A} → (Sg ℤ (λ i → Setoid._∼_ S (elementPower generator i) a))
{ "alphanum_fraction": 0.7144742631, "avg_line_length": 45.46, "ext": "agda", "hexsha": "acae944ef1d437f3e3f7549753d91285f3398729", "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": "Groups/Cyclic/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/Cyclic/Definition.agda", "max_line_length": 139, "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": "Groups/Cyclic/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 773, "size": 2273 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Prod.Properties where open import Cubical.Core.Everything open import Cubical.Data.Prod.Base open import Cubical.Data.Sigma renaming (_×_ to _×Σ_) hiding (prodIso ; toProdIso ; curryIso) open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' -- Swapping is an equivalence ×≡ : {a b : A × B} → proj₁ a ≡ proj₁ b → proj₂ a ≡ proj₂ b → a ≡ b ×≡ {a = (a1 , b1)} {b = (a2 , b2)} id1 id2 i = (id1 i) , (id2 i) swap : A × B → B × A swap (x , y) = (y , x) swap-invol : (xy : A × B) → swap (swap xy) ≡ xy swap-invol (_ , _) = refl isEquivSwap : (A : Type ℓ) (B : Type ℓ') → isEquiv (λ (xy : A × B) → swap xy) isEquivSwap A B = isoToIsEquiv (iso swap swap swap-invol swap-invol) swapEquiv : (A : Type ℓ) (B : Type ℓ') → A × B ≃ B × A swapEquiv A B = (swap , isEquivSwap A B) swapEq : (A : Type ℓ) (B : Type ℓ') → A × B ≡ B × A swapEq A B = ua (swapEquiv A B) private open import Cubical.Data.Nat -- As × is defined as a datatype this computes as expected -- (i.e. "C-c C-n test1" reduces to (2 , 1)). If × is implemented -- using Sigma this would be "transp (λ i → swapEq ℕ ℕ i) i0 (1 , 2)" test : ℕ × ℕ test = transp (λ i → swapEq ℕ ℕ i) i0 (1 , 2) testrefl : test ≡ (2 , 1) testrefl = refl -- equivalence between the sigma-based definition and the inductive one A×B≃A×ΣB : A × B ≃ A ×Σ B A×B≃A×ΣB = isoToEquiv (iso (λ { (a , b) → (a , b)}) (λ { (a , b) → (a , b)}) (λ _ → refl) (λ { (a , b) → refl })) A×B≡A×ΣB : A × B ≡ A ×Σ B A×B≡A×ΣB = ua A×B≃A×ΣB -- truncation for products isOfHLevelProd : (n : HLevel) → isOfHLevel n A → isOfHLevel n B → isOfHLevel n (A × B) isOfHLevelProd {A = A} {B = B} n h1 h2 = let h : isOfHLevel n (A ×Σ B) h = isOfHLevelΣ n h1 (λ _ → h2) in transport (λ i → isOfHLevel n (A×B≡A×ΣB {A = A} {B = B} (~ i))) h ×-≃ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A : Type ℓ₁} {B : Type ℓ₂} {C : Type ℓ₃} {D : Type ℓ₄} → A ≃ C → B ≃ D → A × B ≃ C × D ×-≃ {A = A} {B = B} {C = C} {D = D} f g = isoToEquiv (iso φ ψ η ε) where φ : A × B → C × D φ (a , b) = equivFun f a , equivFun g b ψ : C × D → A × B ψ (c , d) = equivFun (invEquiv f) c , equivFun (invEquiv g) d η : section φ ψ η (c , d) i = retEq f c i , retEq g d i ε : retract φ ψ ε (a , b) i = secEq f a i , secEq g b i {- Some simple ismorphisms -} prodIso : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} {D : Type ℓ'''} → Iso A C → Iso B D → Iso (A × B) (C × D) Iso.fun (prodIso iAC iBD) (a , b) = (Iso.fun iAC a) , Iso.fun iBD b Iso.inv (prodIso iAC iBD) (c , d) = (Iso.inv iAC c) , Iso.inv iBD d Iso.rightInv (prodIso iAC iBD) (c , d) = ×≡ (Iso.rightInv iAC c) (Iso.rightInv iBD d) Iso.leftInv (prodIso iAC iBD) (a , b) = ×≡ (Iso.leftInv iAC a) (Iso.leftInv iBD b) toProdIso : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} → Iso (A → B × C) ((A → B) × (A → C)) Iso.fun toProdIso = λ f → (λ a → proj₁ (f a)) , (λ a → proj₂ (f a)) Iso.inv toProdIso (f , g) = λ a → (f a) , (g a) Iso.rightInv toProdIso (f , g) = refl Iso.leftInv toProdIso b = funExt λ a → sym (×-η _) curryIso : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} → Iso (A × B → C) (A → B → C) Iso.fun curryIso f a b = f (a , b) Iso.inv curryIso f (a , b) = f a b Iso.rightInv curryIso a = refl Iso.leftInv curryIso f = funExt λ {(a , b) → refl}
{ "alphanum_fraction": 0.5480978261, "avg_line_length": 32.8571428571, "ext": "agda", "hexsha": "ce5d3a9fd34857113540e986b2cdd9dcdd29ab52", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Prod/Properties.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/Data/Prod/Properties.agda", "max_line_length": 93, "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/Data/Prod/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1558, "size": 3680 }
------------------------------------------------------------------------ -- Linearisation of mixfix operators ------------------------------------------------------------------------ open import Mixfix.Expr open import Mixfix.Acyclic.PrecedenceGraph using (acyclic; precedence) module Mixfix.Acyclic.Show (g : PrecedenceGraphInterface.PrecedenceGraph acyclic) where open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.List using (List) open import Data.List.Membership.Propositional using (_∈_) open import Data.List.Relation.Unary.Any using (here; there) open import Data.Vec using (Vec; []; _∷_) import Data.DifferenceList as DiffList open DiffList using (DiffList; _++_) renaming (_∷_ to cons; [_] to singleton) open import Data.Product using (∃; _,_; -,_) open import Function using (_∘_; flip) open import Data.Maybe using (Maybe; nothing; just) import Data.String as String open import Relation.Binary.PropositionalEquality using (_≡_; refl) open PrecedenceCorrect acyclic g open import StructurallyRecursiveDescentParsing.Simplified open import StructurallyRecursiveDescentParsing.Simplified.Semantics as Semantics open import Mixfix.Fixity open import Mixfix.Operator open import Mixfix.Acyclic.Lib as Lib open Lib.Semantics-⊕ import Mixfix.Acyclic.Grammar import Mixfix.Acyclic.Lemma private module Grammar = Mixfix.Acyclic.Grammar g module Lemma = Mixfix.Acyclic.Lemma g ------------------------------------------------------------------------ -- Linearisation -- Note: The code assumes that the grammar is unambiguous. module Show where mutual expr : ∀ {ps} → Expr ps → DiffList NamePart expr (_ ∙ e) = exprIn e exprIn : ∀ {p assoc} → ExprIn p assoc → DiffList NamePart exprIn ⟪ op ⟫ = inner op exprIn (l ⟨ op ⟫ ) = outer l ++ inner op exprIn ( ⟪ op ⟩ r) = inner op ++ outer r exprIn (l ⟨ op ⟩ r) = expr l ++ inner op ++ expr r exprIn (l ⟨ op ⟩ˡ r) = outer l ++ inner op ++ expr r exprIn (l ⟨ op ⟩ʳ r) = expr l ++ inner op ++ outer r outer : ∀ {p assoc} → Outer p assoc → DiffList NamePart outer (similar e) = exprIn e outer (tighter e) = expr e inner : ∀ {fix} {ops : List (∃ (Operator fix))} → Inner ops → DiffList NamePart inner (_∙_ {op = op} _ args) = inner′ (nameParts op) args inner′ : ∀ {arity} → Vec NamePart (1 + arity) → Vec (Expr g) arity → DiffList NamePart inner′ (n ∷ []) [] = singleton n inner′ (n ∷ ns) (arg ∷ args) = cons n (expr arg ++ inner′ ns args) show : ∀ {ps} → Expr ps → List NamePart show = DiffList.toList ∘ Show.expr ------------------------------------------------------------------------ -- Correctness module Correctness where mutual expr : ∀ {ps s} (e : Expr ps) → e ⊕ s ∈⟦ Grammar.precs ps ⟧· Show.expr e s expr (here refl ∙ e) = ∣ˡ (<$> exprIn e) expr (there x∈xs ∙ e) = ∣ʳ (<$> expr (x∈xs ∙ e)) exprIn : ∀ {p assoc s} (e : ExprIn p assoc) → (-, e) ⊕ s ∈⟦ Grammar.prec p ⟧· Show.exprIn e s exprIn {precedence ops sucs} e = exprIn′ _ e where p = precedence ops sucs module N = Grammar.Prec ops sucs lemmaʳ : ∀ {f : Outer p right → ExprIn p right} {s e} {g : DiffList NamePart} → (∀ {s} → f ⊕ s ∈⟦ N.preRight ⟧· g s) → e ⊕ s ∈⟦ N.appʳ <$> N.preRight + ⊛ N.p↑ ⟧· Show.exprIn e s → f (similar e) ⊕ s ∈⟦ N.appʳ <$> N.preRight + ⊛ N.p↑ ⟧· g (Show.exprIn e s) lemmaʳ f∈ (<$> fs∈ ⊛ e∈) = <$> +-∷ f∈ fs∈ ⊛ e∈ preRight : ∀ {s} (e : ExprIn p right) → e ⊕ s ∈⟦ N.appʳ <$> N.preRight + ⊛ N.p↑ ⟧· Show.exprIn e s preRight ( ⟪ op ⟩ tighter e) = <$> +-[] (∣ˡ (<$> inner op)) ⊛ expr e preRight ( ⟪ op ⟩ similar e) = lemmaʳ (∣ˡ (<$> inner op)) (preRight e) preRight (l ⟨ op ⟩ʳ tighter e) = <$> +-[] (∣ʳ (<$> expr l ⊛ inner op)) ⊛ expr e preRight (l ⟨ op ⟩ʳ similar e) = lemmaʳ (∣ʳ (<$> expr l ⊛ inner op)) (preRight e) lemmaˡ : ∀ {f : Outer p left → ExprIn p left} {s e} {g : DiffList NamePart} → (∀ {s} → f ⊕ s ∈⟦ N.postLeft ⟧· g s) → e ⊕ g s ∈⟦ N.appˡ <$> N.p↑ ⊛ N.postLeft + ⟧· Show.exprIn e (g s) → f (similar e) ⊕ s ∈⟦ N.appˡ <$> N.p↑ ⊛ N.postLeft + ⟧· Show.exprIn e (g s) lemmaˡ {f} f∈ (_⊛_ {x = fs} (<$>_ {x = e} e∈) fs∈) = Lib.Semantics-⊕.cast∈ (Lemma.appˡ-∷ʳ (tighter e) fs f) (<$> e∈ ⊛ +-∷ʳ fs∈ f∈) postLeft : ∀ {s} (e : ExprIn p left) → e ⊕ s ∈⟦ N.appˡ <$> N.p↑ ⊛ N.postLeft + ⟧· Show.exprIn e s postLeft (tighter e ⟨ op ⟫ ) = <$> expr e ⊛ +-[] (∣ˡ (<$> inner op)) postLeft (similar e ⟨ op ⟫ ) = lemmaˡ (∣ˡ (<$> inner op)) (postLeft e) postLeft (tighter e ⟨ op ⟩ˡ r) = <$> expr e ⊛ +-[] (∣ʳ (<$> inner op ⊛ expr r)) postLeft (similar e ⟨ op ⟩ˡ r) = lemmaˡ (∣ʳ (<$> inner op ⊛ expr r)) (postLeft e) exprIn′ : ∀ assoc {s} (e : ExprIn p assoc) → (-, e) ⊕ s ∈⟦ Grammar.prec p ⟧· Show.exprIn e s exprIn′ non ⟪ op ⟫ = ∥ˡ (<$> inner op) exprIn′ non (l ⟨ op ⟩ r) = ∥ʳ (∥ˡ (<$> expr l ⊛ inner op ⊛ expr r)) exprIn′ right e = ∥ʳ (∥ʳ (∥ˡ (preRight e))) exprIn′ left e = ∥ʳ (∥ʳ (∥ʳ (∥ˡ (postLeft e)))) inner : ∀ {fix s ops} (i : Inner {fix} ops) → i ⊕ s ∈⟦ Grammar.inner ops ⟧· Show.inner i s inner {fix} {s} (_∙_ {arity} {op} op∈ops args) = helper op∈ops args where helper : {ops : List (∃ (Operator fix))} (op∈ : (arity , op) ∈ ops) (args : Vec (Expr g) arity) → let i = op∈ ∙ args in i ⊕ s ∈⟦ Grammar.inner ops ⟧· Show.inner i s helper (here refl) args = ∣ˡ (<$> inner′ (nameParts op) args) helper (there {x = _ , _} op∈) args = ∣ʳ (<$> helper op∈ args) inner′ : ∀ {arity s} (ns : Vec NamePart (1 + arity)) args → args ⊕ s ∈⟦ Grammar.expr between ns ⟧· Show.inner′ ns args s inner′ (n ∷ []) [] = between-[] inner′ (n ∷ n′ ∷ ns) (arg ∷ args) = between-∷ (expr arg) (inner′ (n′ ∷ ns) args) -- All generated strings are syntactically correct (but possibly -- ambiguous). Note that this result implies that all -- precedence-correct expressions are generated by the grammar. correct : (e : Expr g) → e ∈ Grammar.expression · show e correct e = Semantics.⊕-sound (Lib.Semantics-⊕.sound (Correctness.expr e))
{ "alphanum_fraction": 0.5210646388, "avg_line_length": 41.6139240506, "ext": "agda", "hexsha": "663ad84305988650f63dd896d24c31f841c8af15", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "Mixfix/Acyclic/Show.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "Mixfix/Acyclic/Show.agda", "max_line_length": 93, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "Mixfix/Acyclic/Show.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 2226, "size": 6575 }
{-# OPTIONS --no-termination-check #-} ------------------------------------------------------------------------ -- A library of parser combinators ------------------------------------------------------------------------ module Parallel.Lib where open import Utilities open import Parallel open import Parallel.Index open import Data.Bool hiding (_≟_) open import Data.Nat hiding (_≟_) open import Data.Product.Record using (_,_) open import Data.Product renaming (_,_ to pair) open import Data.List open import Data.Function open import Data.Maybe import Data.Char as C open import Relation.Nullary open import Relation.Binary ------------------------------------------------------------------------ -- Applicative functor parsers -- We could get these for free with better library support. infixl 4 _⊛_ _<⊛_ _⊛>_ _<$>_ _<$_ -- Parser together with return and _⊛_ form a (generalised) -- applicative functor. (Warning: I have not checked that the laws are -- actually satisfied.) -- Note that all the resulting indices can be inferred. _⊛_ : forall {tok r₁ r₂ i₁ i₂} -> Parser tok i₁ (r₁ -> r₂) -> Parser tok i₂ r₁ -> Parser tok _ r₂ -- (i₁ ·I (i₂ ·I 1I)) f ⊛ x = f >>= \f' -> x >>= \x' -> return (f' x') _<$>_ : forall {tok r₁ r₂ i} -> (r₁ -> r₂) -> Parser tok i r₁ -> Parser tok _ r₂ -- (i ·I 1I) f <$> x = return f ⊛ x _<⊛_ : forall {tok i₁ i₂ r₁ r₂} -> Parser tok i₁ r₁ -> Parser tok i₂ r₂ -> Parser tok _ r₁ x <⊛ y = const <$> x ⊛ y _⊛>_ : forall {tok i₁ i₂ r₁ r₂} -> Parser tok i₁ r₁ -> Parser tok i₂ r₂ -> Parser tok _ r₂ x ⊛> y = flip const <$> x ⊛ y _<$_ : forall {tok r₁ r₂ i} -> r₁ -> Parser tok i r₂ -> Parser tok _ r₁ x <$ y = const x <$> y ------------------------------------------------------------------------ -- Parsers for sequences mutual _⋆ : forall {tok r d} -> Parser tok (false , d) r -> Parser tok _ (List r) p ⋆ ~ return [] ∣ p + _+ : forall {tok r d} -> Parser tok (false , d) r -> Parser tok (false , d) (List r) p + ~ _∷_ <$> p ⊛ p ⋆ -- Are these definitions productive? _∣_ and _⊛_ are not -- constructors... Unfolding (and ignoring some casts) we get -- (unless I've made some mistake) -- -- p ⋆ ~ parser \k -> Base._∣_ (k []) (unP (p +) k) -- -- and -- -- p + ~ parser (\k -> unP p (\x -> -- unP (p ⋆) (\xs -> k (x ∷ xs)))) -- ~ parser (\k -> unP p (\x -> Base._∣_ (k (x ∷ [])) -- (unP (p +) (\xs -> k (x ∷ xs))))). -- -- Assume that p + is applied to the continuation k = -- const Base.fail. We get -- -- unP (p +) k ~ unP p (\x -> unP (p +) (\xs -> k (x ∷ xs))). -- -- This implies that the definitions above are not /obviously/ -- productive. Note now that when p is defined the function unP p -- has type -- -- forall {i' r'} -> -- (r -> Base.Parser tok r' i') -> -- Base.Parser tok r' (i ·I i') -- -- for arbitrary i' and r', and with i = (false , d) as above this -- specialises to -- -- forall {i' r'} -> -- (r -> Base.Parser tok r' i') -> -- Base.Parser tok r' (false , d). -- -- Note that in some cases it is actually possible for p to -- immediately return its input (by first checking that i' = -- (false, d)). Furthermore, if p can pattern match on the result of -- the continuation (like in Parallel.problematic), then unP (p +) -- is not productive. In this case the module system prevents p from -- performing such pattern matching /directly/, but ensuring that -- this is not possible /indirectly/ seems overly difficult, -- considering that there are definitions (other than -- Parallel.problematic) which pattern match on Base.Parser. -- -- As an example the type checking of the following definition does -- not terminate: -- -- loops : parse-complete (problematic false + >>= \_ -> fail) ('a' ∷ []) -- ≡ [] -- loops = ≡-refl -- -- Furthermore the definition of number below, which uses _+, is -- rather fragile, and the type checking of some definitions in -- Parallel.Examples which use number fail to terminate (at least -- with the version of Agda which is current at the time of -- writing). -- p sepBy sep parses one or more ps separated by seps. _sepBy_ : forall {tok r r' i d} -> Parser tok i r -> Parser tok (false , d) r' -> Parser tok _ (List r) p sepBy sep = _∷_ <$> p ⊛ (sep ⊛> p) ⋆ chain₁ : forall {tok d₁ i₂ r} -> Assoc -> Parser tok (false , d₁) r -> Parser tok i₂ (r -> r -> r) -> Parser tok _ r chain₁ a p op = chain₁-combine a <$> (pair <$> p ⊛ op) ⋆ ⊛ p chain : forall {tok d₁ i₂ r} -> Assoc -> Parser tok (false , d₁) r -> Parser tok i₂ (r -> r -> r) -> r -> Parser tok _ r chain a p op x = return x ∣ chain₁ a p op ------------------------------------------------------------------------ -- Parsing a given token (symbol) module Sym (a : DecSetoid) where open DecSetoid a using (_≟_) renaming (carrier to tok) sym : tok -> Parser tok _ tok sym x = sat p where p : tok -> Maybe tok p y with x ≟ y ... | yes _ = just y ... | no _ = nothing ------------------------------------------------------------------------ -- Character parsers digit : Parser C.Char _ ℕ digit = 0 <$ sym '0' ∣ 1 <$ sym '1' ∣ 2 <$ sym '2' ∣ 3 <$ sym '3' ∣ 4 <$ sym '4' ∣ 5 <$ sym '5' ∣ 6 <$ sym '6' ∣ 7 <$ sym '7' ∣ 8 <$ sym '8' ∣ 9 <$ sym '9' where open Sym C.decSetoid number : Parser C.Char _ ℕ number = toNum <$> ds where -- Inlining ds makes the type checker loop. ds = digit + toNum = foldr (\n x -> 10 * x + n) 0 ∘ reverse
{ "alphanum_fraction": 0.5237270523, "avg_line_length": 30.3894736842, "ext": "agda", "hexsha": "62a7ba054fe1a72bba0ccd9f1b32f828c3bacc38", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/Parallel/Lib.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/Parallel/Lib.agda", "max_line_length": 77, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/Parallel/Lib.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 1745, "size": 5774 }
-- Andreas, 2014-01-07 Issue reported by Dmitriy Traytel {-# OPTIONS --copatterns #-} module _ where open import Common.Size open import Common.Prelude hiding (map) record Stream (A : Set) : Set where coinductive field head : A tail : Stream A open Stream -- This type should be empty. data D : (i : Size) → Set where cons : ∀ i → Stream (D i) → D (↑ i) -- BAD: But we can construct an inhabitant. inh : Stream (D ∞) head inh = cons ∞ inh -- Should be rejected by termination checker. tail inh = inh map : ∀{A B} → (A → B) → Stream A → Stream B head (map f s) = f (head s) tail (map f s) = map f (tail s) loop : ∀ i → D i → ⊥ loop .(↑ i) (cons i s) = head (map (loop i) s) absurd : ⊥ absurd = loop ∞ (cons ∞ inh)
{ "alphanum_fraction": 0.6156968877, "avg_line_length": 20.5277777778, "ext": "agda", "hexsha": "fc66e57048c33669a4731f431f701efb5cbaa907", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/Issue1209.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/Issue1209.agda", "max_line_length": 68, "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/Issue1209.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": 249, "size": 739 }
{-# OPTIONS --instance-search-depth=5 --show-implicit #-} open import Oscar.Prelude open import Oscar.Class.Smap open import Oscar.Class.Surjextensionality open import Oscar.Class.Symmetry open import Oscar.Class.Transitivity open import Oscar.Data.Proposequality open import Oscar.Data.Surjcollation import Oscar.Class.Surjection.⋆ module Oscar.Data.Surjextenscollation where module _ {𝔵 𝔞 𝔞̇ 𝔟 𝔟̇} {𝔛 : Ø 𝔵} (𝔄 : 𝔛 → 𝔛 → Ø 𝔞) (𝔅 : 𝔛 → Ø 𝔟) ⦃ _ : Smaphomarrow!.class 𝔄 𝔅 ⦄ (𝔄̇ : ∀ {x y} → 𝔄 x y → 𝔄 x y → Ø 𝔞̇) (let ℭ : 𝔛 → Ø 𝔵 ∙̂ 𝔞 ∙̂ 𝔞̇ ∙̂ ↑̂ 𝔟̇ ℭ = LeftExtensionṖroperty 𝔟̇ 𝔄 𝔄̇) (𝔅̇ : ∀ {y} → 𝔅 y → 𝔅 y → Ø 𝔟̇) ⦃ _ : ∀ {y} → Symmetry.class (𝔅̇ {y}) ⦄ ⦃ _ : ∀ {y} → Transitivity.class (𝔅̇ {y}) ⦄ ⦃ _ : Surjextensionality!.class 𝔄 𝔄̇ (Extension 𝔅) (Pointwise 𝔅̇) ⦄ where surjextenscollation[_/_]⟦_/_⟧ : ∀ {m} → 𝔅 m → 𝔅 m → ℭ m surjextenscollation[_/_]⟦_/_⟧ s t = surjcollation⟦ 𝔄 / 𝔅̇ ⟧ s t , λ f≐g f◃s=f◃t → -- FIXME this (`surjextensionality[ Pointwise 𝔅̇ ] ⦃ ! ⦄ f≐g t ∙ f◃s=f◃t ∙ symmetry (surjextensionality[ Pointwise 𝔅̇ ] ⦃ ! ⦄ f≐g s)`) used to be a workaround for "instance search depth exhausted", but now does not seem to help. See the FIXME note in Oscar.Class.Surjextensionality. ⟪ f≐g ⟫[ Pointwise 𝔅̇ ] t ∙ f◃s=f◃t ∙ symmetry (⟪ f≐g ⟫[ Pointwise 𝔅̇ ] s) module _ {𝔵 𝔞 𝔞̇} {𝔛 : Ø 𝔵} {𝔄 : 𝔛 → 𝔛 → Ø 𝔞} (𝔄̇ : ∀ {x y} → 𝔄 x y → 𝔄 x y → Ø 𝔞̇) {𝔟} {𝔅 : 𝔛 → Ø 𝔟} {𝔟̇} {𝔅̇ : ∀ {y} → 𝔅 y → 𝔅 y → Ø 𝔟̇} ⦃ _ : Smaphomarrow!.class 𝔄 𝔅 ⦄ ⦃ _ : ∀ {y} → Symmetry.class (𝔅̇ {y}) ⦄ ⦃ _ : ∀ {y} → Transitivity.class (𝔅̇ {y}) ⦄ ⦃ _ : Surjextensionality!.class 𝔄 𝔄̇ (Extension 𝔅) (Pointwise 𝔅̇) ⦄ where surjextenscollation⟦_⟧ = surjextenscollation[ 𝔄 / 𝔅 ]⟦ 𝔄̇ / 𝔅̇ ⟧ module _ {𝔵 𝔞 𝔞̇ 𝔟 𝔟̇} {𝔛 : Ø 𝔵} {𝔄 : 𝔛 → 𝔛 → Ø 𝔞} {𝔅 : 𝔛 → Ø 𝔟} (𝔄̇ : ∀ {x y} → 𝔄 x y → 𝔄 x y → Ø 𝔞̇) (𝔅̇ : ∀ {y} → 𝔅 y → 𝔅 y → Ø 𝔟̇) ⦃ _ : Smaphomarrow!.class 𝔄 𝔅 ⦄ ⦃ _ : ∀ {y} → Symmetry.class (𝔅̇ {y}) ⦄ ⦃ _ : ∀ {y} → Transitivity.class (𝔅̇ {y}) ⦄ ⦃ _ : Surjextensionality!.class 𝔄 𝔄̇ (Extension 𝔅) (Pointwise 𝔅̇) ⦄ where surjextenscollation⟦_/_⟧ = surjextenscollation[ 𝔄 / 𝔅 ]⟦ 𝔄̇ / 𝔅̇ ⟧ module Surjextenscollation {𝔵 𝔞 𝔞̇} {𝔛 : Ø 𝔵} (𝔄 : 𝔛 → 𝔛 → Ø 𝔞) (𝔄̇ : ∀ {x y} → 𝔄 x y → 𝔄 x y → Ø 𝔞̇) {𝔟} {𝔅 : 𝔛 → Ø 𝔟} {𝔟̇} {𝔅̇ : ∀ {y} → 𝔅 y → 𝔅 y → Ø 𝔟̇} ⦃ _ : Smaphomarrow!.class 𝔄 𝔅 ⦄ ⦃ _ : ∀ {y} → Symmetry.class (𝔅̇ {y}) ⦄ ⦃ _ : ∀ {y} → Transitivity.class (𝔅̇ {y}) ⦄ ⦃ _ : Surjextensionality!.class 𝔄 𝔄̇ (Extension 𝔅) (Pointwise 𝔅̇) ⦄ where method = surjextenscollation[ 𝔄 / 𝔅 ]⟦ 𝔄̇ / 𝔅̇ ⟧ infix 18 _⟹_ _⟹_ = method module _ {𝔵} {𝔛 : Ø 𝔵} {𝔞₁} {𝔄₁ : 𝔛 → Ø 𝔞₁} {𝔞₂} {𝔄₂ : 𝔛 → Ø 𝔞₂} (𝔄 : 𝔛 → 𝔛 → Ø 𝔞₁ ∙̂ 𝔞₂) ⦃ _ : 𝔄 ≡ Arrow 𝔄₁ 𝔄₂ ⦄ (let 𝔄 = Arrow 𝔄₁ 𝔄₂) where open Surjextenscollation 𝔄 _≡̇_ public using () renaming (method to ≡-surjextenscollation⟦_⟧) public
{ "alphanum_fraction": 0.5423728814, "avg_line_length": 36.5949367089, "ext": "agda", "hexsha": "53c9fd00d073dd05f3e54ffcb5df7efa65deaa9c", "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/Data/Surjextenscollation.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/Data/Surjextenscollation.agda", "max_line_length": 288, "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/Data/Surjextenscollation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1678, "size": 2891 }
module Ex3 where -- Conor: 5.5/15 (marked in sem 1 for 3.1-3.4) -- really 5.5/7 then another 3/8 in sem 2, giving 8.5/15 ---------------------------------------------------------------------------- -- EXERCISE 3 -- MONADS FOR HUTTON'S RAZOR -- -- VALUE: 15% -- DEADLINE: 5pm, Friday 20 November (week 9) -- -- DON'T SUBMIT, COMMIT! -- -- The purpose of this exercise is to introduce you to some useful -- mathematical structures and build good tools for working with -- vectors ---------------------------------------------------------------------------- open import CS410-Prelude open import CS410-Monoid open import CS410-Nat open import CS410-Vec open import CS410-Functor -- HINT: your tasks are heralded with the eminently searchable tag, "???" ---------------------------------------------------------------------------- -- HUTTON'S RAZOR ---------------------------------------------------------------------------- HVal : Set -- the set of *values* for Hutton's Razor HVal = Two + Nat -- Booleans or natural numbers data HExp (X : Set) : Set where var : X -> HExp X -- variables val : HVal -> HExp X -- values _+H_ _>=H_ : (e1 e2 : HExp X) -> HExp X -- addition, comparison ifH_then_else_ : (e1 e2 e3 : HExp X) -> HExp X -- conditional _>=2_ : Nat -> Nat -> Two x >=2 zero = tt zero >=2 suc _ = ff suc m >=2 suc n = m >=2 n ---------------------------------------------------------------------------- -- ??? 3.1 the HExp syntax-with-substitution monad (score: 2 / 2) ---------------------------------------------------------------------------- -- Show that HExp is a monad, where the "bind" operation performs -- simultaneous substitution (transforming all the variables in a term). hExpMonad : Monad HExp hExpMonad = record { return = λ x → var x ; _>>=_ = λ x f → hExpMonad>>= x f ; law1 = λ x f → refl ; law2 = λ t → hExpMonadLaw2 t ; law3 = λ f g t → hExpMonadLaw3 t g f } where hExpMonad>>= : {X Y : Set} → HExp X → (X → HExp Y) → HExp Y hExpMonad>>= (var x) f = f x hExpMonad>>= (val x) f = val x hExpMonad>>= (x +H y) f = hExpMonad>>= x f +H hExpMonad>>= y f hExpMonad>>= (x >=H y) f = hExpMonad>>= x f >=H hExpMonad>>= y f hExpMonad>>= (ifH x then y else z) f = ifH hExpMonad>>= x f then hExpMonad>>= y f else hExpMonad>>= z f hExpMonadLaw2 : {X : Set} → (t : HExp X) → hExpMonad>>= t (λ x → var x) == t hExpMonadLaw2 (var x) = refl hExpMonadLaw2 (val x) = refl hExpMonadLaw2 (x +H y) rewrite hExpMonadLaw2 x | hExpMonadLaw2 y = refl hExpMonadLaw2 (x >=H y) rewrite hExpMonadLaw2 x | hExpMonadLaw2 y = refl hExpMonadLaw2 (ifH x then y else z) rewrite hExpMonadLaw2 x | hExpMonadLaw2 y | hExpMonadLaw2 z = refl hExpMonadLaw3 : {X Y Z : Set} → (t : HExp X) → (g : Y → HExp Z) → (f : X → HExp Y) → hExpMonad>>= (hExpMonad>>= t f) g == hExpMonad>>= t (λ x → hExpMonad>>= (f x) g) hExpMonadLaw3 (var x) g t = refl hExpMonadLaw3 (val x) g t = refl hExpMonadLaw3 (f +H f₁) g t rewrite hExpMonadLaw3 f g t | hExpMonadLaw3 f₁ g t = refl hExpMonadLaw3 (f >=H f₁) g t rewrite hExpMonadLaw3 f g t | hExpMonadLaw3 f₁ g t = refl hExpMonadLaw3 (ifH f then f₁ else f₂) g t rewrite hExpMonadLaw3 f g t | hExpMonadLaw3 f₁ g t | hExpMonadLaw3 f₂ g t = refl ---------------------------------------------------------------------------- -- ??? 3.2 the error management monad (score: 1 / 1) ---------------------------------------------------------------------------- -- show that "+ E" is monadic, generalising the "Maybe" monad by allowing -- some sort of error report errorMonad : (E : Set) -> Monad \ V -> V + E -- "value or error" errorMonad E = record { return = λ x → tt , x ; _>>=_ = errorMonad>>= ; law1 = λ x f → refl ; law2 = errorMonadLaw2 ; law3 = errorMonadLaw3 } where errorMonad>>= : {X Y : Set} → X + E → (X → Y + E) → Y + E errorMonad>>= (tt , snd) y = y snd errorMonad>>= (ff , snd) y = ff , snd errorMonadLaw2 : {X : Set} (t : X + E) → errorMonad>>= t (λ x → tt , x) == t errorMonadLaw2 (tt , snd) = refl errorMonadLaw2 (ff , snd) = refl errorMonadLaw3 : {X Y Z : Set} (f : X → Y + E) (g : Y → Z + E) (t : X + E) → errorMonad>>= (errorMonad>>= t f) g == errorMonad>>= t (λ x → errorMonad>>= (f x) g) errorMonadLaw3 f g (tt , snd) = refl errorMonadLaw3 f g (ff , snd) = refl ---------------------------------------------------------------------------- -- ??? 3.3 the environment monad transformer (score: 1 / 1) ---------------------------------------------------------------------------- -- show that any monad can be adapted to thread some environment information -- as well as whatever else it already managed envMonad : (G : Set){M : Set -> Set} -> Monad M -> Monad \ V -> G -> M V -- "computation in an environment" envMonad G {M} MM = record { return = λ {X} z _ → Monad.return MM z ; _>>=_ = λ {X} {Y} z z₁ z₂ → (MM Monad.>>= z z₂) (λ z₃ → z₁ z₃ z₂) ; law1 = λ {X Y} x f → envMonadLaw1 f x ; law2 = envMonadLaw2 ; law3 = envMonadLaw3 } where open Monad MM envMonadLaw1 : {X Y : Set} (f : X → G → M Y) -> (x : X) -> (λ z₂ → return x >>= (λ z₃ → f z₃ z₂)) == f x envMonadLaw1 f x = ext (λ g → Monad.law1 MM x (λ z → f z g)) envMonadLaw2 : {X : Set} (t : G → M X) → (λ z₂ → t z₂ >>= (λ z₃ → return z₃)) == t envMonadLaw2 x = ext (λ a → Monad.law2 MM (x a)) envMonadLaw3 : {X Y Z : Set} (f : X → G → M Y) (g : Y → G → M Z) (t : G → M X) →(λ z₂ → (t z₂ >>= (λ z₃ → f z₃ z₂)) >>= (λ z₃ → g z₃ z₂)) == (λ z₂ → t z₂ >>= (λ z₃ → f z₃ z₂ >>= (λ z₄ → g z₄ z₂))) envMonadLaw3 f g t = ext (λ a → Monad.law3 MM (λ z → f z a) (λ z → g z a) (t a)) ---------------------------------------------------------------------------- -- ??? 3.4 interpreting Hutton's Razor (score: 1.5 / 3) ---------------------------------------------------------------------------- -- Implement an interpreter for Hutton's Razor. -- You will need to construct a type to represent possible run-time errors. -- Ensure that addition and comparison act on numbers, not Booleans. -- Ensure that the condition in an "if" is a Boolean, not a number. data InterpretError : Set where NotTwo : InterpretError NotNat : InterpretError -- helpful things to build Env : Set -> Set -- an environment for a given set of variables Env X = X -> HVal Compute : Set{- variables -} -> Set{- values -} -> Set Compute X V = Env X -> V + InterpretError -- how to compute a V computeMonad : {Z : Set} -> Monad (Compute Z) computeMonad {Z} = envMonad (Env Z) (errorMonad InterpretError) -- build this from the above parts -- This operation should explain how to get the value of a variable -- from the environment. varVal : {X : Set} -> X -> Compute X HVal varVal x y = tt , (y x) -- tt , (y x) -- These operations should ensure that you get the sort of value -- that you want, in order to ensure that you don't do bogus -- computation. mustBeNat : {X : Set} -> HVal -> Compute X Nat mustBeNat (tt , tt) x = ff , NotNat -- Conor: more case analysis than needed mustBeNat (tt , ff) x = ff , NotNat mustBeNat (ff , zero) x = tt , zero -- Conor: more case analysis than needed mustBeNat (ff , suc snd) x = tt , suc snd mustBeTwo : {X : Set} -> HVal -> Compute X Two mustBeTwo (tt , tt) x = tt , tt -- Conor: more case analysis than needed mustBeTwo (tt , ff) x = tt , ff mustBeTwo (ff , zero) x = ff , NotTwo -- Conor: more case analysis than needed mustBeTwo (ff , suc snd) x = ff , NotTwo -- Now, you're ready to go. Don't introduce the environment explicitly. -- Use the monad to thread it. interpret : {X : Set} -> HExp X -> Compute X HVal interpret {X} = go where open Monad (computeMonad {X}) go : HExp X -> Compute X HVal -- Conor: you already have the right kit, so it's counterproductive to go down to this detail go (var x) E = tt , (E x) -- Conor: go (var x) = varVal x go (val x) E = tt , x go (t +H t₁) E = {!!} -- Conor: go (l +H r) = -- go l >>= \ lv -> -- lv : HVal -- mustBeNat lv >>= \ ln -> -- ln : Nat -- go r >>= \ rv -> -- rv : HVal -- mustBeNat rv >>= \ rn -> -- rn : Nat -- return (ln +N rn) go (t >=H t₁) E = {!!} go (ifH t then t₁ else t₂) E = {!!} ---------------------------------------------------------------------------- -- ??? 3.5 Typed Hutton's Razor (score: 0.5 / 1) ---------------------------------------------------------------------------- -- Labelling the expressions with their types gives strong guarantees -- sooner (we can make it grammatically incorrect to add a bool to a -- nat) and makes some things easier as (if we're adding them then we -- know they are nats). -- some names for the types we will use in our typed syntax. data HType : Set where hTwo hNat : HType -- mapping names for types to real types. THVal : HType -> Set THVal hTwo = Two THVal hNat = Nat -- A syntax for types expressions, indexed by typed variables. Compare -- with the untyped HExp and fill in the missing expression formers, -- we have shown you the way with _+H_. think: what can be guaranteed? data THExp (X : HType -> Set) : HType -> Set where var : forall {T} -> X T -> THExp X T val : forall {T} -> THVal T -> THExp X T _+H_ : THExp X hNat -> THExp X hNat -> THExp X hNat _>=H_ : THExp X hNat -> THExp X hTwo {- Conor: hNat here! -} -> THExp X hTwo ifH_then_else_ : forall {T} -> THExp X hTwo -> THExp X T -> THExp X T -> THExp X T -- ??? fill in the other two constructs, typed appropriately -- (remember that "if then else" can compute values at any type) ---------------------------------------------------------------------------- -- ??? 3.6 Well Typed Programs Don't Go Wrong (score: 0 / 1) ---------------------------------------------------------------------------- -- notation for functions betweeen indexed sets (e.g. indexed by types) _-:>_ : {I : Set}(S T : I -> Set) -> I -> Set (S -:> T) i = S i -> T i infixr 3 _-:>_ -- notation for indexed sets [_] : {I : Set}(X : I -> Set) -> Set [ X ] = forall {i} -> X i -- We can put the two together to make types like -- [ S -:> T ] -- = forall {i} -> S i -> T i -- which is the type of functions which work at any index -- and respect that index. That'll be very useful in just a moment. -- An evaluator for typed terms, it takes an environment for -- variables (a function mapping variables to values) and a expression -- and returns a value). Written as below it looks like it lifts a -- function from variables to values to a function from terms to -- values. eval : {X : HType -> Set} -> [ X -:> THVal ] -> [ THExp X -:> THVal ] eval g (var x) = g x eval g (val x) = x eval g (t +H t1) = eval g t +N eval g t eval g (t >=H t1) = eval g t >=2 eval g t eval g (ifH t then t1 else t2) = if eval g t then eval g t1 else eval g t1 -- Conor: all three step cases get the wrong answers -- Note that the environment is an *index-respecting* function from -- variables to values. The index is the type of the variable: you're -- making sure that when you look up a variable of a given type, you -- get a value of that type. As a result, you can deliver a *type-safe* -- evaluator: when an expression has a given type, its value must have -- that type. ---------------------------------------------------------------------------- -- ??? 3.7 Variable Contexts (score: 1 / 1) ---------------------------------------------------------------------------- -- backwards lists. data Bwd (X : Set) : Set where [] : Bwd X _/_ : Bwd X -> X -> Bwd X -- Our datatype for type indexed expressions is very liberal about -- variables, they can be any set indexed by types. Here we build -- something more structured, that nevertheless satisfies the specification -- We will not use names for variables only numbers. -- Hence, a context is just a list of types. Context : Set Context = Bwd HType -- Well scoped and well typed variables, top = 0, pop = suc. -- top is the variable on the right hand end of a non-empty context. -- pop takes a variable and extends puts it into a longer context. data Var : (G : Context)(T : HType) -> Set where top : {G : Context}{T : HType} -> Var (G / T) T pop : {G : Context}{T S : HType} -> Var G T -> Var (G / S) T -- We can also represent environments as stacks, as opposed to functions. -- You can read a variable as the sequence of instructions for extracting -- a value from a stack: you keep popping stuff off until the value you -- want is the the one at the top. Stack : Context -> Set Stack [] = One Stack (G / S) = Stack G * THVal S -- Looking up a value for a variable in an an environment or fetching -- something from a stack given a sequence of pop and top -- instructions. It's all the same to us! fetch : {G : Context} -> Stack G -> [ Var G -:> THVal ] fetch g top = snd g fetch g (pop v) = fetch (fst g) v -- An evaluator for expression with more structured variables. We -- already know how to evaluate, we just have to explain how to deal -- with manage the different style of environment. evalStack : {G : Context}{T : HType} -> Stack G -> [ THExp (Var G) -:> THVal ] evalStack g = eval (fetch g) ---------------------------------------------------------------------------- -- ??? 3.8 Terms-With-One-Hole (score: 1 / 1) ---------------------------------------------------------------------------- -- Next, we build some kit that we'll use to present type errors. -- Here we represent an expression with a bit missing. Addition can have -- have a bit missing (a hole) on the right or on the left. What about -- the other expression formers? data HExp' (X : Set) : Set where []+H_ _+H[] : HExp X -> HExp' X []>=H_ _>=H[] : HExp X -> HExp' X ifH[]then_else_ ifH_then[]else_ ifH_then_else[] : HExp X -> HExp X -> HExp' X -- ??? more constructors here -- specifically, you will need a constructor for each way that a -- subexpression can fit inside an expression; -- we use the naming convention of showing where the "hole" is -- by putting [] in the corresponding place in the name. -- take a expression with a hole, and a expression to plug in and plug -- it in! _[]<-_ : forall {X} -> HExp' X -> HExp X -> HExp X ([]+H r) []<- t = t +H r (l +H[]) []<- t = l +H t ([]>=H r) []<- t = t >=H r (l >=H[]) []<- t = l >=H t (ifH[]then l else r) []<- t = ifH t then l else r (ifH e then[]else r) []<- t = ifH e then t else r (ifH e then l else[]) []<- t = ifH e then l else t -- ??? more cases here {- data List (X : Set) : Set where -- X scopes over the whole declaration... [] : List X -- ...so you can use it here... _::_ : X -> List X -> List X -- ...and here. infixr 3 _::_ -} -- As we descend down into a term we can keep the pieces we pass along -- the way in a list, this is a zipper. For example, given the -- expression 3 + (4 + 5) we could go down by going right and right -- again to reach 5. In our list we would have [ 4 + [] , 3 + [] ]. -- we need an operation that takes us back up to the root of the tree, -- restoring the expression to its former state (e.g. 3 + (4 + 5)). rootToHole : forall {X} -> List (HExp' X) -> HExp X -> HExp X rootToHole [] t = t rootToHole (t' :: t's) t = t' []<- rootToHole t's t -- The idea is that the pair of a List (HExp' X) and a single -- HExp X together represent a term with a designated subterm "in focus". -- The list of one-hole terms represents the *path* to the designated -- subterm, together with the *other stuff* hanging off to either side -- of that path. ---------------------------------------------------------------------------- -- ??? 3.9 Forgetting Types (score: 0.5 / 1) ---------------------------------------------------------------------------- -- SUSPICION: why would we want to? -- Given a typed term (THEXP X T) we can forget the types to obtain an -- untyped term (HExp Y) if we know how to forget types from variables -- (varFog). termFog : {X : HType -> Set}{Y : Set}(varFog : {T : HType} -> X T -> Y) -> {T : HType} -> THExp X T -> HExp Y termFog vF (var x) = var (vF x) termFog vF (val x) = {!x!} -- Conor: need to find the type termFog vF (t +H t1) = (termFog vF t) +H (termFog vF t1) termFog vF (t >=H t1) = (termFog vF t) >=H (termFog vF t1) termFog vF (ifH t then t1 else t2) = ifH (termFog vF t) then (termFog vF t1) else (termFog vF t2) -- Note that it's a local naming convention to call functions which -- forget information "fog". When it is foggy, you can see less. -- Our purpose in writing a function to throw away information is to -- *specify* what it means to *obtain* information. ---------------------------------------------------------------------------- -- ??? 3.10 A Typechecking View (score: 0 / 3) ---------------------------------------------------------------------------- -- We finish by building a typechecker which will allow us to detect -- when an untyped Hutton's Razor term can be converted into a typed -- term (and evaluated safely without rechecking). We make use of -- your solution to part 3.9 to express the idea that -- an untyped term is the forgetful image of a typed term we know -- and your solution to part 3.8 to express the idea that -- an untyped term can be focused at a place where there is a type error -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- But first, we need to build you a wee bit more kit. Typechecking relies -- on checking that the type you want is the type you've got, which sometimes -- means testing *equality* of types. It's not enough to have a function -- htypeEq : HType -> HType -> Two -- because we need to convince *Agda* of the equality, not just write a function -- that happens to say yes to equal things. -- a set with one element removed, i.e. X -[ x ] is the pair of some y in X and -- a proof that y isn't x _-[_] : (X : Set) -> X -> Set X -[ x ] = Sg X \ y -> x == y -> Zero -- a view for comparing types for equality data HTypeComparable (T : HType) : HType -> Set where same : HTypeComparable T T diff : (SnT : HType -[ T ]) -> HTypeComparable T (fst SnT) -- the above view type presents is two options, and in both of them, we -- have to come through with enough evidence to convince Agda -- implementing the view hTypeCompare : (S T : HType) -> HTypeComparable S T hTypeCompare hTwo hTwo = same hTypeCompare hTwo hNat = diff (hNat , \ ()) hTypeCompare hNat hTwo = diff (hTwo , \ ()) hTypeCompare hNat hNat = same -- we write the obvious four cases; in the "same" cases, the types really -- do match; in the "diff" cases, Agda can rule out the equation hTwo == hNat -- (or vice versa) because it knows the constructors of datatypes differ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- But back to our typechecker. To make things easier, we'll assume -- that our supplier has already been kind enough to do *scope* checking, -- so that all the variables written by the programmer have been looked -- up and turned into typed references. -- a reference: a pair of a type and a variable of that type. Ref : Context -> Set Ref G = Sg HType (Var G) -- making a reference ref : forall {G S} -> Var G S -> Ref G ref {G}{S} v = S , v -- ??? At last, your bit! Show that the following view type covers all -- untyped terms: -- either things go well and get the 'ok' and a well typed term -- or something went wrong down in the expression tree somewhere, -- so we can explain where that is. data Checkable (G : Context) -- the context of typed variables in scope (T : HType) -- the type we expect : HExp (Ref G) -- the untyped term we hope has type T -> Set where -- one of two situations applies -- either ok : (t : THExp (Var G) T) -- we have a term of type T -> Checkable G T (termFog ref t) -- and it's what we're checking -- or err : (t's : List (HExp' (Ref G))) -- there's some surroundings (s : HExp (Ref G)) -- and a subterm of interest -> Checkable G T (rootToHole t's s) -- in what we're checking check : (G : Context)(T : HType)(h : HExp (Ref G)) -> Checkable G T h check G T h = {!!} -- Now, this isn't quite the whole story, but it's pretty good. We've -- guaranteed that -- * if we say yes, it's because we've found the typed version -- of the untyped input -- * if we say no, we can point to a place where (we say that) there's a -- problem -- So we're *sound* (we never say yes to bad things), but not necessarily -- *complete* (we can say no to good things). Nothing stops us reporting a -- bogus type error at the subterm of our choosing! We could work harder -- and define, in the same way as the typed terms, the "terrors", being -- the terms containing at least one type error. The canny way to do that -- is to try writing the typechecker, then grow the datatype that describes -- all the failure cases. ------------------------------------------------------------------------------ -- -- If you want to read around this topic, you may be interested in -- -- The Zipper -- Gerard Huet -- Journal of Functional Programming, 1997. -- -- Monadic presentations of lambda terms using generalized inductive types -- Thorsten Altenkirch and Bernhard Reus -- Computer Science Logic, 1999. -- -- An exercise in dependent types: A well-typed interpreter -- Lennart Augustsson and Magnus Carlsson -- Workshop on Dependent Types in Programming, Gothenburg, 1999. -- -- The view from the left -- Conor McBride and James McKinna -- Journal of Functional Programming, 2004.
{ "alphanum_fraction": 0.5561792747, "avg_line_length": 41.3370165746, "ext": "agda", "hexsha": "3606fd92fe49378abd16c062c2d35651572e58bc", "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": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_path": "Ex3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_path": "Ex3.agda", "max_line_length": 198, "max_stars_count": null, "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_path": "Ex3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6453, "size": 22446 }
module bool-test where open import bool open import eq open import level ~~tt : ~ ~ tt ≡ tt ~~tt = refl ~~ff : ~ ~ ff ≡ ff ~~ff = refl ~~-elim2 : ∀ (b : 𝔹) → ~ ~ b ≡ b ~~-elim2 tt = ~~tt ~~-elim2 ff = ~~ff ~~tt' : ~ ~ tt ≡ tt ~~tt' = refl{lzero}{𝔹}{tt} ~~ff' : ~ ~ ff ≡ ff ~~ff' = refl{lzero}{𝔹}{ff} test1 : 𝔹 test1 = tt && ff test2 : 𝔹 test2 = tt && tt test1-ff : test1 ≡ ff test1-ff = refl test2-tt : test2 ≡ tt test2-tt = refl
{ "alphanum_fraction": 0.525, "avg_line_length": 12.9411764706, "ext": "agda", "hexsha": "cccb315ebad54a56a9a7f841b23e92d477522578", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "bool-test.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "bool-test.agda", "max_line_length": 32, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "bool-test.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 200, "size": 440 }
import Level as L open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Product open import Data.Empty open import Data.Nat open import Data.Nat.Properties open import RevMachine module PartialRevNoRepeat {ℓ} (M : PartialRevMachine {ℓ}) where infix 99 _ᵣₑᵥ infixr 10 _∷_ infixr 10 _++↦_ open RevMachine.PartialRevMachine M is-stuck : State → Set _ is-stuck st = ∄[ st' ] (st ↦ st') is-initial : State → Set _ is-initial st = ∄[ st' ] (st' ↦ st) data _↦ᵣₑᵥ_ : State → State → Set (L.suc ℓ) where _ᵣₑᵥ : ∀ {st₁ st₂} → st₁ ↦ st₂ → st₂ ↦ᵣₑᵥ st₁ data _↦*_ : State → State → Set (L.suc ℓ) where ◾ : {st : State} → st ↦* st _∷_ : {st₁ st₂ st₃ : State} → st₁ ↦ st₂ → st₂ ↦* st₃ → st₁ ↦* st₃ _++↦_ : {st₁ st₂ st₃ : State} → st₁ ↦* st₂ → st₂ ↦* st₃ → st₁ ↦* st₃ ◾ ++↦ st₁↦*st₂ = st₁↦*st₂ (st₁↦st₁' ∷ st₁'↦*st₂) ++↦ st₂'↦*st₃ = st₁↦st₁' ∷ (st₁'↦*st₂ ++↦ st₂'↦*st₃) len↦ : ∀ {st st'} → st ↦* st' → ℕ len↦ ◾ = 0 len↦ (_ ∷ r) = 1 + len↦ r data _↦ᵣₑᵥ*_ : State → State → Set (L.suc ℓ) where ◾ : ∀ {st} → st ↦ᵣₑᵥ* st _∷_ : ∀ {st₁ st₂ st₃} → st₁ ↦ᵣₑᵥ st₂ → st₂ ↦ᵣₑᵥ* st₃ → st₁ ↦ᵣₑᵥ* st₃ _++↦ᵣₑᵥ_ : ∀ {st₁ st₂ st₃} → st₁ ↦ᵣₑᵥ* st₂ → st₂ ↦ᵣₑᵥ* st₃ → st₁ ↦ᵣₑᵥ* st₃ ◾ ++↦ᵣₑᵥ st₁↦ᵣₑᵥ*st₂ = st₁↦ᵣₑᵥ*st₂ (st₁↦ᵣₑᵥst₁' ∷ st₁'↦ᵣₑᵥ*st₂) ++↦ᵣₑᵥ st₂'↦ᵣₑᵥ*st₃ = st₁↦ᵣₑᵥst₁' ∷ (st₁'↦ᵣₑᵥ*st₂ ++↦ᵣₑᵥ st₂'↦ᵣₑᵥ*st₃) Rev↦ : ∀ {st₁ st₂} → st₁ ↦* st₂ → st₂ ↦ᵣₑᵥ* st₁ Rev↦ ◾ = ◾ Rev↦ (r ∷ rs) = Rev↦ rs ++↦ᵣₑᵥ ((r ᵣₑᵥ) ∷ ◾) Rev↦ᵣₑᵥ : ∀ {st₁ st₂} → st₁ ↦ᵣₑᵥ* st₂ → st₂ ↦* st₁ Rev↦ᵣₑᵥ ◾ = ◾ Rev↦ᵣₑᵥ ((r ᵣₑᵥ) ∷ rs) = Rev↦ᵣₑᵥ rs ++↦ (r ∷ ◾) deterministic* : ∀ {st st₁ st₂} → st ↦* st₁ → st ↦* st₂ → is-stuck st₁ → is-stuck st₂ → st₁ ≡ st₂ deterministic* ◾ ◾ stuck₁ stuck₂ = refl deterministic* ◾ (r ∷ ↦*₂) stuck₁ stuck₂ = ⊥-elim (stuck₁ (_ , r)) deterministic* (r ∷ ↦*₁) ◾ stuck₁ stuck₂ = ⊥-elim (stuck₂ (_ , r)) deterministic* (r₁ ∷ ↦*₁) (r₂ ∷ ↦*₂) stuck₁ stuck₂ with deterministic r₁ r₂ ... | refl = deterministic* ↦*₁ ↦*₂ stuck₁ stuck₂ deterministic*' : ∀ {st st₁ st'} → (rs₁ : st ↦* st₁) → (rs : st ↦* st') → is-stuck st' → Σ[ rs' ∈ st₁ ↦* st' ] (len↦ rs ≡ len↦ rs₁ + len↦ rs') deterministic*' ◾ rs stuck = rs , refl deterministic*' (r ∷ rs₁) ◾ stuck = ⊥-elim (stuck (_ , r)) deterministic*' (r ∷ rs₁) (r' ∷ rs) stuck with deterministic r r' ... | refl with deterministic*' rs₁ rs stuck ... | (rs' , eq) = rs' , cong suc eq deterministicᵣₑᵥ* : ∀ {st st₁ st₂} → st ↦ᵣₑᵥ* st₁ → st ↦ᵣₑᵥ* st₂ → ¬ (is-fail st) → is-initial st₁ → is-initial st₂ → st₁ ≡ st₂ deterministicᵣₑᵥ* ◾ ◾ _ initial₁ initial₂ = refl deterministicᵣₑᵥ* ◾ (r ᵣₑᵥ ∷ ↦ᵣₑᵥ*₂) _ initial₁ initial₂ = ⊥-elim (initial₁ (_ , r)) deterministicᵣₑᵥ* (r ᵣₑᵥ ∷ ↦ᵣₑᵥ*₁) ◾ _ initial₁ initial₂ = ⊥-elim (initial₂ (_ , r)) deterministicᵣₑᵥ* (_∷_ {_} {st'} {_} (r₁ ᵣₑᵥ) ↦ᵣₑᵥ*₁) (r₂ ᵣₑᵥ ∷ ↦ᵣₑᵥ*₂) nf initial₁ initial₂ with is-fail? st' ... | yes st'-f = ⊥-elim (fail-is-stuck st'-f (_ , r₁)) ... | no st'-nf with deterministicᵣₑᵥ r₁ r₂ nf ... | refl = deterministicᵣₑᵥ* ↦ᵣₑᵥ*₁ ↦ᵣₑᵥ*₂ st'-nf initial₁ initial₂ data _↦[_]_ : State → ℕ → State → Set (L.suc ℓ) where ◾ : ∀ {st} → st ↦[ 0 ] st _∷_ : ∀ {st₁ st₂ st₃ n} → st₁ ↦ st₂ → st₂ ↦[ n ] st₃ → st₁ ↦[ suc n ] st₃ _++↦ⁿ_ : ∀ {st₁ st₂ st₃ n m} → st₁ ↦[ n ] st₂ → st₂ ↦[ m ] st₃ → st₁ ↦[ n + m ] st₃ ◾ ++↦ⁿ st₁↦*st₂ = st₁↦*st₂ (st₁↦st₁' ∷ st₁'↦*st₂) ++↦ⁿ st₂'↦*st₃ = st₁↦st₁' ∷ (st₁'↦*st₂ ++↦ⁿ st₂'↦*st₃) data _↦ᵣₑᵥ[_]_ : State → ℕ → State → Set (L.suc ℓ) where ◾ : ∀ {st} → st ↦ᵣₑᵥ[ 0 ] st _∷_ : ∀ {st₁ st₂ st₃ n} → st₁ ↦ᵣₑᵥ st₂ → st₂ ↦ᵣₑᵥ[ n ] st₃ → st₁ ↦ᵣₑᵥ[ suc n ] st₃ _++↦ᵣₑᵥⁿ_ : ∀ {st₁ st₂ st₃ n m} → st₁ ↦ᵣₑᵥ[ n ] st₂ → st₂ ↦ᵣₑᵥ[ m ] st₃ → st₁ ↦ᵣₑᵥ[ n + m ] st₃ ◾ ++↦ᵣₑᵥⁿ st₁↦*st₂ = st₁↦*st₂ (st₁↦st₁' ∷ st₁'↦*st₂) ++↦ᵣₑᵥⁿ st₂'↦*st₃ = st₁↦st₁' ∷ (st₁'↦*st₂ ++↦ᵣₑᵥⁿ st₂'↦*st₃) deterministicⁿ : ∀ {st st₁ st₂ n} → st ↦[ n ] st₁ → st ↦[ n ] st₂ → st₁ ≡ st₂ deterministicⁿ ◾ ◾ = refl deterministicⁿ (r₁ ∷ rs₁) (r₂ ∷ rs₂) with deterministic r₁ r₂ ... | refl = deterministicⁿ rs₁ rs₂ deterministicᵣₑᵥⁿ : ∀ {st st₁ st₂ n} → st ↦ᵣₑᵥ[ n ] st₁ → st ↦ᵣₑᵥ[ n ] st₂ → ¬ (is-fail st) → st₁ ≡ st₂ deterministicᵣₑᵥⁿ ◾ ◾ _ = refl deterministicᵣₑᵥⁿ (_∷_ {_} {st'} {_} (r₁ ᵣₑᵥ) rs₁) (r₂ ᵣₑᵥ ∷ rs₂) nf with is-fail? st' ... | yes st'-f = ⊥-elim (fail-is-stuck st'-f (_ , r₁)) ... | no st'-nf with deterministicᵣₑᵥ r₁ r₂ nf ... | refl = deterministicᵣₑᵥⁿ rs₁ rs₂ st'-nf private split↦ⁿ : ∀ {st st'' n m} → st ↦[ n + m ] st'' → ∃[ st' ] (st ↦[ n ] st' × st' ↦[ m ] st'') split↦ⁿ {n = 0} {m} rs = _ , ◾ , rs split↦ⁿ {n = suc n} {m} (r ∷ rs) with split↦ⁿ {n = n} {m} rs ... | st' , st↦ⁿst' , st'↦ᵐst'' = st' , (r ∷ st↦ⁿst') , st'↦ᵐst'' split↦ᵣₑᵥⁿ : ∀ {st st'' n m} → st ↦ᵣₑᵥ[ n + m ] st'' → ∃[ st' ] (st ↦ᵣₑᵥ[ n ] st' × st' ↦ᵣₑᵥ[ m ] st'') split↦ᵣₑᵥⁿ {n = 0} {m} rs = _ , ◾ , rs split↦ᵣₑᵥⁿ {n = suc n} {m} (r ∷ rs) with split↦ᵣₑᵥⁿ {n = n} {m} rs ... | st' , st↦ⁿst' , st'↦ᵐst'' = st' , (r ∷ st↦ⁿst') , st'↦ᵐst'' diff : ∀ {n m} → n < m → ∃[ k ] (0 < k × n + k ≡ m) diff {0} {(suc m)} (s≤s z≤n) = suc m , s≤s z≤n , refl diff {(suc n)} {(suc (suc m))} (s≤s (s≤s n≤m)) with diff {n} {suc m} (s≤s n≤m) ... | k , 0<k , eq = k , 0<k , cong suc eq Revⁿ : ∀ {st st' n} → st ↦[ n ] st' → st' ↦ᵣₑᵥ[ n ] st Revⁿ {n = 0} ◾ = ◾ Revⁿ {n = suc n} (r ∷ rs) rewrite +-comm 1 n = Revⁿ rs ++↦ᵣₑᵥⁿ (r ᵣₑᵥ ∷ ◾) NoRepeat : ∀ {st₀ stₙ stₘ n m} → is-initial st₀ → n < m → st₀ ↦[ n ] stₙ → st₀ ↦[ m ] stₘ → stₙ ≢ stₘ NoRepeat {stₙ = st} {_} {m} st₀-is-init n<m st₀↦ᵐst st₀↦ᵐ⁺ᵏ⁺¹st refl with diff n<m ... | suc k , 0<k , refl with is-fail? st ... | yes st-is-f with split↦ⁿ {n = m} {1 + k} st₀↦ᵐ⁺ᵏ⁺¹st ... | st′ , st₀↦ᵐst′ , (r ∷ rs) with deterministicⁿ st₀↦ᵐst st₀↦ᵐst′ ... | refl = ⊥-elim (fail-is-stuck st-is-f (_ , r)) NoRepeat {stₙ = st} {_} {m} st₀-is-init n<m st₀↦ᵐst st₀↦ᵐ⁺ᵏ⁺¹st refl | suc k , 0<k , refl | no st-is-nf with (Revⁿ st₀↦ᵐst , Revⁿ st₀↦ᵐ⁺ᵏ⁺¹st) ... | st'↦ᵐst₀' , st'↦ᵐ⁺ᵏ⁺¹st₀' with split↦ᵣₑᵥⁿ st'↦ᵐ⁺ᵏ⁺¹st₀' ... | st′ , st'↦ᵐst′ , st′↦ᵏ⁺¹st₀' with deterministicᵣₑᵥⁿ st'↦ᵐst₀' st'↦ᵐst′ st-is-nf ... | refl with st′↦ᵏ⁺¹st₀' ... | r ᵣₑᵥ ∷ rs = ⊥-elim (st₀-is-init (_ , r))
{ "alphanum_fraction": 0.5135928329, "avg_line_length": 42.3137254902, "ext": "agda", "hexsha": "709301eaa1b5d8352d9b7a6b998b8c9e467ecd4a", "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": "PartialRevNoRepeat.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": "PartialRevNoRepeat.agda", "max_line_length": 144, "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": "PartialRevNoRepeat.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": 3850, "size": 6474 }
module lob--2015-06-14--III where data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} record Σ {X : Set} (F : X → Set) : Set where constructor _,_ field fst : X snd : F fst data ⊤ : Set where unit : ⊤ data Tree (X : Set) : Set where br : Tree X → Tree X → Tree X leaf : X → Tree X indtree : {X : Set} → (P : Tree X → Set) → ((s t : Tree X) → P s → P t → P (br s t)) → ((x : X) → P (leaf x)) → (t : Tree X) → P t indtree P b l (br s t) = b s t (indtree P b l s) (indtree P b l t) indtree P b l (leaf x) = l x data Preterm : Set where type : ℕ → Preterm pi : Preterm → Preterm → Preterm sig : Preterm → Preterm → Preterm bot : Preterm top : Preterm unit : Preterm var : ℕ → Preterm lam : Preterm → Preterm → Preterm app : Preterm → Preterm → Preterm tree : Preterm → Preterm br : Preterm → Preterm → Preterm → Preterm leaf : Preterm → Preterm → Preterm ind : Preterm → Preterm → Preterm → Preterm → Preterm → Preterm ‘λ→’ = lam data _::_ : Preterm → Preterm → Set where ::type : (ℓ : ℕ) → type ℓ :: type (suc ℓ) -- ... □ : Preterm → Set □ T = Σ \(t : Preterm) → t :: T num : ℕ → Preterm num 0 = leaf top unit num (suc n) = br top unit (num n) data List (X : Set) : Set where nil : List X _,_ : X → List X → List X infixr 1 _,_ list : List Preterm → Preterm list nil = leaf top unit list (x , xs) = br top x (list xs) cons : ℕ → List Preterm → Preterm cons n xs = br top (num n) (list xs) ‘type’ : Preterm → Preterm ‘type’ n = cons 0 (n , nil) ‘pi’ : Preterm → Preterm → Preterm ‘pi’ x f = cons 1 (x , f , nil) ‘sig’ : Preterm → Preterm → Preterm ‘sig’ x f = cons 2 (x , f , nil) ‘bot’ : Preterm ‘bot’ = cons 3 nil ‘top’ : Preterm ‘top’ = cons 4 nil ‘unit’ : Preterm ‘unit’ = cons 5 nil ‘var’ : Preterm → Preterm ‘var’ n = cons 6 (n , nil) ‘lam’ : Preterm → Preterm → Preterm ‘lam’ t b = cons 7 (t , b , nil) ‘app’ : Preterm → Preterm → Preterm ‘app’ f x = cons 8 (f , x , nil) ‘tree’ : Preterm → Preterm ‘tree’ x = cons 9 (x , nil) ‘br’ : Preterm → Preterm → Preterm → Preterm ‘br’ x l r = cons 10 (x , l , r , nil) ‘leaf’ : Preterm → Preterm → Preterm ‘leaf’ x y = cons 11 (x , y , nil) ‘ind’ : Preterm → Preterm → Preterm → Preterm → Preterm → Preterm ‘ind’ x p b l t = cons 12 (x , p , b , l , t , nil) ‘Preterm’ : Preterm ‘Preterm’ = tree top ‘Preterm’::type₀ : ‘Preterm’ :: type 0 ‘Preterm’::type₀ = {!!} ‘□’ : Preterm ‘□’ = {!!} _‘→’_ : Preterm → Preterm → Preterm A ‘→’ B = pi A {!!} quot : Preterm → Preterm quot (type n) = ‘type’ (num n) quot (pi x f) = ‘pi’ (quot x) (quot f) quot (sig x f) = ‘sig’ (quot x) (quot f) quot bot = ‘bot’ quot top = ‘top’ quot unit = ‘unit’ quot (var n) = ‘var’ (num n) quot (lam x b) = ‘lam’ (quot x) (quot b) quot (app f x) = ‘app’ (quot f) (quot x) quot (tree x) = ‘tree’ (quot x) quot (br x l r) = ‘br’ (quot x) (quot l) (quot r) quot (leaf x y) = ‘leaf’ (quot x) (quot y) quot (ind x p b l t) = ‘ind’ (quot x) (quot p) (quot b) (quot l) (quot t) ‘quot’ : Preterm ‘quot’ = {!!} ‘‘→’’ : Preterm ‘‘→’’ = {!!} ⌜_⌝ = quot _‘’_ = app infixl 1 _‘’_ postulate X : Set ‘X’ : Preterm ‘X’::type₀ : ‘X’ :: type 0 App : {‘A’ ‘B’ : Preterm} → □ (‘A’ ‘→’ ‘B’) → □ ‘A’ → □ ‘B’ App □‘A→B’ □‘A’ = {!!} ‘App’ : Preterm ‘App’ = {!!} Quot : {‘T’ : Preterm} → □ ‘T’ → □ (‘□’ ‘’ ⌜ ‘T’ ⌝) Quot □T = {!!} ‘Quot’ : Preterm ‘Quot’ = {!!} ‘L₀’ : Preterm ‘L₀’ = (‘λ→’ ‘Preterm’ ((‘app’ ⌜ ‘□’ ⌝ (‘app’ (var 0) (‘quot’ ‘’ (var 0)))) ‘’ ‘‘→’’ ‘’ ⌜ ‘X’ ⌝ )) L : Preterm L = (λ (h : Preterm) → (app ‘□’ (app h (⌜ h ⌝))) ‘→’ ‘X’) ‘L₀’ ‘L’ = app ‘L₀’ ⌜ ‘L₀’ ⌝ Conv : □ (‘□’ ‘’ ⌜ L ⌝) → □ (‘□’ ‘’ ‘L’) Conv = {!!} ‘Conv’ : Preterm ‘Conv’ = {!!} postulate f : □ ‘X’ → X ‘f’ : Preterm d‘f’ : ‘f’ :: (app ‘□’ (quot ‘X’) ‘→’ ‘X’) y : X y = (λ (ℓ : □ L) → f (App ℓ (Conv (Quot ℓ)))) ( ‘λ→’ (‘□’ ‘’ ‘L’) (‘f’ ‘’ (‘App’ ‘’ (var 0) ‘’ (‘Conv’ ‘’ (‘Quot’ ‘’ var 0)))) , {!!})
{ "alphanum_fraction": 0.5013739695, "avg_line_length": 19.8168316832, "ext": "agda", "hexsha": "10691735209a294f0ff0ea081f6a8f2d2029a562", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/lob--2015-06-14--III.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/lob--2015-06-14--III.agda", "max_line_length": 98, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/lob--2015-06-14--III.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 1756, "size": 4003 }
-- A solution for -- https://github.com/josevalim/nested-data-structure-traversal -- in Agda using fold. Basically it is identical to its Haskell sibling except -- fancy unicode symbols. The `refl` proof at the end is pretty nice though. -- -- Coded against agda-2.6.1.3 and agda-stdlib-1.5 module Fold where open import Data.Nat using (ℕ; _+_) open import Data.Bool using (Bool; true; false; if_then_else_) open import Data.String using (String) open import Data.List using (List; []; _∷_; map; foldl; reverse; length; zipWith; upTo) open import Data.Product using (_×_; _,_; proj₂) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) record Lesson : Set where constructor lesson field name : String record Chapter : Set where constructor chapter field title : String reset : Bool lessons : List Lesson record PosLesson : Set where constructor pos_lesson field name : String pos : ℕ record PosChapter : Set where constructor pos_chapter field title : String reset : Bool pos : ℕ lessons : List PosLesson input : List Chapter input = chapter "Getting started" false (lesson "Welcome" ∷ lesson "Installation" ∷ []) ∷ chapter "Basic operator" false (lesson "Addition / Subtraction" ∷ lesson "Multiplication / Division" ∷ []) ∷ chapter "Advanced topics" true (lesson "Mutability" ∷ lesson "Immutability" ∷ []) ∷ [] expected : List PosChapter expected = pos_chapter "Getting started" false 1 (pos_lesson "Welcome" 1 ∷ pos_lesson "Installation" 2 ∷ []) ∷ pos_chapter "Basic operator" false 2 (pos_lesson "Addition / Subtraction" 3 ∷ pos_lesson "Multiplication / Division" 4 ∷ []) ∷ pos_chapter "Advanced topics" true 3 (pos_lesson "Mutability" 1 ∷ pos_lesson "Immutability" 2 ∷ []) ∷ [] solve : List Chapter → List PosChapter solve i = (reverse ∘ proj₂ ∘ proj₂) (foldl go (1 , 1 , []) i) where go : ℕ × ℕ × List PosChapter → Chapter → ℕ × ℕ × List PosChapter go (nc , nl , acc) (chapter title reset lessons) = let n = length lessons nl' = if reset then 1 else nl ps = map (_+ nl') (upTo n) plessons = zipWith (λ {(lesson name) p → pos_lesson name p}) lessons ps in (nc + 1 , nl' + n , pos_chapter title reset nc plessons ∷ acc) _ : solve input ≡ expected _ = refl
{ "alphanum_fraction": 0.6336241079, "avg_line_length": 32.7532467532, "ext": "agda", "hexsha": "aef1f9d083a31eaff1820f96f4288b2499402035", "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": "1fe511f7ef550aed998b75c18a432abf6ab41c5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "eengineergz/Lambda", "max_forks_repo_path": "2-resources/__DATA-Structures/ds-traversal-multi-lang/agda/Fold.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1fe511f7ef550aed998b75c18a432abf6ab41c5f", "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": "eengineergz/Lambda", "max_issues_repo_path": "2-resources/__DATA-Structures/ds-traversal-multi-lang/agda/Fold.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "1fe511f7ef550aed998b75c18a432abf6ab41c5f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "eengineergz/Lambda", "max_stars_repo_path": "2-resources/__DATA-Structures/ds-traversal-multi-lang/agda/Fold.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 692, "size": 2522 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Irrelevance {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Irrelevance for propositionally equal types irrelevance′ : ∀ {A A′ Γ l} → A PE.≡ A′ → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩ A′ irrelevance′ PE.refl [A] = [A] -- Irrelevance for propositionally equal types and contexts irrelevanceΓ′ : ∀ {l A A′ Γ Γ′} → Γ PE.≡ Γ′ → A PE.≡ A′ → Γ ⊩⟨ l ⟩ A → Γ′ ⊩⟨ l ⟩ A′ irrelevanceΓ′ PE.refl PE.refl [A] = [A] mutual -- Irrelevance for type equality irrelevanceEq : ∀ {Γ A B l l′} (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / p → Γ ⊩⟨ l′ ⟩ A ≡ B / q irrelevanceEq p q A≡B = irrelevanceEqT (goodCasesRefl p q) A≡B -- Irrelevance for type equality with propositionally equal first types irrelevanceEq′ : ∀ {Γ A A′ B l l′} (eq : A PE.≡ A′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ A ≡ B / p → Γ ⊩⟨ l′ ⟩ A′ ≡ B / q irrelevanceEq′ PE.refl p q A≡B = irrelevanceEq p q A≡B -- Irrelevance for type equality with propositionally equal types irrelevanceEq″ : ∀ {Γ A A′ B B′ l l′} (eqA : A PE.≡ A′) (eqB : B PE.≡ B′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ A ≡ B / p → Γ ⊩⟨ l′ ⟩ A′ ≡ B′ / q irrelevanceEq″ PE.refl PE.refl p q A≡B = irrelevanceEq p q A≡B -- Irrelevance for type equality with propositionally equal second types irrelevanceEqR′ : ∀ {Γ A B B′ l} (eqB : B PE.≡ B′) (p : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / p → Γ ⊩⟨ l ⟩ A ≡ B′ / p irrelevanceEqR′ PE.refl p A≡B = A≡B -- Irrelevance for type equality with propositionally equal types and -- a lifting of propositionally equal types irrelevanceEqLift″ : ∀ {Γ A A′ B B′ C C′ l l′} (eqA : A PE.≡ A′) (eqB : B PE.≡ B′) (eqC : C PE.≡ C′) (p : Γ ∙ C ⊩⟨ l ⟩ A) (q : Γ ∙ C′ ⊩⟨ l′ ⟩ A′) → Γ ∙ C ⊩⟨ l ⟩ A ≡ B / p → Γ ∙ C′ ⊩⟨ l′ ⟩ A′ ≡ B′ / q irrelevanceEqLift″ PE.refl PE.refl PE.refl p q A≡B = irrelevanceEq p q A≡B -- Helper for irrelevance of type equality using shape view irrelevanceEqT : ∀ {Γ A B l l′} {p : Γ ⊩⟨ l ⟩ A} {q : Γ ⊩⟨ l′ ⟩ A} → ShapeView Γ l l′ A A p q → Γ ⊩⟨ l ⟩ A ≡ B / p → Γ ⊩⟨ l′ ⟩ A ≡ B / q irrelevanceEqT (ℕᵥ ℕA ℕB) (ιx (ℕ₌ x)) = ιx (ℕ₌ x) irrelevanceEqT (ne (ne K D neK _) (ne K₁ D₁ neK₁ K≡K₁)) (ιx (ne₌ M D′ neM K≡M)) rewrite whrDet* (red D , ne neK) (red D₁ , ne neK₁) = ιx (ne₌ M D′ neM K≡M) irrelevanceEqT {Γ} (Πᵥ (Πᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , G≡G₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ in Π₌ F′ G′ D′ (PE.subst (λ x → Γ ⊢ x ≅ Π F′ ▹ G′) ΠFG≡ΠF₁G₁ A≡B) (λ {ρ} [ρ] ⊢Δ → irrelevanceEq′ (PE.cong (wk ρ) F≡F₁) ([F] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) ([F≡F′] [ρ] ⊢Δ)) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceEq′ (PE.cong (λ y → wk (lift ρ) y [ _ ]) G≡G₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([G≡G′] [ρ] ⊢Δ [a])) irrelevanceEqT (Uᵥ _ _ _ _ _ _) (U₌ B≡U) = U₌ B≡U irrelevanceEqT (emb⁰¹ PE.refl x) (ιx A≡B) = irrelevanceEqT x A≡B irrelevanceEqT {Γ} {A} {B} {l} {.¹} (emb¹⁰ PE.refl x) A≡B = ιx (irrelevanceEqT x A≡B) -- -------------------------------------------------------------------------------- -- Irrelevance for terms irrelevanceTerm : ∀ {Γ A t l l′} (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / p → Γ ⊩⟨ l′ ⟩ t ∷ A / q irrelevanceTerm p q t = irrelevanceTermT (goodCasesRefl p q) t -- Irrelevance for terms with propositionally equal types irrelevanceTerm′ : ∀ {Γ A A′ t l l′} (eq : A PE.≡ A′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ t ∷ A / p → Γ ⊩⟨ l′ ⟩ t ∷ A′ / q irrelevanceTerm′ PE.refl p q t = irrelevanceTerm p q t -- Irrelevance for terms with propositionally equal types and terms irrelevanceTerm″ : ∀ {Γ A A′ t t′ l l′} (eqA : A PE.≡ A′) (eqt : t PE.≡ t′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ t ∷ A / p → Γ ⊩⟨ l′ ⟩ t′ ∷ A′ / q irrelevanceTerm″ PE.refl PE.refl p q t = irrelevanceTerm p q t -- Irrelevance for terms with propositionally equal types, terms and contexts irrelevanceTermΓ″ : ∀ {l l′ A A′ t t′ Γ Γ′} → Γ PE.≡ Γ′ → A PE.≡ A′ → t PE.≡ t′ → ([A] : Γ ⊩⟨ l ⟩ A) ([A′] : Γ′ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Γ′ ⊩⟨ l′ ⟩ t′ ∷ A′ / [A′] irrelevanceTermΓ″ PE.refl PE.refl PE.refl [A] [A′] [t] = irrelevanceTerm [A] [A′] [t] -- Helper for irrelevance of terms using shape view irrelevanceTermT : ∀ {Γ A t l l′} {p : Γ ⊩⟨ l ⟩ A} {q : Γ ⊩⟨ l′ ⟩ A} → ShapeView Γ l l′ A A p q → Γ ⊩⟨ l ⟩ t ∷ A / p → Γ ⊩⟨ l′ ⟩ t ∷ A / q irrelevanceTermT (ℕᵥ D D′) (ιx (ℕₜ n d n≡n prop)) = ιx (ℕₜ n d n≡n prop) irrelevanceTermT (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (ιx (neₜ k d nf)) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceTermT (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (ιx (neₜ k d nf)) | PE.refl = ιx (neₜ k d nf) irrelevanceTermT {Γ} {t = t} (Πᵥ (Πᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) (Πₜ f d funcF f≡f [f] [f]₁) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , G≡G₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ in Πₜ f (PE.subst (λ x → Γ ⊢ t :⇒*: f ∷ x) ΠFG≡ΠF₁G₁ d) funcF (PE.subst (λ x → Γ ⊢ f ≅ f ∷ x) ΠFG≡ΠF₁G₁ f≡f) (λ {ρ} [ρ] ⊢Δ [a]₁ [b]₁ [a≡b]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ [b] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [b]₁ [a≡b] = irrelevanceEqTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a≡b]₁ in irrelevanceEqTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f] [ρ] ⊢Δ [a] [b] [a≡b])) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f]₁ [ρ] ⊢Δ [a])) irrelevanceTermT (Uᵥ .⁰ 0<1 ⊢Γ .⁰ 0<1 _) t = t irrelevanceTermT (emb⁰¹ PE.refl x) (ιx t) = irrelevanceTermT x t irrelevanceTermT (emb¹⁰ PE.refl x) t = ιx (irrelevanceTermT x t) -- -------------------------------------------------------------------------------- -- Irrelevance for term equality irrelevanceEqTerm : ∀ {Γ A t u l l′} (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A / q irrelevanceEqTerm p q t≡u = irrelevanceEqTermT (goodCasesRefl p q) t≡u -- Irrelevance for term equality with propositionally equal types irrelevanceEqTerm′ : ∀ {Γ A A′ t u l l′} (eq : A PE.≡ A′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A′ / q irrelevanceEqTerm′ PE.refl p q t≡u = irrelevanceEqTerm p q t≡u -- Irrelevance for term equality with propositionally equal types and terms irrelevanceEqTerm″ : ∀ {Γ A A′ t t′ u u′ l l′} (eqt : t PE.≡ t′) (equ : u PE.≡ u′) (eqA : A PE.≡ A′) (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ A′) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / p → Γ ⊩⟨ l′ ⟩ t′ ≡ u′ ∷ A′ / q irrelevanceEqTerm″ PE.refl PE.refl PE.refl p q t≡u = irrelevanceEqTerm p q t≡u -- Helper for irrelevance of term equality using shape view irrelevanceEqTermT : ∀ {Γ A t u} {l l′} {p : Γ ⊩⟨ l ⟩ A} {q : Γ ⊩⟨ l′ ⟩ A} → ShapeView Γ l l′ A A p q → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A / q irrelevanceEqTermT (ℕᵥ D D′) (ιx (ℕₜ₌ k k′ d d′ k≡k′ prop)) = ιx (ℕₜ₌ k k′ d d′ k≡k′ prop) irrelevanceEqTermT (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (ιx (neₜ₌ k m d d′ nf)) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceEqTermT (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (ιx (neₜ₌ k m d d′ nf)) | PE.refl = ιx (neₜ₌ k m d d′ nf) irrelevanceEqTermT {Γ} {t = t} {u = u} (Πᵥ (Πᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , G≡G₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ [A] = Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [A]₁ = Πᵣ′ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁ in Πₜ₌ f g (PE.subst (λ x → Γ ⊢ t :⇒*: f ∷ x) ΠFG≡ΠF₁G₁ d) (PE.subst (λ x → Γ ⊢ u :⇒*: g ∷ x) ΠFG≡ΠF₁G₁ d′) funcF funcG (PE.subst (λ x → Γ ⊢ f ≅ g ∷ x) ΠFG≡ΠF₁G₁ f≡g) (irrelevanceTerm [A] [A]₁ [f]) (irrelevanceTerm [A] [A]₁ [g]) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceEqTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f≡g] [ρ] ⊢Δ [a])) irrelevanceEqTermT (Uᵥ .⁰ 0<1 ⊢Γ .⁰ 0<1 ⊢Γ₁) t≡u = t≡u irrelevanceEqTermT (emb⁰¹ PE.refl x) (ιx t≡u) = irrelevanceEqTermT x t≡u irrelevanceEqTermT (emb¹⁰ PE.refl x) t≡u = ιx (irrelevanceEqTermT x t≡u)
{ "alphanum_fraction": 0.4441239416, "avg_line_length": 52.4243902439, "ext": "agda", "hexsha": "8c1ba36d3a1458f855b80d6c7f86ab0ce250a8c9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Irrelevance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Irrelevance.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Irrelevance.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4887, "size": 10747 }
{-# OPTIONS --copatterns #-} {-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS --show-implicit #-} -- One-place functors (decorations) on Set module Control.Decoration where open import Data.Product using (_×_; _,_; proj₁; proj₂; uncurry) open import Function using (id; _∘_; const) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Axiom.FunctionExtensionality open import Control.Functor hiding (Id; Const) renaming (idIsFunctor to Id; compIsFunctor to _·_; constIsFunctor to Const) open import Control.Functor.NaturalTransformation using (IsNatTrans; KKNat) open import Control.Comonad open IsFunctor record IsDecoration (D : Set → Set) : Set₁ where field traverse : ∀ {F} (F! : IsFunctor F) {A B} → (A → F B) → D A → F (D B) -- The free theorem for traverse: -- A natural transformation after a traversal can be combined with the traversal. traverse-free : ∀ {F} (F! : IsFunctor F) {G} (G! : IsFunctor G) → ∀ (η : ∀ {A} → F A → G A) (η! : IsNatTrans (functor F F!) (functor G G!) η) → ∀ {A B} (f : A → F B) → η ∘ traverse F! f ≡ traverse G! (η ∘ f) -- Identity traversal. traverse-id : ∀ {A} → traverse Id {A = A} id ≡ id -- Distributing a traversal. traverse-∘ : ∀ {F G} (F! : IsFunctor F) (G! : IsFunctor G) → ∀ {A B C} {f : A → F B} {g : B → G C} → traverse (F! · G!) ((map F! g) ∘ f) ≡ map F! (traverse G! g) ∘ traverse F! f isFunctor : IsFunctor D isFunctor = record { ops = record { map = traverse Id } ; laws = record { map-id = traverse-id ; map-∘ = traverse-∘ Id Id } } open IsFunctor isFunctor using () renaming (map to dmap; map-∘ to dmap-∘) -- Lens operations. private gets : ∀ {A B} → (A → B) → D A → B gets {B = B} = traverse (Const B) {B = B} get : ∀ {A} → D A → A get = gets id modify : ∀ {A B} → (A → B) → D A → D B modify = dmap set : ∀ {A B} → B → D A → D B set b = dmap (const b) -- Comonad structure. isComonad : IsComonad D isComonad = record { extract = extract ; extend = extend ; extend-β = extend-β _ ; extend-η = extend-η ; extend-∘ = {!!} } where extract : ∀ {A} → D A → A extract {A = A} = get extend : ∀ {A B} → (D A → B) → (D A → D B) extend {A = A}{B = B} f x = set (f x) x -- extend {A = A}{B = B} f = uncurry set ∘ (λ x → f x , x) -- The get-set law. extend-β : ∀ {A B} (f : D A → B) → extract ∘ extend f ≡ f extend-β {A = A}{B = B} f = begin extract ∘ extend f ≡⟨⟩ get ∘ (λ x → set (f x) x) ≡⟨⟩ traverse (Const B) id ∘ (λ x → dmap (const (f x)) x) ≡⟨⟩ (λ x → traverse (Const B) id (dmap (const (f x)) x)) ≡⟨⟩ (λ x → (traverse (Const B) id ∘ traverse Id (const (f x))) x) ≡⟨ {! traverse-∘!} ⟩ (λ x → traverse (Const B) (const (f x)) x) ≡⟨ {!gets=∘get!} ⟩ (λ x → (const (f x) ∘ traverse (Const A) id) x) ≡⟨⟩ (λ x → f x) ≡⟨⟩ f ∎ -- The set-get law. extend-η : ∀ {A} → extend {A = A} extract ≡ id extend-η = begin extend extract ≡⟨⟩ (λ x → set (get x) x) ≡⟨ {!!} ⟩ id ∎ -- The set-set law. -- Lens structure. -- Law: gets in terms of get. gets=∘get : ∀ {A B} (f : A → B) → gets f ≡ f ∘ get gets=∘get {A = A}{B = B} f = begin gets f ≡⟨⟩ traverse (Const B) {B = B} f ≡⟨ traverse-∘ (Const B) Id {g = f} ⟩ traverse (Const B) {B = A} f ≡⟨ sym (traverse-free (Const A) (Const B) f (KKNat f) id) ⟩ f ∘ traverse (Const A) {B = A} id ≡⟨⟩ f ∘ get ∎ -- Constant traversal. traverse-c : ∀ {A B} (b : B) (l : D A) → B traverse-c {B = B} b = traverse (Const B) {B = B} (const b) -- Holds by parametricity (since type B is arbitrary and there is just one b : B given). traverse-const : ∀ {A B} {b : B} (l : D A) → traverse (Const B) (const b) l ≡ b traverse-const {A = A} {B = B} {b = b} l = begin traverse (Const B) (const b) l ≡⟨ cong (λ z → z l) (gets=∘get (const b)) ⟩ (const b ∘ traverse (Const A) {B = B} id) l ≡⟨⟩ b ∎ -- Lens laws. -- 1. Get what you set. get-set : ∀ {A} {a : A} → get ∘ set {A = A} a ≡ const a get-set {A = A} {a = a} = begin get ∘ set a ≡⟨⟩ get ∘ dmap (const a) ≡⟨⟩ traverse (Const A) id ∘ traverse Id (const a) ≡⟨⟩ map Id (traverse (Const A) id) ∘ traverse Id (const a) ≡⟨ sym (traverse-∘ Id (Const A)) ⟩ traverse (Id · Const A) (map Id id ∘ const a) ≡⟨⟩ traverse (Const A) (const a) ≡⟨⟩ gets (const a) ≡⟨ gets=∘get (const a) ⟩ const a ∘ get ≡⟨⟩ const a ∎ -- 2. Set what you got. set-get : ∀ {A} (l : D A) → set (get l) l ≡ l set-get {A = A} l = begin set (get l) l ≡⟨⟩ dmap (λ _ → get l) l ≡⟨⟩ traverse Id (λ _ → get l) l ≡⟨ {!!} ⟩ l ∎ -- 3. Set twice is set once. set-set : ∀ {A} (a b : A) → set a ∘ set {A = A} b ≡ set a set-set a b = begin set a ∘ set b ≡⟨⟩ dmap (const a) ∘ dmap (const b) ≡⟨ sym dmap-∘ ⟩ dmap (const a ∘ const b) ≡⟨⟩ dmap (const a) ≡⟨⟩ set a ∎ open IsDecoration -- Identity decoration. idIsDecoration : IsDecoration (λ A → A) traverse idIsDecoration F! f = f traverse-free idIsDecoration F! G! η η! f = refl traverse-id idIsDecoration = refl traverse-∘ idIsDecoration F! G! = refl -- Decoration composition. _•_ : ∀ {D E} → IsDecoration D → IsDecoration E → IsDecoration (λ A → D (E A)) traverse (d • e) F f = traverse d F (traverse e F f) traverse-free (d • e) F G η η! f = begin η ∘ traverse (d • e) F f ≡⟨⟩ η ∘ traverse d F (traverse e F f) ≡⟨ traverse-free d F G η η! _ ⟩ traverse d G (η ∘ traverse e F f) ≡⟨ cong (traverse d G) (traverse-free e F G η η! f) ⟩ traverse d G (traverse e G (η ∘ f)) ≡⟨⟩ traverse (d • e) G (η ∘ f) ∎ traverse-id (d • e) = begin traverse d Id (traverse e Id id) ≡⟨ cong (traverse d Id) (traverse-id e) ⟩ traverse d Id id ≡⟨ traverse-id d ⟩ id ∎ traverse-∘ (d • e) F G {f = f} {g = g} = begin traverse (d • e) FG (map F g ∘ f) ≡⟨⟩ traverse d FG (traverse e FG (map F g ∘ f)) ≡⟨ cong (traverse d FG) (traverse-∘ e F G) ⟩ traverse d FG (map F (traverse e G g) ∘ traverse e F f) ≡⟨ traverse-∘ d F G ⟩ map F (traverse d G (traverse e G g)) ∘ traverse d F (traverse e F f) ≡⟨⟩ map F (traverse (d • e) G g) ∘ traverse (d • e) F f ∎ where FG = F · G -- The instance. decoration : ∀ {A} → IsDecoration (_×_ A) -- traverse decoration F f (a , x) = map F (_,_ a) (f x) -- FAILS BUG WITH record pattern trans!! traverse decoration F f ax = map F (_,_ (proj₁ ax)) (f (proj₂ ax)) -- WORKS traverse-free decoration F G η η! f = fun-ext λ ax → let (a , x) = ax in begin (η ∘ traverse decoration F f) (a , x) ≡⟨⟩ (η ∘ map F (_,_ a)) (f x) ≡⟨ cong (λ z → z (f x)) (η! (_,_ a)) ⟩ (map G (_,_ a) ∘ η) (f x) ≡⟨⟩ map G (_,_ a) (η (f x)) ≡⟨⟩ traverse decoration G (η ∘ f) (a , x) ∎ traverse-id decoration = refl traverse-∘ decoration F G {f = f} {g = g} = fun-ext λ ax → let (a , x) = ax in begin traverse decoration FG (map F g ∘ f) (a , x) ≡⟨⟩ map FG (_,_ a) (map F g (f x)) ≡⟨⟩ map F (map G (_,_ a)) (map F g (f x)) ≡⟨ cong (λ z → z _) (sym (map-∘ F)) ⟩ map F (map G (_,_ a) ∘ g) (f x) ≡⟨⟩ map F (λ y → map G (_,_ a) (g y)) (f x) ≡⟨⟩ map F (λ y → traverse decoration G g (a , y)) (f x) ≡⟨⟩ map F (traverse decoration G g ∘ (_,_ a)) (f x) ≡⟨ cong (λ z → z _) (map-∘ F) ⟩ map F (traverse decoration G g) (map F (_,_ a) (f x)) ≡⟨⟩ map F (traverse decoration G g) (traverse decoration F f (a , x)) ≡⟨⟩ (map F (traverse decoration G g) ∘ traverse decoration F f) (a , x) ∎ where FG = F · G
{ "alphanum_fraction": 0.4560612889, "avg_line_length": 31.2535211268, "ext": "agda", "hexsha": "6df23be72ccee70235e97e347a7d37d4cf3df1c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Decoration.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Decoration.agda", "max_line_length": 122, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Decoration.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3234, "size": 8876 }