Search is not available for this dataset
text
string
meta
dict
-- Andreas, 2012-10-02 -- {-# OPTIONS -v tc.conv.level:100 -v tc.constr.add:40 -v tc.meta:50 -v tc.inj.use:30 -v 80 #-} module Issue689 where open import Common.Level data Bad : Set₁ where c : Set₁ → Bad -- this should not leave unsolvable constraints, but report an error
{ "alphanum_fraction": 0.6942446043, "avg_line_length": 25.2727272727, "ext": "agda", "hexsha": "8f8ea53c48bce442bc72ad24a76832ee6a3fc2cd", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue689.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue689.agda", "max_line_length": 96, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue689.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": 88, "size": 278 }
------------------------------------------------------------------------ -- The sequential colimit HIT with an erased higher constructor ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- The definition of sequential colimits and the statement of the -- non-dependent universal property are based on those in van Doorn's -- "Constructing the Propositional Truncation using Non-recursive -- HITs". -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining sequential colimits uses path -- equality, but the supplied notion of equality is used for many -- other things. import Equality.Path as P module Colimit.Sequential.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Erased.Cubical eq private variable a b p q : Level A B : Type a P : A → Type p n : ℕ e x : A ------------------------------------------------------------------------ -- The type -- Sequential colimits, with an erased higher constructor. data Colimitᴱ (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) : Type p where ∣_∣ : P n → Colimitᴱ P step @0 ∣∣≡∣∣ᴾ : (x : P n) → ∣ step x ∣ P.≡ ∣ x ∣ -- A variant of ∣∣≡∣∣ᴾ. @0 ∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} (x : P n) → _≡_ {A = Colimitᴱ P step} ∣ step x ∣ ∣ x ∣ ∣∣≡∣∣ x = _↔_.from ≡↔≡ (∣∣≡∣∣ᴾ x) ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator, expressed using paths. record Elimᴾ {P : ℕ → Type p} {@0 step : ∀ {n} → P n → P (suc n)} (Q : Colimitᴱ P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ @0 ∣∣≡∣∣ʳ : (x : P n) → P.[ (λ i → Q (∣∣≡∣∣ᴾ x i)) ] ∣∣ʳ (step x) ≡ ∣∣ʳ x open Elimᴾ public elimᴾ : {@0 step : ∀ {n} → P n → P (suc n)} {Q : Colimitᴱ P step → Type q} → Elimᴾ Q → (x : Colimitᴱ P step) → Q x elimᴾ {P = P} {step = step} {Q = Q} e = helper where module E = Elimᴾ e helper : (x : Colimitᴱ P step) → Q x helper ∣ x ∣ = E.∣∣ʳ x helper (∣∣≡∣∣ᴾ x i) = E.∣∣≡∣∣ʳ x i -- A non-dependent eliminator, expressed using paths. record Recᴾ (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B @0 ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) P.≡ ∣∣ʳ x open Recᴾ public recᴾ : {@0 step : ∀ {n} → P n → P (suc n)} → Recᴾ P step B → Colimitᴱ P step → B recᴾ r = elimᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ → R.∣∣≡∣∣ʳ where module R = Recᴾ r -- A dependent eliminator. record Elim {P : ℕ → Type p} {@0 step : ∀ {n} → P n → P (suc n)} (Q : Colimitᴱ P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ @0 ∣∣≡∣∣ʳ : (x : P n) → subst Q (∣∣≡∣∣ x) (∣∣ʳ (step x)) ≡ ∣∣ʳ x open Elim public elim : {@0 step : ∀ {n} → P n → P (suc n)} {Q : Colimitᴱ P step → Type q} → Elim Q → (x : Colimitᴱ P step) → Q x elim e = elimᴾ λ where .∣∣ʳ → E.∣∣ʳ .∣∣≡∣∣ʳ x → subst≡→[]≡ (E.∣∣≡∣∣ʳ x) where module E = Elim e -- A "computation" rule. @0 elim-∣∣≡∣∣ : dcong (elim e) (∣∣≡∣∣ x) ≡ Elim.∣∣≡∣∣ʳ e x elim-∣∣≡∣∣ = dcong-subst≡→[]≡ (refl _) -- A non-dependent eliminator. record Rec (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B @0 ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) ≡ ∣∣ʳ x open Rec public rec : {@0 step : ∀ {n} → P n → P (suc n)} → Rec P step B → Colimitᴱ P step → B rec r = recᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ x → _↔_.to ≡↔≡ (R.∣∣≡∣∣ʳ x) where module R = Rec r -- A "computation" rule. @0 rec-∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} {r : Rec P step B} {x : P n} → cong (rec r) (∣∣≡∣∣ x) ≡ Rec.∣∣≡∣∣ʳ r x rec-∣∣≡∣∣ = cong-≡↔≡ (refl _) ------------------------------------------------------------------------ -- The universal property -- The universal property of the sequential colimit. universal-property : {@0 step : ∀ {n} → P n → P (suc n)} → (Colimitᴱ P step → B) ≃ (∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x)) universal-property {P = P} {B = B} {step = step} = Eq.↔→≃ to from to∘from from∘to where to : (Colimitᴱ P step → B) → ∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x) to h = (λ _ → h ∘ ∣_∣) , [ (λ _ x → h ∣ step x ∣ ≡⟨ cong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) ] from : (∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x)) → Colimitᴱ P step → B from (f , g) = rec λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → erased g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , g) = cong (f ,_) $ []-cong [ (⟨ext⟩ λ n → ⟨ext⟩ λ x → cong (rec _) (∣∣≡∣∣ x) ≡⟨ rec-∣∣≡∣∣ ⟩∎ erased g n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to h)) (∣∣≡∣∣ x))) (trans (refl _) (cong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) rec-∣∣≡∣∣ (trans-reflˡ _) ⟩ trans (sym (cong h (∣∣≡∣∣ x))) (cong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ -- A dependently typed variant of the sequential colimit's universal -- property. universal-property-Π : {@0 step : ∀ {n} → P n → P (suc n)} → {Q : Colimitᴱ P step → Type q} → ((x : Colimitᴱ P step) → Q x) ≃ (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x)) universal-property-Π {P = P} {step = step} {Q = Q} = Eq.↔→≃ to from to∘from from∘to where to : ((x : Colimitᴱ P step) → Q x) → ∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x) to h = (λ _ → h ∘ ∣_∣) , [ (λ _ x → subst Q (∣∣≡∣∣ x) (h ∣ step x ∣) ≡⟨ dcong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) ] from : (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x)) → (x : Colimitᴱ P step) → Q x from (f , [ g ]) = elim λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , [ g ]) = cong (f ,_) $ []-cong [ (⟨ext⟩ λ n → ⟨ext⟩ λ x → dcong (elim _) (∣∣≡∣∣ x) ≡⟨ elim-∣∣≡∣∣ ⟩∎ g n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (from (to h)) (∣∣≡∣∣ x))) (trans (cong (subst Q (∣∣≡∣∣ x)) (refl _)) (dcong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) elim-∣∣≡∣∣ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩ trans (sym (dcong h (∣∣≡∣∣ x))) (dcong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎
{ "alphanum_fraction": 0.4120803694, "avg_line_length": 29.7881040892, "ext": "agda", "hexsha": "58bad7f64a9a02433553172c629aa9f3b52ce646", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Colimit/Sequential/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Colimit/Sequential/Erased.agda", "max_line_length": 98, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Colimit/Sequential/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 3508, "size": 8013 }
module _ where record Pair (A B : Set) : Set where field π₁ : A π₂ : B open Pair foo : {A B : Set} → Pair A B → Pair A B foo = λ { x → {!x!} } {- Case splitting on x produces: foo = λ { record { π₁ = π₃ ; π₂ = π₃ } → ? } Repeated variables in pattern: π₃ -}
{ "alphanum_fraction": 0.5376344086, "avg_line_length": 16.4117647059, "ext": "agda", "hexsha": "1b5583e116df1d377a12efe0d93dfb6d026a72f5", "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/Issue2669.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/Issue2669.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2669.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": 108, "size": 279 }
open import Prelude hiding (id; Bool) module Implicits.Resolution.Undecidable.Expressiveness where open import Implicits.Syntax open import Implicits.Substitutions open import Extensions.ListFirst open import Implicits.Resolution.Ambiguous.Resolution as A open import Implicits.Resolution.Deterministic.Resolution as D open import Implicits.Resolution.Undecidable.Resolution as I mutual ↓-sound : ∀ {ν} {Δ : ICtx ν} {a r} → Δ D.⊢ r ↓ a → Δ I.⊢ r ↓ a ↓-sound (i-simp a) = i-simp a ↓-sound (i-iabs x x₁) = i-iabs (≥-deterministic x) (↓-sound x₁) ↓-sound (i-tabs b x) = i-tabs b (↓-sound x) Δ⟨τ⟩-sound : ∀ {ν} {Δ Δ' : ICtx ν} {a r} → Δ D.⟨ a ⟩= r → Δ' D.⊢ r ↓ a → first r ∈ Δ ⇔ (λ r' → Δ' I.⊢ r' ↓ a) Δ⟨τ⟩-sound (here p v) y = here (↓-sound y) v Δ⟨τ⟩-sound (there x ¬x◁τ p) y = there x (¬◁-¬↓ ¬x◁τ) (Δ⟨τ⟩-sound p y) where ↓-◁ : ∀ {ν} {Δ : ICtx ν} {a r} → Δ I.⊢ r ↓ a → r ◁ a ↓-◁ (i-simp _) = m-simp ↓-◁ (i-iabs _ r2↓a) = m-iabs (↓-◁ r2↓a) ↓-◁ (i-tabs b r↓a) = m-tabs b (↓-◁ r↓a) ¬◁-¬↓ : ∀ {ν} {Δ : ICtx ν} {a r} → ¬ r ◁ a → ¬ Δ I.⊢ r ↓ a ¬◁-¬↓ ¬a◁a (i-simp a) = ¬a◁a m-simp ¬◁-¬↓ ¬r◁a (i-iabs ⊢ᵣr₁ r₂↓a) = ¬r◁a (m-iabs (↓-◁ r₂↓a)) ¬◁-¬↓ ¬r◁a (i-tabs b r[/]↓a) = ¬r◁a (m-tabs b (↓-◁ r[/]↓a)) ≥-deterministic : ∀ {ν} {Δ : ICtx ν} {a} → Δ D.⊢ᵣ a → Δ I.⊢ᵣ a ≥-deterministic (r-simp {τ = a} Δ⟨a⟩=r r↓a) = r-simp (Δ⟨τ⟩-sound Δ⟨a⟩=r r↓a) ≥-deterministic (r-iabs ρ₁ x) = r-iabs ρ₁ (≥-deterministic x) ≥-deterministic (r-tabs x) = r-tabs (≥-deterministic x)
{ "alphanum_fraction": 0.5323834197, "avg_line_length": 40.6315789474, "ext": "agda", "hexsha": "eb128a9fd0e22f076674d8c036da1582e1630d18", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Undecidable/Expressiveness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Undecidable/Expressiveness.agda", "max_line_length": 78, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Undecidable/Expressiveness.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 771, "size": 1544 }
{-# OPTIONS --cubical --safe #-} module Hyper where open import Prelude hiding (⊥) open import Data.Empty.UniversePolymorphic open import Data.List using (List; _∷_; []) open import Data.Vec.Iterated open import Data.Nat using (_*_; _+_) open import Data.Nat.Properties using (Even; Odd) private variable n m : ℕ infixr 4 _#_↬_ _#_↬_ : ℕ → Type a → Type b → Type (a ℓ⊔ b) zero # A ↬ B = ⊥ suc n # A ↬ B = n # B ↬ A → B module _ {a b} {A : Type a} {B : Type b} where yfld : Vec B n → 1 + (n * 2) # List (A × B) ↬ (A → List (A × B)) yfld = foldr (λ n → 1 + (n * 2) # List (A × B) ↬ (A → List (A × B))) (λ y yk xk x → (x , y) ∷ xk yk) (λ ()) xfld : Vec A n → (1 + n) * 2 # (A → List (A × B)) ↬ List (A × B) xfld = foldr (λ n → (1 + n) * 2 # (A → List (A × B)) ↬ List (A × B)) (λ x xk yk → yk xk x) (λ _ → []) zip : Vec A n → Vec B n → List (A × B) zip xs ys = xfld xs (yfld ys) cata : Even n → (((C → A) → B) → C) → n # A ↬ B → C cata {n = suc (suc n)} e ϕ h = ϕ (λ g → h (g ∘ cata e ϕ)) push : (A → B) → n # A ↬ B → 2 + n # A ↬ B push {n = suc n} f q k = f (k q) one : Odd n → n # A ↬ A one {n = suc zero} o () one {n = suc (suc n)} o k = k (one o)
{ "alphanum_fraction": 0.4806902219, "avg_line_length": 25.3541666667, "ext": "agda", "hexsha": "fc91d7242621a285fec81f6b262c96661c54a4d5", "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": "Hyper.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": "Hyper.agda", "max_line_length": 66, "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": "Hyper.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": 536, "size": 1217 }
open import Agda.Builtin.Char open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.String open import Agda.Builtin.String.Properties data ⊥ : Set where ∷⁻¹ : ∀ {A : Set} {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y ∷⁻¹ refl = refl xD800 = primNatToChar 0xD800 xD801 = primNatToChar 0xD801 legit : '\xD800' ∷ [] ≡ '\xD801' ∷ [] legit = primStringFromListInjective _ _ refl actually : xD800 ≡ xD801 actually = refl nope : xD800 ≡ xD801 → ⊥ nope () boom : ⊥ boom = nope (∷⁻¹ legit) errorAlsoInLHS : Char → String errorAlsoInLHS '\xD8AA' = "bad" errorAlsoInLHS _ = "meh"
{ "alphanum_fraction": 0.6715210356, "avg_line_length": 19.935483871, "ext": "agda", "hexsha": "a4c36deb293fb3713e1646a40795a74a592ba6fe", "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/Issue4999.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/Issue4999.agda", "max_line_length": 61, "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/Issue4999.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": 239, "size": 618 }
module CTL.Modalities.AN where open import FStream.Core open import Library -- Always (in) Next : p ⊧ φ ⇔ p[1] ⊧ φ AN' : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream' C (Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) AN' props = APred head (inF (tail props)) AN : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream C (Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) AN props = APred AN' (inF props) mutual AN'ₛ : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream' C (Set ℓ₂) → FStream' {i} C (Set (ℓ₁ ⊔ ℓ₂)) head (AN'ₛ props) = AN' props tail (AN'ₛ props) = ANₛ (tail props) ANₛ : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} → FStream C (Set ℓ₂) → FStream {i} C (Set (ℓ₁ ⊔ ℓ₂)) inF (ANₛ props) = fmap AN'ₛ (inF props)
{ "alphanum_fraction": 0.5671641791, "avg_line_length": 27.9166666667, "ext": "agda", "hexsha": "94e12ae1995a067cc3adce5a806aa3a4fa161661", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "CTL/Modalities/AN.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "CTL/Modalities/AN.agda", "max_line_length": 61, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "CTL/Modalities/AN.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 319, "size": 670 }
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Algebra.Signature where open import Data.Nat using (ℕ) record Signature : Set₁ where field ops : ℕ → Set open Signature public data ExtendedOp (Σ : Signature) (O : ℕ → Set) : ℕ → Set where newₒ : ∀ {n} → O n → ExtendedOp Σ O n oldₒ : ∀ {n} → ops Σ n → ExtendedOp Σ O n _⦅_⦆ : (Σ : Signature) → (ℕ → Set) → Signature Σ ⦅ O ⦆ = record { ops = ExtendedOp Σ O }
{ "alphanum_fraction": 0.6173120729, "avg_line_length": 23.1052631579, "ext": "agda", "hexsha": "2804b9c6fbbee1dc11482d6d50c1dfbd5b478397", "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/Signature.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/Signature.agda", "max_line_length": 61, "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/Signature.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": 159, "size": 439 }
-- Andreas, 2017-08-10, issue #2664, reported by csetzer -- Test case by Ulf -- {-# OPTIONS -v tc.rec:40 #-} -- {-# OPTIONS -v tc.cc:60 #-} open import Agda.Builtin.IO open import Agda.Builtin.String open import Agda.Builtin.Unit open import Agda.Builtin.Nat mutual -- Error WAS: -- The presence of mutual affected the compilation of the projections -- since it triggered a record pattern translation for them. record R : Set where constructor mkR field dummy : Nat str : String helloWorld : R helloWorld = mkR 0 "Hello World!" postulate putStrLn : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO as Text #-} {-# COMPILE GHC putStrLn = Text.putStrLn #-} {-# COMPILE JS putStrLn = function(x) { return function(cb) { process.stdout.write(x + "\n"); cb(0); }; } #-} {-# FOREIGN OCaml let printEndline y world = Lwt.return (print_endline y) #-} {-# COMPILE OCaml putStrLn = printEndline #-} main : IO ⊤ main = putStrLn (R.str helloWorld) -- Expected: Should print -- -- Hello World!
{ "alphanum_fraction": 0.6714836224, "avg_line_length": 23.5909090909, "ext": "agda", "hexsha": "cc259e1ec04ec812ed220901ef3b1ed470562b7e", "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": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "xekoukou/agda-ocaml", "max_forks_repo_path": "test/Compiler/simple/Issue2664.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "xekoukou/agda-ocaml", "max_issues_repo_path": "test/Compiler/simple/Issue2664.agda", "max_line_length": 110, "max_stars_count": 7, "max_stars_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "xekoukou/agda-ocaml", "max_stars_repo_path": "test/Compiler/simple/Issue2664.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 285, "size": 1038 }
module OList {A : Set}(_≤_ : A → A → Set) where open import Data.List open import Bound.Lower A open import Bound.Lower.Order _≤_ data OList : Bound → Set where onil : {b : Bound} → OList b :< : {b : Bound}{x : A} → LeB b (val x) → OList (val x) → OList b forget : {b : Bound} → OList b → List A forget onil = [] forget ( :< {x = x} _ xs) = x ∷ forget xs
{ "alphanum_fraction": 0.4820627803, "avg_line_length": 21.2380952381, "ext": "agda", "hexsha": "4bbf937d8af3ae3e9062e468a9987d5ba128e4af", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/OList.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/OList.agda", "max_line_length": 47, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/OList.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 147, "size": 446 }
------------------------------------------------------------------------ -- Formalisation of subtyping for recursive types -- -- Nils Anders Danielsson ------------------------------------------------------------------------ -- This formalisation is explained in "Subtyping, Declaratively—An -- Exercise in Mixed Induction and Coinduction" (coauthored with -- Thorsten Altenkirch). The code is partly based on "Coinductive -- Axiomatization of Recursive Type Equality and Subtyping" by Michael -- Brandt and Fritz Henglein. module RecursiveTypes where -- Recursive types and potentially infinite trees. import RecursiveTypes.Syntax -- Substitutions. import RecursiveTypes.Substitution -- The semantics of recursive types, defined in terms of the trees -- that you get when unfolding them. import RecursiveTypes.Semantics -- The definition of subtyping which, in my eyes, is the most obvious. -- Some people may dislike coinductive definitions, though. import RecursiveTypes.Subtyping.Semantic.Coinductive -- An example. import RecursiveTypes.Subtyping.Example -- Another definition of subtyping, this time in terms of finite -- approximations. According to Brandt and Henglein this definition is -- due to Amadio and Cardelli. import RecursiveTypes.Subtyping.Semantic.Inductive -- The two semantical definitions of subtyping above can easily be -- proved equivalent. import RecursiveTypes.Subtyping.Semantic.Equivalence -- An axiomatisation of subtyping which is inspired by Brandt and -- Henglein's. The main difference is that their axiomatisation is -- inductive, using explicit hypotheses to get a coinductive flavour, -- whereas mine is mixed inductive/coinductive, using no explicit -- hypotheses. The axiomatisation is proved equivalent to the -- coinductive semantic definition of subtyping. The proof is a lot -- simpler than Brandt and Henglein's, but their proof includes a -- decision procedure for subtyping. import RecursiveTypes.Subtyping.Axiomatic.Coinductive -- Brandt and Henglein's axiomatisation, plus some proofs: -- • A proof showing that the axiomatisation is sound with respect to -- the ones above. The soundness proof is different from the one -- given by Brandt and Henglein: it is cyclic (but productive). -- • Proofs of decidability and completeness, based on Brandt and -- Henglein's algorithm. import RecursiveTypes.Subtyping.Axiomatic.Inductive -- Some modules containing supporting code for the proof of -- decidability, including Brandt and Henglein's subterm relation. import RecursiveTypes.Subterm import RecursiveTypes.Subterm.RestrictedHypothesis import RecursiveTypes.Syntax.UnfoldedOrFixpoint -- An incorrect "subtyping" relation which illustrates the fact that -- taking the transitive closure of a coinductively defined relation -- is not in general equivalent to adding an inductive transitivity -- constructor to it. import RecursiveTypes.Subtyping.Axiomatic.Incorrect -- Finally some code which is not directly related to subtyping or -- recursive types: an example which shows that, in a coinductive -- setting, it is not always sound to postulate admissible rules -- (inductively). import AdmissibleButNotPostulable
{ "alphanum_fraction": 0.7636932707, "avg_line_length": 36.3068181818, "ext": "agda", "hexsha": "8b92e07337915ff1c4d51e441817208a7dd4e36e", "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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "RecursiveTypes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "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/codata", "max_issues_repo_path": "RecursiveTypes.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "RecursiveTypes.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 691, "size": 3195 }
{-# OPTIONS --prop --rewriting #-} module Examples.Sorting.Parallel.Comparable where open import Calf.CostMonoid open import Calf.CostMonoids parCostMonoid = ℕ²-ParCostMonoid costMonoid = ParCostMonoid.costMonoid parCostMonoid open import Data.Nat using (ℕ) open ParCostMonoid parCostMonoid using (ℂ) open import Data.Product using (_,_) fromℕ : ℕ → ℂ fromℕ n = n , n open import Examples.Sorting.Comparable costMonoid fromℕ public
{ "alphanum_fraction": 0.7876712329, "avg_line_length": 23.0526315789, "ext": "agda", "hexsha": "26ed5963db8e31471566b9c5517f619c6da72652", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Examples/Sorting/Parallel/Comparable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "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": "jonsterling/agda-calf", "max_issues_repo_path": "src/Examples/Sorting/Parallel/Comparable.agda", "max_line_length": 63, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Examples/Sorting/Parallel/Comparable.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 130, "size": 438 }
module Highlighting where Set-one : Set₂ Set-one = Set₁ record R (A : Set) : Set-one where constructor con field X : Set F : Set → Set → Set F A B = B field P : F A X → Set -- highlighting of non-terminating definition Q : F A X → Set Q = Q postulate P : _ open import Highlighting.M using (ℕ) renaming ( _+_ to infixl 5 _⊕_ ; _*_ to infixl 7 _⊗_ ) data D (A : Set) : Set-one where d : let X = D in X A postulate _+_ _×_ : Set → Set → Set infixl 4 _×_ _+_ -- Issue #2140: the operators should be highlighted also in the -- fixity declaration. -- Issue #3120, jump-to-definition for record field tags -- in record expressions and patterns. anR : ∀ A → R A anR A = record { X = A ; P = λ _ → A } idR : ∀ A → R A → R A idR A r@record { X = X; P = P } = record r { X = X } record S (A : Set) : Set where field X : A idR' : ∀ A → R A → R A idR' A r@record { X = X; P = P } = record r { X = X } open S bla : ∀{A} → A → S A bla x .X = x -- Issue #3825: highlighting of unsolved metas in record{M} expressions record R₂ (A : Set) : Set where field impl : {a : A} → A module M {A : Set} where impl : {a : A} → A -- yellow should not be here impl {a} = a r₂ : ∀{A} → R₂ A r₂ = record {M} -- just because there is an unsolved meta here -- End issue #3825 -- Issue #3855: highlighting of quantity attributes. -- @0 and @erased should be highlighted as symbols. idPoly0 : {@0 A : Set} → A → A idPoly0 x = x idPolyE : {@erased A : Set} → A → A idPolyE x = x -- Issue #3989: Shadowed repeated variables in telescopes should by -- default /not/ be highlighted. Issue-3989 : (A A : Set) → Set Issue-3989 _ A = A -- Issue #4356. open import Agda.Builtin.Sigma Issue-4356₁ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set) Issue-4356₁ = λ P@(A , B) → P Issue-4356₂ : Σ Set (λ _ → Set) → Set Issue-4356₂ = λ (A , B) → A Issue-4356₃ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set) Issue-4356₃ P = let Q@(A , B) = P in Q Issue-4356₄ : Σ Set (λ _ → Set) → Set Issue-4356₄ P = let (A , B) = P in B Issue-4356₅ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set) Issue-4356₅ P@(A , B) = P Issue-4356₆ : Σ Set (λ _ → Set) → Set Issue-4356₆ (A , B) = B -- Issue #4361: Highlighting builtins. data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat -#} -- NATURAL should be highlighted as keyword.
{ "alphanum_fraction": 0.5954003407, "avg_line_length": 20.2413793103, "ext": "agda", "hexsha": "53a382d6ca9d1c73f407815af863f158c762a359", "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": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Soares/agda", "max_forks_repo_path": "test/interaction/Highlighting.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "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": "Soares/agda", "max_issues_repo_path": "test/interaction/Highlighting.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Soares/agda", "max_stars_repo_path": "test/interaction/Highlighting.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 896, "size": 2348 }
------------------------------------------------------------------------ -- This module proves that the recognisers correspond exactly to -- decidable predicates of type List Bool → Bool (when the alphabet is -- Bool) ------------------------------------------------------------------------ -- This result could be generalised to other finite alphabets. module TotalRecognisers.Simple.ExpressiveStrength where open import Codata.Musical.Notation open import Data.Bool open import Data.Bool.Properties open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; equivalence; module Equivalence) open import Data.List open import Data.Product open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable import TotalRecognisers.Simple open TotalRecognisers.Simple Bool _≟_ -- One direction of the correspondence has already been established: -- For every grammar there is an equivalent decidable predicate. grammar⇒pred : ∀ {n} (p : P n) → ∃ λ (f : List Bool → Bool) → ∀ s → s ∈ p ⇔ T (f s) grammar⇒pred p = ((λ s → ⌊ s ∈? p ⌋) , λ _ → equivalence fromWitness toWitness) -- For every decidable predicate there is a corresponding grammar. -- Note that these grammars are all "infinite LL(1)". pred⇒grammar : (f : List Bool → Bool) → ∃ λ (p : P (f [])) → ∀ s → s ∈ p ⇔ T (f s) pred⇒grammar f = (grammar f , λ s → equivalence (sound f) (complete f s)) where accept-if-true : ∀ b → P b accept-if-true true = empty accept-if-true false = fail grammar : (f : List Bool → Bool) → P (f []) grammar f = tok true · ♯ grammar (f ∘ _∷_ true ) ∣ tok false · ♯ grammar (f ∘ _∷_ false) ∣ accept-if-true (f []) accept-if-true-sound : ∀ b {s} → s ∈ accept-if-true b → s ≡ [] × T b accept-if-true-sound true empty = (refl , _) accept-if-true-sound false () accept-if-true-complete : ∀ {b} → T b → [] ∈ accept-if-true b accept-if-true-complete ok with Equivalence.to T-≡ ⟨$⟩ ok ... | refl = empty sound : ∀ f {s} → s ∈ grammar f → T (f s) sound f (∣-right s∈) with accept-if-true-sound (f []) s∈ ... | (refl , ok) = ok sound f (∣-left (∣-left (tok · s∈))) = sound (f ∘ _∷_ true ) s∈ sound f (∣-left (∣-right (tok · s∈))) = sound (f ∘ _∷_ false) s∈ complete : ∀ f s → T (f s) → s ∈ grammar f complete f [] ok = ∣-right {n₁ = false} $ accept-if-true-complete ok complete f (true ∷ bs) ok = ∣-left {n₁ = false} $ ∣-left {n₁ = false} $ tok · complete (f ∘ _∷_ true ) bs ok complete f (false ∷ bs) ok = ∣-left {n₁ = false} $ ∣-right {n₁ = false} $ tok · complete (f ∘ _∷_ false) bs ok
{ "alphanum_fraction": 0.593529193, "avg_line_length": 35.8533333333, "ext": "agda", "hexsha": "a229a4807c81f5e08b24ec0dae54398803a86d4b", "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": "TotalRecognisers/Simple/ExpressiveStrength.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": "TotalRecognisers/Simple/ExpressiveStrength.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalRecognisers/Simple/ExpressiveStrength.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": 832, "size": 2689 }
-- {-# OPTIONS --show-implicit #-} module Issue89 where open import Common.Coinduction renaming (∞ to ∞_) ------------------------------------------------------------------------ -- Streams infixr 5 _≺_ data Stream A : Set where _≺_ : (x : A) (xs : ∞ (Stream A)) -> Stream A head : forall {A} -> Stream A -> A head (x ≺ xs) = x tail : forall {A} -> Stream A -> Stream A tail (x ≺ xs) = ♭ xs ------------------------------------------------------------------------ -- Stream programs infix 8 _∞ infixr 5 _⋎_ infix 4 ↓_ mutual data Stream′ A : Set1 where _≺_ : (x : A) (xs : ∞ (StreamProg A)) -> Stream′ A data StreamProg (A : Set) : Set1 where ↓_ : (xs : Stream′ A) -> StreamProg A _∞ : (x : A) -> StreamProg A _⋎_ : (xs ys : StreamProg A) -> StreamProg A head′ : ∀ {A} → Stream′ A → A head′ (x ≺ xs) = x tail′ : ∀ {A} → Stream′ A → StreamProg A tail′ (x ≺ xs) = ♭ xs P⇒′ : forall {A} -> StreamProg A -> Stream′ A P⇒′ (↓ xs) = xs P⇒′ (x ∞) = x ≺ ♯ (x ∞) P⇒′ (xs ⋎ ys) with P⇒′ xs P⇒′ (xs ⋎ ys) | xs′ = head′ xs′ ≺ ♯ (ys ⋎ tail′ xs′) mutual ′⇒ : forall {A} -> Stream′ A -> Stream A ′⇒ (x ≺ xs) = x ≺ ♯ P⇒ (♭ xs) P⇒ : forall {A} -> StreamProg A -> Stream A P⇒ xs = ′⇒ (P⇒′ xs) ------------------------------------------------------------------------ -- Stream equality infix 4 _≡_ _≈_ _≊_ data _≡_ {a : Set} (x : a) : a -> Set where ≡-refl : x ≡ x data _≈_ {A} (xs ys : Stream A) : Set where _≺_ : (x≡ : head xs ≡ head ys) (xs≈ : ∞ (tail xs ≈ tail ys)) -> xs ≈ ys _≊_ : forall {A} (xs ys : StreamProg A) -> Set xs ≊ ys = P⇒ xs ≈ P⇒ ys foo : forall {A} (x : A) -> x ∞ ⋎ x ∞ ≊ x ∞ foo x = ≡-refl ≺ ♯ foo x -- The first goal has goal type -- head (′⇒ (x ≺ x ∞ ⋎ x ∞)) ≡ head (′⇒ (x ≺ x ∞)). -- The normal form of the left-hand side is x, and the normal form of -- the right-hand side is x (both according to Agda), but ≡-refl is -- not accepted by the type checker: -- x != head (′⇒ (P⇒′ (x ∞))) of type .A -- when checking that the expression ≡-refl has type -- (head (P⇒ (x ∞ ⋎ x ∞)) ≡ head (P⇒ (x ∞)))
{ "alphanum_fraction": 0.4597315436, "avg_line_length": 24.5411764706, "ext": "agda", "hexsha": "fc55e36ad1eb7ad2530feadea9924cc9feda174d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue89.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/Issue89.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue89.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": 869, "size": 2086 }
import Relation.Binary.Reasoning.Setoid as SetoidR open import MultiSorted.AlgebraicTheory import MultiSorted.Interpretation as Interpretation import MultiSorted.Model as Model import MultiSorted.UniversalInterpretation as UniversalInterpretation import MultiSorted.Substitution as Substitution import MultiSorted.SyntacticCategory as SyntacticCategory module MultiSorted.UniversalModel {ℓt} {𝓈 ℴ} {Σ : Signature {𝓈} {ℴ}} (T : Theory ℓt Σ) where open Theory T open Substitution T open UniversalInterpretation T open Interpretation.Interpretation ℐ open SyntacticCategory T 𝒰 : Model.Is-Model T ℐ 𝒰 = record { model-eq = λ ε var-var → let open SetoidR (eq-setoid (ax-ctx ε) (sort-of (ctx-slot (ax-sort ε)) var-var)) in begin interp-term (ax-lhs ε) var-var ≈⟨ interp-term-self (ax-lhs ε) var-var ⟩ ax-lhs ε ≈⟨ id-action ⟩ ax-lhs ε [ id-s ]s ≈⟨ eq-axiom ε id-s ⟩ ax-rhs ε [ id-s ]s ≈˘⟨ id-action ⟩ ax-rhs ε ≈˘⟨ interp-term-self (ax-rhs ε) var-var ⟩ interp-term (ax-rhs ε) var-var ∎ } -- The universal model is universal universality : ∀ (ε : Equation Σ) → ⊨ ε → ⊢ ε universality ε p = let open Equation in let open SetoidR (eq-setoid (eq-ctx ε) (eq-sort ε)) in (begin eq-lhs ε ≈˘⟨ interp-term-self (eq-lhs ε) var-var ⟩ interp-term (eq-lhs ε) var-var ≈⟨ p var-var ⟩ interp-term (eq-rhs ε) var-var ≈⟨ interp-term-self (eq-rhs ε) var-var ⟩ eq-rhs ε ∎)
{ "alphanum_fraction": 0.5975683891, "avg_line_length": 35, "ext": "agda", "hexsha": "dc43761bd416e78413502225df9f20bd79763eb0", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/MultiSorted/UniversalModel.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/MultiSorted/UniversalModel.agda", "max_line_length": 106, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/MultiSorted/UniversalModel.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 510, "size": 1645 }
module InstanceArgumentsModNotParameterised where postulate A : Set a : A record B : Set where field bA : A b : B b = record {bA = a} module C = B b open C {{...}}
{ "alphanum_fraction": 0.6132596685, "avg_line_length": 12.0666666667, "ext": "agda", "hexsha": "e4782ee83b928ab8fb17132dd3ba9226eb0a47b0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/InstanceArgumentsModNotParameterised.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/InstanceArgumentsModNotParameterised.agda", "max_line_length": 49, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/InstanceArgumentsModNotParameterised.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": 57, "size": 181 }
{-# OPTIONS --without-K #-} open import Types module Functions where -- Identity functions id : ∀ {i} (A : Set i) → (A → A) id A = λ x → x -- Constant functions cst : ∀ {i j} {A : Set i} {B : Set j} (b : B) → (A → B) cst b = λ _ → b -- Composition of dependent functions _◯_ : ∀ {i j k} {A : Set i} {B : A → Set j} {C : (a : A) → (B a → Set k)} → (g : {a : A} → Π (B a) (C a)) → (f : Π A B) → Π A (λ a → C a (f a)) g ◯ f = λ x → g (f x) -- Application infixr 0 _$_ _$_ : ∀ {i j} {A : Set i} {B : A → Set j} → (∀ x → B x) → (∀ x → B x) f $ x = f x -- Curry! Can't live without it! curry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : Σ A B → Set k} → (∀ s → C s) → (∀ x y → C (x , y)) curry f x y = f (x , y) uncurry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : ∀ x → B x → Set k} → (∀ x y → C x y) → (∀ s → C (π₁ s) (π₂ s)) uncurry f (x , y) = f x y
{ "alphanum_fraction": 0.4373549884, "avg_line_length": 26.1212121212, "ext": "agda", "hexsha": "809c3f8642b68e803b856aaa3aab99d2ebc053fb", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Functions.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Functions.agda", "max_line_length": 73, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Functions.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": 398, "size": 862 }
module Peano where open import IPL data ℕ : Set where zero : ℕ -- Axiom 2.1. 0 is a natural number _++ : ℕ → ℕ -- Axiom 2.2. If n is a natural number, then n++ is also a natural number data _≡_ : ℕ → ℕ → Set where refl : {a : ℕ} → a ≡ a axiom23 : {n : ℕ} → ¬ (zero ≡ (n ++)) axiom23 = λ () axiom24 : {n m : ℕ} → (n ++) ≡ (m ++) → n ≡ m axiom24 refl = refl _+_ : ℕ → ℕ → ℕ -- Definition 2.2.1 zero + m = m (n ++) + m = (n + m) ++ ≡-sec : {n m : ℕ} → n ≡ m → (n ++) ≡ (m ++) ≡-sec refl = refl ≡-comm : {n m : ℕ} → n ≡ m → m ≡ n ≡-comm refl = refl ≡-trans : {n m p : ℕ} → n ≡ m → m ≡ p → n ≡ p ≡-trans refl refl = refl lemma222 : (n : ℕ) → (n + zero) ≡ n lemma222 zero = refl lemma222 (n ++) = ≡-sec (lemma222 n) lemma223 : (n m : ℕ) → (n + (m ++)) ≡ ((n + m) ++) lemma223 zero m = refl lemma223 (n ++) m = ≡-sec (lemma223 n m) -- Addition is commutative prop224 : (n m : ℕ) → (n + m) ≡ (m + n) prop224 zero m = ≡-comm (lemma222 m) prop224 (n ++) m = ≡-trans (≡-sec (prop224 n m)) (≡-comm (lemma223 m n)) -- Addition is associative prop225 : (a b c : ℕ) → ((a + b) + c) ≡ (a + (b + c)) prop225 zero b c = refl prop225 (a ++) b c = ≡-sec (prop225 a b c) -- Cancellation law prop226 : (a b c : ℕ) → (a + b) ≡ (a + c) → b ≡ c prop226 zero b c = λ z → z prop226 (a ++) b c = λ z → (prop226 a b c) (axiom24 z)
{ "alphanum_fraction": 0.4781675018, "avg_line_length": 26.8653846154, "ext": "agda", "hexsha": "72bcadde4ad88ae3b39628483044f6b015332d48", "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": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alf239/tao", "max_forks_repo_path": "peano.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "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": "alf239/tao", "max_issues_repo_path": "peano.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alf239/tao", "max_stars_repo_path": "peano.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 612, "size": 1397 }
{-# OPTIONS --without-K #-} open import Type open import Data.Bits using (Bits) open import Data.Bit using (Bit) open import Data.Zero using (𝟘) open import Data.Fin using (Fin) open import Data.Maybe using (Maybe) open import Data.Nat using (ℕ) open import Data.Product using (Σ; _×_) open import Data.Sum using (_⊎_) open import Data.One using (𝟙) open import Data.Vec using (Vec) module Explore.Syntax where -- this is to be imported from the appropriate module postulate S : ★₀ → ★₀ S𝟙 : S 𝟙 SBit : S Bit SFin : ∀ n → S (Fin n) SBits : ∀ n → S (Bits n) SVec : ∀ {A} → S A → ∀ n → S (Vec A n) _S×_ : ∀ {A B} → S A → S B → S (A × B) _S⊎_ : ∀ {A B} → S A → S B → S (A ⊎ B) SMaybe : ∀ {A} → S A → S (Maybe A) SΣ : ∀ {A} {B : A → _} → S A → (∀ x → S (B x)) → S (Σ A B) S𝟙→ : ∀ {A} → S A → S (𝟙 → A) SBit→ : ∀ {A} → S A → S (Bit → A) S𝟘→ : ∀ A → S (𝟘 → A) S×→ : ∀ {A B C} → S (A → B → C) → S (A × B → C) S⟨_⊎_⟩→ : ∀ {A B C} → S (A → C) → S (B → C) → S (A ⊎ B → C) module Fin-universe where `★ : ★₀ `★ = ℕ -- decoding El : `★ → ★₀ El = Fin `S : ∀ `A → S (El `A) `S = SFin module Bits-universe where `★ : ★₀ `★ = ℕ -- decoding El : `★ → ★₀ El = Bits `S : ∀ `A → S (El `A) `S = SBits module ⊎×-universe where data `★ : ★₀ where `𝟙 : `★ _`×_ _`⊎_ : `★ → `★ → `★ -- decoding El : `★ → ★₀ El `𝟙 = 𝟙 El (s `× t) = El s × El t El (s `⊎ t) = El s ⊎ El t `S : ∀ `A → S (El `A) `S `𝟙 = S𝟙 `S (s `× t) = `S s S× `S t `S (s `⊎ t) = `S s S⊎ `S t module 𝟙-Maybe-universe where data `★ : ★₀ where -- one element `𝟙 : `★ -- one element more `Maybe : `★ → `★ -- decoding El : `★ → ★₀ El `𝟙 = 𝟙 El (`Maybe t) = Maybe (El t) `S : ∀ `A → S (El `A) `S `𝟙 = S𝟙 `S (`Maybe t) = SMaybe (`S t) module ΣBit-universe where data `★ : ★₀ El : `★ → ★₀ data `★ where `Bit : `★ `Σ : (s : `★) → (El s → `★) → `★ -- decoding El `Bit = Bit El (`Σ s t) = Σ (El s) λ x → El (t x) `S : ∀ `A → S (El `A) `S `Bit = SBit `S (`Σ s t) = SΣ (`S s) λ x → `S (t x) module ⊎×→-universe where -- Types appearing on the left of an arrow data `★⁻ : ★₀ where -- zero and elements `𝟘 `𝟙 : `★⁻ -- products and co-products _`×_ _`⊎_ : `★⁻ → `★⁻ → `★⁻ -- decoding of negative types El⁻ : `★⁻ → ★₀ El⁻ `𝟘 = 𝟘 El⁻ `𝟙 = 𝟙 El⁻ (s `× t) = El⁻ s × El⁻ t El⁻ (s `⊎ t) = El⁻ s ⊎ El⁻ t `S⟨_⟩→_ : ∀ `A {B} (sB : S B) → S (El⁻ `A → B) `S⟨ `𝟘 ⟩→ t = S𝟘→ _ `S⟨ `𝟙 ⟩→ t = S𝟙→ t `S⟨ s `× t ⟩→ u = S×→ (`S⟨ s ⟩→ `S⟨ t ⟩→ u) `S⟨ s `⊎ t ⟩→ u = S⟨ `S⟨ s ⟩→ u ⊎ `S⟨ t ⟩→ u ⟩→ data `★ : ★₀ where -- one element `𝟙 : `★ -- products and co-products _`×_ _`⊎_ : `★ → `★ → `★ -- functions _`→_ : `★⁻ → `★ → `★ -- decoding of positive types El : `★ → ★₀ El `𝟙 = 𝟙 El (s `× t) = El s × El t El (s `⊎ t) = El s ⊎ El t El (s `→ t) = El⁻ s → El t `S : ∀ `A → S (El `A) `S `𝟙 = S𝟙 `S (s `× t) = `S s S× `S t `S (s `⊎ t) = `S s S⊎ `S t `S (s `→ t) = `S⟨ s ⟩→ `S t module Σ⊎×→-universe where -- Types appearing on the left of an arrow data `★⁻ : ★₀ where -- zero, one, and two elements `𝟘 `𝟙 `Bit : `★⁻ -- products and co-products _`×_ _`⊎_ : `★⁻ → `★⁻ → `★⁻ -- Σ? -- decoding of negative types El⁻ : `★⁻ → ★₀ El⁻ `𝟘 = 𝟘 El⁻ `𝟙 = 𝟙 El⁻ `Bit = Bit El⁻ (s `× t) = El⁻ s × El⁻ t El⁻ (s `⊎ t) = El⁻ s ⊎ El⁻ t `S⟨_⟩→_ : ∀ `A {B} (sB : S B) → S (El⁻ `A → B) `S⟨ `𝟘 ⟩→ t = S𝟘→ _ `S⟨ `𝟙 ⟩→ t = S𝟙→ t `S⟨ `Bit ⟩→ t = SBit→ t `S⟨ s `× t ⟩→ u = S×→ (`S⟨ s ⟩→ `S⟨ t ⟩→ u) `S⟨ s `⊎ t ⟩→ u = S⟨ `S⟨ s ⟩→ u ⊎ `S⟨ t ⟩→ u ⟩→ data `★ : ★₀ El : `★ → ★₀ data `★ where -- one and two elements `𝟙 `Bit : `★ -- 'n' elements `Fin : ℕ → `★ -- one element more `Maybe : `★ → `★ -- products and co-products _`×_ _`⊎_ : `★ → `★ → `★ -- dependent pairs `Σ : (s : `★) → (El s → `★) → `★ -- vectors `Vec : `★ → ℕ → `★ -- functions _`→_ : `★⁻ → `★ → `★ -- decoding of positive types El `𝟙 = 𝟙 El `Bit = Bit El (`Fin n) = Fin n El (`Maybe t) = Maybe (El t) El (s `× t) = El s × El t El (s `⊎ t) = El s ⊎ El t El (`Σ s t) = Σ (El s) λ x → El (t x) El (s `→ t) = El⁻ s → El t El (`Vec t n) = Vec (El t) n `Bits = `Vec `Bit `S : ∀ `A → S (El `A) `S `𝟙 = S𝟙 `S `Bit = SBit `S (`Fin n) = SFin n `S (`Maybe `A) = SMaybe (`S `A) `S (`A `× `B) = `S `A S× `S `B `S (`A `⊎ `B) = `S `A S⊎ `S `B `S (`Σ `A `B) = SΣ (`S `A) λ x → `S (`B x) `S (`Vec `A n) = SVec (`S `A) n `S (`A `→ `B) = `S⟨ `A ⟩→ `S `B
{ "alphanum_fraction": 0.3827160494, "avg_line_length": 21.4826086957, "ext": "agda", "hexsha": "514ef9f8299b8064d1508325d2a90e6db9676b27", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/TODO/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/TODO/Syntax.agda", "max_line_length": 61, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/TODO/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 2454, "size": 4941 }
{-# OPTIONS --no-termination-check #-} module Pi-abstract-machine where open import Data.Empty open import Data.Unit open import Data.Sum hiding (map) open import Data.Product hiding (map) infixr 30 _⟷_ infixr 30 _⟺_ infixr 20 _◎_ ------------------------------------------------------------------------------ -- A universe of our value types data B : Set where ZERO : B ONE : B PLUS : B → B → B TIMES : B → B → B data VB : (b : B) → Set where unitB : VB ONE inlB : {b₁ b₂ : B} → VB b₁ → VB (PLUS b₁ b₂) inrB : {b₁ b₂ : B} → VB b₂ → VB (PLUS b₁ b₂) pairB : {b₁ b₂ : B} → VB b₁ → VB b₂ → VB (TIMES b₁ b₂) ------------------------------------------------------------------------------ -- Primitive isomorphisms data _⟷_ : B → B → Set where -- (+,0) commutative monoid unite₊ : { b : B } → PLUS ZERO b ⟷ b uniti₊ : { b : B } → b ⟷ PLUS ZERO b swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁ assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃ assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃) -- (*,1) commutative monoid unite⋆ : { b : B } → TIMES ONE b ⟷ b uniti⋆ : { b : B } → b ⟷ TIMES ONE b swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁ assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃ assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃) -- * distributes over + dist : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) factor : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃ -- id id⟷ : { b : B } → b ⟷ b adjointP : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) adjointP unite₊ = uniti₊ adjointP uniti₊ = unite₊ adjointP swap₊ = swap₊ adjointP assocl₊ = assocr₊ adjointP assocr₊ = assocl₊ adjointP unite⋆ = uniti⋆ adjointP uniti⋆ = unite⋆ adjointP swap⋆ = swap⋆ adjointP assocl⋆ = assocr⋆ adjointP assocr⋆ = assocl⋆ adjointP dist = factor adjointP factor = dist adjointP id⟷ = id⟷ evalP : { b₁ b₂ : B } → (b₁ ⟷ b₂) → VB b₁ → VB b₂ evalP unite₊ (inlB ()) evalP unite₊ (inrB v) = v evalP uniti₊ v = inrB v evalP swap₊ (inlB v) = inrB v evalP swap₊ (inrB v) = inlB v evalP assocl₊ (inlB v) = inlB (inlB v) evalP assocl₊ (inrB (inlB v)) = inlB (inrB v) evalP assocl₊ (inrB (inrB v)) = inrB v evalP assocr₊ (inlB (inlB v)) = inlB v evalP assocr₊ (inlB (inrB v)) = inrB (inlB v) evalP assocr₊ (inrB v) = inrB (inrB v) evalP unite⋆ (pairB unitB v) = v evalP uniti⋆ v = (pairB unitB v) evalP swap⋆ (pairB v₁ v₂) = pairB v₂ v₁ evalP assocl⋆ (pairB v₁ (pairB v₂ v₃)) = pairB (pairB v₁ v₂) v₃ evalP assocr⋆ (pairB (pairB v₁ v₂) v₃) = pairB v₁ (pairB v₂ v₃) evalP dist (pairB (inlB v₁) v₃) = inlB (pairB v₁ v₃) evalP dist (pairB (inrB v₂) v₃) = inrB (pairB v₂ v₃) evalP factor (inlB (pairB v₁ v₃)) = pairB (inlB v₁) v₃ evalP factor (inrB (pairB v₂ v₃)) = pairB (inrB v₂) v₃ evalP id⟷ v = v -- Backwards evaluator bevalP : { b₁ b₂ : B } → (b₁ ⟷ b₂) → VB b₂ → VB b₁ bevalP c v = evalP (adjointP c) v ------------------------------------------------------------------------------ -- Closure combinators data _⟺_ : B → B → Set where iso : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₁ ⟺ b₂) sym : { b₁ b₂ : B } → (b₁ ⟺ b₂) → (b₂ ⟺ b₁) _◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟺ b₂) → (b₂ ⟺ b₃) → (b₁ ⟺ b₃) _⊕_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟺ b₃) → (b₂ ⟺ b₄) → (PLUS b₁ b₂ ⟺ PLUS b₃ b₄) _⊗_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟺ b₃) → (b₂ ⟺ b₄) → (TIMES b₁ b₂ ⟺ TIMES b₃ b₄) -- adjoint : { b₁ b₂ : B } → (b₁ ⟺ b₂) → (b₂ ⟺ b₁) adjoint (iso c) = iso (adjointP c) adjoint (sym c) = c adjoint (c₁ ◎ c₂) = adjoint c₂ ◎ adjoint c₁ adjoint (c₁ ⊕ c₂) = adjoint c₁ ⊕ adjoint c₂ adjoint (c₁ ⊗ c₂) = adjoint c₁ ⊗ adjoint c₂ ------------------------------------------------------------------------------ -- Operational semantics -- (Context a b c d) represents a combinator (c <=> d) with a hole -- requiring something of type (a <=> b). When we use these contexts, -- it is always the case that the (c <=> a) part of the computation -- has ALREADY been done and that we are about to evaluate (a <=> b) -- using a given 'a'. The continuation takes the output 'b' and -- produces a 'd'. data Context : B → B → B → B → Set where emptyC : {a b : B} → Context a b a b seqC₁ : {a b c i o : B} → (b ⟺ c) → Context a c i o → Context a b i o seqC₂ : {a b c i o : B} → (a ⟺ b) → Context a c i o → Context b c i o leftC : {a b c d i o : B} → (c ⟺ d) → Context (PLUS a c) (PLUS b d) i o → Context a b i o rightC : {a b c d i o : B} → (a ⟺ b) → Context (PLUS a c) (PLUS b d) i o → Context c d i o -- the (i <-> a) part of the computation is completely done; so we must store -- the value of type [[ c ]] as part of the context fstC : {a b c d i o : B} → VB c → (c ⟺ d) → Context (TIMES a c) (TIMES b d) i o → Context a b i o -- the (i <-> c) part of the computation and the (a <-> b) part of -- the computation are completely done; so we must store the value -- of type [[ b ]] as part of the context sndC : {a b c d i o : B} → (a ⟺ b) → VB b → Context (TIMES a c) (TIMES b d) i o → Context c d i o -- Small-step evaluation -- A computation (c <=> d) is split into: -- - a history (c <==> a) -- - a current computation in focus (a <==> b) -- - a future (b <==> d) record BState (a b c d : B) : Set where constructor <_!_!_> field comb : a ⟺ b val : VB a context : Context a b c d record AState (a b c d : B) : Set where constructor [_!_!_] field comb : a ⟺ b val : VB b context : Context a b c d data State (d : B) : Set where before : {a b c : B} → BState a b c d → State d after : {a b c : B} → AState a b c d → State d final : VB d → State d -- The (c <=> a) part of the computation has been done. -- We are about to perform the (a <=> b) part of the computation. beforeStep : {a b c d : B} → BState a b c d → State d beforeStep < iso f ! v ! C > = after [ iso f ! (evalP f v) ! C ] beforeStep < sym c ! v ! C > = before < adjoint c ! v ! C > beforeStep < _◎_ {b₂ = _} f g ! v ! C > = before < f ! v ! seqC₁ g C > beforeStep < _⊕_ {b₁} {b₂} {b₃} {b₄} f g ! inlB v ! C > = before < f ! v ! leftC g C > beforeStep < _⊕_ {b₁} {b₂} {b₃} {b₄} f g ! inrB v ! C > = before < g ! v ! rightC f C > beforeStep < _⊗_ f g ! (pairB v₁ v₂ ) ! C > = before < f ! v₁ ! fstC v₂ g C > -- The (c <=> a) part of the computation has been done. -- The (a <=> b) part of the computation has been done. -- We need to examine the context to get the 'd'. -- We rebuild the combinator on the way out. afterStep : {a b c d : B} → AState a b c d → State d afterStep {d = d} [ f ! v ! emptyC ] = final v afterStep [ f ! v ! seqC₁ g C ] = before < g ! v ! seqC₂ f C > afterStep [ g ! v ! seqC₂ f C ] = after [ f ◎ g ! v ! C ] afterStep [ f ! v ! leftC g C ] = after [ f ⊕ g ! inlB v ! C ] afterStep [ g ! v ! rightC f C ] = after [ f ⊕ g ! inrB v ! C ] afterStep [ f ! v₁ ! fstC v₂ g C ] = before < g ! v₂ ! sndC f v₁ C > afterStep [ g ! v₂ ! sndC f v₁ C ] = after [ f ⊗ g ! (pairB v₁ v₂) ! C ] -- Backwards evaluator -- Re-use AState and BState, but use them 'backwards' -- this one is different as it produces a 'c' rather than a 'd' data Stateb (c : B) : Set where before : {a b d : B} → AState a b c d → Stateb c after : {a b d : B} → BState a b c d → Stateb c final : VB c → Stateb c -- The (d <=> b) part of the computation has been done. -- We have a 'b' and we are about to do the (a <=> b) computation backwards. -- We get an 'a' and examine the context to get the 'c' beforeStepb : { a b c d : B } → AState a b c d → Stateb c beforeStepb [ iso f ! v ! C ] = after < iso f ! bevalP f v ! C > beforeStepb [ sym c ! v ! C ] = before [ adjoint c ! v ! C ] beforeStepb [ f ◎ g ! v ! C ] = before [ g ! v ! seqC₂ f C ] beforeStepb [ f ⊕ g ! inlB v ! C ] = before [ f ! v ! leftC g C ] beforeStepb [ f ⊕ g ! inrB v ! C ] = before [ g ! v ! rightC f C ] beforeStepb [ f ⊗ g ! pairB v₁ v₂ ! C ] = before [ g ! v₂ ! sndC f v₁ C ] -- The (d <-> b) part of the computation has been done. -- The (a <-> b) backwards computation has been done. -- We have an 'a' and examine the context to get the 'c' afterStepb : { a b c d : B } → BState a b c d → Stateb c afterStepb < f ! v ! emptyC > = final v afterStepb < g ! v ! seqC₂ f C > = before [ f ! v ! seqC₁ g C ] afterStepb < f ! v ! seqC₁ g C > = after < f ◎ g ! v ! C > afterStepb < f ! v ! leftC g C > = after < f ⊕ g ! inlB v ! C > afterStepb < g ! v ! rightC f C > = after < f ⊕ g ! inrB v ! C > afterStepb < g ! v₂ ! sndC f v₁ C > = before [ f ! v₁ ! fstC v₂ g C ] afterStepb < f ! v₁ ! fstC v₂ g C > = after < f ⊗ g ! pairB v₁ v₂ ! C > ------------------------------------------------------------------------------ -- A single step of a machine step : {d : B} → State d → State d step (before st) = beforeStep st step (after st) = afterStep st step (final v) = final v stepb : {c : B} → Stateb c → Stateb c stepb (before st) = beforeStepb st stepb (after st) = afterStepb st stepb (final v) = final v -- Forward and backwards evaluators loop until final state eval : {a b : B} → (a ⟺ b) → VB a → VB b eval f v = loop (before < f ! v ! emptyC > ) where loop : {b : B} → State b → VB b loop (final v) = v loop st = loop (step st) evalb : {a b : B} → (a ⟺ b) → VB b → VB a evalb f v = loop (before [ f ! v ! emptyC ] ) where loop : {b : B} → Stateb b → VB b loop (final v) = v loop st = loop (stepb st) ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5366410629, "avg_line_length": 37.6328125, "ext": "agda", "hexsha": "b013c62ef15f9a7dc68f84cec4b5b230e7147eab", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/Pi-abstract-machine.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/Pi-abstract-machine.agda", "max_line_length": 88, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/Pi-abstract-machine.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3917, "size": 9634 }
------------------------------------------------------------------------------ -- Well-founded induction on the lexicographic order on natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From the thesis: The induction principle $\Conid{Lexi-wfind}$ is -- proved by well-founded induction on the usual order $\Conid{LT}$ on -- (partial) natural numbers which, in turn, can be proved by pattern -- matching on the proof that the numbers are total. module FOT.FOTC.Data.Nat.Induction.NonAcc.LexicographicI where open import FOTC.Base open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesI open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.Induction.NonAcc.WF-I open module WFI = FOTC.Data.Nat.Induction.NonAcc.WF-I.WFInd open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ Lexi-wfind : (A : D → D → Set) → (∀ {m₁ n₁} → N m₁ → N n₁ → (∀ {m₂ n₂} → N m₂ → N n₂ → Lexi m₂ n₂ m₁ n₁ → A m₂ n₂) → A m₁ n₁) → ∀ {m n} → N m → N n → A m n Lexi-wfind A h {m} Nm Nn = <-wfind {!!} {!!} {!!}
{ "alphanum_fraction": 0.5479452055, "avg_line_length": 38.5277777778, "ext": "agda", "hexsha": "e17e6c48cb3157a95f0b325ab979cb67a5ef4ac1", "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/Induction/NonAcc/LexicographicI.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/Induction/NonAcc/LexicographicI.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/Induction/NonAcc/LexicographicI.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": 369, "size": 1387 }
{-# OPTIONS --without-K #-} module Circuits where open import PiLevel0 using (U; ZERO; ONE; PLUS; TIMES; BOOL; BOOL²; _⟷_; unite₊; uniti₊; swap₊; assocl₊; assocr₊; unite⋆; uniti⋆; swap⋆; assocl⋆; assocr⋆; absorbr; absorbl; factorzr; factorzl; dist; factor; id⟷; _◎_; _⊕_; _⊗_; _⟷⟨_⟩_; _□; NOT; CNOT; TOFFOLI) ------------------------------------------------------------------------------ SWAP : BOOL² ⟷ BOOL² SWAP = swap⋆ CONTROL : {t : U} → (t ⟷ t) → (TIMES BOOL t ⟷ TIMES BOOL t) CONTROL {t} f = TIMES BOOL t ⟷⟨ id⟷ ⟩ TIMES (PLUS x y) t ⟷⟨ dist ⟩ PLUS (TIMES x t) (TIMES y t) ⟷⟨ id⟷ ⊕ (id⟷ ⊗ f) ⟩ PLUS (TIMES x t) (TIMES y t) ⟷⟨ factor ⟩ TIMES (PLUS x y) t ⟷⟨ id⟷ ⟩ TIMES BOOL t □ where x = ONE; y = ONE FREDKIN : TIMES BOOL BOOL² ⟷ TIMES BOOL BOOL² FREDKIN = CONTROL SWAP ------------------------------------------------------------------------------ -- Fig. 4 in http://arxiv.org/pdf/1110.2574v2.pdf -- (e) cycles -- (c) reversible truth table ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3870967742, "avg_line_length": 27.6304347826, "ext": "agda", "hexsha": "29f8e9810eab9bc3dcb59a5353cd74d2f7e5e733", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Circuits.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Circuits.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Circuits.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 399, "size": 1271 }
{-# OPTIONS --without-K --safe #-} module Fragment.Examples.CSemigroup.Arith.Functions where open import Fragment.Examples.CSemigroup.Arith.Base -- Fully dynamic associativity +-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m + n) + o ≡ f m + (n + o) +-dyn-assoc₁ = fragment CSemigroupFrex +-csemigroup +-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m + n) + o) + g p ≡ f m + (n + (o + g p)) +-dyn-assoc₂ = fragment CSemigroupFrex +-csemigroup +-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m + n) + g o + (p + h q) ≡ f m + (n + g o + p) + h q +-dyn-assoc₃ = fragment CSemigroupFrex +-csemigroup *-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m * n) * o ≡ f m * (n * o) *-dyn-assoc₁ = fragment CSemigroupFrex *-csemigroup *-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m * n) * o) * g p ≡ f m * (n * (o * g p)) *-dyn-assoc₂ = fragment CSemigroupFrex *-csemigroup *-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m * n) * g o * (p * h q) ≡ f m * (n * g o * p) * h q *-dyn-assoc₃ = fragment CSemigroupFrex *-csemigroup -- Fully dynamic commutativity +-dyn-comm₁ : ∀ {f : ℕ → ℕ} {m} → f m + m ≡ m + f m +-dyn-comm₁ = fragment CSemigroupFrex +-csemigroup +-dyn-comm₂ : ∀ {f g : ℕ → ℕ} {m n o} → f m + (n + g o) ≡ (g o + n) + f m +-dyn-comm₂ = fragment CSemigroupFrex +-csemigroup +-dyn-comm₃ : ∀ {f g h : ℕ → ℕ} {m n o p} → (f m + g n) + (h o + p) ≡ (p + h o) + (g n + f m) +-dyn-comm₃ = fragment CSemigroupFrex +-csemigroup *-dyn-comm₁ : ∀ {f : ℕ → ℕ} {m} → f m * m ≡ m * f m *-dyn-comm₁ = fragment CSemigroupFrex *-csemigroup *-dyn-comm₂ : ∀ {f g : ℕ → ℕ} {m n o} → f m * (n * g o) ≡ (g o * n) * f m *-dyn-comm₂ = fragment CSemigroupFrex *-csemigroup *-dyn-comm₃ : ∀ {f g h : ℕ → ℕ} {m n o p} → (f m * g n) * (h o * p) ≡ (p * h o) * (g n * f m) *-dyn-comm₃ = fragment CSemigroupFrex *-csemigroup -- Fully dynamic associavity and commutativity +-dyn-comm-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (f m + f (f m)) + f (f (f m)) ≡ f (f (f m)) + (f (f m) + f m) +-dyn-comm-assoc₁ = fragment CSemigroupFrex +-csemigroup +-dyn-comm-assoc₂ : ∀ {f g : ℕ → ℕ} {m n} → ((f m + f n) + g m) + g n ≡ g m + (f n + (g n + f m)) +-dyn-comm-assoc₂ = fragment CSemigroupFrex +-csemigroup +-dyn-comm-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p q} → f (m + n) + o + (p + q) ≡ f (m + n) + q + (p + o) +-dyn-comm-assoc₃ = fragment CSemigroupFrex +-csemigroup *-dyn-comm-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (f m * f (f m)) * f (f (f m)) ≡ f (f (f m)) * (f (f m) * f m) *-dyn-comm-assoc₁ = fragment CSemigroupFrex *-csemigroup *-dyn-comm-assoc₂ : ∀ {f g : ℕ → ℕ} {m n} → ((f m * f n) * g m) * g n ≡ g m * (f n * (g n * f m)) *-dyn-comm-assoc₂ = fragment CSemigroupFrex *-csemigroup *-dyn-comm-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p q} → f (m + n) * o * (p * q) ≡ f (m + n) * q * (p * o) *-dyn-comm-assoc₃ = fragment CSemigroupFrex *-csemigroup -- Partially static associativity +-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m + 2) + (3 + f 0) ≡ m + (5 + f 0) +-sta-assoc₁ = fragment CSemigroupFrex +-csemigroup +-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m + g n) + 5) + o) + p ≡ f m + (g n + (2 + (3 + (o + p)))) +-sta-assoc₂ = fragment CSemigroupFrex +-csemigroup +-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) + (n + 2) + (3 + (o + p)) ≡ (((n + 1) + (4 + o)) + p) + f (n + m) +-sta-assoc₃ = fragment CSemigroupFrex +-csemigroup *-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m * 2) * (3 * f 0) ≡ m * (6 * f 0) *-sta-assoc₁ = fragment CSemigroupFrex *-csemigroup *-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m * g n) * 6) * o) * p ≡ f m * (g n * (2 * (3 * (o * p)))) *-sta-assoc₂ = fragment CSemigroupFrex *-csemigroup *-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) * (n * 4) * (3 * (o * p)) ≡ (((n * 2) * (6 * o)) * p) * f (n + m) *-sta-assoc₃ = fragment CSemigroupFrex *-csemigroup -- Partially static commutativity +-sta-comm₁ : ∀ {f g : ℕ → ℕ} {m} → f m + g 1 ≡ g 1 + f m +-sta-comm₁ = fragment CSemigroupFrex +-csemigroup +-sta-comm₂ : ∀ {f g : ℕ → ℕ} {m n} → f m + (2 + g n) ≡ (g n + 2) + f m +-sta-comm₂ = fragment CSemigroupFrex +-csemigroup +-sta-comm₃ : ∀ {f g h : ℕ → ℕ} {m n o p} → (1 + (f m + g n)) + ((o + p) + h 2) ≡ ((p + o) + h 2) + (1 + (g n + f m)) +-sta-comm₃ = fragment CSemigroupFrex +-csemigroup *-sta-comm₁ : ∀ {f g : ℕ → ℕ} {m} → f m * g 1 ≡ g 1 * f m *-sta-comm₁ = fragment CSemigroupFrex *-csemigroup *-sta-comm₂ : ∀ {f g : ℕ → ℕ} {m n} → f m * (2 * g n) ≡ (g n * 2) * f m *-sta-comm₂ = fragment CSemigroupFrex *-csemigroup *-sta-comm₃ : ∀ {f g h : ℕ → ℕ} {m n o p} → (3 * (f m * g n)) * ((o * p) * h 2) ≡ ((p * o) * h 2) * (3 * (g n * f m)) *-sta-comm₃ = fragment CSemigroupFrex *-csemigroup -- Partially static associavity and commutativity +-sta-comm-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → 1 + (f m + n) + f o + 4 ≡ 5 + n + (f m + f o) +-sta-comm-assoc₁ = fragment CSemigroupFrex +-csemigroup +-sta-comm-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → 5 + ((f m + n) + o) + g p ≡ g p + ((o + 1) + (n + f m)) + 4 +-sta-comm-assoc₂ = fragment CSemigroupFrex +-csemigroup +-sta-comm-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m + g n + 1) + o + (p + h q + 4) ≡ (2 + h q) + (p + o + g n) + (f m + 3) +-sta-comm-assoc₃ = fragment CSemigroupFrex +-csemigroup *-sta-comm-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → 2 * (f m * n) * f o * 6 ≡ 12 * n * (f m * f o) *-sta-comm-assoc₁ = fragment CSemigroupFrex *-csemigroup *-sta-comm-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → 12 * ((f m * n) * o) * g p ≡ g p * ((o * 2) * (n * f m)) * 6 *-sta-comm-assoc₂ = fragment CSemigroupFrex *-csemigroup *-sta-comm-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m * g n * 2) * o * (p * h q * 6) ≡ (4 * h q) * (p * o * g n) * (f m * 3) *-sta-comm-assoc₃ = fragment CSemigroupFrex *-csemigroup
{ "alphanum_fraction": 0.5143769968, "avg_line_length": 44.7142857143, "ext": "agda", "hexsha": "981a4bbba00714529cabb0bbfa8cc2d9680281a8", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Functions.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Functions.agda", "max_line_length": 127, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Functions.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": 2564, "size": 5634 }
{- This second-order equational theory was created from the following second-order syntax description: syntax QIO type T : 0-ary P : 0-ary term new : P.T -> T measure : P T T -> T applyX : P P.T -> T applyI2 : P P.T -> T applyDuv : P P (P,P).T -> T applyDu : P P.T -> T applyDv : P P.T -> T theory (A) a:P t u:T |> applyX (a, b.measure(b, t, u)) = measure(a, u, t) (B) a:P b:P t u:P.T |> measure(a, applyDu(b, b.t[b]), applyDv(b, b.u[b])) = applyDuv(a, b, a b.measure(a, t[b], u[b])) (D) t u:T |> new(a.measure(a, t, u)) = t (E) b:P t:(P, P).T |> new(a.applyDuv(a, b, a b. t[a,b])) = applyDu(b, b.new(a.t[a,b])) -} module QIO.Equality where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Families.Build open import SOAS.ContextMaps.Inductive open import QIO.Signature open import QIO.Syntax open import SOAS.Metatheory.SecondOrder.Metasubstitution QIO:Syn open import SOAS.Metatheory.SecondOrder.Equality QIO:Syn private variable α β γ τ : QIOT Γ Δ Π : Ctx infix 1 _▹_⊢_≋ₐ_ -- Axioms of equality data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ QIO) α Γ → (𝔐 ▷ QIO) α Γ → Set where A : ⁅ P ⁆ ⁅ T ⁆ ⁅ T ⁆̣ ▹ ∅ ⊢ applyX 𝔞 (measure x₀ 𝔟 𝔠) ≋ₐ measure 𝔞 𝔠 𝔟 B : ⁅ P ⁆ ⁅ P ⁆ ⁅ P ⊩ T ⁆ ⁅ P ⊩ T ⁆̣ ▹ ∅ ⊢ measure 𝔞 (applyDu 𝔟 (𝔠⟨ x₀ ⟩)) (applyDv 𝔟 (𝔡⟨ x₀ ⟩)) ≋ₐ applyDuv 𝔞 𝔟 (measure x₀ (𝔠⟨ x₁ ⟩) (𝔡⟨ x₁ ⟩)) D : ⁅ T ⁆ ⁅ T ⁆̣ ▹ ∅ ⊢ new (measure x₀ 𝔞 𝔟) ≋ₐ 𝔞 E : ⁅ P ⁆ ⁅ P · P ⊩ T ⁆̣ ▹ ∅ ⊢ new (applyDuv x₀ 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩)) ≋ₐ applyDu 𝔞 (new (𝔟⟨ x₀ ◂ x₁ ⟩)) open EqLogic _▹_⊢_≋ₐ_ open ≋-Reasoning
{ "alphanum_fraction": 0.5239154616, "avg_line_length": 30.4745762712, "ext": "agda", "hexsha": "2b06f7a211f561346672c9a21f3927235bd969e2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "out/QIO/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "k4rtik/agda-soas", "max_issues_repo_path": "out/QIO/Equality.agda", "max_line_length": 147, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "out/QIO/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 819, "size": 1798 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT import homotopy.ConstantToSetExtendsToProp as ConstExt module homotopy.RelativelyConstantToSetExtendsViaSurjection {i j k} {A : Type i} {B : Type j} {C : B → Type k} (C-is-set : ∀ b → is-set (C b)) (f : A → B) (f-is-surj : is-surj f) (g : (a : A) → C (f a)) (g-is-const : ∀ a₁ a₂ → (p : f a₁ == f a₂) → g a₁ == g a₂ [ C ↓ p ]) where {- (b : A) ----> [ hfiber f b ] ----?----> C ? ^ | hfiber f b -} private lemma : ∀ b → hfiber f b → C b lemma b (a , fa=b) = transport C fa=b (g a) lemma-const : ∀ b → (h₁ h₂ : hfiber f b) → lemma b h₁ == lemma b h₂ lemma-const ._ (a₁ , fa₁=fa₂) (a₂ , idp) = to-transp (g-is-const a₁ a₂ fa₁=fa₂) module CE (b : B) = ConstExt {A = hfiber f b} {B = C b} (C-is-set b) (lemma b) (lemma-const b) ext : Π B C ext b = CE.ext b (f-is-surj b) β : (a : A) → ext (f a) == g a β a = ap (CE.ext (f a)) (prop-has-all-paths Trunc-level (f-is-surj (f a)) [ a , idp ])
{ "alphanum_fraction": 0.4898148148, "avg_line_length": 27.6923076923, "ext": "agda", "hexsha": "dffde1ba9182c6750cd086971b51dc3b828c8cdb", "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": "theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.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": "theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.agda", "max_line_length": 71, "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": "theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 420, "size": 1080 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Ints.IsoInt where open import Cubical.HITs.Ints.IsoInt.Base public
{ "alphanum_fraction": 0.7428571429, "avg_line_length": 23.3333333333, "ext": "agda", "hexsha": "1aab2919fe39b56e402401970a87216a05a86d19", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/Ints/IsoInt.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/HITs/Ints/IsoInt.agda", "max_line_length": 50, "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/HITs/Ints/IsoInt.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 42, "size": 140 }
------------------------------------------------------------------------------ -- Testing an alternative definition of subtraction ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.SubtractionSL where open import Data.Nat hiding ( _∸_ ) open import Relation.Binary.PropositionalEquality -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Data/Nat.agda). infixl 9 _∸₁_ _∸₂_ -- First definition (from the Agda standard library 0.8.1). _∸₁_ : ℕ → ℕ → ℕ m ∸₁ zero = m zero ∸₁ suc n = zero suc m ∸₁ suc n = m ∸₁ n -- Second definition. _∸₂_ : ℕ → ℕ → ℕ m ∸₂ zero = m {-# CATCHALL #-} zero ∸₂ n = zero suc m ∸₂ suc n = m ∸₂ n -- Both definitions are equivalents. thm : ∀ m n → m ∸₁ n ≡ m ∸₂ n thm m zero = refl thm zero (suc n) = refl thm (suc m) (suc n) = thm m n
{ "alphanum_fraction": 0.5076923077, "avg_line_length": 28.1081081081, "ext": "agda", "hexsha": "29a804add2c7fb3a1d1de8359e1f0638cf27f769", "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/SubtractionSL.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/SubtractionSL.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/SubtractionSL.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": 310, "size": 1040 }
module Issue2579.Import where record Wrap A : Set where constructor wrap field wrapped : A
{ "alphanum_fraction": 0.7604166667, "avg_line_length": 16, "ext": "agda", "hexsha": "da74d9e70e6e38ba242912dd7127bdaa3814f35f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/Succeed/Issue2579/Import.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/Succeed/Issue2579/Import.agda", "max_line_length": 29, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/Succeed/Issue2579/Import.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 24, "size": 96 }
{-# OPTIONS --show-implicit #-} module PragmasRespected where postulate Foo : {A : Set₁} → Set Bar : Foo {A = Set} -- Andreas, 2014-10-20, AIM XX: -- This test used to check that the --show-implicit option -- is turned on even if the module is just reloaded from -- an interface file. -- However, as we now always recheck when reload, -- this test should now trivially succeed.
{ "alphanum_fraction": 0.6961038961, "avg_line_length": 25.6666666667, "ext": "agda", "hexsha": "a12daa5a7304f5dd19802870f6672f4b3f4332e0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/PragmasRespected.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/PragmasRespected.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/PragmasRespected.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 107, "size": 385 }
------------------------------------------------------------------------------ -- Totality of Boolean conjunction ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Bool.AndTotality where open import FOTC.Base open import FOTC.Data.Bool.Type ------------------------------------------------------------------------------ postulate thm : (A : D → Set) → ∀ {b} → (Bool b ∧ A true ∧ A false) → A b -- Because the ATPs don't handle induction, them cannot prove the -- induction principle for Bool. -- {-# ATP prove thm #-} postulate thm₁ : {A : D → Set} → ∀ {x y z} → Bool x → A y → A z → A (if x then y else z) -- Because the ATPs don't handle induction, them cannot prove this postulate. -- {-# ATP prove thm₁ #-} -- Typing of the if-then-else. if-T : (A : D → Set) → ∀ {x y z} → Bool x → A y → A z → A (if x then y else z) if-T A {y = y} btrue Ay Az = subst A (sym (if-true y)) Ay if-T A {z = z} bfalse Ay Az = subst A (sym (if-false z)) Az _&&_ : D → D → D x && y = if x then y else false {-# ATP definition _&&_ #-} postulate &&-Bool : ∀ {x y} → Bool x → Bool y → Bool (x && y) {-# ATP prove &&-Bool if-T #-} &&-Bool₁ : ∀ {x y} → Bool x → Bool y → Bool (x && y) &&-Bool₁ {y = y} btrue By = prf where postulate prf : Bool (true && y) {-# ATP prove prf if-T #-} &&-Bool₁ {y = y} bfalse By = prf where postulate prf : Bool (false && y) {-# ATP prove prf if-T #-} &&-Bool₂ : ∀ {x y} → Bool x → Bool y → Bool (x && y) &&-Bool₂ btrue By = if-T Bool btrue By bfalse &&-Bool₂ bfalse By = if-T Bool bfalse By bfalse
{ "alphanum_fraction": 0.4884246189, "avg_line_length": 33.4150943396, "ext": "agda", "hexsha": "fa45b103251567a5a6597ffd09b6d1207ef7b61d", "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/Bool/AndTotality.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/Bool/AndTotality.agda", "max_line_length": 80, "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/Bool/AndTotality.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": 526, "size": 1771 }
{-# OPTIONS --without-K --exact-split #-} module 16-sets where import 15-groups open 15-groups public {- Equivalence relations -} Rel-Prop : (l : Level) {l1 : Level} (A : UU l1) → UU ((lsuc l) ⊔ l1) Rel-Prop l A = A → (A → UU-Prop l) type-Rel-Prop : {l1 l2 : Level} {A : UU l1} (R : Rel-Prop l2 A) → A → A → UU l2 type-Rel-Prop R x y = pr1 (R x y) is-prop-type-Rel-Prop : {l1 l2 : Level} {A : UU l1} (R : Rel-Prop l2 A) → (x y : A) → is-prop (type-Rel-Prop R x y) is-prop-type-Rel-Prop R x y = pr2 (R x y) is-reflexive-Rel-Prop : {l1 l2 : Level} {A : UU l1} → Rel-Prop l2 A → UU (l1 ⊔ l2) is-reflexive-Rel-Prop {A = A} R = (x : A) → type-Rel-Prop R x x is-symmetric-Rel-Prop : {l1 l2 : Level} {A : UU l1} → Rel-Prop l2 A → UU (l1 ⊔ l2) is-symmetric-Rel-Prop {A = A} R = (x y : A) → type-Rel-Prop R x y → type-Rel-Prop R y x is-transitive-Rel-Prop : {l1 l2 : Level} {A : UU l1} → Rel-Prop l2 A → UU (l1 ⊔ l2) is-transitive-Rel-Prop {A = A} R = (x y z : A) → type-Rel-Prop R x y → type-Rel-Prop R y z → type-Rel-Prop R x z is-equivalence-relation : {l1 l2 : Level} {A : UU l1} (R : Rel-Prop l2 A) → UU (l1 ⊔ l2) is-equivalence-relation R = is-reflexive-Rel-Prop R × ( is-symmetric-Rel-Prop R × is-transitive-Rel-Prop R) Eq-Rel : (l : Level) {l1 : Level} (A : UU l1) → UU ((lsuc l) ⊔ l1) Eq-Rel l A = Σ (Rel-Prop l A) is-equivalence-relation rel-prop-Eq-Rel : {l1 l2 : Level} {A : UU l1} → Eq-Rel l2 A → Rel-Prop l2 A rel-prop-Eq-Rel = pr1 type-Eq-Rel : {l1 l2 : Level} {A : UU l1} → Eq-Rel l2 A → A → A → UU l2 type-Eq-Rel R = type-Rel-Prop (rel-prop-Eq-Rel R) is-equivalence-relation-rel-prop-Eq-Rel : {l1 l2 : Level} {A : UU l1} (R : Eq-Rel l2 A) → is-equivalence-relation (rel-prop-Eq-Rel R) is-equivalence-relation-rel-prop-Eq-Rel R = pr2 R refl-Eq-Rel : {l1 l2 : Level} {A : UU l1} (R : Eq-Rel l2 A) → is-reflexive-Rel-Prop (rel-prop-Eq-Rel R) refl-Eq-Rel R = pr1 (is-equivalence-relation-rel-prop-Eq-Rel R) symm-Eq-Rel : {l1 l2 : Level} {A : UU l1} (R : Eq-Rel l2 A) → is-symmetric-Rel-Prop (rel-prop-Eq-Rel R) symm-Eq-Rel R = pr1 (pr2 (is-equivalence-relation-rel-prop-Eq-Rel R)) trans-Eq-Rel : {l1 l2 : Level} {A : UU l1} (R : Eq-Rel l2 A) → is-transitive-Rel-Prop (rel-prop-Eq-Rel R) trans-Eq-Rel R = pr2 (pr2 (is-equivalence-relation-rel-prop-Eq-Rel R)) {- Section 15.2 The universal property of set quotients -} identifies-Eq-Rel : {l1 l2 l3 : Level} {A : UU l1} (R : Eq-Rel l2 A) → {B : UU l3} → (A → B) → UU (l1 ⊔ (l2 ⊔ l3)) identifies-Eq-Rel {A = A} R f = (x y : A) → type-Eq-Rel R x y → Id (f x) (f y) precomp-map-universal-property-Eq-Rel : {l l1 l2 l3 : Level} {A : UU l1} (R : Eq-Rel l2 A) {B : UU-Set l3} (f : A → type-Set B) (H : identifies-Eq-Rel R f) → (X : UU-Set l) → (type-hom-Set B X) → Σ (A → type-Set X) (identifies-Eq-Rel R) precomp-map-universal-property-Eq-Rel R f H X g = pair (g ∘ f) (λ x y r → ap g (H x y r)) universal-property-set-quotient : (l : Level) {l1 l2 l3 : Level} {A : UU l1} (R : Eq-Rel l2 A) {B : UU-Set l3} (f : A → type-Set B) (H : identifies-Eq-Rel R f) → UU _ universal-property-set-quotient l R {B} f H = (X : UU-Set l) → is-equiv (precomp-map-universal-property-Eq-Rel R {B} f H X) {- Effective quotients -} is-effective-Set-Quotient : {l1 l2 l3 : Level} {A : UU l1} (R : Eq-Rel l2 A) (B : UU-Set l3) (f : A → type-Set B) (H : identifies-Eq-Rel R f) → UU (l1 ⊔ l2 ⊔ l3) is-effective-Set-Quotient {A = A} R B f H = (x y : A) → is-equiv (H x y) -- Section 13.4 is-small : (l : Level) {l1 : Level} (A : UU l1) → UU (lsuc l ⊔ l1) is-small l A = Σ (UU l) (λ X → A ≃ X) is-small-map : (l : Level) {l1 l2 : Level} {A : UU l1} {B : UU l2} → (A → B) → UU (lsuc l ⊔ (l1 ⊔ l2)) is-small-map l {B = B} f = (b : B) → is-small l (fib f b) is-locally-small : (l : Level) {l1 : Level} (A : UU l1) → UU (lsuc l ⊔ l1) is-locally-small l A = (x y : A) → is-small l (Id x y) total-subtype : {l1 l2 : Level} {A : UU l1} (P : A → UU-Prop l2) → UU (l1 ⊔ l2) total-subtype {A = A} P = Σ A (λ x → pr1 (P x)) equiv-subtype-equiv : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} (e : A ≃ B) (C : A → UU-Prop l3) (D : B → UU-Prop l4) → ((x : A) → (C x) ↔ (D (map-equiv e x))) → total-subtype C ≃ total-subtype D equiv-subtype-equiv e C D H = equiv-toto (λ y → type-Prop (D y)) e ( λ x → equiv-iff (C x) (D (map-equiv e x)) (H x)) equiv-comp-equiv' : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} → (A ≃ B) → (C : UU l3) → (B ≃ C) ≃ (A ≃ C) equiv-comp-equiv' e C = equiv-subtype-equiv ( equiv-precomp-equiv e C) ( is-equiv-Prop) ( is-equiv-Prop) ( λ g → pair ( is-equiv-comp' g (map-equiv e) (is-equiv-map-equiv e)) ( λ is-equiv-eg → is-equiv-left-factor' g (map-equiv e) is-equiv-eg (is-equiv-map-equiv e))) is-prop-is-small : (l : Level) {l1 : Level} (A : UU l1) → is-prop (is-small l A) is-prop-is-small l A = is-prop-is-contr-if-inh ( λ Xe → is-contr-equiv' ( Σ (UU l) (λ Y → (pr1 Xe) ≃ Y)) ( equiv-tot ((λ Y → equiv-comp-equiv' (pr2 Xe) Y))) ( is-contr-total-equiv (pr1 Xe))) is-prop-is-locally-small : (l : Level) {l1 : Level} (A : UU l1) → is-prop (is-locally-small l A) is-prop-is-locally-small l A = is-prop-Π (λ x → is-prop-Π (λ y → is-prop-is-small l (Id x y)))
{ "alphanum_fraction": 0.5651847683, "avg_line_length": 32.9074074074, "ext": "agda", "hexsha": "bc751b99ec34a62dbe312c2ceb86991b9fe7976d", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/16-sets.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/16-sets.agda", "max_line_length": 80, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/16-sets.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 2344, "size": 5331 }
{-# OPTIONS --universe-polymorphism #-} module Issue311 where open import Common.Level postulate A : Set C : (b : Level) (B : A → Set b) → Set b f : (b : Level) (B : A → Set b) → C b B → A g : (b : Level) (B : A → Set b) (d : C b B) → B (f b B d) P : (c : Level) → Set c Q : A → Set checkQ : ∀ a → Q a → Set T : (c : Level) → Set c T c = P c → A Foo : (c : Level) (d : C c (λ _ → T c)) → Q (f c (λ _ → T c) d) → Set Foo c d q with f c (λ _ → T c) d | g c (λ _ → T c) d Foo c d q | x | y = checkQ x q -- C-c C-, gives: -- -- Goal: Set₁ -- ———————————————————————————————————————————————————————————— -- q : Q (f c (λ _ → P c → A) d) -- y : P c → A -- x : A -- d : C c (λ _ → P c → A) -- c : Level -- -- Note that q has type Q (f c (λ _ → P c → A) d); it should have type -- Q x.
{ "alphanum_fraction": 0.4173913043, "avg_line_length": 22.3611111111, "ext": "agda", "hexsha": "a7d0bfed458b2d130930f9fc4ce74877d13b614d", "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/Issue311.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/Issue311.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue311.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": 335, "size": 805 }
{-# OPTIONS --safe #-} {- This uses ideas from Floris van Doorn's phd thesis and the code in https://github.com/cmu-phil/Spectral/blob/master/spectrum/basic.hlean -} module Cubical.Homotopy.Spectrum where open import Cubical.Foundations.Prelude open import Cubical.Data.Unit.Pointed open import Cubical.Foundations.Equiv open import Cubical.Data.Int open import Cubical.Homotopy.Prespectrum private variable ℓ : Level Spectrum : (ℓ : Level) → Type (ℓ-suc ℓ) Spectrum ℓ = let open GenericPrespectrum in Σ[ P ∈ Prespectrum ℓ ] ((k : ℤ) → isEquiv (fst (map P k)))
{ "alphanum_fraction": 0.7232597623, "avg_line_length": 25.6086956522, "ext": "agda", "hexsha": "c2a36d017b5e21912dc79b58d8bd1d1b9377fb6b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Homotopy/Spectrum.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Homotopy/Spectrum.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Homotopy/Spectrum.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 176, "size": 589 }
------------------------------------------------------------------------ -- Example: Left recursive expression grammar ------------------------------------------------------------------------ module TotalParserCombinators.Recogniser.Expression where open import Codata.Musical.Notation open import Data.Bool open import Data.Char as Char using (Char) open import Data.List open import Data.String as String using (String) open import Function open import Relation.Binary.PropositionalEquality open import TotalParserCombinators.BreadthFirst import TotalParserCombinators.Lib as Lib open import TotalParserCombinators.Recogniser ------------------------------------------------------------------------ -- Lifted versions of some parsers -- Specific tokens. tok : Char → P Char [] tok c = lift $ Lib.Token.tok Char Char._≟_ c -- Numbers. number : P Char [] number = lift Lib.number ------------------------------------------------------------------------ -- An expression grammar -- t ∷= t '+' f ∣ f -- f ∷= f '*' a ∣ a -- a ∷= '(' t ')' ∣ n mutual term = ♯ term · tok '+' · factor ∣ factor factor = ♯ factor · tok '*' · atom ∣ atom atom = tok '(' · ♯ term · tok ')' ∣ number ------------------------------------------------------------------------ -- Unit tests module Tests where test : ∀ {n} → P Char n → String → Bool test p s = not $ null $ parse ⟦ p ⟧ (String.toList s) ex₁ : test term "1*(2+3)" ≡ true ex₁ = refl ex₂ : test term "1*(2+3" ≡ false ex₂ = refl
{ "alphanum_fraction": 0.5, "avg_line_length": 24.2857142857, "ext": "agda", "hexsha": "2ad178dd3b961c551f4c1fffb9714910798754e7", "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/Recogniser/Expression.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Recogniser/Expression.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Recogniser/Expression.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 354, "size": 1530 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of the binary representation of natural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Bin.Properties where open import Data.Bin open import Data.Digit using (Bit; Expansion) import Data.Fin as Fin import Data.Fin.Properties as 𝔽ₚ open import Data.List.Base using (List; []; _∷_) open import Data.List.Properties using (∷-injective) open import Data.Nat using (ℕ; zero; z≤n; s≤s) renaming (suc to 1+_; _+_ to _+ℕ_; _*_ to _*ℕ_; _≤_ to _≤ℕ_) import Data.Nat.Properties as ℕₚ open import Data.Product using (proj₁; proj₂) open import Function using (_∘_) open import Relation.Binary open import Relation.Binary.Consequences open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; isEquivalence; resp₂; decSetoid) open import Relation.Nullary using (yes; no) ------------------------------------------------------------------------ -- (Bin, _≡_) is a decidable setoid 1#-injective : ∀ {as bs} → as 1# ≡ bs 1# → as ≡ bs 1#-injective refl = refl infix 4 _≟_ _≟ₑ_ _≟ₑ_ : ∀ {base} → Decidable (_≡_ {A = Expansion base}) _≟ₑ_ [] [] = yes refl _≟ₑ_ [] (_ ∷ _) = no λ() _≟ₑ_ (_ ∷ _) [] = no λ() _≟ₑ_ (x ∷ xs) (y ∷ ys) with x Fin.≟ y | xs ≟ₑ ys ... | _ | no xs≢ys = no (xs≢ys ∘ proj₂ ∘ ∷-injective) ... | no x≢y | _ = no (x≢y ∘ proj₁ ∘ ∷-injective) ... | yes refl | yes refl = yes refl _≟_ : Decidable {A = Bin} _≡_ 0# ≟ 0# = yes refl 0# ≟ bs 1# = no λ() as 1# ≟ 0# = no λ() as 1# ≟ bs 1# with as ≟ₑ bs ... | yes refl = yes refl ... | no as≢bs = no (as≢bs ∘ 1#-injective) ≡-isDecEquivalence : IsDecEquivalence _≡_ ≡-isDecEquivalence = record { isEquivalence = isEquivalence ; _≟_ = _≟_ } ≡-decSetoid : DecSetoid _ _ ≡-decSetoid = decSetoid _≟_ ------------------------------------------------------------------------ -- (Bin _≡_ _<_) is a strict total order <-trans : Transitive _<_ <-trans (less lt₁) (less lt₂) = less (ℕₚ.<-trans lt₁ lt₂) <-asym : Asymmetric _<_ <-asym (less lt) (less gt) = ℕₚ.<-asym lt gt <-irrefl : Irreflexive _≡_ _<_ <-irrefl refl (less lt) = ℕₚ.<-irrefl refl lt ∷ʳ-mono-< : ∀ {a b as bs} → as 1# < bs 1# → (a ∷ as) 1# < (b ∷ bs) 1# ∷ʳ-mono-< {a} {b} {as} {bs} (less lt) = less (begin 1+ (m₁ +ℕ n₁ *ℕ 2) ≤⟨ s≤s (ℕₚ.+-monoˡ-≤ _ (𝔽ₚ.toℕ≤pred[n] a)) ⟩ 1+ (1 +ℕ n₁ *ℕ 2) ≡⟨ refl ⟩ 1+ n₁ *ℕ 2 ≤⟨ ℕₚ.*-mono-≤ lt ℕₚ.≤-refl ⟩ n₂ *ℕ 2 ≤⟨ ℕₚ.n≤m+n m₂ (n₂ *ℕ 2) ⟩ m₂ +ℕ n₂ *ℕ 2 ∎) where open ℕₚ.≤-Reasoning m₁ = Fin.toℕ a; m₂ = Fin.toℕ b n₁ = toℕ (as 1#); n₂ = toℕ (bs 1#) ∷ˡ-mono-< : ∀ {a b bs} → a Fin.< b → (a ∷ bs) 1# < (b ∷ bs) 1# ∷ˡ-mono-< {a} {b} {bs} lt = less (begin 1 +ℕ (m₁ +ℕ n *ℕ 2) ≡⟨ sym (ℕₚ.+-assoc 1 m₁ (n *ℕ 2)) ⟩ (1 +ℕ m₁) +ℕ n *ℕ 2 ≤⟨ ℕₚ.+-monoˡ-≤ _ lt ⟩ m₂ +ℕ n *ℕ 2 ∎) where open ℕₚ.≤-Reasoning m₁ = Fin.toℕ a; m₂ = Fin.toℕ b; n = toℕ (bs 1#) 1<[23] : ∀ {b} → [] 1# < (b ∷ []) 1# 1<[23] {b} = less (ℕₚ.n≤m+n (Fin.toℕ b) 2) 1<2+ : ∀ {b bs} → [] 1# < (b ∷ bs) 1# 1<2+ {_} {[]} = 1<[23] 1<2+ {_} {b ∷ bs} = <-trans 1<[23] (∷ʳ-mono-< {a = b} 1<2+) 0<1+ : ∀ {bs} → 0# < bs 1# 0<1+ {[]} = less (s≤s z≤n) 0<1+ {b ∷ bs} = <-trans (less (s≤s z≤n)) 1<2+ <⇒≢ : ∀ {a b} → a < b → a ≢ b <⇒≢ lt eq = asym⟶irr (resp₂ _<_) sym <-asym eq lt <-cmp : Trichotomous _≡_ _<_ <-cmp 0# 0# = tri≈ (<-irrefl refl) refl (<-irrefl refl) <-cmp 0# (_ 1#) = tri< 0<1+ (<⇒≢ 0<1+) (<-asym 0<1+) <-cmp (_ 1#) 0# = tri> (<-asym 0<1+) (<⇒≢ 0<1+ ∘ sym) 0<1+ <-cmp ([] 1#) ([] 1#) = tri≈ (<-irrefl refl) refl (<-irrefl refl) <-cmp ([] 1#) ((b ∷ bs) 1#) = tri< 1<2+ (<⇒≢ 1<2+) (<-asym 1<2+) <-cmp ((a ∷ as) 1#) ([] 1#) = tri> (<-asym 1<2+) (<⇒≢ 1<2+ ∘ sym) 1<2+ <-cmp ((a ∷ as) 1#) ((b ∷ bs) 1#) with <-cmp (as 1#) (bs 1#) ... | tri< lt ¬eq ¬gt = tri< (∷ʳ-mono-< lt) (<⇒≢ (∷ʳ-mono-< lt)) (<-asym (∷ʳ-mono-< lt)) ... | tri> ¬lt ¬eq gt = tri> (<-asym (∷ʳ-mono-< gt)) (<⇒≢ (∷ʳ-mono-< gt) ∘ sym) (∷ʳ-mono-< gt) ... | tri≈ ¬lt refl ¬gt with 𝔽ₚ.<-cmp a b ... | tri≈ ¬lt′ refl ¬gt′ = tri≈ (<-irrefl refl) refl (<-irrefl refl) ... | tri< lt′ ¬eq ¬gt′ = tri< (∷ˡ-mono-< lt′) (<⇒≢ (∷ˡ-mono-< lt′)) (<-asym (∷ˡ-mono-< lt′)) ... | tri> ¬lt′ ¬eq gt′ = tri> (<-asym (∷ˡ-mono-< gt′)) (<⇒≢ (∷ˡ-mono-< gt′) ∘ sym) (∷ˡ-mono-< gt′) <-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_ <-isStrictTotalOrder = record { isEquivalence = isEquivalence ; trans = <-trans ; compare = <-cmp } <-strictTotalOrder : StrictTotalOrder _ _ _ <-strictTotalOrder = record { Carrier = Bin ; _≈_ = _≡_ ; _<_ = _<_ ; isStrictTotalOrder = <-isStrictTotalOrder }
{ "alphanum_fraction": 0.4786972552, "avg_line_length": 33.9027777778, "ext": "agda", "hexsha": "63d261c237c00bc90d4519341bebc7e892168238", "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/Bin/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/Bin/Properties.agda", "max_line_length": 77, "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/Bin/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2266, "size": 4882 }
open import Prelude open import Nat open import List open import Bij module delta-lemmas (K : Set) {{bij : bij K Nat}} where -- abbreviations for conversion between K and Nat key : Nat → K key = convert-inv {{bij}} nat : K → Nat nat = bij.convert bij -- another bij-related convenience functions inj-cp : ∀{k1 k2} → k1 ≠ k2 → nat k1 ≠ nat k2 inj-cp ne eq = abort (ne (bij.inj bij eq)) -- helper function delta : ∀{n m} → n < m → Nat delta n<m = difference (n<m→1+n≤m n<m) -- raw underlying list-of-pairs type dl : (V : Set) → Set dl V = List (Nat ∧ V) ---- helper definitions ---- _lkup_ : {V : Set} → dl V → Nat → Maybe V [] lkup x = None ((hn , hv) :: t) lkup n with <dec n hn ... | Inl n<hn = None ... | Inr (Inl refl) = Some hv ... | Inr (Inr hn<n) = t lkup (delta hn<n) _,,'_ : ∀{V} → dl V → (Nat ∧ V) → dl V [] ,,' (n , v) = (n , v) :: [] ((hn , hv) :: t) ,,' (n , v) with <dec n hn ... | Inl n<hn = (n , v) :: ((delta n<hn , hv) :: t) ... | Inr (Inl refl) = (n , v) :: t ... | Inr (Inr hn<n) = (hn , hv) :: (t ,,' (delta hn<n , v)) data _∈'_ : {V : Set} (p : Nat ∧ V) → (d : dl V) → Set where InH : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) ∈' ((n , v) :: d) InT : {V : Set} {d : dl V} {n s : Nat} {v v' : V} → (n , v) ∈' d → (n + 1+ s , v) ∈' ((s , v') :: d) dom' : {V : Set} → dl V → Nat → Set dom' {V} d n = Σ[ v ∈ V ] ((n , v) ∈' d) _#'_ : {V : Set} (n : Nat) → (d : dl V) → Set n #' d = dom' d n → ⊥ ---- lemmas ---- undelta : (x s : Nat) → (x<s+1+x : x < s + 1+ x) → s == delta x<s+1+x undelta x s x<s+1+x rewrite n+1+m==1+n+m {s} {x} | ! (m-n==1+m-1+n n≤m+n (n<m→1+n≤m x<s+1+x)) | +comm {s} {x} = ! (n+m-n==m n≤n+m) n#'[] : {V : Set} {n : Nat} → _#'_ {V} n [] n#'[] (_ , ()) too-small : {V : Set} {d : dl V} {xl xb : Nat} {v : V} → xl < xb → dom' ((xb , v) :: d) xl → ⊥ too-small (_ , ne) (_ , InH) = ne refl too-small (x+1+xb≤xb , x+1+xb==xb) (_ , InT _) = x+1+xb==xb (≤antisym x+1+xb≤xb (≤trans (≤1+ ≤refl) n≤m+n)) all-not-none : {V : Set} {d : dl V} {x : Nat} {v : V} → None ≠ (((x , v) :: d) lkup x) all-not-none {x = x} rewrite <dec-refl x = λ () all-bindings-==-rec-eq : {V : Set} {d1 d2 : dl V} {x : Nat} {v : V} → ((x' : Nat) → ((x , v) :: d1) lkup x' == ((x , v) :: d2) lkup x') → ((x' : Nat) → d1 lkup x' == d2 lkup x') all-bindings-==-rec-eq {x = x} h x' with h (x' + 1+ x) ... | eq with <dec (x' + 1+ x) x ... | Inl x'+1+x<x = abort (<antisym x'+1+x<x (n<m→n<s+m n<1+n)) ... | Inr (Inl x'+1+x==x) = abort ((flip n≠n+1+m) (n+1+m==1+n+m · (+comm {1+ x} · x'+1+x==x))) ... | Inr (Inr x<x'+1+x) rewrite ! (undelta x x' x<x'+1+x) = eq all-bindings-==-rec : {V : Set} {d1 d2 : dl V} {x1 x2 : Nat} {v1 v2 : V} → ((x : Nat) → ((x1 , v1) :: d1) lkup x == ((x2 , v2) :: d2) lkup x) → ((x : Nat) → d1 lkup x == d2 lkup x) all-bindings-==-rec {x1 = x1} {x2} h x with h x1 | h x2 ... | eq1 | eq2 rewrite <dec-refl x1 | <dec-refl x2 with <dec x1 x2 | <dec x2 x1 ... | Inl _ | _ = abort (somenotnone eq1) ... | Inr _ | Inl _ = abort (somenotnone (! eq2)) ... | Inr (Inl refl) | Inr (Inl refl) rewrite someinj eq1 | someinj eq2 = all-bindings-==-rec-eq h x ... | Inr (Inl refl) | Inr (Inr x2<x2) = abort (<antirefl x2<x2) ... | Inr (Inr x2<x2) | Inr (Inl refl) = abort (<antirefl x2<x2) ... | Inr (Inr x2<x1) | Inr (Inr x1<x2) = abort (<antisym x1<x2 x2<x1) sad-lemma : {V : Set} {d : dl V} {x n : Nat} {v v' : V} → (x + 1+ n , v') ∈' ((n , v) :: d) → Σ[ x' ∈ Nat ] Σ[ d' ∈ dl V ] ( d' == ((n , v) :: d) ∧ x' == x + 1+ n ∧ (x' , v') ∈' d') sad-lemma h = _ , _ , refl , refl , h lemma-math' : ∀{x x1 n} → x ≠ x1 + (n + 1+ x) lemma-math' {x} {x1} {n} rewrite ! (+assc {x1} {n} {1+ x}) | n+1+m==1+n+m {x1 + n} {x} | +comm {1+ x1 + n} {x} = n≠n+1+m lookup-cons-2' : {V : Set} {d : dl V} {n : Nat} {v : V} → d lkup n == Some v → (n , v) ∈' d lookup-cons-2' {d = []} () lookup-cons-2' {d = ((hn , hv) :: t)} {n} h with <dec n hn lookup-cons-2' {d = ((hn , hv) :: t)} {n} () | Inl _ lookup-cons-2' {d = ((hn , hv) :: t)} {.hn} refl | Inr (Inl refl) = InH lookup-cons-2' {d = ((hn , hv) :: t)} {n} {v} h | Inr (Inr hn<n) = tr (λ y → (y , v) ∈' ((hn , hv) :: t)) (m-n+n==m (n<m→1+n≤m hn<n)) (InT (lookup-cons-2' {d = t} h)) lookup-cons-1' : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) ∈' d → d lkup n == Some v lookup-cons-1' {n = x} InH rewrite <dec-refl x = refl lookup-cons-1' (InT {d = d} {n = x} {s} {v} x∈d) with <dec (x + 1+ s) s ... | Inl x+1+s<s = abort (<antisym x+1+s<s (n<m→n<s+m n<1+n)) ... | Inr (Inl x+1+s==s) = abort ((flip n≠n+1+m) (n+1+m==1+n+m · (+comm {1+ s} · x+1+s==s))) ... | Inr (Inr s<x+1+s) with lookup-cons-1' x∈d ... | h rewrite ! (undelta s x s<x+1+s) = h n,v∈'d,,n,v : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) ∈' (d ,,' (n , v)) n,v∈'d,,n,v {d = []} {n} {v} = InH n,v∈'d,,n,v {d = ((hn , hv) :: t)} {n} {v} with <dec n hn ... | Inl _ = InH ... | Inr (Inl refl) = InH ... | Inr (Inr hn<n) = tr (λ y → (y , v) ∈' ((hn , hv) :: (t ,,' (delta hn<n , v)))) (m-n+n==m (n<m→1+n≤m hn<n)) (InT (n,v∈'d,,n,v {d = t} {delta hn<n})) n∈d+→'n∈d : {V : Set} {d : dl V} {n n' : Nat} {v v' : V} → n ≠ n' → (n , v) ∈' (d ,,' (n' , v')) → (n , v) ∈' d n∈d+→'n∈d {d = []} n≠n' InH = abort (n≠n' refl) n∈d+→'n∈d {d = []} n≠n' (InT ()) n∈d+→'n∈d {d = (hn , hv) :: t} {n' = n'} n≠n' n∈d+ with <dec n' hn n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = n'} n≠n' InH | Inl n'<hn = abort (n≠n' refl) n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = n'} n≠n' (InT InH) | Inl n'<hn rewrite m-n+n==m (n<m→1+n≤m n'<hn) = InH n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = n'} n≠n' (InT (InT {n = n} n∈d+)) | Inl n'<hn rewrite +assc {n} {1+ (delta n'<hn)} {1+ n'} | m-n+n==m (n<m→1+n≤m n'<hn) = InT n∈d+ n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = .hn} n≠n' InH | Inr (Inl refl) = abort (n≠n' refl) n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = .hn} n≠n' (InT n∈d+) | Inr (Inl refl) = InT n∈d+ n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = n'} n≠n' InH | Inr (Inr hn<n') = InH n∈d+→'n∈d {_} {(hn , hv) :: t} {n' = n'} n≠n' (InT n∈d+) | Inr (Inr hn<n') = InT (n∈d+→'n∈d (λ where refl → n≠n' (m-n+n==m (n<m→1+n≤m hn<n'))) n∈d+) n∈d→'n∈d+ : {V : Set} {d : dl V} {n n' : Nat} {v v' : V} → n ≠ n' → (n , v) ∈' d → (n , v) ∈' (d ,,' (n' , v')) n∈d→'n∈d+ {n = n} {n'} {v} {v'} n≠n' (InH {d = d'}) with <dec n' n ... | Inl n'<n = tr (λ y → (y , v) ∈' ((n' , v') :: ((delta n'<n , v) :: d'))) (m-n+n==m (n<m→1+n≤m n'<n)) (InT InH) ... | Inr (Inl refl) = abort (n≠n' refl) ... | Inr (Inr n<n') = InH n∈d→'n∈d+ {n = .(_ + 1+ _)} {n'} {v} {v'} n≠n' (InT {d = d} {n} {s} {v' = v''} n∈d) with <dec n' s ... | Inl n'<s = tr (λ y → (y , v) ∈' ((n' , v') :: ((delta n'<s , v'') :: d))) ((+assc {b = 1+ (delta n'<s)}) · (ap1 (n +_) (1+ap (m-n+n==m (n<m→1+n≤m n'<s))))) (InT (InT n∈d)) ... | Inr (Inl refl) = InT n∈d ... | Inr (Inr s<n') = InT (n∈d→'n∈d+ (λ where refl → n≠n' (m-n+n==m (n<m→1+n≤m s<n'))) n∈d) mem-dec' : {V : Set} (d : dl V) (n : Nat) → dom' d n ∨ n #' d mem-dec' [] n = Inr (λ ()) mem-dec' ((hn , hv) :: t) n with <dec n hn ... | Inl n<hn = Inr (too-small n<hn) ... | Inr (Inl refl) = Inl (hv , InH) ... | Inr (Inr hn<n) with mem-dec' t (delta hn<n) mem-dec' ((hn , hv) :: t) n | Inr (Inr hn<n) | Inl (v , rec) = Inl (v , tr (λ y → (y , v) ∈' ((hn , hv) :: t)) (m-n+n==m (n<m→1+n≤m hn<n)) (InT rec)) mem-dec' {V} ((hn , hv) :: t) n | Inr (Inr hn<n) | Inr dne = Inr n∉d where n∉d : Σ[ v ∈ V ] ((n , v) ∈' ((hn , hv) :: t)) → ⊥ n∉d (_ , n∈d) with n∈d ... | InH = (π2 hn<n) refl ... | InT {n = s} n-hn-1∈t rewrite ! (undelta hn s hn<n) = dne (_ , n-hn-1∈t) extensional' : {V : Set} {d1 d2 : dl V} → ((n : Nat) → d1 lkup n == d2 lkup n) → d1 == d2 extensional' {d1 = []} {[]} all-bindings-== = refl extensional' {d1 = []} {(hn2 , hv2) :: t2} all-bindings-== = abort (all-not-none {d = t2} {x = hn2} (all-bindings-== hn2)) extensional' {d1 = (hn1 , hv1) :: t1} {[]} all-bindings-== = abort (all-not-none {d = t1} {x = hn1} (! (all-bindings-== hn1))) extensional' {d1 = (hn1 , hv1) :: t1} {(hn2 , hv2) :: t2} all-bindings-== rewrite extensional' {d1 = t1} {t2} (all-bindings-==-rec all-bindings-==) with all-bindings-== hn1 | all-bindings-== hn2 ... | hv1== | hv2== rewrite <dec-refl hn1 | <dec-refl hn2 with <dec hn1 hn2 | <dec hn2 hn1 ... | Inl hn1<hn2 | _ = abort (somenotnone hv1==) ... | Inr (Inl refl) | Inl hn2<hn1 = abort (somenotnone (! hv2==)) ... | Inr (Inr hn2<hn1) | Inl hn2<'hn1 = abort (somenotnone (! hv2==)) ... | Inr (Inl refl) | Inr _ rewrite someinj hv1== = refl ... | Inr (Inr hn2<hn1) | Inr (Inl refl) rewrite someinj hv2== = refl ... | Inr (Inr hn2<hn1) | Inr (Inr hn1<hn2) = abort (<antisym hn1<hn2 hn2<hn1) ==-dec' : {V : Set} (d1 d2 : dl V) → ((v1 v2 : V) → v1 == v2 ∨ v1 ≠ v2) → d1 == d2 ∨ d1 ≠ d2 ==-dec' [] [] _ = Inl refl ==-dec' [] (_ :: _) _ = Inr (λ ()) ==-dec' (_ :: _) [] _ = Inr (λ ()) ==-dec' ((hn1 , hv1) :: t1) ((hn2 , hv2) :: t2) V==dec with natEQ hn1 hn2 | V==dec hv1 hv2 | ==-dec' t1 t2 V==dec ... | Inl refl | Inl refl | Inl refl = Inl refl ... | Inl refl | Inl refl | Inr ne = Inr λ where refl → ne refl ... | Inl refl | Inr ne | _ = Inr λ where refl → ne refl ... | Inr ne | _ | _ = Inr λ where refl → ne refl delete' : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) ∈' d → Σ[ d⁻ ∈ dl V ] ( d == d⁻ ,,' (n , v) ∧ n #' d⁻) delete' {d = (n' , v') :: d} {n} n∈d with <dec n n' ... | Inl n<n' = abort (too-small n<n' (_ , n∈d)) delete' {_} {(n' , v') :: []} {.n'} InH | Inr (Inl _) = [] , refl , λ () delete' {_} {(n' , v') :: ((n'' , v'') :: d)} {.n'} InH | Inr (Inl _) = ((n'' + 1+ n' , v'') :: d) , lem , λ {(_ , n'∈d+) → abort (too-small (n<m→n<s+m n<1+n) (_ , n'∈d+))} where lem : ((n' , v') :: ((n'' , v'') :: d)) == ((n'' + 1+ n' , v'') :: d) ,,' (n' , v') lem with <dec n' (n'' + 1+ n') lem | Inl n'<n''+1+n' rewrite ! (undelta n' n'' n'<n''+1+n') = refl lem | Inr (Inl false) = abort (lemma-math' {x1 = Z} false) lem | Inr (Inr false) = abort (<antisym false (n<m→n<s+m n<1+n)) delete' {d = (n' , v') :: d} InH | Inr (Inr n'<n') = abort (<antirefl n'<n') delete' {d = (n' , v') :: d} (InT n∈d) | Inr _ with delete' {d = d} n∈d delete' {d = (n' , v') :: d} {.(_ + 1+ n')} {v} (InT {n = x} n∈d) | Inr _ | d⁻ , refl , x#d⁻ = _ , lem' , lem where lem : (x + 1+ n') #' ((n' , v') :: d⁻) lem (_ , x+1+n'∈d?) with sad-lemma x+1+n'∈d? ... | _ , _ , refl , n'==x+1+n' , InH = abort (lemma-math' {x1 = Z} n'==x+1+n') ... | _ , _ , refl , n'==x+1+n' , InT x+1+n'∈d' rewrite +inj {b = 1+ n'} n'==x+1+n' = x#d⁻ (_ , x+1+n'∈d') lem' : ((n' , v') :: (d⁻ ,,' (x , v))) == (((n' , v') :: d⁻) ,,' (x + 1+ n' , v)) lem' with <dec (x + 1+ n') n' lem' | Inl x+1+n'<n' = abort (<antisym x+1+n'<n' (n<m→n<s+m n<1+n)) lem' | Inr (Inl false) = abort (lemma-math' {x1 = Z} (! false)) lem' | Inr (Inr n'<x+1+n') rewrite ! (undelta n' x n'<x+1+n') = refl extend-size' : {V : Set} {d : dl V} {n : Nat} {v : V} → n #' d → ∥ d ,,' (n , v) ∥ == 1+ ∥ d ∥ extend-size' {d = []} n#d = refl extend-size' {d = (n' , v') :: d} {n} n#d with <dec n n' ... | Inl n<n' = refl ... | Inr (Inl refl) = abort (n#d (_ , InH)) ... | Inr (Inr n'<n) = 1+ap (extend-size' λ {(v , diff∈d) → n#d (v , tr (λ y → (y , v) ∈' ((n' , v') :: d)) (m-n+n==m (n<m→1+n≤m n'<n)) (InT diff∈d))}) ---- contrapositives of some previous lemmas ---- lookup-dec' : {V : Set} (d : dl V) (n : Nat) → Σ[ v ∈ V ] (d lkup n == Some v) ∨ d lkup n == None lookup-dec' d n with d lkup n ... | Some v = Inl (v , refl) ... | None = Inr refl lookup-cp-2' : {V : Set} {d : dl V} {n : Nat} → n #' d → d lkup n == None lookup-cp-2' {d = d} {n} n#d with lookup-dec' d n ... | Inl (_ , n∈d) = abort (n#d (_ , lookup-cons-2' n∈d)) ... | Inr n#'d = n#'d n#d→'n#d+ : {V : Set} {d : dl V} {n n' : Nat} {v' : V} → n ≠ n' → n #' d → n #' (d ,,' (n' , v')) n#d→'n#d+ {d = d} {n} {n'} {v'} n≠n' n#d with mem-dec' (d ,,' (n' , v')) n ... | Inl (_ , n∈d+) = abort (n#d (_ , n∈d+→'n∈d n≠n' n∈d+)) ... | Inr n#d+ = n#d+ ---- union, and dlt <=> list conversion definitions merge' : {V : Set} → (V → V → V) → Maybe V → V → V merge' merge ma1 v2 with ma1 ... | None = v2 ... | Some v1 = merge v1 v2 union' : {V : Set} → (V → V → V) → dl V → dl V → Nat → dl V union' merge d1 [] _ = d1 union' merge d1 ((hn , hv) :: d2) offset with d1 ,,' (hn + offset , merge' merge (d1 lkup hn + offset) hv) ... | d1+ = union' merge d1+ d2 (1+ hn + offset) dlt⇒list' : {V : Set} (d : dl V) → dl V dlt⇒list' [] = [] dlt⇒list' ((x , v) :: d) = (x , v) :: map (λ {(x' , v') → x' + 1+ x , v'}) (dlt⇒list' d) list⇒dlt' : {V : Set} (d : dl V) → dl V list⇒dlt' = foldr _,,'_ [] ---- union, dlt <=> list, etc lemmas ---- lemma-union'-0 : {V : Set} {m : V → V → V} {d1 d2 : dl V} {x n : Nat} {v : V} → (x , v) ∈' d1 → (x , v) ∈' (union' m d1 d2 (n + 1+ x)) lemma-union'-0 {d2 = []} x∈d1 = x∈d1 lemma-union'-0 {d2 = (x1 , v1) :: d2} {x} {n} x∈d1 rewrite ! (+assc {1+ x1} {n} {1+ x}) = lemma-union'-0 {d2 = d2} {n = 1+ x1 + n} (n∈d→'n∈d+ (lemma-math' {x1 = x1} {n}) x∈d1) lemma-union'-1 : {V : Set} {m : V → V → V} {d1 d2 : dl V} {x n : Nat} {v : V} → (x , v) ∈' d1 → (n≤x : n ≤ x) → (difference n≤x) #' d2 → (x , v) ∈' (union' m d1 d2 n) lemma-union'-1 {d2 = []} {x} x∈d1 n≤x x-n#d2 = x∈d1 lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 with <dec x (x1 + n) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inl x<x1+n with d1 lkup x1 + n lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inl x<x1+n | Some v' with expr-eq (λ _ → d1 ,,' (x1 + n , m v' v1)) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inl x<x1+n | Some v' | d1+ , refl = tr (λ y → (x , v) ∈' (union' m d1+ d2 y)) (n+1+m==1+n+m {difference (π1 x<x1+n)} · 1+ap (m-n+n==m (π1 x<x1+n))) (lemma-union'-0 {d2 = d2} (n∈d→'n∈d+ (π2 x<x1+n) x∈d1)) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inl x<x1+n | None with expr-eq (λ _ → d1 ,,' (x1 + n , v1)) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inl x<x1+n | None | d1+ , refl = tr (λ y → (x , v) ∈' (union' m d1+ d2 y)) (n+1+m==1+n+m {difference (π1 x<x1+n)} · 1+ap (m-n+n==m (π1 x<x1+n))) (lemma-union'-0 {d2 = d2} (n∈d→'n∈d+ (π2 x<x1+n) x∈d1)) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inr (Inl refl) rewrite +comm {x1} {n} | n+m-n==m n≤x = abort (x-n#d2 (_ , InH)) lemma-union'-1 {m = m} {d1} {(x1 , v1) :: d2} {x} {n} {v} x∈d1 n≤x x-n#d2 | Inr (Inr x1+n<x) rewrite (! (a+b==c→a==c-b (+assc {delta x1+n<x} · m-n+n==m (n<m→1+n≤m x1+n<x)) n≤x)) = lemma-union'-1 (n∈d→'n∈d+ (flip (π2 x1+n<x)) x∈d1) (n<m→1+n≤m x1+n<x) λ {(_ , x-x1-n∈d2) → x-n#d2 (_ , InT x-x1-n∈d2)} lemma-union'-2 : {V : Set} {m : V → V → V} {d1 d2 : dl V} {x n : Nat} {v : V} → (x + n) #' d1 → (x , v) ∈' d2 → (x + n , v) ∈' (union' m d1 d2 n) lemma-union'-2 {d1 = d1} x+n#d1 (InH {d = d2}) rewrite lookup-cp-2' x+n#d1 = lemma-union'-0 {d2 = d2} {n = Z} (n,v∈'d,,n,v {d = d1}) lemma-union'-2 {d1 = d1} {n = n} x+n#d1 (InT {d = d2} {n = x} {s} x∈d2) rewrite +assc {x} {1+ s} {n} with d1 lkup s + n ... | Some v' = lemma-union'-2 (λ {(_ , x∈d1+) → x+n#d1 (_ , n∈d+→'n∈d (flip (lemma-math' {x1 = Z})) x∈d1+)}) x∈d2 ... | None = lemma-union'-2 (λ {(_ , x∈d1+) → x+n#d1 (_ , n∈d+→'n∈d (flip (lemma-math' {x1 = Z})) x∈d1+)}) x∈d2 lemma-union'-3 : {V : Set} {m : V → V → V} {d1 d2 : dl V} {x n : Nat} {v1 v2 : V} → (x + n , v1) ∈' d1 → (x , v2) ∈' d2 → (x + n , m v1 v2) ∈' (union' m d1 d2 n) lemma-union'-3 {d1 = d1} x+n∈d1 (InH {d = d2}) rewrite lookup-cons-1' x+n∈d1 = lemma-union'-0 {d2 = d2} {n = Z} (n,v∈'d,,n,v {d = d1}) lemma-union'-3 {d1 = d1} {n = n} x+n∈d1 (InT {d = d2} {n = x} {s} x∈d2) rewrite +assc {x} {1+ s} {n} with d1 lkup s + n ... | Some v' = lemma-union'-3 (n∈d→'n∈d+ (flip (lemma-math' {x1 = Z})) x+n∈d1) x∈d2 ... | None = lemma-union'-3 (n∈d→'n∈d+ (flip (lemma-math' {x1 = Z})) x+n∈d1) x∈d2 lemma-union'-4 : {V : Set} {m : V → V → V} {d1 d2 : dl V} {x n : Nat} → dom' (union' m d1 d2 n) x → dom' d1 x ∨ (Σ[ s ∈ Nat ] (x == n + s ∧ dom' d2 s)) lemma-union'-4 {d2 = []} x∈un = Inl x∈un lemma-union'-4 {d1 = d1} {(x1 , _) :: d2} {x} {n} x∈un with lemma-union'-4 {d2 = d2} x∈un ... | Inr (s , refl , _ , s∈d2) rewrite +comm {x1} {n} | ! (n+1+m==1+n+m {n + x1} {s}) | +assc {n} {x1} {1+ s} | +comm {x1} {1+ s} | ! (n+1+m==1+n+m {s} {x1}) = Inr (_ , refl , _ , InT s∈d2) ... | Inl (_ , x∈d1+) with natEQ x (n + x1) ... | Inl refl = Inr (_ , refl , _ , InH) ... | Inr x≠n+x1 rewrite +comm {x1} {n} = Inl (_ , n∈d+→'n∈d x≠n+x1 x∈d1+) dlt⇒list-size' : {V : Set} {d : dl V} → ∥ dlt⇒list' d ∥ == ∥ d ∥ dlt⇒list-size' {d = []} = refl dlt⇒list-size' {d = _ :: d} = 1+ap (map-len · dlt⇒list-size') dlt⇒list-In-1' : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) ∈' d → (n , v) In dlt⇒list' d dlt⇒list-In-1' InH = LInH dlt⇒list-In-1' (InT ∈h) = LInT <| map-In <| dlt⇒list-In-1' ∈h too-small-list : {V : Set} {d : dl V} {m m' : Nat} {v : V} → m ≤ m' → (m , v) In (map (λ { (n'' , v'') → n'' + 1+ m' , v'' }) (dlt⇒list' d)) → ⊥ too-small-list {d = (n2 , v2) :: d} n≤n' LInH = abort (lemma-math' {x1 = Z} (≤antisym (≤trans n≤m+n (n≤m+n {m = n2})) n≤n')) too-small-list {d = (n2 , v2) :: d} {m} {m'} {v} m≤m' (LInT in') = too-small-list (≤trans m≤m' (≤trans n≤m+n (n≤m+n {m = n2}))) rec-in where rec-in = tr (λ y → (m , v) In y) (map^2 {f = (λ { (n'' , v'') → n'' + 1+ m' , v'' })} {(λ { (n'' , v'') → n'' + 1+ n2 , v'' })} {dlt⇒list' d} · map-ext (λ where (n'' , v'') → ap1 (λ y' → y' , v'') <| +assc {n''} {b = 1+ n2} {c = 1+ m'})) in' dlt⇒list-In-2' : {V : Set} {d : dl V} {n : Nat} {v : V} → (n , v) In dlt⇒list' d → (n , v) ∈' d dlt⇒list-In-2' {d = _ :: d} LInH = InH dlt⇒list-In-2' {d = (n' , v') :: d} {n} (LInT in') with <dec n n' ... | Inl n<n' = abort (too-small-list (π1 n<n') in') ... | Inr (Inl refl) = abort (too-small-list ≤refl in') ... | Inr (Inr n'<n) with n<m→s+1+n=m n'<n ... | _ , refl = InT (dlt⇒list-In-2' (lem2 in')) where lem1 : ∀{V l} {m1 m2 : Nat} {vv1 vv2 : V} → m1 ≠ m2 → (in'' : (m1 , vv1) In ((m2 , vv2) :: l)) → Σ[ in2 ∈ ((m1 , vv1) In l) ] (in'' == LInT in2) lem1 ne LInH = abort (ne refl) lem1 ne (LInT in'') = in'' , refl lem2 : ∀{V s l} {vv : V} → (s + 1+ n' , vv) In map (λ { (n'' , v'') → n'' + 1+ n' , v'' }) l → (s , vv) In l lem2 {s = s} {(n2 , v2) :: l} in'' with natEQ s n2 lem2 {s = s} {(s , v2) :: l} LInH | Inl refl = LInH lem2 {s = s} {(s , v2) :: l} (LInT in'') | Inl refl = LInT (lem2 in'') ... | Inr ne with lem1 (+inj-cp ne) in'' ... | in2 , refl = LInT (lem2 in2) list⇒dlt-In' : {V : Set} {l : dl V} {n : Nat} {v : V} → (n , v) ∈' list⇒dlt' l → (n , v) In l list⇒dlt-In' {l = (n' , v') :: l} {n} ∈h rewrite foldl-++ {l1 = reverse l} {(n' , v') :: []} {_,,'_} {[]} with natEQ n n' ... | Inr ne = LInT (list⇒dlt-In' (n∈d+→'n∈d ne ∈h)) ... | Inl refl rewrite someinj <| (! <| lookup-cons-1' ∈h) · (lookup-cons-1' {n = n} {v'} <| n,v∈'d,,n,v {d = foldl _,,'_ [] (reverse l)}) = LInH list⇒dlt-order' : {V : Set} {l1 l2 : dl V} {n : Nat} {v1 v2 : V} → (n , v1) ∈' (list⇒dlt' ((n , v1) :: l1 ++ ((n , v2) :: l2))) list⇒dlt-order' {l1 = l1} {l2} {n} {v1} {v2} rewrite foldl-++ {l1 = reverse (l1 ++ ((n , v2) :: l2))} {(n , v1) :: []} {_,,'_} {[]} = n,v∈'d,,n,v {d = foldl _,,'_ [] <| reverse (l1 ++ ((n , v2) :: l2))} bij-pair-1 : {V : Set} (nv : Nat ∧ V) → (nat <| key <| π1 nv , π2 nv) == nv bij-pair-1 (n , v) rewrite convert-bij2 {t = n} = refl bij-pair-2 : {V : Set} (kv : K ∧ V) → (key <| nat <| π1 kv , π2 kv) == kv bij-pair-2 (k , v) rewrite convert-bij1 {f = k} = refl dltmap-func' : {V1 V2 : Set} {d : dl V1} {f : V1 → V2} {n : Nat} {v : V1} → (map (λ { (hn , hv) → hn , f hv }) (d ,,' (n , v))) == (map (λ { (hn , hv) → hn , f hv }) d ,,' (n , f v)) dltmap-func' {d = []} = refl dltmap-func' {d = (nh , vh) :: d} {f = f} {n} with <dec n nh ... | Inl n<nh = refl ... | Inr (Inl refl) = refl ... | Inr (Inr nh<n) = ap1 ((nh , f vh) ::_) (dltmap-func' {d = d}) -- these proofs could use refactoring - -- contraction should probably make use of ==-dec' -- and exchange is way too long and repetitive contraction' : {V : Set} {d : dl V} {n : Nat} {v v' : V} → (d ,,' (n , v')) ,,' (n , v) == d ,,' (n , v) contraction' {d = []} {n} rewrite <dec-refl n = refl contraction' {d = (hn , hv) :: t} {n} {v} {v'} with <dec n hn ... | Inl _ rewrite <dec-refl n = refl ... | Inr (Inl refl) rewrite <dec-refl hn = refl ... | Inr (Inr hn<n) with <dec n hn ... | Inl n<hn = abort (<antisym n<hn hn<n) ... | Inr (Inl refl) = abort (<antirefl hn<n) ... | Inr (Inr hn<'n) with contraction' {d = t} {delta hn<'n} {v} {v'} ... | eq rewrite diff-proof-irrelevance (n<m→1+n≤m hn<n) (n<m→1+n≤m hn<'n) | eq = refl exchange' : {V : Set} {d : dl V} {n1 n2 : Nat} {v1 v2 : V} → n1 ≠ n2 → (d ,,' (n1 , v1)) ,,' (n2 , v2) == (d ,,' (n2 , v2)) ,,' (n1 , v1) exchange' {V} {d} {n1} {n2} {v1} {v2} n1≠n2 = extensional' fun where fun : (n : Nat) → ((d ,,' (n1 , v1)) ,,' (n2 , v2)) lkup n == ((d ,,' (n2 , v2)) ,,' (n1 , v1)) lkup n fun n with natEQ n n1 | natEQ n n2 | mem-dec' d n fun n | Inl refl | Inl refl | _ = abort (n1≠n2 refl) fun n1 | Inl refl | Inr n≠n2 | Inl (_ , n1∈d) with n,v∈'d,,n,v {d = d} {n1} {v1} ... | n∈d+1 with n∈d→'n∈d+ {v' = v2} n≠n2 n∈d+1 | n,v∈'d,,n,v {d = d ,,' (n2 , v2)} {n1} {v1} ... | n∈d++1 | n∈d++2 rewrite lookup-cons-1' n∈d++1 | lookup-cons-1' n∈d++2 = refl fun n1 | Inl refl | Inr n≠n2 | Inr n1#d with n,v∈'d,,n,v {d = d} {n1} {v1} ... | n∈d+1 with n∈d→'n∈d+ {v' = v2} n≠n2 n∈d+1 | n,v∈'d,,n,v {d = d ,,' (n2 , v2)} {n1} {v1} ... | n∈d++1 | n∈d++2 rewrite lookup-cons-1' n∈d++1 | lookup-cons-1' n∈d++2 = refl fun n2 | Inr n≠n1 | Inl refl | Inl (_ , n2∈d) with n,v∈'d,,n,v {d = d} {n2} {v2} ... | n∈d+2 with n∈d→'n∈d+ {v' = v1} n≠n1 n∈d+2 | n,v∈'d,,n,v {d = d ,,' (n1 , v1)} {n2} {v2} ... | n∈d++1 | n∈d++2 rewrite lookup-cons-1' n∈d++1 | lookup-cons-1' n∈d++2 = refl fun n2 | Inr n≠n1 | Inl refl | Inr n2#d with n,v∈'d,,n,v {d = d} {n2} {v2} ... | n∈d+2 with n∈d→'n∈d+ {v' = v1} n≠n1 n∈d+2 | n,v∈'d,,n,v {d = d ,,' (n1 , v1)} {n2} {v2} ... | n∈d++1 | n∈d++2 rewrite lookup-cons-1' n∈d++1 | lookup-cons-1' n∈d++2 = refl fun n | Inr n≠n1 | Inr n≠n2 | Inl (_ , n∈d) with n∈d→'n∈d+ {v' = v1} n≠n1 n∈d | n∈d→'n∈d+ {v' = v2} n≠n2 n∈d ... | n∈d+1 | n∈d+2 with n∈d→'n∈d+ {v' = v2} n≠n2 n∈d+1 | n∈d→'n∈d+ {v' = v1} n≠n1 n∈d+2 ... | n∈d++1 | n∈d++2 rewrite lookup-cons-1' n∈d++1 | lookup-cons-1' n∈d++2 = refl fun n | Inr n≠n1 | Inr n≠n2 | Inr n#d with n#d→'n#d+ {v' = v1} n≠n1 n#d | n#d→'n#d+ {v' = v2} n≠n2 n#d ... | n#d+1 | n#d+2 with n#d→'n#d+ {v' = v2} n≠n2 n#d+1 | n#d→'n#d+ {v' = v1} n≠n1 n#d+2 ... | n#d++1 | n#d++2 rewrite lookup-cp-2' n#d++1 | lookup-cp-2' n#d++2 = refl
{ "alphanum_fraction": 0.3922377569, "avg_line_length": 41.4208860759, "ext": "agda", "hexsha": "0489857f026e004f6d805e48b6709842b76abb32", "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": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nickcollins/dependent-dicts-agda", "max_forks_repo_path": "delta-lemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "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": "nickcollins/dependent-dicts-agda", "max_issues_repo_path": "delta-lemmas.agda", "max_line_length": 127, "max_stars_count": null, "max_stars_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nickcollins/dependent-dicts-agda", "max_stars_repo_path": "delta-lemmas.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12497, "size": 26178 }
module Issue335 where postulate A : Set k : (.A -> Set) -> A bla = k (\ .(x : A) -> A) -- syntax for irrelevant typed lambda now exists
{ "alphanum_fraction": 0.5957446809, "avg_line_length": 17.625, "ext": "agda", "hexsha": "9f084215f96eab86b361d6123b42e41ca8cf9897", "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/succeed/Issue335.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/Issue335.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue335.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": 45, "size": 141 }
module Data.Nat.Etc where open import Data.Nat open import Data.Nat.Properties.Simple open import Function open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; trans; sym) open PropEq.≡-Reasoning -- exponention _^_ : ℕ → ℕ → ℕ a ^ zero = 1 a ^ suc b = a * (a ^ b) -------------------------------------------------------------------------------- -- Properties -------------------------------------------------------------------------------- distrib-left-*-+ : ∀ m n o → m * (n + o) ≡ m * n + m * o distrib-left-*-+ m n o = begin m * (n + o) ≡⟨ *-comm m (n + o) ⟩ (n + o) * m ≡⟨ distribʳ-*-+ m n o ⟩ n * m + o * m ≡⟨ cong (flip _+_ (o * m)) (*-comm n m) ⟩ m * n + o * m ≡⟨ cong (_+_ (m * n)) (*-comm o m) ⟩ m * n + m * o ∎ {- no-zero-divisor : ∀ m n → m ≢ 0 → m * n ≡ 0 → n ≡ 0 no-zero-divisor zero n p q = contradiction q p no-zero-divisor (suc m) zero p q = refl no-zero-divisor (suc m) (suc n) p () m^n≢0 : ∀ m n → {m≢0 : m ≢ 0} → m ^ n ≢ 0 m^n≢0 m zero {p} = λ () m^n≢0 m (suc n) {p} = contraposition (no-zero-divisor m (m ^ n) p) (m^n≢0 m n {p}) m≰n⇒n<m : (m n : ℕ) → m ≰ n → m > n m≰n⇒n<m zero n p = contradiction p (λ z → z z≤n) m≰n⇒n<m (suc m) zero p = s≤s z≤n m≰n⇒n<m (suc m) (suc n) p = s≤s (m≰n⇒n<m m n (λ z → p (s≤s z))) -} >⇒≰ : _>_ ⇒ _≰_ >⇒≰ {zero} () >⇒≰ {suc m} {zero} rel () >⇒≰ {suc m} {suc n} (s≤s rel) (s≤s x) = contradiction x (>⇒≰ rel) >⇒≢ : _>_ ⇒ _≢_ >⇒≢ {zero} () m≡n >⇒≢ {suc m} {zero} m>n () >⇒≢ {suc m} {suc n} (s≤s m>n) m≡n = >⇒≢ m>n (cong pred m≡n) {- ≰⇒> : _≰_ ⇒ _>_ ≰⇒> {zero} z≰n with z≰n z≤n ... | () ≰⇒> {suc m} {zero} _ = s≤s z≤n ≰⇒> {suc m} {suc n} m≰n = s≤s (≰⇒> (m≰n ∘ s≤s)) -} {- begin {! !} ≡⟨ {! !} ⟩ {! !} ≡⟨ {! !} ⟩ {! !} ≡⟨ {! !} ⟩ {! !} ≡⟨ {! !} ⟩ {! !} ∎ -}
{ "alphanum_fraction": 0.3991354467, "avg_line_length": 25.7037037037, "ext": "agda", "hexsha": "b622648bcfa3f87460f5eb7cefe295815c4bffb7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/Data/Nat/Etc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/Data/Nat/Etc.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/Data/Nat/Etc.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 966, "size": 2082 }
-- Concrete definition of contexts over a sort T module SOAS.Context {T : Set} where open import SOAS.Common open import Data.List using (List; []; _∷_; _++_) -- Context: a list of types data Ctx : Set where ∅ : Ctx _∙_ : (α : T) → (Γ : Ctx) → Ctx infixr 50 _∙_ -- Singleton context pattern _⌋ τ = τ ∙ ∅ pattern ⌈_⌋ α = α ∙ ∅ pattern ⌊_ α = α infixr 60 _⌋ infix 70 ⌈_⌋ infix 70 ⌊_ -- Context concatenation _∔_ : Ctx → Ctx → Ctx ∅ ∔ Δ = Δ (α ∙ Γ) ∔ Δ = α ∙ (Γ ∔ Δ) infixl 20 _∔_ -- Context concatenation is associative ∔-assoc : (Γ Δ Θ : Ctx) → ((Γ ∔ Δ) ∔ Θ) ≡ (Γ ∔ (Δ ∔ Θ)) ∔-assoc ∅ Δ Θ = refl ∔-assoc (α ∙ Γ) Δ Θ = cong (α ∙_) (∔-assoc Γ Δ Θ) -- Empty context is right unit of context concatenation ∔-unitʳ : (Γ : Ctx) → Γ ∔ ∅ ≡ Γ ∔-unitʳ ∅ = refl ∔-unitʳ (α ∙ Γ) = cong (α ∙_) (∔-unitʳ Γ)
{ "alphanum_fraction": 0.5670356704, "avg_line_length": 20.8461538462, "ext": "agda", "hexsha": "a1a6703d414d7d40f2f571b8780bbba737a2d0f8", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Context.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Context.agda", "max_line_length": 55, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Context.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 393, "size": 813 }
-- Andreas, 2017-03-21, issue #2466 -- The unifier should not turn user-written variable patterns into -- dot patterns. -- {-# OPTIONS -v reify.implicit:100 -v interaction.case:100 #-} -- {-# OPTIONS -v tc.lhs.unify:40 #-} postulate A B : Set module Explicit where data D : A → B → Set where c : ∀ p {p'} x → D p' x → D p x test : ∀ p x → D p x → D p x test .p _ (c p x pp) = {!p'!} where y = x -- Expected: test .p _ (c p {p'} x pp) = ? module Implicit where data D : A → B → Set where c : ∀ {p p' x} → D p' x → D p x test : ∀ p {x} → D p x → D p x test .p (c {p} {x = x} pp) = {!p'!} where y = x -- Expected: test .p (c {p} {p'} {x} pp) = ?
{ "alphanum_fraction": 0.5100574713, "avg_line_length": 19.8857142857, "ext": "agda", "hexsha": "23bae51ac87e49520d795994f36ebf05490fc7a5", "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": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phadej/agda", "max_forks_repo_path": "test/interaction/Issue2466.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "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": "phadej/agda", "max_issues_repo_path": "test/interaction/Issue2466.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phadej/agda", "max_stars_repo_path": "test/interaction/Issue2466.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 272, "size": 696 }
module InstanceArgs where data UnitMonoid : Set where u : UnitMonoid p : UnitMonoid → UnitMonoid → UnitMonoid record Plus (A : Set) : Set where infixl 6 _+_ field _+_ : A → A → A open Plus {{...}} instance plus-unitMonoid : Plus UnitMonoid plus-unitMonoid = record { _+_ = p } bigValue : UnitMonoid bigValue = u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u + u
{ "alphanum_fraction": 0.270718232, "avg_line_length": 65.6125, "ext": "agda", "hexsha": "ba99b40f09aa37245e038aa75004e3d790611e44", "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": "benchmark/misc/InstanceArgs.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": "benchmark/misc/InstanceArgs.agda", "max_line_length": 81, "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": "benchmark/misc/InstanceArgs.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": 2568, "size": 5249 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) open import Categories.Category.Monoidal.Core using (Monoidal) open import Categories.Category.Monoidal.Symmetric using (Symmetric) module Categories.Category.Monoidal.Star-Autonomous {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Categories.Category.Product using (_⁂_; assocˡ) open import Categories.Functor using (Functor; _∘F_; id) open import Categories.Functor.Properties using (FullyFaithful) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Functor.Hom open Category C renaming (op to Cᵒᵖ) hiding (id) open Monoidal M open Functor ⊗ renaming (op to ⊗ₒₚ) open Hom C record Star-Autonomous : Set (levelOfTerm M) where field symmetric : Symmetric M Star : Functor Cᵒᵖ C open Functor Star renaming (op to Starₒₚ) public field FF-Star : FullyFaithful Star A**≃A : (Star ∘F Starₒₚ) ≃ id 𝒞[A⊗B,C*]≃𝒞[A,B⊗C*] : Hom[-,-] ∘F (⊗ₒₚ ⁂ Star) ≃ Hom[-,-] ∘F (id ⁂ (Star ∘F ⊗ₒₚ)) ∘F assocˡ _ _ _
{ "alphanum_fraction": 0.7241063245, "avg_line_length": 33.0606060606, "ext": "agda", "hexsha": "9f88fa738f7b227f1dbbada5b61ad07b0199aa97", "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/Monoidal/Star-Autonomous.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/Monoidal/Star-Autonomous.agda", "max_line_length": 103, "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/Monoidal/Star-Autonomous.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": 362, "size": 1091 }
------------------------------------------------------------------------ -- Recognisers built on top of the parsers ------------------------------------------------------------------------ -- Note that these recognisers are different from the ones in -- TotalRecognisers.LeftRecursion: these allow the use of fewer sharps. -- (Compare the examples in TotalRecognisers.LeftRecursion.Expression -- and TotalParserCombinators.Recogniser.Expression.) module TotalParserCombinators.Recogniser where open import Category.Monad open import Codata.Musical.Notation open import Data.Bool open import Data.List as List import Data.List.Categorical open import Data.Maybe open import Data.Unit open import Level open RawMonadPlus {f = zero} Data.List.Categorical.monadPlus using () renaming (_⊛_ to _⊛′_) open import TotalParserCombinators.Parser as Parser using (Parser; flatten); open Parser.Parser import TotalParserCombinators.Lib as Lib ------------------------------------------------------------------------ -- Helper function infixl 4 _·′_ _·′_ : (mb₁ mb₂ : Maybe (List ⊤)) → List ⊤ mb₁ ·′ nothing = [] mb₁ ·′ just b₂ = List.map _ (flatten mb₁) ⊛′ b₂ ------------------------------------------------------------------------ -- Recognisers infixl 50 _·_ infixl 5 _∣_ -- Recognisers. mutual -- The index is non-empty if the corresponding language contains the -- empty string (is nullable). data P (Tok : Set) : List ⊤ → Set₁ where -- Parsers can be turned into recognisers. lift : ∀ {R n} (p : Parser Tok R n) → P Tok (List.map _ n) -- Symmetric choice. _∣_ : ∀ {n₁ n₂} (p₁ : P Tok n₁) (p₂ : P Tok n₂) → P Tok (n₁ ++ n₂) -- Sequencing. _·_ : ∀ {n₁ n₂} (p₁ : ∞⟨ n₂ ⟩P Tok (flatten n₁)) (p₂ : ∞⟨ n₁ ⟩P Tok (flatten n₂)) → P Tok (n₁ ·′ n₂) -- Delayed if the index is /nothing/. ∞⟨_⟩P : Maybe (List ⊤) → Set → List ⊤ → Set₁ ∞⟨ nothing ⟩P Tok n = ∞ (P Tok n) ∞⟨ just _ ⟩P Tok n = P Tok n ------------------------------------------------------------------------ -- Helper function related to ∞⟨_⟩P -- Is the argument parser forced? If the result is just something, -- then it is. forced? : ∀ {Tok m n} → ∞⟨ m ⟩P Tok n → Maybe (List ⊤) forced? {m = m} _ = m ------------------------------------------------------------------------ -- The semantics of the recognisers is defined by translation ⟦_⟧ : ∀ {Tok n} (p : P Tok n) → Parser Tok ⊤ n ⟦ lift p ⟧ = _ <$> p ⟦ p₁ ∣ p₂ ⟧ = ⟦ p₁ ⟧ ∣ ⟦ p₂ ⟧ ⟦ p₁ · p₂ ⟧ with forced? p₁ | forced? p₂ ... | just xs | nothing = _ <$> ⟦ p₁ ⟧ ⊛ ♯ ⟦ ♭ p₂ ⟧ ... | just xs | just ys = _ <$> ⟦ p₁ ⟧ ⊛ ⟦ p₂ ⟧ ... | nothing | nothing = ♯ (_ <$> ⟦ ♭ p₁ ⟧) ⊛ ♯ ⟦ ♭ p₂ ⟧ ... | nothing | just ys = ♯ (_ <$> ⟦ ♭ p₁ ⟧) ⊛ ⟦ p₂ ⟧
{ "alphanum_fraction": 0.5124234786, "avg_line_length": 30.8555555556, "ext": "agda", "hexsha": "98c171b972377e610c5accc08ffd1d091a048026", "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/Recogniser.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/Recogniser.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Recogniser.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": 855, "size": 2777 }
{-# OPTIONS --rewriting #-} -- -- Prelude.agda - Some base definitions -- module Prelude where open import Agda.Primitive public record ⊤ : Set where constructor tt {-# BUILTIN UNIT ⊤ #-} record Σ {i j} (A : Set i) (B : A → Set j) : Set (i ⊔ j) where constructor _,_ field fst : A snd : B fst open Σ public data ℕ : Set where O : ℕ S : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} uncurry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : Set k} → (φ : (a : A) → (b : B a) → C) → Σ A B → C uncurry φ (a , b) = φ a b curry : ∀ {i j k} {A : Set i} {B : A → Set j} {C : Set k} → (ψ : Σ A B → C) → (a : A) → (b : B a) → C curry ψ a b = ψ (a , b) infix 30 _==_ data _==_ {i} {A : Set i} (a : A) : A → Set i where idp : a == a {-# BUILTIN EQUALITY _==_ #-} {-# BUILTIN REFL idp #-} transport : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ : A} (p : a₀ == a₁) → P a₀ → P a₁ transport P idp x = x sym : ∀ {i} {A : Set i} {a₀ a₁ : A} (p : a₀ == a₁) → a₁ == a₀ sym idp = idp etrans : ∀ {i} {A : Set i} {a₀ a₁ a₂ : A} → a₀ == a₁ → a₁ == a₂ → a₀ == a₂ etrans idp idp = idp proof-irrelevance : ∀ {a} {A : Set a} {x y : A} (p q : x == y) → p == q proof-irrelevance idp idp = idp elimtransport : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ : A} (p : a₀ == a₁) (q : a₀ == a₁) (r : p == q) (x : P a₀) → transport P p x == transport P q x elimtransport P p .p idp x = idp tr! : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ : A} (p : a₀ == a₁) (q : a₀ == a₁) (x : P a₀) → transport P p x == transport P q x tr! P p q x = elimtransport P p q (proof-irrelevance p q) x tr² : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ a₂ : A} (p : a₀ == a₁) (q : a₁ == a₂) (x : P a₀) → transport P q (transport P p x) == transport P (etrans p q) x tr² P idp idp x = idp tr³ : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ a₂ a₃ : A} (p₀ : a₀ == a₁) (p₁ : a₁ == a₂) (p₂ : a₂ == a₃) (x : P a₀) → transport P p₂ (transport P p₁ (transport P p₀ x)) == transport P (etrans p₀ (etrans p₁ p₂)) x tr³ P idp idp idp x = idp tr⁴ : ∀{i j} {A : Set i} (P : A → Set j) {a₀ a₁ a₂ a₃ a₄ : A} (p₀ : a₀ == a₁) (p₁ : a₁ == a₂) (p₂ : a₂ == a₃) (p₃ : a₃ == a₄) (x : P a₀) → transport P p₃ (transport P p₂ (transport P p₁ (transport P p₀ x))) == transport P (etrans p₀ (etrans p₁ (etrans p₂ p₃))) x tr⁴ P idp idp idp idp x = idp hfiber : ∀ {i} {A B : Set i} (f : A → B) (b : B) → Set i hfiber {A = A} f b = Σ A (λ a → f a == b) PathOver : ∀ {i j} {A : Set i} (B : A → Set j) {a₀ a₁ : A} (p : a₀ == a₁) (b₉ : B a₀) (b₁ : B a₁) → Set j PathOver B idp b₀ b₁ = b₀ == b₁ infix 30 PathOver syntax PathOver B p u v = u == v [ B ↓ p ] Σ-r : ∀ {i j k} {A : Set i} {B : A → Set j} (C : Σ A B → Set k) → A → Set (j ⊔ k) Σ-r {A = A} {B = B} C a = Σ (B a) (λ b → C (a , b)) Σ-in : ∀ {i j k} {A : Set i} {B : A → Set j} (C : (a : A) → B a → Set k) → A → Set (j ⊔ k) Σ-in {A = A} {B = B} C a = Σ (B a) (λ b → C a b) infix 30 _↦_ postulate _↦_ : ∀ {i} {A : Set i} → A → A → Set i {-# BUILTIN REWRITE _↦_ #-} data bool : Set where true : bool false : bool data ⊥ : Set where if_then_else : ∀ {a} {A : Set a} → bool → A → A → A if true then A else B = A if false then A else B = B _≤_ : ℕ → ℕ → bool O ≤ n₁ = true S n₀ ≤ O = false S n₀ ≤ S n₁ = n₀ ≤ n₁ min : ℕ → ℕ → ℕ min n₀ n₁ with n₀ ≤ n₁ min n₀ n₁ | true = n₀ min n₀ n₁ | false = n₁ ≤S : ∀ (n₀ n₁ : ℕ) → (n₀ ≤ n₁) == true → (n₀ ≤ S n₁) == true ≤S O n₁ x = idp ≤S (S n₀) O () ≤S (S n₀) (S n₁) x = ≤S n₀ n₁ x S≤S : ∀ (n₀ n₁ : ℕ) → (n₀ ≤ n₁) == true → (S n₀ ≤ S n₁) == true S≤S n₀ n₁ x = x
{ "alphanum_fraction": 0.4604663629, "avg_line_length": 29.1484375, "ext": "agda", "hexsha": "b9153356ddd83f2e708e63f8530b315ad1cc685c", "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": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt", "max_forks_repo_path": "agda/Prelude.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_issues_repo_issues_event_max_datetime": "2018-07-12T16:44:10.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-14T09:31:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thibautbenjamin/catt", "max_issues_repo_path": "agda/Prelude.agda", "max_line_length": 265, "max_stars_count": 11, "max_stars_repo_head_hexsha": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ThiBen/catt", "max_stars_repo_path": "agda/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2020-05-21T00:44:36.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-31T10:06:17.000Z", "num_tokens": 1767, "size": 3731 }
-- Andreas, 2021-08-19, issue #5291 reported by gergoerdi -- https://stackoverflow.com/q/66816547/477476 open import Agda.Builtin.Char open import Agda.Builtin.String works : Char works = '\SOH' -- This used to fail as the matcher was committed to finding SOH after SO. -- (Worked only for prefix-free matching.) test : Char test = '\SO' -- Here, all the silly legacy ASCII escape sequences in their glorious detail... all : String all = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK\BEL\BS\HT\LF\VT\FF\CR\SO\SI\DEL\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\EM\SUB\ESC\FS\GS\RS\US"
{ "alphanum_fraction": 0.7243816254, "avg_line_length": 28.3, "ext": "agda", "hexsha": "5972e0b99fab564766e43d1e09f5a451afc063ff", "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/Issue5291.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/Issue5291.agda", "max_line_length": 127, "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/Issue5291.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": 199, "size": 566 }
{-# OPTIONS --without-K --safe #-} module Categories.Bicategory.Monad.Properties where open import Categories.Category open import Categories.Bicategory.Instance.Cats open import Categories.NaturalTransformation using (NaturalTransformation) open import Categories.Functor using (Functor) import Categories.Bicategory.Monad as BicatMonad import Categories.Monad as ElemMonad import Categories.Morphism.Reasoning as MR -------------------------------------------------------------------------------- -- Bicategorical Monads in Cat are the same as the more elementary -- definition of Monads. CatMonad⇒Monad : ∀ {o ℓ e} → (T : BicatMonad.Monad (Cats o ℓ e)) → ElemMonad.Monad (BicatMonad.Monad.C T) CatMonad⇒Monad T = record { F = T.T ; η = T.η ; μ = T.μ ; assoc = λ {X} → begin η T.μ X ∘ F₁ T.T (η T.μ X) ≈⟨ intro-ids ⟩ (η T.μ X ∘ (F₁ T.T (η T.μ X) ∘ id) ∘ id) ≈⟨ T.assoc ⟩ (η T.μ X ∘ F₁ T.T id ∘ η T.μ (F₀ T.T X)) ≈⟨ ∘-resp-≈ʳ (∘-resp-≈ˡ (identity T.T) ○ identityˡ) ⟩ η T.μ X ∘ η T.μ (F₀ T.T X) ∎ ; sym-assoc = λ {X} → begin η T.μ X ∘ η T.μ (F₀ T.T X) ≈⟨ intro-F-ids ⟩ η T.μ X ∘ (F₁ T.T id ∘ η T.μ (F₀ T.T X)) ∘ id ≈⟨ T.sym-assoc ⟩ η T.μ X ∘ F₁ T.T (η T.μ X) ∘ id ≈⟨ ∘-resp-≈ʳ identityʳ ⟩ η T.μ X ∘ F₁ T.T (η T.μ X) ∎ ; identityˡ = λ {X} → begin η T.μ X ∘ F₁ T.T (η T.η X) ≈⟨ intro-ids ⟩ η T.μ X ∘ (F₁ T.T (η T.η X) ∘ id) ∘ id ≈⟨ T.identityˡ ⟩ id ∎ ; identityʳ = λ {X} → begin η T.μ X ∘ η T.η (F₀ T.T X) ≈⟨ intro-F-ids ⟩ η T.μ X ∘ (F₁ T.T id ∘ η T.η (F₀ T.T X)) ∘ id ≈⟨ T.identityʳ ⟩ id ∎ } where module T = BicatMonad.Monad T open Category (BicatMonad.Monad.C T) open HomReasoning open Equiv open MR (BicatMonad.Monad.C T) open NaturalTransformation open Functor intro-ids : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → f ∘ g ≈ f ∘ (g ∘ id) ∘ id intro-ids = ⟺ (∘-resp-≈ʳ identityʳ) ○ ⟺ (∘-resp-≈ʳ identityʳ) intro-F-ids : ∀ {X Y Z} {f : F₀ T.T Y ⇒ Z} {g : X ⇒ F₀ T.T Y} → f ∘ g ≈ f ∘ (F₁ T.T id ∘ g) ∘ id intro-F-ids = ∘-resp-≈ʳ (⟺ identityˡ ○ ⟺ (∘-resp-≈ˡ (identity T.T))) ○ ⟺ (∘-resp-≈ʳ identityʳ) Monad⇒CatMonad : ∀ {o ℓ e} {𝒞 : Category o ℓ e} → (T : ElemMonad.Monad 𝒞) → BicatMonad.Monad (Cats o ℓ e) Monad⇒CatMonad {𝒞 = 𝒞} T = record { C = 𝒞 ; T = T.F ; η = T.η ; μ = T.μ ; assoc = λ {X} → begin T.μ.η X ∘ (T.F.F₁ (T.μ.η X) ∘ id) ∘ id ≈⟨ eliminate-ids ⟩ T.μ.η X ∘ T.F.F₁ (T.μ.η X) ≈⟨ T.assoc ⟩ T.μ.η X ∘ T.μ.η (T.F.F₀ X) ≈⟨ ∘-resp-≈ʳ (⟺ identityˡ ○ ∘-resp-≈ˡ (⟺ T.F.identity)) ⟩ T.μ.η X ∘ T.F.F₁ id ∘ T.μ.η (T.F.F₀ X) ∎ ; sym-assoc = λ {X} → begin T.μ.η X ∘ (T.F.F₁ id ∘ T.μ.η (T.F.F₀ X)) ∘ id ≈⟨ eliminate-F-ids ⟩ T.μ.η X ∘ T.μ.η (T.F.F₀ X) ≈⟨ T.sym-assoc ⟩ T.μ.η X ∘ T.F.F₁ (T.μ.η X) ≈⟨ ∘-resp-≈ʳ (⟺ identityʳ) ⟩ T.μ.η X ∘ T.F.F₁ (T.μ.η X) ∘ id ∎ ; identityˡ = λ {X} → begin T.μ.η X ∘ (T.F.F₁ (T.η.η X) ∘ id) ∘ id ≈⟨ eliminate-ids ⟩ T.μ.η X ∘ T.F.F₁ (T.η.η X) ≈⟨ T.identityˡ ⟩ id ∎ ; identityʳ = λ {X} → begin (T.μ.η X ∘ (T.F.F₁ id ∘ T.η.η (T.F.F₀ X)) ∘ id) ≈⟨ eliminate-F-ids ⟩ T.μ.η X ∘ T.η.η (T.F.F₀ X) ≈⟨ T.identityʳ ⟩ id ∎ } where module T = ElemMonad.Monad T open Category 𝒞 open HomReasoning open MR 𝒞 eliminate-ids : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → f ∘ (g ∘ id) ∘ id ≈ f ∘ g eliminate-ids = ∘-resp-≈ʳ identityʳ ○ ∘-resp-≈ʳ identityʳ eliminate-F-ids : ∀ {X Y Z} {f : T.F.F₀ Y ⇒ Z} {g : X ⇒ T.F.F₀ Y} → f ∘ (T.F.F₁ id ∘ g) ∘ id ≈ f ∘ g eliminate-F-ids = ∘-resp-≈ʳ identityʳ ○ ∘-resp-≈ʳ (∘-resp-≈ˡ T.F.identity ○ identityˡ)
{ "alphanum_fraction": 0.4710346572, "avg_line_length": 42.0531914894, "ext": "agda", "hexsha": "c4df88c1b02ed9c6f25e861dd4802d20970026ab", "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/Bicategory/Monad/Properties.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/Bicategory/Monad/Properties.agda", "max_line_length": 105, "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/Bicategory/Monad/Properties.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": 1802, "size": 3953 }
module vtv where open import Function.Base open import Data.Unit.Base open import Agda.Builtin.Nat open import Data.Integer open import Data.Product open import Agda.Builtin.String open import Data.List open import Data.Bool open import Data.Maybe.Base using (just) using (nothing) open import Agda.Builtin.Coinduction import IO.Primitive as Prim open import IO renaming (_>>=_ to _>>>=_) renaming (_>>_ to _>>>_) open import verify using (parse-verify) open import Codata.Musical.Colist renaming (length to length*) renaming (map to map*) renaming ([_] to [_]*) renaming (_∷_ to _∷*_) renaming (_++_ to _++*_) open import Codata.Musical.Costring open import Data.Bool using (if_then_else_) open import basic using (Chars) postulate prim-get-args : Prim.IO (List String) prim-exit-failure : Prim.IO ⊤ {-# FOREIGN GHC import qualified System.Environment as Env #-} {-# FOREIGN GHC import Data.Text #-} {-# FOREIGN GHC import qualified System.Exit #-} {-# COMPILE GHC prim-get-args = fmap (fmap pack) Env.getArgs #-} {-# COMPILE GHC prim-exit-failure = System.Exit.exitFailure #-} exit-failure : IO ⊤ exit-failure = lift prim-exit-failure _>>=_ : {A : Set} {B : Set} → IO A → (A → IO B) → IO B _>>=_ f g = ♯ f >>>= \ x → ♯ (g x) _>>_ : {A : Set} {B : Set} → IO A → IO B → IO B _>>_ f g = ♯ f >>> ♯ g skip : IO ⊤ skip = lift (Prim.return tt) get-args : IO (List String) get-args = lift prim-get-args put-str-ln : String → IO ⊤ put-str-ln s = putStr s >> (putStr "\n" >> skip) costring-to-chars : Costring → Chars costring-to-chars (c ∷* cs) = c ∷ costring-to-chars (♭ cs) costring-to-chars _ = [] -- print-result : Res ⊤ → IO ⊤ -- print-result (cont tt x) = put-str-ln "Proof verified (kernel = ATTV)." -- print-result (stop s) = do -- putStr "Invalid proof : " -- put-str-ln s -- exit-failure print-result : Bool → IO ⊤ print-result true = put-str-ln "Proof verified by VTV." print-result false = do putStr "Invalid proof" exit-failure io-verify : IO ⊤ io-verify = do (pn ∷ _) ← get-args where _ → (put-str-ln "Missing proof file name." >> exit-failure) ps ← getContents cs ← readFiniteFile pn >>= (return ∘ primStringToList) print-result (parse-verify (costring-to-chars ps) cs) main : Prim.IO ⊤ main = run io-verify
{ "alphanum_fraction": 0.658123371, "avg_line_length": 27.0823529412, "ext": "agda", "hexsha": "3f034039f88d6b6e44b155e2eeac1311fc3f86dc", "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": "6577dfad2f197a9d9ed003138798930d515185a4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skbaek/tesc", "max_forks_repo_path": "vtv/vtv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6577dfad2f197a9d9ed003138798930d515185a4", "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": "skbaek/tesc", "max_issues_repo_path": "vtv/vtv.agda", "max_line_length": 74, "max_stars_count": 7, "max_stars_repo_head_hexsha": "6577dfad2f197a9d9ed003138798930d515185a4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skbaek/tesc", "max_stars_repo_path": "vtv/vtv.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-01T12:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2020-06-30T13:16:19.000Z", "num_tokens": 712, "size": 2302 }
------------------------------------------------------------------------ -- Pushouts, defined using a HIT ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- This module follows the HoTT book rather closely. -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining pushouts uses path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Pushout {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J hiding (id; _∘_) import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import Pointed-type equality-with-J using (Pointed-type) import Suspension eq as S private variable a b l ℓ m p r : Level A B : Type a S : A -- Spans. record Span l r m : Type (lsuc (l ⊔ r ⊔ m)) where field {Left} : Type l {Right} : Type r {Middle} : Type m left : Middle → Left right : Middle → Right -- Pushouts. data Pushout (S : Span l r m) : Type (l ⊔ r ⊔ m) where inl : Span.Left S → Pushout S inr : Span.Right S → Pushout S glueᴾ : (x : Span.Middle S) → inl (Span.left S x) P.≡ inr (Span.right S x) -- Glue. glue : (x : Span.Middle S) → _≡_ {A = Pushout S} (inl (Span.left S x)) (inr (Span.right S x)) glue x = _↔_.from ≡↔≡ (glueᴾ x) -- A dependent eliminator, expressed using paths. elimᴾ : {S : Span l r m} (open Span S) (P : Pushout S → Type p) (h₁ : (x : Left) → P (inl x)) (h₂ : (x : Right) → P (inr x)) → (∀ x → P.[ (λ i → P (glueᴾ x i)) ] h₁ (left x) ≡ h₂ (right x)) → (x : Pushout S) → P x elimᴾ P h₁ h₂ g = λ where (inl x) → h₁ x (inr x) → h₂ x (glueᴾ x i) → g x i -- A non-dependent eliminator. recᴾ : {S : Span l r m} (open Span S) (h₁ : Left → A) (h₂ : Right → A) → (∀ x → h₁ (left x) P.≡ h₂ (right x)) → Pushout S → A recᴾ = elimᴾ _ -- A dependent eliminator. elim : {S : Span l r m} (open Span S) (P : Pushout S → Type p) (h₁ : (x : Left) → P (inl x)) (h₂ : (x : Right) → P (inr x)) → (∀ x → subst P (glue x) (h₁ (left x)) ≡ h₂ (right x)) → (x : Pushout S) → P x elim P h₁ h₂ g = elimᴾ P h₁ h₂ (subst≡→[]≡ ∘ g) elim-glue : {S : Span l r m} (open Span S) {P : Pushout S → Type p} {h₁ : (x : Left) → P (inl x)} {h₂ : (x : Right) → P (inr x)} {g : ∀ x → subst P (glue x) (h₁ (left x)) ≡ h₂ (right x)} {x : Middle} → dcong (elim P h₁ h₂ g) (glue x) ≡ g x elim-glue = dcong-subst≡→[]≡ (refl _) -- A non-dependent eliminator. rec : {S : Span l r m} (open Span S) (h₁ : Left → A) (h₂ : Right → A) → (∀ x → h₁ (left x) ≡ h₂ (right x)) → Pushout S → A rec h₁ h₂ g = recᴾ h₁ h₂ (_↔_.to ≡↔≡ ∘ g) rec-glue : {S : Span l r m} (open Span S) {h₁ : Left → A} {h₂ : Right → A} {g : ∀ x → h₁ (left x) ≡ h₂ (right x)} {x : Middle} → cong (rec h₁ h₂ g) (glue x) ≡ g x rec-glue = cong-≡↔≡ (refl _) -- Cocones. Cocone : Span l r m → Type a → Type (a ⊔ l ⊔ r ⊔ m) Cocone S A = ∃ λ (left : Left → A) → ∃ λ (right : Right → A) → (x : Middle) → left (Span.left S x) ≡ right (Span.right S x) where open Span S using (Left; Right; Middle) -- Some projection functions for cocones. module Cocone (c : Cocone S A) where open Span S using (Left; Right; Middle) left : Left → A left = proj₁ c right : Right → A right = proj₁ (proj₂ c) left-left≡right-right : (x : Middle) → left (Span.left S x) ≡ right (Span.right S x) left-left≡right-right = proj₂ (proj₂ c) -- A universal property for pushouts. Pushout→↔Cocone : (Pushout S → A) ↔ Cocone S A Pushout→↔Cocone {S = S} {A = A} = record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to-from } ; left-inverse-of = from-to } where open Span S to : (Pushout S → A) → Cocone S A to f = f ∘ inl , f ∘ inr , cong f ∘ glue from : Cocone S A → (Pushout S → A) from c = rec (Cocone.left c) (Cocone.right c) (Cocone.left-left≡right-right c) to-from : ∀ c → to (from c) ≡ c to-from c = cong (λ x → _ , _ , x) $ ⟨ext⟩ λ x → cong (from c) (glue x) ≡⟨ rec-glue ⟩∎ Cocone.left-left≡right-right c x ∎ from-to : ∀ f → from (to f) ≡ f from-to f = ⟨ext⟩ $ elim _ (λ _ → refl _) (λ _ → refl _) (λ x → subst (λ y → from (to f) y ≡ f y) (glue x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to f)) (glue x))) (trans (refl _) (cong f (glue x))) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩ trans (sym (cong (from (to f)) (glue x))) (cong f (glue x)) ≡⟨ cong (λ eq → trans (sym eq) (cong f (glue x))) rec-glue ⟩ trans (sym (Cocone.left-left≡right-right (to f) x)) (cong f (glue x)) ≡⟨⟩ trans (sym (cong f (glue x))) (cong f (glue x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- Joins. Join : Type a → Type b → Type (a ⊔ b) Join A B = Pushout (record { Middle = A × B ; left = proj₁ ; right = proj₂ }) -- Join is symmetric. Join-symmetric : Join A B ≃ Join B A Join-symmetric = Eq.↔→≃ to to to-to to-to where to : Join A B → Join B A to = rec inr inl (sym ∘ glue ∘ swap) to-to : (x : Join A B) → to (to x) ≡ x to-to = elim _ (λ _ → refl _) (λ _ → refl _) (λ p → subst (λ x → to (to x) ≡ x) (glue p) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (to ∘ to) (glue p))) (trans (refl _) (cong id (glue p))) ≡⟨ cong₂ (trans ∘ sym) (sym $ cong-∘ _ _ _) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (cong to (cong to (glue p)))) (glue p) ≡⟨ cong (flip trans _) $ cong (sym ∘ cong to) rec-glue ⟩ trans (sym (cong to (sym (glue (swap p))))) (glue p) ≡⟨ cong (flip trans _) $ cong sym $ cong-sym _ _ ⟩ trans (sym (sym (cong to (glue (swap p))))) (glue p) ≡⟨ cong (flip trans _) $ sym-sym _ ⟩ trans (cong to (glue (swap p))) (glue p) ≡⟨ cong (flip trans _) rec-glue ⟩ trans (sym (glue (swap (swap p)))) (glue p) ≡⟨⟩ trans (sym (glue p)) (glue p) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- The empty type is a right identity for Join. Join-⊥ʳ : Join A (⊥ {ℓ = ℓ}) ≃ A Join-⊥ʳ = Eq.↔→≃ (rec id ⊥-elim (λ { (_ , ()) })) inl refl (elim _ (λ _ → refl _) (λ ()) (λ { (_ , ()) })) -- The empty type is a left identity for Join. Join-⊥ˡ : Join (⊥ {ℓ = ℓ}) A ≃ A Join-⊥ˡ {A = A} = Join ⊥ A ↝⟨ Join-symmetric ⟩ Join A ⊥ ↝⟨ Join-⊥ʳ ⟩□ A □ -- Cones. Cone : {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b) Cone f = Pushout (record { Left = ⊤ ; right = f }) -- Wedges. Wedge : Pointed-type a → Pointed-type b → Type (a ⊔ b) Wedge (A , a) (B , b) = Pushout (record { Middle = ⊤ ; left = const a ; right = const b }) -- Smash products. Smash-product : Pointed-type a → Pointed-type b → Type (a ⊔ b) Smash-product PA@(A , a) PB@(B , b) = Cone f where f : Wedge PA PB → A × B f = rec (_, b) (a ,_) (λ _ → refl _) -- Suspensions. Susp : Type a → Type a Susp A = Pushout (record { Left = ⊤ ; Middle = A ; Right = ⊤ }) -- These suspensions are equivalent to the ones defined in Suspension. Susp≃Susp : Susp A ≃ S.Susp A Susp≃Susp = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to∘from } ; left-inverse-of = from∘to }) where to : Susp A → S.Susp A to = recᴾ (λ _ → S.north) (λ _ → S.south) S.meridianᴾ from : S.Susp A → Susp A from = S.recᴾ (inl _) (inr _) glueᴾ to∘from : ∀ x → to (from x) ≡ x to∘from = _↔_.from ≡↔≡ ∘ S.elimᴾ _ P.refl P.refl (λ a i _ → S.meridianᴾ a i) from∘to : ∀ x → from (to x) ≡ x from∘to = _↔_.from ≡↔≡ ∘ elimᴾ _ (λ _ → P.refl) (λ _ → P.refl) (λ a i _ → glueᴾ a i)
{ "alphanum_fraction": 0.5035207203, "avg_line_length": 26.6553846154, "ext": "agda", "hexsha": "9ab5cc82a2636bb33b6f952052d337ce75a79c54", "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/Pushout.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/Pushout.agda", "max_line_length": 138, "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/Pushout.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": 3284, "size": 8663 }
open import MJ.Types import MJ.Classtable.Core as Core module MJ.Syntax.Program {c}(Ct : Core.Classtable c) where open import Prelude open import Data.List open import MJ.Classtable.Code Ct open import MJ.Syntax Ct Prog : Ty c → Set Prog a = Code × (Body [] a)
{ "alphanum_fraction": 0.7396226415, "avg_line_length": 18.9285714286, "ext": "agda", "hexsha": "aebc6a40ee0da33c171645292c210b5cda83ebdc", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/MJ/Syntax/Program.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/MJ/Syntax/Program.agda", "max_line_length": 58, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/MJ/Syntax/Program.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 73, "size": 265 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Unit.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat open import Cubical.Data.Unit.Base isPropUnit : isProp Unit isPropUnit _ _ i = tt isContrUnit : isContr Unit isContrUnit = tt , λ {tt → refl} isOfHLevelUnit : (n : ℕ) → isOfHLevel n Unit isOfHLevelUnit 0 = isContrUnit isOfHLevelUnit 1 = isPropUnit isOfHLevelUnit (suc n) = hLevelSuc n Unit (isOfHLevelUnit n)
{ "alphanum_fraction": 0.7568555759, "avg_line_length": 24.8636363636, "ext": "agda", "hexsha": "4fe856fcdb0ac7a02624bd64b2437961c3ad0df0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Unit/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Unit/Properties.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Unit/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 168, "size": 547 }
------------------------------------------------------------------------------ -- FOCT terms properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Base.PropertiesATP where open import FOTC.Base ------------------------------------------------------------------------------ -- Injective properties postulate succInjective : ∀ {m n} → succ₁ m ≡ succ₁ n → m ≡ n {-# ATP prove succInjective #-} ------------------------------------------------------------------------------ -- Discrimination rules postulate S≢0 : ∀ {n} → succ₁ n ≢ zero {-# ATP prove S≢0 #-}
{ "alphanum_fraction": 0.3554987212, "avg_line_length": 31.28, "ext": "agda", "hexsha": "8ac1d0c73ae0f6d381e267826799b36479dfefb8", "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/Base/PropertiesATP.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/Base/PropertiesATP.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/Base/PropertiesATP.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": 133, "size": 782 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Escape {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.LogicalRelation open import Tools.Product import Tools.PropositionalEquality as PE -- Reducible types are well-formed. escape : ∀ {l Γ A} → Γ ⊩⟨ l ⟩ A → Γ ⊢ A escape (Uᵣ′ l′ l< ⊢Γ) = Uⱼ ⊢Γ escape (ℕᵣ [ ⊢A , ⊢B , D ]) = ⊢A escape (Emptyᵣ [ ⊢A , ⊢B , D ]) = ⊢A escape (Unitᵣ [ ⊢A , ⊢B , D ]) = ⊢A escape (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) = ⊢A escape (Bᵣ′ W F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) = ⊢A escape (emb 0<1 A) = escape A -- Reducible type equality respect the equality relation. escapeEq : ∀ {l Γ A B} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] → Γ ⊢ A ≅ B escapeEq (Uᵣ′ l′ l< ⊢Γ) PE.refl = ≅-Urefl ⊢Γ escapeEq (ℕᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ ℕₙ ℕₙ (≅-ℕrefl (wf ⊢A)) escapeEq (Emptyᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ Emptyₙ Emptyₙ (≅-Emptyrefl (wf ⊢A)) escapeEq (Unitᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ Unitₙ Unitₙ (≅-Unitrefl (wf ⊢A)) escapeEq (ne′ K D neK K≡K) (ne₌ M D′ neM K≡M) = ≅-red (red D) (red D′) (ne neK) (ne neM) (~-to-≅ K≡M) escapeEq (Bᵣ′ W F G D ⊢F ⊢G A≡A [F] [G] G-ext) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = ≅-red (red D) D′ ⟦ W ⟧ₙ ⟦ W ⟧ₙ A≡B escapeEq (emb 0<1 A) A≡B = escapeEq A A≡B -- Reducible terms are well-formed. escapeTerm : ∀ {l Γ A t} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Γ ⊢ t ∷ A escapeTerm (Uᵣ′ l′ l< ⊢Γ) (Uₜ A [ ⊢t , ⊢u , d ] typeA A≡A [A]) = ⊢t escapeTerm (ℕᵣ D) (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop) = conv ⊢t (sym (subset* (red D))) escapeTerm (Emptyᵣ D) (Emptyₜ e [ ⊢t , ⊢u , d ] t≡t prop) = conv ⊢t (sym (subset* (red D))) escapeTerm (Unitᵣ D) (Unitₜ e [ ⊢t , ⊢u , d ] prop) = conv ⊢t (sym (subset* (red D))) escapeTerm (ne′ K D neK K≡K) (neₜ k [ ⊢t , ⊢u , d ] nf) = conv ⊢t (sym (subset* (red D))) escapeTerm (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [ ⊢t , ⊢u , d ] funcF f≡f [f] [f]₁) = conv ⊢t (sym (subset* (red D))) escapeTerm (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Σₜ p [ ⊢t , ⊢u , d ] pProd p≅p [fst] [snd]) = conv ⊢t (sym (subset* (red D))) escapeTerm (emb 0<1 A) t = escapeTerm A t -- Reducible term equality respect the equality relation. escapeTermEq : ∀ {l Γ A t u} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] → Γ ⊢ t ≅ u ∷ A escapeTermEq (Uᵣ′ l′ l< ⊢Γ) (Uₜ₌ A B d d′ typeA typeB A≡B [A] [B] [A≡B]) = ≅ₜ-red (id (Uⱼ ⊢Γ)) (redₜ d) (redₜ d′) Uₙ (typeWhnf typeA) (typeWhnf typeB) A≡B escapeTermEq (ℕᵣ D) (ℕₜ₌ k k′ d d′ k≡k′ prop) = let natK , natK′ = split prop in ≅ₜ-red (red D) (redₜ d) (redₜ d′) ℕₙ (naturalWhnf natK) (naturalWhnf natK′) k≡k′ escapeTermEq (Emptyᵣ D) (Emptyₜ₌ k k′ d d′ k≡k′ prop) = let natK , natK′ = esplit prop in ≅ₜ-red (red D) (redₜ d) (redₜ d′) Emptyₙ (ne natK) (ne natK′) k≡k′ escapeTermEq {l} {Γ} {A} {t} {u} (Unitᵣ D) (Unitₜ₌ ⊢t ⊢u) = let t≅u = ≅ₜ-η-unit ⊢t ⊢u A≡Unit = subset* (red D) in ≅-conv t≅u (sym A≡Unit) escapeTermEq (ne′ K D neK K≡K) (neₜ₌ k m d d′ (neNfₜ₌ neT neU t≡u)) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) (ne neK) (ne neT) (ne neU) (~-to-≅ₜ t≡u) escapeTermEq (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) Πₙ (functionWhnf funcF) (functionWhnf funcG) f≡g escapeTermEq (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Σₜ₌ p r d d′ pProd rProd p≅r [t] [u] [fstp] [fstr] [fst≡] [snd≡]) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) Σₙ (productWhnf pProd) (productWhnf rProd) p≅r escapeTermEq (emb 0<1 A) t≡u = escapeTermEq A t≡u
{ "alphanum_fraction": 0.5264102564, "avg_line_length": 41.935483871, "ext": "agda", "hexsha": "21200c2fe4acbc652abec946405bc20ea444f962", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1995, "size": 3900 }
{-# OPTIONS --safe #-} module Cubical.HITs.CumulativeHierarchy where open import Cubical.HITs.CumulativeHierarchy.Base public hiding (elim; elimProp) open import Cubical.HITs.CumulativeHierarchy.Properties public open import Cubical.HITs.CumulativeHierarchy.Constructions public
{ "alphanum_fraction": 0.8333333333, "avg_line_length": 35.25, "ext": "agda", "hexsha": "0cd804b36a9f62b2dac1085c0a8a816329f940db", "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/HITs/CumulativeHierarchy.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/HITs/CumulativeHierarchy.agda", "max_line_length": 65, "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/HITs/CumulativeHierarchy.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": 68, "size": 282 }
-- Andreas, 2018-06-18, problem surfaced with issue #3136 -- Correct printing of a pattern lambda that has no patterns. -- {-# OPTIONS -v extendedlambda:50 #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality record R : Set where no-eta-equality field w : Bool f : R f = λ where .R.w → λ where → false triggerError : ∀ x → x ≡ f triggerError x = refl -- Error prints extended lambda name in error: -- x != λ { .R.w → λ { .extendedlambda1 → false } } of type R -- when checking that the expression refl has type x ≡ f -- Expected: -- x != λ { .R.w → λ { → false } } of type R -- when checking that the expression refl has type x ≡ f
{ "alphanum_fraction": 0.6596385542, "avg_line_length": 23.7142857143, "ext": "agda", "hexsha": "099938ec7ae90341c4d5d5c881c4997e28a4a4dc", "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/Issue3136a.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/Issue3136a.agda", "max_line_length": 61, "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/Issue3136a.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": 198, "size": 664 }
{-# OPTIONS --cubical --allow-unsolved-metas #-} open import Prelude open import Relation.Binary module Data.AVLTree.Mapping {k} {K : Type k} {r₁ r₂} (totalOrder : TotalOrder K r₁ r₂) where open import Relation.Binary.Construct.Bounded totalOrder open import Data.Nat using (_+_) open TotalOrder totalOrder using (_<?_; compare) open TotalOrder b-ord using (<-trans) renaming (refl to <-refl) import Data.Empty.UniversePolymorphic as Poly open import Data.AVLTree.Internal totalOrder private variable n m : ℕ v : Level Val : K → Type v data Mapping (Val : K → Type v) : Type (k ℓ⊔ v ℓ⊔ r₁) where [_] : Tree Val [⊥] [⊤] n → Mapping Val quot : (xs : Tree Val [⊥] [⊤] n) (ys : Tree Val [⊥] [⊤] m) → toList xs ≡ toList ys → [ xs ] ≡ [ ys ] trunc : isSet (Mapping Val) lookup′ : (x : K) → Mapping Val → Maybe (Val x) lookup′ x [ xs ] = lookup x xs lookup′ x (quot xs ys p j) = {!!} lookup′ x (trunc xs xs₁ x₁ y i i₁) = {!!}
{ "alphanum_fraction": 0.6458773784, "avg_line_length": 30.5161290323, "ext": "agda", "hexsha": "3e47da398454daef374fd839a30c8de9d21281f2", "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/AVLTree/Mapping.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/AVLTree/Mapping.agda", "max_line_length": 102, "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/AVLTree/Mapping.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": 329, "size": 946 }
open import Base open import Homotopy.Connected module Homotopy.Extensions.ProductPushoutToProductToConnected.Magic {i j} {D E : Set i} (h : E → D) where {- k E ---> F x | /^ | ≃ / | / l? v / (x : D) -} -- The mapping l and the coherence data. extension : (F : D → Set j) (k : ∀ x → F (h x)) → Set (max i j) extension F k = Σ (Π D F) (λ l → ∀ x → k x ≡ l (h x)) -- Specialized J rules. private -- This is a combination of 2~3 basic rules. lemma₁ : ∀ (F : D → Set j) (k : ∀ x → F (h x)) {l₁ l₂ : ∀ x → F x} (p : l₁ ≡ l₂) (q : ∀ x → k x ≡ l₁ (h x)) a → transport (λ l → ∀ x → k x ≡ l (h x)) p q a ≡ q a ∘ happly p (h a) lemma₁ F k refl q a = ! $ refl-right-unit _ -- May be generalized later. lemma₂ : ∀ {i} {X : Set i} {x₁ x₂ x₃ : X} (p₁ : x₁ ≡ x₂) (p₂ : x₂ ≡ x₃) (p₃ : x₁ ≡ x₃) → (p₁ ∘ p₂ ≡ p₃) ≡ (p₂ ≡ ! p₁ ∘ p₃) lemma₂ refl _ _ = refl -- May be generalized later. lemma₃ : ∀ {i} {X : Set i} {x₁ x₂ : X} (p₁ : x₁ ≡ x₂) (p₂ : x₁ ≡ x₂) → (p₁ ≡ p₂) ≡ (p₂ ≡ p₁) lemma₃ p₁ p₂ = eq-to-path $ ! , iso-is-eq ! ! opposite-opposite opposite-opposite lemma₄ : ∀ {i j} {A A′ : Set i} (B′ : A′ → Set j) (eq : A ≃ A′) → Σ A (λ x → (B′ (eq ☆ x))) ≡ Σ A′ B′ lemma₄ {j = j} B′ eq = equiv-induction (λ {A A′} eq → ∀ (B′ : A′ → Set j) → Σ A (λ x → (B′ (eq ☆ x))) ≡ Σ A′ B′) (λ A _ → refl) eq B′ -- The main lemma module _ {n₁ : ℕ₋₂} (h-is-conn : has-connected-fibers n₁ h) where open import Homotopy.Truncation extension-is-truncated : (F : D → Set j) {n₂ : ℕ₋₂} ⦃ F-is-trunc : ∀ x → is-truncated (n₂ +2+ n₁) (F x) ⦄ (k : ∀ x → F (h x)) → is-truncated n₂ (extension F k) extension-is-truncated F {⟨-2⟩} ⦃ F-is-trunc ⦄ k = center , (λ e″ → Σ-eq (path-l e″) (path-coh e″)) where -- The section l′ : ∀ x → τ n₁ (hfiber h x) → F x l′ x = τ-extend-nondep ⦃ F-is-trunc x ⦄ λ{(preimage , shift) → transport F shift (k preimage)} -- The section l : ∀ x → F x l x = l′ x (π₁ (h-is-conn x)) -- The coherence data (commutivity) abstract coh : ∀ x → k x ≡ l (h x) coh x = ap (l′ (h x)) $ π₂ (h-is-conn (h x)) $ proj (x , refl) -- The canonical choice of section+coherence center : extension F k center = l , coh -- The path between the canonical choice and others (pointwise). abstract path-l-pointwise′ : ∀ (e : extension F k) x → τ n₁ (hfiber h x) → π₁ e x ≡ l x path-l-pointwise′ = λ{(l″ , coh″) x → τ-extend-nondep ⦃ ≡-is-truncated n₁ $ F-is-trunc x ⦄ -- The point is to make all artifacts go away when shift = refl _. (λ{(pre , shift) → transport (λ x → l″ x ≡ l x) shift $ l″ (h pre) ≡⟨ ! $ coh″ pre ⟩ k pre ≡⟨ coh pre ⟩∎ l (h pre) ∎})} -- The path between the canonical choice and others (pointwise). abstract path-l-pointwise : ∀ (e : extension F k) x → π₁ e x ≡ l x path-l-pointwise = λ e x → path-l-pointwise′ e x (π₁ (h-is-conn x)) -- The path between the canonical choice and others. abstract path-l : ∀ (e : extension F k) → π₁ e ≡ l path-l = funext ◯ path-l-pointwise -- The path between the canonical choice and others. abstract path-coh : ∀ (e : extension F k) → transport (λ l → ∀ x → k x ≡ l (h x)) (path-l e) (π₂ e) ≡ coh path-coh e″ = funext λ x → let coh″ = π₂ e″ in transport (λ l → ∀ x → k x ≡ l (h x)) (path-l e″) coh″ x ≡⟨ lemma₁ F k (path-l e″) coh″ x ⟩ coh″ x ∘ happly (path-l e″) (h x) ≡⟨ ap (λ p → coh″ x ∘ p (h x)) $ happly-funext (path-l-pointwise e″) ⟩ coh″ x ∘ (path-l-pointwise′ e″ (h x) (π₁ (h-is-conn (h x)))) ≡⟨ ap (λ y → π₂ e″ x ∘ (path-l-pointwise′ e″ (h x) y)) $ ! $ π₂ (h-is-conn (h x)) $ proj (x , refl) ⟩ coh″ x ∘ (path-l-pointwise′ e″ (h x) (proj (x , refl))) ≡⟨ refl ⟩ coh″ x ∘ ((! $ coh″ x) ∘ coh x) ≡⟨ ! $ concat-assoc (coh″ x) (! $ coh″ x) (coh x) ⟩ (coh″ x ∘ (! $ coh″ x)) ∘ coh x ≡⟨ ap (λ p → p ∘ coh x) $ opposite-right-inverse (coh″ x) ⟩∎ coh x ∎ extension-is-truncated F {S n₂} ⦃ F-is-trunc ⦄ k = λ e₁ e₂ → transport (is-truncated n₂) (! $ extension≡-extension′-path e₁ e₂) (extension′-is-trunc e₁ e₂) where module _ (e₁ e₂ : extension F k) where l₁ = π₁ e₁ l₂ = π₁ e₂ coh₁ = π₂ e₁ coh₂ = π₂ e₂ -- The trick: Make a new F for the path space. F′ : ∀ D → Set j F′ x = l₁ x ≡ l₂ x k′ : ∀ x → F′ (h x) k′ x = ! (coh₁ x) ∘ coh₂ x F′-is-trunc : ∀ x → is-truncated (n₂ +2+ n₁) (F′ x) F′-is-trunc x = F-is-trunc x (l₁ x) (l₂ x) extension′ : Set (max i j) extension′ = extension F′ k′ -- Conversion between paths and new extensions. abstract extension≡-extension′-path : (e₁ ≡ e₂) ≡ extension′ extension≡-extension′-path = e₁ ≡ e₂ ≡⟨ ! $ eq-to-path $ total-Σ-eq-equiv ⟩ Σ (l₁ ≡ l₂) (λ l₁≡l₂ → transport (λ l → ∀ x → k x ≡ l (h x)) l₁≡l₂ coh₁ ≡ coh₂) ≡⟨ ap (Σ (l₁ ≡ l₂)) (funext λ _ → ! $ eq-to-path $ funext-equiv) ⟩ Σ (l₁ ≡ l₂) (λ l₁≡l₂ → ∀ x → transport (λ l → ∀ x → k x ≡ l (h x)) l₁≡l₂ coh₁ x ≡ coh₂ x) ≡⟨ ap (Σ (l₁ ≡ l₂)) (funext λ l₁≡l₂ → ap (λ p → ∀ x → p x ≡ coh₂ x) $ funext $ lemma₁ F k l₁≡l₂ coh₁) ⟩ Σ (l₁ ≡ l₂) (λ l₁≡l₂ → ∀ x → coh₁ x ∘ happly l₁≡l₂ (h x) ≡ coh₂ x) ≡⟨ ap (Σ (l₁ ≡ l₂)) (funext λ l₁≡l₂ → ap (λ p → ∀ x → p x) $ funext λ x → lemma₂ (coh₁ x) (happly l₁≡l₂ (h x)) (coh₂ x)) ⟩ Σ (l₁ ≡ l₂) (λ l₁≡l₂ → ∀ x → happly l₁≡l₂ (h x) ≡ ! (coh₁ x) ∘ coh₂ x) ≡⟨ ap (Σ (l₁ ≡ l₂)) (funext λ l₁≡l₂ → ap (λ p → ∀ x → p x) $ funext λ x → lemma₃ (happly l₁≡l₂ (h x)) (! (coh₁ x) ∘ coh₂ x)) ⟩ Σ (l₁ ≡ l₂) (λ l₁≡l₂ → ∀ x → ! (coh₁ x) ∘ coh₂ x ≡ happly l₁≡l₂ (h x)) ≡⟨ lemma₄ (λ l₁x≡l₂x → ∀ x → ! (coh₁ x) ∘ coh₂ x ≡ l₁x≡l₂x (h x)) happly-equiv ⟩∎ extension′ ∎ -- Recursive calls. abstract extension′-is-trunc : is-truncated n₂ extension′ extension′-is-trunc = extension-is-truncated F′ {n₂} ⦃ F′-is-trunc ⦄ k′
{ "alphanum_fraction": 0.4369699583, "avg_line_length": 39.5284090909, "ext": "agda", "hexsha": "f987903c9a01b50b6aaf19c879f443f35cdfd5e6", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected/Magic.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected/Magic.agda", "max_line_length": 103, "max_stars_count": 294, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected/Magic.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": 2672, "size": 6957 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Functorial where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Path open import Cubical.Foundations.SIP private variable ℓ ℓ₁ : Level -- Standard notion of structure from a "functorial" action -- We don't need all the functor axioms, only F id ≡ id FunctorialEquivStr : {S : Type ℓ → Type ℓ₁} → (∀ {X Y} → (X → Y) → S X → S Y) → StrEquiv S ℓ₁ FunctorialEquivStr F (X , s) (Y , t) e = F (e .fst) s ≡ t functorialUnivalentStr : {S : Type ℓ → Type ℓ₁} (F : ∀ {X Y} → (X → Y) → S X → S Y) → (∀ {X} s → F (idfun X) s ≡ s) → UnivalentStr S (FunctorialEquivStr F) functorialUnivalentStr F η = SNS→UnivalentStr (FunctorialEquivStr F) (λ s t → pathToEquiv (cong (_≡ t) (η s)))
{ "alphanum_fraction": 0.6866597725, "avg_line_length": 29.303030303, "ext": "agda", "hexsha": "96f270bd57dc081fe342bf9a950633536c5b7e31", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Functorial.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "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": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Functorial.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Functorial.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 344, "size": 967 }
module Numeral.Natural.Oper.Modulo where import Lvl open import Data open import Data.Boolean.Stmt open import Logic.Propositional.Theorems open import Numeral.Natural open import Numeral.Natural.Oper.Comparisons open import Relator.Equals infixl 10100 _mod_ -- Modulo is defined using this. -- This, unlike (_mod_) is keeping internal state of the previous value. -- `r` is the current result. Should be 0 at the start. -- `b` is the modulus. This value will not change in the repeated applications of the function. -- `a'` is the number to take the modulo of. -- 'b'` is the temporary modulus. Should be `b` at the start. -- This function works by repeatedly decreasing `a'` and `b'` and at the same time increasing `r` until `b'` is 0. -- When `b'` is 0, `r` is resetted to 0, and `b'` is resetted to `b`. -- Almost the same algorithm imperatively: -- while a'!=0{ -- a'-= 1; -- b'-= 1; -- r += 1; -- if b'==0{ -- r := 0; -- b':= b; -- } -- } -- return r; -- Example execution: -- [ 0 , 2 ] 5 mod' 2 -- = [ 1 , 2 ] 4 mod' 1 -- = [ 2 , 2 ] 3 mod' 0 -- = [ 0 , 2 ] 3 mod' 2 -- = [ 1 , 2 ] 2 mod' 1 -- = [ 2 , 2 ] 1 mod' 0 -- = [ 0 , 2 ] 1 mod' 2 -- = [ 1 , 2 ] 0 mod' 1 -- = 1 -- The above is describing the following code: -- {-# TERMINATING #-} -- [_,_]_mod₀'_ : ℕ → ℕ → ℕ → ℕ → ℕ -- [ _ , 𝟎 ] _ mod₀' _ = 𝟎 -- [ _ , b ] a' mod₀' 𝟎 = [ 𝟎 , b ] a' mod₀' b -- [ r , _ ] 𝟎 mod₀' _ = r -- [ r , b ] 𝐒(a') mod₀' 𝐒(b') = [ 𝐒(r) , b ] a' mod₀' b' -- Then it is transformed to the following code (So that it terminates): -- [_,_]_mod₀'_ : ℕ → ℕ → ℕ → ℕ → ℕ -- [ _ , 𝟎 ] _ mod₀' _ = 𝟎 -- [ _ , 𝐒(_) ] 𝟎 mod₀' 𝟎 = 𝟎 -- [ r , 𝐒(_) ] 𝟎 mod₀' 𝐒(_) = r -- [ _ , 𝐒(b) ] 𝐒(a') mod₀' 𝟎 = [ 𝐒(𝟎) , 𝐒(b) ] a' mod₀' b -- [ r , 𝐒(b) ] 𝐒(a') mod₀' 𝐒(b') = [ 𝐒(r) , 𝐒(b) ] a' mod₀' b' -- And finally removing the forbidden 𝟎 cases of `b` and `b'` by just interpreting (b=0), (b'=0) in this function as 1's: -- [ r , _ ] 𝟎 mod' _ = r -- [ _ , b ] 𝐒(a') mod' 𝟎 = [ 𝟎 , b ] a' mod' b -- [ r , b ] 𝐒(a') mod' 𝐒(b') = [ 𝐒(r) , b ] a' mod' b' -- Note: [ r , b ] a mod' b) is like ((a − r) mod b). The other b is actually a state for handling the situation when a is greater than the modulus b. -- TODO: If it is possible together with the BUILTIN pragma, swap b and b' to avoid confusion. b' is actually a state (like r) and is not the actual base [_,_]_mod'_ : ℕ → ℕ → ℕ → ℕ → ℕ [ r , _ ] 𝟎 mod' _ = r [ _ , b ] 𝐒(a') mod' 𝟎 = [ 𝟎 , b ] a' mod' b [ r , b ] 𝐒(a') mod' 𝐒(b') = [ 𝐒(r) , b ] a' mod' b' {-# BUILTIN NATMODSUCAUX [_,_]_mod'_ #-} -- Difference between the value before and after the floored division operation. _mod_ : ℕ → (m : ℕ) → .⦃ pos : IsTrue(positive?(m))⦄ → ℕ a mod 𝐒(m) = [ 𝟎 , m ] a mod' m _mod₀_ : ℕ → ℕ → ℕ _ mod₀ 𝟎 = 𝟎 a mod₀ 𝐒(m) = [ 𝟎 , m ] a mod' m
{ "alphanum_fraction": 0.5256322625, "avg_line_length": 39.0133333333, "ext": "agda", "hexsha": "8612ba2fec94224c1b777a95969580687f396d59", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Oper/Modulo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Oper/Modulo.agda", "max_line_length": 153, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Oper/Modulo.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": 1244, "size": 2926 }
------------------------------------------------------------------------ -- A parametrised coinductive definition that can be used to define -- various forms of similarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude open import Labelled-transition-system module Similarity.General {ℓ} (lts : LTS ℓ) (open LTS lts) (_[_]↝_ : Proc → Label → Proc → Type ℓ) (⟶→↝ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]↝ q) where open import Equality.Propositional as Eq hiding (Extensionality) open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Function-universe equality-with-J hiding (id; _∘_) open import Indexed-container hiding (⟨_⟩) open import Relation open import Similarity.Step lts _[_]↝_ as Step public using (StepC) open Indexed-container public using (force) open StepC public using (⟨_⟩; challenge) -- Similarity. Note that this definition is small. infix 4 _≤_ _≤′_ [_]_≤_ [_]_≤′_ Similarity : Size → Rel₂ ℓ Proc Similarity i = ν StepC i Similarity′ : Size → Rel₂ ℓ Proc Similarity′ i = ν′ StepC i [_]_≤_ : Size → Proc → Proc → Type ℓ [_]_≤_ i = curry (Similarity i) [_]_≤′_ : Size → Proc → Proc → Type ℓ [_]_≤′_ i = curry (Similarity′ i) _≤_ : Proc → Proc → Type ℓ _≤_ = [ ∞ ]_≤_ _≤′_ : Proc → Proc → Type ℓ _≤′_ = [ ∞ ]_≤′_ -- Similarity is reflexive. mutual reflexive-≤ : ∀ {p i} → [ i ] p ≤ p reflexive-≤ = StepC.⟨ (λ p⟶p′ → _ , ⟶→↝ p⟶p′ , reflexive-≤′) ⟩ reflexive-≤′ : ∀ {p i} → [ i ] p ≤′ p force reflexive-≤′ = reflexive-≤ ≡⇒≤ : ∀ {p q} → p ≡ q → p ≤ q ≡⇒≤ refl = reflexive-≤ -- Functions that can be used to aid the instance resolution -- mechanism. infix -2 ≤:_ ≤′:_ ≤:_ : ∀ {i p q} → [ i ] p ≤ q → [ i ] p ≤ q ≤:_ = id ≤′:_ : ∀ {i p q} → [ i ] p ≤′ q → [ i ] p ≤′ q ≤′:_ = id -- Bisimilarity of similarity proofs. infix 4 [_]_≡_ [_]_≡′_ [_]_≡_ : ∀ {p q} → Size → (_ _ : ν StepC ∞ (p , q)) → Type ℓ [_]_≡_ i = curry (ν-bisimilar i) [_]_≡′_ : ∀ {p q} → Size → (_ _ : ν′ StepC ∞ (p , q)) → Type ℓ [_]_≡′_ i = curry (ν′-bisimilar i) -- An alternative characterisation of bisimilarity of similarity -- proofs. []≡↔ : Eq.Extensionality ℓ ℓ → ∀ {p q} {i : Size} (p≤q₁ p≤q₂ : ν StepC ∞ (p , q)) → [ i ] p≤q₁ ≡ p≤q₂ ↔ (∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) → let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge p≤q₁ p⟶p′ q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge p≤q₂ p⟶p′ in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) → subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂ × [ i ] subst (ν′ StepC ∞ ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ ≡′ p′≤q′₂) []≡↔ ext {p} {q} {i} p≤q₁@(s₁ , f₁) p≤q₂@(s₂ , f₂) = [ i ] p≤q₁ ≡ p≤q₂ ↝⟨ ν-bisimilar↔ ext (s₁ , f₁) (s₂ , f₂) ⟩ (∃ λ (eq : s₁ ≡ s₂) → ∀ {o} (p : Container.Position StepC s₁ o) → [ i ] f₁ p ≡′ f₂ (subst (λ s → Container.Position StepC s o) eq p)) ↝⟨ Step.⟦StepC⟧₂↔ ext (ν′-bisimilar i) p≤q₁ p≤q₂ ⟩□ (∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) → let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge p≤q₁ p⟶p′ q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge p≤q₂ p⟶p′ in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) → subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂ × [ i ] subst (ν′ StepC ∞ ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ ≡′ p′≤q′₂) □ -- A statement of extensionality for similarity. Extensionality : Type ℓ Extensionality = ν′-extensionality StepC -- This form of extensionality can be used to derive another form (in -- the presence of extensionality for functions). extensionality : Eq.Extensionality ℓ ℓ → Extensionality → ∀ {p q} {p≤q₁ p≤q₂ : ν StepC ∞ (p , q)} → [ ∞ ] p≤q₁ ≡ p≤q₂ → p≤q₁ ≡ p≤q₂ extensionality ext ν-ext = ν-extensionality ext ν-ext
{ "alphanum_fraction": 0.5181745821, "avg_line_length": 26.9214285714, "ext": "agda", "hexsha": "a2a52a21b04b1307adca5a7a08a3fb840f807d73", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Similarity/General.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Similarity/General.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Similarity/General.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1626, "size": 3769 }
open import Relation.Binary.Core module BBHeap.Subtyping.Properties {A : Set} (_≤_ : A → A → Set) (trans≤ : Transitive _≤_) where open import BBHeap _≤_ open import BBHeap.Subtyping _≤_ trans≤ open import BBHeap.Properties _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ open import Bound.Lower.Order.Properties _≤_ trans≤ open import List.Permutation.Base A open import List.Permutation.Base.Equivalence A subtyping⋘l : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b) → h ⋘ h' → subtyping b''≤b h ⋘ h' subtyping⋘l b''≤b lf⋘ = lf⋘ subtyping⋘l b''≤b (ll⋘ b≤x b'≤x' l⋘r l'⋘r' l'≃r' r≃l') = ll⋘ (transLeB b''≤b b≤x) b'≤x' l⋘r l'⋘r' l'≃r' r≃l' subtyping⋘l b''≤b (lr⋘ b≤x b'⋘x' l⋙r l'⋘r' l'≃r' l⋗l') = lr⋘ (transLeB b''≤b b≤x) b'⋘x' l⋙r l'⋘r' l'≃r' l⋗l' subtyping⋘ : {b b' b'' b''' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b)(b'''≤b' : LeB b''' b') → h ⋘ h' → subtyping b''≤b h ⋘ subtyping b'''≤b' h' subtyping⋘ b''≤b b'''≤b' lf⋘ = lf⋘ subtyping⋘ b''≤b b'''≤b' (ll⋘ b≤x b'≤x' l⋘r l'⋘r' l'≃r' r≃l') = ll⋘ (transLeB b''≤b b≤x) (transLeB b'''≤b' b'≤x') l⋘r l'⋘r' l'≃r' r≃l' subtyping⋘ b''≤b b'''≤b' (lr⋘ b≤x b'⋘x' l⋙r l'⋘r' l'≃r' l⋗l') = lr⋘ (transLeB b''≤b b≤x) (transLeB b'''≤b' b'⋘x') l⋙r l'⋘r' l'≃r' l⋗l' subtyping⋙r : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b' : LeB b'' b') → h ⋙ h' → h ⋙ subtyping b''≤b' h' subtyping⋙r b''≤b' (⋙lf b≤x) = ⋙lf b≤x subtyping⋙r b''≤b' (⋙rl b≤x b'≤x' l⋘r l≃r l'⋘r' l⋗r') = ⋙rl b≤x (transLeB b''≤b' b'≤x') l⋘r l≃r l'⋘r' l⋗r' subtyping⋙r b''≤b' (⋙rr b≤x b'⋘x' l⋘r l≃r l'⋙r' l≃l') = ⋙rr b≤x (transLeB b''≤b' b'⋘x') l⋘r l≃r l'⋙r' l≃l' subtyping⋙ : {b b' b'' b''' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b)(b'''≤b' : LeB b''' b') → h ⋙ h' → subtyping b''≤b h ⋙ subtyping b'''≤b' h' subtyping⋙ b''≤b b'''≤b' (⋙lf b≤x) = ⋙lf (transLeB b''≤b b≤x) subtyping⋙ b''≤b b'''≤b' (⋙rl b≤x b'≤x' l⋘r l≃r l'⋘r' l⋗r') = ⋙rl (transLeB b''≤b b≤x) (transLeB b'''≤b' b'≤x') l⋘r l≃r l'⋘r' l⋗r' subtyping⋙ b''≤b b'''≤b' (⋙rr b≤x b'⋘x' l⋘r l≃r l'⋙r' l≃l') = ⋙rr (transLeB b''≤b b≤x) (transLeB b'''≤b' b'⋘x') l⋘r l≃r l'⋙r' l≃l' subtyping≃r : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b' : LeB b'' b') → h ≃ h' → h ≃ subtyping b''≤b' h' subtyping≃r b''≤b' ≃lf = ≃lf subtyping≃r b''≤b' (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') = ≃nd b≤x (transLeB b''≤b' b'≤x') l⋘r l'⋘r' l≃r l'≃r' l≃l' subtyping≃l : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b) → h ≃ h' → subtyping b''≤b h ≃ h' subtyping≃l b''≤b h≃h' = sym≃ (subtyping≃r b''≤b (sym≃ h≃h')) subtyping≃ : {b b' b'' b''' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b)(b'''≤b' : LeB b''' b') → h ≃ h' → subtyping b''≤b h ≃ subtyping b'''≤b' h' subtyping≃ b''≤b b'''≤b' h≃h' = subtyping≃r b'''≤b' (subtyping≃l b''≤b h≃h') subtyping⋗r : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b' : LeB b'' b') → h ⋗ h' → h ⋗ subtyping b''≤b' h' subtyping⋗r b''≤b' (⋗lf b≤x) = ⋗lf b≤x subtyping⋗r b''≤b' (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l') = ⋗nd b≤x (transLeB b''≤b' b'≤x') l⋘r l'⋘r' l≃r l'≃r' l⋗l' subtyping⋗l : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b) → h ⋗ h' → subtyping b''≤b h ⋗ h' subtyping⋗l b''≤b (⋗lf b≤x) = ⋗lf (transLeB b''≤b b≤x) subtyping⋗l b''≤b (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l') = ⋗nd (transLeB b''≤b b≤x) b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l' subtyping⋗ : {b b' b'' b''' : Bound}{h : BBHeap b}{h' : BBHeap b'}(b''≤b : LeB b'' b)(b'''≤b' : LeB b''' b') → h ⋗ h' → subtyping b''≤b h ⋗ subtyping b'''≤b' h' subtyping⋗ b''≤b b'''≤b' h⋗h' = subtyping⋗r b'''≤b' (subtyping⋗l b''≤b h⋗h') lemma-subtyping# : {b b' : Bound}(b'≤b : LeB b' b)(h : BBHeap b) → # (subtyping b'≤b h) ≡ # h lemma-subtyping# b'≤b leaf = refl lemma-subtyping# b'≤b (left b≤x l⋘r) = refl lemma-subtyping# b'≤b (right b≤x l⋙r) = refl lemma-subtyping≡ : {b b' : Bound}(b'≤b : LeB b' b)(h : BBHeap b) → (flatten (subtyping b'≤b h)) ≡ flatten h lemma-subtyping≡ b'≤b leaf = refl lemma-subtyping≡ b'≤b (left {l = l} {r = r} b≤x l⋘r) rewrite lemma-subtyping≡ b≤x l | lemma-subtyping≡ b≤x r = refl lemma-subtyping≡ b'≤b (right {l = l} {r = r} b≤x l⋙r) rewrite lemma-subtyping≡ b≤x l | lemma-subtyping≡ b≤x r = refl lemma-subtyping∼ : {b b' : Bound}(b'≤b : LeB b' b)(h : BBHeap b) → flatten (subtyping b'≤b h) ∼ flatten h lemma-subtyping∼ b'≤b leaf = ∼[] lemma-subtyping∼ b'≤b (left b≤x l⋘r) = ∼x /head /head refl∼ lemma-subtyping∼ b'≤b (right b≤x l⋙r) = ∼x /head /head refl∼
{ "alphanum_fraction": 0.5218065087, "avg_line_length": 63.6197183099, "ext": "agda", "hexsha": "153bcb52f74012df7d4e07d3cb02ffe703ab5f0d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Subtyping/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Subtyping/Properties.agda", "max_line_length": 161, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Subtyping/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 2784, "size": 4517 }
{-# OPTIONS --without-K #-} -- Finished 6pm Th, March 24! yay! -- Bit thanks to tzaikin for posting his work online (some of his macros -- were essential for this proof for me) and to the code we saw in class today. module EH where open import Level using (_⊔_) open import Data.Product using (Σ; _,_) open import Function renaming (_∘_ to _○_) infixr 8 _∘_ -- path composition infixr 8 _⋆_ -- horizontal path composition infix 4 _≡_ -- propositional equality infix 4 _∼_ -- homotopy between two functions infix 4 _≃_ -- type of equivalences -- macros from tzaikin for equational rewriting over non-standard ≡ infixr 4 _≡⟨_⟩_ infix 4 _∎ ------------------------------------------------------------------------------ -- A few HoTT primitives data _≡_ {ℓ} {A : Set ℓ} : (a b : A) → Set ℓ where refl : (a : A) → (a ≡ a) pathInd : ∀ {u ℓ} → {A : Set u} → (C : {x y : A} → x ≡ y → Set ℓ) → (c : (x : A) → C (refl x)) → ({x y : A} (p : x ≡ y) → C p) pathInd C c (refl x) = c x -- ! : ∀ {u} → {A : Set u} {x y : A} → (x ≡ y) → (y ≡ x) ! = pathInd (λ {x} {y} _ → y ≡ x) refl _∘_ : ∀ {u} → {A : Set u} → {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z) _∘_ {u} {A} {x} {y} {z} p q = pathInd {u} (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z))) (λ x z q → pathInd (λ {x} {z} _ → x ≡ z) refl {x} {z} q) {x} {y} p z q -- Handy "macros" (from tzaikin) _∎ : {A : Set} → (p : A) → p ≡ p p ∎ = refl p _≡⟨_⟩_ : {A : Set} → {q r : A} → (p : A) → p ≡ q → q ≡ r → p ≡ r p ≡⟨ α ⟩ β = α ∘ β -- RU : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ p ∘ refl y) RU {A} {x} {y} p = pathInd (λ {x} {y} p → p ≡ p ∘ (refl y)) (λ x → refl (refl x)) {x} {y} p LU : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ refl x ∘ p) LU {A} {x} {y} p = pathInd (λ {x} {y} p → p ≡ (refl x) ∘ p) (λ x → refl (refl x)) {x} {y} p invTransL : {A : Set} {x y : A} → (p : x ≡ y) → (! p ∘ p ≡ refl y) invTransL {A} {x} {y} p = pathInd (λ {x} {y} p → ! p ∘ p ≡ refl y) (λ x → refl (refl x)) {x} {y} p invTransR : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → (p ∘ ! p ≡ refl x) invTransR {ℓ} {A} {x} {y} p = pathInd (λ {x} {y} p → p ∘ ! p ≡ refl x) (λ x → refl (refl x)) {x} {y} p invId : {A : Set} {x y : A} → (p : x ≡ y) → (! (! p) ≡ p) invId {A} {x} {y} p = pathInd (λ {x} {y} p → ! (! p) ≡ p) (λ x → refl (refl x)) {x} {y} p assocP : {A : Set} {x y z w : A} → (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r) assocP {A} {x} {y} {z} {w} p q r = pathInd (λ {x} {y} p → (z : A) → (w : A) → (q : y ≡ z) → (r : z ≡ w) → p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r) (λ x z w q r → pathInd (λ {x} {z} q → (w : A) → (r : z ≡ w) → (refl x) ∘ (q ∘ r) ≡ ((refl x) ∘ q) ∘ r) (λ x w r → pathInd (λ {x} {w} r → (refl x) ∘ ((refl x) ∘ r) ≡ ((refl x) ∘ (refl x)) ∘ r) (λ x → (refl (refl x))) {x} {w} r) {x} {z} q w r) {x} {y} p z w q r invComp : {A : Set} {x y z : A} → (p : x ≡ y) → (q : y ≡ z) → ! (p ∘ q) ≡ ! q ∘ ! p invComp {A} {x} {y} {z} p q = pathInd (λ {x} {y} p → (z : A) → (q : y ≡ z) → ! (p ∘ q) ≡ ! q ∘ ! p) (λ x z q → pathInd (λ {x} {z} q → ! (refl x ∘ q) ≡ ! q ∘ ! (refl x)) (λ x → refl (refl x)) {x} {z} q) {x} {y} p z q -- ap : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {x y : A} → (f : A → B) → (x ≡ y) → (f x ≡ f y) ap {ℓ} {ℓ'} {A} {B} {x} {y} f p = pathInd -- on p (λ {x} {y} p → f x ≡ f y) (λ x → refl (f x)) {x} {y} p apfTrans : ∀ {u} → {A B : Set u} {x y z : A} → (f : A → B) → (p : x ≡ y) → (q : y ≡ z) → ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q) apfTrans {u} {A} {B} {x} {y} {z} f p q = pathInd {u} (λ {x} {y} p → (z : A) → (q : y ≡ z) → ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q)) (λ x z q → pathInd {u} (λ {x} {z} q → ap f (refl x ∘ q) ≡ (ap f (refl x)) ∘ (ap f q)) (λ x → refl (refl (f x))) {x} {z} q) {x} {y} p z q apfInv : ∀ {u} → {A B : Set u} {x y : A} → (f : A → B) → (p : x ≡ y) → ap f (! p) ≡ ! (ap f p) apfInv {u} {A} {B} {x} {y} f p = pathInd {u} (λ {x} {y} p → ap f (! p) ≡ ! (ap f p)) (λ x → refl (ap f (refl x))) {x} {y} p apfComp : {A B C : Set} {x y : A} → (f : A → B) → (g : B → C) → (p : x ≡ y) → ap g (ap f p) ≡ ap (g ○ f) p apfComp {A} {B} {C} {x} {y} f g p = pathInd (λ {x} {y} p → ap g (ap f p) ≡ ap (g ○ f) p) (λ x → refl (ap g (ap f (refl x)))) {x} {y} p apfId : {A : Set} {x y : A} → (p : x ≡ y) → ap id p ≡ p apfId {A} {x} {y} p = pathInd (λ {x} {y} p → ap id p ≡ p) (λ x → refl (refl x)) {x} {y} p -- transport : ∀ {ℓ ℓ'} → {A : Set ℓ} {x y : A} → (P : A → Set ℓ') → (p : x ≡ y) → P x → P y transport {ℓ} {ℓ'} {A} {x} {y} P p = pathInd -- on p (λ {x} {y} p → (P x → P y)) (λ _ → id) {x} {y} p apd : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : A → Set ℓ'} {x y : A} → (f : (a : A) → B a) → (p : x ≡ y) → (transport B p (f x) ≡ f y) apd {ℓ} {ℓ'} {A} {B} {x} {y} f p = pathInd (λ {x} {y} p → transport B p (f x) ≡ f y) (λ x → refl (f x)) {x} {y} p -- Homotopies and equivalences _∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} → (f g : (x : A) → P x) → Set (ℓ ⊔ ℓ') _∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x record qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkqinv field g : B → A α : (f ○ g) ∼ id β : (g ○ f) ∼ id record isequiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkisequiv field g : B → A α : (f ○ g) ∼ id h : B → A β : (h ○ f) ∼ id equiv₁ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → qinv f → isequiv f equiv₁ (mkqinv qg qα qβ) = mkisequiv qg qα qg qβ _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) isequiv postulate univalence : {A B : Set} → (A ≡ B) ≃ (A ≃ B) ------------------------------------------------------------------------------ -- Path and loop spaces 1-Path : {A : Set} → (a b : A) → Set 1-Path {A} a b = (a ≡ b) 2-Path : {A : Set} → (a b : A) (p q : 1-Path {A} a b) → Set 2-Path {A} a b p q = (p ≡ q) Ω : (A : Set) → {a : A} → Set Ω A {a} = 1-Path {A} a a Ω² : (A : Set) → {a : A} → Set Ω² A {a} = 2-Path {A} a a (refl a) (refl a) -- Whiskering Lemmas -- ___ p ___ ___ r ___ -- / \ / \ -- a α⇓ b β⇓ c -- \ / \ / -- --- q --- --- s --- wskR : {A : Set} {a b c : A} {p q : 1-Path {A} a b} → (α : 2-Path {A} a b p q) → (r : 1-Path {A} b c) → (p ∘ r) ≡ (q ∘ r) wskR {A} {a} {b} {c} {p} {q} α r = (pathInd (λ {b} {c} r → {p q : a ≡ b} → (α : p ≡ q) → 2-Path {A} a c (p ∘ r) (q ∘ r)) (λ b {p} {q} α → (p ∘ refl b) ≡⟨ ! (RU p) ⟩ p ≡⟨ α ⟩ q ≡⟨ RU q ⟩ (q ∘ refl b) ∎) r) α wskL : {A : Set} {a b c : A} {r s : 1-Path {A} b c} → (q : 1-Path {A} a b) → (β : 2-Path {A} b c r s) → (q ∘ r) ≡ (q ∘ s) wskL {A} {a} {b} {c} {r} {s} q β = (pathInd (λ {a} {b} q → {r s : b ≡ c} → (α : r ≡ s) → 2-Path {A} a c (q ∘ r) (q ∘ s)) ((λ b {p} {q} β → (refl b ∘ p) ≡⟨ ! (LU p) ⟩ p ≡⟨ β ⟩ q ≡⟨ LU q ⟩ (refl b ∘ q) ∎)) q) β _⋆_ : {A : Set} {a b c : A} {p q : 1-Path {A} a b} {r s : 1-Path {A} b c} (α : 2-Path {A} a b p q) → (β : 2-Path {A} b c r s) → (p ∘ r) ≡ (q ∘ s) _⋆_ {A} {a} {b} {c} {p} {q} {r} {s} α β = (wskR α r) ∘ (wskL q β) Hcomp→compR1 : {A : Set} {a : A} (α : 2-Path {A} a a (refl a) (refl a)) → (wskR α (refl a)) ≡ (! (RU (refl a))) ∘ α ∘ (RU (refl a)) Hcomp→compR1 {A} {a} α = refl (pathInd (λ {x} {y} _ → x ≡ y) refl (pathInd (λ {x} {y} _ → (x₁ : a ≡ a) (x₂ : y ≡ x₁) → x ≡ x₁) (λ x x₁ → pathInd (λ {x₂} {y} _ → x₂ ≡ y) refl) α (refl a) (refl (refl a)))) Hcomp→compL1 : {A : Set} {a : A} (β : 2-Path {A} a a (refl a) (refl a)) → (wskL (refl a) β) ≡ (! (LU (refl a))) ∘ β ∘ (LU (refl a)) Hcomp→compL1 {A} {a} β = refl (pathInd (λ {x} {y} _ → x ≡ y) refl (pathInd (λ {x} {y} _ → (x₁ : a ≡ a) (x₂ : y ≡ x₁) → x ≡ x₁) (λ x x₁ → pathInd (λ {x₂} {y} _ → x₂ ≡ y) refl) β (refl a) (refl (refl a)))) -- proof from pg 81 α⋆β≡α∘β : {A : Set} {a : A} (α : 2-Path {A} a a (refl a) (refl a)) → (β : 2-Path {A} a a (refl a) (refl a)) → α ⋆ β ≡ α ∘ β α⋆β≡α∘β {A} {a} α β = α ⋆ β ≡⟨ refl (α ⋆ β) ⟩ (wskR α ra) ∘ (wskL ra β) ≡⟨ refl ((!(refl ra) ∘ α ∘ (refl ra)) ∘ (wskL ra β)) ⟩ (!(refl ra) ∘ (α ∘ (refl ra))) ∘ (wskL ra β) ≡⟨ ap (λ p → ((!(refl ra) ∘ p) ∘ (wskL ra β))) (! (RU α)) ⟩ ((!(refl ra) ∘ α) ∘ (wskL ra β)) ≡⟨ ap (λ p → (p ∘ (wskL ra β))) (! (LU α)) ⟩ (α ∘ (wskL ra β)) ≡⟨ refl (α ∘ (wskL ra β)) ⟩ (α ∘ (!(refl ra) ∘ β ∘ (refl ra))) ≡⟨ ap (λ p → (α ∘ (!(refl ra) ∘ p))) (! (RU β)) ⟩ (α ∘ (!(refl ra) ∘ β)) ≡⟨ ap (λ p → (α ∘ p)) (! (LU β)) ⟩ α ∘ β ∎ where ra = (refl a) _⋆'_ : {A : Set} {a b c : A} {p q : 1-Path {A} a b} {r s : 1-Path {A} b c} (α : 2-Path {A} a b p q) → (β : 2-Path {A} b c r s) → (p ∘ r) ≡ (q ∘ s) _⋆'_ {A} {a} {b} {c} {p} {q} {r} {s} α β = (wskL p β) ∘ (wskR α s) α⋆'β≡β∘α : {A : Set} {a : A} (α : 2-Path {A} a a (refl a) (refl a)) → (β : 2-Path {A} a a (refl a) (refl a)) → α ⋆' β ≡ β ∘ α α⋆'β≡β∘α {A} {a} α β = α ⋆' β ≡⟨ refl (α ⋆' β) ⟩ (wskL ra β) ∘ (!(refl ra) ∘ (α ∘ (refl ra))) ≡⟨ ap (λ p → ((wskL ra β) ∘ (!(refl ra) ∘ p))) (! (RU α)) ⟩ ((wskL ra β) ∘ (!(refl ra) ∘ α)) ≡⟨ ap (λ p → ((wskL ra β) ∘ p)) (! (LU α)) ⟩ ((wskL ra β) ∘ α) ≡⟨ refl ((wskL ra β) ∘ α) ⟩ ((!(refl ra) ∘ β ∘ (refl ra)) ∘ α) ≡⟨ ap (λ p → ((!(refl ra) ∘ p) ∘ α)) (! (RU β)) ⟩ ((!(refl ra) ∘ β) ∘ α) ≡⟨ ap (λ p → (p ∘ α)) (! (LU β)) ⟩ β ∘ α ∎ where ra = (refl a) -- yuck lots of nested induction α⋆β≡α⋆'β : {A : Set} {a : A} (α : 2-Path {A} a a (refl a) (refl a)) → (β : 2-Path {A} a a (refl a) (refl a)) → α ⋆ β ≡ α ⋆' β α⋆β≡α⋆'β {A} {a} α β = -- induction on α pathInd (λ α → α ⋆ β ≡ α ⋆' β) (λ p → -- induction on β pathInd (λ β → refl p ⋆ β ≡ refl p ⋆' β) (λ q → -- induction on p (pathInd (λ {a} {b} p → (c : A) → (q : b ≡ c) → ((refl p ⋆ refl q) ≡ (refl p ⋆' refl q))) (λ a d q → -- induction on q pathInd (λ {a} {d} r → ((refl (refl a) ⋆ refl r) ≡ (refl (refl a) ⋆' refl r))) (λ a → refl (refl (refl a))) q) p a q)) β) α eckmann-hilton : {A : Set} {a : A} (α β : Ω² A {a}) → α ∘ β ≡ β ∘ α eckmann-hilton {A} {a} α β = α ∘ β ≡⟨ ! (α⋆β≡α∘β α β) ⟩ α ⋆ β ≡⟨ α⋆β≡α⋆'β α β ⟩ α ⋆' β ≡⟨ α⋆'β≡β∘α α β ⟩ β ∘ α ∎ ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3336125304, "avg_line_length": 27.3203661327, "ext": "agda", "hexsha": "11a8ae0e03811266c41282bc6e273aeadaf599a8", "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": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_path": "EH.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "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": "andmkent/misc-HoTT", "max_issues_repo_path": "EH.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_path": "EH.agda", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "num_tokens": 5812, "size": 11939 }
module rename where open import lib open import cedille-types open import ctxt-types open import is-free open import syntax-util renamectxt : Set renamectxt = stringset × trie string {- the trie maps vars to their renamed versions, and the stringset stores all those renamed versions -} empty-renamectxt : renamectxt empty-renamectxt = empty-stringset , empty-trie renamectxt-contains : renamectxt → string → 𝔹 renamectxt-contains (_ , r) s = trie-contains r s renamectxt-insert : renamectxt → (s1 s2 : string) → renamectxt renamectxt-insert (ranr , r) s x = stringset-insert ranr x , trie-insert r s x renamectxt-single : var → var → renamectxt renamectxt-single = renamectxt-insert empty-renamectxt renamectxt-lookup : renamectxt → string → maybe string renamectxt-lookup (ranr , r) s = trie-lookup r s renamectxt-remove : renamectxt → string → renamectxt renamectxt-remove (ranr , r) s with trie-lookup r s renamectxt-remove (ranr , r) s | nothing = ranr , r renamectxt-remove (ranr , r) s | just s' = stringset-remove ranr s' , trie-remove r s renamectxt-in-range : renamectxt → string → 𝔹 renamectxt-in-range (ranr , r) s = stringset-contains ranr s renamectxt-in-field : renamectxt → string → 𝔹 renamectxt-in-field m s = renamectxt-contains m s || renamectxt-in-range m s renamectxt-rep : renamectxt → string → string renamectxt-rep r x with renamectxt-lookup r x renamectxt-rep r x | nothing = x renamectxt-rep r x | just x' = x' eq-var : renamectxt → string → string → 𝔹 eq-var r x y = renamectxt-rep r x =string renamectxt-rep r y pick-new-name : string → string pick-new-name x = x ^ "'" {- rename-away-from x g r rename the variable x to be some new name (related to x) which does not satisfy the given predicate on names (assuming this is possible), and is not in the domain of the renamectxt . -} {-# NON_TERMINATING #-} rename-away-from : string → (string → 𝔹) → renamectxt → string rename-away-from x g r = if (g x) then rename-away-from (pick-new-name x) g r else if (renamectxt-in-field r x) then rename-away-from (pick-new-name x) g r else x fresh-var : string → (string → 𝔹) → renamectxt → string fresh-var = rename-away-from rename-var-if : {ed : exprd} → ctxt → renamectxt → var → ⟦ ed ⟧ → var rename-var-if Γ ρ y t = if is-free-in check-erased y t || renamectxt-in-range ρ y then rename-away-from y (ctxt-binds-var Γ) ρ else y renamectxt-insert* : renamectxt → (vs1 vs2 : 𝕃 string) → maybe renamectxt renamectxt-insert* ρ [] [] = just ρ renamectxt-insert* ρ (x :: vs1) (y :: vs2) = renamectxt-insert* (renamectxt-insert ρ x y) vs1 vs2 renamectxt-insert* ρ _ _ = nothing
{ "alphanum_fraction": 0.7005208333, "avg_line_length": 34.9090909091, "ext": "agda", "hexsha": "931f4198bf6e094135fc6c3625fec23f81156647", "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": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xoltar/cedille", "max_forks_repo_path": "src/rename.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "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": "xoltar/cedille", "max_issues_repo_path": "src/rename.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xoltar/cedille", "max_stars_repo_path": "src/rename.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 783, "size": 2688 }
------------------------------------------------------------------------------ -- Streams (unbounded lists) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Stream where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Stream.Type public ------------------------------------------------------------------------------ postulate zeros : D zeros-eq : zeros ≡ zero ∷ zeros {-# ATP axiom zeros-eq #-} postulate ones : D ones-eq : ones ≡ succ₁ zero ∷ ones {-# ATP axiom ones-eq #-}
{ "alphanum_fraction": 0.4097693351, "avg_line_length": 27.2962962963, "ext": "agda", "hexsha": "e085edee9c361d916699498ee55d012b1065954a", "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/Data/Stream.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/Data/Stream.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/Data/Stream.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": 138, "size": 737 }
module Interpretation where open import VariableName open import FunctionName open import PredicateName open import Element open import Elements open import TruthValue record Interpretation : Set where field μ⟦_⟧ : VariableName → Element 𝑓⟦_⟧ : FunctionName → Elements → Element 𝑃⟦_⟧ : PredicateName → Elements → TruthValue open Interpretation public open import OscarPrelude open import Term open import Delay open import Vector mutual τ⇑⟦_⟧ : Interpretation → {i : Size} → Term → Delay i Element τ⇑⟦ I ⟧ (variable 𝑥) = now $ μ⟦ I ⟧ 𝑥 τ⇑⟦ I ⟧ (function 𝑓 τs) = 𝑓⟦ I ⟧ 𝑓 ∘ ⟨_⟩ <$> τs⇑⟦ I ⟧ τs τs⇑⟦_⟧ : Interpretation → {i : Size} → (τs : Terms) → Delay i (Vector Element (arity τs)) τs⇑⟦ I ⟧ ⟨ ⟨ [] ⟩ ⟩ = now ⟨ [] ⟩ τs⇑⟦ I ⟧ ⟨ ⟨ τ ∷ τs ⟩ ⟩ = τ⇑⟦ I ⟧ τ >>= (λ t → τs⇑⟦ I ⟧ ⟨ ⟨ τs ⟩ ⟩ >>= λ ts → now ⟨ t ∷ vector ts ⟩) τs⇓⟦_⟧ : (I : Interpretation) → (τs : Terms) → τs⇑⟦ I ⟧ τs ⇓ τs⇓⟦ I ⟧ ⟨ ⟨ [] ⟩ ⟩ = _ , now⇓ τs⇓⟦ I ⟧ ⟨ ⟨ variable 𝑥 ∷ τs ⟩ ⟩ = _ , τs⇓⟦ I ⟧ ⟨ ⟨ τs ⟩ ⟩ ⇓>>=⇓ now⇓ τs⇓⟦ I ⟧ ⟨ ⟨ function 𝑓₁ τs₁ ∷ τs₂ ⟩ ⟩ = _ , τs⇓⟦ I ⟧ τs₁ ⇓>>=⇓ now⇓ >>=⇓ (τs⇓⟦ I ⟧ ⟨ ⟨ τs₂ ⟩ ⟩ ⇓>>=⇓ now⇓) τ⇓⟦_⟧ : (I : Interpretation) → (τ : Term) → τ⇑⟦ I ⟧ τ ⇓ τ⇓⟦ I ⟧ (variable 𝑥) = _ , now⇓ τ⇓⟦ I ⟧ (function 𝑓 τs) = _ , τs⇓⟦ I ⟧ τs ⇓>>=⇓ now⇓ τ⟦_⟧ : (I : Interpretation) → {i : Size} → (τ : Term) → Element τ⟦ I ⟧ τ = fst (τ⇓⟦ I ⟧ τ)
{ "alphanum_fraction": 0.5386313466, "avg_line_length": 28.914893617, "ext": "agda", "hexsha": "8b6f41df7af223bc7659fddded1cf1ad6a9d9047", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/Interpretation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/Interpretation.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Interpretation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 723, "size": 1359 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Terms used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Term where open import Data.List.Base hiding (_++_) import Data.List.Properties as Lₚ open import Data.Nat as ℕ using (ℕ; zero; suc) open import Data.Product open import Data.Maybe.Base using (Maybe; just; nothing) open import Reflection.Abstraction open import Reflection.Argument open import Reflection.Argument.Information using (visibility) import Reflection.Argument.Visibility as Visibility; open Visibility.Visibility import Reflection.Literal as Literal import Reflection.Meta as Meta open import Reflection.Name as Name using (Name) import Reflection.Pattern as Pattern open import Relation.Nullary open import Relation.Nullary.Product using (_×-dec_) open import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Re-exporting the builtin type and constructors open import Agda.Builtin.Reflection as Builtin public using (Sort; Type; Term; Clause) open Sort public open Term public renaming (agda-sort to sort) open Clause public ------------------------------------------------------------------------ -- Handy synonyms Clauses : Set Clauses = List Clause -- Pattern synonyms for more compact presentation pattern vLam s t = lam visible (abs s t) pattern hLam s t = lam hidden (abs s t) pattern iLam s t = lam instance′ (abs s t) pattern Π[_∶_]_ s a ty = pi a (abs s ty) pattern vΠ[_∶_]_ s a ty = Π[ s ∶ (vArg a) ] ty pattern hΠ[_∶_]_ s a ty = Π[ s ∶ (hArg a) ] ty pattern iΠ[_∶_]_ s a ty = Π[ s ∶ (iArg a) ] ty ---------------------------------------------------------------------- -- Utility functions getName : Term → Maybe Name getName (con c args) = just c getName (def f args) = just f getName _ = nothing -- "n ⋯⟅∷⟆ xs" prepends "n" visible unknown arguments to the list of -- arguments. Useful when constructing the list of arguments for a -- function with initial inferable arguments. infixr 5 _⋯⟨∷⟩_ _⋯⟨∷⟩_ : ℕ → Args Term → Args Term zero ⋯⟨∷⟩ xs = xs suc i ⋯⟨∷⟩ xs = unknown ⟨∷⟩ (i ⋯⟨∷⟩ xs) {-# INLINE _⋯⟨∷⟩_ #-} -- "n ⋯⟅∷⟆ xs" prepends "n" hidden unknown arguments to the list of -- arguments. Useful when constructing the list of arguments for a -- function with initial implicit arguments. infixr 5 _⋯⟅∷⟆_ _⋯⟅∷⟆_ : ℕ → Args Term → Args Term zero ⋯⟅∷⟆ xs = xs suc i ⋯⟅∷⟆ xs = unknown ⟅∷⟆ (i ⋯⟅∷⟆ xs) {-# INLINE _⋯⟅∷⟆_ #-} ------------------------------------------------------------------------ -- Decidable equality clause-injective₁ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → ps ≡ ps′ clause-injective₁ refl = refl clause-injective₂ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → b ≡ b′ clause-injective₂ refl = refl clause-injective : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → ps ≡ ps′ × b ≡ b′ clause-injective = < clause-injective₁ , clause-injective₂ > absurd-clause-injective : ∀ {ps ps′} → absurd-clause ps ≡ absurd-clause ps′ → ps ≡ ps′ absurd-clause-injective refl = refl infix 4 _≟-AbsTerm_ _≟-AbsType_ _≟-ArgTerm_ _≟-ArgType_ _≟-Args_ _≟-Clause_ _≟-Clauses_ _≟_ _≟-Sort_ _≟-AbsTerm_ : DecidableEquality (Abs Term) _≟-AbsType_ : DecidableEquality (Abs Type) _≟-ArgTerm_ : DecidableEquality (Arg Term) _≟-ArgType_ : DecidableEquality (Arg Type) _≟-Args_ : DecidableEquality (Args Term) _≟-Clause_ : DecidableEquality Clause _≟-Clauses_ : DecidableEquality Clauses _≟_ : DecidableEquality Term _≟-Sort_ : DecidableEquality Sort -- Decidable equality 'transformers' -- We need to inline these because the terms are not sized so termination -- would not obvious if we were to use higher-order functions such as -- Data.List.Properties' ≡-dec abs s a ≟-AbsTerm abs s′ a′ = unAbs-dec (a ≟ a′) abs s a ≟-AbsType abs s′ a′ = unAbs-dec (a ≟ a′) arg i a ≟-ArgTerm arg i′ a′ = unArg-dec (a ≟ a′) arg i a ≟-ArgType arg i′ a′ = unArg-dec (a ≟ a′) [] ≟-Args [] = yes refl (x ∷ xs) ≟-Args (y ∷ ys) = Lₚ.∷-dec (x ≟-ArgTerm y) (xs ≟-Args ys) [] ≟-Args (_ ∷ _) = no λ() (_ ∷ _) ≟-Args [] = no λ() [] ≟-Clauses [] = yes refl (x ∷ xs) ≟-Clauses (y ∷ ys) = Lₚ.∷-dec (x ≟-Clause y) (xs ≟-Clauses ys) [] ≟-Clauses (_ ∷ _) = no λ() (_ ∷ _) ≟-Clauses [] = no λ() clause ps b ≟-Clause clause ps′ b′ = Dec.map′ (uncurry (cong₂ clause)) clause-injective (ps Pattern.≟s ps′ ×-dec b ≟ b′) absurd-clause ps ≟-Clause absurd-clause ps′ = Dec.map′ (cong absurd-clause) absurd-clause-injective (ps Pattern.≟s ps′) clause _ _ ≟-Clause absurd-clause _ = no λ() absurd-clause _ ≟-Clause clause _ _ = no λ() var-injective₁ : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → x ≡ x′ var-injective₁ refl = refl var-injective₂ : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → args ≡ args′ var-injective₂ refl = refl var-injective : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → x ≡ x′ × args ≡ args′ var-injective = < var-injective₁ , var-injective₂ > con-injective₁ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ con-injective₁ refl = refl con-injective₂ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → args ≡ args′ con-injective₂ refl = refl con-injective : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ × args ≡ args′ con-injective = < con-injective₁ , con-injective₂ > def-injective₁ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ def-injective₁ refl = refl def-injective₂ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → args ≡ args′ def-injective₂ refl = refl def-injective : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ × args ≡ args′ def-injective = < def-injective₁ , def-injective₂ > meta-injective₁ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′ meta-injective₁ refl = refl meta-injective₂ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → args ≡ args′ meta-injective₂ refl = refl meta-injective : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′ × args ≡ args′ meta-injective = < meta-injective₁ , meta-injective₂ > lam-injective₁ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ lam-injective₁ refl = refl lam-injective₂ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → t ≡ t′ lam-injective₂ refl = refl lam-injective : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ × t ≡ t′ lam-injective = < lam-injective₁ , lam-injective₂ > pat-lam-injective₁ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ pat-lam-injective₁ refl = refl pat-lam-injective₂ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → args ≡ args′ pat-lam-injective₂ refl = refl pat-lam-injective : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ × args ≡ args′ pat-lam-injective = < pat-lam-injective₁ , pat-lam-injective₂ > pi-injective₁ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ pi-injective₁ refl = refl pi-injective₂ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₂ ≡ t₂′ pi-injective₂ refl = refl pi-injective : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ × t₂ ≡ t₂′ pi-injective = < pi-injective₁ , pi-injective₂ > sort-injective : ∀ {x y} → sort x ≡ sort y → x ≡ y sort-injective refl = refl lit-injective : ∀ {x y} → lit x ≡ lit y → x ≡ y lit-injective refl = refl set-injective : ∀ {x y} → set x ≡ set y → x ≡ y set-injective refl = refl slit-injective : ∀ {x y} → Sort.lit x ≡ lit y → x ≡ y slit-injective refl = refl var x args ≟ var x′ args′ = Dec.map′ (uncurry (cong₂ var)) var-injective (x ℕ.≟ x′ ×-dec args ≟-Args args′) con c args ≟ con c′ args′ = Dec.map′ (uncurry (cong₂ con)) con-injective (c Name.≟ c′ ×-dec args ≟-Args args′) def f args ≟ def f′ args′ = Dec.map′ (uncurry (cong₂ def)) def-injective (f Name.≟ f′ ×-dec args ≟-Args args′) meta x args ≟ meta x′ args′ = Dec.map′ (uncurry (cong₂ meta)) meta-injective (x Meta.≟ x′ ×-dec args ≟-Args args′) lam v t ≟ lam v′ t′ = Dec.map′ (uncurry (cong₂ lam)) lam-injective (v Visibility.≟ v′ ×-dec t ≟-AbsTerm t′) pat-lam cs args ≟ pat-lam cs′ args′ = Dec.map′ (uncurry (cong₂ pat-lam)) pat-lam-injective (cs ≟-Clauses cs′ ×-dec args ≟-Args args′) pi t₁ t₂ ≟ pi t₁′ t₂′ = Dec.map′ (uncurry (cong₂ pi)) pi-injective (t₁ ≟-ArgType t₁′ ×-dec t₂ ≟-AbsType t₂′) sort s ≟ sort s′ = Dec.map′ (cong sort) sort-injective (s ≟-Sort s′) lit l ≟ lit l′ = Dec.map′ (cong lit) lit-injective (l Literal.≟ l′) unknown ≟ unknown = yes refl var x args ≟ con c args′ = no λ() var x args ≟ def f args′ = no λ() var x args ≟ lam v t = no λ() var x args ≟ pi t₁ t₂ = no λ() var x args ≟ sort _ = no λ() var x args ≟ lit _ = no λ() var x args ≟ meta _ _ = no λ() var x args ≟ unknown = no λ() con c args ≟ var x args′ = no λ() con c args ≟ def f args′ = no λ() con c args ≟ lam v t = no λ() con c args ≟ pi t₁ t₂ = no λ() con c args ≟ sort _ = no λ() con c args ≟ lit _ = no λ() con c args ≟ meta _ _ = no λ() con c args ≟ unknown = no λ() def f args ≟ var x args′ = no λ() def f args ≟ con c args′ = no λ() def f args ≟ lam v t = no λ() def f args ≟ pi t₁ t₂ = no λ() def f args ≟ sort _ = no λ() def f args ≟ lit _ = no λ() def f args ≟ meta _ _ = no λ() def f args ≟ unknown = no λ() lam v t ≟ var x args = no λ() lam v t ≟ con c args = no λ() lam v t ≟ def f args = no λ() lam v t ≟ pi t₁ t₂ = no λ() lam v t ≟ sort _ = no λ() lam v t ≟ lit _ = no λ() lam v t ≟ meta _ _ = no λ() lam v t ≟ unknown = no λ() pi t₁ t₂ ≟ var x args = no λ() pi t₁ t₂ ≟ con c args = no λ() pi t₁ t₂ ≟ def f args = no λ() pi t₁ t₂ ≟ lam v t = no λ() pi t₁ t₂ ≟ sort _ = no λ() pi t₁ t₂ ≟ lit _ = no λ() pi t₁ t₂ ≟ meta _ _ = no λ() pi t₁ t₂ ≟ unknown = no λ() sort _ ≟ var x args = no λ() sort _ ≟ con c args = no λ() sort _ ≟ def f args = no λ() sort _ ≟ lam v t = no λ() sort _ ≟ pi t₁ t₂ = no λ() sort _ ≟ lit _ = no λ() sort _ ≟ meta _ _ = no λ() sort _ ≟ unknown = no λ() lit _ ≟ var x args = no λ() lit _ ≟ con c args = no λ() lit _ ≟ def f args = no λ() lit _ ≟ lam v t = no λ() lit _ ≟ pi t₁ t₂ = no λ() lit _ ≟ sort _ = no λ() lit _ ≟ meta _ _ = no λ() lit _ ≟ unknown = no λ() meta _ _ ≟ var x args = no λ() meta _ _ ≟ con c args = no λ() meta _ _ ≟ def f args = no λ() meta _ _ ≟ lam v t = no λ() meta _ _ ≟ pi t₁ t₂ = no λ() meta _ _ ≟ sort _ = no λ() meta _ _ ≟ lit _ = no λ() meta _ _ ≟ unknown = no λ() unknown ≟ var x args = no λ() unknown ≟ con c args = no λ() unknown ≟ def f args = no λ() unknown ≟ lam v t = no λ() unknown ≟ pi t₁ t₂ = no λ() unknown ≟ sort _ = no λ() unknown ≟ lit _ = no λ() unknown ≟ meta _ _ = no λ() pat-lam _ _ ≟ var x args = no λ() pat-lam _ _ ≟ con c args = no λ() pat-lam _ _ ≟ def f args = no λ() pat-lam _ _ ≟ lam v t = no λ() pat-lam _ _ ≟ pi t₁ t₂ = no λ() pat-lam _ _ ≟ sort _ = no λ() pat-lam _ _ ≟ lit _ = no λ() pat-lam _ _ ≟ meta _ _ = no λ() pat-lam _ _ ≟ unknown = no λ() var x args ≟ pat-lam _ _ = no λ() con c args ≟ pat-lam _ _ = no λ() def f args ≟ pat-lam _ _ = no λ() lam v t ≟ pat-lam _ _ = no λ() pi t₁ t₂ ≟ pat-lam _ _ = no λ() sort _ ≟ pat-lam _ _ = no λ() lit _ ≟ pat-lam _ _ = no λ() meta _ _ ≟ pat-lam _ _ = no λ() unknown ≟ pat-lam _ _ = no λ() set t ≟-Sort set t′ = Dec.map′ (cong set) set-injective (t ≟ t′) lit n ≟-Sort lit n′ = Dec.map′ (cong lit) slit-injective (n ℕ.≟ n′) unknown ≟-Sort unknown = yes refl set _ ≟-Sort lit _ = no λ() set _ ≟-Sort unknown = no λ() lit _ ≟-Sort set _ = no λ() lit _ ≟-Sort unknown = no λ() unknown ≟-Sort set _ = no λ() unknown ≟-Sort lit _ = no λ()
{ "alphanum_fraction": 0.5700880731, "avg_line_length": 36.593373494, "ext": "agda", "hexsha": "5e724e710a4b9e274a425f4d8b2dba8bae3bba01", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Reflection/Term.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Reflection/Term.agda", "max_line_length": 105, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Reflection/Term.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": 4442, "size": 12149 }
module Category where open import Logic.Equivalence open import Logic.Relations open Equivalence using () renaming (_==_ to eq) record Cat : Set2 where field Obj : Set1 _─→_ : Obj -> Obj -> Set id : {A : Obj} -> A ─→ A _∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C Eq : {A B : Obj} -> Equivalence (A ─→ B) cong : {A B C : Obj}{f₁ f₂ : B ─→ C}{g₁ g₂ : A ─→ B} -> eq Eq f₁ f₂ -> eq Eq g₁ g₂ -> eq Eq (f₁ ∘ g₁) (f₂ ∘ g₂) idLeft : {A B : Obj}{f : A ─→ B} -> eq Eq (id ∘ f) f idRight : {A B : Obj}{f : A ─→ B} -> eq Eq (f ∘ id) f assoc : {A B C D : Obj}{f : C ─→ D}{g : B ─→ C}{h : A ─→ B} -> eq Eq ((f ∘ g) ∘ h) (f ∘ (g ∘ h)) module Category (ℂ : Cat) where private module CC = Cat ℂ open CC public hiding (_─→_; _∘_) private module Eq {A B : Obj} = Equivalence (Eq {A}{B}) open Eq public hiding (_==_) infix 20 _==_ infixr 30 _─→_ infixr 90 _∘_ _─→_ = CC._─→_ _==_ : {A B : Obj} -> Rel (A ─→ B) _==_ = Eq._==_ _∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C _∘_ = CC._∘_ congL : {A B C : Obj}{f₁ f₂ : B ─→ C}{g : A ─→ B} -> f₁ == f₂ -> f₁ ∘ g == f₂ ∘ g congL p = cong p (refl _) congR : {A B C : Obj}{f : B ─→ C}{g₁ g₂ : A ─→ B} -> g₁ == g₂ -> f ∘ g₁ == f ∘ g₂ congR p = cong (refl _) p module Poly-Cat where infix 20 _==_ infixr 30 _─→_ _─→'_ infixr 90 _∘_ private module C = Category -- Objects data Obj (ℂ : Cat) : Set1 where -- obj : C.Obj ℂ -> Obj ℂ -- obj⁻¹ : {ℂ : Cat} -> Obj ℂ -> C.Obj ℂ -- obj⁻¹ {ℂ} (obj A) = A postulate X : Set -- Arrows data _─→_ {ℂ : Cat}(A B : Obj ℂ) : Set where arr : X -> A ─→ B -- C._─→_ ℂ (obj⁻¹ A) (obj⁻¹ B) -> A ─→ B postulate ℂ : Cat A : Obj ℂ B : Obj ℂ foo : A ─→ B -> X foo (arr f) = ? -- arr⁻¹ : {ℂ : Cat}{A B : Obj ℂ} -> A ─→ B -> C._─→_ ℂ (obj⁻¹ A) (obj⁻¹ B) -- arr⁻¹ {ℂ}{A}{B} (arr f) = f open Poly-Cat open Category hiding (Obj; _─→_) {- id : {ℂ : Cat}{A : Obj ℂ} -> A ─→ A id {ℂ} = arr (Pr.id ℂ) _∘_ : {ℂ : Cat}{A B C : Obj ℂ} -> B ─→ C -> A ─→ B -> A ─→ C _∘_ {ℂ} (arr f) (arr g) = arr (Pr.compose ℂ f g) data _==_ {ℂ : Cat}{A B : Obj ℂ}(f g : A ─→ B) : Set where eqArr : Pr.equal ℂ (arr⁻¹ f) (arr⁻¹ g) -> f == g refl : {ℂ : Cat}{A B : Obj ℂ}{f : A ─→ B} -> f == f refl {ℂ} = eqArr (Pr.refl ℂ) sym : {ℂ : Cat}{A B : Obj ℂ}{f g : A ─→ B} -> f == g -> g == f sym {ℂ} (eqArr fg) = eqArr (Pr.sym ℂ fg) trans : {ℂ : Cat}{A B : Obj ℂ}{f g h : A ─→ B} -> f == g -> g == h -> f == h trans {ℂ} (eqArr fg) (eqArr gh) = eqArr (Pr.trans ℂ fg gh) cong : {ℂ : Cat}{A B C : Obj ℂ}{f₁ f₂ : B ─→ C}{g₁ g₂ : A ─→ B} -> f₁ == f₂ -> g₁ == g₂ -> f₁ ∘ g₁ == f₂ ∘ g₂ cong {ℂ} {f₁ = arr _}{f₂ = arr _}{g₁ = arr _}{g₂ = arr _} (eqArr p) (eqArr q) = eqArr (Pr.cong ℂ p q) congL : {ℂ : Cat}{A B C : Obj ℂ}{f₁ f₂ : B ─→ C}{g : A ─→ B} -> f₁ == f₂ -> f₁ ∘ g == f₂ ∘ g congL p = cong p refl congR : {ℂ : Cat}{A B C : Obj ℂ}{f : B ─→ C}{g₁ g₂ : A ─→ B} -> g₁ == g₂ -> f ∘ g₁ == f ∘ g₂ congR q = cong refl q Eq : {ℂ : Cat}{A B : Obj ℂ} -> Equivalence (A ─→ B) Eq = equiv _==_ (\x -> refl) (\x y -> sym) (\x y z -> trans) idL : {ℂ : Cat}{A B : Obj ℂ}{f : A ─→ B} -> id ∘ f == f idL {ℂ}{f = arr _} = eqArr (Pr.idL ℂ) idR : {ℂ : Cat}{A B : Obj ℂ}{f : A ─→ B} -> f ∘ id == f idR {ℂ}{f = arr _} = eqArr (Pr.idR ℂ) assoc : {ℂ : Cat}{A B C D : Obj ℂ}{f : C ─→ D}{g : B ─→ C}{h : A ─→ B} -> (f ∘ g) ∘ h == f ∘ (g ∘ h) assoc {ℂ}{f = arr _}{g = arr _}{h = arr _} = eqArr (Pr.assoc ℂ) -}
{ "alphanum_fraction": 0.4381270903, "avg_line_length": 26.977443609, "ext": "agda", "hexsha": "63238f8601462582db7159a6d1cb454f8e35ac0d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Category.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Category.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": 1765, "size": 3588 }
{-# OPTIONS --cumulativity #-} open import Agda.Primitive data Unit : Set where unit : Unit record Container a : Set (lsuc a) where constructor _◁_ field Shape : Set a Pos : Shape → Set a open Container public data Free {a : Level} (C : Container a) (A : Unit → Set a) : Set a where pure : A unit → Free C A impure : (s : Shape C) → (Pos C s → Free C A) → Free C A ROp : ∀ a → Container (lsuc a) ROp a = Set a ◁ λ x → x rop : {a : Level} {A : Unit → Set a} → Free (ROp a) A rop {_} {A} = impure (A unit) pure rop′ : {a : Level} {A : Unit → Set (lsuc a)} → Free (ROp a) A rop′ {a} {A} = rop {a} -- This should not work, A : Set (suc a) is too large. -- Passing it as an implicit parameter {A} gives the expected error.
{ "alphanum_fraction": 0.5563909774, "avg_line_length": 29.5555555556, "ext": "agda", "hexsha": "be1bab51d8511a825bfdfba415ea32f5b55f7283", "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/Fail/Issue4926b.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue4926b.agda", "max_line_length": 91, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue4926b.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": 264, "size": 798 }
module Prelude.List.Relations.All where open import Prelude.Equality open import Prelude.Nat open import Prelude.Empty open import Prelude.Unit open import Prelude.Product open import Prelude.Number open import Prelude.List.Base open import Prelude.Applicative open import Agda.Primitive infixr 5 _∷_ data All {a b} {A : Set a} (P : A → Set b) : List A → Set (a ⊔ b) where [] : All P [] _∷_ : ∀ {x xs} (p : P x) (ps : All P xs) → All P (x ∷ xs)
{ "alphanum_fraction": 0.6960352423, "avg_line_length": 23.8947368421, "ext": "agda", "hexsha": "b6c5668fe5197d89d99a9855db09c7e247944de6", "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": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Prelude/List/Relations/All.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "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": "t-more/agda-prelude", "max_issues_repo_path": "src/Prelude/List/Relations/All.agda", "max_line_length": 71, "max_stars_count": null, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Prelude/List/Relations/All.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 141, "size": 454 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Rational numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Rational.Base where open import Function using (id) open import Data.Integer as ℤ using (ℤ; ∣_∣; +_; -[1+_]) open import Data.Nat.GCD open import Data.Nat.Divisibility as ℕDiv using (divides; 0∣⇒≡0) open import Data.Nat.Coprimality as C using (Coprime; Bézout-coprime) open import Data.Nat as ℕ using (ℕ; zero; suc) open import Data.Product open import Level using (0ℓ) open import Relation.Nullary.Decidable using (False) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst; cong; cong₂; module ≡-Reasoning) open ≡-Reasoning ------------------------------------------------------------------------ -- Rational numbers in reduced form. Note that there is exactly one -- way to represent every rational number. record ℚ : Set where constructor mkℚ field numerator : ℤ denominator-1 : ℕ .isCoprime : Coprime ∣ numerator ∣ (suc denominator-1) denominatorℕ : ℕ denominatorℕ = suc denominator-1 denominator : ℤ denominator = + denominatorℕ open ℚ public using () renaming ( numerator to ↥_ ; denominator to ↧_ ; denominatorℕ to ↧ₙ_ ) ------------------------------------------------------------------------ -- Equality of rational numbers (coincides with _≡_) infix 4 _≃_ _≃_ : Rel ℚ 0ℓ p ≃ q = (↥ p ℤ.* ↧ q) ≡ (↥ q ℤ.* ↧ p) ------------------------------------------------------------------------ -- Ordering of rationals infix 4 _≤_ data _≤_ : Rel ℚ 0ℓ where *≤* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p) → p ≤ q ------------------------------------------------------------------------ -- Negation pattern +0 = + 0 pattern +[1+_] n = + suc n -_ : ℚ → ℚ - mkℚ -[1+ n ] d prf = mkℚ +[1+ n ] d prf - mkℚ +0 d prf = mkℚ +0 d prf - mkℚ +[1+ n ] d prf = mkℚ -[1+ n ] d prf ------------------------------------------------------------------------ -- Constructing rationals infix 4 _≢0 _≢0 : ℕ → Set n ≢0 = False (n ℕ.≟ 0) -- A constructor for ℚ that takes two natural numbers, say 6 and 21, -- and returns them in a normalized form, e.g. say 2 and 7 normalize : ∀ m n .{m≢0 : m ≢0} .{n≢0 : n ≢0} → ℚ normalize (suc m) (suc n) with gcd (suc m) (suc n) ... | zero , GCD.is (1+m∣0 , _) _ = contradiction (0∣⇒≡0 1+m∣0) λ() ... | suc g , G@(GCD.is (divides (suc p) refl , divides (suc q) refl) _) = mkℚ (+ suc p) q (Bézout-coprime (Bézout.identity G)) -- A constructor for ℚ that (unlike mkℚ) automatically normalises it's -- arguments. See the constants section below for how to use this operator. infixl 7 _/_ _/_ : (n : ℤ) (d : ℕ) → .{d≢0 : d ≢0} → ℚ _/_ +0 d {d≢0} = mkℚ +0 0 (C.sym (C.1-coprimeTo 0)) _/_ +[1+ n ] d {d≢0} = normalize (suc n) d {_} {d≢0} _/_ -[1+ n ] d {d≢0} = - normalize (suc n) d {_} {d≢0} ------------------------------------------------------------------------------ -- Some constants 0ℚ : ℚ 0ℚ = + 0 / 1 1ℚ : ℚ 1ℚ = + 1 / 1 ½ : ℚ ½ = + 1 / 2 -½ : ℚ -½ = - ½ ------------------------------------------------------------------------------ -- Operations on rationals infix 8 -_ 1/_ infixl 7 _*_ _÷_ infixl 6 _-_ _+_ -- addition _+_ : ℚ → ℚ → ℚ p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q) -- multiplication _*_ : ℚ → ℚ → ℚ p * q = (↥ p ℤ.* ↥ q) / (↧ₙ p ℕ.* ↧ₙ q) -- subtraction _-_ : ℚ → ℚ → ℚ p - q = p + (- q) -- reciprocal: requires a proof that the numerator is not zero 1/_ : (p : ℚ) → .{n≢0 : ∣ ↥ p ∣ ≢0} → ℚ 1/ mkℚ +[1+ n ] d prf = mkℚ +[1+ d ] n (C.sym prf) 1/ mkℚ -[1+ n ] d prf = mkℚ -[1+ d ] n (C.sym prf) -- division: requires a proof that the denominator is not zero _÷_ : (p q : ℚ) → .{n≢0 : ∣ ↥ q ∣ ≢0} → ℚ (p ÷ q) {n≢0} = p * (1/_ q {n≢0})
{ "alphanum_fraction": 0.4896621281, "avg_line_length": 26.2649006623, "ext": "agda", "hexsha": "129068ffb6b5086c5f9c5f495f642a3aa85a7944", "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/Rational/Base.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/Rational/Base.agda", "max_line_length": 78, "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/Rational/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1436, "size": 3966 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Ring.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Macro open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring.Base private variable ℓ : Level {- some basic calculations (used for example in QuotientRing.agda), that should become obsolete or subject to change once we have a ring solver (see https://github.com/agda/cubical/issues/297) -} module Theory (R' : Ring {ℓ}) where open RingStr (snd R') private R = ⟨ R' ⟩ implicitInverse : (x y : R) → x + y ≡ 0r → y ≡ - x implicitInverse x y p = y ≡⟨ sym (+-lid y) ⟩ 0r + y ≡⟨ cong (λ u → u + y) (sym (+-linv x)) ⟩ (- x + x) + y ≡⟨ sym (+-assoc _ _ _) ⟩ (- x) + (x + y) ≡⟨ cong (λ u → (- x) + u) p ⟩ (- x) + 0r ≡⟨ +-rid _ ⟩ - x ∎ equalByDifference : (x y : R) → x - y ≡ 0r → x ≡ y equalByDifference x y p = x ≡⟨ sym (+-rid _) ⟩ x + 0r ≡⟨ cong (λ u → x + u) (sym (+-linv y)) ⟩ x + ((- y) + y) ≡⟨ +-assoc _ _ _ ⟩ (x - y) + y ≡⟨ cong (λ u → u + y) p ⟩ 0r + y ≡⟨ +-lid _ ⟩ y ∎ 0-selfinverse : - 0r ≡ 0r 0-selfinverse = sym (implicitInverse _ _ (+-rid 0r)) 0-idempotent : 0r + 0r ≡ 0r 0-idempotent = +-lid 0r +-idempotency→0 : (x : R) → x ≡ x + x → x ≡ 0r +-idempotency→0 x p = x ≡⟨ sym (+-rid x) ⟩ x + 0r ≡⟨ cong (λ u → x + u) (sym (+-rinv _)) ⟩ x + (x + (- x)) ≡⟨ +-assoc _ _ _ ⟩ (x + x) + (- x) ≡⟨ cong (λ u → u + (- x)) (sym p) ⟩ x + (- x) ≡⟨ +-rinv _ ⟩ 0r ∎ 0-rightNullifies : (x : R) → x · 0r ≡ 0r 0-rightNullifies x = let x·0-is-idempotent : x · 0r ≡ x · 0r + x · 0r x·0-is-idempotent = x · 0r ≡⟨ cong (λ u → x · u) (sym 0-idempotent) ⟩ x · (0r + 0r) ≡⟨ ·-rdist-+ _ _ _ ⟩ (x · 0r) + (x · 0r) ∎ in (+-idempotency→0 _ x·0-is-idempotent) 0-leftNullifies : (x : R) → 0r · x ≡ 0r 0-leftNullifies x = let 0·x-is-idempotent : 0r · x ≡ 0r · x + 0r · x 0·x-is-idempotent = 0r · x ≡⟨ cong (λ u → u · x) (sym 0-idempotent) ⟩ (0r + 0r) · x ≡⟨ ·-ldist-+ _ _ _ ⟩ (0r · x) + (0r · x) ∎ in +-idempotency→0 _ 0·x-is-idempotent -commutesWithRight-· : (x y : R) → x · (- y) ≡ - (x · y) -commutesWithRight-· x y = implicitInverse (x · y) (x · (- y)) (x · y + x · (- y) ≡⟨ sym (·-rdist-+ _ _ _) ⟩ x · (y + (- y)) ≡⟨ cong (λ u → x · u) (+-rinv y) ⟩ x · 0r ≡⟨ 0-rightNullifies x ⟩ 0r ∎) -commutesWithLeft-· : (x y : R) → (- x) · y ≡ - (x · y) -commutesWithLeft-· x y = implicitInverse (x · y) ((- x) · y) (x · y + (- x) · y ≡⟨ sym (·-ldist-+ _ _ _) ⟩ (x - x) · y ≡⟨ cong (λ u → u · y) (+-rinv x) ⟩ 0r · y ≡⟨ 0-leftNullifies y ⟩ 0r ∎) -isDistributive : (x y : R) → (- x) + (- y) ≡ - (x + y) -isDistributive x y = implicitInverse _ _ ((x + y) + ((- x) + (- y)) ≡⟨ sym (+-assoc _ _ _) ⟩ x + (y + ((- x) + (- y))) ≡⟨ cong (λ u → x + (y + u)) (+-comm _ _) ⟩ x + (y + ((- y) + (- x))) ≡⟨ cong (λ u → x + u) (+-assoc _ _ _) ⟩ x + ((y + (- y)) + (- x)) ≡⟨ cong (λ u → x + (u + (- x))) (+-rinv _) ⟩ x + (0r + (- x)) ≡⟨ cong (λ u → x + u) (+-lid _) ⟩ x + (- x) ≡⟨ +-rinv _ ⟩ 0r ∎) translatedDifference : (x a b : R) → a - b ≡ (x + a) - (x + b) translatedDifference x a b = a - b ≡⟨ cong (λ u → a + u) (sym (+-lid _)) ⟩ (a + (0r + (- b))) ≡⟨ cong (λ u → a + (u + (- b))) (sym (+-rinv _)) ⟩ (a + ((x + (- x)) + (- b))) ≡⟨ cong (λ u → a + u) (sym (+-assoc _ _ _)) ⟩ (a + (x + ((- x) + (- b)))) ≡⟨ (+-assoc _ _ _) ⟩ ((a + x) + ((- x) + (- b))) ≡⟨ cong (λ u → u + ((- x) + (- b))) (+-comm _ _) ⟩ ((x + a) + ((- x) + (- b))) ≡⟨ cong (λ u → (x + a) + u) (-isDistributive _ _) ⟩ ((x + a) - (x + b)) ∎ +-assoc-comm1 : (x y z : R) → x + (y + z) ≡ y + (x + z) +-assoc-comm1 x y z = +-assoc x y z ∙∙ cong (λ x → x + z) (+-comm x y) ∙∙ sym (+-assoc y x z) +-assoc-comm2 : (x y z : R) → x + (y + z) ≡ z + (y + x) +-assoc-comm2 x y z = +-assoc-comm1 x y z ∙∙ cong (λ x → y + x) (+-comm x z) ∙∙ +-assoc-comm1 y z x module HomTheory {R S : Ring {ℓ}} (f′ : RingHom R S) where open Theory ⦃...⦄ open RingStr ⦃...⦄ open RingHom f′ private instance _ = R _ = S _ = snd R _ = snd S homPres0 : f 0r ≡ 0r homPres0 = +-idempotency→0 (f 0r) (f 0r ≡⟨ sym (cong f 0-idempotent) ⟩ f (0r + 0r) ≡⟨ isHom+ _ _ ⟩ f 0r + f 0r ∎) -commutesWithHom : (x : ⟨ R ⟩) → f (- x) ≡ - (f x) -commutesWithHom x = implicitInverse _ _ (f x + f (- x) ≡⟨ sym (isHom+ _ _) ⟩ f (x + (- x)) ≡⟨ cong f (+-rinv x) ⟩ f 0r ≡⟨ homPres0 ⟩ 0r ∎)
{ "alphanum_fraction": 0.3841746671, "avg_line_length": 39.1393939394, "ext": "agda", "hexsha": "e0ffd9222d7fc66ab5bd47b34328197f78a6724b", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/Algebra/Ring/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2400, "size": 6458 }
-- Andreas, 2017-01-12, issue #2386 id : {A : Set} → A → A id x = x data Eq (A : Set) : (x y : A) → Set where refl : (x : A) → Eq A x (id x) {-# BUILTIN EQUALITY Eq #-} -- Should be accepted.
{ "alphanum_fraction": 0.5202020202, "avg_line_length": 16.5, "ext": "agda", "hexsha": "010a1ccc56beb9d43d25cef95d6a9e0a5efe7bcf", "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/Issue2386ReflId.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/Issue2386ReflId.agda", "max_line_length": 41, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2386ReflId.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": 79, "size": 198 }
{-# OPTIONS --allow-unsolved-metas #-} data ⊤ : Set where tt : ⊤ data _≡_ (a : ⊤) : {B : Set} → B → Set where refl : a ≡ a foo : ⊤ foo = (λ (z : ⊤) (q : bar ≡ {!!}) → tt) bar refl where bar : ⊤ bar = {!!}
{ "alphanum_fraction": 0.4369369369, "avg_line_length": 15.8571428571, "ext": "agda", "hexsha": "b4d511b3be9ef3f6438fa2d81e027026974f832f", "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/Issue2627.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/Issue2627.agda", "max_line_length": 48, "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/Issue2627.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": 97, "size": 222 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed W-types aka Petersson-Synek trees ------------------------------------------------------------------------ module Data.W.Indexed where open import Level open import Data.Container.Indexed.Core open import Data.Product open import Relation.Unary -- The family of indexed W-types. module _ {ℓ c r} {O : Set ℓ} (C : Container O O c r) where open Container C data W (o : O) : Set (ℓ ⊔ c ⊔ r) where sup : ⟦ C ⟧ W o → W o -- Projections. head : W ⊆ Command head (sup (c , _)) = c tail : ∀ {o} (w : W o) (r : Response (head w)) → W (next (head w) r) tail (sup (_ , k)) r = k r -- Induction, (primitive) recursion and iteration. ind : ∀ {ℓ} (P : Pred (Σ O W) ℓ) → (∀ {o} (cs : ⟦ C ⟧ W o) → □ C P (o , cs) → P (o , sup cs)) → ∀ {o} (w : W o) → P (o , w) ind P φ (sup (c , k)) = φ (c , k) (λ r → ind P φ (k r)) rec : ∀ {ℓ} {X : Pred O ℓ} → (⟦ C ⟧ (W ∩ X) ⊆ X) → W ⊆ X rec φ (sup (c , k))= φ (c , λ r → (k r , rec φ (k r))) iter : ∀ {ℓ} {X : Pred O ℓ} → (⟦ C ⟧ X ⊆ X) → W ⊆ X iter φ (sup (c , k))= φ (c , λ r → iter φ (k r))
{ "alphanum_fraction": 0.4399664148, "avg_line_length": 27.6976744186, "ext": "agda", "hexsha": "1b615ecba2d0518d50fbd642073e9440627a16e2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/W/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/W/Indexed.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/W/Indexed.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 442, "size": 1191 }
module SystemF.Syntax.Type.Constructors where open import Prelude open import SystemF.Syntax.Type open import SystemF.Substitutions.Types -- church numerals tnat : Type 0 tnat = ∀' (((tvar zero) →' (tvar zero)) →' (tvar zero) →' (tvar zero)) -- Type of the polymorphic identity tid' : ∀ {n} → Type n tid' = ∀' ((tvar zero) →' (tvar zero)) -- Top/terminal/unit type ⊤' : ∀ {n} → Type n ⊤' = tid' -- Bottom/initial/zero type ⊥' : ∀ {n} → Type n ⊥' = ∀' (tvar zero) -- n-ary function type infixr 7 _→ⁿ_ _→ⁿ_ : ∀ {n k} → Vec (Type n) k → Type n → Type n [] →ⁿ z = z (a ∷ as) →ⁿ z = as →ⁿ a →' z -- Record/finite tuple rec : ∀ {n k} → Vec (Type n) k → Type n rec [] = ⊤' rec (a ∷ as) = ∀' ((map tp-weaken (a ∷ as) →ⁿ tvar zero) →' tvar zero) -- tuple _×'_ : ∀ {n} → Type n → Type n → Type n a ×' b = rec (a ∷ b ∷ [])
{ "alphanum_fraction": 0.5600961538, "avg_line_length": 22.4864864865, "ext": "agda", "hexsha": "724fc8f79c6d19df9f573399d2aba2975c6d7699", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_line_length": 70, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/Syntax/Type/Constructors.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 337, "size": 832 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Finite.Fin.Construction.Discrete where open import Data.Product using (∃; _,_) open import Data.Nat using (ℕ) open import Data.Fin open import Data.Fin.Patterns open import Function using (case_of_) open import Relation.Nullary using (Dec; yes; no) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_ ; refl; ≡-≟-identity; ≢-≟-identity) open import Categories.Category.Finite.Fin open import Categories.Category private card : ∀ {n} (j k : Fin n) → ℕ card {ℕ.suc n} 0F 0F = 1 card {ℕ.suc n} 0F (suc k) = 0 card {ℕ.suc n} (suc j) 0F = 0 card {ℕ.suc n} (suc j) (suc k) = card j k id : ∀ {n} (a : Fin n) → Fin (card a a) id {ℕ.suc n} 0F = 0F id {ℕ.suc n} (suc a) = id a comp : ∀ n {a b c : Fin n} → Fin (card b c) → Fin (card a b) → Fin (card a c) comp (ℕ.suc n) {0F} {0F} {0F} f g = 0F comp (ℕ.suc n) {suc a} {suc b} {suc c} f g = comp n f g assoc : ∀ n {a b c d : Fin n} {f : Fin (card a b)} {g : Fin (card b c)} {h : Fin (card c d)} → (comp n (comp n h g) f) ≡ comp n h (comp n g f) assoc (ℕ.suc n) {0F} {0F} {0F} {0F} {f} {g} {h} = refl assoc (ℕ.suc n) {suc a} {suc b} {suc c} {suc d} {f} {g} {h} = assoc n identityˡ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n (id b) f ≡ f identityˡ (ℕ.suc n) {0F} {0F} {0F} = refl identityˡ (ℕ.suc n) {suc a} {suc b} {f} = identityˡ n identityʳ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n f (id a) ≡ f identityʳ (ℕ.suc n) {0F} {0F} {0F} = refl identityʳ (ℕ.suc n) {suc a} {suc b} {f} = identityʳ n module _ (n : ℕ) where DiscreteShape : FinCatShape DiscreteShape = record { size = n ; ∣_⇒_∣ = card {n} ; hasShape = record { id = id {n} _ ; _∘_ = comp n ; assoc = assoc n ; identityˡ = identityˡ n ; identityʳ = identityʳ n } } Discrete : ∀ n → Category _ _ _ Discrete n = FinCategory (DiscreteShape n) module Discrete n = Category (Discrete n)
{ "alphanum_fraction": 0.5513748191, "avg_line_length": 31.8923076923, "ext": "agda", "hexsha": "61de0c07bb92bb8334dc159d893f17f39f36f13f", "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/Finite/Fin/Construction/Discrete.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/Finite/Fin/Construction/Discrete.agda", "max_line_length": 101, "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/Finite/Fin/Construction/Discrete.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 858, "size": 2073 }
-- Andreas, 2016-05-10, issue 1848, reported by Nisse -- {-# OPTIONS -v tc.lhs.top:20 #-} data D : Set where c : D → D postulate P : D → Set foo : (x : D) → P x foo _ = {!!} -- checked lhs: -- ps = _ -- delta = (x : D) -- qs = [r(x = VarP (0,"x"))] -- The unnamed variable is part of the context: -- Goal: P .x -- ———————————————————————————————————————————————————————————— -- .x : D bar : (x : D) → P x bar (c _) = {!!} -- WAS: -- checked lhs: -- ps = _ -- delta = (_ : D) -- qs = [r(x = ConP Issue1848.D.c ... [r(_ = VarP (0,"_"))])] -- The unnamed variable is not part of the context: -- Goal: P (c _) -- ———————————————————————————————————————————————————————————— -- This can, in more complicated situations, make the goal type harder -- to understand. -- NOW: -- Unnamed variable should be displayed in the context, e.g., as ".x"
{ "alphanum_fraction": 0.4513574661, "avg_line_length": 20.0909090909, "ext": "agda", "hexsha": "d3b75f2a3541a5cec14a2adf8303763a7cef16d2", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue1848.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue1848.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue1848.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": 283, "size": 884 }
open import GGT -- Throughout the following assume A is a (right) Action module GGT.Theory {a b ℓ₁ ℓ₂} (A : Action a b ℓ₁ ℓ₂) where open import Level open import Relation.Unary hiding (_\\_; _⇒_) open import Relation.Binary open import Algebra open import Data.Product open Action A renaming (setoid to Ω') open import Relation.Binary.Reasoning.MultiSetoid -- open import Relation.Binary.Reasoning.Setoid Ω' would be enough open Group G renaming (setoid to S) open import GGT.Group.Structures {a} {ℓ₂} {ℓ₁} open import GGT.Group.Bundles {a} {ℓ₂} {ℓ₁} open import Function.Bundles open import Function.Base using (_on_) orbitalEq : IsEquivalence _ω_ orbitalEq = record { refl = r ; sym = s ; trans = t } where open Setoid Ω' renaming (sym to σ) r : Reflexive _ω_ r {o} = ε , actId o s : Symmetric _ω_ s {x} {y} ( g , x·g≡y ) = (g ⁻¹ , y·g⁻¹≡x) where y·g⁻¹≡x = σ x≡y·g⁻¹ where x≡y·g⁻¹ = begin⟨ Ω' ⟩ x ≈˘⟨ actId x ⟩ x · ε ≈˘⟨ G-ext (inverseʳ _) ⟩ x · (g ∙ g ⁻¹) ≈⟨ actAssoc _ _ _ ⟩ x · g · g ⁻¹ ≈⟨ ·-cong (g ⁻¹) x·g≡y ⟩ y · g ⁻¹ ∎ t : Transitive _ω_ t {x} {y} {z} ( g , x·g≡y ) ( h , y·h≡z ) = ( g ∙ h , x·gh≡z ) where x·gh≡z : _ x·gh≡z = begin⟨ Ω' ⟩ x · (g ∙ h) ≈⟨ actAssoc _ _ _ ⟩ x · g · h ≈⟨ ·-cong _ x·g≡y ⟩ y · h ≈⟨ y·h≡z ⟩ z ∎ ω≤≋ : _≋_ ⇒ _ω_ ω≤≋ {o} {o'} o≋o' = (ε , oε≋o' ) where oε≋o' = begin⟨ Ω' ⟩ o · ε ≈⟨ actId o ⟩ o ≈⟨ o≋o' ⟩ o' ∎ stabIsSubGroup : ∀ (o : Ω) → (stab o) ≤ G stabIsSubGroup o = record { ε∈ = actId o ; ∙-⁻¹-closed = itis ; r = resp } where itis = λ {x} {y} px py → begin⟨ Ω' ⟩ (o · (x - y)) ≡⟨⟩ o · x ∙ (y ⁻¹) ≈⟨ actAssoc o x (y ⁻¹) ⟩ o · x · y ⁻¹ ≈⟨ ·-cong (y ⁻¹) px ⟩ o · y ⁻¹ ≈˘⟨ ·-cong (y ⁻¹) py ⟩ o · y · y ⁻¹ ≈˘⟨ actAssoc o y (y ⁻¹) ⟩ o · (y ∙ y ⁻¹) ≈⟨ G-ext (inverseʳ y) ⟩ o · ε ≈⟨ actId o ⟩ o ∎ resp : ∀ {x y : Carrier} → x ≈ y → ((stab o) x) → ((stab o) y) resp {x} {y} x~y xfixeso = begin⟨ Ω' ⟩ o · y ≈˘⟨ G-ext x~y ⟩ o · x ≈⟨ xfixeso ⟩ o ∎ Stab : Ω → SubGroup G Stab o = record { P = stab o; isSubGroup = stabIsSubGroup o} orbitalCorr : {o : Ω} → Bijection (Stab o \\ G) (Orbit o) orbitalCorr {o} = record { f = f ; cong = cc ; bijective = inj ,′ surj } where open Setoid (Stab o \\ G) renaming (_≈_ to _≈₁_; Carrier to G') open Setoid (Orbit o) renaming (_≈_ to _≈₂_) open Setoid S renaming (refl to r) f : G' → Σ Ω (o ·G) f x = (o · x , ( x , G-ext r)) cc : f Preserves _≈₁_ ⟶ _≈₂_ cc {g} {h} g≈₁h = begin⟨ Ω' ⟩ -- f h ≈₂ f g o · g ≈˘⟨ actId (o · g) ⟩ o · g · ε ≈˘⟨ G-ext (inverseˡ h) ⟩ o · g · (h ⁻¹ ∙ h ) ≈˘⟨ actAssoc o g (h ⁻¹ ∙ h ) ⟩ o · (g ∙ (h ⁻¹ ∙ h )) ≈˘⟨ G-ext (assoc _ _ _) ⟩ o · ((g ∙ h ⁻¹) ∙ h ) ≈⟨ actAssoc _ _ h ⟩ o · (g ∙ h ⁻¹) · h ≈⟨ ·-cong h g≈₁h ⟩ -- g≈₁h ⇒ P (g ∙ h ⁻¹) ⇒ (g ∙ h ⁻¹) ∈ Stab o o · h ∎ inj : _ -- o · g = o · h ⇒ g ∙ h ⁻¹ ∈ Stab o inj {g} {h} fg≈₂fh = begin⟨ Ω' ⟩ o · g ∙ h ⁻¹ ≈⟨ actAssoc _ _ _ ⟩ o · g · h ⁻¹ ≈⟨ ·-cong _ fg≈₂fh ⟩ o · h · h ⁻¹ ≈˘⟨ actAssoc _ _ _ ⟩ o · (h ∙ h ⁻¹) ≈⟨ G-ext (inverseʳ h)⟩ o · ε ≈⟨ actId o ⟩ o ∎ surj : _ surj (_ , p) = p
{ "alphanum_fraction": 0.3895131086, "avg_line_length": 35.1315789474, "ext": "agda", "hexsha": "f339dec3db62eacbd8dbf478e571ffdae4870aca", "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": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zampino/ggt", "max_forks_repo_path": "src/ggt/Theory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "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": "zampino/ggt", "max_issues_repo_path": "src/ggt/Theory.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zampino/ggt", "max_stars_repo_path": "src/ggt/Theory.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z", "num_tokens": 1655, "size": 4005 }
{-# OPTIONS --without-K #-} module Ch1-5 where open import Data.Product open import Ch2-1 uniq : ∀ {a b} {A : Set a} {B : Set b} → (x : A × B) → ((proj₁ x , proj₂ x) ≡ x) uniq (fst , snd) = refl ind : ∀ {a b c} {A : Set a} {B : Set b} → (C : A × B → Set c) → ((x : A) → (y : B) → C (x , y)) → (p : A × B) → C p ind C c (fst , snd) = c fst snd -- Definition 1.5.2 Definition-1-5-2 : ∀ {a b c} {A : Set a} {B : Set b} → (C : Set c) → (f : A → B → C) → A × B → C Definition-1-5-2 {_} {_} {_} {A} {B} C f (fst , snd) = f fst snd
{ "alphanum_fraction": 0.4500907441, "avg_line_length": 19.6785714286, "ext": "agda", "hexsha": "a7a3d68ce7ff7e74805c1ebc4d44d45d0e5bdd14", "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": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/hott", "max_forks_repo_path": "src/Ch1-5.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/hott", "max_issues_repo_path": "src/Ch1-5.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/hott", "max_stars_repo_path": "src/Ch1-5.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 251, "size": 551 }
{-# OPTIONS --safe #-} open import Generics.Prelude hiding (lookup; pi; curry) open import Generics.Telescope open import Generics.Desc open import Generics.All open import Generics.HasDesc import Generics.Helpers as Helpers open import Relation.Binary.HeterogeneousEquality.Core using (_≅_; refl) module Generics.Constructions.Cong {P I ℓ} {A : Indexed P I ℓ} (H : HasDesc {P} {I} {ℓ} A) {p} where open HasDesc H private variable V : ExTele P i i₁ i₂ : ⟦ I ⟧tel p v v₁ v₂ : ⟦ V ⟧tel p ----------------------- -- Type of congruences levelCongCon : (C : ConDesc P V I) → Level levelCongCon (var _) = ℓ levelCongCon (π {ℓ} _ _ C) = ℓ ⊔ levelCongCon C levelCongCon (A ⊗ B) = levelIndArg A ℓ ⊔ levelCongCon B CongCon : (C : ConDesc P V I) (mk₁ : ∀ {i₁} → ⟦ C ⟧Con A′ (p , v₁ , i₁) → ⟦ D ⟧Data A′ (p , i₁)) (mk₂ : ∀ {i₂} → ⟦ C ⟧Con A′ (p , v₂ , i₂) → ⟦ D ⟧Data A′ (p , i₂)) → Set (levelCongCon C) -- If non-inductive arguments are equal CongCon (π (n , ai) S C) mk₁ mk₂ = {s₁ : < relevance ai > S _} {s₂ : < relevance ai > S _} → s₁ ≅ s₂ → CongCon C (λ x → mk₁ (s₁ , x)) (λ x → mk₂ (s₂ , x)) -- And inductive arguments are equal CongCon (A ⊗ B) mk₁ mk₂ = {f₁ : ⟦ A ⟧IndArg A′ _} {f₂ : ⟦ A ⟧IndArg A′ _} → f₁ ≅ f₂ → CongCon B (λ x → mk₁ (f₁ , x)) (λ x → mk₂ (f₂ , x)) -- Then applying the constructor to both sets should lead -- to equal values CongCon (var f) mk₁ mk₂ = constr (mk₁ refl) ≅ constr (mk₂ refl) Cong : ∀ k → Set (levelCongCon (lookupCon D k)) Cong k = CongCon (lookupCon D k) (k ,_) (k ,_) ---------------------- -- Generic congruence deriveCong : ∀ k → Cong k deriveCong k = congCon (lookupCon D k) where congCon : (C : ConDesc P V I) {mk : ∀ {i} → ⟦ C ⟧Con A′ (p , v , i) → ⟦ D ⟧Data A′ (p , i)} → CongCon C mk mk congCon (var f) = refl congCon (π ai S C) refl = congCon C congCon (A ⊗ B) refl = congCon B
{ "alphanum_fraction": 0.5594159114, "avg_line_length": 27.2054794521, "ext": "agda", "hexsha": "1e5d5f9a8e48b21a88b838de4821164c72146144", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Constructions/Cong.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Constructions/Cong.agda", "max_line_length": 76, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Constructions/Cong.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 748, "size": 1986 }
{-# OPTIONS --without-K #-} module VectorLemmas where open import Level using (Level) open import Data.Vec using (Vec; tabulate; []; _∷_; lookup; allFin) renaming (_++_ to _++V_; map to mapV; concat to concatV) open import Data.Vec.Properties using (lookup-++-≥; lookup∘tabulate; tabulate-∘; tabulate∘lookup; tabulate-allFin) open import Function using (id;_∘_;flip) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; cong₂; subst; trans; proof-irrelevance; module ≡-Reasoning) open import Data.Nat using (ℕ; zero; suc; _+_; z≤n; _*_) open import Data.Nat.Properties.Simple using (+-comm; +-right-identity) open import Data.Fin using (Fin; zero; suc; inject+; raise; reduce≥) open import Data.Fin.Properties using (toℕ-injective) open import Data.Sum using (_⊎_; [_,_]′; inj₁; inj₂) renaming (map to map⊎) open import SubstLemmas open import FinNatLemmas open import FiniteFunctions ------------------------------------------------------------------------------ -- Lemmas about map and tabulate -- to make things look nicer _!!_ : ∀ {m} {A : Set} → Vec A m → Fin m → A v !! i = lookup i v -- this is actually in Data.Vec.Properties, but over an arbitrary -- Setoid. Specialize map-id : ∀ {a n} {A : Set a} (xs : Vec A n) → mapV id xs ≡ xs map-id [] = refl map-id (x ∷ xs) = cong (_∷_ x) (map-id xs) map-++-commute : ∀ {a b m n} {A : Set a} {B : Set b} (f : B → A) (xs : Vec B m) {ys : Vec B n} → mapV f (xs ++V ys) ≡ mapV f xs ++V mapV f ys map-++-commute f [] = refl map-++-commute f (x ∷ xs) = cong (λ z → f x ∷ z) (map-++-commute f xs) -- this is too, but is done "point free", this version is more convenient map-∘ : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c} (f : B → C) (g : A → B) → (xs : Vec A n) → mapV (f ∘ g) xs ≡ (mapV f ∘ mapV g) xs map-∘ f g [] = refl map-∘ f g (x ∷ xs) = cong (_∷_ (f (g x))) (map-∘ f g xs) -- this looks trivial, why can't I find it? lookup-map : ∀ {a b} {n : ℕ} {A : Set a} {B : Set b} → (i : Fin n) → (f : A → B) → (v : Vec A n) → lookup i (mapV f v) ≡ f (lookup i v) lookup-map {n = 0} () _ _ lookup-map {n = suc n} zero f (x ∷ v) = refl lookup-map {n = suc n} (suc i) f (x ∷ v) = lookup-map i f v -- These are 'generalized' lookup into left/right parts of a Vector which -- does not depend on the values in the Vector at all. look-left : ∀ {m n} {a b c : Level} {A : Set a} {B : Set b} {C : Set c} → (i : Fin m) → (f : A → C) → (g : B → C) → (vm : Vec A m) → (vn : Vec B n) → lookup (inject+ n i) (mapV f vm ++V mapV g vn) ≡ f (lookup i vm) look-left {0} () _ _ _ _ look-left {suc _} zero f g (x ∷ vm) vn = refl look-left {suc _} (suc i) f g (x ∷ vm) vn = look-left i f g vm vn look-right : ∀ {m n} {a b c : Level} {A : Set a} {B : Set b} {C : Set c} → (i : Fin n) → (f : A → C) → (g : B → C) → (vm : Vec A m) → (vn : Vec B n) → lookup (raise m i) (mapV f vm ++V mapV g vn) ≡ g (lookup i vn) look-right {0} i f g vn vm = lookup-map i g vm look-right {suc m} {0} () _ _ _ _ look-right {suc m} {suc n} i f g (x ∷ vn) vm = look-right i f g vn vm -- variant left!! : ∀ {m n} {C : Set} → (i : Fin m) → (f : Fin m → C) → {g : Fin n → C} → (tabulate f ++V tabulate g) !! (inject+ n i) ≡ f i left!! {zero} () _ left!! {suc _} zero f = refl left!! {suc _} (suc i) f = left!! i (f ∘ suc) right!! : ∀ {m n} {C : Set} → (i : Fin n) → {f : Fin m → C} → (g : Fin n → C) → (tabulate f ++V tabulate g) !! (raise m i) ≡ g i right!! {zero} i g = lookup∘tabulate g i right!! {suc _} {0} () _ right!! {suc m} {suc _} i g = right!! {m} i g -- similar to lookup-++-inject+ from library lookup-++-raise : ∀ {m n} {a : Level} {A : Set a} → (vm : Vec A m) (vn : Vec A n) (i : Fin n) → lookup (raise m i) (vm ++V vn) ≡ lookup i vn lookup-++-raise {0} vn vm i = begin (lookup i (vn ++V vm) ≡⟨ lookup-++-≥ vn vm i z≤n ⟩ lookup (reduce≥ i z≤n) vm ≡⟨ refl ⟩ lookup i vm ∎) where open ≡-Reasoning -- lookup-++-raise {suc m} {0} _ _ () lookup-++-raise {suc m} {suc n} (x ∷ vn) vm i = lookup-++-raise vn vm i -- concat (map (map f) xs) = map f (concat xs) concat-map : ∀ {a b m n} {A : Set a} {B : Set b} → (xs : Vec (Vec A n) m) → (f : A → B) → concatV (mapV (mapV f) xs) ≡ mapV f (concatV xs) concat-map [] f = refl concat-map (xs ∷ xss) f = begin (concatV (mapV (mapV f) (xs ∷ xss)) ≡⟨ refl ⟩ concatV (mapV f xs ∷ mapV (mapV f) xss) ≡⟨ refl ⟩ mapV f xs ++V concatV (mapV (mapV f) xss) ≡⟨ cong (_++V_ (mapV f xs)) (concat-map xss f) ⟩ mapV f xs ++V mapV f (concatV xss) ≡⟨ sym (map-++-commute f xs) ⟩ mapV f (xs ++V concatV xss) ≡⟨ refl ⟩ mapV f (concatV (xs ∷ xss)) ∎) where open ≡-Reasoning map-map-map : ∀ {a b c m n} {A : Set a} {B : Set b} {C : Set c} → (f : B → C) → (g : A → Vec B n) → (xs : Vec A m) → mapV (mapV f) (mapV g xs) ≡ mapV (mapV f ∘ g) xs map-map-map f g xss = sym (map-∘ (mapV f) g xss) splitV+ : ∀ {m n} {a : Level} {A : Set a} {f : Fin (m + n) → A} → Vec A (m + n) splitV+ {m} {n} {f = f} = tabulate {m} (f ∘ inject+ n) ++V tabulate {n} (f ∘ raise m) splitVOp+ : ∀ {m} {n} {a : Level} {A : Set a} {f : Fin (n + m) → A} → Vec A (m + n) splitVOp+ {m} {n} {f = f} = tabulate {m} (f ∘ raise n) ++V tabulate {n} (f ∘ inject+ m) -- f can be implicit since this is mostly used in equational reasoning, where it can be inferred! tabulate-split : ∀ {m n} {a : Level} {A : Set a} → {f : Fin (m + n) → A} → tabulate {m + n} f ≡ splitV+ {m} {n} {f = f} tabulate-split {0} = refl tabulate-split {suc m} {f = f} = cong (_∷_ (f zero)) (tabulate-split {m} {f = f ∘ suc}) lookup-subst : ∀ {m m' n} (i : Fin n) (xs : Vec (Fin m) n) (eq : m ≡ m') → lookup i (subst (λ s → Vec (Fin s) n) eq xs) ≡ subst Fin eq (lookup i xs) lookup-subst i xs refl = refl -- lookup is associative on Fin vectors lookupassoc : ∀ {m₁ m₂ m₃ m₄} → (π₁ : Vec (Fin m₂) m₁) (π₂ : Vec (Fin m₃) m₂) (π₃ : Vec (Fin m₄) m₃) → (i : Fin m₁) → lookup (lookup i π₁) (tabulate (λ j → lookup (lookup j π₂) π₃)) ≡ lookup (lookup i (tabulate (λ j → lookup (lookup j π₁) π₂))) π₃ lookupassoc π₁ π₂ π₃ i = begin (lookup (lookup i π₁) (tabulate (λ j → lookup (lookup j π₂) π₃)) ≡⟨ lookup∘tabulate (λ j → lookup (lookup j π₂) π₃) (lookup i π₁) ⟩ lookup (lookup (lookup i π₁) π₂) π₃ ≡⟨ cong (λ x → lookup x π₃) (sym (lookup∘tabulate (λ j → lookup (lookup j π₁) π₂) i)) ⟩ lookup (lookup i (tabulate (λ j → lookup (lookup j π₁) π₂))) π₃ ∎) where open ≡-Reasoning -- This should generalize a lot, but that can be done later subst-lookup-tabulate-raise : ∀ {m n : ℕ} → (z : Fin n) → subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (raise m i)))) ≡ raise m z subst-lookup-tabulate-raise {m} {n} z = begin (subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (raise m i)))) ≡⟨ cong (subst Fin (+-comm n m)) (lookup∘tabulate (λ i → subst Fin (+-comm m n) (raise m i)) z) ⟩ subst Fin (+-comm n m) (subst Fin (+-comm m n) (raise m z)) ≡⟨ subst-subst (+-comm n m) (+-comm m n) (proof-irrelevance (sym (+-comm n m)) (+-comm m n)) (raise m z) ⟩ raise m z ∎) where open ≡-Reasoning subst-lookup-tabulate-inject+ : ∀ {m n : ℕ} → (z : Fin m) → subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (inject+ n i)))) ≡ inject+ n z subst-lookup-tabulate-inject+ {m} {n} z = begin (subst Fin (+-comm n m) (lookup z (tabulate (λ i → subst Fin (+-comm m n) (inject+ n i)))) ≡⟨ cong (subst Fin (+-comm n m)) (lookup∘tabulate (λ i → subst Fin (+-comm m n) (inject+ n i)) z) ⟩ subst Fin (+-comm n m) (subst Fin (+-comm m n) (inject+ n z)) ≡⟨ subst-subst (+-comm n m) (+-comm m n) (proof-irrelevance (sym (+-comm n m)) (+-comm m n)) (inject+ n z) ⟩ inject+ n z ∎) where open ≡-Reasoning -- a kind of inverse for splitAt unSplit : {m n : ℕ} {A : Set} → (f : Fin (m + n) → A) → tabulate {m} (f ∘ (inject+ n)) ++V tabulate {n} (f ∘ (raise m)) ≡ tabulate f unSplit {0} {n} f = refl unSplit {suc m} f = cong (λ x → (f zero) ∷ x) (unSplit {m} (f ∘ suc)) -- nested tabulate-lookup denest-tab-!! : {A B C : Set} {k : ℕ} → (f : B → C) → (g : A → B) → (v : Vec A k) → tabulate (λ i → f (tabulate (λ j → g (v !! j)) !! i)) ≡ mapV (f ∘ g) v denest-tab-!! f g v = begin ( tabulate (λ i → f (tabulate (λ j → g (v !! j)) !! i)) ≡⟨ tabulate-∘ f (λ i → tabulate (λ j → g (v !! j)) !! i) ⟩ mapV f (tabulate (λ i → tabulate (λ j → g (v !! j)) !! i) ) ≡⟨ cong (mapV f) (tabulate∘lookup (tabulate (λ j → g (v !! j)))) ⟩ mapV f (tabulate (λ j → g (v !! j))) ≡⟨ cong (mapV f) (tabulate-∘ g (flip lookup v)) ⟩ mapV f (mapV g (tabulate (flip lookup v))) ≡⟨ sym (map-∘ f g _) ⟩ mapV (f ∘ g) (tabulate (flip lookup v)) ≡⟨ cong (mapV (f ∘ g)) (tabulate∘lookup v) ⟩ mapV (f ∘ g) v ∎) where open ≡-Reasoning tab++[]≡tab∘̂unite+ : ∀ {m} {A : Set} (f : Fin m → A) (eq : m + 0 ≡ m) → tabulate f ++V [] ≡ tabulate (λ j → f (subst Fin eq j)) tab++[]≡tab∘̂unite+ {zero} f eq = refl tab++[]≡tab∘̂unite+ {suc m} f eq = cong₂ _∷_ (cong f pf₁) pf₂ where pf₁ : zero ≡ subst Fin eq zero pf₁ = toℕ-injective (sym (toℕ-invariance zero eq)) pf₃ : ∀ j → suc (subst Fin (+-right-identity m) j) ≡ subst Fin eq (suc j) pf₃ j = toℕ-injective (trans (cong suc (toℕ-invariance j (+-right-identity m))) (sym (toℕ-invariance (suc j) eq))) pf₂ : tabulate (f ∘ suc) ++V [] ≡ tabulate (λ j → f (subst Fin eq (suc j))) pf₂ = trans (tab++[]≡tab∘̂unite+ (f ∘ suc) (+-right-identity m)) (finext (λ j → cong f (pf₃ j))) -- Move to its own spot later merge-[,] : {A B C D E : Set} → {h : A → C} → {i : B → D} → {f : C → E} → {g : D → E} → (x : A ⊎ B) → [ f , g ]′ ( map⊎ h i x ) ≡ [ (f ∘ h) , (g ∘ i) ]′ x merge-[,] (inj₁ x) = refl merge-[,] (inj₂ y) = refl
{ "alphanum_fraction": 0.5107345721, "avg_line_length": 43.0995850622, "ext": "agda", "hexsha": "d17b1f0b66b9479fa486cb5f7b5261afc2461209", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_line_length": 98, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/VectorLemmas.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 4155, "size": 10387 }
import Lvl open import Type module Structure.Logic.Constructive.BoundedPredicate {ℓₗ} {Formula : Type{ℓₗ}} {ℓₘₗ} (Proof : Formula → Type{ℓₘₗ}) {ℓₚ} {Predicate : Type{ℓₚ}} {ℓₒ} {Domain : Type{ℓₒ}} (_$_ : Predicate → (x : Domain) → ∀{B : Domain → Formula} → Proof(B(x)) → Formula) where import Logic.Predicate as Meta open import Type.Dependent using (Σ) open import Type.Properties.Inhabited using (◊) import Structure.Logic.Constructive.Propositional as Propositional open import Syntax.Function private variable P : Predicate private variable X Y Q : Formula private variable x y z : Domain private variable B : Domain → Formula -- Rules of universal quantification (for all). record BoundedUniversal(∀ₗ : (Domain → Formula) → Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where field intro : (∀{x} → (bx : Proof(B(x))) → Proof((P $ x) {B} bx)) → Proof(∀ₗ B P) elim : Proof(∀ₗ B P) → ∀{x} → (bx : Proof(B(x))) → Proof((P $ x) {B} bx) ∀ₗ = \ ⦃(Meta.[∃]-intro ▫) : Meta.∃(BoundedUniversal)⦄ → ▫ module ∀ₛ {▫} ⦃ p ⦄ = BoundedUniversal {▫} p -- Rules of existential quantification (exists). record BoundedExistential(∃ : (Domain → Formula) → Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where field intro : (bx : Proof(B(x))) → Proof((P $ x) {B} bx) → Proof(∃ B P) elim : (∀{x} → (bx : Proof(B(x))) → Proof((P $ x) {B} bx) → Proof(Q)) → (Proof(∃ B P) → Proof(Q)) ∃ = \ ⦃(Meta.[∃]-intro ▫) : Meta.∃(BoundedExistential)⦄ → ▫ module ∃ₛ {▫} ⦃ p ⦄ = BoundedExistential {▫} p record BoundedExistentialWitness(∃ : (Domain → Formula) → Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where field witness : Proof(∃ B P) → Domain bound : (p : Proof(∃ B P)) → Proof(B(witness p)) proof : (p : Proof(∃ B P)) → Proof((P $ witness p) {B} (bound p)) record Logic : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where field ⦃ propositional ⦄ : Propositional.Logic(Proof) ⦃ universal ⦄ : Meta.∃(BoundedUniversal) ⦃ existential ⦄ : Meta.∃(BoundedExistential)
{ "alphanum_fraction": 0.6299955097, "avg_line_length": 44.54, "ext": "agda", "hexsha": "d52bfe452c2c43da33590a7144f63314a95962a9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Logic/Constructive/BoundedPredicate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Logic/Constructive/BoundedPredicate.agda", "max_line_length": 163, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Logic/Constructive/BoundedPredicate.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": 879, "size": 2227 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module groups.Pointed where infix 60 ⊙[_,_]ᴳˢ ⊙[_,_]ᴳ record ⊙GroupStructure {i : ULevel} (GEl : Type i) : Type (lsucc i) where constructor ⊙[_,_]ᴳˢ field de⊙ᴳˢ : GroupStructure GEl ptᴳˢ : GEl open GroupStructure de⊙ᴳˢ public open ⊙GroupStructure using (de⊙ᴳˢ; ptᴳˢ) public record ⊙Group (i : ULevel) : Type (lsucc i) where constructor ⊙[_,_]ᴳ field de⊙ᴳ : Group i ptᴳ : Group.El de⊙ᴳ open Group de⊙ᴳ public ⊙exp = Group.exp de⊙ᴳ ptᴳ open ⊙Group using (de⊙ᴳ; ptᴳ) public ⊙Group₀ = ⊙Group lzero infix 0 _⊙→ᴳ_ _⊙→ᴳ_ : ∀ {i j} → ⊙Group i → ⊙Group j → Type (lmax i j) ⊙G ⊙→ᴳ ⊙H = Σ (de⊙ᴳ ⊙G →ᴳ de⊙ᴳ ⊙H) (λ φ → GroupHom.f φ (ptᴳ ⊙G) == ptᴳ ⊙H) infix 30 _⊙≃ᴳ_ _⊙≃ᴳ_ : ∀ {i j} → ⊙Group i → ⊙Group j → Type (lmax i j) ⊙G ⊙≃ᴳ ⊙H = Σ (de⊙ᴳ ⊙G ≃ᴳ de⊙ᴳ ⊙H) (λ φ → GroupIso.f φ (ptᴳ ⊙G) == ptᴳ ⊙H) infixl 120 _⊙⁻¹ᴳ _⊙⁻¹ᴳ : ∀ {i j} {⊙G : ⊙Group i} {⊙H : ⊙Group j} → ⊙G ⊙≃ᴳ ⊙H → ⊙H ⊙≃ᴳ ⊙G _⊙⁻¹ᴳ (iso , iic) = iso ⁻¹ᴳ , ! (equiv-adj (GroupIso.f-equiv iso) iic) ⊙exp-hom : ∀ {i} (⊙G : ⊙Group i) → ⊙[ ℤ-group , 1 ]ᴳ ⊙→ᴳ ⊙G ⊙exp-hom ⊙[ G , pt ]ᴳ = exp-hom G pt , idp is-struct-infinite-cyclic : ∀ {i} {El : Type i} → ⊙GroupStructure El → Type i is-struct-infinite-cyclic ⊙[ G , g ]ᴳˢ = is-equiv (GroupStructure.exp G g) is-infinite-cyclic : ∀ {i} → ⊙Group i → Type i is-infinite-cyclic ⊙[ G , g ]ᴳ = is-struct-infinite-cyclic ⊙[ Group.group-struct G , g ]ᴳˢ isomorphism-preserves-infinite-cyclic : ∀ {i j} → {⊙G : ⊙Group i} {⊙H : ⊙Group j} → ⊙G ⊙≃ᴳ ⊙H → is-infinite-cyclic ⊙G → is-infinite-cyclic ⊙H isomorphism-preserves-infinite-cyclic {⊙G = ⊙[ G , g ]ᴳ} {⊙H = ⊙[ H , h ]ᴳ} (iso , pres-pt) ⊙G-iic = is-eq _ (is-equiv.g ⊙G-iic ∘ GroupIso.g iso) to-from from-to where abstract lemma : Group.exp H h ∼ GroupIso.f iso ∘ Group.exp G g lemma i = ! $ GroupIso.f iso (Group.exp G g i) =⟨ GroupIso.pres-exp iso g i ⟩ Group.exp H (GroupIso.f iso g) i =⟨ ap (λ x → Group.exp H x i) pres-pt ⟩ Group.exp H h i =∎ to-from : ∀ x → Group.exp H h (is-equiv.g ⊙G-iic (GroupIso.g iso x)) == x to-from x = Group.exp H h (is-equiv.g ⊙G-iic (GroupIso.g iso x)) =⟨ lemma (is-equiv.g ⊙G-iic (GroupIso.g iso x)) ⟩ GroupIso.f iso (Group.exp G g (is-equiv.g ⊙G-iic (GroupIso.g iso x))) =⟨ ap (GroupIso.f iso) (is-equiv.f-g ⊙G-iic (GroupIso.g iso x)) ⟩ GroupIso.f iso (GroupIso.g iso x) =⟨ GroupIso.f-g iso x ⟩ x =∎ from-to : ∀ i → is-equiv.g ⊙G-iic (GroupIso.g iso (Group.exp H h i)) == i from-to i = is-equiv.g ⊙G-iic (GroupIso.g iso (Group.exp H h i)) =⟨ ap (is-equiv.g ⊙G-iic ∘ GroupIso.g iso) (lemma i) ⟩ is-equiv.g ⊙G-iic (GroupIso.g iso (GroupIso.f iso (Group.exp G g i))) =⟨ ap (is-equiv.g ⊙G-iic) (GroupIso.g-f iso (Group.exp G g i)) ⟩ is-equiv.g ⊙G-iic (Group.exp G g i) =⟨ is-equiv.g-f ⊙G-iic i ⟩ i =∎ isomorphism-preserves'-infinite-cyclic : ∀ {i j} → {⊙G : ⊙Group i} {⊙H : ⊙Group j} → ⊙G ⊙≃ᴳ ⊙H → is-infinite-cyclic ⊙H → is-infinite-cyclic ⊙G isomorphism-preserves'-infinite-cyclic iso iic = isomorphism-preserves-infinite-cyclic (iso ⊙⁻¹ᴳ) iic
{ "alphanum_fraction": 0.5594874924, "avg_line_length": 33.793814433, "ext": "agda", "hexsha": "f50d370359ff5499672146cf664cad77018d0bd7", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/groups/Pointed.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/groups/Pointed.agda", "max_line_length": 79, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/groups/Pointed.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": 1553, "size": 3278 }
data Nat : Set where nohana : Nat kibou : Nat -> Nat one = kibou nohana two = kibou one
{ "alphanum_fraction": 0.6382978723, "avg_line_length": 13.4285714286, "ext": "agda", "hexsha": "5102279ff6d82e4151e4c9a750766f8675b5faa9", "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/LaTeXAndHTML/succeed/HighlightOccurrences.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/LaTeXAndHTML/succeed/HighlightOccurrences.agda", "max_line_length": 21, "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/LaTeXAndHTML/succeed/HighlightOccurrences.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 37, "size": 94 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.EilenbergMacLane1 open import homotopy.EilenbergMacLane {- Given sequence of groups (Gₙ : n ≥ 1) such that Gₙ is abelian for n > 1, - we can construct a space X such that πₙ(X) == Gₙ. - (We can also make π₀(X) whatever we want but this isn't done here.) -} module homotopy.SpaceFromGroups where {- From a sequence of spaces (Fₙ) such that Fₙ is n-connected and - n+1-truncated, construct a space X such that πₙ₊₁(X) == πₙ₊₁(Fₙ) -} module SpaceFromEMs {i} (F : ℕ → Ptd i) {{pF : {n : ℕ} → has-level ⟨ S n ⟩ (de⊙ (F n))}} {{cF : (n : ℕ) → is-connected ⟨ n ⟩ (de⊙ (F n))}} where X : Ptd i X = ⊙FinTuples F πS-X : (n : ℕ) → πS n X ≃ᴳ πS n (F n) πS-X n = πS n (⊙FinTuples F) ≃ᴳ⟨ prefix-lemma n O F ⟩ πS n (⊙FinTuples (λ k → F (n + k))) ≃ᴳ⟨ πS-emap n (⊙fin-tuples-cons (λ k → F (n + k))) ⁻¹ᴳ ⟩ πS n (F (n + O) ⊙× ⊙FinTuples (λ k → F (n + S k))) ≃ᴳ⟨ πS-× n (F (n + O)) (⊙FinTuples (λ k → F (n + S k))) ⟩ πS n (F (n + O)) ×ᴳ πS n (⊙FinTuples (λ k → F (n + S k))) ≃ᴳ⟨ ×ᴳ-emap (idiso (πS n (F (n + O))) ) (contr-iso-0ᴳ _ $ connected-at-level-is-contr {{⟨⟩}} {{Trunc-preserves-conn {n = 0} $ Ω^-conn _ (S n) _ $ transport (λ k → is-connected k (FinTuples (λ k → F (n + S k)))) (+2+-comm 0 ⟨ n ⟩₋₁) (ncolim-conn _ _ {{connected-lemma _ _ (λ k → transport (λ s → is-connected ⟨ s ⟩ (de⊙ (F (n + S k)))) (+-βr n k ∙ +-comm (S n) k) (cF (n + S k)))}})}}) ⟩ πS n (F (n + O)) ×ᴳ 0ᴳ ≃ᴳ⟨ ×ᴳ-unit-r _ ⟩ πS n (F (n + O)) ≃ᴳ⟨ transportᴳ-iso (λ k → πS n (F k)) (+-unit-r n) ⟩ πS n (F n) ≃ᴳ∎ where {- In computing πₙ₊₁, spaces before Fₙ are ignored because of their - truncation level -} prefix-lemma : (n : ℕ) (m : ℕ) (F : ℕ → Ptd i) {{_ : {k : ℕ} → has-level ⟨ S m + k ⟩ (de⊙ (F k))}} → πS (m + n) (⊙FinTuples F) ≃ᴳ πS (m + n) (⊙FinTuples (λ k → F (n + k))) prefix-lemma O m F = idiso _ prefix-lemma (S n) m F = πS (m + S n) (⊙FinTuples F) ≃ᴳ⟨ πS-emap (m + S n) (⊙fin-tuples-cons F) ⁻¹ᴳ ⟩ πS (m + S n) (F O ⊙× ⊙FinTuples (F ∘ S)) ≃ᴳ⟨ πS-× (m + S n) (F O) (⊙FinTuples (F ∘ S)) ⟩ πS (m + S n) (F O) ×ᴳ πS (m + S n) (⊙FinTuples (F ∘ S)) ≃ᴳ⟨ ×ᴳ-emap lemma₁ lemma₂ ⟩ 0ᴳ ×ᴳ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k)))) ≃ᴳ⟨ ×ᴳ-unit-l _ ⟩ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k)))) ≃ᴳ∎ where {- ignore first space -} lemma₁ : πS (m + S n) (F O) ≃ᴳ 0ᴳ lemma₁ = πS->level-econv (m + S n) _ (F O) (⟨⟩-monotone-< (<-ap-S (<-+-l m (O<S n)))) {- ignore the rest by recursive call -} lemma₂ : πS (m + S n) (⊙FinTuples (F ∘ S)) ≃ᴳ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k)))) lemma₂ = πS (m + S n) (⊙FinTuples (F ∘ S)) ≃ᴳ⟨ transportᴳ-iso (λ s → πS s (⊙FinTuples (F ∘ S))) (+-βr m n) ⟩ πS (S m + n) (⊙FinTuples (F ∘ S)) ≃ᴳ⟨ prefix-lemma n (S m) (F ∘ S) {{λ {k} → transport (λ s → has-level ⟨ s ⟩ (de⊙ (F (S k)))) (+-βr (S m) k) ⟨⟩}} ⟩ πS (S m + n) (⊙FinTuples (λ k → F (S (n + k)))) ≃ᴳ⟨ transportᴳ-iso (λ s → πS s (⊙FinTuples (λ k → F (S (n + k))))) (+-βr m n) ⁻¹ᴳ ⟩ πS (m + S n) (⊙FinTuples (λ k → F (S (n + k)))) ≃ᴳ∎ connected-lemma : (m : ℕ) (F : ℕ → Ptd i) (cA' : (n : ℕ) → is-connected ⟨ n + m ⟩ (de⊙ (F n))) (n : ℕ) → is-connected ⟨ m ⟩ (FinTuplesType F n) connected-lemma m F cA' O = Trunc-preserves-level ⟨ m ⟩ ⟨⟩ connected-lemma m F cA' (S n) = ×-conn (cA' O) (connected-lemma m (F ∘ S) (λ n → connected-≤T (⟨⟩-monotone-≤ (inr ltS)) {{cA' (S n)}}) n) {- Given sequence of groups (Gₙ : n ≥ 1) such that Gₙ is abelian for n > 1, - construct a space X such that πₙ(X) == Gₙ. -} module SpaceFromGroups {i} (G : ℕ → Group i) (abG-S : (n : ℕ) → is-abelian (G (S n))) where private F : ℕ → Ptd i F O = ⊙EM₁ (G O) F (S n) = EMExplicit.⊙EM (G (S n) , abG-S n) (S (S n)) instance pF : (n : ℕ) → has-level ⟨ S n ⟩ (de⊙ (F n)) pF O = EM₁-level {G = G O} pF (S n) = EMExplicit.EM-level (G (S n) , abG-S n) (S (S n)) cF : (n : ℕ) → is-connected ⟨ n ⟩ (de⊙ (F n)) cF O = EM₁-conn {G = G O} cF (S n) = EMExplicit.EM-conn (G (S n) , abG-S n) (S n) module M = SpaceFromEMs F X = M.X πS-X : (n : ℕ) → πS n X ≃ᴳ G n πS-X O = π₁-EM₁ (G O) ∘eᴳ M.πS-X O πS-X (S n) = EMExplicit.πS-diag (G (S n) , abG-S n) (S n) ∘eᴳ M.πS-X (S n)
{ "alphanum_fraction": 0.4525807805, "avg_line_length": 37.5275590551, "ext": "agda", "hexsha": "be935e0a785739ab35bf72457ea14f4374fd54e6", "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/SpaceFromGroups.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/SpaceFromGroups.agda", "max_line_length": 93, "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/SpaceFromGroups.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2223, "size": 4766 }
{-# OPTIONS --rewriting #-} module Examples.OpSem where open import Luau.OpSem using (_⊢_⟶ᴱ_⊣_; _⊢_⟶ᴮ_⊣_; subst) open import Luau.Syntax using (Block; var; val; nil; local_←_; _∙_; done; return; block_is_end) open import Luau.Heap using (∅) ex1 : ∅ ⊢ (local (var "x") ← val nil ∙ return (var "x") ∙ done) ⟶ᴮ (return (val nil) ∙ done) ⊣ ∅ ex1 = subst nil
{ "alphanum_fraction": 0.649859944, "avg_line_length": 32.4545454545, "ext": "agda", "hexsha": "c3f74ec1dbc57b481714d11e21d37dd15fb0a18f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Examples/OpSem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Examples/OpSem.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Examples/OpSem.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 147, "size": 357 }
module BasicIS4.Metatheory.DyadicGentzenSpinalNormalForm-HereditarySubstitution where open import BasicIS4.Syntax.DyadicGentzenSpinalNormalForm public -- Hereditary substitution and reduction. mutual [_≔_]ⁿᶠ_ : ∀ {A B Γ Δ} → (i : A ∈ Γ) → Γ ∖ i ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᶠ B → Γ ∖ i ⁏ Δ ⊢ⁿᶠ B [ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ j xs y) with i ≟∈ j [ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ .i xs y) | same = reduce s ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ᵗᵖ y) [ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ ._ xs y) | diff j = neⁿᶠ (spⁿᵉ j ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ᵗᵖ y)) [ i ≔ s ]ⁿᶠ neⁿᶠ (mspⁿᵉ j xs y) = neⁿᶠ (mspⁿᵉ j ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ᵗᵖ y)) [ i ≔ s ]ⁿᶠ lamⁿᶠ t = lamⁿᶠ ([ pop i ≔ mono⊢ⁿᶠ weak⊆ s ]ⁿᶠ t) [ i ≔ s ]ⁿᶠ boxⁿᶠ t = boxⁿᶠ t [ i ≔ s ]ⁿᶠ pairⁿᶠ t u = pairⁿᶠ ([ i ≔ s ]ⁿᶠ t) ([ i ≔ s ]ⁿᶠ u) [ i ≔ s ]ⁿᶠ unitⁿᶠ = unitⁿᶠ [_≔_]ˢᵖ_ : ∀ {A B C Γ Δ} → (i : A ∈ Γ) → Γ ∖ i ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ˢᵖ B ⦙ C → Γ ∖ i ⁏ Δ ⊢ˢᵖ B ⦙ C [ i ≔ s ]ˢᵖ nilˢᵖ = nilˢᵖ [ i ≔ s ]ˢᵖ appˢᵖ xs u = appˢᵖ ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ⁿᶠ u) [ i ≔ s ]ˢᵖ fstˢᵖ xs = fstˢᵖ ([ i ≔ s ]ˢᵖ xs) [ i ≔ s ]ˢᵖ sndˢᵖ xs = sndˢᵖ ([ i ≔ s ]ˢᵖ xs) [_≔_]ᵗᵖ_ : ∀ {A B C Γ Δ} → (i : A ∈ Γ) → Γ ∖ i ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ᵗᵖ B ⦙ C → Γ ∖ i ⁏ Δ ⊢ᵗᵖ B ⦙ C [ i ≔ s ]ᵗᵖ nilᵗᵖ = nilᵗᵖ [ i ≔ s ]ᵗᵖ unboxᵗᵖ u = unboxᵗᵖ u′ where u′ = [ i ≔ mmono⊢ⁿᶠ weak⊆ s ]ⁿᶠ u m[_≔_]ⁿᶠ_ : ∀ {A B Γ Δ} → (i : A ∈ Δ) → ∅ ⁏ Δ ∖ i ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᶠ B → Γ ⁏ Δ ∖ i ⊢ⁿᶠ B m[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ j xs y) = neⁿᶠ (spⁿᵉ j (m[ i ≔ s ]ˢᵖ xs) (m[ i ≔ s ]ᵗᵖ y)) m[ i ≔ s ]ⁿᶠ neⁿᶠ (mspⁿᵉ j xs y) with i ≟∈ j m[ i ≔ s ]ⁿᶠ neⁿᶠ (mspⁿᵉ .i xs y) | same = reduce (mono⊢ⁿᶠ bot⊆ s) (m[ i ≔ s ]ˢᵖ xs) (m[ i ≔ s ]ᵗᵖ y) m[ i ≔ s ]ⁿᶠ neⁿᶠ (mspⁿᵉ ._ xs y) | diff j = neⁿᶠ (mspⁿᵉ j (m[ i ≔ s ]ˢᵖ xs) (m[ i ≔ s ]ᵗᵖ y)) m[ i ≔ s ]ⁿᶠ lamⁿᶠ t = lamⁿᶠ (m[ i ≔ s ]ⁿᶠ t) m[ i ≔ s ]ⁿᶠ boxⁿᶠ t = boxⁿᶠ (m[ i ≔ s ]ⁿᶠ t) m[ i ≔ s ]ⁿᶠ pairⁿᶠ t u = pairⁿᶠ (m[ i ≔ s ]ⁿᶠ t) (m[ i ≔ s ]ⁿᶠ u) m[ i ≔ s ]ⁿᶠ unitⁿᶠ = unitⁿᶠ m[_≔_]ˢᵖ_ : ∀ {A B C Γ Δ} → (i : A ∈ Δ) → ∅ ⁏ Δ ∖ i ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ˢᵖ B ⦙ C → Γ ⁏ Δ ∖ i ⊢ˢᵖ B ⦙ C m[ i ≔ s ]ˢᵖ nilˢᵖ = nilˢᵖ m[ i ≔ s ]ˢᵖ appˢᵖ xs u = appˢᵖ (m[ i ≔ s ]ˢᵖ xs) (m[ i ≔ s ]ⁿᶠ u) m[ i ≔ s ]ˢᵖ fstˢᵖ xs = fstˢᵖ (m[ i ≔ s ]ˢᵖ xs) m[ i ≔ s ]ˢᵖ sndˢᵖ xs = sndˢᵖ (m[ i ≔ s ]ˢᵖ xs) m[_≔_]ᵗᵖ_ : ∀ {A B C Γ Δ} → (i : A ∈ Δ) → ∅ ⁏ Δ ∖ i ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ᵗᵖ B ⦙ C → Γ ⁏ Δ ∖ i ⊢ᵗᵖ B ⦙ C m[ i ≔ s ]ᵗᵖ nilᵗᵖ = nilᵗᵖ m[ i ≔ s ]ᵗᵖ unboxᵗᵖ u = unboxᵗᵖ u′ where u′ = m[ pop i ≔ mmono⊢ⁿᶠ weak⊆ s ]ⁿᶠ u reduce : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ˢᵖ A ⦙ B → Γ ⁏ Δ ⊢ᵗᵖ B ⦙ C → {{_ : Tyⁿᵉ C}} → Γ ⁏ Δ ⊢ⁿᶠ C reduce t nilˢᵖ nilᵗᵖ = t reduce (neⁿᶠ (spⁿᵉ i xs nilᵗᵖ)) nilˢᵖ y = neⁿᶠ (spⁿᵉ i xs y) reduce (neⁿᶠ (spⁿᵉ i xs (unboxᵗᵖ u))) nilˢᵖ y = neⁿᶠ (spⁿᵉ i xs (unboxᵗᵖ u′)) where u′ = reduce u nilˢᵖ (mmono⊢ᵗᵖ weak⊆ y) reduce (neⁿᶠ (mspⁿᵉ i xs nilᵗᵖ)) nilˢᵖ y = neⁿᶠ (mspⁿᵉ i xs y) reduce (neⁿᶠ (mspⁿᵉ i xs (unboxᵗᵖ u))) nilˢᵖ y = neⁿᶠ (mspⁿᵉ i xs (unboxᵗᵖ u′)) where u′ = reduce u nilˢᵖ (mmono⊢ᵗᵖ weak⊆ y) reduce (neⁿᶠ t {{()}}) (appˢᵖ xs u) y reduce (neⁿᶠ t {{()}}) (fstˢᵖ xs) y reduce (neⁿᶠ t {{()}}) (sndˢᵖ xs) y reduce (lamⁿᶠ t) (appˢᵖ xs u) y = reduce ([ top ≔ u ]ⁿᶠ t) xs y reduce (boxⁿᶠ t) nilˢᵖ (unboxᵗᵖ u) = m[ top ≔ t ]ⁿᶠ u reduce (pairⁿᶠ t u) (fstˢᵖ xs) y = reduce t xs y reduce (pairⁿᶠ t u) (sndˢᵖ xs) y = reduce u xs y -- Reduction-based normal forms. appⁿᶠ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A ▻ B → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᶠ B appⁿᶠ (neⁿᶠ t {{()}}) appⁿᶠ (lamⁿᶠ t) u = [ top ≔ u ]ⁿᶠ t fstⁿᶠ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A ∧ B → Γ ⁏ Δ ⊢ⁿᶠ A fstⁿᶠ (neⁿᶠ t {{()}}) fstⁿᶠ (pairⁿᶠ t u) = t sndⁿᶠ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A ∧ B → Γ ⁏ Δ ⊢ⁿᶠ B sndⁿᶠ (neⁿᶠ t {{()}}) sndⁿᶠ (pairⁿᶠ t u) = u -- Useful equipment for deriving neutrals. ≪appˢᵖ : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ˢᵖ C ⦙ A ▻ B → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ˢᵖ C ⦙ B ≪appˢᵖ nilˢᵖ t = appˢᵖ nilˢᵖ t ≪appˢᵖ (appˢᵖ xs u) t = appˢᵖ (≪appˢᵖ xs t) u ≪appˢᵖ (fstˢᵖ xs) t = fstˢᵖ (≪appˢᵖ xs t) ≪appˢᵖ (sndˢᵖ xs) t = sndˢᵖ (≪appˢᵖ xs t) ≪fstˢᵖ : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⁏ Δ ⊢ˢᵖ C ⦙ A ≪fstˢᵖ nilˢᵖ = fstˢᵖ nilˢᵖ ≪fstˢᵖ (appˢᵖ xs u) = appˢᵖ (≪fstˢᵖ xs) u ≪fstˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪fstˢᵖ xs) ≪fstˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪fstˢᵖ xs) ≪sndˢᵖ : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⁏ Δ ⊢ˢᵖ C ⦙ B ≪sndˢᵖ nilˢᵖ = sndˢᵖ nilˢᵖ ≪sndˢᵖ (appˢᵖ xs u) = appˢᵖ (≪sndˢᵖ xs) u ≪sndˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪sndˢᵖ xs) ≪sndˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪sndˢᵖ xs) -- Derived neutrals. varⁿᵉ : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊢ⁿᵉ A varⁿᵉ i = spⁿᵉ i nilˢᵖ nilᵗᵖ appⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ▻ B → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᵉ B appⁿᵉ (spⁿᵉ i xs nilᵗᵖ) t = spⁿᵉ i (≪appˢᵖ xs t) nilᵗᵖ appⁿᵉ (spⁿᵉ i xs (unboxᵗᵖ u)) t = spⁿᵉ i xs (unboxᵗᵖ u′) where u′ = appⁿᶠ u (mmono⊢ⁿᶠ weak⊆ t) appⁿᵉ (mspⁿᵉ i xs nilᵗᵖ) t = mspⁿᵉ i (≪appˢᵖ xs t) nilᵗᵖ appⁿᵉ (mspⁿᵉ i xs (unboxᵗᵖ u)) t = mspⁿᵉ i xs (unboxᵗᵖ u′) where u′ = appⁿᶠ u (mmono⊢ⁿᶠ weak⊆ t) mvarⁿᵉ : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ ⊢ⁿᵉ A mvarⁿᵉ i = mspⁿᵉ i nilˢᵖ nilᵗᵖ fstⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ∧ B → Γ ⁏ Δ ⊢ⁿᵉ A fstⁿᵉ (spⁿᵉ i xs nilᵗᵖ) = spⁿᵉ i (≪fstˢᵖ xs) nilᵗᵖ fstⁿᵉ (spⁿᵉ i xs (unboxᵗᵖ u)) = spⁿᵉ i xs (unboxᵗᵖ (fstⁿᶠ u)) fstⁿᵉ (mspⁿᵉ i xs nilᵗᵖ) = mspⁿᵉ i (≪fstˢᵖ xs) nilᵗᵖ fstⁿᵉ (mspⁿᵉ i xs (unboxᵗᵖ u)) = mspⁿᵉ i xs (unboxᵗᵖ (fstⁿᶠ u)) sndⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ∧ B → Γ ⁏ Δ ⊢ⁿᵉ B sndⁿᵉ (spⁿᵉ i xs nilᵗᵖ) = spⁿᵉ i (≪sndˢᵖ xs) nilᵗᵖ sndⁿᵉ (spⁿᵉ i xs (unboxᵗᵖ u)) = spⁿᵉ i xs (unboxᵗᵖ (sndⁿᶠ u)) sndⁿᵉ (mspⁿᵉ i xs nilᵗᵖ) = mspⁿᵉ i (≪sndˢᵖ xs) nilᵗᵖ sndⁿᵉ (mspⁿᵉ i xs (unboxᵗᵖ u)) = mspⁿᵉ i xs (unboxᵗᵖ (sndⁿᶠ u)) -- Iterated expansion. expand : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A → Γ ⁏ Δ ⊢ⁿᶠ A expand {α P} t = neⁿᶠ t {{α P}} expand {A ▻ B} t = lamⁿᶠ (expand (appⁿᵉ (mono⊢ⁿᵉ weak⊆ t) (expand (varⁿᵉ top)))) expand {□ A} t = neⁿᶠ t {{□ A}} expand {A ∧ B} t = pairⁿᶠ (expand (fstⁿᵉ t)) (expand (sndⁿᵉ t)) expand {⊤} t = unitⁿᶠ -- Expansion-based normal forms. varⁿᶠ : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊢ⁿᶠ A varⁿᶠ i = expand (varⁿᵉ i) mvarⁿᶠ : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ ⊢ⁿᶠ A mvarⁿᶠ i = expand (mvarⁿᵉ i) mutual unboxⁿᶠ : ∀ {A C Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ □ A → Γ ⁏ Δ , A ⊢ⁿᶠ C → Γ ⁏ Δ ⊢ⁿᶠ C unboxⁿᶠ (neⁿᶠ t) u = expand (unboxⁿᵉ t u) unboxⁿᶠ (boxⁿᶠ t) u = m[ top ≔ t ]ⁿᶠ u unboxⁿᵉ : ∀ {A C Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ □ A → Γ ⁏ Δ , A ⊢ⁿᶠ C → Γ ⁏ Δ ⊢ⁿᵉ C unboxⁿᵉ (spⁿᵉ i xs nilᵗᵖ) u = spⁿᵉ i xs (unboxᵗᵖ u) unboxⁿᵉ (spⁿᵉ i xs (unboxᵗᵖ t)) u = spⁿᵉ i xs (unboxᵗᵖ u′) where u′ = unboxⁿᶠ t (mmono⊢ⁿᶠ (keep (weak⊆)) u) unboxⁿᵉ (mspⁿᵉ i xs nilᵗᵖ) u = mspⁿᵉ i xs (unboxᵗᵖ u) unboxⁿᵉ (mspⁿᵉ i xs (unboxᵗᵖ t)) u = mspⁿᵉ i xs (unboxᵗᵖ u′) where u′ = unboxⁿᶠ t (mmono⊢ⁿᶠ (keep (weak⊆)) u) -- Translation from terms to normal forms. tm→nf : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ⁿᶠ A tm→nf (var i) = varⁿᶠ i tm→nf (lam t) = lamⁿᶠ (tm→nf t) tm→nf (app t u) = appⁿᶠ (tm→nf t) (tm→nf u) tm→nf (mvar i) = mvarⁿᶠ i tm→nf (box t) = boxⁿᶠ (tm→nf t) tm→nf (unbox t u) = unboxⁿᶠ (tm→nf t) (tm→nf u) tm→nf (pair t u) = pairⁿᶠ (tm→nf t) (tm→nf u) tm→nf (fst t) = fstⁿᶠ (tm→nf t) tm→nf (snd t) = sndⁿᶠ (tm→nf t) tm→nf unit = unitⁿᶠ -- Normalisation by hereditary substitution. norm : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A norm = nf→tm ∘ tm→nf
{ "alphanum_fraction": 0.4925706772, "avg_line_length": 41.3315217391, "ext": "agda", "hexsha": "ff297fe4e6e360e587be81a727347ecf9a308b80", "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": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Metatheory/DyadicGentzenSpinalNormalForm-HereditarySubstitution.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Metatheory/DyadicGentzenSpinalNormalForm-HereditarySubstitution.agda", "max_line_length": 105, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Metatheory/DyadicGentzenSpinalNormalForm-HereditarySubstitution.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 5446, "size": 7605 }
{-# OPTIONS --without-K #-} open import Base open import Algebra.Groups {- The definition of G-sets. Thanks to Daniel Grayson. -} module Algebra.GroupSets {i} (grp : group i) where private module G = group grp -- The right group action with respect to the group [grp]. -- [Y] should be some set, but that condition is not needed -- in the definition. record action (Y : Set i) : Set i where constructor act[_,_,_] field _∙_ : Y → G.carrier → Y right-unit : ∀ y → y ∙ G.e ≡ y assoc : ∀ y p₁ p₂ → (y ∙ p₁) ∙ p₂ ≡ y ∙ (p₁ G.∙ p₂) {- action-eq : ∀ {Y} ⦃ _ : is-set Y ⦄ {act₁ act₂ : action Y} → action._∙_ act₁ ≡ action._∙_ act₂ → act₁ ≡ act₂ action-eq ∙≡ = -} -- The definition of a G-set. A set [carrier] equipped with -- a right group action with respect to [grp]. record gset : Set (suc i) where constructor gset[_,_,_] field carrier : Set i act : action carrier set : is-set carrier open action act public -- A convenient tool to compare two G-sets. Many data are -- just props and this function do the coversion for them -- for you. You only need to show the non-trivial parts. gset-eq : ∀ {gs₁ gs₂ : gset} (carrier≡ : gset.carrier gs₁ ≡ gset.carrier gs₂) → (∙≡ : transport (λ Y → Y → G.carrier → Y) carrier≡ (action._∙_ (gset.act gs₁)) ≡ action._∙_ (gset.act gs₂)) → gs₁ ≡ gs₂ gset-eq {gset[ Y , act[ ∙ , unit₁ , assoc₁ ] , set₁ ]} {gset[ ._ , act[ ._ , unit₂ , assoc₂ ] , set₂ ]} refl refl = gset[ Y , act[ ∙ , unit₁ , assoc₁ ] , set₁ ] ≡⟨ ap (λ unit → gset[ Y , act[ ∙ , unit , assoc₁ ] , set₁ ]) $ prop-has-all-paths (Π-is-prop λ _ → set₁ _ _) _ _ ⟩ gset[ Y , act[ ∙ , unit₂ , assoc₁ ] , set₁ ] ≡⟨ ap (λ assoc → gset[ Y , act[ ∙ , unit₂ , assoc ] , set₁ ]) $ prop-has-all-paths (Π-is-prop λ _ → Π-is-prop λ _ → Π-is-prop λ _ → set₁ _ _) _ _ ⟩ gset[ Y , act[ ∙ , unit₂ , assoc₂ ] , set₁ ] ≡⟨ ap (λ set → gset[ Y , act[ ∙ , unit₂ , assoc₂ ] , set ]) $ prop-has-all-paths is-set-is-prop _ _ ⟩∎ gset[ Y , act[ ∙ , unit₂ , assoc₂ ] , set₂ ] ∎
{ "alphanum_fraction": 0.5491540924, "avg_line_length": 34.7142857143, "ext": "agda", "hexsha": "61c003ac65e1d86b3e4ec561f5e259ac5b6009cf", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Algebra/GroupSets.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Algebra/GroupSets.agda", "max_line_length": 99, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Algebra/GroupSets.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": 791, "size": 2187 }
------------------------------------------------------------------------------ -- 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.GroupTheory.NoPatternMatchingOnRefl where open import GroupTheory.Base ------------------------------------------------------------------------------ -- From GroupTheory.PropertiesI -- Congruence properties -- The propositional equality is compatible with the binary operation. ·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c ·-leftCong {a} {c = c} h = subst (λ t → a · c ≡ t · c) h refl ·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c ·-rightCong {a} {b} h = subst (λ t → a · b ≡ a · t) h refl -- The propositional equality is compatible with the inverse function. ⁻¹-cong : ∀ {a b} → a ≡ b → a ⁻¹ ≡ b ⁻¹ ⁻¹-cong {a} h = subst (λ t → a ⁻¹ ≡ t ⁻¹) h refl
{ "alphanum_fraction": 0.4726415094, "avg_line_length": 35.3333333333, "ext": "agda", "hexsha": "8621f7745b4c7ac52f76072c7354449096c37ae7", "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/GroupTheory/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/GroupTheory/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/GroupTheory/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": 275, "size": 1060 }
{-# OPTIONS --rewriting #-} module Duality where open import Data.Bool open import Data.Nat hiding (compare) open import Data.Nat.Properties open import Data.Fin hiding (_+_) open import Data.Product open import Function open import Relation.Binary.PropositionalEquality hiding (Extensionality) open import Agda.Builtin.Equality.Rewrite -- variables variable n m : ℕ open import Types.Direction open import Auxiliary.Extensionality open import Auxiliary.RewriteLemmas ---------------------------------------------------------------------- -- session types coinductively import Types.COI as COI ---------------------------------------------------------------------- -- session type inductively with explicit rec import Types.IND as IND ---------------------------------------------------------------------- -- provide an embedding of IND to COI open COI open IND hiding (_≈_ ; _≈'_ ; ≈-refl ; ≈'-refl ; ≈ᵗ-refl) ind2coiT : IND.Type 0 → COI.Type ind2coiS : IND.SType 0 → COI.SType ind2coiG : IND.GType 0 → COI.STypeF COI.SType ind2coiT TUnit = TUnit ind2coiT TInt = TInt ind2coiT (TPair it it₁) = TPair (ind2coiT it) (ind2coiT it₁) ind2coiT (TChan st) = TChan (ind2coiS st) ind2coiG (transmit d t ist) = transmit d (ind2coiT t) (ind2coiS ist) ind2coiG (choice d m alt) = choice d m (ind2coiS ∘ alt) ind2coiG end = end SType.force (ind2coiS (gdd gst)) = ind2coiG gst SType.force (ind2coiS (rec gst)) = ind2coiG (st-substG gst zero (rec gst)) ---------------------------------------------------------------------- {-# TERMINATING #-} subst-weakenS : (s : IND.SType (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0) → st-substS (weaken1'S (inject₁ j) s) (suc i) s0 ≡ weaken1'S j (st-substS s i s0) subst-weakenG : (g : IND.GType (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0) → st-substG (weaken1'G (inject₁ j) g) (suc i) s0 ≡ weaken1'G j (st-substG g i s0) subst-weakenT : (t : IND.Type (suc n)) (i : Fin (suc n)) (j : Fin (suc n)) (le : Data.Fin._≤_ j i) (s0 : IND.SType 0) → st-substT (weaken1'T (inject₁ j) t) (suc i) s0 ≡ weaken1'T j (st-substT t i s0) subst-weakenS (gdd gst) i j le s0 = cong gdd (subst-weakenG gst i j le s0) subst-weakenS (rec gst) i j le s0 = cong rec (subst-weakenG gst (suc i) (suc j) (s≤s le) s0) subst-weakenS (var p x) zero zero le s0 = refl subst-weakenS {suc n} (var p x) (suc i) zero le s0 = refl subst-weakenS {suc n} (var p zero) (suc i) (suc j) le s0 = refl subst-weakenS {suc n} (var p (suc x)) (suc i) (suc j) (s≤s le) s0 rewrite (weak-weakS j zero z≤n (st-substS (var p x) i s0)) = cong (weaken1'S zero) (subst-weakenS (var p x) i j le s0) subst-weakenG (transmit d t s) i j le s0 = cong₂ (transmit d) (subst-weakenT t i j le s0) (subst-weakenS s i j le s0) subst-weakenG (choice d m alt) i j le s0 = cong (choice d m) (ext (λ m' → subst-weakenS (alt m') i j le s0 )) subst-weakenG end i j le s0 = refl subst-weakenT TUnit i j le s0 = refl subst-weakenT TInt i j le s0 = refl subst-weakenT (TPair t t₁) i j le s0 = cong₂ TPair (subst-weakenT t i j le s0) (subst-weakenT t₁ i j le s0) subst-weakenT (TChan s) i j le s0 = cong TChan (subst-weakenS s i j le s0) {-# TERMINATING #-} subst-swap-dualT : ∀ {ist} → (t : IND.Type (suc n)) (i : Fin (suc n)) → st-substT t i ist ≡ st-substT (swap-polT i t) i (IND.dualS ist) subst-swap-dualS : ∀ {ist} → (st : IND.SType (suc n)) (i : Fin (suc n)) → st-substS st i ist ≡ st-substS (swap-polS i st) i (IND.dualS ist) subst-swap-dualG : ∀ {ist} → (gst : IND.GType (suc n)) (i : Fin (suc n)) → st-substG gst i ist ≡ st-substG (swap-polG i gst) i (IND.dualS ist) subst-swap-dualT TUnit i = refl subst-swap-dualT TInt i = refl subst-swap-dualT (TPair ty ty₁) i = cong₂ TPair (subst-swap-dualT ty i) (subst-swap-dualT ty₁ i) subst-swap-dualT (TChan x) i = cong TChan (subst-swap-dualS x i) subst-swap-dualS (gdd gst) i = cong gdd (subst-swap-dualG gst i) subst-swap-dualS (rec gst) i = cong rec (subst-swap-dualG gst (suc i)) subst-swap-dualS {n} {ist} (var p zero) zero = cong (weakenS n) (dual-if-dual p ist) subst-swap-dualS {suc n} (var p zero) (suc i) = refl subst-swap-dualS {suc n} (var p (suc x)) zero = refl subst-swap-dualS {suc n}{ist} (var p (suc x)) (suc i) rewrite subst-weakenS (swap-polS i (var p x)) i zero z≤n (dualS ist) = cong (weaken1'S zero) (subst-swap-dualS ((var p x)) i) subst-swap-dualG (transmit d t s) i = cong₂ (transmit d) (subst-swap-dualT t i) (subst-swap-dualS s i) subst-swap-dualG (choice d m alt) i = cong (choice d m) (ext (λ x → subst-swap-dualS (alt x) i)) subst-swap-dualG end i = refl ---------------------------------------------------------------------- swap-i-weakenS : (i : Fin (suc n)) (s : IND.SType n) → swap-polS i (weaken1'S i s) ≡ weaken1'S i s swap-i-weakenG : (i : Fin (suc n)) (g : IND.GType n) → swap-polG i (weaken1'G i g) ≡ weaken1'G i g swap-i-weakenT : (i : Fin (suc n)) (t : IND.TType n) → swap-polT i (weaken1'T i t) ≡ weaken1'T i t swap-i-weakenS i (gdd gst) = cong gdd (swap-i-weakenG i gst) swap-i-weakenS i (rec gst) = cong rec (swap-i-weakenG (suc i) gst) swap-i-weakenS zero (var p zero) = refl swap-i-weakenS (suc i) (var p zero) = refl swap-i-weakenS zero (var p (suc x)) = refl swap-i-weakenS (suc i) (var p (suc x)) = cong weaken1S (swap-i-weakenS i (var p x)) swap-i-weakenG i (transmit d t s) = cong₂ (transmit d) (swap-i-weakenT i t) (swap-i-weakenS i s) swap-i-weakenG i (choice d m alt) = cong (choice d m) (ext (swap-i-weakenS i ∘ alt)) swap-i-weakenG i end = refl swap-i-weakenT i TUnit = refl swap-i-weakenT i TInt = refl swap-i-weakenT i (TPair t₁ t₂) = cong₂ TPair (swap-i-weakenT i t₁) (swap-i-weakenT i t₂) swap-i-weakenT i (TChan x) = cong TChan (swap-i-weakenS i x) {-# TERMINATING #-} subst-swapG : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (g : GType (suc (suc n))) → st-substG (swap-polG (inject j) g) i ist ≡ swap-polG (inject! j) (st-substG g i ist) subst-swapS : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (s : IND.SType (suc (suc n))) → st-substS (swap-polS (inject j) s) i ist ≡ swap-polS (inject! j) (st-substS s i ist) subst-swapT : (ist : IND.SType 0) (i : Fin (suc (suc n))) (j : Fin′ i) (g : IND.Type (suc (suc n))) → st-substT (swap-polT (inject j) g) i ist ≡ swap-polT (inject! j) (st-substT g i ist) subst-swapG ist i j (transmit d t s) = cong₂ (transmit d) (subst-swapT ist i j t) (subst-swapS ist i j s) subst-swapG ist i j (choice d m alt) = cong (choice d m) (ext (λ x → subst-swapS ist i j (alt x))) subst-swapG ist i j end = refl subst-swapS ist i j (gdd gst) = cong gdd (subst-swapG ist i j gst) subst-swapS ist i j (rec gst) = cong rec (subst-swapG ist (suc i) (suc j) gst) subst-swapS{zero} ist zero () (var p zero) subst-swapS {zero} ist (suc zero) zero (var p zero) = refl subst-swapS {zero} ist (suc zero) zero (var p (suc x)) rewrite swap-i-weakenS zero (st-substS (var p x) zero ist) = refl subst-swapS{suc n} ist (suc i) zero (var p zero) = refl subst-swapS{suc n} ist (suc i) (suc j) (var p zero) = refl subst-swapS{suc n} ist zero () (var p (suc x)) subst-swapS{suc n} ist (suc i) zero (var p (suc x)) rewrite swap-i-weakenS zero (st-substS (var p x) i ist) = refl subst-swapS{suc n} ist (suc i) (suc j) (var p (suc x)) rewrite subst-weakenS (swap-polS (inject j) (var p x)) i zero z≤n ist | swap-weakenS (inject! j) (st-substS (var p x) i ist) = cong weaken1S (subst-swapS ist i j (var p x)) subst-swapT ist i j TUnit = refl subst-swapT ist i j TInt = refl subst-swapT ist i j (TPair t t₁) = cong₂ TPair (subst-swapT ist i j t) (subst-swapT ist i j t₁) subst-swapT ist i j (TChan x) = cong TChan (subst-swapS ist i j x) ---------------------------------------------------------------------- dual-recT' : (t : TType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0) → st-substT (swap-polT i t) i (dualS ist) ≡ st-substT t i ist dual-recG' : (g : GType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0) → st-substG (swap-polG i g) i (dualS ist) ≡ st-substG g i ist dual-recS' : (s : IND.SType (suc n)) (i : Fin (suc n)) (ist : IND.SType 0) → st-substS (swap-polS i s) i (dualS ist) ≡ st-substS s i ist dual-recT' TUnit i ist = refl dual-recT' TInt i ist = refl dual-recT' (TPair t t₁) i ist = cong₂ TPair (dual-recT' t i ist) (dual-recT' t₁ i ist) dual-recT' (TChan s) i ist = cong TChan (dual-recS' s i ist) dual-recG' (transmit d t s) i ist = cong₂ (transmit d) (dual-recT' t i ist) (dual-recS' s i ist) dual-recG' (choice d m alt) i ist = cong (choice d m) (ext (λ m' → dual-recS' (alt m') i ist)) dual-recG' end i ist = refl dual-recS' (gdd gst) i ist = cong gdd (dual-recG' gst i ist) dual-recS' (rec gst) i ist = cong rec (dual-recG' gst (suc i) ist) dual-recS' (var p zero) zero ist rewrite (dual-if-dual p ist) = refl dual-recS' (var p (suc x)) zero ist = trivial-subst-var p x (dualS ist) (ist) dual-recS' (var p zero) (suc i) ist = trivial-subst-var' p i (dualS ist) (ist) dual-recS' (var p (suc x)) (suc i) ist rewrite (subst-swap-dualS{ist = ist} (var p (suc x)) (suc i)) = refl ---------------------------------------------------------------------- -- show that the dualS function is compatible with unfolding -- that is -- COI.dual ∘ ind2coi ≈ ind2coi ∘ IND.dual {-# TERMINATING #-} dual-lemmaS : (s : IND.SType (suc n)) (j : Fin (suc n)) (s0 : IND.SType 0) → st-substS (dualS s) j s0 ≡ dualS (st-substS s j s0) dual-lemmaG : (g : IND.GType (suc n)) (j : Fin (suc n)) (s0 : IND.SType 0) → st-substG (dualG g) j s0 ≡ dualG (st-substG g j s0) dual-lemmaS (gdd gst) j s0 = cong gdd (dual-lemmaG gst j s0) dual-lemmaS (rec gst) j s0 rewrite (subst-swapG s0 (suc j) zero (dualG gst)) = let rst = dual-lemmaG gst (suc j) s0 in cong rec (cong (swap-polG zero) rst) dual-lemmaS {n} (var POS zero) zero s0 = sym (dual-weakenS' n s0) dual-lemmaS {n} (var NEG zero) zero s0 rewrite (sym (dual-weakenS' n s0)) | (sym (dual-invS (weakenS n s0))) = refl dual-lemmaS {suc n} (var POS zero) (suc j) s0 = refl dual-lemmaS {suc n} (var NEG zero) (suc j) s0 = refl dual-lemmaS {suc n} (var POS (suc x)) zero s0 = refl dual-lemmaS {suc n} (var NEG (suc x)) zero s0 = refl dual-lemmaS {suc n} (var POS (suc x)) (suc j) s0 rewrite (dual-weakenS zero (st-substS (var POS x) j s0)) = cong (weaken1'S zero) (dual-lemmaS (var POS x) j s0) dual-lemmaS {suc n} (var NEG (suc x)) (suc j) s0 rewrite (dual-weakenS zero (st-substS (var NEG x) j s0)) = cong (weaken1'S zero) (dual-lemmaS (var NEG x) j s0) dual-lemmaG (transmit d t s) j s0 = cong₂ (transmit (dual-dir d)) refl (dual-lemmaS s j s0) dual-lemmaG (choice d m alt) j s0 = cong (choice (dual-dir d) m) (ext (λ m' → dual-lemmaS (alt m') j s0)) dual-lemmaG end j s0 = refl ---------------------------------------------------------------------- -- main result dual-compatibleS : (ist : IND.SType 0) → COI.dual (ind2coiS ist) ≈ ind2coiS (IND.dualS ist) dual-compatibleG : (gst : IND.GType 0) → COI.dualF (ind2coiG gst) ≈' ind2coiG (IND.dualG gst) Equiv.force (dual-compatibleS (gdd gst)) = dual-compatibleG gst Equiv.force (dual-compatibleS (rec gst)) rewrite (dual-recG' (dualG gst) zero (rec gst)) | dual-lemmaG gst zero (rec gst) = dual-compatibleG (st-substG gst zero (rec gst)) dual-compatibleG (transmit d t s) = eq-transmit (dual-dir d) ≈ᵗ-refl (dual-compatibleS s) dual-compatibleG (choice d m alt) = eq-choice (dual-dir d) (dual-compatibleS ∘ alt) dual-compatibleG end = eq-end
{ "alphanum_fraction": 0.6201746725, "avg_line_length": 48.3122362869, "ext": "agda", "hexsha": "2405e361d0636f374f33f95fd3da536867fd59b5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-07T16:12:50.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-07T16:12:50.000Z", "max_forks_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "peterthiemann/dual-session", "max_forks_repo_path": "src/Duality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "peterthiemann/dual-session", "max_issues_repo_path": "src/Duality.agda", "max_line_length": 160, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "peterthiemann/dual-session", "max_stars_repo_path": "src/Duality.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:43:25.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-13T05:43:25.000Z", "num_tokens": 4471, "size": 11450 }
open import Type module Graph.Oper {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where open import Logic.Propositional open import Graph{ℓ₁}{ℓ₂}(V) _∪_ : Graph → Graph → Graph (g₁ ∪ g₂) v₁ v₂ = g₁ v₁ v₂ ∨ g₂ v₁ v₂ -- TODO: lift1On2
{ "alphanum_fraction": 0.6698113208, "avg_line_length": 21.2, "ext": "agda", "hexsha": "edd9928e38e6765ad93bd7e4105d0fe3edde4648", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Graph/Oper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Graph/Oper.agda", "max_line_length": 55, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Graph/Oper.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": 93, "size": 212 }
module Eval where open import Data.Empty open import Data.Unit open import Data.Unit.Core open import Data.Nat renaming (_⊔_ to _⊔ℕ_) open import Data.Sum renaming (map to _⊎→_) open import Data.Product renaming (map to _×→_) open import Data.Vec open import Relation.Binary.PropositionalEquality open import FT -- Finite Types _∘_ = trans mutual evalComb : {a b : FT} → a ⇛ b → ⟦ a ⟧ → ⟦ b ⟧ evalComb unite₊⇛ (inj₁ ()) evalComb unite₊⇛ (inj₂ y) = y evalComb uniti₊⇛ v = inj₂ v evalComb swap₊⇛ (inj₁ x) = inj₂ x evalComb swap₊⇛ (inj₂ y) = inj₁ y evalComb assocl₊⇛ (inj₁ x) = inj₁ (inj₁ x) evalComb assocl₊⇛ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) evalComb assocl₊⇛ (inj₂ (inj₂ y)) = inj₂ y evalComb assocr₊⇛ (inj₁ (inj₁ x)) = inj₁ x evalComb assocr₊⇛ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) evalComb assocr₊⇛ (inj₂ y) = inj₂ (inj₂ y) evalComb unite⋆⇛ (tt , proj₂) = proj₂ evalComb uniti⋆⇛ v = tt , v evalComb swap⋆⇛ (proj₁ , proj₂) = proj₂ , proj₁ evalComb assocl⋆⇛ (proj₁ , proj₂ , proj₃) = (proj₁ , proj₂) , proj₃ evalComb assocr⋆⇛ ((proj₁ , proj₂) , proj₃) = proj₁ , proj₂ , proj₃ evalComb distz⇛ (() , proj₂) evalComb factorz⇛ () evalComb dist⇛ (inj₁ x , proj₂) = inj₁ (x , proj₂) evalComb dist⇛ (inj₂ y , proj₂) = inj₂ (y , proj₂) evalComb factor⇛ (inj₁ (proj₁ , proj₂)) = inj₁ proj₁ , proj₂ evalComb factor⇛ (inj₂ (proj₁ , proj₂)) = inj₂ proj₁ , proj₂ evalComb id⇛ v = v evalComb (sym⇛ c) v = evalBComb c v evalComb (c₁ ◎ c₂) v = evalComb c₂ (evalComb c₁ v) evalComb (c ⊕ c₁) (inj₁ x) = inj₁ (evalComb c x) evalComb (c ⊕ c₁) (inj₂ y) = inj₂ (evalComb c₁ y) evalComb (c ⊗ c₁) (proj₁ , proj₂) = evalComb c proj₁ , evalComb c₁ proj₂ evalBComb : {a b : FT} → a ⇛ b → ⟦ b ⟧ → ⟦ a ⟧ evalBComb unite₊⇛ v = inj₂ v evalBComb uniti₊⇛ (inj₁ ()) evalBComb uniti₊⇛ (inj₂ y) = y evalBComb swap₊⇛ (inj₁ x) = inj₂ x evalBComb swap₊⇛ (inj₂ y) = inj₁ y evalBComb assocl₊⇛ (inj₁ (inj₁ x)) = inj₁ x evalBComb assocl₊⇛ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) evalBComb assocl₊⇛ (inj₂ y) = inj₂ (inj₂ y) evalBComb assocr₊⇛ (inj₁ x) = inj₁ (inj₁ x) evalBComb assocr₊⇛ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) evalBComb assocr₊⇛ (inj₂ (inj₂ y)) = inj₂ y evalBComb unite⋆⇛ x = tt , x evalBComb uniti⋆⇛ (tt , x) = x evalBComb swap⋆⇛ (x , y) = y , x evalBComb assocl⋆⇛ ((x , y) , z) = x , y , z evalBComb assocr⋆⇛ (x , y , z) = (x , y) , z evalBComb distz⇛ () evalBComb factorz⇛ (() , _) evalBComb dist⇛ (inj₁ (proj₁ , proj₂)) = inj₁ proj₁ , proj₂ evalBComb dist⇛ (inj₂ (proj₁ , proj₂)) = inj₂ proj₁ , proj₂ evalBComb factor⇛ (inj₁ x , proj₂) = inj₁ (x , proj₂) evalBComb factor⇛ (inj₂ y , proj₂) = inj₂ (y , proj₂) evalBComb id⇛ x = x evalBComb (sym⇛ c) x = evalComb c x evalBComb (c ◎ c₁) x = evalBComb c (evalBComb c₁ x) evalBComb (c ⊕ c₁) (inj₁ x) = inj₁ (evalBComb c x) evalBComb (c ⊕ c₁) (inj₂ y) = inj₂ (evalBComb c₁ y) evalBComb (c ⊗ c₁) (proj₁ , proj₂) = evalBComb c proj₁ , evalBComb c₁ proj₂ mutual Comb∘BComb : {a b : FT} → (c : a ⇛ b) → ∀ x → evalBComb c (evalComb c x) ≡ x Comb∘BComb unite₊⇛ (inj₁ ()) Comb∘BComb unite₊⇛ (inj₂ y) = refl Comb∘BComb uniti₊⇛ x = refl Comb∘BComb swap₊⇛ (inj₁ x) = refl Comb∘BComb swap₊⇛ (inj₂ y) = refl Comb∘BComb assocl₊⇛ (inj₁ x) = refl Comb∘BComb assocl₊⇛ (inj₂ (inj₁ x)) = refl Comb∘BComb assocl₊⇛ (inj₂ (inj₂ y)) = refl Comb∘BComb assocr₊⇛ (inj₁ (inj₁ x)) = refl Comb∘BComb assocr₊⇛ (inj₁ (inj₂ y)) = refl Comb∘BComb assocr₊⇛ (inj₂ y) = refl Comb∘BComb unite⋆⇛ (tt , y) = refl Comb∘BComb uniti⋆⇛ x = refl Comb∘BComb swap⋆⇛ (x , y) = refl Comb∘BComb assocl⋆⇛ (x , y , z) = refl Comb∘BComb assocr⋆⇛ ((x , y) , z) = refl Comb∘BComb distz⇛ (() , _) Comb∘BComb factorz⇛ () Comb∘BComb dist⇛ (inj₁ x , y) = refl Comb∘BComb dist⇛ (inj₂ x , y) = refl Comb∘BComb factor⇛ (inj₁ (x , y)) = refl Comb∘BComb factor⇛ (inj₂ (x , y)) = refl Comb∘BComb id⇛ x = refl Comb∘BComb (sym⇛ c) x = BComb∘Comb c x Comb∘BComb (c₀ ◎ c₁) x = cong (evalBComb c₀) (Comb∘BComb c₁ (evalComb c₀ x)) ∘ Comb∘BComb c₀ x Comb∘BComb (c₀ ⊕ c₁) (inj₁ x) = cong inj₁ (Comb∘BComb c₀ x) Comb∘BComb (c₀ ⊕ c₁) (inj₂ y) = cong inj₂ (Comb∘BComb c₁ y) Comb∘BComb (c₀ ⊗ c₁) (x , y) = cong₂ _,_ (Comb∘BComb c₀ x) (Comb∘BComb c₁ y) BComb∘Comb : {a b : FT} → (c : a ⇛ b) → ∀ x → evalComb c (evalBComb c x) ≡ x BComb∘Comb unite₊⇛ x = refl BComb∘Comb uniti₊⇛ (inj₁ ()) BComb∘Comb uniti₊⇛ (inj₂ y) = refl BComb∘Comb swap₊⇛ (inj₁ x) = refl BComb∘Comb swap₊⇛ (inj₂ y) = refl BComb∘Comb assocl₊⇛ (inj₁ (inj₁ x)) = refl BComb∘Comb assocl₊⇛ (inj₁ (inj₂ y)) = refl BComb∘Comb assocl₊⇛ (inj₂ y) = refl BComb∘Comb assocr₊⇛ (inj₁ x) = refl BComb∘Comb assocr₊⇛ (inj₂ (inj₁ x)) = refl BComb∘Comb assocr₊⇛ (inj₂ (inj₂ y)) = refl BComb∘Comb unite⋆⇛ x = refl BComb∘Comb uniti⋆⇛ (tt , proj₂) = refl BComb∘Comb swap⋆⇛ (proj₁ , proj₂) = refl BComb∘Comb assocl⋆⇛ ((proj₁ , proj₂) , proj₃) = refl BComb∘Comb assocr⋆⇛ (proj₁ , proj₂ , proj₃) = refl BComb∘Comb distz⇛ () BComb∘Comb factorz⇛ (() , _) BComb∘Comb dist⇛ (inj₁ (proj₁ , proj₂)) = refl BComb∘Comb dist⇛ (inj₂ (proj₁ , proj₂)) = refl BComb∘Comb factor⇛ (inj₁ x , proj₂) = refl BComb∘Comb factor⇛ (inj₂ y , proj₂) = refl BComb∘Comb id⇛ x = refl BComb∘Comb (sym⇛ c) x = Comb∘BComb c x BComb∘Comb (c₀ ◎ c₁) x = cong (evalComb c₁) (BComb∘Comb c₀ (evalBComb c₁ x)) ∘ BComb∘Comb c₁ x BComb∘Comb (c ⊕ c₁) (inj₁ x) = cong inj₁ (BComb∘Comb c x) BComb∘Comb (c ⊕ c₁) (inj₂ y) = cong inj₂ (BComb∘Comb c₁ y) BComb∘Comb (c ⊗ c₁) (x , y) = cong₂ _,_ (BComb∘Comb c x) (BComb∘Comb c₁ y) ----------------------------------------------------------------------------------- -- evaluate the alternative interpretation; A needs to be a pointed type. mutual evalComb′ : {a b : FT} {A : Set} {pt : A} → a ⇛ b → ⟦ a ⟧′ A → ⟦ b ⟧′ A evalComb′ unite₊⇛ (inj₁ ()) evalComb′ unite₊⇛ (inj₂ y) = y evalComb′ uniti₊⇛ x = inj₂ x evalComb′ swap₊⇛ (inj₁ x) = inj₂ x evalComb′ swap₊⇛ (inj₂ y) = inj₁ y evalComb′ assocl₊⇛ (inj₁ x) = inj₁ (inj₁ x) evalComb′ assocl₊⇛ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) evalComb′ assocl₊⇛ (inj₂ (inj₂ y)) = inj₂ y evalComb′ assocr₊⇛ (inj₁ (inj₁ x)) = inj₁ x evalComb′ assocr₊⇛ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) evalComb′ assocr₊⇛ (inj₂ y) = inj₂ (inj₂ y) evalComb′ unite⋆⇛ (_ , x) = x evalComb′ {pt = a} uniti⋆⇛ x = a , x evalComb′ swap⋆⇛ (x , y) = y , x evalComb′ assocl⋆⇛ (x , y , z) = (x , y) , z evalComb′ assocr⋆⇛ ((x , y) , z) = x , y , z evalComb′ distz⇛ (() , _) evalComb′ factorz⇛ () evalComb′ dist⇛ (inj₁ x , z) = inj₁ (x , z) evalComb′ dist⇛ (inj₂ y , z) = inj₂ (y , z) evalComb′ factor⇛ (inj₁ (x , y)) = inj₁ x , y evalComb′ factor⇛ (inj₂ (x , y)) = inj₂ x , y evalComb′ id⇛ x = x evalComb′ {pt = a} (sym⇛ c) x = evalBComb′ {pt = a} c x evalComb′ {pt = a} (c₀ ◎ c₁) x = evalComb′ {pt = a} c₁ (evalComb′ {pt = a} c₀ x) evalComb′ {pt = a} (c₀ ⊕ c₁) (inj₁ x) = inj₁ (evalComb′ {pt = a} c₀ x) evalComb′ {pt = a} (c₀ ⊕ c₁) (inj₂ y) = inj₂ (evalComb′ {pt = a} c₁ y) evalComb′ {pt = a} (c₀ ⊗ c₁) (x , y) = evalComb′ {pt = a} c₀ x , evalComb′ {pt = a} c₁ y evalBComb′ : {a b : FT} {A : Set} {pt : A} → a ⇛ b → ⟦ b ⟧′ A → ⟦ a ⟧′ A evalBComb′ unite₊⇛ x = inj₂ x evalBComb′ uniti₊⇛ (inj₁ ()) evalBComb′ uniti₊⇛ (inj₂ y) = y evalBComb′ swap₊⇛ (inj₁ x) = inj₂ x evalBComb′ swap₊⇛ (inj₂ y) = inj₁ y evalBComb′ assocl₊⇛ (inj₁ (inj₁ x)) = inj₁ x evalBComb′ assocl₊⇛ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) evalBComb′ assocl₊⇛ (inj₂ y) = inj₂ (inj₂ y) evalBComb′ assocr₊⇛ (inj₁ x) = inj₁ (inj₁ x) evalBComb′ assocr₊⇛ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) evalBComb′ assocr₊⇛ (inj₂ (inj₂ y)) = inj₂ y evalBComb′ {pt = a} unite⋆⇛ x = a , x evalBComb′ uniti⋆⇛ (_ , y) = y evalBComb′ swap⋆⇛ (x , y) = y , x evalBComb′ assocl⋆⇛ ((x , y) , z) = x , y , z evalBComb′ assocr⋆⇛ (x , y , z) = (x , y) , z evalBComb′ distz⇛ () evalBComb′ factorz⇛ (() , _) evalBComb′ dist⇛ (inj₁ (x , y)) = inj₁ x , y evalBComb′ dist⇛ (inj₂ (x , y)) = inj₂ x , y evalBComb′ factor⇛ (inj₁ x , z) = inj₁ (x , z) evalBComb′ factor⇛ (inj₂ y , z) = inj₂ (y , z) evalBComb′ id⇛ x = x evalBComb′ {pt = a} (sym⇛ c) x = evalComb′ {pt = a} c x evalBComb′ {pt = a} (c₀ ◎ c₁) x = evalBComb′ {pt = a} c₀ (evalBComb′ {pt = a} c₁ x) evalBComb′ {pt = a} (c₀ ⊕ c₁) (inj₁ x) = inj₁ (evalBComb′ {pt = a} c₀ x) evalBComb′ {pt = a} (c₀ ⊕ c₁) (inj₂ y) = inj₂ (evalBComb′ {pt = a} c₁ y) evalBComb′ {pt = a} (c₀ ⊗ c₁) (x , y) = evalBComb′ {pt = a} c₀ x , evalBComb′ {pt = a} c₁ y --- SWAP12 SWAP23 SWAP13 : PLUS ONE (PLUS ONE ONE) ⇛ PLUS ONE (PLUS ONE ONE) SWAP12 = assocl₊⇛ ◎ (swap₊⇛ ⊕ id⇛) ◎ assocr₊⇛ SWAP23 = id⇛ ⊕ swap₊⇛ SWAP13 = SWAP23 ◎ SWAP12 ◎ SWAP23 x121 = evalComb SWAP12 (inj₁ tt) -- 0 -> 1 x122 = evalComb SWAP12 (inj₂ (inj₁ tt)) -- 1 -> 0 x123 = evalComb SWAP12 (inj₂ (inj₂ tt)) -- 2 -> 2 x231 = evalComb SWAP23 (inj₁ tt) -- 0 -> 0 x232 = evalComb SWAP23 (inj₂ (inj₁ tt)) -- 1 -> 2 x233 = evalComb SWAP23 (inj₂ (inj₂ tt)) -- 2 -> 1 x131 = evalComb SWAP13 (inj₁ tt) -- 0 -> 2 x132 = evalComb SWAP13 (inj₂ (inj₁ tt)) -- 1 -> 1 x133 = evalComb SWAP13 (inj₂ (inj₂ tt)) -- 2 -> 0
{ "alphanum_fraction": 0.5810546875, "avg_line_length": 41.3273542601, "ext": "agda", "hexsha": "a8b912a97a9eb9378e28391e56d6ff120208bbca", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/Eval.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/Eval.agda", "max_line_length": 93, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/Eval.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 4735, "size": 9216 }
open import Formalization.PredicateLogic.Signature module Formalization.PredicateLogic.Minimal.NaturalDeduction.NegativeTranslations (𝔏 : Signature) where open Signature(𝔏) open import Data.Either as Either using (Left ; Right) open import Data.ListSized using (List) import Logic.Propositional as Meta import Logic.Predicate as Meta import Lvl open import Formalization.PredicateLogic.Minimal.NaturalDeduction (𝔏) import Formalization.PredicateLogic.Classical.NaturalDeduction private module Classical = Formalization.PredicateLogic.Classical.NaturalDeduction (𝔏) open import Formalization.PredicateLogic.Syntax(𝔏) open import Formalization.PredicateLogic.Syntax.NegativeTranslations(𝔏) open import Formalization.PredicateLogic.Syntax.Substitution(𝔏) open import Functional using (_∘_ ; _∘₂_ ; _∘₃_ ; _∘₄_ ; swap ; _←_) open import Numeral.Finite open import Numeral.Natural open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇] ; map ; unmap) renaming (•_ to · ; _≡_ to _≡ₛ_) open import Structure.Relator open import Type -- TODO: Move this module module _ where private variable ℓ : Lvl.Level private variable T A B : Type{ℓ} private variable S S₁ S₂ : PredSet{ℓ}(T) private variable f : A → B private variable x : T postulate map-preserves-union : (map f(S₁ ∪ S₂) ⊆ ((map f(S₁)) ∪ (map f(S₂)))) postulate map-preserves-singleton : (map f(S₁ ∪ S₂) ⊆ ((map f(S₁)) ∪ (map f(S₂)))) postulate map-preserves-union-singleton : (map f(S ∪ · x) ⊆ ((map f(S)) ∪ ·(f(x)))) private variable ℓ ℓ₁ ℓ₂ : Lvl.Level private variable args n vars : ℕ private variable Γ Γ₁ Γ₂ : PredSet{ℓ}(Formula(vars)) private variable φ ψ γ φ₁ ψ₁ γ₁ φ₂ ψ₂ γ₂ φ₃ ψ₃ φ₄ ψ₄ φ₅ ψ₅ δ₁ δ₂ : Formula(vars) private variable p : Prop(args) private variable x : List(Term(vars))(args) [⊢]-functionₗ : (Γ₁ ≡ₛ Γ₂) → ((Γ₁ ⊢_) ≡ₛ (Γ₂ ⊢_)) [⊢]-functionₗ Γ₁Γ₂ = Meta.[↔]-intro (weaken (Meta.[↔]-to-[←] Γ₁Γ₂)) (weaken (Meta.[↔]-to-[→] Γ₁Γ₂)) [⊢][→]-elim : ((Γ ∪ · φ) ⊢ ψ) → ((Γ ⊢ φ) → (Γ ⊢ ψ)) [⊢][→]-elim Γφψ Γφ = [∨]-elim Γφψ Γφψ ([∨]-introₗ Γφ) [⟶]-intro-inverse : (Γ ⊢ (φ ⟶ ψ)) → ((Γ ∪ · φ) ⊢ ψ) [⟶]-intro-inverse p = [⟶]-elim (direct (Right [≡]-intro)) (weaken-union p) weaken-closure-union : (((Γ₁ ⊢_) ∪ Γ₂) ⊢ φ) → ((((Γ₁ ∪ Γ₂) ⊢_)) ⊢ φ) weaken-closure-union {Γ₁ = Γ₁}{Γ₂ = Γ₂}{φ = φ} = weaken sub where sub : ((Γ₁ ⊢_) ∪ Γ₂) ⊆ ((Γ₁ ∪ Γ₂) ⊢_) sub (Left p) = weaken-union p sub (Right p) = direct (Right p) {- assume-closure : ((Γ ⊢_) ⊢ φ) → (Γ ⊢ φ) assume-closure (direct p) = p assume-closure [⊤]-intro = [⊤]-intro assume-closure ([∧]-intro p q) = [∧]-intro (assume-closure p) (assume-closure q) assume-closure ([∧]-elimₗ p) = [∧]-elimₗ (assume-closure p) assume-closure ([∧]-elimᵣ p) = [∧]-elimᵣ (assume-closure p) assume-closure ([∨]-introₗ p) = [∨]-introₗ (assume-closure p) assume-closure ([∨]-introᵣ p) = [∨]-introᵣ (assume-closure p) assume-closure ([∨]-elim p q r) = [∨]-elim {!assume-closure(weaken-closure-union p)!} ([⟶]-elim (direct(Right [≡]-intro)) {!!}) (assume-closure r) assume-closure ([⟶]-intro p) = [⟶]-intro (assume-closure {!weaken-closure-union p!}) assume-closure ([⟶]-elim p q) = [⟶]-elim (assume-closure p) (assume-closure q) assume-closure ([Ɐ]-intro p) = [Ɐ]-intro (assume-closure p) assume-closure ([Ɐ]-elim p) = [Ɐ]-elim (assume-closure p) assume-closure ([∃]-intro p) = [∃]-intro (assume-closure p) assume-closure ([∃]-elim p q) = [∃]-elim (assume-closure {!!}) (assume-closure q) -} -- 2.1.8B1 [¬¬]-intro-[⟶] : (Γ ⊢ (φ ⟶ (¬¬ φ))) [¬¬]-intro-[⟶] = [⟶]-intro ([¬¬]-intro (direct (Right [≡]-intro))) -- 2.1.8.A1 [⟶]-const : Γ ⊢ (φ ⟶ ψ ⟶ φ) [⟶]-const = [⟶]-intro ([⟶]-intro (direct (Left (Right [≡]-intro)))) [⟶]-refl : Γ ⊢ (φ ⟶ φ) [⟶]-refl = [⟶]-intro (direct (Right [≡]-intro)) [⟷]-refl : Γ ⊢ (φ ⟷ φ) [⟷]-refl = [⟷]-intro (direct (Right [≡]-intro)) (direct (Right [≡]-intro)) [⟶]-trans : (Γ ⊢ ((φ ⟶ ψ) ⟶ (ψ ⟶ γ) ⟶ (φ ⟶ γ))) [⟶]-trans = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) (direct (Left (Left (Right [≡]-intro))))) (direct (Left (Right [≡]-intro)))))) [⟶]-contrapositiveᵣ : (Γ ⊢ (φ ⟶ ψ) ⟶ ((¬ φ) ⟵ (¬ ψ))) [⟶]-contrapositiveᵣ = [⟶]-trans [⟶]-double-contrapositiveᵣ : (Γ ⊢ (φ ⟶ ψ) ⟶ ((¬¬ φ) ⟶ (¬¬ ψ))) [⟶]-double-contrapositiveᵣ = [⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [⟶]-contrapositiveᵣ) [⟶]-contrapositiveᵣ) [⟶]-elim₂ : (Γ ⊢ φ₁) → (Γ ⊢ φ₂) → (Γ ⊢ (φ₁ ⟶ φ₂ ⟶ ψ)) → (Γ ⊢ ψ) [⟶]-elim₂ = swap(_∘_) [⟶]-elim ∘ (swap(_∘_) ∘ [⟶]-elim) [⟶]-elim₃ : (Γ ⊢ φ₁) → (Γ ⊢ φ₂) → (Γ ⊢ φ₃) → (Γ ⊢ (φ₁ ⟶ φ₂ ⟶ φ₃ ⟶ ψ)) → (Γ ⊢ ψ) [⟶]-elim₃ = swap(_∘_) [⟶]-elim ∘₂ (swap(_∘_) ∘₂ [⟶]-elim₂) [⟶]-elim₄ : (Γ ⊢ φ₁) → (Γ ⊢ φ₂) → (Γ ⊢ φ₃) → (Γ ⊢ φ₄) → (Γ ⊢ (φ₁ ⟶ φ₂ ⟶ φ₃ ⟶ φ₄ ⟶ ψ)) → (Γ ⊢ ψ) [⟶]-elim₄ = swap(_∘_) [⟶]-elim ∘₃ (swap(_∘_) ∘₃ [⟶]-elim₃) [⟶]-elim₅ : (Γ ⊢ φ₁) → (Γ ⊢ φ₂) → (Γ ⊢ φ₃) → (Γ ⊢ φ₄) → (Γ ⊢ φ₅) → (Γ ⊢ (φ₁ ⟶ φ₂ ⟶ φ₃ ⟶ φ₄ ⟶ φ₅ ⟶ ψ)) → (Γ ⊢ ψ) [⟶]-elim₅ = swap(_∘_) [⟶]-elim ∘₄ (swap(_∘_) ∘₄ [⟶]-elim₄) -- 2.1.8B2 [¬¬¬]-elim : Γ ⊢ ((¬ ¬ ¬ φ) ⟶ (¬ φ)) [¬¬¬]-elim = [⟶]-intro ([⟶]-intro ([⟶]-elim ([¬¬]-intro (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) [∨]-introₗ-by-[¬∧] : Γ ⊢ ((¬ φ) ⟶ ¬(φ ∧ ψ)) [∨]-introₗ-by-[¬∧] = [⟶]-intro ([⟶]-intro ([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) [∨]-introᵣ-by-[¬∧] : Γ ⊢ ((¬ ψ) ⟶ ¬(φ ∧ ψ)) [∨]-introᵣ-by-[¬∧] = [⟶]-intro ([⟶]-intro ([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) [∨]-introₗ-by-[¬¬∧¬] : Γ ⊢ (φ ⟶ ¬((¬ φ) ∧ (¬ ψ))) [∨]-introₗ-by-[¬¬∧¬] = [⟶]-intro ([⟶]-intro ([⟶]-elim (direct (Left (Right [≡]-intro))) ([∧]-elimₗ (direct (Right [≡]-intro))))) [∨]-introᵣ-by-[¬¬∧¬] : Γ ⊢ (ψ ⟶ ¬((¬ φ) ∧ (¬ ψ))) [∨]-introᵣ-by-[¬¬∧¬] = [⟶]-intro ([⟶]-intro ([⟶]-elim (direct (Left (Right [≡]-intro))) ([∧]-elimᵣ (direct (Right [≡]-intro))))) [∃]-intro-by-[¬Ɐ] : ∀{t} → (Γ ⊢ ((¬(substitute0 t φ)) ⟶ ¬(Ɐ φ))) [∃]-intro-by-[¬Ɐ] = [⟶]-intro ([⟶]-intro ([⟶]-elim ([Ɐ]-elim (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) [∃]-intro-by-[¬Ɐ¬] : ∀{t} → (Γ ⊢ ((substitute0 t φ) ⟶ ¬(Ɐ(¬ φ)))) [∃]-intro-by-[¬Ɐ¬] = [⟶]-intro ([⟶]-intro ([⟶]-elim (direct (Left (Right [≡]-intro))) ([Ɐ]-elim (direct (Right [≡]-intro))))) [∧]-map : Γ ⊢ ((φ₁ ⟶ φ₂) ⟶ (ψ₁ ⟶ ψ₂) ⟶ ((φ₁ ∧ ψ₁) ⟶ (φ₂ ∧ ψ₂))) [∧]-map = [⟶]-intro ([⟶]-intro ([⟶]-intro ([∧]-intro ([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) (direct (Left (Left (Right [≡]-intro))))) ([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))))) [∨]-map : Γ ⊢ ((φ₁ ⟶ φ₂) ⟶ (ψ₁ ⟶ ψ₂) ⟶ ((φ₁ ∨ ψ₁) ⟶ (φ₂ ∨ ψ₂))) [∨]-map = [⟶]-intro ([⟶]-intro ([⟶]-intro ([∨]-elim ([∨]-introₗ ([⟶]-intro-inverse (direct (Left (Left (Right [≡]-intro)))))) ([∨]-introᵣ ([⟶]-intro-inverse (direct (Left (Right [≡]-intro))))) (direct (Right [≡]-intro))))) [Ɐ]-map : Γ ⊢ (Ɐ(φ₁ ⟶ φ₂) ⟶ ((Ɐ φ₁) ⟶ (Ɐ φ₂))) [Ɐ]-map = [⟶]-intro ([⟶]-intro ([Ɐ]-intro ([⟶]-elim ([Ɐ]-elim (direct (Right [≡]-intro))) ([Ɐ]-elim(direct (Left (Right [≡]-intro))))))) [⟶]-map : Γ ⊢ ((φ₁ ⟵ φ₂) ⟶ (ψ₁ ⟶ ψ₂) ⟶ ((φ₁ ⟶ ψ₁) ⟶ (φ₂ ⟶ ψ₂))) [⟶]-map = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) (direct (Left (Left (Left (Right [≡]-intro)))))) (direct (Left (Right [≡]-intro)))) (direct (Left (Left (Right [≡]-intro)))))))) [⟶]-map₂ : Γ ⊢ ((φ₁ ⟵ φ₂) ⟶ (ψ₁ ⟵ ψ₂) ⟶ (γ₁ ⟶ γ₂) ⟶ ((φ₁ ⟶ ψ₁ ⟶ γ₁) ⟶ (φ₂ ⟶ ψ₂ ⟶ γ₂))) [⟶]-map₂ = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim₂ (direct (Left (Left (Right [≡]-intro)))) ([⟶]-elim₂ (direct (Left (Right [≡]-intro))) (direct (Right [≡]-intro)) [⟶]-map) [⟶]-map))) [⟶]-map₃ : Γ ⊢ ((φ₁ ⟵ φ₂) ⟶ (ψ₁ ⟵ ψ₂) ⟶ (γ₁ ⟵ γ₂) ⟶ (δ₁ ⟶ δ₂) ⟶ ((φ₁ ⟶ ψ₁ ⟶ γ₁ ⟶ δ₁) ⟶ (φ₂ ⟶ ψ₂ ⟶ γ₂ ⟶ δ₂))) [⟶]-map₃ = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim₃ (direct (Left (Left (Left (Right [≡]-intro))))) (direct (Left (Left (Right [≡]-intro)))) ([⟶]-elim₂ (direct (Left (Right [≡]-intro))) (direct (Right [≡]-intro)) [⟶]-map) [⟶]-map₂)))) [¬]-map : Γ ⊢ ((φ ⟵ ψ) ⟶ (¬ φ) ⟶ (¬ ψ)) [¬]-map = [⟶]-contrapositiveᵣ [⟶]-trans₂ : (Γ ⊢ ((φ₁ ⟶ φ₂ ⟶ ψ) ⟶ (ψ ⟶ γ) ⟶ (φ₁ ⟶ φ₂ ⟶ γ))) [⟶]-trans₂ = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim₂ (direct (Left (Right [≡]-intro))) (direct (Right [≡]-intro)) (direct (Left (Left (Left (Right [≡]-intro)))))) (direct (Left (Left (Right [≡]-intro)))))))) -- 2.1.8B3 [¬¬]-preserve-[⟶] : Γ ⊢ (¬¬(φ ⟶ ψ) ⟶ ((¬¬ φ) ⟶ (¬¬ ψ))) [¬¬]-preserve-[⟶] = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) ([⟶]-elim (direct(Right [≡]-intro)) [⟶]-double-contrapositiveᵣ)) ([¬¬]-intro (direct (Left (Right [≡]-intro)))))) (direct (Left (Left (Right [≡]-intro))))))) -- 2.1.8B4 [¬¬]-preserve-[∧] : Γ ⊢ (¬¬(φ ∧ ψ) ⟷ ((¬¬ φ) ∧ (¬¬ ψ))) [¬¬]-preserve-[∧] {Γ = Γ}{φ = φ} = [⟷]-intro ([⟶]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([∧]-intro (direct (Left (Right [≡]-intro))) (direct (Right [≡]-intro))) (direct (Left (Left (Right [≡]-intro)))))) ([∧]-elimᵣ (direct (Left (Left (Right [≡]-intro))))))) ([∧]-elimₗ (direct (Left (Right [≡]-intro)))))) ([∧]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∨]-introₗ-by-[¬∧]) (direct (Left (Right [≡]-intro))))) ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∨]-introᵣ-by-[¬∧]) (direct (Left (Right [≡]-intro))))) ) -- 2.1.8B5 [¬]-preserve-[∨][∧] : Γ ⊢ (¬(φ ∨ ψ) ⟷ ((¬ φ) ∧ (¬ ψ))) [¬]-preserve-[∨][∧] = [⟷]-intro ([⟶]-intro ([∨]-elim ([⟶]-elim (direct (Right [≡]-intro)) ([∧]-elimₗ (direct (Left (Left (Right [≡]-intro)))))) ([⟶]-elim (direct (Right [≡]-intro)) ([∧]-elimᵣ (direct (Left (Left (Right [≡]-intro)))))) (direct (Right [≡]-intro)) )) ([∧]-intro ([⟶]-intro ([⟶]-elim ([∨]-introₗ (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) ([⟶]-intro ([⟶]-elim ([∨]-introᵣ (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro))))) ) -- 2.1.8B6 [¬¬]-preserve-[Ɐ] : Γ ⊢ (¬¬(Ɐ φ) ⟶ (Ɐ(¬¬ φ))) [¬¬]-preserve-[Ɐ] = [⟶]-intro ([Ɐ]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∃]-intro-by-[¬Ɐ]) (direct (Left (Right [≡]-intro)))))) [¬]-preserve-[∃][Ɐ] : Γ ⊢ (¬(∃ φ) ⟷ (Ɐ(¬ φ))) [¬]-preserve-[∃][Ɐ] = [⟷]-intro ([⟶]-intro ([∃]-elim ([⟶]-intro-inverse ([Ɐ]-elim (direct (Left (Right [≡]-intro))))) (direct (Right [≡]-intro)))) ([Ɐ]-intro ([⟶]-intro ([⟶]-elim ([∃]-intro (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro)))))) open import Lang.Instance -- 2.3.1 data NegativeFragment : Formula(vars) → Type{ℓₚ Lvl.⊔ ℓₒ} where atom : NegativeFragment(¬(p $ x)) bottom : NegativeFragment{vars}(⊥) top : NegativeFragment{vars}(⊤) and : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ∧ ψ) impl : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ⟶ ψ) all : (∀{t} → NegativeFragment(substitute0 t φ)) → NegativeFragment(Ɐ φ) pattern neg p = NegativeFragment.impl p bottom instance _ = \{vars} {p}{args}{x} → atom{vars}{p = p}{args}{x = x} instance _ = \{vars} → bottom{vars} instance _ = \{vars} → top{vars} instance _ = \{vars} {φ} ⦃ neg-φ ⦄ {ψ} ⦃ neg-ψ ⦄ → and{vars}{φ = φ}{ψ = ψ} neg-φ neg-ψ instance _ = \{vars} {φ} ⦃ neg-φ ⦄ {ψ} ⦃ neg-ψ ⦄ → impl{vars}{φ = φ}{ψ = ψ} neg-φ neg-ψ instance _ = \{vars} {φ} ⦃ neg-φ : ∀{_} → _ ⦄ → all{vars}{φ = φ} (\{t} → neg-φ{t}) -- 2.3.2 [¬¬]-elim-on-negativeFragment : NegativeFragment(φ) → (Γ ⊢ ((¬¬ φ) ⟶ φ)) [¬¬]-elim-on-negativeFragment atom = [¬¬¬]-elim [¬¬]-elim-on-negativeFragment bottom = [¬¬]-intro [⟶]-refl [¬¬]-elim-on-negativeFragment top = [⟶]-intro [⊤]-intro [¬¬]-elim-on-negativeFragment (and negφ negψ) = [⟶]-intro ([∧]-intro ([⟶]-elim ([∧]-elimₗ([⟷]-elimᵣ (direct (Right [≡]-intro)) [¬¬]-preserve-[∧])) ([¬¬]-elim-on-negativeFragment negφ)) ([⟶]-elim ([∧]-elimᵣ([⟷]-elimᵣ (direct (Right [≡]-intro)) [¬¬]-preserve-[∧])) ([¬¬]-elim-on-negativeFragment negψ)) ) [¬¬]-elim-on-negativeFragment (impl negφ negψ) = [⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim₂ (direct (Left (Right [≡]-intro))) ([¬¬]-intro (direct (Right [≡]-intro))) [¬¬]-preserve-[⟶]) ([¬¬]-elim-on-negativeFragment negψ) )) [¬¬]-elim-on-negativeFragment (all negφ) = [⟶]-intro ([Ɐ]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∃]-intro-by-[¬Ɐ]) (direct (Left (Right [≡]-intro))))) ([¬¬]-elim-on-negativeFragment negφ))) Stable : ∀{ℓ}{vars} → Formula(vars) → Type Stable{ℓ = ℓ} (φ) = ∀{Γ : PredSet{ℓ}(_)} → (Γ ⊢ (¬¬ φ ⟶ φ)) [¬]-stability : Stable{ℓ}(¬ φ) [¬]-stability = [¬¬¬]-elim -- [∨]-stability : Stable(φ) → Stable(ψ) → Stable{ℓ}(φ ∨ ψ) -- [∨]-stability sφ sψ = [⟶]-intro ([∨]-elim ([∨]-introₗ {!!}) ([∨]-introᵣ {!!}) {!!}) [∨]-elim-by-[¬∧] : Stable(φ) → Stable(ψ) → Stable(γ) → (Γ ⊢ (((¬ φ) ⟶ γ) ⟶ ((¬ ψ) ⟶ γ) ⟶ ¬(φ ∧ ψ) ⟶ γ)) [∨]-elim-by-[¬∧] negφ negψ negγ = [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([⟶]-elim₃ negφ negψ ([∧]-intro ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Left (Right [≡]-intro))))) [⟶]-contrapositiveᵣ)) ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) [⟶]-contrapositiveᵣ))) [∧]-map) (direct (Left (Right [≡]-intro))))) negγ))) [∨]-elim-by-[¬¬∧¬] : (∀{ℓ} → Stable{ℓ}(γ)) → (Γ ⊢ ((φ ⟶ γ) ⟶ (ψ ⟶ γ) ⟶ ¬((¬ φ) ∧ (¬ ψ)) ⟶ γ)) [∨]-elim-by-[¬¬∧¬] negγ = [⟶]-elim₅ (pp negγ) (pp negγ) [⟶]-refl [⟶]-refl ([∨]-elim-by-[¬∧] [¬]-stability [¬]-stability negγ) [⟶]-map₃ where pp : Stable(ψ) → (Γ ⊢ ((φ ⟶ ψ) ⟶ ((¬¬ φ) ⟶ ψ))) pp negψ = [⟶]-elim₂ [⟶]-double-contrapositiveᵣ negψ [⟶]-trans₂ [⟷]-to-[⟵] : (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ (φ ⟵ ψ)) [⟷]-to-[⟵] p = [⟶]-intro ([⟷]-elimₗ (direct (Right [≡]-intro)) (weaken-union p)) [⟷]-to-[⟶] : (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ (φ ⟶ ψ)) [⟷]-to-[⟶] p = [⟶]-intro ([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken-union p)) [Ɐ][→]-distributivity : Γ ⊢ (Ɐ(φ ⟶ ψ) ⟶ (Ɐ φ) ⟶ (Ɐ ψ)) [Ɐ][→]-distributivity = [⟶]-intro ([⟶]-intro ([Ɐ]-intro ([⟶]-elim ([Ɐ]-elim (direct (Right [≡]-intro))) ([Ɐ]-elim (direct (Left (Right [≡]-intro))))))) [¬∃]-to-[∀¬] : Γ ⊢ (¬(∃ φ) ⟶ Ɐ(¬ φ)) [¬∃]-to-[∀¬] = [⟶]-intro ([Ɐ]-intro ([⟶]-intro ([⟶]-elim ([∃]-intro (direct (Right [≡]-intro))) (direct (Left (Right [≡]-intro)))))) [¬Ɐ]-to-[∃¬] : (∀{t} → Stable(substitute0 t φ)) → Stable(∃(¬ φ)) → (Γ ⊢ (¬(Ɐ φ) ⟶ ∃(¬ φ))) [¬Ɐ]-to-[∃¬] negφ nege = [⟶]-intro ([⟶]-elim ([⟶]-intro ([⟶]-elim ([⟶]-elim₂ ([Ɐ]-intro negφ) ([⟶]-elim (direct (Right [≡]-intro)) [¬∃]-to-[∀¬]) [Ɐ][→]-distributivity) (direct (Left (Right [≡]-intro))))) nege) {- test : (Γ ⊢ (¬¬ φ ⟶ φ)) → (Γ ⊢ (¬ Ɐ(¬ φ))) → (Γ ⊢ ∃ φ) test negφ p = [∃]-elim ([∃]-intro {![⟶]-intro negφ!}) ([⟶]-elim p test2) -} [∃]-elim-by-[¬¬∧¬] : (∀{t} → (Γ ∪ ·(substitute0 t φ)) ⊢ ψ) → (Γ ⊢ ¬(Ɐ(¬ φ))) → (Γ ⊢ ψ) [∃]-elim-by-[¬¬∧¬] p q = [∃]-elim p {!!} -- test : ∀{t} → (Γ₁ ≡ₛ Γ₂) → (Γ₁ ⊢ φ) → (Γ₂ ⊢ substitute0 t φ) -- test p = {!p!} {- test : ∀{t} → (∀{Γ : PredSet{ℓ}(Formula(𝐒(vars)))} → (Γ ⊢ φ)) → (∀{Γ : PredSet{ℓ}(Formula(vars))} → (Γ ⊢ substitute0 t φ)) test {t = t} Γφ {Γ} with Γφ{unmap(substitute0 t) Γ} ... | direct p = direct p ... | [⊤]-intro = [⊤]-intro ... | [∧]-intro p q = [∧]-intro {!test p!} {!!} ... | [∧]-elimₗ p = {!!} ... | [∧]-elimᵣ p = {!!} ... | [∨]-introₗ p = {!!} ... | [∨]-introᵣ p = {!!} ... | [∨]-elim p q r = {!!} ... | [⟶]-intro p = {!!} ... | [⟶]-elim p q = {!!} ... | [Ɐ]-intro p = {!!} ... | [Ɐ]-elim p = {!!} ... | [∃]-intro p = {!!} ... | [∃]-elim p q = {!!} -} substitute0-negativeFragment : NegativeFragment(φ) → ∀{t} → NegativeFragment(substitute0 t φ) substitute0-negativeFragment atom = atom substitute0-negativeFragment bottom = bottom substitute0-negativeFragment top = top substitute0-negativeFragment (and p q) = and (substitute0-negativeFragment p) (substitute0-negativeFragment q) substitute0-negativeFragment (impl p q) = impl (substitute0-negativeFragment p) (substitute0-negativeFragment q) substitute0-negativeFragment (all p) = {!!} -- all (substitute0-negativeFragment p) ggTrans-negativeFragment : NegativeFragment(ggTrans(φ)) ggTrans-negativeFragment {φ = p $ x} = neg atom ggTrans-negativeFragment {φ = ⊤} = top ggTrans-negativeFragment {φ = ⊥} = bottom ggTrans-negativeFragment {φ = φ ∧ ψ} = and ggTrans-negativeFragment ggTrans-negativeFragment ggTrans-negativeFragment {φ = φ ∨ ψ} = neg(and(neg ggTrans-negativeFragment) (neg ggTrans-negativeFragment)) ggTrans-negativeFragment {φ = φ ⟶ ψ} = impl ggTrans-negativeFragment ggTrans-negativeFragment ggTrans-negativeFragment {φ = Ɐ φ} = all (substitute0-negativeFragment (ggTrans-negativeFragment {φ = φ})) ggTrans-negativeFragment {φ = ∃ φ} = neg (all (neg (substitute0-negativeFragment (ggTrans-negativeFragment {φ = φ})))) -- [¬¬]-elim-of-koTrans : (Γ ⊢ (¬¬ ggTrans(φ))) ← (Γ ⊢ (ggTrans φ)) ggTrans-substitute0 : ∀{t} → (ggTrans(substitute0 t φ) ≡ substitute0 t (ggTrans φ)) ggTrans-substitute0 {φ = P $ x} = [≡]-intro ggTrans-substitute0 {φ = ⊤} = [≡]-intro ggTrans-substitute0 {φ = ⊥} = [≡]-intro ggTrans-substitute0 {φ = φ ∧ ψ}{t} rewrite ggTrans-substitute0 {φ = φ}{t} rewrite ggTrans-substitute0 {φ = ψ}{t} = [≡]-intro ggTrans-substitute0 {φ = φ ∨ ψ}{t} rewrite ggTrans-substitute0 {φ = φ}{t} rewrite ggTrans-substitute0 {φ = ψ}{t} = [≡]-intro ggTrans-substitute0 {φ = φ ⟶ ψ}{t} rewrite ggTrans-substitute0 {φ = φ}{t} rewrite ggTrans-substitute0 {φ = ψ}{t} = [≡]-intro ggTrans-substitute0 {φ = Ɐ φ}{t} = {!!} -- rewrite ggTrans-substitute0 {φ = φ}{termVar𝐒 t} -- = [≡]-intro ggTrans-substitute0 {φ = ∃ φ}{t} = {!!} -- rewrite ggTrans-substitute0 {φ = φ}{termVar𝐒 t} -- = [≡]-intro koTrans-substitute0 : ∀{t} → (koTrans(substitute0 t φ) ≡ substitute0 t (koTrans φ)) koTrans-substitute0 {φ = f $ x} = [≡]-intro koTrans-substitute0 {φ = ⊤} = [≡]-intro koTrans-substitute0 {φ = ⊥} = [≡]-intro koTrans-substitute0 {φ = φ ∧ ψ}{t} rewrite koTrans-substitute0 {φ = φ}{t} rewrite koTrans-substitute0 {φ = ψ}{t} = [≡]-intro koTrans-substitute0 {φ = φ ∨ ψ}{t} rewrite koTrans-substitute0 {φ = φ}{t} rewrite koTrans-substitute0 {φ = ψ}{t} = [≡]-intro koTrans-substitute0 {φ = φ ⟶ ψ}{t} rewrite koTrans-substitute0 {φ = φ}{t} rewrite koTrans-substitute0 {φ = ψ}{t} = [≡]-intro koTrans-substitute0 {φ = Ɐ φ}{t} = {!!} -- rewrite koTrans-substitute0 {φ = φ}{termVar𝐒 t} -- = [≡]-intro koTrans-substitute0 {φ = ∃ φ}{t} = {!!} -- rewrite koTrans-substitute0 {φ = φ}{termVar𝐒 t} -- = [≡]-intro -- 2.3.4 (ii) ggTrans-correctnessₗ : (Γ Classical.⊢ φ) ← (map ggTrans Γ ⊢ (ggTrans φ)) ggTrans-correctnessᵣ : (Γ Classical.⊢ φ) → (map ggTrans Γ ⊢ (ggTrans φ)) ggTrans-correctnessᵣ (Classical.direct p) = direct (Meta.[∃]-intro _ ⦃ Meta.[∧]-intro p [≡]-intro ⦄) ggTrans-correctnessᵣ (Classical.[⊤]-intro) = [⊤]-intro ggTrans-correctnessᵣ {Γ = Γ}{φ = φ} (Classical.[⊥]-elim p) = [⟶]-elim ([⟶]-intro(weaken{Γ₂ = (map ggTrans Γ) ∪ ·(ggTrans(¬ φ))} map-preserves-union-singleton (ggTrans-correctnessᵣ p))) ([¬¬]-elim-on-negativeFragment ggTrans-negativeFragment) ggTrans-correctnessᵣ (Classical.[∧]-intro p q) = [∧]-intro (ggTrans-correctnessᵣ p) (ggTrans-correctnessᵣ q) ggTrans-correctnessᵣ (Classical.[∧]-elimₗ p) = [∧]-elimₗ (ggTrans-correctnessᵣ p) ggTrans-correctnessᵣ (Classical.[∧]-elimᵣ p) = [∧]-elimᵣ (ggTrans-correctnessᵣ p) ggTrans-correctnessᵣ (Classical.[∨]-introₗ p) = [⟶]-elim (ggTrans-correctnessᵣ p) [∨]-introₗ-by-[¬¬∧¬] ggTrans-correctnessᵣ (Classical.[∨]-introᵣ p) = [⟶]-elim (ggTrans-correctnessᵣ p) [∨]-introᵣ-by-[¬¬∧¬] ggTrans-correctnessᵣ (Classical.[∨]-elim p q r) = [⟶]-elim₃ ([⟶]-intro(weaken map-preserves-union-singleton (ggTrans-correctnessᵣ p))) ([⟶]-intro(weaken map-preserves-union-singleton (ggTrans-correctnessᵣ q))) (ggTrans-correctnessᵣ r) ([∨]-elim-by-[¬¬∧¬] ([¬¬]-elim-on-negativeFragment ggTrans-negativeFragment)) ggTrans-correctnessᵣ (Classical.[⟶]-intro p) = [⟶]-intro (weaken map-preserves-union-singleton (ggTrans-correctnessᵣ p)) ggTrans-correctnessᵣ (Classical.[⟶]-elim p q) = [⟶]-elim (ggTrans-correctnessᵣ p) (ggTrans-correctnessᵣ q) ggTrans-correctnessᵣ (Classical.[Ɐ]-intro p) = [Ɐ]-intro (substitute₁(_ ⊢_) ggTrans-substitute0 (ggTrans-correctnessᵣ p)) ggTrans-correctnessᵣ (Classical.[Ɐ]-elim p) = substitute₁ₗ(_ ⊢_) ggTrans-substitute0 ([Ɐ]-elim (ggTrans-correctnessᵣ p)) ggTrans-correctnessᵣ (Classical.[∃]-intro p) = [⟶]-elim (substitute₁(_ ⊢_) ggTrans-substitute0 (ggTrans-correctnessᵣ p)) [∃]-intro-by-[¬Ɐ¬] ggTrans-correctnessᵣ (Classical.[∃]-elim p q) = [⟶]-elim ([⟶]-intro ([⟶]-elim ([Ɐ]-intro ([⟶]-intro ([⟶]-elim (weaken {!map-preserves-union-singleton!} (ggTrans-correctnessᵣ p)) (direct (Left (Right [≡]-intro)))))) (weaken-union (ggTrans-correctnessᵣ q)))) ([¬¬]-elim-on-negativeFragment ggTrans-negativeFragment) koTrans-stability : Stable{ℓ}(koTrans(φ)) koTrans-stability {φ = f $ x} = [¬¬¬]-elim koTrans-stability {φ = ⊤} = [⟶]-intro [⊤]-intro koTrans-stability {φ = ⊥} = [⟶]-intro ([⟶]-elim [⟶]-refl (direct (Right [≡]-intro))) koTrans-stability {φ = φ ∧ ψ} = [¬¬¬]-elim koTrans-stability {φ = φ ∨ ψ} = [¬¬¬]-elim koTrans-stability {φ = φ ⟶ ψ} = [¬¬¬]-elim koTrans-stability {φ = Ɐ φ} = [¬¬¬]-elim koTrans-stability {φ = ∃ φ} = [¬¬¬]-elim {- koTrans-to-[¬¬] : Γ ⊢ (koTrans(φ) ⟶ (¬¬ φ)) koTrans-to-[¬¬] {φ = f $ x} = [⟶]-refl koTrans-to-[¬¬] {φ = ⊤} = [¬¬]-intro-[⟶] koTrans-to-[¬¬] {φ = ⊥} = [¬¬]-intro-[⟶] koTrans-to-[¬¬] {φ = φ ∧ ψ} = [⟶]-intro ([⟷]-elimₗ ([⟶]-elim₃ koTrans-to-[¬¬] koTrans-to-[¬¬] {!!} [∧]-map) [¬¬]-preserve-[∧]) koTrans-to-[¬¬] {φ = φ ∨ ψ} = {!!} koTrans-to-[¬¬] {φ = φ ⟶ ψ} = {!!} koTrans-to-[¬¬] {φ = Ɐ φ} = {!!} koTrans-to-[¬¬] {φ = ∃ φ} = {!!} -} ggTrans-koTransₗ : Γ ⊢ ((ggTrans φ) ⟵ (koTrans φ)) ggTrans-koTransᵣ : Γ ⊢ ((ggTrans φ) ⟶ (koTrans φ)) [∧]-elimₗ-koTrans : (Γ ⊢ (koTrans(φ ∧ ψ) ⟶ koTrans(φ))) [∧]-elimₗ-koTrans = [⟶]-intro ([∧]-elimₗ ([⟶]-elim₃ koTrans-stability koTrans-stability ([⟷]-elimᵣ (direct (Right [≡]-intro)) [¬¬]-preserve-[∧]) [∧]-map)) [∧]-elimᵣ-koTrans : (Γ ⊢ (koTrans(φ ∧ ψ) ⟶ koTrans(ψ))) [∧]-elimᵣ-koTrans = [⟶]-intro ([∧]-elimᵣ ([⟶]-elim₃ koTrans-stability koTrans-stability ([⟷]-elimᵣ (direct (Right [≡]-intro)) [¬¬]-preserve-[∧]) [∧]-map)) -- [⟶]-elim-koTrans : (Γ ⊢ (koTrans(φ) ⟶ koTrans(φ ⟶ ψ) ⟶ koTrans(ψ))) -- [⟶]-intro ([⟶]-elim ([∧]-elimₗ ([⟷]-elimᵣ ([⟶]-intro-inverse {![¬¬]-intro-[⟶]!}) [¬¬]-preserve-[∧])) koTrans-stability) -- {![∧]-elimₗ(Meta.[↔]-to-[→] [¬¬][∧] Γφψ)!} -- [¬]-preserve-[∨][∧] : Γ ⊢ (¬(φ ∨ ψ) ⟷ ((¬ φ) ∧ (¬ ψ))) -- Alternative proof of the (_∧_)-case: -- [⟶]-intro ([∧]-intro -- ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∧]-elimₗ-koTrans) (weaken-union(ggTrans-koTransₗ {φ = φ}))) -- ([⟶]-elim ([⟶]-elim (direct (Right [≡]-intro)) [∧]-elimᵣ-koTrans) (weaken-union(ggTrans-koTransₗ {φ = ψ}))) -- ) ggTrans-koTransₗ {φ = P $ x} = [⟶]-refl ggTrans-koTransₗ {φ = ⊤} = [⟶]-refl ggTrans-koTransₗ {φ = ⊥} = [⟶]-refl ggTrans-koTransₗ {φ = φ ∧ ψ} = [⟶]-elim₃ ([⟶]-elim₂ ([⟷]-to-[⟶] [¬¬]-preserve-[∧]) ([⟶]-elim₂ koTrans-stability koTrans-stability [∧]-map) [⟶]-trans) [⟶]-refl ([⟶]-elim₂ (ggTrans-koTransₗ {φ = φ}) (ggTrans-koTransₗ {φ = ψ}) [∧]-map) [⟶]-map ggTrans-koTransₗ {φ = φ ∨ ψ} = [⟶]-elim₃ ([⟶]-elim ([⟷]-to-[⟵] [¬]-preserve-[∨][∧]) [⟶]-contrapositiveᵣ) [⟶]-refl ([⟶]-elim ([⟶]-elim₂ ([⟶]-elim (ggTrans-koTransₗ {φ = φ}) [¬]-map) ([⟶]-elim (ggTrans-koTransₗ {φ = ψ}) [¬]-map) [∧]-map) [¬]-map) [⟶]-map ggTrans-koTransₗ {φ = φ ⟶ ψ} = [⟶]-elim₃ (([⟶]-elim₂ [¬¬]-preserve-[⟶] ([⟶]-elim₂ [¬¬]-intro-[⟶] koTrans-stability [⟶]-map) [⟶]-trans)) [⟶]-refl (([⟶]-elim₂ (ggTrans-koTransᵣ {φ = φ}) (ggTrans-koTransₗ {φ = ψ}) [⟶]-map)) [⟶]-map ggTrans-koTransₗ {Γ = Γ}{φ = Ɐ φ} = [⟶]-elim₃ ([⟶]-elim₂ [¬¬]-preserve-[Ɐ] ([⟶]-elim ([Ɐ]-intro (substitute₁(\φ → Γ ⊢ ((¬¬ φ) ⟶ φ)) koTrans-substitute0 koTrans-stability)) ([Ɐ]-map {φ₂ = koTrans φ})) [⟶]-trans) [⟶]-refl ([⟶]-elim ([Ɐ]-intro (substitute₂(\a b → Γ ⊢ (a ⟵ b)) ggTrans-substitute0 koTrans-substitute0 (ggTrans-koTransₗ {φ = substitute0 _ φ}))) [Ɐ]-map) [⟶]-map ggTrans-koTransₗ {φ = ∃ φ} = [⟶]-elim₃ ([⟶]-elim ([⟷]-to-[⟵] [¬]-preserve-[∃][Ɐ]) [⟶]-contrapositiveᵣ) [⟶]-refl ([⟶]-elim ([⟶]-elim ([Ɐ]-intro ([⟶]-elim (substitute₂(\a b → _ ⊢ (a ⟵ b)) ggTrans-substitute0 koTrans-substitute0 (ggTrans-koTransₗ {φ = substitute0 _ φ})) [¬]-map)) [Ɐ]-map) [¬]-map) [⟶]-map ggTrans-koTransᵣ {φ = P $ x} = [⟶]-refl ggTrans-koTransᵣ {φ = ⊤} = [⟶]-refl ggTrans-koTransᵣ {φ = ⊥} = [⟶]-refl ggTrans-koTransᵣ {φ = φ ∧ ψ} = [⟶]-intro ([¬¬]-intro ([∧]-intro ([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) (weaken-union(ggTrans-koTransᵣ {φ = φ}))) ([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) (weaken-union(ggTrans-koTransᵣ {φ = ψ}))) )) ggTrans-koTransᵣ {φ = φ ∨ ψ} = [⟶]-intro ([¬¬]-intro ([⟶]-elim₃ {!!} {!!} {!direct (Right [≡]-intro)!} ([∨]-elim-by-[¬¬∧¬] {!koTrans-stability!}) )) ggTrans-koTransᵣ {φ = φ ⟶ ψ} = [⟶]-intro ([¬¬]-intro ([⟶]-intro ([⟶]-elim ([⟶]-elim ([⟵]-elim (direct (Right [≡]-intro)) (weaken-union(weaken-union(ggTrans-koTransₗ {φ = φ})))) (direct (Left (Right [≡]-intro)))) (weaken-union(weaken-union(ggTrans-koTransᵣ {φ = ψ}))) ) )) ggTrans-koTransᵣ {φ = Ɐ φ} = {!!} ggTrans-koTransᵣ {φ = ∃ φ} = {!!}
{ "alphanum_fraction": 0.5416272842, "avg_line_length": 53.1213389121, "ext": "agda", "hexsha": "53987dfcaf3772c7d420c46e5b7014f60d1ba6fb", "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": "Formalization/PredicateLogic/Minimal/NaturalDeduction/NegativeTranslations.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": "Formalization/PredicateLogic/Minimal/NaturalDeduction/NegativeTranslations.agda", "max_line_length": 409, "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": "Formalization/PredicateLogic/Minimal/NaturalDeduction/NegativeTranslations.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": 11733, "size": 25392 }
module Cats.Category where open import Level import Cats.Category.Base as Base import Cats.Category.Constructions.CCC as CCC import Cats.Category.Constructions.Epi as Epi import Cats.Category.Constructions.Equalizer as Equalizer import Cats.Category.Constructions.Exponential as Exponential import Cats.Category.Constructions.Iso as Iso import Cats.Category.Constructions.Initial as Initial import Cats.Category.Constructions.Mono as Mono import Cats.Category.Constructions.Product as Product import Cats.Category.Constructions.Terminal as Terminal import Cats.Category.Constructions.Unique as Unique Category : ∀ lo la l≈ → Set (suc (lo ⊔ la ⊔ l≈)) Category = Base.Category module Category {lo la l≈} (Cat : Base.Category lo la l≈) where open Base.Category Cat public open Epi.Build Cat public open Equalizer.Build Cat public open Exponential.Build Cat public open Initial.Build Cat public open Iso.Build Cat public open Mono.Build Cat public open Product.Build Cat public open Terminal.Build Cat public open Unique.Build Cat public open CCC public using (IsCCC) open Exponential public using (HasExponentials) open Initial public using (HasInitial) open Product public using ( HasProducts ; HasBinaryProducts ; HasFiniteProducts ; HasProducts→HasBinaryProducts ; HasProducts→HasTerminal ) open Terminal public using (HasTerminal)
{ "alphanum_fraction": 0.8032187271, "avg_line_length": 31.0681818182, "ext": "agda", "hexsha": "b429b8df36c11bce174b4dc51a1f060b5b9e0670", "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.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.agda", "max_line_length": 63, "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.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 310, "size": 1367 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.Multivariate.Equiv.Comp-Poly where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_) open import Cubical.Data.Vec open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Polynomials.Univariate.Base open import Cubical.Algebra.Polynomials.Multivariate.Base open import Cubical.Algebra.Polynomials.Multivariate.Properties open import Cubical.Algebra.CommRing.Instances.MultivariatePoly private variable ℓ ℓ' : Level module Comp-Poly-nm (A' : CommRing ℓ) (n m : ℕ) where private A = fst A' open CommRingStr (snd A') module Mr = Nth-Poly-structure A' m module N+Mr = Nth-Poly-structure A' (n +n m) module N∘Mr = Nth-Poly-structure (PolyCommRing A' m) n ----------------------------------------------------------------------------- -- direct sens N∘M→N+M-b : (v : Vec ℕ n) → Poly A' m → Poly A' (n +n m) N∘M→N+M-b v = Poly-Rec-Set.f A' m (Poly A' (n +n m)) trunc 0P (λ v' a → base (v ++ v') a) _Poly+_ Poly+-assoc Poly+-Rid Poly+-comm (λ v' → base-0P (v ++ v')) (λ v' a b → base-Poly+ (v ++ v') a b) N∘M→N+M : Poly (PolyCommRing A' m) n → Poly A' (n +n m) N∘M→N+M = Poly-Rec-Set.f (PolyCommRing A' m) n (Poly A' (n +n m)) trunc 0P N∘M→N+M-b _Poly+_ Poly+-assoc Poly+-Rid Poly+-comm (λ _ → refl) (λ v a b → refl) -- ----------------------------------------------------------------------------- -- -- Converse sens N+M→N∘M : Poly A' (n +n m) → Poly (PolyCommRing A' m) n N+M→N∘M = Poly-Rec-Set.f A' (n +n m) (Poly (PolyCommRing A' m) n) trunc 0P (λ v a → let v , v' = sep-vec n m v in base v (base v' a)) _Poly+_ Poly+-assoc Poly+-Rid Poly+-comm (λ v → (cong (base (fst (sep-vec n m v))) (base-0P (snd (sep-vec n m v)))) ∙ (base-0P (fst (sep-vec n m v)))) λ v a b → base-Poly+ (fst (sep-vec n m v)) (base (snd (sep-vec n m v)) a) (base (snd (sep-vec n m v)) b) ∙ cong (base (fst (sep-vec n m v))) (base-Poly+ (snd (sep-vec n m v)) a b) ----------------------------------------------------------------------------- -- Section e-sect : (P : Poly A' (n +n m)) → N∘M→N+M (N+M→N∘M P) ≡ P e-sect = Poly-Ind-Prop.f A' (n +n m) (λ P → N∘M→N+M (N+M→N∘M P) ≡ P) (λ _ → trunc _ _) refl (λ v a → cong (λ X → base X a) (sep-vec-id n m v)) (λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V) ----------------------------------------------------------------------------- -- Retraction e-retr : (P : Poly (PolyCommRing A' m) n) → N+M→N∘M (N∘M→N+M P) ≡ P e-retr = Poly-Ind-Prop.f (PolyCommRing A' m) n (λ P → N+M→N∘M (N∘M→N+M P) ≡ P) (λ _ → trunc _ _) refl (λ v → Poly-Ind-Prop.f A' m (λ P → N+M→N∘M (N∘M→N+M (base v P)) ≡ base v P) (λ _ → trunc _ _) (sym (base-0P v)) (λ v' a → cong₂ base (sep-vec-fst n m v v') (cong (λ X → base X a) (sep-vec-snd n m v v'))) (λ {U V} ind-U ind-V → (cong₂ _Poly+_ ind-U ind-V) ∙ (base-Poly+ v U V))) (λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V ) ----------------------------------------------------------------------------- -- Morphism of ring map-0P : N∘M→N+M (0P) ≡ 0P map-0P = refl N∘M→N+M-gmorph : (P Q : Poly (PolyCommRing A' m) n) → N∘M→N+M ( P Poly+ Q) ≡ N∘M→N+M P Poly+ N∘M→N+M Q N∘M→N+M-gmorph = λ P Q → refl map-1P : N∘M→N+M (N∘Mr.1P) ≡ N+Mr.1P map-1P = cong (λ X → base X 1r) (rep-concat n m 0 ) N∘M→N+M-rmorph : (P Q : Poly (PolyCommRing A' m) n) → N∘M→N+M ( P N∘Mr.Poly* Q) ≡ N∘M→N+M P N+Mr.Poly* N∘M→N+M Q N∘M→N+M-rmorph = -- Ind P Poly-Ind-Prop.f (PolyCommRing A' m) n (λ P → (Q : Poly (PolyCommRing A' m) n) → N∘M→N+M (P N∘Mr.Poly* Q) ≡ (N∘M→N+M P N+Mr.Poly* N∘M→N+M Q)) (λ P p q i Q j → trunc _ _ (p Q) (q Q) i j) (λ Q → refl) (λ v → -- Ind Base P Poly-Ind-Prop.f A' m (λ P → (Q : Poly (PolyCommRing A' m) n) → N∘M→N+M (base v P N∘Mr.Poly* Q) ≡ (N∘M→N+M (base v P) N+Mr.Poly* N∘M→N+M Q)) (λ P p q i Q j → trunc _ _ (p Q) (q Q) i j) (λ Q → cong (λ X → N∘M→N+M (X N∘Mr.Poly* Q)) (base-0P v)) (λ v' a → -- Ind Q Poly-Ind-Prop.f (PolyCommRing A' m) n (λ Q → N∘M→N+M (base v (base v' a) N∘Mr.Poly* Q) ≡ (N∘M→N+M (base v (base v' a)) N+Mr.Poly* N∘M→N+M Q)) (λ _ → trunc _ _) (sym (N+Mr.0PRightAnnihilatesPoly (N∘M→N+M (base v (base v' a))))) (λ w → -- Ind base Q Poly-Ind-Prop.f A' m _ (λ _ → trunc _ _) (sym (N+Mr.0PRightAnnihilatesPoly (N∘M→N+M (base v (base v' a))))) (λ w' b → cong (λ X → base X (a · b)) (+n-vec-concat n m v w v' w')) λ {U V} ind-U ind-V → cong (λ X → N∘M→N+M (base v (base v' a) N∘Mr.Poly* X)) (sym (base-Poly+ w U V)) ∙ cong₂ (_Poly+_ ) ind-U ind-V ∙ sym (cong (λ X → N∘M→N+M (base v (base v' a)) N+Mr.Poly* N∘M→N+M X) (base-Poly+ w U V)) ) -- End Ind base Q λ {U V} ind-U ind-V → cong₂ _Poly+_ ind-U ind-V) -- End Ind Q λ {U V} ind-U ind-V Q → cong (λ X → N∘M→N+M (X N∘Mr.Poly* Q)) (sym (base-Poly+ v U V)) ∙ cong₂ _Poly+_ (ind-U Q) (ind-V Q) ∙ sym (cong (λ X → (N∘M→N+M X) N+Mr.Poly* (N∘M→N+M Q)) (sym (base-Poly+ v U V)) )) -- End Ind base P λ {U V} ind-U ind-V Q → cong₂ _Poly+_ (ind-U Q) (ind-V Q) -- End Ind P ----------------------------------------------------------------------------- -- Ring Equivalence module _ (A' : CommRing ℓ) (n m : ℕ) where open Comp-Poly-nm A' n m CRE-PolyN∘M-PolyN+M : CommRingEquiv (PolyCommRing (PolyCommRing A' m) n) (PolyCommRing A' (n +n m)) fst CRE-PolyN∘M-PolyN+M = isoToEquiv is where is : Iso _ _ Iso.fun is = N∘M→N+M Iso.inv is = N+M→N∘M Iso.rightInv is = e-sect Iso.leftInv is = e-retr snd CRE-PolyN∘M-PolyN+M = makeIsRingHom map-1P N∘M→N+M-gmorph N∘M→N+M-rmorph
{ "alphanum_fraction": 0.442386231, "avg_line_length": 40.0935672515, "ext": "agda", "hexsha": "387dd55b5b46723697f5ef166c9f7f649b577c1c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Comp-Poly.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Comp-Poly.agda", "max_line_length": 144, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Equiv/Comp-Poly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2525, "size": 6856 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties -- module directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Star.Properties where open import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties public {-# WARNING_ON_IMPORT "Data.Star.Properties was deprecated in v0.16. Use Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties instead." #-}
{ "alphanum_fraction": 0.6028938907, "avg_line_length": 31.1, "ext": "agda", "hexsha": "30b4deb8614d4174e9bfb69d2080e0568687301c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Star/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Star/Properties.agda", "max_line_length": 78, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Star/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 110, "size": 622 }
------------------------------------------------------------------------ -- The "always true" predicate, □ ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Delay-monad.Sized.Always where open import Prelude open import Prelude.Size open import Delay-monad.Sized open import Delay-monad.Sized.Monad -- The "always true" predicate, □. mutual data □ {a p} {A : Size → Type a} (i : Size) (P : A ∞ → Type p) : Delay A ∞ → Type (a ⊔ p) where now : ∀ {x} → P x → □ i P (now x) later : ∀ {x} → □′ i P (force x) → □ i P (later x) record □′ {a p} {A : Size → Type a} (i : Size) (P : A ∞ → Type p) (x : Delay A ∞) : Type (a ⊔ p) where coinductive field force : {j : Size< i} → □ j P x open □′ public -- □ is closed, in a certain sense, under bind. □->>= : ∀ {i a b p q} {A : Size → Type a} {B : Size → Type b} {P : A ∞ → Type p} {Q : B ∞ → Type q} {x : Delay A ∞} {f : ∀ {i} → A i → Delay B i} → □ i P x → (∀ {x} → P x → □ i Q (f x)) → □ i Q (x >>= f) □->>= (now P-x) □-f = □-f P-x □->>= (later □-x) □-f = later λ { .force → □->>= (force □-x) □-f }
{ "alphanum_fraction": 0.4214103653, "avg_line_length": 28.0238095238, "ext": "agda", "hexsha": "ee3dcdc0f1b4335131bf78d9331e20acf7b30855", "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": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/delay-monad", "max_forks_repo_path": "src/Delay-monad/Sized/Always.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "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/delay-monad", "max_issues_repo_path": "src/Delay-monad/Sized/Always.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/delay-monad", "max_stars_repo_path": "src/Delay-monad/Sized/Always.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 433, "size": 1177 }
open import Prelude open import Level using (_⊔_; Lift; lift) renaming (suc to ls; zero to lz) open import Data.String using (String) open import Data.Maybe using (Maybe; nothing; just) open import Data.Nat using (_≤_) module RW.Data.RTrie.Insert where open import Relation.Binary.PropositionalEquality using (inspect; [_]) open import RW.Data.RTrie.Decl import RW.Data.PMap (RTermᵢ ⊥) as IdxMap import RW.Data.PMap ℕ as ℕmap postulate trie-err : ∀{a}{A : Set a} → String → A open import RW.Utils.Monads open Monad {{...}} open Eq {{...}} I : ∀{a} → Set a → Set a I {a} = STₐ {lz} {a} (Σ ℕ (λ _ → Maybe ℕ)) _<$>_ : ∀{a}{A B : Set a} → (A → B) → I A → I B f <$> ix = ix >>= (return ∘ f) -------------------- -- Monadic boilerplate private getLbl : I (Maybe ℕ) getLbl = getₐ >>= return ∘ p2 putLbl : ℕ → I Unit putLbl n = getₐ >>= λ x → putₐ (p1 x , just n) getCount : I ℕ getCount = p1 <$> getₐ putCount : ℕ → I Unit putCount x = getLbl >>= putₐ ∘ (_,_ x) ++count : I ℕ ++count = getCount <>= (putCount ∘ suc) CellCtx : Set _ CellCtx = RTrie → Cell singleton : ∀{a}{A : Set a} → A → List A singleton x = x ∷ [] applyBRule : Rule → ℕ → Maybe ℕ applyBRule (Tr m n) k with m ≟-ℕ k ...| yes _ = just n ...| no _ = nothing applyBRule _ _ = nothing -- |Makes a new rule *without* checking anything. -- If the current label is nothing, returns a Gather -- If the current label is a (just l), return a Tr l. -- -- Changes the state to the newly created label. makeRule : I Rule makeRule = getLbl >>= λ l → (++count <>= putLbl) -- increments the counter and set's it. >>= λ c′ → return $ maybe (flip Tr c′) (Gr c′) l -- |Given a list of rules, which arise from we reaching -- either a leaf node or a previously bound symbol, -- will apply one of such rules or create a new one. -- -- In any case, this will change the current label either -- to a fresh one or by a transition in the list. handleRules : List Rule → I (List Rule) handleRules rs = getLbl >>= maybe (flip l≡just rs) (l≡nothing rs) where l≡just : ℕ → List Rule → I (List Rule) l≡just l [] = singleton <$> makeRule l≡just l (r ∷ rs) with applyBRule r l ...| just l′ = putLbl l′ >> return (r ∷ rs) ...| nothing = (_∷_ r) <$> l≡just l rs l≡nothing : List Rule → I (List Rule) l≡nothing [] = singleton <$> makeRule l≡nothing ((Gr k) ∷ rs) = putLbl k >> return ((Gr k) ∷ rs) l≡nothing (r ∷ rs) = _∷_ r <$> l≡nothing rs -- |Given a cell and a NON-BINDING index, mIdx takes care -- of finding the trie we need to keep traversing and -- creating a reconstruction function, for when we -- finish modifying the mentioned trie. mIdx : Cell → RTermᵢ ⊥ → I (CellCtx × RTrie) -- In the case we are inserting a ivarᵢ, we are going to merge the new btrie, -- which is going to be a leaf (TODO: why?), in the default branch. mIdx ((d , mh) , bs) (ivarᵢ _) = return $ (λ bt → (merge d bt , mh) , bs) , BTrieEmpty where merge : RTrie → RTrie → RTrie merge (Leaf as) (Leaf bs) = Leaf (as ++ bs) merge _ bt = bt -- For the more general case, if tid ∉ mh, we add and entry (tid ↦ empty). -- After, we return mh(tid) and the context that modifies this exact entry. mIdx ((d , mh) , bs) tid = let mh′ , prf = IdxMap.alterPrf BTrieEmpty tid mh in return $ (λ f → (d , IdxMap.insert tid f mh) , bs) , (IdxMap.lkup' tid mh′ prf) -- |When we find a binding symbol, however, things can be a bit more tricky. -- This symbol is either registered, in which case we just add a fresh -- rule to it, or it is not registered in the map, where we add it with -- a fresh rule. mSym : Cell → ℕ → I (CellCtx × RTrie) mSym (mh , bs) tsym with ℕmap.lkup tsym bs ...| nothing = makeRule >>= λ r → return (const (mh , (tsym , r ∷ []) ∷ bs) , BTrieEmpty) ...| just rs = handleRules rs >>= λ r → return (const (mh , ℕmap.insert tsym r bs) , BTrieEmpty) -- |𝑴 chooses which traversal function to use. 𝑴 : {A : Set}{{enA : Enum A}} → Cell → RTermᵢ A → I (CellCtx × RTrie) 𝑴 {{enum aℕ _}} c tid with toSymbol tid | inspect toSymbol tid ...| nothing | [ prf ] = mIdx c (idx-cast tid prf) ...| just s | _ = maybe (mSym c) enum-err (aℕ s) where postulate enum-err : I (CellCtx × RTrie) -- |Insertion of an (opened) term in a cell. Returns the altered cell. mutual insCell* : {A : Set}{{enA : Enum A}} → List (RTerm A) → List Cell → I (List Cell) insCell* [] _ = return [] insCell* _ [] = return [] insCell* (t ∷ ts) (b ∷ bs) = insCell (out t) b >>= λ b′ → (_∷_ b′) <$> insCell* ts bs -- Variation of insCell*, assuming we're always adding to empty cells. insCell*ε : {A : Set}{{enA : Enum A}} → List (RTerm A) → I (List Cell) insCell*ε [] = return [] insCell*ε (t ∷ ts) = insCell (out t) ((Leaf [] , IdxMap.empty) , []) >>= λ b → (_∷_ b) <$> insCell*ε ts {-# TERMINATING #-} insCell : {A : Set}{{enA : Enum A}} → RTermᵢ A × List (RTerm A) → Cell → I Cell insCell (tid , tr) cell = 𝑴 cell tid >>= λ { (c , bt) → insCellAux tid tr bt >>= return ∘ c } where -- Note how if tid is a binding symbol, we don't do anything. That's -- because 𝑴 already took care of adding the rules in the correct place for us. tr≡[] : {A : Set}{{enA : Enum A}} → RTermᵢ A → I RTrie tr≡[] tid with toSymbol tid ...| nothing = (Leaf ∘ singleton) <$> makeRule ...| _ = return $ Fork [] insCellAux : {A : Set}{{enA : Enum A}} → RTermᵢ A → List (RTerm A) → RTrie → I RTrie -- Inserting in a Leaf is impossible... insCellAux tid _ (Leaf r) = return (Leaf r) -- If we don't have recursive arguments in the term beeing inserted, -- we follow by tr≡[] insCellAux tid [] _ = tr≡[] tid -- Otherwise we simply add our recursive arguments. insCellAux tid tr (Fork []) = Fork <$> insCell*ε tr insCellAux tid tr (Fork ms) = Fork <$> insCell* tr ms -- |Insertion has to begin in a 1-cell fork. -- This gives some intuition that BTries should contain an arity, somewhere in their type. ins : {A : Set}{{enA : Enum A}} → RTerm A → RTrie → I RTrie ins t (Fork (cell ∷ [])) = (Fork ∘ singleton) <$> insCell (out t) cell ins t (Fork []) = (Fork ∘ singleton) <$> insCell (out t) ((Leaf [] , IdxMap.empty) , []) ins t _ = trie-err "Insertion has to begin in a 1-cell fork" -- Interfacing {-# TERMINATING #-} insertTerm : {A : Set}{{enA : Enum A}} → Name → RTerm A → (ℕ × RTrie) → (ℕ × RTrie) insertTerm d term (n , Leaf r) = trie-err "Can't insert in a leaf" insertTerm d term (n , bt) = let bt′ , n′ , lbl = STₐ.run (ins term bt) (n + 1 , nothing) in maybe′ (λ l′ → l′ , substΣ l′ d bt′) (trie-err "empty final lbl") lbl where open import Data.Maybe using (maybe′) -- Substitution boilerplate. sR : ℕ → Name → Rule → Rule sR k c (Tr m n) with n ≟-ℕ k ...| yes _ = Fr m c ...| no _ = Tr m n sR _ _ r = r mutual sC : ℕ → Name → Cell → Cell sC k c ((d , mh) , bs) = (substΣ k c d , IdxMap.map (substΣ k c) mh) , ℕmap.map (Prelude.map (sR k c)) bs substΣ : ℕ → Name → RTrie → RTrie substΣ k c (Leaf rs) = Leaf (Prelude.map (sR k c) rs) substΣ k c (Fork ms) = Fork (Prelude.map (sC k c) ms)
{ "alphanum_fraction": 0.5489151123, "avg_line_length": 35.8227272727, "ext": "agda", "hexsha": "601e17903dfe812bae80c7e91a38013954ab80d2", "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": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Data/RTrie/Insert.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Data/RTrie/Insert.agda", "max_line_length": 93, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Data/RTrie/Insert.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 2608, "size": 7881 }
-- Andreas, 2020-03-18, issue 4518, reported by strangeglyph -- Better error message when parsing of LHS fails open import Agda.Builtin.Nat using (Nat) -- forgot to import constructors postulate foo : Nat test : Set₁ test with foo ... | zero = Set ... | suc n = Set -- ERROR: -- Could not parse the left-hand side test | suc n -- NEW INFORMATION: -- Problematic expression: (suc n)
{ "alphanum_fraction": 0.6948717949, "avg_line_length": 20.5263157895, "ext": "agda", "hexsha": "a864bdea6464f9af3371931d10e78bf69b6571c1", "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/Fail/Issue4518.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue4518.agda", "max_line_length": 73, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue4518.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": 112, "size": 390 }
{-# OPTIONS --without-K --exact-split #-} module abelian-subgroups where import abelian-groups import subgroups open abelian-groups public open subgroups public {- Subsets of abelian groups -} subset-Ab : (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1) subset-Ab l A = subset-Group l (group-Ab A) is-set-subset-Ab : (l : Level) {l1 : Level} (A : Ab l1) → is-set (subset-Ab l A) is-set-subset-Ab l A = is-set-subset-Group l (group-Ab A) {- Defining subgroups -} contains-zero-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU l2 contains-zero-subset-Ab A = contains-unit-subset-Group (group-Ab A) is-prop-contains-zero-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → is-prop (contains-zero-subset-Ab A P) is-prop-contains-zero-subset-Ab A = is-prop-contains-unit-subset-Group (group-Ab A) closed-under-add-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2) closed-under-add-subset-Ab A = closed-under-mul-subset-Group (group-Ab A) is-prop-closed-under-add-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → is-prop (closed-under-add-subset-Ab A P) is-prop-closed-under-add-subset-Ab A = is-prop-closed-under-mul-subset-Group (group-Ab A) closed-under-neg-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2) closed-under-neg-subset-Ab A = closed-under-inv-subset-Group (group-Ab A) is-prop-closed-under-neg-subset-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → is-prop (closed-under-neg-subset-Ab A P) is-prop-closed-under-neg-subset-Ab A = is-prop-closed-under-inv-subset-Group (group-Ab A) is-subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → UU (l1 ⊔ l2) is-subgroup-Ab A = is-subgroup-Group (group-Ab A) is-prop-is-subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : subset-Ab l2 A) → is-prop (is-subgroup-Ab A P) is-prop-is-subgroup-Ab A = is-prop-is-subgroup-Group (group-Ab A) {- Introducing the type of all subgroups of a group G -} Subgroup-Ab : (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1) Subgroup-Ab l A = Subgroup l (group-Ab A) subset-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) → ( Subgroup-Ab l2 A) → ( subset-Ab l2 A) subset-Subgroup-Ab A = subset-Subgroup (group-Ab A) is-emb-subset-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) → is-emb (subset-Subgroup-Ab {l2 = l2} A) is-emb-subset-Subgroup-Ab A = is-emb-subset-Subgroup (group-Ab A) type-subset-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → (type-Ab A → UU l2) type-subset-Subgroup-Ab A = type-subset-Subgroup (group-Ab A) is-prop-type-subset-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → (x : type-Ab A) → is-prop (type-subset-Subgroup-Ab A P x) is-prop-type-subset-Subgroup-Ab A = is-prop-type-subset-Subgroup (group-Ab A) is-subgroup-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → is-subgroup-Ab A (subset-Subgroup-Ab A P) is-subgroup-Subgroup-Ab A = is-subgroup-Subgroup (group-Ab A) contains-zero-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → contains-zero-subset-Ab A (subset-Subgroup-Ab A P) contains-zero-Subgroup-Ab A = contains-unit-Subgroup (group-Ab A) closed-under-add-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → closed-under-add-subset-Ab A (subset-Subgroup-Ab A P) closed-under-add-Subgroup-Ab A = closed-under-mul-Subgroup (group-Ab A) closed-under-neg-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → closed-under-neg-subset-Ab A (subset-Subgroup-Ab A P) closed-under-neg-Subgroup-Ab A = closed-under-inv-Subgroup (group-Ab A) {- Given a subgroup of an abelian group, we construct an abelian group -} type-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → UU (l1 ⊔ l2) type-ab-Subgroup-Ab A = type-group-Subgroup (group-Ab A) incl-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → type-ab-Subgroup-Ab A P → type-Ab A incl-ab-Subgroup-Ab A = incl-group-Subgroup (group-Ab A) is-emb-incl-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → is-emb (incl-ab-Subgroup-Ab A P) is-emb-incl-ab-Subgroup-Ab A = is-emb-incl-group-Subgroup (group-Ab A) eq-subgroup-ab-eq-ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → {x y : type-ab-Subgroup-Ab A P} → Id (incl-ab-Subgroup-Ab A P x) (incl-ab-Subgroup-Ab A P y) → Id x y eq-subgroup-ab-eq-ab A = eq-subgroup-eq-group (group-Ab A) set-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) → Subgroup-Ab l2 A → UU-Set (l1 ⊔ l2) set-ab-Subgroup-Ab A = set-group-Subgroup (group-Ab A) zero-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → type-ab-Subgroup-Ab A P zero-ab-Subgroup-Ab A = unit-group-Subgroup (group-Ab A) add-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x y : type-ab-Subgroup-Ab A P) → type-ab-Subgroup-Ab A P add-ab-Subgroup-Ab A = mul-group-Subgroup (group-Ab A) neg-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → type-ab-Subgroup-Ab A P → type-ab-Subgroup-Ab A P neg-ab-Subgroup-Ab A = inv-group-Subgroup (group-Ab A) is-associative-add-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x y z : type-ab-Subgroup-Ab A P) → Id (add-ab-Subgroup-Ab A P (add-ab-Subgroup-Ab A P x y) z) (add-ab-Subgroup-Ab A P x (add-ab-Subgroup-Ab A P y z)) is-associative-add-ab-Subgroup-Ab A = is-associative-mul-group-Subgroup (group-Ab A) left-zero-law-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x : type-ab-Subgroup-Ab A P) → Id (add-ab-Subgroup-Ab A P (zero-ab-Subgroup-Ab A P) x) x left-zero-law-ab-Subgroup-Ab A = left-unit-law-group-Subgroup (group-Ab A) right-zero-law-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x : type-ab-Subgroup-Ab A P) → Id (add-ab-Subgroup-Ab A P x (zero-ab-Subgroup-Ab A P)) x right-zero-law-ab-Subgroup-Ab A = right-unit-law-group-Subgroup (group-Ab A) left-neg-law-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x : type-ab-Subgroup-Ab A P) → Id ( add-ab-Subgroup-Ab A P (neg-ab-Subgroup-Ab A P x) x) ( zero-ab-Subgroup-Ab A P) left-neg-law-ab-Subgroup-Ab A = left-inverse-law-group-Subgroup (group-Ab A) right-neg-law-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x : type-ab-Subgroup-Ab A P) → Id ( add-ab-Subgroup-Ab A P x (neg-ab-Subgroup-Ab A P x)) ( zero-ab-Subgroup-Ab A P) right-neg-law-ab-Subgroup-Ab A = right-inverse-law-group-Subgroup (group-Ab A) is-commutative-add-ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → ( x y : type-ab-Subgroup-Ab A P) → Id ( add-ab-Subgroup-Ab A P x y) (add-ab-Subgroup-Ab A P y x) is-commutative-add-ab-Subgroup-Ab A P (pair x p) (pair y q) = eq-subgroup-ab-eq-ab A P (is-commutative-add-Ab A x y) ab-Subgroup-Ab : {l1 l2 : Level} (A : Ab l1) → Subgroup-Ab l2 A → Ab (l1 ⊔ l2) ab-Subgroup-Ab A P = pair (group-Subgroup (group-Ab A) P) (is-commutative-add-ab-Subgroup-Ab A P) {- We show that the inclusion from ab-Subgroup-Ab A P → A is a group homomorphism -} preserves-add-incl-ab-Subgroup-Ab : { l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → preserves-add (ab-Subgroup-Ab A P) A (incl-ab-Subgroup-Ab A P) preserves-add-incl-ab-Subgroup-Ab A = preserves-mul-incl-group-Subgroup (group-Ab A) hom-ab-Subgroup-Ab : { l1 l2 : Level} (A : Ab l1) (P : Subgroup-Ab l2 A) → hom-Ab (ab-Subgroup-Ab A P) A hom-ab-Subgroup-Ab A = hom-group-Subgroup (group-Ab A) {- We define another type of subgroups of A as the type of group inclusions -} emb-Ab : { l1 l2 : Level} (A : Ab l1) (B : Ab l2) → UU (l1 ⊔ l2) emb-Ab A B = emb-Group (group-Ab A) (group-Ab B) emb-Ab-Slice : (l : Level) {l1 : Level} (A : Ab l1) → UU ((lsuc l) ⊔ l1) emb-Ab-Slice l A = emb-Group-Slice l (group-Ab A) emb-ab-slice-Subgroup-Ab : { l1 l2 : Level} (A : Ab l1) → Subgroup-Ab l2 A → emb-Ab-Slice (l1 ⊔ l2) A emb-ab-slice-Subgroup-Ab A = emb-group-slice-Subgroup (group-Ab A)
{ "alphanum_fraction": 0.6455665025, "avg_line_length": 35.6140350877, "ext": "agda", "hexsha": "53dcabfb8484fe79464ad82826ff837d764e9e5c", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/abelian-subgroups.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/abelian-subgroups.agda", "max_line_length": 78, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/abelian-subgroups.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 3273, "size": 8120 }