Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Pi
module lib.types.Group where
record GroupStructure {i} (El : Type i) --(El-level : has-level 0 El)
: Type i where
constructor group-structure
field
ident : El
inv : El → El
comp : El → El → El
unitl : ∀ a → comp ident a == a
unitr : ∀ a → comp a ident == a
assoc : ∀ a b c → comp (comp a b) c == comp a (comp b c)
invl : ∀ a → (comp (inv a) a) == ident
invr : ∀ a → (comp a (inv a)) == ident
record Group i : Type (lsucc i) where
constructor group
field
El : Type i
El-level : has-level 0 El
group-struct : GroupStructure El
open GroupStructure group-struct public
⊙El : Σ (Type i) (λ A → A)
⊙El = (El , ident)
Group₀ : Type (lsucc lzero)
Group₀ = Group lzero
is-abelian : ∀ {i} → Group i → Type i
is-abelian G = (a b : Group.El G) → Group.comp G a b == Group.comp G b a
module _ where
open GroupStructure
abstract
group-structure= : ∀ {i} {A : Type i} (pA : has-level 0 A)
{id₁ id₂ : A} {inv₁ inv₂ : A → A} {comp₁ comp₂ : A → A → A}
→ ∀ {unitl₁ unitl₂} → ∀ {unitr₁ unitr₂} → ∀ {assoc₁ assoc₂}
→ ∀ {invr₁ invr₂} → ∀ {invl₁ invl₂}
→ (id₁ == id₂) → (inv₁ == inv₂) → (comp₁ == comp₂)
→ Path {A = GroupStructure A}
(group-structure id₁ inv₁ comp₁ unitl₁ unitr₁ assoc₁ invl₁ invr₁)
(group-structure id₂ inv₂ comp₂ unitl₂ unitr₂ assoc₂ invl₂ invr₂)
group-structure= pA {id₁ = id₁} {inv₁ = inv₁} {comp₁ = comp₁} idp idp idp =
ap5 (group-structure id₁ inv₁ comp₁)
(prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)
(prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)
(prop-has-all-paths
(Π-level (λ _ → Π-level (λ _ → Π-level (λ _ → pA _ _)))) _ _)
(prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)
(prop-has-all-paths (Π-level (λ _ → pA _ _)) _ _)
where
ap5 : ∀ {j} {C D E F G H : Type j}
{c₁ c₂ : C} {d₁ d₂ : D} {e₁ e₂ : E} {f₁ f₂ : F} {g₁ g₂ : G}
(f : C → D → E → F → G → H)
→ (c₁ == c₂) → (d₁ == d₂) → (e₁ == e₂) → (f₁ == f₂) → (g₁ == g₂)
→ f c₁ d₁ e₁ f₁ g₁ == f c₂ d₂ e₂ f₂ g₂
ap5 f idp idp idp idp idp = idp
↓-group-structure= : ∀ {i} {A B : Type i}
(A-level : has-level 0 A)
{GS : GroupStructure A} {HS : GroupStructure B} (p : A == B)
→ (ident GS == ident HS [ (λ C → C) ↓ p ])
→ (inv GS == inv HS [ (λ C → C → C) ↓ p ])
→ (comp GS == comp HS [ (λ C → C → C → C) ↓ p ])
→ GS == HS [ GroupStructure ↓ p ]
↓-group-structure= A-level idp = group-structure= A-level
module _ {i} (G : Group i) where
private
open Group G
infix 80 _⊙_
_⊙_ = comp
group-inv-unique-l : (g h : El) → (g ⊙ h == ident) → inv h == g
group-inv-unique-l g h p =
inv h =⟨ ! (unitl (inv h)) ⟩
ident ⊙ inv h =⟨ ! p |in-ctx (λ w → w ⊙ inv h) ⟩
(g ⊙ h) ⊙ inv h =⟨ assoc g h (inv h) ⟩
g ⊙ (h ⊙ inv h) =⟨ invr h |in-ctx (λ w → g ⊙ w) ⟩
g ⊙ ident =⟨ unitr g ⟩
g ∎
group-inv-unique-r : (g h : El) → (g ⊙ h == ident) → inv g == h
group-inv-unique-r g h p =
inv g =⟨ ! (unitr (inv g)) ⟩
inv g ⊙ ident =⟨ ! p |in-ctx (λ w → inv g ⊙ w) ⟩
inv g ⊙ (g ⊙ h) =⟨ ! (assoc (inv g) g h) ⟩
(inv g ⊙ g) ⊙ h =⟨ invl g |in-ctx (λ w → w ⊙ h) ⟩
ident ⊙ h =⟨ unitl h ⟩
h ∎
group-inv-ident : inv ident == ident
group-inv-ident =
group-inv-unique-l ident ident (unitl ident)
group-inv-comp : (g₁ g₂ : El) → inv (g₁ ⊙ g₂) == inv g₂ ⊙ inv g₁
group-inv-comp g₁ g₂ =
group-inv-unique-r (g₁ ⊙ g₂) (inv g₂ ⊙ inv g₁) $
(g₁ ⊙ g₂) ⊙ (inv g₂ ⊙ inv g₁)
=⟨ assoc g₁ g₂ (inv g₂ ⊙ inv g₁) ⟩
g₁ ⊙ (g₂ ⊙ (inv g₂ ⊙ inv g₁))
=⟨ ! (assoc g₂ (inv g₂) (inv g₁)) |in-ctx (λ w → g₁ ⊙ w) ⟩
g₁ ⊙ ((g₂ ⊙ inv g₂) ⊙ inv g₁)
=⟨ invr g₂ |in-ctx (λ w → g₁ ⊙ (w ⊙ inv g₁)) ⟩
g₁ ⊙ (ident ⊙ inv g₁)
=⟨ unitl (inv g₁) |in-ctx (λ w → g₁ ⊙ w) ⟩
g₁ ⊙ inv g₁
=⟨ invr g₁ ⟩
ident ∎
group-inv-inv : (g : El) → inv (inv g) == g
group-inv-inv g = group-inv-unique-r (inv g) g (invl g)
group-cancel-l : (g : El) {h k : El} → g ⊙ h == g ⊙ k → h == k
group-cancel-l g {h} {k} p =
h =⟨ ! (unitl h) ⟩
ident ⊙ h =⟨ ap (λ w → w ⊙ h) (! (invl g)) ⟩
(inv g ⊙ g) ⊙ h =⟨ assoc (inv g) g h ⟩
inv g ⊙ (g ⊙ h) =⟨ ap (λ w → inv g ⊙ w) p ⟩
inv g ⊙ (g ⊙ k) =⟨ ! (assoc (inv g) g k) ⟩
(inv g ⊙ g) ⊙ k =⟨ ap (λ w → w ⊙ k) (invl g) ⟩
ident ⊙ k =⟨ unitl k ⟩
k ∎
group-cancel-r : (g : El) {h k : El} → h ⊙ g == k ⊙ g → h == k
group-cancel-r g {h} {k} p =
h =⟨ ! (unitr h) ⟩
h ⊙ ident =⟨ ap (λ w → h ⊙ w) (! (invr g)) ⟩
h ⊙ (g ⊙ inv g) =⟨ ! (assoc h g (inv g)) ⟩
(h ⊙ g) ⊙ inv g =⟨ ap (λ w → w ⊙ inv g) p ⟩
(k ⊙ g) ⊙ inv g =⟨ assoc k g (inv g) ⟩
k ⊙ (g ⊙ inv g) =⟨ ap (λ w → k ⊙ w) (invr g) ⟩
k ⊙ ident =⟨ unitr k ⟩
k ∎
| {
"alphanum_fraction": 0.4665751813,
"avg_line_length": 35.9225352113,
"ext": "agda",
"hexsha": "41ea9411d3aa8703445d85791a28a1a2da5e8f5d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Group.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Group.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Group.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2173,
"size": 5101
} |
{-# OPTIONS --allow-unsolved-metas --warning=error --without-K --guardedness #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
module Fields.CauchyCompletion.Field {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where
open Setoid S
open PartiallyOrderedRing pRing
open SetoidPartialOrder pOrder
open Equivalence eq
open SetoidTotalOrder (TotallyOrderedRing.total order)
open Field F
open Group (Ring.additiveGroup R)
open import Rings.Orders.Total.Cauchy order
open import Rings.Orders.Total.Lemmas order
open import Rings.Orders.Total.AbsoluteValue order
open import Fields.CauchyCompletion.Definition order F
open import Fields.CauchyCompletion.Multiplication order F
open import Fields.CauchyCompletion.Addition order F
open import Fields.CauchyCompletion.Setoid order F
open import Fields.CauchyCompletion.Group order F
open import Fields.CauchyCompletion.Ring order F
open import Fields.CauchyCompletion.Comparison order F
Cnontrivial : (pr : Setoid._∼_ cauchyCompletionSetoid (injection (Ring.0R R)) (injection (Ring.1R R))) → False
Cnontrivial pr with pr (Ring.1R R) (0<1 nontrivial)
Cnontrivial pr | N , b with b {succ N} (le 0 refl)
... | bl rewrite indexAndApply (constSequence 0G) (map inverse (constSequence (Ring.1R R))) _+_ {N} | indexAndConst 0G N | equalityCommutative (mapAndIndex (constSequence (Ring.1R R)) inverse N) | indexAndConst (Ring.1R R) N = irreflexive {Ring.1R R} (<WellDefined (Equivalence.transitive eq (absWellDefined _ _ identLeft) (Equivalence.transitive eq (Equivalence.symmetric eq (absNegation (Ring.1R R))) abs1Is1)) (Equivalence.reflexive eq) bl)
boundedMap : A → A
boundedMap a with totality 0G a
boundedMap a | inl (inl x) = underlying (allInvertible a λ pr → irreflexive (<WellDefined (Equivalence.reflexive eq) pr x))
boundedMap a | inl (inr x) = underlying (allInvertible a λ pr → irreflexive (<WellDefined pr (Equivalence.reflexive eq) x))
boundedMap a | inr x = Ring.1R R
-- TODO: make a real which is equivalent by approximating from above;
-- make a real which is equivalent by approximating from below.
-- Use not-zero to show that one of those sequences must pass 0 at some point.
aNonzeroImpliesBounded : (a : CauchyCompletion) → (Setoid._∼_ cauchyCompletionSetoid a (injection 0G) → False) → (a <Cr 0G) || 0G r<C a
aNonzeroImpliesBounded a a!=0 = {!!}
1/aConverges : (a : CauchyCompletion) → (Setoid._∼_ cauchyCompletionSetoid a (injection 0G) → False) → cauchy (map boundedMap (CauchyCompletion.elts a))
1/aConverges a a!=0 e 0<e = {!!}
1/a : (a : CauchyCompletion) → (Setoid._∼_ cauchyCompletionSetoid a (injection 0G) → False) → CauchyCompletion
1/a a a!=0 = record { elts = map boundedMap (CauchyCompletion.elts a) ; converges = 1/aConverges a a!=0 }
1/a*a=1 : (a : CauchyCompletion) (pr : Setoid._∼_ cauchyCompletionSetoid a (injection 0G) → False) → Setoid._∼_ cauchyCompletionSetoid ((1/a a pr) *C a) (injection (Ring.1R R))
1/a*a=1 a a!=0 e 0<e = {!!}
CField : Field CRing
Field.allInvertible CField a a!=0 = (1/a a a!=0) , 1/a*a=1 a a!=0
Field.nontrivial CField = Cnontrivial
| {
"alphanum_fraction": 0.7561874671,
"avg_line_length": 53.4929577465,
"ext": "agda",
"hexsha": "a810d6bc6a24246f5bffca25e6c90c885323f887",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Fields/CauchyCompletion/Field.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Fields/CauchyCompletion/Field.agda",
"max_line_length": 443,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Fields/CauchyCompletion/Field.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 1198,
"size": 3798
} |
{-# OPTIONS --universe-polymorphism --allow-unsolved-metas --no-termination-check #-}
module Issue202 where
Foo : ∀ {A} → A → Set
Foo x = Foo x
-- Previously resulted in the following (cryptic) error:
-- Bug.agda:6,13-14
-- _5 !=< _5
-- when checking that the expression x has type _5 | {
"alphanum_fraction": 0.6864111498,
"avg_line_length": 26.0909090909,
"ext": "agda",
"hexsha": "9c6594566925bdee82d8355cdc90f75d285747c0",
"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/Issue202.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/Issue202.agda",
"max_line_length": 85,
"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/Issue202.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": 85,
"size": 287
} |
------------------------------------------------------------------------
-- Operations and lemmas related to application of substitutions
------------------------------------------------------------------------
open import Data.Universe.Indexed
module deBruijn.Substitution.Data.Application.Application1
{i u e} {Uni : IndexedUniverse i u e} where
import deBruijn.Context; open deBruijn.Context Uni
open import deBruijn.Substitution.Data.Application.Application22
open import deBruijn.Substitution.Data.Basics
open import deBruijn.Substitution.Data.Map
open import deBruijn.Substitution.Data.Simple
open import Function using (_$_)
open import Level using (_⊔_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open P.≡-Reasoning
-- More operations and lemmas related to application. In this module
-- the application operator is assumed to be homogeneous, so some
-- previously proved lemmas can be stated in a less complicated way.
record Application₁ {t} (T : Term-like t) : Set (i ⊔ u ⊔ e ⊔ t) where
open Term-like T
field
-- Simple substitutions.
simple : Simple T
-- The homogeneous variant is defined in terms of the
-- heterogeneous one.
application₂₂ : Application₂₂ simple simple ([id] {T = T})
open Simple simple public
open Application₂₂ application₂₂ public
hiding ( ∘⋆; ∘⋆-cong; /∋-∘⋆
; trans-cong; id-∘; map-trans-wk-subst; map-trans-↑; wk-∘-↑
)
-- Composition of multiple substitutions.
--
-- Note that singleton sequences are handled specially, to avoid the
-- introduction of unnecessary identity substitutions.
∘⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Subs T ρ̂ → Sub T ρ̂
∘⋆ ε = id
∘⋆ (ε ▻ ρ) = ρ
∘⋆ (ρs ▻ ρ) = ∘⋆ ρs ∘ ρ
-- A congruence lemma.
∘⋆-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T ρ̂₁}
{Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T ρ̂₂} →
ρs₁ ≅-⇨⋆ ρs₂ → ∘⋆ ρs₁ ≅-⇨ ∘⋆ ρs₂
∘⋆-cong P.refl = P.refl
abstract
-- Applying a composed substitution to a variable is equivalent to
-- applying all the substitutions one after another.
/∋-∘⋆ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρs : Subs T ρ̂) →
x /∋ ∘⋆ ρs ≅-⊢ var · x /⊢⋆ ρs
/∋-∘⋆ x ε = begin
[ x /∋ id ] ≡⟨ /∋-id x ⟩
[ var · x ] ∎
/∋-∘⋆ x (ε ▻ ρ) = begin
[ x /∋ ρ ] ≡⟨ P.sym $ var-/⊢ x ρ ⟩
[ var · x /⊢ ρ ] ∎
/∋-∘⋆ x (ρs ▻ ρ₁ ▻ ρ₂) = begin
[ x /∋ ∘⋆ (ρs ▻ ρ₁) ∘ ρ₂ ] ≡⟨ /∋-∘ x (∘⋆ (ρs ▻ ρ₁)) ρ₂ ⟩
[ x /∋ ∘⋆ (ρs ▻ ρ₁) /⊢ ρ₂ ] ≡⟨ /⊢-cong (/∋-∘⋆ x (ρs ▻ ρ₁)) P.refl ⟩
[ var · x /⊢⋆ (ρs ▻ ρ₁) /⊢ ρ₂ ] ∎
-- Yet another variant of var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆.
∘⋆-⇒-/⊢⋆ :
∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T ρ̂) (ρs₂ : Subs T ρ̂) →
∘⋆ ρs₁ ≅-⇨ ∘⋆ ρs₂ → ∀ {σ} (t : Γ ⊢ σ) → t /⊢⋆ ρs₁ ≅-⊢ t /⊢⋆ ρs₂
∘⋆-⇒-/⊢⋆ ρs₁ ρs₂ hyp = var-/⊢⋆-⇒-/⊢⋆ ρs₁ ρs₂ (λ x → begin
[ var · x /⊢⋆ ρs₁ ] ≡⟨ P.sym $ /∋-∘⋆ x ρs₁ ⟩
[ x /∋ ∘⋆ ρs₁ ] ≡⟨ /∋-cong (P.refl {x = [ x ]}) hyp ⟩
[ x /∋ ∘⋆ ρs₂ ] ≡⟨ /∋-∘⋆ x ρs₂ ⟩
[ var · x /⊢⋆ ρs₂ ] ∎)
-- id is a left identity of _∘_.
id-∘ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) → id ∘ ρ ≅-⇨ ρ
id-∘ ρ = begin
[ id ∘ ρ ] ≡⟨ Application₂₂.id-∘ application₂₂ ρ ⟩
[ map [id] ρ ] ≡⟨ map-[id] ρ ⟩
[ ρ ] ∎
-- The wk substitution commutes with any other (modulo lifting
-- etc.).
wk-∘-↑ : ∀ {Γ Δ} σ {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) →
ρ ∘ wk {σ = σ / ρ} ≅-⇨ wk {σ = σ} ∘ ρ ↑
wk-∘-↑ σ ρ = begin
[ ρ ∘ wk ] ≡⟨ ∘-cong (P.sym $ map-[id] ρ) P.refl ⟩
[ map [id] ρ ∘ wk ] ≡⟨ Application₂₂.wk-∘-↑ application₂₂ σ ρ ⟩
[ wk {σ = σ} ∘ ρ ↑ ] ∎
-- Applying a composed substitution is equivalent to applying one
-- substitution and then the other.
/⊢-∘ : ∀ {Γ Δ Ε σ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(t : Γ ⊢ σ) (ρ₁ : Sub T ρ̂₁) (ρ₂ : Sub T ρ̂₂) →
t /⊢ ρ₁ ∘ ρ₂ ≅-⊢ t /⊢ ρ₁ /⊢ ρ₂
/⊢-∘ t ρ₁ ρ₂ = ∘⋆-⇒-/⊢⋆ (ε ▻ ρ₁ ∘ ρ₂) (ε ▻ ρ₁ ▻ ρ₂) P.refl t
-- _∘_ is associative.
∘-∘ : ∀ {Γ Δ Ε Ζ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} {ρ̂₃ : Ε ⇨̂ Ζ}
(ρ₁ : Sub T ρ̂₁) (ρ₂ : Sub T ρ̂₂) (ρ₃ : Sub T ρ̂₃) →
ρ₁ ∘ (ρ₂ ∘ ρ₃) ≅-⇨ (ρ₁ ∘ ρ₂) ∘ ρ₃
∘-∘ ρ₁ ρ₂ ρ₃ = extensionality P.refl λ x → begin
[ x /∋ ρ₁ ∘ (ρ₂ ∘ ρ₃) ] ≡⟨ /∋-∘ x ρ₁ (ρ₂ ∘ ρ₃) ⟩
[ x /∋ ρ₁ /⊢ ρ₂ ∘ ρ₃ ] ≡⟨ /⊢-∘ (x /∋ ρ₁) ρ₂ ρ₃ ⟩
[ x /∋ ρ₁ /⊢ ρ₂ /⊢ ρ₃ ] ≡⟨ /⊢-cong (P.sym $ /∋-∘ x ρ₁ ρ₂) (P.refl {x = [ ρ₃ ]}) ⟩
[ x /∋ ρ₁ ∘ ρ₂ /⊢ ρ₃ ] ≡⟨ P.sym $ /∋-∘ x (ρ₁ ∘ ρ₂) ρ₃ ⟩
[ x /∋ (ρ₁ ∘ ρ₂) ∘ ρ₃ ] ∎
-- If sub t is applied to variable zero then t is returned.
zero-/⊢-sub : ∀ {Γ σ} (t : Γ ⊢ σ) → var · zero /⊢ sub t ≅-⊢ t
zero-/⊢-sub t = begin
[ var · zero /⊢ sub t ] ≡⟨ var-/⊢ zero (sub t) ⟩
[ zero /∋ sub t ] ≡⟨ P.refl ⟩
[ t ] ∎
-- The sub substitution commutes with any other (modulo lifting
-- etc.).
↑-∘-sub : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ⊢ σ) (ρ : Sub T ρ̂) →
sub t ∘ ρ ≅-⇨ ρ ↑ σ ∘ sub (t /⊢ ρ)
↑-∘-sub t ρ =
let lemma = begin
[ id ∘ ρ ] ≡⟨ id-∘ ρ ⟩
[ ρ ] ≡⟨ P.sym $ wk-subst-∘-sub ρ (t /⊢ ρ) ⟩
[ wk-subst ρ ∘ sub (t /⊢ ρ) ] ∎
in begin
[ sub t ∘ ρ ] ≡⟨ P.refl ⟩
[ (id ▻ t) ∘ ρ ] ≡⟨ ▻-∘ id t ρ ⟩
[ id ∘ ρ ▻ t /⊢ ρ ] ≡⟨ ▻⇨-cong P.refl lemma (P.sym $ zero-/⊢-sub (t /⊢ ρ)) ⟩
[ wk-subst ρ ∘ sub (t /⊢ ρ) ▻ var · zero /⊢ sub (t /⊢ ρ) ] ≡⟨ P.sym $ ▻-∘ (wk-subst ρ) (var · zero) (sub (t /⊢ ρ)) ⟩
[ (wk-subst ρ ▻ var · zero) ∘ sub (t /⊢ ρ) ] ≡⟨ ∘-cong (P.sym $ unfold-↑ ρ) P.refl ⟩
[ ρ ↑ ∘ sub (t /⊢ ρ) ] ∎
-- wk-subst⁺ can be expressed using composition and wk⁺.
∘-wk⁺ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) (Δ⁺ : Ctxt⁺ Δ) →
ρ ∘ wk⁺ Δ⁺ ≅-⇨ wk-subst⁺ Δ⁺ ρ
∘-wk⁺ ρ ε = begin
[ ρ ∘ wk⁺ ε ] ≡⟨ P.refl ⟩
[ ρ ∘ id ] ≡⟨ ∘-id ρ ⟩
[ ρ ] ≡⟨ P.refl ⟩
[ wk-subst⁺ ε ρ ] ∎
∘-wk⁺ ρ (Δ⁺ ▻ σ) = begin
[ ρ ∘ wk⁺ (Δ⁺ ▻ σ) ] ≡⟨ ∘-cong (P.refl {x = [ ρ ]}) (wk⁺-▻ Δ⁺) ⟩
[ ρ ∘ (wk⁺ Δ⁺ ∘ wk) ] ≡⟨ ∘-∘ ρ (wk⁺ Δ⁺) wk ⟩
[ (ρ ∘ wk⁺ Δ⁺) ∘ wk ] ≡⟨ ∘-cong (∘-wk⁺ ρ Δ⁺) P.refl ⟩
[ wk-subst⁺ Δ⁺ ρ ∘ wk ] ≡⟨ ∘-wk (wk-subst⁺ Δ⁺ ρ) ⟩
[ wk-subst (wk-subst⁺ Δ⁺ ρ) ] ≡⟨ P.refl ⟩
[ wk-subst⁺ (Δ⁺ ▻ σ) ρ ] ∎
mutual
-- wk-subst₊ can be expressed using composition and wk₊.
∘-wk₊ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) (Δ₊ : Ctxt₊ Δ) →
ρ ∘ wk₊ Δ₊ ≅-⇨ wk-subst₊ Δ₊ ρ
∘-wk₊ ρ ε = begin
[ ρ ∘ wk₊ ε ] ≡⟨ P.refl ⟩
[ ρ ∘ id ] ≡⟨ ∘-id ρ ⟩
[ ρ ] ≡⟨ P.refl ⟩
[ wk-subst₊ ε ρ ] ∎
∘-wk₊ ρ (σ ◅ Δ₊) = begin
[ ρ ∘ wk₊ (σ ◅ Δ₊) ] ≡⟨ ∘-cong (P.refl {x = [ ρ ]}) (wk₊-◅ Δ₊) ⟩
[ ρ ∘ (wk ∘ wk₊ Δ₊) ] ≡⟨ ∘-∘ ρ wk (wk₊ Δ₊) ⟩
[ (ρ ∘ wk) ∘ wk₊ Δ₊ ] ≡⟨ ∘-cong (∘-wk ρ) P.refl ⟩
[ wk-subst ρ ∘ wk₊ Δ₊ ] ≡⟨ ∘-wk₊ (wk-subst ρ) Δ₊ ⟩
[ wk-subst₊ Δ₊ (wk-subst ρ) ] ≡⟨ P.refl ⟩
[ wk-subst₊ (σ ◅ Δ₊) ρ ] ∎
-- Unfolding lemma for wk₊.
wk₊-◅ : ∀ {Γ σ} (Γ₊ : Ctxt₊ (Γ ▻ σ)) →
wk₊ (σ ◅ Γ₊) ≅-⇨ wk ∘ wk₊ Γ₊
wk₊-◅ {σ = σ} Γ₊ = begin
[ wk₊ (σ ◅ Γ₊) ] ≡⟨ P.refl ⟩
[ wk-subst₊ Γ₊ wk ] ≡⟨ P.sym $ ∘-wk₊ wk Γ₊ ⟩
[ wk ∘ wk₊ Γ₊ ] ∎
-- A consequence of wk₊-◅.
/∋-wk₊-◅ : ∀ {Γ τ σ} (x : Γ ∋ τ) (Γ₊ : Ctxt₊ (Γ ▻ σ)) →
x /∋ wk₊ (σ ◅ Γ₊) ≅-⊢ suc x /∋ wk₊ Γ₊
/∋-wk₊-◅ {σ = σ} x Γ₊ = begin
[ x /∋ wk₊ (σ ◅ Γ₊) ] ≡⟨ /∋-cong (P.refl {x = [ x ]}) (wk₊-◅ Γ₊) ⟩
[ x /∋ wk ∘ wk₊ Γ₊ ] ≡⟨ /∋-∘ x wk (wk₊ Γ₊) ⟩
[ x /∋ wk /⊢ wk₊ Γ₊ ] ≡⟨ /⊢-cong (/∋-wk x) P.refl ⟩
[ var · suc x /⊢ wk₊ Γ₊ ] ≡⟨ var-/⊢ (suc x) (wk₊ Γ₊) ⟩
[ suc x /∋ wk₊ Γ₊ ] ∎
| {
"alphanum_fraction": 0.3990306947,
"avg_line_length": 38.5023923445,
"ext": "agda",
"hexsha": "33ab230cf6fe9a8a0d4a6b842a9537db645141e4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/dependently-typed-syntax",
"max_forks_repo_path": "deBruijn/Substitution/Data/Application/Application1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/dependently-typed-syntax",
"max_issues_repo_path": "deBruijn/Substitution/Data/Application/Application1.agda",
"max_line_length": 125,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/dependently-typed-syntax",
"max_stars_repo_path": "deBruijn/Substitution/Data/Application/Application1.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z",
"num_tokens": 4355,
"size": 8047
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointers into star-lists
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Star.Pointer {ℓ} {I : Set ℓ} where
open import Data.Maybe.Base using (Maybe; nothing; just)
open import Data.Star.Decoration
open import Data.Unit
open import Function
open import Level
open import Relation.Binary
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
-- Pointers into star-lists. The edge pointed to is decorated with Q,
-- while other edges are decorated with P.
data Pointer {r p q} {T : Rel I r}
(P : EdgePred p T) (Q : EdgePred q T)
: Rel (Maybe (NonEmpty (Star T))) (p ⊔ q) where
step : ∀ {i j k} {x : T i j} {xs : Star T j k}
(p : P x) → Pointer P Q (just (nonEmpty (x ◅ xs)))
(just (nonEmpty xs))
done : ∀ {i j k} {x : T i j} {xs : Star T j k}
(q : Q x) → Pointer P Q (just (nonEmpty (x ◅ xs))) nothing
-- Any P Q xs means that some edge in xs satisfies Q, while all
-- preceding edges satisfy P. A star-list of type Any Always Always xs
-- is basically a prefix of xs; the existence of such a prefix
-- guarantees that xs is non-empty.
Any : ∀ {r p q} {T : Rel I r} (P : EdgePred p T) (Q : EdgePred q T) →
EdgePred (ℓ ⊔ (r ⊔ (p ⊔ q))) (Star T)
Any P Q xs = Star (Pointer P Q) (just (nonEmpty xs)) nothing
module _ {r p q} {T : Rel I r} {P : EdgePred p T} {Q : EdgePred q T} where
this : ∀ {i j k} {x : T i j} {xs : Star T j k} →
Q x → Any P Q (x ◅ xs)
this q = done q ◅ ε
that : ∀ {i j k} {x : T i j} {xs : Star T j k} →
P x → Any P Q xs → Any P Q (x ◅ xs)
that p = _◅_ (step p)
-- Safe lookup.
data Result {r p q} (T : Rel I r)
(P : EdgePred p T) (Q : EdgePred q T) : Set (ℓ ⊔ r ⊔ p ⊔ q) where
result : ∀ {i j} {x : T i j} (p : P x) (q : Q x) → Result T P Q
-- The first argument points out which edge to extract. The edge is
-- returned, together with proofs that it satisfies Q and R.
module _ {t p q} {T : Rel I t} {P : EdgePred p T} {Q : EdgePred q T} where
lookup : ∀ {r} {R : EdgePred r T} {i j} {xs : Star T i j} →
Any P Q xs → All R xs → Result T Q R
lookup (done q ◅ ε) (↦ r ◅ _) = result q r
lookup (step p ◅ ps) (↦ r ◅ rs) = lookup ps rs
lookup (done _ ◅ () ◅ _) _
-- We can define something resembling init.
prefixIndex : ∀ {i j} {xs : Star T i j} → Any P Q xs → I
prefixIndex (done {i = i} q ◅ _) = i
prefixIndex (step p ◅ ps) = prefixIndex ps
prefix : ∀ {i j} {xs : Star T i j} →
(ps : Any P Q xs) → Star T i (prefixIndex ps)
prefix (done q ◅ _) = ε
prefix (step {x = x} p ◅ ps) = x ◅ prefix ps
-- Here we are taking the initial segment of ps (all elements but the
-- last, i.e. all edges satisfying P).
init : ∀ {i j} {xs : Star T i j} →
(ps : Any P Q xs) → All P (prefix ps)
init (done q ◅ _) = ε
init (step p ◅ ps) = ↦ p ◅ init ps
-- One can simplify the implementation by not carrying around the
-- indices in the type:
last : ∀ {i j} {xs : Star T i j} →
Any P Q xs → NonEmptyEdgePred T Q
last ps with lookup {r = p} ps (decorate (const (lift tt)) _)
... | result q _ = nonEmptyEdgePred q
| {
"alphanum_fraction": 0.5448564593,
"avg_line_length": 35.9569892473,
"ext": "agda",
"hexsha": "f54241ecceca9de6828f28e8dcd0677f72098d66",
"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/Star/Pointer.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/Star/Pointer.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/Star/Pointer.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1107,
"size": 3344
} |
-- (Pre)additive categories
{-# OPTIONS --safe #-}
module Cubical.Categories.Additive.Base where
open import Cubical.Algebra.AbGroup.Base
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Limits.Initial
open import Cubical.Categories.Limits.Terminal
open import Cubical.Foundations.Prelude
private
variable
ℓ ℓ' : Level
-- Preadditive categories
module _ (C : Category ℓ ℓ') where
open Category C
record PreaddCategoryStr : Type (ℓ-max ℓ (ℓ-suc ℓ')) where
field
homAbStr : (x y : ob) → AbGroupStr Hom[ x , y ]
-- Polymorphic abelian group operations
0h = λ {x} {y} → AbGroupStr.0g (homAbStr x y)
-_ = λ {x} {y} → AbGroupStr.-_ (homAbStr x y)
_+_ = λ {x} {y} → AbGroupStr._+_ (homAbStr x y)
_-_ : ∀ {x y} (f g : Hom[ x , y ]) → Hom[ x , y ]
f - g = f + (- g)
infixr 7 _+_
infixl 7.5 _-_
infix 8 -_
field
⋆distl+ : {x y z : ob} → (f : Hom[ x , y ]) → (g g' : Hom[ y , z ]) →
f ⋆ (g + g') ≡ (f ⋆ g) + (f ⋆ g')
⋆distr+ : {x y z : ob} → (f f' : Hom[ x , y ]) → (g : Hom[ y , z ]) →
(f + f') ⋆ g ≡ (f ⋆ g) + (f' ⋆ g)
record PreaddCategory (ℓ ℓ' : Level) : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
cat : Category ℓ ℓ'
preadd : PreaddCategoryStr cat
open Category cat public
open PreaddCategoryStr preadd public
-- Additive categories
module _ (C : PreaddCategory ℓ ℓ') where
open PreaddCategory C
-- Zero object
record ZeroObject : Type (ℓ-max ℓ ℓ') where
field
z : ob
zInit : isInitial cat z
zTerm : isTerminal cat z
-- Biproducts
record IsBiproduct {x y x⊕y : ob}
(i₁ : Hom[ x , x⊕y ]) (i₂ : Hom[ y , x⊕y ])
(π₁ : Hom[ x⊕y , x ]) (π₂ : Hom[ x⊕y , y ])
: Type (ℓ-max ℓ ℓ') where
field
i₁⋆π₁ : i₁ ⋆ π₁ ≡ id
i₁⋆π₂ : i₁ ⋆ π₂ ≡ 0h
i₂⋆π₁ : i₂ ⋆ π₁ ≡ 0h
i₂⋆π₂ : i₂ ⋆ π₂ ≡ id
∑π⋆i : π₁ ⋆ i₁ + π₂ ⋆ i₂ ≡ id
record Biproduct (x y : ob) : Type (ℓ-max ℓ ℓ') where
field
x⊕y : ob
i₁ : Hom[ x , x⊕y ]
i₂ : Hom[ y , x⊕y ]
π₁ : Hom[ x⊕y , x ]
π₂ : Hom[ x⊕y , y ]
isBipr : IsBiproduct i₁ i₂ π₁ π₂
open IsBiproduct isBipr public
-- Additive categories
record AdditiveCategoryStr : Type (ℓ-max ℓ (ℓ-suc ℓ')) where
field
zero : ZeroObject
biprod : ∀ x y → Biproduct x y
-- Biproduct notation
open Biproduct
_⊕_ = λ (x y : ob) → biprod x y .x⊕y
infixr 6 _⊕_
record AdditiveCategory (ℓ ℓ' : Level) : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
preaddcat : PreaddCategory ℓ ℓ'
addit : AdditiveCategoryStr preaddcat
open PreaddCategory preaddcat public
open AdditiveCategoryStr addit public
| {
"alphanum_fraction": 0.5663585952,
"avg_line_length": 24.1517857143,
"ext": "agda",
"hexsha": "02dc206ca1a4e2f9efb13f1c473aa5aa4c743ae7",
"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/Categories/Additive/Base.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/Categories/Additive/Base.agda",
"max_line_length": 75,
"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/Categories/Additive/Base.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": 1098,
"size": 2705
} |
-- Andreas, 2013-01-08, Reported by andres.sicard.ramirez, Jan 7
-- {-# OPTIONS -v term:10 -v term.matrices:40 #-}
-- The difference between @bar@ and @bar'@ is the position of the
-- hypothesis (n : ℕ). While @bar@ is accepted by the termination
-- checker, @bar'@ is rejected for it.
open import Common.Prelude renaming (Nat to ℕ)
open import Common.Product
open import Common.Coinduction
open import Common.Equality
data Foo : ℕ → Set where
foo : (n : ℕ) → ∞ (Foo n) → Foo (suc n)
module NoWith where
bar : (A : ℕ → Set) (n : ℕ) →
((m : ℕ) → A m → ∃ λ m' → m ≡ suc m' × A m') →
A n → Foo n
bar A n h An = subst Foo (sym (proj₁ (proj₂ (h n An))))
(foo (proj₁ (h n An)) (♯ (bar A (proj₁ (h n An)) h (proj₂ (proj₂ (h n An))))))
module CorrectlyRejected where
-- Proof rejected by the termination checker.
--
-- (If I do pattern matching on @n≡Sn'@, the proof is accepted.)
bar' : (A : ℕ → Set) →
((m : ℕ) → A m → ∃ λ m' → m ≡ suc m' × A m') →
(n : ℕ) → A n → Foo n
bar' A h n An with h n An
... | (n' , n≡Sn' , An') = subst Foo (sym n≡Sn') (foo n' (♯ (bar' A h n' An')))
postulate
A : ℕ → Set
h : (m : ℕ) → A m → ∃ λ m' → suc m' ≡ m × A m'
-- Proof rejected by the termination checker.
bar : (n : ℕ) → A n → Foo n
bar n An with h n An
... | (n' , p , An') = subst Foo p (foo n' (♯ (bar n' An')))
module WasAccepted1 where
-- Proof wrongly accepted by the termination checker.
bar : (A : ℕ → Set) (n : ℕ) →
((m : ℕ) → A m → ∃ λ m' → m ≡ suc m' × A m') →
A n → Foo n
bar A n h An with h n An
... | (n' , n≡Sn' , An') = subst Foo (sym n≡Sn') (foo n' (♯ (bar A n' h An')))
-- Proof was wrongly accepted by the termination checker.
postulate
A : ℕ → Set
H = (m : ℕ) → A m → ∃ λ m' → suc m' ≡ m × A m'
-- argument h was essential for faulty behavior
bar : (n : ℕ) → H → A n → Foo n
bar n h An with h n An
... | (n' , p , An') = subst Foo p (foo n' (♯ (bar n' h An')))
{- termination checking clause of bar
lhs: 5 4 3 (_,_ 2 (_,_ 1 0))
rhs: subst Foo p (foo n' (.Issue1014.♯-0 n h An n' p An'))
kept call from bar 5 4 3 (_,_ 2 (_,_ 1 0))
to .Issue1014.♯-0 (n) (h) (An) (n') (p) (An')
call matrix (with guardedness):
[[.,.,.,.,.]
,[.,0,.,.,.]
,[.,.,0,.,.]
,[.,.,.,0,.]
,[.,.,.,.,0]
,[.,.,.,.,0]
,[.,.,.,.,0]]
termination checking body of .Issue1014.♯-0
: (n : ℕ)
(h : (m : ℕ) → A m → Σ ℕ (λ m' → Σ (suc m' ≡ m) (λ x → A m')))
(An : A n) (n' : ℕ) (p : suc n' ≡ n) (An' : A n') →
∞ (Foo n')
termination checking delayed clause of .Issue1014.♯-0
lhs: 5 4 3 2 1 0
rhs: ♯ bar n' h An'
kept call from .Issue1014.♯-0 5 4 3 2 1 0
to bar (n') (h) (An')
call matrix (with guardedness):
[[-1,.,.,.,.,.,.]
,[.,.,.,.,0,.,.]
,[.,.,0,.,.,.,.]
,[.,.,.,.,.,.,0]]
[Issue1014.bar] does termination check
-}
| {
"alphanum_fraction": 0.5123762376,
"avg_line_length": 29.1546391753,
"ext": "agda",
"hexsha": "7eb175b8cf8ba365ebc5f7205ebbb3e7de7a3ce4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue1014.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1014.agda",
"max_line_length": 82,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1014.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": 1145,
"size": 2828
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Diagram.Pullback
module Categories.Bicategory.Construction.Spans {o ℓ e} {𝒞 : Category o ℓ e}
(_×ₚ_ : ∀ {X Y Z} → (f : 𝒞 [ X , Z ]) (g : 𝒞 [ Y , Z ]) → Pullback 𝒞 f g) where
open import Level
open import Function using (_$_)
open import Data.Product using (Σ; _×_; _,_; proj₁; proj₂; uncurry)
open import Categories.Bicategory
open import Categories.NaturalTransformation.NaturalIsomorphism hiding (refl; sym)
open import Categories.Category.Diagram.Span 𝒞
open import Categories.Category.Construction.Spans 𝒞 renaming (Spans to Spans₁)
open import Categories.Morphism
open import Categories.Morphism.Reasoning 𝒞
private
module Spans₁ X Y = Category (Spans₁ X Y)
open Category 𝒞
open HomReasoning
open Equiv
open Span
open Span⇒
open Pullback
open Compositions _×ₚ_
private
variable
A B C D E : Obj
--------------------------------------------------------------------------------
-- Proofs about span compositions
⊚₁-identity : ∀ (f : Span B C) → (g : Span A B) → Spans₁ A C [ Spans₁.id B C {f} ⊚₁ Spans₁.id A B {g} ≈ Spans₁.id A C ]
⊚₁-identity f g = ⟺ (unique ((cod g) ×ₚ (dom f)) id-comm id-comm)
⊚₁-homomorphism : {f f′ f″ : Span B C} {g g′ g″ : Span A B}
→ (α : Span⇒ f f′) → (α′ : Span⇒ f′ f″)
→ (β : Span⇒ g g′) → (β′ : Span⇒ g′ g″)
→ Spans₁ A C [ (Spans₁ B C [ α′ ∘ α ]) ⊚₁ (Spans₁ A B [ β′ ∘ β ]) ≈ Spans₁ A C [ α′ ⊚₁ β′ ∘ α ⊚₁ β ] ]
⊚₁-homomorphism {A} {B} {C} {f} {f′} {f″} {g} {g′} {g″} α α′ β β′ =
let pullback = (cod g) ×ₚ (dom f)
pullback′ = (cod g′) ×ₚ(dom f′)
pullback″ = (cod g″) ×ₚ (dom f″)
α-chase = begin
p₂ pullback″ ∘ universal pullback″ _ ∘ universal pullback′ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback″) ⟩
(arr α′ ∘ p₂ pullback′) ∘ universal pullback′ _ ≈⟨ extendˡ (p₂∘universal≈h₂ pullback′) ⟩
(arr α′ ∘ arr α) ∘ p₂ pullback ∎
β-chase = begin
p₁ pullback″ ∘ universal pullback″ _ ∘ universal pullback′ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback″) ⟩
(arr β′ ∘ p₁ pullback′) ∘ universal pullback′ _ ≈⟨ extendˡ (p₁∘universal≈h₁ pullback′) ⟩
(arr β′ ∘ arr β) ∘ p₁ pullback ∎
in ⟺ (unique pullback″ β-chase α-chase)
--------------------------------------------------------------------------------
-- Associators
module _ (f : Span C D) (g : Span B C) (h : Span A B) where
private
pullback-fg = (cod g) ×ₚ (dom f)
pullback-gh = (cod h) ×ₚ (dom g)
pullback-⟨fg⟩h = (cod h) ×ₚ (dom (f ⊚₀ g))
pullback-f⟨gh⟩ = (cod (g ⊚₀ h)) ×ₚ (dom f)
⊚-assoc : Span⇒ ((f ⊚₀ g) ⊚₀ h) (f ⊚₀ (g ⊚₀ h))
⊚-assoc = record
{ arr = universal pullback-f⟨gh⟩ {h₁ = universal pullback-gh (commute pullback-⟨fg⟩h ○ assoc)} $ begin
(cod g ∘ p₂ pullback-gh) ∘ universal pullback-gh _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-gh) ⟩
cod g ∘ p₁ pullback-fg ∘ p₂ pullback-⟨fg⟩h ≈⟨ extendʳ (commute pullback-fg) ⟩
dom f ∘ p₂ pullback-fg ∘ p₂ pullback-⟨fg⟩h ∎
; commute-dom = begin
((dom h ∘ p₁ pullback-gh) ∘ p₁ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullʳ (p₁∘universal≈h₁ pullback-f⟨gh⟩) ⟩
(dom h ∘ p₁ pullback-gh) ∘ universal pullback-gh _ ≈⟨ pullʳ (p₁∘universal≈h₁ pullback-gh) ⟩
dom h ∘ p₁ pullback-⟨fg⟩h ∎
; commute-cod = begin
(cod f ∘ p₂ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ extendˡ (p₂∘universal≈h₂ pullback-f⟨gh⟩) ⟩
(cod f ∘ p₂ pullback-fg) ∘ p₂ pullback-⟨fg⟩h ∎
}
⊚-assoc⁻¹ : Span⇒ (f ⊚₀ (g ⊚₀ h)) ((f ⊚₀ g) ⊚₀ h)
⊚-assoc⁻¹ = record
{ arr = universal pullback-⟨fg⟩h {h₁ = p₁ pullback-gh ∘ p₁ pullback-f⟨gh⟩} {h₂ = universal pullback-fg (⟺ assoc ○ commute pullback-f⟨gh⟩)} $ begin
cod h ∘ p₁ pullback-gh ∘ p₁ pullback-f⟨gh⟩ ≈⟨ extendʳ (commute pullback-gh) ⟩
dom g ∘ p₂ pullback-gh ∘ p₁ pullback-f⟨gh⟩ ≈⟨ pushʳ (⟺ (p₁∘universal≈h₁ pullback-fg)) ⟩
(dom g ∘ p₁ pullback-fg) ∘ universal pullback-fg _ ∎
; commute-dom = begin
(dom h ∘ p₁ pullback-⟨fg⟩h) ∘ universal pullback-⟨fg⟩h _ ≈⟨ extendˡ (p₁∘universal≈h₁ pullback-⟨fg⟩h) ⟩
(dom h ∘ p₁ pullback-gh) ∘ p₁ pullback-f⟨gh⟩ ∎
; commute-cod = begin
((cod f ∘ p₂ pullback-fg) ∘ p₂ pullback-⟨fg⟩h) ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-⟨fg⟩h) ⟩
(cod f ∘ p₂ pullback-fg) ∘ universal pullback-fg _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-fg) ⟩
cod f ∘ p₂ pullback-f⟨gh⟩ ∎
}
⊚-assoc-iso : Iso (Spans₁ A D) ⊚-assoc ⊚-assoc⁻¹
⊚-assoc-iso = record
{ isoˡ =
let lemma-fgˡ = begin
p₁ pullback-fg ∘ universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-fg) ⟩
(p₂ pullback-gh ∘ p₁ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullʳ (p₁∘universal≈h₁ pullback-f⟨gh⟩) ⟩
p₂ pullback-gh ∘ universal pullback-gh _ ≈⟨ p₂∘universal≈h₂ pullback-gh ⟩
p₁ pullback-fg ∘ p₂ pullback-⟨fg⟩h ∎
lemma-fgʳ = begin
p₂ pullback-fg ∘ universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-fg) ⟩
p₂ pullback-f⟨gh⟩ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ p₂∘universal≈h₂ pullback-f⟨gh⟩ ⟩
p₂ pullback-fg ∘ p₂ pullback-⟨fg⟩h ∎
lemmaˡ = begin
p₁ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-⟨fg⟩h) ⟩
(p₁ pullback-gh ∘ p₁ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullʳ (p₁∘universal≈h₁ pullback-f⟨gh⟩) ⟩
p₁ pullback-gh ∘ universal pullback-gh _ ≈⟨ p₁∘universal≈h₁ pullback-gh ⟩
p₁ pullback-⟨fg⟩h ∎
lemmaʳ = begin
p₂ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-⟨fg⟩h) ⟩
universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ≈⟨ unique-diagram pullback-fg lemma-fgˡ lemma-fgʳ ⟩
p₂ pullback-⟨fg⟩h ∎
in unique pullback-⟨fg⟩h lemmaˡ lemmaʳ ○ ⟺ (Pullback.id-unique pullback-⟨fg⟩h)
; isoʳ =
let lemma-ghˡ = begin
p₁ pullback-gh ∘ universal pullback-gh _ ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-gh) ⟩
p₁ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ≈⟨ p₁∘universal≈h₁ pullback-⟨fg⟩h ⟩
p₁ pullback-gh ∘ p₁ pullback-f⟨gh⟩ ∎
lemma-ghʳ = begin
p₂ pullback-gh ∘ universal pullback-gh _ ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-gh) ⟩
(p₁ pullback-fg ∘ p₂ pullback-⟨fg⟩h) ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-⟨fg⟩h) ⟩
p₁ pullback-fg ∘ universal pullback-fg _ ≈⟨ p₁∘universal≈h₁ pullback-fg ⟩
p₂ pullback-gh ∘ p₁ pullback-f⟨gh⟩ ∎
lemmaˡ = begin
p₁ pullback-f⟨gh⟩ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-f⟨gh⟩) ⟩
universal pullback-gh _ ∘ universal pullback-⟨fg⟩h _ ≈⟨ unique-diagram pullback-gh lemma-ghˡ lemma-ghʳ ⟩
p₁ pullback-f⟨gh⟩ ∎
lemmaʳ = begin
p₂ pullback-f⟨gh⟩ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-f⟨gh⟩) ⟩
(p₂ pullback-fg ∘ p₂ pullback-⟨fg⟩h) ∘ universal pullback-⟨fg⟩h _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-⟨fg⟩h) ⟩
p₂ pullback-fg ∘ universal pullback-fg _ ≈⟨ p₂∘universal≈h₂ pullback-fg ⟩
p₂ pullback-f⟨gh⟩ ∎
in unique pullback-f⟨gh⟩ lemmaˡ lemmaʳ ○ ⟺ (Pullback.id-unique pullback-f⟨gh⟩)
}
⊚-assoc-commute : ∀ {f f′ : Span C D} {g g′ : Span B C} {h h′ : Span A B} → (α : Span⇒ f f′) → (β : Span⇒ g g′) → (γ : Span⇒ h h′)
→ Spans₁ A D [ Spans₁ A D [ ⊚-assoc f′ g′ h′ ∘ (α ⊚₁ β) ⊚₁ γ ] ≈ Spans₁ A D [ α ⊚₁ (β ⊚₁ γ) ∘ ⊚-assoc f g h ] ]
⊚-assoc-commute {f = f} {f′ = f′} {g = g} {g′ = g′} {h = h} {h′ = h′} α β γ =
let pullback-fg = (cod g) ×ₚ (dom f)
pullback-fg′ = (cod g′) ×ₚ (dom f′)
pullback-gh = (cod h) ×ₚ (dom g)
pullback-gh′ = (cod h′) ×ₚ (dom g′)
pullback-f⟨gh⟩ = (cod (g ⊚₀ h)) ×ₚ (dom f)
pullback-f⟨gh⟩′ = (cod (g′ ⊚₀ h′)) ×ₚ (dom f′)
pullback-⟨fg⟩h = (cod h) ×ₚ (dom (f ⊚₀ g))
pullback-⟨fg⟩h′ = (cod h′) ×ₚ (dom (f′ ⊚₀ g′))
lemma-ghˡ′ = begin
p₁ pullback-gh′ ∘ universal pullback-gh′ _ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-gh′) ⟩
p₁ pullback-⟨fg⟩h′ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ p₁∘universal≈h₁ pullback-⟨fg⟩h′ ⟩
arr γ ∘ p₁ pullback-⟨fg⟩h ≈⟨ pushʳ (⟺ (p₁∘universal≈h₁ pullback-gh)) ⟩
(arr γ ∘ p₁ pullback-gh) ∘ universal pullback-gh _ ≈⟨ pushˡ (⟺ (p₁∘universal≈h₁ pullback-gh′)) ⟩
p₁ pullback-gh′ ∘ universal pullback-gh′ _ ∘ universal pullback-gh _ ∎
lemma-ghʳ′ = begin
p₂ pullback-gh′ ∘ universal pullback-gh′ _ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-gh′) ⟩
(p₁ pullback-fg′ ∘ p₂ pullback-⟨fg⟩h′) ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-⟨fg⟩h′) ⟩
p₁ pullback-fg′ ∘ universal pullback-fg′ _ ∘ p₂ pullback-⟨fg⟩h ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-fg′) ⟩
(arr β ∘ p₁ pullback-fg) ∘ p₂ pullback-⟨fg⟩h ≈⟨ extendˡ (⟺ (p₂∘universal≈h₂ pullback-gh)) ⟩
(arr β ∘ p₂ pullback-gh) ∘ universal pullback-gh _ ≈⟨ pushˡ (⟺ (p₂∘universal≈h₂ pullback-gh′)) ⟩
p₂ pullback-gh′ ∘ universal pullback-gh′ _ ∘ universal pullback-gh _ ∎
lemmaˡ = begin
p₁ pullback-f⟨gh⟩′ ∘ universal pullback-f⟨gh⟩′ _ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-f⟨gh⟩′) ⟩
universal pullback-gh′ _ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ unique-diagram pullback-gh′ lemma-ghˡ′ lemma-ghʳ′ ⟩
universal pullback-gh′ _ ∘ universal pullback-gh _ ≈⟨ pushʳ (⟺ (p₁∘universal≈h₁ pullback-f⟨gh⟩)) ⟩
(universal pullback-gh′ _ ∘ p₁ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pushˡ (⟺ (p₁∘universal≈h₁ pullback-f⟨gh⟩′)) ⟩
p₁ pullback-f⟨gh⟩′ ∘ universal pullback-f⟨gh⟩′ _ ∘ universal pullback-f⟨gh⟩ _ ∎
lemmaʳ = begin
p₂ pullback-f⟨gh⟩′ ∘ universal pullback-f⟨gh⟩′ _ ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-f⟨gh⟩′) ⟩
(p₂ pullback-fg′ ∘ p₂ pullback-⟨fg⟩h′) ∘ universal pullback-⟨fg⟩h′ _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback-⟨fg⟩h′) ⟩
p₂ pullback-fg′ ∘ universal pullback-fg′ _ ∘ p₂ pullback-⟨fg⟩h ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-fg′) ⟩
(arr α ∘ p₂ pullback-fg) ∘ p₂ pullback-⟨fg⟩h ≈⟨ extendˡ (⟺ (p₂∘universal≈h₂ pullback-f⟨gh⟩)) ⟩
(arr α ∘ p₂ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ≈⟨ pushˡ (⟺ (p₂∘universal≈h₂ pullback-f⟨gh⟩′)) ⟩
p₂ pullback-f⟨gh⟩′ ∘ universal pullback-f⟨gh⟩′ _ ∘ universal pullback-f⟨gh⟩ _ ∎
in unique-diagram pullback-f⟨gh⟩′ lemmaˡ lemmaʳ
--------------------------------------------------------------------------------
-- Unitors
module _ (f : Span A B) where
private
pullback-dom-f = id ×ₚ (dom f)
pullback-cod-f = (cod f) ×ₚ id
⊚-unitˡ : Span⇒ (id-span ⊚₀ f) f
⊚-unitˡ = record
{ arr = p₁ pullback-cod-f
; commute-dom = refl
; commute-cod = commute pullback-cod-f
}
⊚-unitˡ⁻¹ : Span⇒ f (id-span ⊚₀ f)
⊚-unitˡ⁻¹ = record
{ arr = universal pullback-cod-f id-comm
; commute-dom = cancelʳ (p₁∘universal≈h₁ pullback-cod-f)
; commute-cod = pullʳ (p₂∘universal≈h₂ pullback-cod-f) ○ identityˡ
}
⊚-unitˡ-iso : Iso (Spans₁ A B) ⊚-unitˡ ⊚-unitˡ⁻¹
⊚-unitˡ-iso = record
{ isoˡ = unique-diagram pullback-cod-f (pullˡ (p₁∘universal≈h₁ pullback-cod-f) ○ id-comm-sym) (pullˡ (p₂∘universal≈h₂ pullback-cod-f) ○ commute pullback-cod-f ○ id-comm-sym)
; isoʳ = p₁∘universal≈h₁ pullback-cod-f
}
⊚-unitʳ : Span⇒ (f ⊚₀ id-span) f
⊚-unitʳ = record
{ arr = p₂ pullback-dom-f
; commute-dom = ⟺ (commute pullback-dom-f)
; commute-cod = refl
}
⊚-unitʳ⁻¹ : Span⇒ f (f ⊚₀ id-span)
⊚-unitʳ⁻¹ = record
{ arr = universal pullback-dom-f id-comm-sym
; commute-dom = pullʳ (p₁∘universal≈h₁ pullback-dom-f) ○ identityˡ
; commute-cod = pullʳ (p₂∘universal≈h₂ pullback-dom-f) ○ identityʳ
}
⊚-unitʳ-iso : Iso (Spans₁ A B) ⊚-unitʳ ⊚-unitʳ⁻¹
⊚-unitʳ-iso = record
{ isoˡ = unique-diagram pullback-dom-f (pullˡ (p₁∘universal≈h₁ pullback-dom-f) ○ ⟺ (commute pullback-dom-f) ○ id-comm-sym) (pullˡ (p₂∘universal≈h₂ pullback-dom-f) ○ id-comm-sym)
; isoʳ = p₂∘universal≈h₂ pullback-dom-f
}
⊚-unitˡ-commute : ∀ {f f′ : Span A B} → (α : Span⇒ f f′) → Spans₁ A B [ Spans₁ A B [ ⊚-unitˡ f′ ∘ Spans₁.id B B ⊚₁ α ] ≈ Spans₁ A B [ α ∘ ⊚-unitˡ f ] ]
⊚-unitˡ-commute {f′ = f′} α = p₁∘universal≈h₁ ((cod f′) ×ₚ id)
⊚-unitʳ-commute : ∀ {f f′ : Span A B} → (α : Span⇒ f f′) → Spans₁ A B [ Spans₁ A B [ ⊚-unitʳ f′ ∘ α ⊚₁ Spans₁.id A A ] ≈ Spans₁ A B [ α ∘ ⊚-unitʳ f ] ]
⊚-unitʳ-commute {f′ = f′} α = p₂∘universal≈h₂ (id ×ₚ (dom f′))
--------------------------------------------------------------------------------
-- Coherence Conditions
triangle : (f : Span A B) → (g : Span B C) → Spans₁ A C [ Spans₁ A C [ Spans₁.id B C {g} ⊚₁ ⊚-unitˡ f ∘ ⊚-assoc g id-span f ] ≈ ⊚-unitʳ g ⊚₁ Spans₁.id A B {f} ]
triangle f g =
let pullback-dom-g = id ×ₚ (dom g)
pullback-cod-f = (cod f) ×ₚ id
pullback-fg = (cod f) ×ₚ (dom g)
pullback-id-fg = (cod (id-span ⊚₀ f)) ×ₚ (dom g)
pullback-f-id-g = (cod f) ×ₚ (dom (id-span ⊚₀ g))
in unique pullback-fg (pullˡ (p₁∘universal≈h₁ pullback-fg) ○ pullʳ (p₁∘universal≈h₁ pullback-id-fg) ○ p₁∘universal≈h₁ pullback-cod-f ○ ⟺ identityˡ)
(pullˡ (p₂∘universal≈h₂ pullback-fg) ○ pullʳ (p₂∘universal≈h₂ pullback-id-fg) ○ identityˡ)
pentagon : (f : Span A B) → (g : Span B C) → (h : Span C D) → (i : Span D E)
→ Spans₁ A E [ Spans₁ A E [ (Spans₁.id D E {i}) ⊚₁ (⊚-assoc h g f) ∘ Spans₁ A E [ ⊚-assoc i (h ⊚₀ g) f ∘ ⊚-assoc i h g ⊚₁ Spans₁.id A B {f} ] ] ≈ Spans₁ A E [ ⊚-assoc i h (g ⊚₀ f) ∘ ⊚-assoc (i ⊚₀ h) g f ] ]
pentagon {A} {B} {C} {D} {E} f g h i =
let pullback-fg = (cod f) ×ₚ (dom g)
pullback-gh = (cod g) ×ₚ (dom h)
pullback-hi = (cod h) ×ₚ (dom i)
pullback-f⟨gh⟩ = (cod f) ×ₚ (dom (h ⊚₀ g))
pullback-⟨fg⟩h = (cod (g ⊚₀ f)) ×ₚ (dom h)
pullback-⟨gh⟩i = (cod (h ⊚₀ g)) ×ₚ (dom i)
pullback-g⟨hi⟩ = (cod g) ×ₚ (dom (i ⊚₀ h))
pullback-⟨⟨fg⟩h⟩i = (cod (h ⊚₀ (g ⊚₀ f))) ×ₚ (dom i)
pullback-⟨f⟨gh⟩⟩i = (cod ((h ⊚₀ g) ⊚₀ f)) ×ₚ (dom i)
pullback-⟨fg⟩⟨hi⟩ = (cod (g ⊚₀ f)) ×ₚ (dom (i ⊚₀ h))
pullback-f⟨⟨gh⟩i⟩ = (cod f) ×ₚ (dom (i ⊚₀ (h ⊚₀ g)))
pullback-f⟨g⟨hi⟩⟩ = (cod f) ×ₚ (dom ((i ⊚₀ h) ⊚₀ g))
lemma-fgˡ = begin
p₁ pullback-fg ∘ universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-fg) ⟩
p₁ pullback-f⟨gh⟩ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-f⟨gh⟩) ⟩
p₁ pullback-f⟨⟨gh⟩i⟩ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ p₁∘universal≈h₁ pullback-f⟨⟨gh⟩i⟩ ⟩
id ∘ p₁ pullback-f⟨g⟨hi⟩⟩ ≈⟨ identityˡ ⟩
p₁ pullback-f⟨g⟨hi⟩⟩ ≈˘⟨ p₁∘universal≈h₁ pullback-fg ⟩
p₁ pullback-fg ∘ universal pullback-fg _ ∎
lemma-fgʳ = begin
p₂ pullback-fg ∘ universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-fg) ⟩
(p₁ pullback-gh ∘ p₂ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center (p₂∘universal≈h₂ pullback-f⟨gh⟩) ⟩
p₁ pullback-gh ∘ (p₁ pullback-⟨gh⟩i ∘ p₂ pullback-f⟨⟨gh⟩i⟩) ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center⁻¹ refl (p₂∘universal≈h₂ pullback-f⟨⟨gh⟩i⟩) ⟩
(p₁ pullback-gh ∘ p₁ pullback-⟨gh⟩i) ∘ universal pullback-⟨gh⟩i _ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ center (p₁∘universal≈h₁ pullback-⟨gh⟩i) ⟩
p₁ pullback-gh ∘ universal pullback-gh _ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-gh) ⟩
p₁ pullback-g⟨hi⟩ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈˘⟨ p₂∘universal≈h₂ pullback-fg ⟩
p₂ pullback-fg ∘ universal pullback-fg _ ∎
lemma-⟨fg⟩hˡ = begin
p₁ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-⟨fg⟩h) ⟩
universal pullback-fg _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ unique-diagram pullback-fg lemma-fgˡ lemma-fgʳ ⟩
universal pullback-fg _ ≈˘⟨ p₁∘universal≈h₁ pullback-⟨fg⟩⟨hi⟩ ⟩
p₁ pullback-⟨fg⟩⟨hi⟩ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ≈⟨ pushˡ (⟺ (p₁∘universal≈h₁ pullback-⟨fg⟩h)) ⟩
p₁ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ∎
lemma-⟨fg⟩hʳ = begin
p₂ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-⟨fg⟩h) ⟩
(p₂ pullback-gh ∘ p₂ pullback-f⟨gh⟩) ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center (p₂∘universal≈h₂ pullback-f⟨gh⟩) ⟩
p₂ pullback-gh ∘ (p₁ pullback-⟨gh⟩i ∘ p₂ pullback-f⟨⟨gh⟩i⟩) ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center⁻¹ refl (p₂∘universal≈h₂ pullback-f⟨⟨gh⟩i⟩) ⟩
(p₂ pullback-gh ∘ p₁ pullback-⟨gh⟩i) ∘ universal pullback-⟨gh⟩i _ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ center (p₁∘universal≈h₁ pullback-⟨gh⟩i) ⟩
p₂ pullback-gh ∘ universal pullback-gh _ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ extendʳ (p₂∘universal≈h₂ pullback-gh) ⟩
p₁ pullback-hi ∘ p₂ pullback-g⟨hi⟩ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ pushʳ (⟺ (p₂∘universal≈h₂ pullback-⟨fg⟩⟨hi⟩)) ⟩
(p₁ pullback-hi ∘ p₂ pullback-⟨fg⟩⟨hi⟩) ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ≈⟨ pushˡ (⟺ (p₂∘universal≈h₂ pullback-⟨fg⟩h)) ⟩
p₂ pullback-⟨fg⟩h ∘ universal pullback-⟨fg⟩h _ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ∎
lemmaˡ = begin
p₁ pullback-⟨⟨fg⟩h⟩i ∘ universal pullback-⟨⟨fg⟩h⟩i _ ∘ universal pullback-⟨f⟨gh⟩⟩i _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₁∘universal≈h₁ pullback-⟨⟨fg⟩h⟩i) ⟩
(universal pullback-⟨fg⟩h _ ∘ p₁ pullback-⟨f⟨gh⟩⟩i) ∘ universal pullback-⟨f⟨gh⟩⟩i _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center (p₁∘universal≈h₁ pullback-⟨f⟨gh⟩⟩i) ⟩
universal pullback-⟨fg⟩h _ ∘ universal pullback-f⟨gh⟩ _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ unique-diagram pullback-⟨fg⟩h lemma-⟨fg⟩hˡ lemma-⟨fg⟩hʳ ⟩
universal pullback-⟨fg⟩h _ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ≈⟨ pushˡ (⟺ (p₁∘universal≈h₁ pullback-⟨⟨fg⟩h⟩i)) ⟩
p₁ pullback-⟨⟨fg⟩h⟩i ∘ universal pullback-⟨⟨fg⟩h⟩i _ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ∎
lemmaʳ = begin
p₂ pullback-⟨⟨fg⟩h⟩i ∘ universal pullback-⟨⟨fg⟩h⟩i _ ∘ universal pullback-⟨f⟨gh⟩⟩i _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-⟨⟨fg⟩h⟩i) ⟩
(id ∘ p₂ pullback-⟨f⟨gh⟩⟩i) ∘ universal pullback-⟨f⟨gh⟩⟩i _ ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center (p₂∘universal≈h₂ pullback-⟨f⟨gh⟩⟩i) ⟩
id ∘ (p₂ pullback-⟨gh⟩i ∘ p₂ pullback-f⟨⟨gh⟩i⟩) ∘ universal pullback-f⟨⟨gh⟩i⟩ _ ≈⟨ center⁻¹ identityˡ (p₂∘universal≈h₂ pullback-f⟨⟨gh⟩i⟩) ⟩
p₂ pullback-⟨gh⟩i ∘ universal pullback-⟨gh⟩i _ ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ pullˡ (p₂∘universal≈h₂ pullback-⟨gh⟩i) ⟩
(p₂ pullback-hi ∘ p₂ pullback-g⟨hi⟩) ∘ p₂ pullback-f⟨g⟨hi⟩⟩ ≈⟨ extendˡ (⟺ (p₂∘universal≈h₂ pullback-⟨fg⟩⟨hi⟩)) ⟩
(p₂ pullback-hi ∘ p₂ pullback-⟨fg⟩⟨hi⟩) ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ≈⟨ pushˡ (⟺ (p₂∘universal≈h₂ pullback-⟨⟨fg⟩h⟩i)) ⟩
p₂ pullback-⟨⟨fg⟩h⟩i ∘ universal pullback-⟨⟨fg⟩h⟩i _ ∘ universal pullback-⟨fg⟩⟨hi⟩ _ ∎
in unique-diagram pullback-⟨⟨fg⟩h⟩i lemmaˡ lemmaʳ
Spans : Bicategory (o ⊔ ℓ) (o ⊔ ℓ ⊔ e) e o
Spans = record
{ enriched = record
{ Obj = Obj
; hom = Spans₁
; id = λ {A} → record
{ F₀ = λ _ → id-span
; F₁ = λ _ → Spans₁.id A A
; identity = refl
; homomorphism = ⟺ identity²
; F-resp-≈ = λ _ → refl
}
; ⊚ = record
{ F₀ = λ (f , g) → f ⊚₀ g
; F₁ = λ (α , β) → α ⊚₁ β
; identity = λ {(f , g)} → ⊚₁-identity f g
; homomorphism = λ {X} {Y} {Z} {(α , α′)} {(β , β′)} → ⊚₁-homomorphism α β α′ β′
; F-resp-≈ = λ {(f , g)} {(f′ , g′)} {_} {_} (α-eq , β-eq) → universal-resp-≈ ((cod g′) ×ₚ (dom f′)) (∘-resp-≈ˡ β-eq) (∘-resp-≈ˡ α-eq)
}
; ⊚-assoc = niHelper record
{ η = λ ((f , g) , h) → ⊚-assoc f g h
; η⁻¹ = λ ((f , g) , h) → ⊚-assoc⁻¹ f g h
; commute = λ ((α , β) , γ) → ⊚-assoc-commute α β γ
; iso = λ ((f , g) , h) → ⊚-assoc-iso f g h
}
; unitˡ = niHelper record
{ η = λ (_ , f) → ⊚-unitˡ f
; η⁻¹ = λ (_ , f) → ⊚-unitˡ⁻¹ f
; commute = λ (_ , α) → ⊚-unitˡ-commute α
; iso = λ (_ , f) → ⊚-unitˡ-iso f
}
; unitʳ = niHelper record
{ η = λ (f , _) → ⊚-unitʳ f
; η⁻¹ = λ (f , _) → ⊚-unitʳ⁻¹ f
; commute = λ (α , _) → ⊚-unitʳ-commute α
; iso = λ (f , _) → ⊚-unitʳ-iso f
}
}
; triangle = λ {_} {_} {_} {f} {g} → triangle f g
; pentagon = λ {_} {_} {_} {_} {_} {f} {g} {h} {i} → pentagon f g h i
}
| {
"alphanum_fraction": 0.513757542,
"avg_line_length": 62.3173333333,
"ext": "agda",
"hexsha": "b62a5452bdc6ebc8852319933d84f97b1b1066dc",
"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/Construction/Spans.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/Construction/Spans.agda",
"max_line_length": 216,
"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/Construction/Spans.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": 9758,
"size": 23369
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.NaturalTransformation where
open import Cubical.Foundations.Prelude
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
private
variable
ℓC ℓC' ℓD ℓD' : Level
module _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where
-- syntax for sequencing in category D
_⋆ᴰ_ : ∀ {x y z} (f : D [ x , y ]) (g : D [ y , z ]) → D [ x , z ]
f ⋆ᴰ g = f ⋆⟨ D ⟩ g
record NatTrans (F G : Functor C D) : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
open Precategory
open Functor
field
-- components of the natural transformation
N-ob : (x : C .ob) → D [(F .F-ob x) , (G .F-ob x)]
-- naturality condition
N-hom : {x y : C .ob} (f : C [ x , y ]) → (F .F-hom f) ⋆ᴰ (N-ob y) ≡ (N-ob x) ⋆ᴰ (G .F-hom f)
open Precategory
open Functor
open NatTrans
idTrans : (F : Functor C D) → NatTrans F F
idTrans F .N-ob x = D .id (F .F-ob x)
idTrans F .N-hom f =
(F .F-hom f) ⋆ᴰ (idTrans F .N-ob _)
≡⟨ D .⋆IdR _ ⟩
F .F-hom f
≡⟨ sym (D .⋆IdL _) ⟩
(D .id (F .F-ob _)) ⋆ᴰ (F .F-hom f)
∎
seqTrans : {F G H : Functor C D} (α : NatTrans F G) (β : NatTrans G H) → NatTrans F H
seqTrans α β .N-ob x = (α .N-ob x) ⋆ᴰ (β .N-ob x)
seqTrans {F} {G} {H} α β .N-hom f =
(F .F-hom f) ⋆ᴰ ((α .N-ob _) ⋆ᴰ (β .N-ob _))
≡⟨ sym (D .⋆Assoc _ _ _) ⟩
((F .F-hom f) ⋆ᴰ (α .N-ob _)) ⋆ᴰ (β .N-ob _)
≡[ i ]⟨ (α .N-hom f i) ⋆ᴰ (β .N-ob _) ⟩
((α .N-ob _) ⋆ᴰ (G .F-hom f)) ⋆ᴰ (β .N-ob _)
≡⟨ D .⋆Assoc _ _ _ ⟩
(α .N-ob _) ⋆ᴰ ((G .F-hom f) ⋆ᴰ (β .N-ob _))
≡[ i ]⟨ (α .N-ob _) ⋆ᴰ (β .N-hom f i) ⟩
(α .N-ob _) ⋆ᴰ ((β .N-ob _) ⋆ᴰ (H .F-hom f))
≡⟨ sym (D .⋆Assoc _ _ _) ⟩
((α .N-ob _) ⋆ᴰ (β .N-ob _)) ⋆ᴰ (H .F-hom f)
∎
module _ ⦃ D-category : isCategory D ⦄ {F G : Functor C D} {α β : NatTrans F G} where
open Precategory
open Functor
open NatTrans
makeNatTransPath : α .N-ob ≡ β .N-ob → α ≡ β
makeNatTransPath p i .N-ob = p i
makeNatTransPath p i .N-hom f = rem i
where
rem : PathP (λ i → (F .F-hom f) ⋆ᴰ (p i _) ≡ (p i _) ⋆ᴰ (G .F-hom f)) (α .N-hom f) (β .N-hom f)
rem = toPathP (D-category .isSetHom _ _ _ _)
module _ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') ⦃ _ : isCategory D ⦄ where
open Precategory
open NatTrans
open Functor
FUNCTOR : Precategory (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD'))
FUNCTOR .ob = Functor C D
FUNCTOR .Hom[_,_] = NatTrans
FUNCTOR .id = idTrans
FUNCTOR ._⋆_ = seqTrans
FUNCTOR .⋆IdL α = makeNatTransPath λ i x → D .⋆IdL (α .N-ob x) i
FUNCTOR .⋆IdR α = makeNatTransPath λ i x → D .⋆IdR (α .N-ob x) i
FUNCTOR .⋆Assoc α β γ = makeNatTransPath λ i x → D .⋆Assoc (α .N-ob x) (β .N-ob x) (γ .N-ob x) i
| {
"alphanum_fraction": 0.5330766538,
"avg_line_length": 32.8390804598,
"ext": "agda",
"hexsha": "d540f18817be25550f844c843e7b3e09587d065a",
"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": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "apabepa10/cubical",
"max_forks_repo_path": "Cubical/Categories/NaturalTransformation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"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": "apabepa10/cubical",
"max_issues_repo_path": "Cubical/Categories/NaturalTransformation.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "apabepa10/cubical",
"max_stars_repo_path": "Cubical/Categories/NaturalTransformation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1356,
"size": 2857
} |
{-
Part 3: Univalence and the SIP
- Univalence from ua and uaβ
- Transporting with ua (examples: ua not : Bool = Bool, ua suc : Z = Z, ...)
- Subst using ua
- The SIP as a consequence of ua
- Examples of using the SIP for math and programming (algebra, data
structures, etc.)
-}
{-# OPTIONS --cubical #-}
module Part3 where
open import Cubical.Foundations.Prelude hiding (refl ; transport ; subst ; sym)
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Int
open import Part2 public
-- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical
-- Agda this is provable, we hence refer to it as the Univalence
-- Theorem.
-- The univalence theorem: equivalences of types give paths of types
ua' : {A B : Type ℓ} → A ≃ B → A ≡ B
ua' = ua
-- Any isomorphism of types gives rise to an equivalence
isoToEquiv' : {A B : Type ℓ} → Iso A B → A ≃ B
isoToEquiv' = isoToEquiv
-- And hence to a path
isoToPath' : {A B : Type ℓ} → Iso A B → A ≡ B
isoToPath' e = ua' (isoToEquiv' e)
-- ua satisfies the following computation rule
-- This suffices to be able to prove the standard formulation of univalence.
uaβ' : {A B : Type ℓ} (e : A ≃ B) (x : A)
→ transport (ua' e) x ≡ fst e x
uaβ' e x = transportRefl (equivFun e x)
-- Time for an example!
-- Booleans
data Bool : Type₀ where
false true : Bool
not : Bool → Bool
not false = true
not true = false
notPath : Bool ≡ Bool
notPath = isoToPath' (iso not not rem rem)
where
rem : (b : Bool) → not (not b) ≡ b
rem false = refl
rem true = refl
_ : transport notPath true ≡ false
_ = refl
-- Another example, integers:
sucPath : Int ≡ Int
sucPath = isoToPath' (iso sucInt predInt sucPred predSuc)
_ : transport sucPath (pos 0) ≡ pos 1
_ = refl
_ : transport (sucPath ∙ sucPath) (pos 0) ≡ pos 2
_ = refl
_ : transport (sym sucPath) (pos 0) ≡ negsuc 0
_ = refl
-------------------------------------------------------------------------
-- The structure identity principle
-- A more efficient version of finite multisets based on association lists
open import Cubical.HITs.AssocList.Base
-- data AssocList (A : Type) : Type where
-- ⟨⟩ : AssocList A
-- ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A
-- per : (a b : A) (m n : ℕ) (xs : AssocList A)
-- → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs
-- agg : (a : A) (m n : ℕ) (xs : AssocList A)
-- → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs
-- del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs
-- trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q
-- Programming and proving is more complicated with AssocList compared
-- to FMSet. This kind of example occurs everywhere in programming and
-- mathematics: one representation is easier to work with, but not
-- efficient, while another is efficient but difficult to work with.
-- Solution: substitute using univalence
substIso : {A B : Type ℓ} (P : Type ℓ → Type ℓ') (e : Iso A B) → P A → P B
substIso P e = subst P (isoToPath e)
-- Can transport for example Monoid structure from FMSet to AssocList
-- this way, but the achieved Monoid structure is not very efficient
-- to work with. A better solution is to prove that FMSet and
-- AssocList are equal *as monoids*, but how to do this?
-- Solution: structure identity principle (SIP)
-- This is a very useful consequence of univalence
open import Cubical.Foundations.SIP
{-
sip' : {ℓ : Level} {S : Type ℓ → Type ℓ} {ι : StrEquiv S ℓ}
(θ : UnivalentStr S ι) (A B : TypeWithStr ℓ S) → A ≃[ ι ] B → A ≡ B
sip' = sip
-}
-- The tricky thing is to prove that (S,ι) is a univalent structure.
-- Luckily we provide automation for this in the library, see for example:
-- open import Cubical.Algebra.Monoid.Base
-- Another cool application of the SIP: matrices represented as
-- functions out of pairs of Fin's and vectors are equal as abelian
-- groups:
open import Cubical.Algebra.Matrix
| {
"alphanum_fraction": 0.6552677898,
"avg_line_length": 29.2426470588,
"ext": "agda",
"hexsha": "3a4671b2636af99a7a6c69d76969358acf18d42c",
"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": "54b18e4adf890b3533bbefda373912423be7f490",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tomdjong/EPIT-2020",
"max_forks_repo_path": "04-cubical-type-theory/material/Part3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"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": "tomdjong/EPIT-2020",
"max_issues_repo_path": "04-cubical-type-theory/material/Part3.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tomdjong/EPIT-2020",
"max_stars_repo_path": "04-cubical-type-theory/material/Part3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1261,
"size": 3977
} |
{-# OPTIONS --cubical --safe #-}
module Fin where
open import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_)
open import Cubical.Foundations.Prelude using (refl; sym; _∙_; cong; transport; subst; funExt; transp; I; i0; i1)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract)
open import Data.Fin using (Fin; toℕ; fromℕ<; #_; _≟_) renaming (zero to fz; suc to fs)
open import Data.Nat using (ℕ; zero; suc; _<_; _>_; z≤n; s≤s)
-- Alternate representation of Fin as a number and proof of its upper bound.
record Fin1 (n : ℕ) : Type where
constructor fin1
field
r : ℕ
r<n : r < n
fin1suc : {n : ℕ} → Fin1 n → Fin1 (suc n)
fin1suc (fin1 r r<n) = fin1 (suc r) (s≤s r<n)
-- From Data.Fin.Properites
-- They need to be re-defined here since Cubical uses a different ≡
fromℕ<-toℕ : ∀ {m} (i : Fin m) (i<m : toℕ i < m) → fromℕ< i<m ≡ i
fromℕ<-toℕ fz (s≤s z≤n) = refl
fromℕ<-toℕ (fs i) (s≤s (s≤s m≤n)) = cong fs (fromℕ<-toℕ i (s≤s m≤n))
toℕ-fromℕ< : ∀ {m n} (m<n : m < n) → toℕ (fromℕ< m<n) ≡ m
toℕ-fromℕ< (s≤s z≤n) = refl
toℕ-fromℕ< (s≤s (s≤s m<n)) = cong suc (toℕ-fromℕ< (s≤s m<n))
toℕ<n : ∀ {n} (i : Fin n) → toℕ i < n
toℕ<n fz = s≤s z≤n
toℕ<n (fs i) = s≤s (toℕ<n i)
-------------------
-- Equivalence of Fin and Fin1
fin→fin1 : {n : ℕ} → Fin n → Fin1 n
fin→fin1 fz = fin1 0 (s≤s z≤n)
fin→fin1 (fs x) = let fin1 r r<n = fin→fin1 x in fin1 (suc r) (s≤s r<n)
fin1→fin : {n : ℕ} → Fin1 n → Fin n
fin1→fin (fin1 _ r<n) = fromℕ< r<n
fin→fin1→fin : {n : ℕ} → (r : Fin n) → (fin1→fin ∘ fin→fin1) r ≡ r
fin→fin1→fin fz = refl
fin→fin1→fin (fs r) = cong fs (fin→fin1→fin r)
fin1→fin→fin1 : {n : ℕ} → (r : Fin1 n) → (fin→fin1 ∘ fin1→fin) r ≡ r
fin1→fin→fin1 (fin1 zero (s≤s z≤n)) = refl
fin1→fin→fin1 (fin1 (suc r) (s≤s (s≤s r<n))) = cong fin1suc (fin1→fin→fin1 (fin1 r (s≤s r<n)))
fin≃fin1 : {n : ℕ} → Iso (Fin n) (Fin1 n)
fin≃fin1 = iso fin→fin1 fin1→fin fin1→fin→fin1 fin→fin1→fin
fin≡fin1 : {n : ℕ} → Fin n ≡ Fin1 n
fin≡fin1 = isoToPath fin≃fin1
-- Equivalence of toℕ and Fin1.r
toℕ≡Fin1r1 : {n : ℕ} → (r : Fin n) → toℕ r ≡ Fin1.r (fin→fin1 r)
toℕ≡Fin1r1 fz = refl
toℕ≡Fin1r1 (fs r) = cong suc (toℕ≡Fin1r1 r)
toℕ≡Fin1r : {n : ℕ} → toℕ {n} ≡ Fin1.r ∘ fin→fin1
toℕ≡Fin1r = funExt toℕ≡Fin1r1
Fin1r≡toℕ1 : {n : ℕ} → (r : Fin1 n) → toℕ (fin1→fin r) ≡ Fin1.r r
Fin1r≡toℕ1 (fin1 r r<n) = toℕ-fromℕ< r<n
Fin1r≡toℕ : {n : ℕ} → toℕ {n} ∘ fin1→fin ≡ Fin1.r
Fin1r≡toℕ = funExt Fin1r≡toℕ1
| {
"alphanum_fraction": 0.5875048506,
"avg_line_length": 33.0384615385,
"ext": "agda",
"hexsha": "9c56b13cf32352bd7ed8ef8d82fe5e1e5dc419e4",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/Fin.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/Fin.agda",
"max_line_length": 117,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/Fin.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 1251,
"size": 2577
} |
----------------------------------------------------------------------
-- Functional big-step evaluation of terms in the partiality monad
-- (alternative version not productivity checker workarounds)
----------------------------------------------------------------------
module SystemF.Eval.NoWorkarounds where
open import Codata.Musical.Notation using (∞; ♯_; ♭)
open import Category.Monad
open import Category.Monad.Partiality.All
open import Data.Fin using (Fin; zero; suc)
open import Data.Maybe as Maybe using (just; nothing)
open import Data.Maybe.Relation.Unary.Any as MaybeAny using (just)
open import Data.Nat using (_+_)
open import Data.Vec using ([])
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import PartialityAndFailure as PF
open PF.Equality hiding (fail)
private
open module M {f} = RawMonad (PF.monad {f}) using (return; _>>=_)
open import SystemF.Type
open import SystemF.Term
open import SystemF.WtTerm
open TypeSubst using () renaming (_[/_] to _[/tp_])
open TermTypeSubst using () renaming (_[/_] to _[/tmTp_])
open TermTermSubst using () renaming (_[/_] to _[/tmTm_])
open WtTermTypeSubst using () renaming (_[/_]′ to _[/⊢tmTp_])
open WtTermTermSubst using () renaming (_[/_] to _[/⊢tmTm_])
open import SystemF.Eval as E
using (Comp; _⊢comp_∈_; does-not-fail)
----------------------------------------------------------------------
-- Functional big-step semantics (alternative version)
--
-- The evaluation function _⇓ given below differs from that in
-- SystemF.Eval in that it evaluates terms directly in the
-- partiality-and-failure monad (rather than first evaluating them in
-- PartialityAndFailure.Workaround._?⊥P and subsequently interpreting
-- the result in PartialityAndFailure._?⊥). This is achieved by
-- manually expanding and inlining every application of the monadic
-- bind operation.
--
-- We give a separate type soundness proof formulated with respect to
-- the alternative semantics, as well as a proof that the two
-- semantics are equivalent (i.e. the two evaluations of any given
-- term are bisimilar).
--
-- The definition of the alternative semantics is more verbose and
-- arguably less readable. However the associated type soundness
-- proof is simpler in that it requires no additional compositionality
-- lemmas.
module _ where
open M
mutual
infix 7 _⇓ _[_]⇓ _·⇓_
-- Evaluation of untyped (open) terms.
_⇓ : ∀ {m n} → Term m n → Comp m n
var x ⇓ = fail
Λ t ⇓ = return (Λ t)
λ' a t ⇓ = return (λ' a t)
μ a t ⇓ = later (♯ (t [/tmTm μ a t ] ⇓))
(t [ a ]) ⇓ with t ⇓
... | c = c [ a ]⇓
(s · t) ⇓ with s ⇓ | t ⇓
... | f | c = f ·⇓ c
fold a t ⇓ with t ⇓
... | c = fold⇓ a c
unfold a t ⇓ with t ⇓
... | c = unfold⇓ a c
-- Evaluation of type application.
_[_]⇓ : ∀ {m n} → Comp m n → Type n → Comp m n
now (just (Λ t)) [ a ]⇓ = later (♯ (t [/tmTp a ] ⇓))
now (just _) [ _ ]⇓ = fail
now nothing [ _ ]⇓ = fail
later c [ a ]⇓ = later (♯ ((♭ c) [ a ]⇓))
-- Evaluation of term application.
_·⇓_ : ∀ {m n} → Comp m n → Comp m n → Comp m n
now (just (λ' _ t)) ·⇓ now (just v) = later (♯ (t [/tmTm ⌜ v ⌝ ] ⇓))
now (just _) ·⇓ now _ = fail
now nothing ·⇓ _ = fail
now f ·⇓ later c = later (♯ (now f ·⇓ (♭ c)))
later f ·⇓ c = later (♯ ((♭ f) ·⇓ c))
-- Evaluation of recursive type folding.
fold⇓ : ∀ {m n} → Type (1 + n) → Comp m n → Comp m n
fold⇓ a (now (just v)) = now (just (fold a v))
fold⇓ _ (now nothing) = fail
fold⇓ a (later c) = later (♯ fold⇓ a (♭ c))
-- Evaluation of recursive type unfolding.
unfold⇓ : ∀ {m n} → Type (1 + n) → Comp m n → Comp m n
unfold⇓ _ (now (just (fold _ v))) = now (just v)
unfold⇓ a (now (just _)) = fail
unfold⇓ a (now nothing) = fail
unfold⇓ a (later c) = later (♯ unfold⇓ a (♭ c))
----------------------------------------------------------------------
-- Type soundness wrt. to the alternative semantics
infix 4 ⊢comp_∈_
-- Short hand for closed well-typed computations.
⊢comp_∈_ : Comp 0 0 → Type 0 → Set
⊢comp c ∈ a = [] ⊢comp c ∈ a
mutual
infix 7 ⊢_⇓ ⊢_[_]⇓ ⊢_·⇓_
-- Evaluation of closed terms preserves well-typedness.
⊢_⇓ : ∀ {t a} → [] ⊢ t ∈ a → ⊢comp t ⇓ ∈ a
⊢ var () ⇓
⊢ Λ ⊢t ⇓ = now (just (Λ ⊢t))
⊢ λ' a ⊢t ⇓ = now (just (λ' a ⊢t))
⊢ μ a ⊢t ⇓ = later (♯ ⊢ ⊢t [/⊢tmTm μ a ⊢t ] ⇓)
⊢ ⊢t [ a ] ⇓ with ⊢ ⊢t ⇓
... | ⊢c = ⊢ ⊢c [ a ]⇓
⊢ ⊢s · ⊢t ⇓ with ⊢ ⊢s ⇓ | ⊢ ⊢t ⇓
... | ⊢f | ⊢c = ⊢ ⊢f ·⇓ ⊢c
⊢ fold a ⊢t ⇓ with ⊢ ⊢t ⇓
... | ⊢c = ⊢fold⇓ a ⊢c
⊢ unfold a ⊢t ⇓ with ⊢ ⊢t ⇓
... | ⊢c = ⊢unfold⇓ a ⊢c
-- Evaluation of type application preserves well-typedness.
⊢_[_]⇓ : ∀ {c a} → ⊢comp c ∈ ∀' a → ∀ b → ⊢comp c [ b ]⇓ ∈ a [/tp b ]
⊢ now (just (Λ ⊢t)) [ a ]⇓ = later (♯ ⊢ ⊢t [/⊢tmTp a ] ⇓)
⊢ later ⊢c [ a ]⇓ = later (♯ ⊢ (♭ ⊢c) [ a ]⇓)
-- Evaluation of term application preserves well-typedness.
⊢_·⇓_ : ∀ {f c a b} → ⊢comp f ∈ a →' b → ⊢comp c ∈ a → ⊢comp f ·⇓ c ∈ b
⊢ now (just (λ' a ⊢t)) ·⇓ now (just ⊢v) =
later (♯ (⊢ ⊢t [/⊢tmTm ⊢⌜ ⊢v ⌝ ] ⇓))
⊢ now (just (λ' a ⊢t)) ·⇓ later ⊢c =
later (♯ (⊢ now (just (λ' a ⊢t)) ·⇓ ♭ ⊢c))
⊢ later ⊢f ·⇓ ⊢c = later (♯ (⊢ ♭ ⊢f ·⇓ ⊢c))
-- Evaluation of recursive type folding preserves well-typedness.
⊢fold⇓ : ∀ {c} a → ⊢comp c ∈ a [/tp μ a ] → ⊢comp fold⇓ a c ∈ μ a
⊢fold⇓ a (now (just ⊢v)) = now (just (fold a ⊢v))
⊢fold⇓ a (later ⊢c) = later (♯ ⊢fold⇓ a (♭ ⊢c))
-- Evaluation of recursive type unfolding preserves well-typedness.
⊢unfold⇓ : ∀ {c} a → ⊢comp c ∈ μ a → ⊢comp unfold⇓ a c ∈ a [/tp μ a ]
⊢unfold⇓ _ (now (just (fold ._ ⊢v))) = now (just ⊢v)
⊢unfold⇓ a (later ⊢c) = later (♯ ⊢unfold⇓ a (♭ ⊢c))
-- Type soundness: evaluation of well-typed terms does not fail.
type-soundness : ∀ {t a} → [] ⊢ t ∈ a → ¬ t ⇓ ≈ fail
type-soundness ⊢t = does-not-fail ⊢ ⊢t ⇓
----------------------------------------------------------------------
-- Equivalence (bisimilarity) of big-step semantics
open PF.Workaround using (⟦_⟧P)
open PF.Equivalence hiding (sym)
open PF.AlternativeEquality
renaming (return to returnP; fail to failP; _>>=_ to _>>=P_)
-- Bind-expanded variants of the various helpers of of _⇓.
_[_]⇓′ : ∀ {m n} → Comp m n → Type n → Comp m n
c [ a ]⇓′ = c >>= λ v → (return v) [ a ]⇓
_·⇓′_ : ∀ {m n} → Comp m n → Comp m n → Comp m n
c ·⇓′ d = c >>= λ f → d >>= λ v → (return f) ·⇓ (return v)
fold⇓′ : ∀ {m n} → Type (1 + n) → Comp m n → Comp m n
fold⇓′ a c = c >>= λ v → fold⇓ a (return v)
unfold⇓′ : ∀ {m n} → Type (1 + n) → Comp m n → Comp m n
unfold⇓′ a c = c >>= λ v → unfold⇓ a (return v)
-- The two variants of _[_]⇓ are strongly bisimilar.
_[_]⇓≅ : ∀ {m n} (c : Comp m n) (a : Type n) → c [ a ]⇓ ≅ c [ a ]⇓′
now (just _) [ _ ]⇓≅ = refl P.refl
now nothing [ _ ]⇓≅ = now P.refl
later c [ a ]⇓≅ = later (♯ ((♭ c) [ a ]⇓≅))
-- The two variants of _·⇓_ are strongly bisimilar.
_·⇓≅_ : ∀ {m n} (c : Comp m n) (d : Comp m n) → c ·⇓ d ≅ c ·⇓′ d
now (just _) ·⇓≅ now (just _) = refl P.refl
now (just (Λ t)) ·⇓≅ now nothing = now P.refl
now (just (λ' a t)) ·⇓≅ now nothing = now P.refl
now (just (fold a t)) ·⇓≅ now nothing = now P.refl
now nothing ·⇓≅ now v = now P.refl
now (just (Λ t)) ·⇓≅ later d = later (♯ (now (just (Λ t)) ·⇓≅ ♭ d))
now (just (λ' a t)) ·⇓≅ later d = later (♯ (now (just (λ' a t)) ·⇓≅ ♭ d))
now (just (fold a t)) ·⇓≅ later d = later (♯ (now (just (fold a t)) ·⇓≅ ♭ d))
now nothing ·⇓≅ later d = now P.refl
later c ·⇓≅ d = later (♯ ((♭ c) ·⇓≅ d))
-- The two variants of fold⇓ are strongly bisimilar.
fold⇓≅ : ∀ {m n} (a : Type (1 + n)) (c : Comp m n) → fold⇓ a c ≅ fold⇓′ a c
fold⇓≅ a (now (just v)) = now P.refl
fold⇓≅ a (now nothing) = now P.refl
fold⇓≅ a (later c) = later (♯ fold⇓≅ a (♭ c))
-- The two variants of unfold⇓ are strongly bisimilar.
unfold⇓≅ : ∀ {m n} (a : Type (1 + n)) (c : Comp m n) →
unfold⇓ a c ≅ unfold⇓′ a c
unfold⇓≅ a (now (just v)) = refl P.refl
unfold⇓≅ a (now nothing) = now P.refl
unfold⇓≅ a (later c) = later (♯ unfold⇓≅ a (♭ c))
mutual
-- Helper lemma relating the two semantics of type application.
[]-E⇓≅⇓′ : ∀ {m n} (v : Val m n) (a : Type n) →
⟦ v E.[ a ]′ ⟧P ≅P (return v) [ a ]⇓
[]-E⇓≅⇓′ (Λ t) a = later (♯ E⇓≅⇓′ (t [/tmTp a ] ))
[]-E⇓≅⇓′ (λ' _ _) _ = failP
[]-E⇓≅⇓′ (fold _ _) _ = failP
-- Helper lemma relating the two semantics of term application.
·-E⇓≅⇓′ : ∀ {m n} (f : Val m n) (v : Val m n) →
⟦ f E.·′ v ⟧P ≅P (return f) ·⇓ (return v)
·-E⇓≅⇓′ (Λ _) _ = failP
·-E⇓≅⇓′ (λ' a t) v = later (♯ E⇓≅⇓′ (t [/tmTm ⌜ v ⌝ ]))
·-E⇓≅⇓′ (fold _ _) _ = failP
-- Helper lemma relating the two semantics of recursive type
-- unfolding.
unfold-E⇓≅⇓′ : ∀ {m n} (a : Type (1 + n)) (v : Val m n) →
⟦ E.unfold′ a v ⟧P ≅P unfold⇓ a (return v)
unfold-E⇓≅⇓′ _ (Λ _) = failP
unfold-E⇓≅⇓′ _ (λ' _ _) = failP
unfold-E⇓≅⇓′ _ (fold _ _) = returnP P.refl
-- The two semantics are ≅P-equivalent.
E⇓≅⇓′ : ∀ {m n} (t : Term m n) → t E.⇓ ≅P t ⇓
E⇓≅⇓′ (var x) = failP
E⇓≅⇓′ (Λ t) = returnP P.refl
E⇓≅⇓′ (λ' a t) = returnP P.refl
E⇓≅⇓′ (μ a t) = later (♯ E⇓≅⇓′ (t [/tmTm μ a t ]))
E⇓≅⇓′ (t [ a ]) =
t [ a ] E.⇓ ≅⟨ complete (E.[]-comp t a) ⟩
(t E.⇓) E.[ a ]⇓ ≅⟨ (E⇓≅⇓′ t >>=P λ v → []-E⇓≅⇓′ v a) ⟩
(t ⇓) [ a ]⇓′ ≅⟨ sym (complete ((t ⇓) [ a ]⇓≅)) ⟩
t [ a ] ⇓ ∎
E⇓≅⇓′ (s · t) =
s · t E.⇓ ≅⟨ complete (E.·-comp s t) ⟩
(s E.⇓) E.·⇓ (t E.⇓) ≅⟨ (E⇓≅⇓′ s >>=P λ f → E⇓≅⇓′ t >>=P λ v →
·-E⇓≅⇓′ f v) ⟩
(s ⇓) ·⇓′ (t ⇓) ≅⟨ sym (complete ((s ⇓) ·⇓≅ (t ⇓))) ⟩
s · t ⇓ ∎
E⇓≅⇓′ (fold a t) =
fold a t E.⇓ ≅⟨ complete (E.fold-comp a t) ⟩
E.fold⇓ a (t E.⇓) ≅⟨ (E⇓≅⇓′ t >>=P λ v → return (fold a v) ∎) ⟩
fold⇓′ a (t ⇓) ≅⟨ sym (complete (fold⇓≅ a (t ⇓))) ⟩
fold a t ⇓ ∎
E⇓≅⇓′ (unfold a t) =
unfold a t E.⇓ ≅⟨ complete (E.unfold-comp a t) ⟩
E.unfold⇓ a (t E.⇓) ≅⟨ (E⇓≅⇓′ t >>=P λ v → unfold-E⇓≅⇓′ a v) ⟩
unfold⇓′ a (t ⇓) ≅⟨ sym (complete (unfold⇓≅ a (t ⇓))) ⟩
unfold a t ⇓ ∎
-- The two big-step semantics are strongly bisimliar.
E⇓≅⇓ : ∀ {m n} (t : Term m n) → t E.⇓ ≅ t ⇓
E⇓≅⇓ t = sound (E⇓≅⇓′ t)
| {
"alphanum_fraction": 0.4878957169,
"avg_line_length": 39.0545454545,
"ext": "agda",
"hexsha": "ae0f8e39dc6b305fad21d749c96046a283942a8d",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-07-06T23:12:48.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-29T12:24:46.000Z",
"max_forks_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sstucki/system-f-agda",
"max_forks_repo_path": "src/SystemF/Eval/NoWorkarounds.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T19:23:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-05-30T06:43:04.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "sstucki/system-f-agda",
"max_issues_repo_path": "src/SystemF/Eval/NoWorkarounds.agda",
"max_line_length": 77,
"max_stars_count": 68,
"max_stars_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sstucki/system-f-agda",
"max_stars_repo_path": "src/SystemF/Eval/NoWorkarounds.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T01:25:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-26T13:12:56.000Z",
"num_tokens": 4640,
"size": 10740
} |
module Agda.Builtin.Int where
open import Agda.Builtin.Nat
open import Agda.Builtin.String
infix 8 pos -- Standard library uses this as +_
data Int : Set where
pos : (n : Nat) → Int
negsuc : (n : Nat) → Int
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN INTEGERPOS pos #-}
{-# BUILTIN INTEGERNEGSUC negsuc #-}
primitive primShowInteger : Int → String
| {
"alphanum_fraction": 0.6568364611,
"avg_line_length": 20.7222222222,
"ext": "agda",
"hexsha": "22267f9d48c8c8ea2569c21eced19c1eb01bc3c7",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Int.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"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": "redfish64/autonomic-agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Int.agda",
"max_line_length": 48,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Int.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 108,
"size": 373
} |
module Stack where
open import Prelude public
-- Stacks, or snoc-lists.
data Stack (X : Set) : Set where
∅ : Stack X
_,_ : Stack X → X → Stack X
-- Stack membership, or de Bruijn indices.
module _ {X : Set} where
infix 3 _∈_
data _∈_ (A : X) : Stack X → Set where
top : ∀ {Γ} → A ∈ Γ , A
pop : ∀ {B Γ} → A ∈ Γ → A ∈ Γ , B
i₀ : ∀ {A Γ} → A ∈ Γ , A
i₀ = top
i₁ : ∀ {A B Γ} → A ∈ Γ , A , B
i₁ = pop i₀
i₂ : ∀ {A B C Γ} → A ∈ Γ , A , B , C
i₂ = pop i₁
-- Stack inclusion, or order-preserving embeddings.
module _ {X : Set} where
infix 3 _⊆_
data _⊆_ : Stack X → Stack X → Set where
done : ∅ ⊆ ∅
skip : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊆ Γ′ , A
keep : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ , A ⊆ Γ′ , A
bot⊆ : ∀ {Γ} → ∅ ⊆ Γ
bot⊆ {∅} = done
bot⊆ {Γ , A} = skip bot⊆
refl⊆ : ∀ {Γ} → Γ ⊆ Γ
refl⊆ {∅} = done
refl⊆ {Γ , A} = keep refl⊆
trans⊆ : ∀ {Γ Γ′ Γ″} → Γ ⊆ Γ′ → Γ′ ⊆ Γ″ → Γ ⊆ Γ″
trans⊆ p done = p
trans⊆ p (skip p′) = skip (trans⊆ p p′)
trans⊆ (skip p) (keep p′) = skip (trans⊆ p p′)
trans⊆ (keep p) (keep p′) = keep (trans⊆ p p′)
weak⊆ : ∀ {A Γ} → Γ ⊆ Γ , A
weak⊆ = skip refl⊆
idtrans⊆ : ∀ {Γ Γ′ } → (p : Γ ⊆ Γ′) → trans⊆ refl⊆ p ≡ p
idtrans⊆ done = refl
idtrans⊆ (skip p) = cong skip (idtrans⊆ p)
idtrans⊆ (keep p) = cong keep (idtrans⊆ p)
idtrans⊆′ : ∀ {Γ Γ′} → (p : Γ ⊆ Γ′) → trans⊆ p refl⊆ ≡ p
idtrans⊆′ done = refl
idtrans⊆′ (skip p) = cong skip (idtrans⊆′ p)
idtrans⊆′ (keep p) = cong keep (idtrans⊆′ p)
assoctrans⊆ : ∀ {Γ Γ′ Γ″ Γ‴} → (p : Γ ⊆ Γ′) (p′ : Γ′ ⊆ Γ″) (p″ : Γ″ ⊆ Γ‴) →
trans⊆ (trans⊆ p p′) p″ ≡ trans⊆ p (trans⊆ p′ p″)
assoctrans⊆ p p′ done = refl
assoctrans⊆ p p′ (skip p″) = cong skip (assoctrans⊆ p p′ p″)
assoctrans⊆ p (skip p′) (keep p″) = cong skip (assoctrans⊆ p p′ p″)
assoctrans⊆ (skip p) (keep p′) (keep p″) = cong skip (assoctrans⊆ p p′ p″)
assoctrans⊆ (keep p) (keep p′) (keep p″) = cong keep (assoctrans⊆ p p′ p″)
-- Monotonicity of stack membership with respect to stack inclusion.
module _ {X : Set} where
mono∈ : ∀ {A : X} {Γ Γ′} → Γ ⊆ Γ′ → A ∈ Γ → A ∈ Γ′
mono∈ done ()
mono∈ (skip p) i = pop (mono∈ p i)
mono∈ (keep p) top = top
mono∈ (keep p) (pop i) = pop (mono∈ p i)
idmono∈ : ∀ {A : X} {Γ} → (i : A ∈ Γ) → mono∈ refl⊆ i ≡ i
idmono∈ top = refl
idmono∈ (pop i) = cong pop (idmono∈ i)
-- Stack thinning.
module _ {X : Set} where
_∖_ : ∀ {A} → (Γ : Stack X) → A ∈ Γ → Stack X
∅ ∖ ()
(Γ , A) ∖ top = Γ
(Γ , B) ∖ pop i = Γ ∖ i , B
thin⊆ : ∀ {A Γ} → (i : A ∈ Γ) → Γ ∖ i ⊆ Γ
thin⊆ top = weak⊆
thin⊆ (pop i) = keep (thin⊆ i)
-- Decidable equality of stack membership.
module _ {X : Set} where
data _=∈_ {A} {Γ : Stack X} (i : A ∈ Γ) : ∀ {B} → B ∈ Γ → Set where
same : i =∈ i
diff : ∀ {B} → (j : B ∈ Γ ∖ i) → i =∈ mono∈ (thin⊆ i) j
_≟∈_ : ∀ {A B Γ} → (i : A ∈ Γ) (j : B ∈ Γ) → i =∈ j
top ≟∈ top = same
top ≟∈ pop j rewrite sym (idmono∈ j) = diff j
pop i ≟∈ top = diff top
pop i ≟∈ pop j with i ≟∈ j
pop i ≟∈ pop .i | same = same
pop i ≟∈ pop ._ | diff j = diff (pop j)
| {
"alphanum_fraction": 0.467438948,
"avg_line_length": 27.2991452991,
"ext": "agda",
"hexsha": "b38d91bd3744dabb69075e96a4ef069c79c3ff59",
"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": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/nbe-correctness",
"max_forks_repo_path": "src/Stack.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/nbe-correctness",
"max_issues_repo_path": "src/Stack.agda",
"max_line_length": 77,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/nbe-correctness",
"max_stars_repo_path": "src/Stack.agda",
"max_stars_repo_stars_event_max_datetime": "2017-03-23T18:51:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-23T06:25:23.000Z",
"num_tokens": 1561,
"size": 3194
} |
module examplesPaperJFP.loadAllOOAgdaPart2 where
-- This is a continuation of the file loadAllOOAgdaPart1
-- giving the code from the ooAgda paper
-- This file was split into two because of a builtin IO which
-- makes loading files from part1 and part2 incompatible.
-- Note that some files which are directly in the libary can be found
-- in loadAllOOAgdaFilesAsInLibrary
-- Sect 1 - 7 are in loadAllOOAgdaPart1.agda
-- 8. State-Dependent Objects and IO
-- 8.1 State-Dependent Interfaces
import examplesPaperJFP.StatefulObject
-- 8.2 State-Dependent Objects
-- 8.2.1. Example of Use of Safe Stack
import examplesPaperJFP.safeFibStackMachineObjectOriented
-- 8.3 Reasoning About Stateful Objects
import examplesPaperJFP.StackBisim
-- 8.3.1. Bisimilarity
-- 8.3.2. Verifying stack laws}
-- 8.3.3. Bisimilarity of different stack implementations
-- 8.4. State-Dependent IO
import examplesPaperJFP.StateDependentIO
-- 9. A Drawing Program in Agda
-- code as in paper adapted to new Agda
open import examplesPaperJFP.IOGraphicsLib
-- code as in library see loadAllOOAgdaFilesAsInLibrary.agda
-- open import SizedIO.IOGraphicsLib
open import examplesPaperJFP.ExampleDrawingProgram
-- 10. A Graphical User Interface using an Object
-- 10.1. wxHaskell
-- 10.2. A Library for Object-Based GUIs in Agda
open import examplesPaperJFP.VariableList
open import examplesPaperJFP.WxGraphicsLib
open import examplesPaperJFP.VariableListForDispatchOnly
-- 10.3 Example: A GUI controlling a Space Ship in Agda
open import examplesPaperJFP.SpaceShipSimpleVar
open import examplesPaperJFP.SpaceShipCell
open import examplesPaperJFP.SpaceShipAdvanced
-- 11. Related Work
open import examplesPaperJFP.agdaCodeBrady
-- 12. Conclusion
-- Bibliography
| {
"alphanum_fraction": 0.8012564249,
"avg_line_length": 26.5303030303,
"ext": "agda",
"hexsha": "d1f6908ea2209c507a5aa73e684b862edd5d5b63",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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": "agda/ooAgda",
"max_issues_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart2.agda",
"max_line_length": 69,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/examplesPaperJFP/loadAllOOAgdaPart2.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 491,
"size": 1751
} |
-- {-# OPTIONS -v tc.meta:20 #-}
-- Andreas, 2011-04-21
module PruneLHS where
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
data Bool : Set where true false : Bool
test : let X : Bool -> Bool -> Bool -> Bool
X = _
in (C : Set) ->
(({x y : Bool} -> X x y x ≡ x) ->
({x y : Bool} -> X x x y ≡ x) -> C) -> C
test C k = k refl refl
-- by the first equation, X cannot depend its second argument
-- by the second equation, X cannot depend on its third argument
| {
"alphanum_fraction": 0.5402750491,
"avg_line_length": 28.2777777778,
"ext": "agda",
"hexsha": "b5687c8ca45d8c412d437fc5f9d5c064d3b40d89",
"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/PruneLHS.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/PruneLHS.agda",
"max_line_length": 64,
"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/PruneLHS.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": 167,
"size": 509
} |
{-
This file contains a diagonalization procedure simpler than Smith normalization.
For any matrix M, it provides two invertible matrices P, Q, one diagonal matrix D and an equality M = P·D·Q.
The only difference from Smith is, the numbers in D are allowed to be arbitrary, instead of being consecutively divisible.
But it is enough to establish important properties of finitely presented abelian groups.
Also, it can be computed much more efficiently (than Smith, only).
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.IntegerMatrix.Diagonalization where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat
hiding (_·_)
renaming (_+_ to _+ℕ_ ; +-assoc to +Assocℕ)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Nat.Divisibility
using (m∣n→m≤n)
renaming (∣-trans to ∣ℕ-trans ; ∣-refl to ∣-reflℕ)
open import Cubical.Data.Int
hiding (_+_ ; _·_ ; _-_ ; -_ ; addEq)
open import Cubical.Data.Int.Divisibility
open import Cubical.Data.FinData
open import Cubical.Data.Empty as Empty
open import Cubical.Data.Unit as Unit
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Data.List
open import Cubical.Algebra.Matrix
open import Cubical.Algebra.Matrix.CommRingCoefficient
open import Cubical.Algebra.Matrix.Elementaries
open import Cubical.Algebra.IntegerMatrix.Base
open import Cubical.Algebra.IntegerMatrix.Elementaries
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Instances.Int
renaming (ℤ to ℤRing)
open import Cubical.Relation.Nullary
open import Cubical.Induction.WellFounded
private
variable
m n k : ℕ
open CommRingStr (ℤRing .snd)
open Coefficient ℤRing
open Sim
open ElemTransformation ℤRing
open ElemTransformationℤ
open SwapPivot
open RowsImproved
open ColsImproved
-- Sequence of non-zero integers
isNonZero : List ℤ → Type
isNonZero [] = Unit
isNonZero (x ∷ xs) = (¬ x ≡ 0) × isNonZero xs
isPropIsNonZero : (xs : List ℤ) → isProp (isNonZero xs)
isPropIsNonZero [] = isPropUnit
isPropIsNonZero (x ∷ xs) = isProp× (isPropΠ (λ _ → isProp⊥)) (isPropIsNonZero xs)
NonZeroList : Type
NonZeroList = Σ[ xs ∈ List ℤ ] isNonZero xs
cons : (n : ℤ)(xs : NonZeroList) → ¬ n ≡ 0 → NonZeroList
cons n (xs , _) _ .fst = n ∷ xs
cons n ([] , _) p .snd = p , tt
cons n (x ∷ xs , q) p .snd = p , q
-- Smith normal matrix
_+length_ : NonZeroList → ℕ → ℕ
xs +length n = length (xs .fst) +ℕ n
diagMat : (xs : List ℤ)(m n : ℕ) → Mat (length xs +ℕ m) (length xs +ℕ n)
diagMat [] _ _ = 𝟘
diagMat (x ∷ xs) _ _ = x ⊕ diagMat xs _ _
diagMat⊕ :
(a : ℤ)(xs : NonZeroList){m n : ℕ}
→ (p : ¬ a ≡ 0)
→ a ⊕ diagMat (xs .fst) m n ≡ diagMat (cons a xs p .fst) m n
diagMat⊕ _ _ _ = refl
-- Diagonal matrix with non-zero diagonal elements
-- Notice that we allow non-square matrices.
record isDiagonal (M : Mat m n) : Type where
field
divs : NonZeroList
rowNull : ℕ
colNull : ℕ
rowEq : divs +length rowNull ≡ m
colEq : divs +length colNull ≡ n
matEq : PathP (λ t → Mat (rowEq t) (colEq t)) (diagMat (divs .fst) rowNull colNull) M
open isDiagonal
row col : {M : Mat m n} → isDiagonal M → ℕ
row isNorm = isNorm .divs +length isNorm .rowNull
col isNorm = isNorm .divs +length isNorm .colNull
isDiagonal𝟘 : isDiagonal (𝟘 {m = m} {n = n})
isDiagonal𝟘 .divs = [] , tt
isDiagonal𝟘 {m = m} .rowNull = m
isDiagonal𝟘 {n = n} .colNull = n
isDiagonal𝟘 .rowEq = refl
isDiagonal𝟘 .colEq = refl
isDiagonal𝟘 .matEq = refl
isDiagonalEmpty : (M : Mat 0 n) → isDiagonal M
isDiagonalEmpty _ .divs = [] , tt
isDiagonalEmpty _ .rowNull = 0
isDiagonalEmpty {n = n} _ .colNull = n
isDiagonalEmpty _ .rowEq = refl
isDiagonalEmpty _ .colEq = refl
isDiagonalEmpty _ .matEq = isContr→isProp isContrEmpty _ _
isDiagonalEmptyᵗ : (M : Mat m 0) → isDiagonal M
isDiagonalEmptyᵗ _ .divs = [] , tt
isDiagonalEmptyᵗ {m = m} _ .rowNull = m
isDiagonalEmptyᵗ _ .colNull = 0
isDiagonalEmptyᵗ _ .rowEq = refl
isDiagonalEmptyᵗ _ .colEq = refl
isDiagonalEmptyᵗ _ .matEq = isContr→isProp isContrEmptyᵗ _ _
-- Induction step towards diagonalization
data DivStatus (a : ℤ)(M : Mat (suc m) (suc n)) : Type where
badCol : (i : Fin m)(p : ¬ a ∣ M (suc i) zero) → DivStatus a M
badRow : (j : Fin n)(p : ¬ a ∣ M zero (suc j)) → DivStatus a M
allDone : ((i : Fin m) → a ∣ M (suc i) zero)
→ ((j : Fin n) → a ∣ M zero (suc j)) → DivStatus a M
divStatus : (a : ℤ)(M : Mat (suc m) (suc n)) → DivStatus a M
divStatus a M =
let col? = ∀Dec (λ i → a ∣ M (suc i) zero) (λ _ → dec∣ _ _)
row? = ∀Dec (λ j → a ∣ M zero (suc j)) (λ _ → dec∣ _ _) in
case col?
return (λ _ → DivStatus a M) of λ
{ (inr p) → badCol (p .fst) (p .snd)
; (inl p) →
case row?
return (λ _ → DivStatus a M) of λ
{ (inr q) → badRow (q .fst) (q .snd)
; (inl q) → allDone p q }}
record DiagStep (M : Mat (suc m) (suc n)) : Type where
field
sim : Sim M
firstColClean : (i : Fin m) → sim .result (suc i) zero ≡ 0
firstRowClean : (j : Fin n) → sim .result zero (suc j) ≡ 0
nonZero : ¬ sim .result zero zero ≡ 0
open DiagStep
simDiagStep : {M : Mat (suc m) (suc n)}(sim : Sim M) → DiagStep (sim .result) → DiagStep M
simDiagStep simM diag .sim = compSim simM (diag .sim)
simDiagStep _ diag .firstColClean = diag .firstColClean
simDiagStep _ diag .firstRowClean = diag .firstRowClean
simDiagStep _ diag .nonZero = diag .nonZero
private
diagStep-helper :
(M : Mat (suc m) (suc n))
→ (p : ¬ M zero zero ≡ 0)(h : Norm (M zero zero))
→ (div? : DivStatus (M zero zero) M)
→ DiagStep M
diagStep-helper M p (acc ind) (badCol i q) =
let improved = improveRows M p
normIneq =
ind _ (stDivIneq p q (improved .div zero) (improved .div (suc i)))
in simDiagStep (improved .sim)
(diagStep-helper _ (improved .nonZero) normIneq (divStatus _ _))
diagStep-helper M p (acc ind) (badRow j q) =
let improved = improveCols M p
normIneq =
ind _ (stDivIneq p q (improved .div zero) (improved .div (suc j)))
in simDiagStep (improved .sim)
(diagStep-helper _ (improved .nonZero) normIneq (divStatus _ _))
diagStep-helper M p (acc ind) (allDone div₁ div₂) =
let improveColM = improveCols M p
invCol = bézoutRows-inv _ p div₂
divCol = (λ i → transport (λ t → invCol t zero ∣ invCol t (suc i)) (div₁ i))
improveRowM = improveRows (improveColM .sim .result) (improveColM .nonZero)
invCol = bézoutRows-inv _ (improveColM .nonZero) divCol
in record
{ sim = compSim (improveColM .sim) (improveRowM .sim)
; firstColClean = improveRowM .vanish
; firstRowClean = (λ j → (λ t → invCol (~ t) (suc j)) ∙ improveColM .vanish j)
; nonZero = improveRowM .nonZero }
diagStep-getStart : (M : Mat (suc m) (suc n)) → NonZeroOrNot M → DiagStep M ⊎ (M ≡ 𝟘)
diagStep-getStart _ (allZero p) = inr p
diagStep-getStart M (hereIs i j p) =
let swapM = swapPivot i j M
swapNonZero = (λ r → p (swapM .swapEq ∙ r))
diagM = diagStep-helper _ swapNonZero (<-wellfounded _) (divStatus _ _)
in inl (simDiagStep (swapM .sim) diagM)
diagStep : (M : Mat (suc m) (suc n)) → DiagStep M ⊎ (M ≡ 𝟘)
diagStep _ = diagStep-getStart _ (findNonZero _)
-- The diagonalization
record Diag (M : Mat m n) : Type where
field
sim : Sim M
isdiag : isDiagonal (sim .result)
open Diag
simDiag : {M : Mat m n}(sim : Sim M) → Diag (sim .result) → Diag M
simDiag simM diag .sim = compSim simM (diag .sim)
simDiag _ diag .isdiag = diag .isdiag
diag𝟘 : Diag (𝟘 {m = m} {n = n})
diag𝟘 .sim = idSim _
diag𝟘 .isdiag = isDiagonal𝟘
diagEmpty : (M : Mat 0 n) → Diag M
diagEmpty _ .sim = idSim _
diagEmpty M .isdiag = isDiagonalEmpty M
diagEmptyᵗ : (M : Mat m 0) → Diag M
diagEmptyᵗ _ .sim = idSim _
diagEmptyᵗ M .isdiag = isDiagonalEmptyᵗ M
decompDiagStep :
(M : Mat (suc m) (suc n))(step : DiagStep M)
→ step .sim .result ≡ step .sim .result zero zero ⊕ sucMat (step .sim .result)
decompDiagStep M step t zero zero = step .sim .result zero zero
decompDiagStep M step t zero (suc j) = step .firstRowClean j t
decompDiagStep M step t (suc i) zero = step .firstColClean i t
decompDiagStep M step t (suc i) (suc j) = step .sim .result (suc i) (suc j)
consIsDiagonal :
(a : ℤ)(M : Mat m n)
→ (p : ¬ a ≡ 0)
→ isDiagonal M → isDiagonal (a ⊕ M)
consIsDiagonal a _ p diag .divs = cons a (diag .divs) p
consIsDiagonal _ _ _ diag .rowNull = diag .rowNull
consIsDiagonal _ _ _ diag .colNull = diag .colNull
consIsDiagonal _ _ _ diag .rowEq = (λ t → suc (diag .rowEq t))
consIsDiagonal _ _ _ diag .colEq = (λ t → suc (diag .colEq t))
consIsDiagonal a _ _ diag .matEq = (λ t → a ⊕ diag .matEq t)
diagReduction :
(a : ℤ)(M : Mat m n)
→ (p : ¬ a ≡ 0)
→ Diag M → Diag (a ⊕ M)
diagReduction a _ _ diag .sim = ⊕Sim a (diag .sim)
diagReduction a _ p diag .isdiag = consIsDiagonal a _ p (diag .isdiag)
-- The Existence of Diagonalization
diagonalize : (M : Mat m n) → Diag M
diagonalize {m = 0} = diagEmpty
diagonalize {m = suc m} {n = 0} = diagEmptyᵗ
diagonalize {m = suc m} {n = suc n} M = helper (diagStep _)
where
helper : DiagStep M ⊎ (M ≡ 𝟘) → Diag M
helper (inr p) = subst Diag (sym p) diag𝟘
helper (inl stepM) =
let sucM = sucMat (stepM .sim .result)
diagM = diagReduction _ _ (stepM .nonZero) (diagonalize sucM)
in simDiag (compSim (stepM .sim) (≡Sim (decompDiagStep _ stepM))) diagM
| {
"alphanum_fraction": 0.6582624225,
"avg_line_length": 33.4,
"ext": "agda",
"hexsha": "2ebb999f040658076f172ff72c93098a04fa9b90",
"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/IntegerMatrix/Diagonalization.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/IntegerMatrix/Diagonalization.agda",
"max_line_length": 122,
"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/IntegerMatrix/Diagonalization.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3465,
"size": 9519
} |
module constants where
open import lib
cedille-extension : string
cedille-extension = "ced"
self-name : string
self-name = "self"
pattern ignored-var = "_"
pattern meta-var-pfx = '?'
pattern qual-local-chr = '@'
pattern qual-global-chr = '.'
meta-var-pfx-str = 𝕃char-to-string [ meta-var-pfx ]
qual-local-str = 𝕃char-to-string [ qual-local-chr ]
qual-global-str = 𝕃char-to-string [ qual-global-chr ]
options-file-name : string
options-file-name = "options"
global-error-string : string → string
global-error-string msg = "{\"error\":\"" ^ msg ^ "\"" ^ "}"
dot-cedille-directory : string → string
dot-cedille-directory dir = combineFileNames dir ".cedille"
| {
"alphanum_fraction": 0.6971514243,
"avg_line_length": 22.2333333333,
"ext": "agda",
"hexsha": "c576fef6a38cf9fcf13635156427a0568895b2d2",
"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/constants.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/constants.agda",
"max_line_length": 60,
"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/constants.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 174,
"size": 667
} |
open import Agda.Builtin.Char
open import Agda.Builtin.String
open import Agda.Builtin.Maybe
open import Agda.Builtin.Sigma
open import Common.IO
printTail : String → IO _
printTail str with primStringUncons str
... | just (_ , tl) = putStr tl
... | nothing = putStr ""
main : _
main = printTail "/test/Compiler/simple/uncons.agda"
| {
"alphanum_fraction": 0.7323529412,
"avg_line_length": 24.2857142857,
"ext": "agda",
"hexsha": "a28cc1f584553eb4942400b0ed7d65a04b81455b",
"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/Compiler/simple/uncons.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Compiler/simple/uncons.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Compiler/simple/uncons.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": 92,
"size": 340
} |
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness #-}
module Agda.Builtin.Char where
open import Agda.Builtin.Nat
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
postulate Char : Set
{-# BUILTIN CHAR Char #-}
primitive
primIsLower primIsDigit primIsAlpha primIsSpace primIsAscii
primIsLatin1 primIsPrint primIsHexDigit : Char → Bool
primToUpper primToLower : Char → Char
primCharToNat : Char → Nat
primNatToChar : Nat → Char
primCharEquality : Char → Char → Bool
primCharToNatInjective : ∀ a b → primCharToNat a ≡ primCharToNat b → a ≡ b
| {
"alphanum_fraction": 0.7470288625,
"avg_line_length": 29.45,
"ext": "agda",
"hexsha": "fa7330d98fb0b9e6e42ef39851fb2095eee44c49",
"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": "src/data/lib/prim/Agda/Builtin/Char.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": "src/data/lib/prim/Agda/Builtin/Char.agda",
"max_line_length": 76,
"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": "src/data/lib/prim/Agda/Builtin/Char.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 170,
"size": 589
} |
open import Oscar.Prelude
module Oscar.Class.Amgu where
record Amgu {𝔵} {X : Ø 𝔵} {𝔱} (T : X → Ø 𝔱) {𝔞} (A : X → Ø 𝔞) {𝔪} (M : Ø 𝔞 → Ø 𝔪) : Ø 𝔵 ∙̂ 𝔱 ∙̂ 𝔞 ∙̂ 𝔪 where
field amgu : ∀ {x} → T x → T x → A x → M (A x)
open Amgu ⦃ … ⦄ public
| {
"alphanum_fraction": 0.4979253112,
"avg_line_length": 24.1,
"ext": "agda",
"hexsha": "4faeec8548d6fa5692d8ed8858f5ea2966ece34b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Amgu.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Amgu.agda",
"max_line_length": 108,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Amgu.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 143,
"size": 241
} |
module FOLsequent where
open import Data.Empty
open import Data.Nat
open import Data.Nat.Properties
open import Data.String using (String)
open import Data.Sum
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; sym; cong; subst)
open import Relation.Nullary
open import Data.List.Base as List using (List; []; _∷_; [_]; _++_)
open import Data.List.Any as LAny
open LAny.Membership-≡
data Term : Set where
$ : ℕ → Term
Fun : String → List Term → Term
Const : String -> Term
Const n = Fun n []
data Formula : Set where
_⟨_⟩ : String → List Term → Formula
_∧_ : Formula → Formula → Formula
_∨_ : Formula → Formula → Formula
_⟶_ : Formula → Formula → Formula
~_ : Formula → Formula
All : (Term → Formula) → Formula
Ex : (Term → Formula) → Formula
-- data Structure : Set where
-- ∣_∣ : Formula → Structure
-- _,,_ : Structure → Structure → Structure
-- Ø : Structure
Structure = List Formula
mutual
FVt : Term → List ℕ
FVt ($ x) = [ x ]
FVt (Fun _ args) = FVlst args
FVlst : List Term -> List ℕ
FVlst [] = []
FVlst (x ∷ xs) = (FVt x) ++ (FVlst xs)
FVf : Formula → List ℕ
FVf (_ ⟨ lst ⟩) = FVlst lst
FVf (f ∧ f₁) = FVf f ++ FVf f₁
FVf (f ∨ f₁) = FVf f ++ FVf f₁
FVf (f ⟶ f₁) = FVf f ++ FVf f₁
FVf (~ f) = FVf f
FVf (All x) = FVf (x (Const ""))
FVf (Ex x) = FVf (x (Const ""))
FV : Structure → List ℕ
FV [] = []
FV (f ∷ l) = FVf f ++ FV l
_#_ : ℕ -> List ℕ -> Set
x # xs = x ∉ xs
∪ : List ℕ -> ℕ
∪ [] = 0
∪ (x ∷ xs) = x ⊔ (∪ xs)
∃# : List ℕ -> ℕ
∃# xs = suc (∪ xs)
------------------------------------------------------------------------------------
ℕ-meet-dist : ∀ {x y z : ℕ} -> (x ≤ y) ⊎ (x ≤ z) -> x ≤ y ⊔ z
ℕ-meet-dist {zero} x≤y⊎x≤z = z≤n
ℕ-meet-dist {suc x} {zero} {zero} (inj₁ ())
ℕ-meet-dist {suc x} {zero} {zero} (inj₂ ())
ℕ-meet-dist {suc x} {zero} {suc z} (inj₁ ())
ℕ-meet-dist {suc x} {zero} {suc z} (inj₂ sx≤sz) = sx≤sz
ℕ-meet-dist {suc x} {suc y} {zero} (inj₁ sx≤sy) = sx≤sy
ℕ-meet-dist {suc x} {suc y} {zero} (inj₂ ())
ℕ-meet-dist {suc x} {suc y} {suc z} (inj₁ (s≤s x≤y)) = s≤s (ℕ-meet-dist (inj₁ x≤y))
ℕ-meet-dist {suc x} {suc y} {suc z} (inj₂ (s≤s y≤z)) =
s≤s (ℕ-meet-dist {_} {y} {z} (inj₂ y≤z))
------------------------------------------------------------------------------------
≤-refl : ∀ {x : ℕ} -> x ≤ x
≤-refl {zero} = z≤n
≤-refl {suc x} = s≤s ≤-refl
------------------------------------------------------------------------------------
∈-cons : ∀ {L} {x y : ℕ} -> x ∈ (y ∷ L) -> ¬(x ≡ y) -> x ∈ L
∈-cons {[]} (here refl) ¬x≡y = ⊥-elim (¬x≡y refl)
∈-cons {[]} (there ()) ¬x≡y
∈-cons {y ∷ L} {x} (here refl) ¬x≡y = ⊥-elim (¬x≡y refl)
∈-cons {y ∷ L} {x} (there x∈L) ¬x≡y = x∈L
------------------------------------------------------------------------------------
∃#-lemma' : ∀ x L -> x ∈ L -> x ≤ ∪ L
∃#-lemma' x [] ()
∃#-lemma' x (y ∷ L) x∈y∷L with x ≟ y
∃#-lemma' x (.x ∷ L) x∈y∷L | yes refl = ℕ-meet-dist {x} {x} (inj₁ ≤-refl)
∃#-lemma' x (y ∷ L) x∈y∷L | no ¬x≡y =
ℕ-meet-dist {x} {y} (inj₂ (∃#-lemma' x L (∈-cons x∈y∷L ¬x≡y)))
------------------------------------------------------------------------------------
∃#-lemma'' : ∀ x L -> x ∈ L -> ¬ (x ≡ ∃# L)
∃#-lemma'' .(suc (∪ L)) L x∈L refl =
1+n≰n {∪ L} (∃#-lemma' (suc (∪ L)) L x∈L)
------------------------------------------------------------------------------------
∃#-lemma : ∀ L -> ∃# L ∉ L
∃#-lemma L ∃#L∈L = ∃#-lemma'' (∃# L) L ∃#L∈L refl
data _⊢_ : Structure → Structure → Set where
I : ∀ {A} → [ A ] ⊢ [ A ]
Cut : ∀ A {Γ Σ Δ Π} →
Γ ⊢ (Δ ++ [ A ]) → ([ A ] ++ Σ) ⊢ Π →
------------------------------------
(Γ ++ Σ) ⊢ (Δ ++ Π)
∧L₁ : ∀ {Γ Δ A B} → (Γ ++ [ A ]) ⊢ Δ → (Γ ++ [ A ∧ B ]) ⊢ Δ
∧L₂ : ∀ {Γ Δ A B} → (Γ ++ [ B ]) ⊢ Δ → (Γ ++ [ A ∧ B ]) ⊢ Δ
∧R : ∀ {Γ Σ Δ Π A B} →
Γ ⊢ ([ A ] ++ Δ) → Σ ⊢ ([ B ] ++ Π) →
-----------------------------------
(Γ ++ Σ) ⊢ ([ A ∧ B ] ++ Δ ++ Π)
∨R₁ : ∀ {Γ Δ A B} → Γ ⊢ ([ A ] ++ Δ) → Γ ⊢ ([ A ∨ B ] ++ Δ)
∨R₂ : ∀ {Γ Δ A B} → Γ ⊢ ([ B ] ++ Δ) → Γ ⊢ ([ A ∨ B ] ++ Δ)
∨L : ∀ {Γ Σ Δ Π A B} →
(Γ ++ [ A ]) ⊢ Δ → (Σ ++ [ B ]) ⊢ Π →
-----------------------------------
(Γ ++ Σ ++ [ A ∨ B ]) ⊢ (Δ ++ Π)
⟶L : ∀ {Γ Σ Δ Π A B} →
Γ ⊢ ([ A ] ++ Δ) → (Σ ++ [ B ]) ⊢ Π →
------------------------------------
(Γ ++ Σ ++ [ A ⟶ B ]) ⊢ (Δ ++ Π)
⟶R : ∀ {Γ Δ A B} → (Γ ++ [ A ]) ⊢ ([ B ] ++ Δ) → Γ ⊢ ([ A ⟶ B ] ++ Δ)
~L : ∀ {Γ Δ A} → Γ ⊢ ([ A ] ++ Δ) → (Γ ++ [ ~ A ]) ⊢ Δ
~R : ∀ {Γ Δ A} → (Γ ++ [ A ]) ⊢ Δ → Γ ⊢ ([ ~ A ] ++ Δ)
AllL : ∀ {Γ Δ A t} → (Γ ++ [ A t ]) ⊢ Δ → (Γ ++ [ All A ]) ⊢ Δ
AllR : ∀ {Γ Δ A y} →
Γ ⊢ ([ A ($ y) ] ++ Δ) → (y-fresh : y # FV (Γ ++ Δ)) →
----------------------
Γ ⊢ ([ All A ] ++ Δ)
ExL : ∀ {Γ Δ A y} →
(Γ ++ [ A ($ y) ]) ⊢ Δ → (y-fresh : y # FV (Γ ++ Δ)) →
----------------------
(Γ ++ [ Ex A ]) ⊢ Δ
ExR : ∀ {Γ Δ A t} → Γ ⊢ ([ A t ] ++ Δ) → Γ ⊢ ([ Ex A ] ++ Δ)
WL : ∀ {Γ Δ A} → Γ ⊢ Δ → (Γ ++ [ A ]) ⊢ Δ
WR : ∀ {Γ Δ A} → Γ ⊢ Δ → Γ ⊢ ([ A ] ++ Δ)
CL : ∀ {Γ Δ A} → (Γ ++ [ A ] ++ [ A ]) ⊢ Δ → (Γ ++ [ A ]) ⊢ Δ
CR : ∀ {Γ Δ A} → Γ ⊢ ([ A ] ++ [ A ] ++ Δ) → Γ ⊢ ([ A ] ++ Δ)
PL : ∀ {Γ₁ Γ₂ Δ A B} →
(Γ₁ ++ [ A ] ++ [ B ] ++ Γ₂) ⊢ Δ →
------------------------------------
(Γ₁ ++ [ B ] ++ [ A ] ++ Γ₂) ⊢ Δ
PR : ∀ {Γ Δ₁ Δ₂ A B} →
Γ ⊢ (Δ₁ ++ [ A ] ++ [ B ] ++ Δ₂) →
------------------------------------
Γ ⊢ (Δ₁ ++ [ B ] ++ [ A ] ++ Δ₂)
PL' : ∀ {A B Δ} -> (A ∷ [ B ]) ⊢ Δ → (B ∷ [ A ]) ⊢ Δ
PL' {A} {B} A,B⊢Δ = PL {[]} {[]} {_} {A} {B} A,B⊢Δ
PR' : ∀ {A B Γ} -> Γ ⊢ (A ∷ [ B ]) → Γ ⊢ (B ∷ [ A ])
PR' {A} {B} Γ⊢A,B = PR {_} {[]} {[]} {A} {B} Γ⊢A,B
_>>_ : ∀ {A B : Set} -> (A → B) -> A -> B
A→B >> A = A→B A
open import Data.Product
_>>₂_ : ∀ {A B C : Set} -> (A → B → C) -> A × B -> C
A→B→C >>₂ (A , B) = A→B→C A B
infixr 4 _>>_
infixr 4 _>>₂_
lemma : ∀ {A B C} -> [] ⊢ [ (A ⟶ (B ∨ C)) ⟶ (((B ⟶ (~ A)) ∧ (~ C)) ⟶ (~ A)) ]
lemma {A} {B} {C} = ⟶R >> ⟶R >> PL' >> CR >> ⟶L {[]} {[ (B ⟶ (~ A)) ∧ (~ C) ]} {[ ~ A ]} {[ ~ A ]} >>₂
(PR' >> ~R >> I) ,
PL' >> CL {[ B ∨ C ]} {A = (B ⟶ (~ A)) ∧ (~ C)} >> ∧L₂ {(B ∨ C) ∷ [ (B ⟶ (~ A)) ∧ (~ C) ]}
>> PL {[ B ∨ C ]} {[]} >> ∧L₁ {(B ∨ C) ∷ [ ~ C ]} >> ⟶L {(B ∨ C) ∷ [ ~ C ]} {[]} {[]} >>₂
(~L {[ B ∨ C ]} >> PR' >> ∨L {[]} {[]} {[ B ]} >>₂ I , I) ,
I
-- AllR {y = y} (AllL {[]} {t = $ y} I) y-fresh
-- where
-- y = ∃# (FV [ All (λ x → P ⟨ [ x ] ⟩) ])
-- y-fresh = ∃#-lemma (FV [ All (λ x → P ⟨ [ x ] ⟩) ])
AllR# : ∀ {Γ Δ A} → Γ ⊢ ([ A ($ (∃# (FV (Γ ++ Δ)))) ] ++ Δ) → Γ ⊢ ([ All A ] ++ Δ)
AllR# {Γ} {Δ} Γ⊢[y/x]A,Δ = AllR Γ⊢[y/x]A,Δ (∃#-lemma (FV (Γ ++ Δ)))
ExL# : ∀ {Γ Δ A} → (Γ ++ [ A ($ (∃# (FV (Γ ++ Δ)))) ]) ⊢ Δ → (Γ ++ [ Ex A ]) ⊢ Δ
ExL# {Γ} {Δ} Γ,[y/x]A⊢Δ = ExL {Γ} Γ,[y/x]A⊢Δ (∃#-lemma (FV (Γ ++ Δ)))
lemma₁ : ∀ {P} → [ All (λ x → P ⟨ [ x ] ⟩) ] ⊢ [ All (λ y → P ⟨ [ y ] ⟩) ]
lemma₁ {P} = AllR# (AllL {[]} I)
lemma₂ : ∀ {P} →
[ Ex (λ y → All (λ x → P ⟨ x ∷ [ y ] ⟩)) ] ⊢ [ All (λ x → Ex (λ y → P ⟨ x ∷ [ y ] ⟩)) ]
lemma₂ {P} = AllR# >> ExL# {[]} >> ExR >> AllL {[]} >> I
| {
"alphanum_fraction": 0.3375071144,
"avg_line_length": 33.4666666667,
"ext": "agda",
"hexsha": "46a1d051bce0214a790f216cc534f3dd53bcc206",
"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": "b4f3ce288633417ce309a0a1371ad0907a007b30",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "goodlyrottenapple/FOLdisplay",
"max_forks_repo_path": "FOLsequent.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b4f3ce288633417ce309a0a1371ad0907a007b30",
"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": "goodlyrottenapple/FOLdisplay",
"max_issues_repo_path": "FOLsequent.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b4f3ce288633417ce309a0a1371ad0907a007b30",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "goodlyrottenapple/FOLdisplay",
"max_stars_repo_path": "FOLsequent.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3337,
"size": 7028
} |
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
data Maybe {a} (A : Set a) : Set a where
just : A → Maybe A
nothing : Maybe A
record RawRoutingAlgebra : Set₁ where
field
PathWeight : Set
module _ (A : RawRoutingAlgebra) where
open RawRoutingAlgebra A
PathWeight⁺ : Set
PathWeight⁺ = Maybe (Σ PathWeight λ _ → Nat)
data P : PathWeight⁺ → Set where
[_] : ∀ {k} → snd k ≡ 0 → P (just k)
badness : (r : PathWeight⁺) → P r → Set
badness r [ refl ] = Nat
| {
"alphanum_fraction": 0.6559546314,
"avg_line_length": 20.3461538462,
"ext": "agda",
"hexsha": "b040795dd91d725998b27c2d65e3b9b0bef76a7c",
"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/Succeed/Issue5424.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/Succeed/Issue5424.agda",
"max_line_length": 46,
"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/Succeed/Issue5424.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": 183,
"size": 529
} |
module Data.Boolean where
import Lvl
open import Type
-- Boolean type
data Bool : Type{Lvl.𝟎} where
𝑇 : Bool -- Represents truth
𝐹 : Bool -- Represents falsity
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE 𝑇 #-}
{-# BUILTIN FALSE 𝐹 #-}
elim : ∀{ℓ}{T : Bool → Type{ℓ}} → T(𝑇) → T(𝐹) → ((b : Bool) → T(b))
elim t _ 𝑇 = t
elim _ f 𝐹 = f
not : Bool → Bool
not 𝑇 = 𝐹
not 𝐹 = 𝑇
{-# COMPILE GHC not = not #-}
-- Control-flow if-else expression
if_then_else_ : ∀{ℓ}{T : Type{ℓ}} → Bool → T → T → T
if b then t else f = elim t f b
| {
"alphanum_fraction": 0.5875706215,
"avg_line_length": 19.6666666667,
"ext": "agda",
"hexsha": "5065f13c75df4ba68fcfb4f294e4bf9ab7d2a742",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Boolean.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Boolean.agda",
"max_line_length": 67,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Boolean.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": 212,
"size": 531
} |
{-# OPTIONS --erased-cubical --safe #-}
module FarmCanon where
open import Data.List using (List; _∷_; [])
open import Data.Nat using (ℕ)
open import Data.Sign renaming (+ to s+ ; - to s-)
open import Data.Vec using (Vec; _∷_; []; map)
open import Canon using (makeCanon2)
open import Instruments using (pianos)
open import Interval
open import MakeTracks using (makeTrackList)
open import MidiEvent
open import Note
open import Pitch
subject : List Note
subject =
tone qtr (c 5) ∷
tone qtr (d 5) ∷
tone half (e 5) ∷
tone 8th (e 5) ∷
tone 8th (e 5) ∷
tone 8th (d 5) ∷
tone 8th (d 5) ∷
tone half (e 5) ∷
[]
transpositions : Vec Opi 4
transpositions = map (makeSigned s-) (per1 ∷ per5 ∷ per8 ∷ per12 ∷ [])
repeats : ℕ
repeats = 3
delay : Duration
delay = half
canon : Vec (List Note) 4
canon = makeCanon2 subject delay transpositions
tempo : ℕ
tempo = 120
canonTracks : List MidiTrack
canonTracks = makeTrackList pianos tempo canon
| {
"alphanum_fraction": 0.6541129832,
"avg_line_length": 21.4680851064,
"ext": "agda",
"hexsha": "e1ab3263526ca06fdb2d702f546f8f79db200016",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/FarmCanon.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/FarmCanon.agda",
"max_line_length": 70,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/FarmCanon.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 343,
"size": 1009
} |
------------------------------------------------------------------------------
-- ABP Lemma 2
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From Dybjer and Sander's paper: The second lemma states that given
-- a state of the latter kind (see Lemma 1) we will arrive at a new
-- start state, which is identical to the old start state except that
-- the bit has alternated and the first item in the input stream has
-- been removed.
module FOTC.Program.ABP.Lemma2I where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Base.List.PropertiesI
open import FOTC.Base.Loop
open import FOTC.Base.PropertiesI
open import FOTC.Data.Bool
open import FOTC.Data.Bool.PropertiesI
open import FOTC.Data.List
open import FOTC.Data.List.PropertiesI
open import FOTC.Program.ABP.ABP
open import FOTC.Program.ABP.Fair.Type
open import FOTC.Program.ABP.Fair.PropertiesI
open import FOTC.Program.ABP.PropertiesI
open import FOTC.Program.ABP.Terms
------------------------------------------------------------------------------
-- Helper function for Lemma 2.
helper₂ : ∀ {b i' is' os₁' os₂' as' bs' cs' ds' js'} →
Bit b →
Fair os₁' →
S' b i' is' os₁' os₂' as' bs' cs' ds' js' →
∀ ft₂ os₂'' → F*T ft₂ → Fair os₂'' → os₂' ≡ ft₂ ++ os₂'' →
∃[ os₁'' ] ∃[ os₂'' ] ∃[ as'' ] ∃[ bs'' ] ∃[ cs'' ] ∃[ ds'' ]
Fair os₁''
∧ Fair os₂''
∧ S (not b) is' os₁'' os₂'' as'' bs'' cs'' ds'' js'
helper₂ {b} {i'} {is'} {os₁'} {os₂'} {as'} {bs'} {cs'} {ds'} {js'}
Bb Fos₁' (as'S' , bs'S' , cs'S' , ds'S' , js'S')
.(T ∷ []) os₂'' f*tnil Fos₂'' os₂'-eq =
os₁' , os₂'' , as'' , bs'' , cs'' , ds''
, Fos₁' , Fos₂''
, as''-eq , bs''-eq , cs''-eq , refl , js'-eq
where
os₂'-eq-helper : os₂' ≡ T ∷ os₂''
os₂'-eq-helper =
os₂' ≡⟨ os₂'-eq ⟩
(T ∷ []) ++ os₂'' ≡⟨ ++-∷ T [] os₂'' ⟩
T ∷ [] ++ os₂'' ≡⟨ ∷-rightCong (++-leftIdentity os₂'') ⟩
T ∷ os₂'' ∎
ds'' : D
ds'' = corrupt os₂'' · cs'
ds'-eq : ds' ≡ ok b ∷ ds''
ds'-eq =
ds' ≡⟨ ds'S' ⟩
corrupt os₂' · (b ∷ cs')
≡⟨ ·-leftCong (corruptCong os₂'-eq-helper) ⟩
corrupt (T ∷ os₂'') · (b ∷ cs')
≡⟨ corrupt-T os₂'' b cs' ⟩
ok b ∷ corrupt os₂'' · cs'
≡⟨ refl ⟩
ok b ∷ ds'' ∎
as'' : D
as'' = as'
as''-eq : as'' ≡ send (not b) · is' · ds''
as''-eq =
as'' ≡⟨ as'S' ⟩
await b i' is' ds' ≡⟨ awaitCong₄ ds'-eq ⟩
await b i' is' (ok b ∷ ds'') ≡⟨ await-ok≡ b b i' is' ds'' refl ⟩
send (not b) · is' · ds'' ∎
bs'' : D
bs'' = bs'
bs''-eq : bs'' ≡ corrupt os₁' · as'
bs''-eq = bs'S'
cs'' : D
cs'' = cs'
cs''-eq : cs'' ≡ ack (not b) · bs'
cs''-eq = cs'S'
js'-eq : js' ≡ out (not b) · bs''
js'-eq = js'S'
helper₂ {b} {i'} {is'} {os₁'} {os₂'} {as'} {bs'} {cs'} {ds'} {js'}
Bb Fos₁' (as'S' , bs'S' , cs'S' , ds'S' , js'S')
.(F ∷ ft₂) os₂'' (f*tcons {ft₂} FTft₂) Fos₂'' os₂'-eq =
helper₂ Bb (tail-Fair Fos₁') ihS' ft₂ os₂'' FTft₂ Fos₂'' refl
where
os₁^ : D
os₁^ = tail₁ os₁'
os₂^ : D
os₂^ = ft₂ ++ os₂''
os₂'-eq-helper : os₂' ≡ F ∷ os₂^
os₂'-eq-helper = os₂' ≡⟨ os₂'-eq ⟩
(F ∷ ft₂) ++ os₂'' ≡⟨ ++-∷ _ _ _ ⟩
F ∷ ft₂ ++ os₂'' ≡⟨ refl ⟩
F ∷ os₂^ ∎
ds^ : D
ds^ = corrupt os₂^ · cs'
ds'-eq : ds' ≡ error ∷ ds^
ds'-eq =
ds'
≡⟨ ds'S' ⟩
corrupt os₂' · (b ∷ cs')
≡⟨ ·-leftCong (corruptCong os₂'-eq-helper) ⟩
corrupt (F ∷ os₂^) · (b ∷ cs')
≡⟨ corrupt-F _ _ _ ⟩
error ∷ corrupt os₂^ · cs'
≡⟨ refl ⟩
error ∷ ds^ ∎
as^ : D
as^ = await b i' is' ds^
as'-eq : as' ≡ < i' , b > ∷ as^
as'-eq = as' ≡⟨ as'S' ⟩
await b i' is' ds' ≡⟨ awaitCong₄ ds'-eq ⟩
await b i' is' (error ∷ ds^) ≡⟨ await-error _ _ _ _ ⟩
< i' , b > ∷ await b i' is' ds^ ≡⟨ refl ⟩
< i' , b > ∷ as^ ∎
bs^ : D
bs^ = corrupt os₁^ · as^
bs'-eq-helper₁ : os₁' ≡ T ∷ tail₁ os₁' → bs' ≡ ok < i' , b > ∷ bs^
bs'-eq-helper₁ h =
bs'
≡⟨ bs'S' ⟩
corrupt os₁' · as'
≡⟨ subst₂ (λ t t' → corrupt os₁' · as' ≡ corrupt t · t')
h
as'-eq
refl
⟩
corrupt (T ∷ tail₁ os₁') · (< i' , b > ∷ as^)
≡⟨ corrupt-T _ _ _ ⟩
ok < i' , b > ∷ corrupt (tail₁ os₁') · as^
≡⟨ refl ⟩
ok < i' , b > ∷ bs^ ∎
bs'-eq-helper₂ : os₁' ≡ F ∷ tail₁ os₁' → bs' ≡ error ∷ bs^
bs'-eq-helper₂ h =
bs'
≡⟨ bs'S' ⟩
corrupt os₁' · as'
≡⟨ subst₂ (λ t t' → corrupt os₁' · as' ≡ corrupt t · t')
h
as'-eq
refl
⟩
corrupt (F ∷ tail₁ os₁') · (< i' , b > ∷ as^)
≡⟨ corrupt-F _ _ _ ⟩
error ∷ corrupt (tail₁ os₁') · as^
≡⟨ refl ⟩
error ∷ bs^ ∎
bs'-eq : bs' ≡ ok < i' , b > ∷ bs^ ∨ bs' ≡ error ∷ bs^
bs'-eq = case (λ h → inj₁ (bs'-eq-helper₁ h))
(λ h → inj₂ (bs'-eq-helper₂ h))
(head-tail-Fair Fos₁')
cs^ : D
cs^ = ack (not b) · bs^
cs'-eq-helper₁ : bs' ≡ ok < i' , b > ∷ bs^ → cs' ≡ b ∷ cs^
cs'-eq-helper₁ h =
cs' ≡⟨ cs'S' ⟩
ack (not b) · bs' ≡⟨ ·-rightCong h ⟩
ack (not b) · (ok < i' , b > ∷ bs^) ≡⟨ ack-ok≢ _ _ _ _ (not-x≢x Bb) ⟩
not (not b) ∷ ack (not b) · bs^ ≡⟨ ∷-leftCong (not-involutive Bb) ⟩
b ∷ ack (not b) · bs^ ≡⟨ refl ⟩
b ∷ cs^ ∎
cs'-eq-helper₂ : bs' ≡ error ∷ bs^ → cs' ≡ b ∷ cs^
cs'-eq-helper₂ h =
cs' ≡⟨ cs'S' ⟩
ack (not b) · bs' ≡⟨ ·-rightCong h ⟩
ack (not b) · (error ∷ bs^) ≡⟨ ack-error _ _ ⟩
not (not b) ∷ ack (not b) · bs^ ≡⟨ ∷-leftCong (not-involutive Bb) ⟩
b ∷ ack (not b) · bs^ ≡⟨ refl ⟩
b ∷ cs^ ∎
cs'-eq : cs' ≡ b ∷ cs^
cs'-eq = case cs'-eq-helper₁ cs'-eq-helper₂ bs'-eq
js'-eq-helper₁ : bs' ≡ ok < i' , b > ∷ bs^ → js' ≡ out (not b) · bs^
js'-eq-helper₁ h =
js'
≡⟨ js'S' ⟩
out (not b) · bs'
≡⟨ ·-rightCong h ⟩
out (not b) · (ok < i' , b > ∷ bs^)
≡⟨ out-ok≢ (not b) b i' bs^ (not-x≢x Bb) ⟩
out (not b) · bs^ ∎
js'-eq-helper₂ : bs' ≡ error ∷ bs^ → js' ≡ out (not b) · bs^
js'-eq-helper₂ h =
js' ≡⟨ js'S' ⟩
out (not b) · bs' ≡⟨ ·-rightCong h ⟩
out (not b) · (error ∷ bs^) ≡⟨ out-error (not b) bs^ ⟩
out (not b) · bs^ ∎
js'-eq : js' ≡ out (not b) · bs^
js'-eq = case js'-eq-helper₁ js'-eq-helper₂ bs'-eq
ds^-eq : ds^ ≡ corrupt os₂^ · (b ∷ cs^)
ds^-eq = ·-rightCong cs'-eq
ihS' : S' b i' is' os₁^ os₂^ as^ bs^ cs^ ds^ js'
ihS' = refl , refl , refl , ds^-eq , js'-eq
-- From Dybjer and Sander's paper: From the assumption that
-- os₂' ∈ Fair and hence by unfolding Fair, we conclude that there are
-- ft₂ : F*T and os₂'' : Fair, such that os₂' = ft₂ ++ os₂''.
--
-- We proceed by induction on ft₂ : F*T using helper.
lemma₂ : ∀ {b i' is' os₁' os₂' as' bs' cs' ds' js'} →
Bit b →
Fair os₁' →
Fair os₂' →
S' b i' is' os₁' os₂' as' bs' cs' ds' js' →
∃[ os₁'' ] ∃[ os₂'' ] ∃[ as'' ] ∃[ bs'' ] ∃[ cs'' ] ∃[ ds'' ]
Fair os₁''
∧ Fair os₂''
∧ S (not b) is' os₁'' os₂'' as'' bs'' cs'' ds'' js'
lemma₂ {b} {is' = is'} {os₂' = os₂'} {js' = js'} Bb Fos₁' Fos₂' s' =
helper₁ (Fair-out Fos₂')
where
helper₁ : (∃[ ft₂ ] ∃[ os₂'' ] F*T ft₂ ∧ os₂' ≡ ft₂ ++ os₂'' ∧ Fair os₂'') →
∃[ os₁'' ] ∃[ os₂'' ] ∃[ as'' ] ∃[ bs'' ] ∃[ cs'' ] ∃[ ds'' ]
Fair os₁''
∧ Fair os₂''
∧ S (not b) is' os₁'' os₂'' as'' bs'' cs'' ds'' js'
helper₁ (ft₂ , os₂'' , FTft₂ , os₂'-eq , Fos₂'') =
helper₂ Bb Fos₁' s' ft₂ os₂'' FTft₂ Fos₂'' os₂'-eq
| {
"alphanum_fraction": 0.4271962958,
"avg_line_length": 32.05859375,
"ext": "agda",
"hexsha": "7abdf7a61cf79ba103743029e5e009bb2bd823c9",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/ABP/Lemma2I.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Program/ABP/Lemma2I.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Program/ABP/Lemma2I.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": 3344,
"size": 8207
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.CoHSpace
module homotopy.Cogroup where
record CogroupStructure {i} (X : Ptd i) : Type i where
field
co-h-struct : CoHSpaceStructure X
⊙inv : X ⊙→ X
open CoHSpaceStructure co-h-struct public
inv : de⊙ X → de⊙ X
inv = fst ⊙inv
field
⊙inv-l : ⊙Wedge-rec ⊙inv (⊙idf X) ⊙∘ ⊙coμ ⊙∼ ⊙cst
⊙assoc : ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
⊙∼ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
{-
module _ {i j : ULevel} {X : Ptd i} (CGS : CogroupStructure X) where
open CogroupStructure CGS
private
lemma-inv : ⊙Wedge-rec (⊙Lift-fmap ⊙inv) (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j})
⊙∘ ⊙coμ
⊙∘ ⊙lower {j = j}
== ⊙cst
abstract
lemma-inv =
! (⊙λ= (⊙∘-assoc
(⊙Wedge-rec (⊙Lift-fmap ⊙inv) (⊙idf (⊙Lift {j = j} X)))
(⊙∨-fmap ⊙lift ⊙lift)
(⊙coμ ⊙∘ ⊙lower)))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (⊙λ= (⊙Wedge-rec-fmap (⊙Lift-fmap ⊙inv) (⊙idf _) ⊙lift ⊙lift))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (! (⊙λ= (⊙Wedge-rec-post∘ ⊙lift ⊙inv (⊙idf _))))
∙ ⊙λ= (⊙∘-assoc ⊙lift (⊙Wedge-rec ⊙inv (⊙idf X)) (⊙coμ ⊙∘ ⊙lower))
∙ ap ⊙Lift-fmap (⊙λ= ⊙inv-l)
private
⊙coμ' : ⊙Lift {j = j} X ⊙→ ⊙Lift {j = j} X ⊙∨ ⊙Lift {j = j} X
⊙coμ' = ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ ⊙∘ ⊙lower {j = j}
private
lemma-assoc' :
⊙–> (⊙∨-assoc (⊙Lift {j = j} X) (⊙Lift {j = j} X) (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ
== ⊙∨-fmap (⊙idf (⊙Lift {j = j} X)) ⊙coμ'
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ
abstract
lemma-assoc' =
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙lift ⊙lift ⊙∘ ⊙coμ
=⟨ ! $ ap (⊙–> (⊙∨-assoc _ _ _) ⊙∘_) $ ⊙λ= $
⊙∘-assoc
(⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift X)))
(⊙∨-fmap ⊙lift ⊙lift)
⊙coμ ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ (⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift X)) ⊙∘ ⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙coμ
=⟨ ap (λ f → ⊙–> (⊙∨-assoc _ _ _ ) ⊙∘ f ⊙∘ ⊙coμ) $
! (⊙λ= $ ⊙∨-fmap-∘ ⊙coμ' ⊙lift (⊙idf (⊙Lift X)) ⊙lift)
∙ (⊙λ= $ ⊙∨-fmap-∘ (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ ⊙lift (⊙idf X)) ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ (⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X))
⊙∘ ⊙coμ
=⟨ ap (⊙–> (⊙∨-assoc _ _ _ ) ⊙∘_) $ ⊙λ= $
⊙∘-assoc
(⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
(⊙∨-fmap ⊙coμ (⊙idf X))
⊙coμ ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ ⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $
⊙∘-assoc
(⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X)))
(⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
(⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
(⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X)) ⊙∘ ⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) $
⊙λ= $ ⊙∨-assoc-nat ⊙lift ⊙lift ⊙lift ⟩
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift) ⊙∘ ⊙–> (⊙∨-assoc X X X))
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift))
(⊙–> (⊙∨-assoc X X X))
(⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift) ⊙∘_) $ ⊙λ= ⊙assoc ⟩
⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $ ⊙∘-assoc
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift))
(⊙∨-fmap (⊙idf X) ⊙coμ)
⊙coμ ⟩
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ)
⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) $
! (⊙λ= $ ⊙∨-fmap-∘ ⊙lift (⊙idf X) (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ)
∙ (⊙λ= $ ⊙∨-fmap-∘ (⊙idf (⊙Lift X)) ⊙lift ⊙coμ' ⊙lift) ⟩
(⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ' ⊙∘ ⊙∨-fmap ⊙lift ⊙lift) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ') (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ ⟩
⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ' ⊙∘ ⊙∨-fmap ⊙lift ⊙lift ⊙∘ ⊙coμ
=∎
private
lemma-assoc :
⊙–> (⊙∨-assoc (⊙Lift {j = j} X) (⊙Lift {j = j} X) (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X)) ⊙∘ ⊙coμ'
== ⊙∨-fmap (⊙idf (⊙Lift {j = j} X)) ⊙coμ' ⊙∘ ⊙coμ'
abstract
lemma-assoc = ap (_⊙∘ ⊙lower) lemma-assoc'
Lift-cogroup-structure : CogroupStructure (⊙Lift {j = j} X)
Lift-cogroup-structure = record
{ co-h-struct = Lift-co-h-space-structure {j = j} co-h-struct
; ⊙inv = ⊙lift ⊙∘ ⊙inv ⊙∘ ⊙lower
; ⊙inv-l = ⊙app= lemma-inv
; ⊙assoc = ⊙app= lemma-assoc
}
-}
module _ {i j} {X : Ptd i} (cogroup-struct : CogroupStructure X) (Y : Ptd j) where
private
module CGS = CogroupStructure cogroup-struct
⊙coμ = CGS.⊙coμ
comp : (X ⊙→ Y) → (X ⊙→ Y) → (X ⊙→ Y)
comp f g = ⊙Wedge-rec f g ⊙∘ ⊙coμ
inv : (X ⊙→ Y) → (X ⊙→ Y)
inv = _⊙∘ CGS.⊙inv
abstract
unit-l : ∀ f → comp ⊙cst f == f
unit-l f =
⊙Wedge-rec ⊙cst f ⊙∘ ⊙coμ
=⟨ ap2 (λ f g → ⊙Wedge-rec f g ⊙∘ ⊙coμ) (! $ ⊙λ= (⊙∘-cst-r f)) (! $ ⊙λ= (⊙∘-unit-r f)) ⟩
⊙Wedge-rec (f ⊙∘ ⊙cst) (f ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) (! $ ⊙λ= $ ⊙Wedge-rec-post∘ f ⊙cst (⊙idf X)) ⟩
(f ⊙∘ ⊙Wedge-rec ⊙cst (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc f (⊙Wedge-rec ⊙cst (⊙idf X)) ⊙coμ ⟩
f ⊙∘ (⊙Wedge-rec ⊙cst (⊙idf X) ⊙∘ ⊙coμ)
=⟨ ap (f ⊙∘_) (⊙λ= CGS.⊙unit-l) ⟩
f ⊙∘ ⊙idf X
=⟨ ⊙λ= (⊙∘-unit-r f) ⟩
f
=∎
assoc : ∀ f g h → comp (comp f g) h == comp f (comp g h)
assoc f g h =
⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) h ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= (⊙∘-unit-r h) |in-ctx (λ h → ⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) h ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) (h ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= (⊙Wedge-rec-fmap (⊙Wedge-rec f g) h ⊙coμ (⊙idf X)) |in-ctx _⊙∘ ⊙coμ ⟩
(⊙Wedge-rec (⊙Wedge-rec f g) h ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec (⊙Wedge-rec f g) h) (⊙∨-fmap ⊙coμ (⊙idf X)) ⊙coμ ⟩
⊙Wedge-rec (⊙Wedge-rec f g) h ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙Wedge-rec-assoc f g h) |in-ctx _⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ ⟩
(⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙–> (⊙∨-assoc X X X)) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec f (⊙Wedge-rec g h)) (⊙–> (⊙∨-assoc X X X)) (⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= CGS.⊙assoc |in-ctx ⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘_ ⟩
⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec f (⊙Wedge-rec g h)) (⊙∨-fmap (⊙idf X) ⊙coμ) ⊙coμ ⟩
(⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙Wedge-rec-fmap f (⊙Wedge-rec g h) (⊙idf X) ⊙coμ) |in-ctx _⊙∘ ⊙coμ ⟩
⊙Wedge-rec (f ⊙∘ ⊙idf X) (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙∘-unit-r f) |in-ctx (λ f → ⊙Wedge-rec f (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec f (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ
=∎
inv-l : ∀ f → comp (inv f) f == ⊙cst
inv-l f =
⊙Wedge-rec (f ⊙∘ CGS.⊙inv) f ⊙∘ ⊙coμ
=⟨ ap (λ g → ⊙Wedge-rec (f ⊙∘ CGS.⊙inv) g ⊙∘ ⊙coμ) (! $ ⊙λ= (⊙∘-unit-r f)) ⟩
⊙Wedge-rec (f ⊙∘ CGS.⊙inv) (f ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) (! $ ⊙λ= $ ⊙Wedge-rec-post∘ f CGS.⊙inv (⊙idf X)) ⟩
(f ⊙∘ ⊙Wedge-rec CGS.⊙inv (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc f (⊙Wedge-rec CGS.⊙inv (⊙idf X)) ⊙coμ ⟩
f ⊙∘ (⊙Wedge-rec CGS.⊙inv (⊙idf X) ⊙∘ ⊙coμ)
=⟨ ap (f ⊙∘_) (⊙λ= CGS.⊙inv-l) ⟩
f ⊙∘ ⊙cst
=⟨ ⊙λ= (⊙∘-cst-r f) ⟩
⊙cst
=∎
cogroup⊙→-group-structure : GroupStructure (X ⊙→ Y)
cogroup⊙→-group-structure = record
{ ident = ⊙cst
; inv = inv
; comp = comp
; unit-l = unit-l
; assoc = assoc
; inv-l = inv-l
}
| {
"alphanum_fraction": 0.4110953058,
"avg_line_length": 40.3636363636,
"ext": "agda",
"hexsha": "203aa9469741fbdf41b86000b9e5e81d000cef59",
"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/homotopy/Cogroup.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/homotopy/Cogroup.agda",
"max_line_length": 116,
"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/homotopy/Cogroup.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": 5148,
"size": 8436
} |
{-# OPTIONS --without-K #-}
module Common.Integer where
open import Agda.Builtin.Int public renaming (Int to Integer)
| {
"alphanum_fraction": 0.7478991597,
"avg_line_length": 23.8,
"ext": "agda",
"hexsha": "f9e3a1b361b0b645782fd8f1e1fecd88d654bd2a",
"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/Common/Integer.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/Common/Integer.agda",
"max_line_length": 61,
"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/Common/Integer.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": 25,
"size": 119
} |
{-# OPTIONS --without-K #-}
module sets.nat.ordering.lt.level where
open import sum
open import equality.core
open import hott.level.core
open import hott.level.closure
open import sets.nat.core
open import sets.nat.ordering.lt.core
open import sets.nat.ordering.leq.level
open import sets.empty
open import container.core
open import container.w
<-level : ∀ {m n} → h 1 (m < n)
<-level = ≤-level
| {
"alphanum_fraction": 0.7518796992,
"avg_line_length": 23.4705882353,
"ext": "agda",
"hexsha": "31e459ca9abe5eb71cd4c842ac31f91cbcb963e3",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/sets/nat/ordering/lt/level.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/sets/nat/ordering/lt/level.agda",
"max_line_length": 39,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/sets/nat/ordering/lt/level.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 105,
"size": 399
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core
open import Categories.Category.Monoidal.Core
module Categories.Object.Monoid {o ℓ e} {𝒞 : Category o ℓ e} (C : Monoidal 𝒞) where
open import Level
-- a monoid object is a generalization of the idea from algebra of a monoid,
-- extended into any monoidal category
open Category 𝒞
open Monoidal C
record IsMonoid (M : Obj) : Set (ℓ ⊔ e) where
field
μ : M ⊗₀ M ⇒ M
η : unit ⇒ M
field
assoc : μ ∘ μ ⊗₁ id ≈ μ ∘ id ⊗₁ μ ∘ associator.from
identityˡ : unitorˡ.from ≈ μ ∘ η ⊗₁ id
identityʳ : unitorʳ.from ≈ μ ∘ id ⊗₁ η
record Monoid : Set (o ⊔ ℓ ⊔ e) where
field
Carrier : Obj
isMonoid : IsMonoid Carrier
open IsMonoid isMonoid public
open Monoid
record Monoid⇒ (M M′ : Monoid) : Set (ℓ ⊔ e) where
field
arr : Carrier M ⇒ Carrier M′
preserves-μ : arr ∘ μ M ≈ μ M′ ∘ arr ⊗₁ arr
preserves-η : arr ∘ η M ≈ η M′
| {
"alphanum_fraction": 0.6430868167,
"avg_line_length": 23.9230769231,
"ext": "agda",
"hexsha": "0a08952111a166c4e3dc8922f865bc302ad29845",
"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/Object/Monoid.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/Object/Monoid.agda",
"max_line_length": 83,
"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/Object/Monoid.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": 341,
"size": 933
} |
module AKS.Everything where
open import AKS.Binary
open import AKS.Exponentiation
open import AKS.Extended
open import AKS.Fin
-- open import AKS.Modular.Quotient
-- open import AKS.Polynomial
open import AKS.Primality
open import AKS.Nat
open import AKS.Nat.GCD
| {
"alphanum_fraction": 0.8143939394,
"avg_line_length": 22,
"ext": "agda",
"hexsha": "179d6b418cfb822852431c15413d1d4f4f6b4264",
"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": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/thesis",
"max_forks_repo_path": "proofs/AKS/Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"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": "mckeankylej/thesis",
"max_issues_repo_path": "proofs/AKS/Everything.agda",
"max_line_length": 35,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/thesis",
"max_stars_repo_path": "proofs/AKS/Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z",
"num_tokens": 79,
"size": 264
} |
------------------------------------------------------------------------
-- Quotiented queues: any two queues representing the same sequence
-- are equal
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
import Equality.Path as P
module Queue.Quotiented
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Equality.Path.Isomorphisms eq
import Equivalence equality-with-J as Eq
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level.Closure equality-with-J
open import List equality-with-J as L hiding (map)
import Queue equality-with-J as Q
open import Quotient eq as Quotient
open import Sum equality-with-J
private
variable
a b : Level
A B : Type a
s s′ s₁ s₂ : Is-set A
q q₁ q₂ x x₁ x₂ : A
f g : A → B
xs : List A
------------------------------------------------------------------------
-- Queues
-- The queue type family is parametrised.
module _
-- The underlying queue type family.
(Q : ∀ {ℓ} → Type ℓ → Type ℓ)
-- Note that the predicate is required to be trivial. Perhaps the
-- code could be made more general, but I have not found a use for
-- such generality.
⦃ is-queue : ∀ {ℓ} → Q.Is-queue Q (λ _ → ↑ _ ⊤) ℓ ⦄
where
abstract
private
-- The quotienting relation: Two queues are seen as equal if
-- they represent the same list.
_∼_ : {A : Type a} (_ _ : Q A) → Type a
q₁ ∼ q₂ = Q.to-List _ q₁ ≡ Q.to-List _ q₂
-- Queues.
--
-- The type is abstract to ensure that a change to a different
-- underlying queue type family does not break code that uses this
-- module.
--
-- Ulf Norell suggested to me that I could use parametrisation
-- instead of abstract. (Because if the underlying queue type
-- family is a parameter, then the underlying queues do not
-- compute.) I decided to use both. (Because I want to have the
-- flexibility that comes with parametrisation, but I do not want
-- to force users to work in a parametrised setting.)
Queue : Type a → Type a
Queue A = Q A / _∼_
-- The remainder of the code uses an implicit underlying queue type
-- family parameter, and an extra instance argument.
module _
{Q : ∀ {ℓ} → Type ℓ → Type ℓ}
⦃ is-queue : ∀ {ℓ} → Q.Is-queue Q (λ _ → ↑ _ ⊤) ℓ ⦄
⦃ is-queue-with-map : ∀ {ℓ₁ ℓ₂} → Q.Is-queue-with-map Q ℓ₁ ℓ₂ ⦄
where
abstract
-- Queue A is a set.
Queue-is-set : Is-set (Queue Q A)
Queue-is-set = /-is-set
------------------------------------------------------------------------
-- Conversion functions
abstract
-- Converts queues to lists. (The carrier type is required to be a
-- set.)
to-List : Is-set A → Queue Q A → List A
to-List s = Quotient.rec λ where
.[]ʳ → Q.to-List _
.[]-respects-relationʳ → id
.is-setʳ → H-level-List 0 s
-- Converts lists to queues.
from-List : List A → Queue Q A
from-List = [_] ∘ Q.from-List
-- The function from-List is a right inverse of to-List s.
to-List-from-List : to-List s (from-List q) ≡ q
to-List-from-List = Q.to-List-from-List
-- The function from-List is a left inverse of to-List s.
from-List-to-List :
(q : Queue Q A) → _≡_ {A = Queue Q A} (from-List (to-List s q)) q
from-List-to-List = Quotient.elim-prop λ where
.[]ʳ q → []-respects-relation (
Q.to-List ⦃ is-queue = is-queue ⦄ _
(Q.from-List (Q.to-List _ q)) ≡⟨ Q.to-List-from-List ⟩∎
Q.to-List _ q ∎)
.is-propositionʳ _ → Queue-is-set
-- If A is a set, then there is a bijection between Queue Q A and
-- List A.
Queue↔List : Is-set A → Queue Q A ↔ List A
Queue↔List s = record
{ surjection = record
{ logical-equivalence = record
{ to = to-List s
; from = from-List
}
; right-inverse-of = λ _ → to-List-from-List
}
; left-inverse-of = from-List-to-List
}
------------------------------------------------------------------------
-- Queue operations
abstract
private
-- Helper functions that can be used to define unary functions
-- on queues.
unary :
{A : Type a} {B : Type b}
(f : List A → List B)
(g : Q A → Q B) →
(∀ {q} → Q.to-List _ (g q) ≡ f (Q.to-List _ q)) →
Queue Q A → Queue Q B
unary f g h =
g /-map λ q₁ q₂ q₁∼q₂ →
Q.to-List _ (g q₁) ≡⟨ h ⟩
f (Q.to-List _ q₁) ≡⟨ cong f q₁∼q₂ ⟩
f (Q.to-List _ q₂) ≡⟨ sym h ⟩∎
Q.to-List _ (g q₂) ∎
to-List-unary :
∀ {h : ∀ {q} → _} q →
to-List s₁ (unary f g (λ {q} → h {q = q}) q) ≡ f (to-List s₂ q)
to-List-unary {s₁ = s₁} {f = f} {g = g} {s₂ = s₂} {h = h} =
Quotient.elim-prop λ where
.[]ʳ q →
to-List s₁ (unary f g h [ q ]) ≡⟨⟩
Q.to-List _ (g q) ≡⟨ h ⟩
f (Q.to-List _ q) ≡⟨⟩
f (to-List s₂ [ q ]) ∎
.is-propositionʳ _ → H-level-List 0 s₁
-- Generalisations of the functions above.
unary′ :
{A : Type a} {F : Type a → Type b} →
(∀ {A} → Is-set A → Is-set (F A)) →
(map : ∀ {A B} → (A → B) → F A → F B) →
(∀ {A} {x : F A} → map id x ≡ x) →
(∀ {A B C} {f : B → C} {g : A → B} x →
map (f ∘ g) x ≡ map f (map g x)) →
(f : List A → F (List B))
(g : Q A → F (Q B)) →
(∀ {q} → map (Q.to-List _) (g q) ≡ f (Q.to-List _ q)) →
Is-set B →
Queue Q A → F (Queue Q B)
unary′ F-set map map-id map-∘ f g h s = Quotient.rec λ where
.[]ʳ → map [_] ∘ g
.[]-respects-relationʳ {x = q₁} {y = q₂} q₁∼q₂ → lemma₂ (
map (to-List s) (map [_] (g q₁)) ≡⟨ sym $ map-∘ _ ⟩
map (Q.to-List _) (g q₁) ≡⟨ h ⟩
f (Q.to-List _ q₁) ≡⟨ cong f q₁∼q₂ ⟩
f (Q.to-List _ q₂) ≡⟨ sym h ⟩
map (Q.to-List _) (g q₂) ≡⟨ map-∘ _ ⟩∎
map (to-List s) (map [_] (g q₂)) ∎)
.is-setʳ → F-set Queue-is-set
where
lemma₁ : map from-List (map (to-List s) x) ≡ x
lemma₁ {x = x} =
map from-List (map (to-List s) x) ≡⟨ sym $ map-∘ _ ⟩
map (from-List ∘ to-List s) x ≡⟨ cong (flip map x) $ ⟨ext⟩ $ _↔_.left-inverse-of (Queue↔List s) ⟩
map id x ≡⟨ map-id ⟩∎
x ∎
lemma₂ :
map (to-List s) x₁ ≡ map (to-List s) x₂ →
x₁ ≡ x₂
lemma₂ {x₁ = x₁} {x₂ = x₂} eq =
x₁ ≡⟨ sym lemma₁ ⟩
map from-List (map (to-List s) x₁) ≡⟨ cong (map from-List) eq ⟩
map from-List (map (to-List s) x₂) ≡⟨ lemma₁ ⟩∎
x₂ ∎
to-List-unary′ :
{F : Type a → Type b}
(F-set : ∀ {A} → Is-set A → Is-set (F A))
(map : ∀ {A B} → (A → B) → F A → F B)
(map-id : ∀ {A} {x : F A} → map id x ≡ x)
(map-∘ : ∀ {A B C} {f : B → C} {g : A → B} x →
map (f ∘ g) x ≡ map f (map g x))
(f : List A → F (List B))
(g : Q A → F (Q B))
(h : ∀ {q} → map (Q.to-List _) (g q) ≡ f (Q.to-List _ q))
(s : Is-set B) →
∀ q →
map (to-List s) (unary′ F-set map map-id map-∘ f g h s q) ≡
f (to-List s′ q)
to-List-unary′ {s′ = s′} F-set map map-id map-∘ f g h s =
Quotient.elim-prop λ where
.[]ʳ q →
map (to-List s)
(unary′ F-set map map-id map-∘ f g h s [ q ]) ≡⟨⟩
map (to-List s) (map [_] (g q)) ≡⟨ sym $ map-∘ _ ⟩
map (Q.to-List _) (g q) ≡⟨ h ⟩
f (Q.to-List _ q) ≡⟨⟩
f (to-List s′ [ q ]) ∎
.is-propositionʳ _ → F-set (H-level-List 0 s)
-- Enqueues an element.
enqueue : A → Queue Q A → Queue Q A
enqueue x = unary (_++ x ∷ []) (Q.enqueue x) Q.to-List-enqueue
to-List-enqueue : to-List s (enqueue x q) ≡ to-List s q ++ x ∷ []
to-List-enqueue {q = q} = to-List-unary q
-- Dequeues an element, if possible. (The carrier type is required
-- to be a set.)
dequeue : Is-set A → Queue Q A → Maybe (A × Queue Q A)
dequeue s = unary′
(Maybe-closure 0 ∘ ×-closure 2 s)
(λ f → ⊎-map id (Σ-map id f))
⊎-map-id
⊎-map-∘
(_↔_.to List↔Maybe[×List])
(Q.dequeue _)
Q.to-List-dequeue
s
to-List-dequeue :
⊎-map id (Σ-map id (to-List s)) (dequeue s q) ≡
_↔_.to List↔Maybe[×List] (to-List s q)
to-List-dequeue {q = q} = to-List-unary′
(Maybe-closure 0 ∘ ×-closure 2 _)
(λ f → ⊎-map id (Σ-map id f))
⊎-map-id
⊎-map-∘
_
(Q.dequeue _)
_
_
q
-- The "inverse" of the dequeue operation.
dequeue⁻¹ : Maybe (A × Queue Q A) → Queue Q A
dequeue⁻¹ nothing = [ Q.empty ]
dequeue⁻¹ (just (x , q)) = unary (x ∷_) (Q.cons x) Q.to-List-cons q
to-List-dequeue⁻¹ :
to-List s (dequeue⁻¹ x) ≡
_↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id (to-List s)) x)
to-List-dequeue⁻¹ {x = nothing} = Q.to-List-empty
to-List-dequeue⁻¹ {x = just (_ , q)} = to-List-unary q
-- A map function.
map : (A → B) → Queue Q A → Queue Q B
map f = unary (L.map f) (Q.map f) Q.to-List-map
to-List-map : to-List s₁ (map f q) ≡ L.map f (to-List s₂ q)
to-List-map {q = q} = to-List-unary q
| {
"alphanum_fraction": 0.4720678856,
"avg_line_length": 32.3496732026,
"ext": "agda",
"hexsha": "9aa562023843180170654e41f7f145edde040cd3",
"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/Queue/Quotiented.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/Queue/Quotiented.agda",
"max_line_length": 112,
"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/Queue/Quotiented.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": 3423,
"size": 9899
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Right-biased universe-sensitive functor and monad instances for These.
--
-- To minimize the universe level of the RawFunctor, we require that
-- elements of B are "lifted" to a copy of B at a higher universe level
-- (a ⊔ b).
-- See the Data.Product.Categorical.Examples for how this is done in a
-- Product-based similar setting.
------------------------------------------------------------------------
-- This functor can be understood as a notion of computation which can
-- either fail (that), succeed (this) or accumulate warnings whilst
-- delivering a successful computation (these).
-- It is a good alternative to Data.Product.Categorical when the notion
-- of warnings does not have a neutral element (e.g. List⁺).
{-# OPTIONS --without-K --safe #-}
open import Level
open import Algebra
module Data.These.Categorical.Right (a : Level) {c ℓ} (W : Semigroup c ℓ) where
open Semigroup W
open import Data.These.Categorical.Right.Base a Carrier public
open import Data.These
open import Category.Applicative
open import Category.Monad
module _ {a b} {A : Set a} {B : Set b} where
applicative : RawApplicative Theseᵣ
applicative = record
{ pure = this
; _⊛_ = ap
} where
ap : ∀ {A B}→ Theseᵣ (A → B) → Theseᵣ A → Theseᵣ B
ap (this f) t = map₁ f t
ap (that w) t = that w
ap (these f w) t = map f (w ∙_) t
monad : RawMonad Theseᵣ
monad = record
{ return = this
; _>>=_ = bind
} where
bind : ∀ {A B} → Theseᵣ A → (A → Theseᵣ B) → Theseᵣ B
bind (this t) f = f t
bind (that w) f = that w
bind (these t w) f = map₂ (w ∙_) (f t)
| {
"alphanum_fraction": 0.6181172291,
"avg_line_length": 29.6315789474,
"ext": "agda",
"hexsha": "7691a0d71e842b1a53683dc57b42d265d15d47d1",
"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/These/Categorical/Right.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/These/Categorical/Right.agda",
"max_line_length": 79,
"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/These/Categorical/Right.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 483,
"size": 1689
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Choosing between elements based on the result of applying a function
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Construct.LiftedChoice where
open import Algebra.Consequences.Base
open import Relation.Binary
open import Relation.Nullary using (¬_; yes; no)
open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; [_,_])
open import Data.Product using (_×_; _,_)
open import Level using (Level; _⊔_)
open import Function.Base using (id; _on_)
open import Function.Injection using (Injection)
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid; _Preserves_⟶_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Unary using (Pred)
open import Relation.Nullary.Negation using (contradiction)
import Relation.Binary.Reasoning.Setoid as EqReasoning
private
variable
a b p ℓ : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Definition
module _ (_≈_ : Rel B ℓ) (_•_ : Op₂ B) where
Lift : Selective _≈_ _•_ → (A → B) → Op₂ A
Lift ∙-sel f x y with ∙-sel (f x) (f y)
... | inj₁ _ = x
... | inj₂ _ = y
------------------------------------------------------------------------
-- Algebraic properties
module _ {_≈_ : Rel B ℓ} {_∙_ : Op₂ B}
(∙-isSelectiveMagma : IsSelectiveMagma _≈_ _∙_) where
private module M = IsSelectiveMagma ∙-isSelectiveMagma
open M hiding (sel; isMagma)
open EqReasoning setoid
module _ (f : A → B) where
private
_◦_ = Lift _≈_ _∙_ M.sel f
sel-≡ : Selective _≡_ _◦_
sel-≡ x y with M.sel (f x) (f y)
... | inj₁ _ = inj₁ P.refl
... | inj₂ _ = inj₂ P.refl
distrib : ∀ x y → ((f x) ∙ (f y)) ≈ f (x ◦ y)
distrib x y with M.sel (f x) (f y)
... | inj₁ fx∙fy≈fx = fx∙fy≈fx
... | inj₂ fx∙fy≈fy = fx∙fy≈fy
module _ (f : A → B) {_≈′_ : Rel A ℓ}
(≈-reflexive : _≡_ ⇒ _≈′_) where
private
_◦_ = Lift _≈_ _∙_ M.sel f
sel : Selective _≈′_ _◦_
sel x y = Sum.map ≈-reflexive ≈-reflexive (sel-≡ f x y)
idem : Idempotent _≈′_ _◦_
idem = sel⇒idem _≈′_ sel
module _ {f : A → B} {_≈′_ : Rel A ℓ}
(f-injective : ∀ {x y} → f x ≈ f y → x ≈′ y)
where
private
_◦_ = Lift _≈_ _∙_ M.sel f
cong : f Preserves _≈′_ ⟶ _≈_ → Congruent₂ _≈′_ _◦_
cong f-cong {x} {y} {u} {v} x≈y u≈v
with M.sel (f x) (f u) | M.sel (f y) (f v)
... | inj₁ fx∙fu≈fx | inj₁ fy∙fv≈fy = x≈y
... | inj₂ fx∙fu≈fu | inj₂ fy∙fv≈fv = u≈v
... | inj₁ fx∙fu≈fx | inj₂ fy∙fv≈fv = f-injective (begin
f x ≈⟨ sym fx∙fu≈fx ⟩
f x ∙ f u ≈⟨ ∙-cong (f-cong x≈y) (f-cong u≈v) ⟩
f y ∙ f v ≈⟨ fy∙fv≈fv ⟩
f v ∎)
... | inj₂ fx∙fu≈fu | inj₁ fy∙fv≈fy = f-injective (begin
f u ≈⟨ sym fx∙fu≈fu ⟩
f x ∙ f u ≈⟨ ∙-cong (f-cong x≈y) (f-cong u≈v) ⟩
f y ∙ f v ≈⟨ fy∙fv≈fy ⟩
f y ∎)
assoc : Associative _≈_ _∙_ → Associative _≈′_ _◦_
assoc ∙-assoc x y z = f-injective (begin
f ((x ◦ y) ◦ z) ≈˘⟨ distrib f (x ◦ y) z ⟩
f (x ◦ y) ∙ f z ≈˘⟨ ∙-congʳ (distrib f x y) ⟩
(f x ∙ f y) ∙ f z ≈⟨ ∙-assoc (f x) (f y) (f z) ⟩
f x ∙ (f y ∙ f z) ≈⟨ ∙-congˡ (distrib f y z) ⟩
f x ∙ f (y ◦ z) ≈⟨ distrib f x (y ◦ z) ⟩
f (x ◦ (y ◦ z)) ∎)
comm : Commutative _≈_ _∙_ → Commutative _≈′_ _◦_
comm ∙-comm x y = f-injective (begin
f (x ◦ y) ≈˘⟨ distrib f x y ⟩
f x ∙ f y ≈⟨ ∙-comm (f x) (f y) ⟩
f y ∙ f x ≈⟨ distrib f y x ⟩
f (y ◦ x) ∎)
------------------------------------------------------------------------
-- Algebraic structures
module _ {_≈′_ : Rel A ℓ} {f : A → B}
(f-injective : ∀ {x y} → f x ≈ f y → x ≈′ y)
(f-cong : f Preserves _≈′_ ⟶ _≈_)
(≈′-isEquivalence : IsEquivalence _≈′_)
where
private
module E = IsEquivalence ≈′-isEquivalence
_◦_ = Lift _≈_ _∙_ M.sel f
isMagma : IsMagma _≈′_ _◦_
isMagma = record
{ isEquivalence = ≈′-isEquivalence
; ∙-cong = cong (λ {x y} → f-injective {x} {y}) f-cong
}
isSemigroup : Associative _≈_ _∙_ → IsSemigroup _≈′_ _◦_
isSemigroup ∙-assoc = record
{ isMagma = isMagma
; assoc = assoc (λ {x y} → f-injective {x} {y}) ∙-assoc
}
isBand : Associative _≈_ _∙_ → IsBand _≈′_ _◦_
isBand ∙-assoc = record
{ isSemigroup = isSemigroup ∙-assoc
; idem = idem f E.reflexive
}
isSemilattice : Associative _≈_ _∙_ → Commutative _≈_ _∙_ →
IsSemilattice _≈′_ _◦_
isSemilattice ∙-assoc ∙-comm = record
{ isBand = isBand ∙-assoc
; comm = comm (λ {x y} → f-injective {x} {y}) ∙-comm
}
isSelectiveMagma : IsSelectiveMagma _≈′_ _◦_
isSelectiveMagma = record
{ isMagma = isMagma
; sel = sel f E.reflexive
}
------------------------------------------------------------------------
-- Other properties
module _ {P : Pred A p} (f : A → B) where
private
_◦_ = Lift _≈_ _∙_ M.sel f
preservesᵒ : (∀ {x y} → P x → (f x ∙ f y) ≈ f y → P y) →
(∀ {x y} → P y → (f x ∙ f y) ≈ f x → P x) →
∀ x y → P x ⊎ P y → P (x ◦ y)
preservesᵒ left right x y (inj₁ px) with M.sel (f x) (f y)
... | inj₁ _ = px
... | inj₂ fx∙fy≈fx = left px fx∙fy≈fx
preservesᵒ left right x y (inj₂ py) with M.sel (f x) (f y)
... | inj₁ fx∙fy≈fy = right py fx∙fy≈fy
... | inj₂ _ = py
preservesʳ : (∀ {x y} → P y → (f x ∙ f y) ≈ f x → P x) →
∀ x {y} → P y → P (x ◦ y)
preservesʳ right x {y} Py with M.sel (f x) (f y)
... | inj₁ fx∙fy≈fx = right Py fx∙fy≈fx
... | inj₂ fx∙fy≈fy = Py
preservesᵇ : ∀ {x y} → P x → P y → P (x ◦ y)
preservesᵇ {x} {y} Px Py with M.sel (f x) (f y)
... | inj₁ _ = Px
... | inj₂ _ = Py
forcesᵇ : (∀ {x y} → P x → (f x ∙ f y) ≈ f x → P y) →
(∀ {x y} → P y → (f x ∙ f y) ≈ f y → P x) →
∀ x y → P (x ◦ y) → P x × P y
forcesᵇ presˡ presʳ x y P[x∙y] with M.sel (f x) (f y)
... | inj₁ fx∙fy≈fx = P[x∙y] , presˡ P[x∙y] fx∙fy≈fx
... | inj₂ fx∙fy≈fy = presʳ P[x∙y] fx∙fy≈fy , P[x∙y]
| {
"alphanum_fraction": 0.4797751054,
"avg_line_length": 32.015,
"ext": "agda",
"hexsha": "562e0f01e5e9defaa26a13812935fa923bd9b4ec",
"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/Algebra/Construct/LiftedChoice.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/Algebra/Construct/LiftedChoice.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Algebra/Construct/LiftedChoice.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": 2617,
"size": 6403
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Rings.IntegralDomains.Definition
open import Rings.Definition
module Rings.Irreducibles.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where
open import Rings.Irreducibles.Definition intDom
open import Rings.Divisible.Definition R
open import Rings.Units.Definition R
open Setoid S
open Equivalence eq
open Ring R
dividesIrreducibleImpliesUnit : {r c : A} → Irreducible r → c ∣ r → (r ∣ c → False) → Unit c
dividesIrreducibleImpliesUnit {r} {c} irred (x , cx=r) notAssoc = Irreducible.irreducible irred x c (transitive *Commutative cx=r) nonunit
where
nonunit : Unit x → False
nonunit (a , xa=1) = notAssoc (a , transitive (transitive (transitive (transitive (*WellDefined (symmetric cx=r) reflexive) (symmetric *Associative)) *Commutative) (*WellDefined xa=1 reflexive)) identIsIdent)
| {
"alphanum_fraction": 0.7359767892,
"avg_line_length": 43.0833333333,
"ext": "agda",
"hexsha": "62dc11da9352abd9351b4456727678f85b499f29",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Rings/Irreducibles/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/Irreducibles/Lemmas.agda",
"max_line_length": 212,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Rings/Irreducibles/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 321,
"size": 1034
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Group.EilenbergMacLane.CupProduct where
open import Cubical.Algebra.Group.EilenbergMacLane.Base renaming (elim to EM-elim)
open import Cubical.Algebra.Group.EilenbergMacLane.WedgeConnectivity
open import Cubical.Algebra.Group.EilenbergMacLane.GroupStructure
open import Cubical.Algebra.Group.EilenbergMacLane.Properties
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc)
open import Cubical.Foundations.Path
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Functions.Morphism
open import Cubical.Homotopy.Loopspace
open import Cubical.HITs.Truncation as Trunc renaming (rec to trRec; elim to trElim)
open import Cubical.HITs.EilenbergMacLane1 renaming (rec to EMrec)
open import Cubical.Algebra.AbGroup.Base
open import Cubical.Data.Empty
renaming (rec to ⊥-rec)
open import Cubical.HITs.Truncation
renaming (elim to trElim ; rec to trRec ; rec2 to trRec2)
open import Cubical.Data.Nat hiding (_·_) renaming (elim to ℕelim)
open import Cubical.HITs.Susp
open import Cubical.Algebra.AbGroup.TensorProduct
open import Cubical.Algebra.Group
open AbGroupStr renaming (_+_ to _+Gr_ ; -_ to -Gr_)
open PlusBis
private
variable
ℓ ℓ' ℓ'' : Level
-- Lemma for distributativity of cup product (used later)
pathType : ∀ {ℓ} {G : AbGroup ℓ} (n : ℕ) (x : EM G (2 + n)) (p : 0ₖ (2 + n) ≡ x) → Type ℓ
pathType n x p = sym (rUnitₖ (2 + n) x) ∙ (λ i → x +ₖ p i)
≡ sym (lUnitₖ (2 + n) x) ∙ λ i → p i +ₖ x
pathTypeMake : ∀ {ℓ} {G : AbGroup ℓ} (n : ℕ) (x : EM G (2 + n)) (p : 0ₖ (2 + n) ≡ x)
→ pathType n x p
pathTypeMake n x = J (λ x p → pathType n x p) refl
-- Definition of cup product (⌣ₖ, given by ·₀ when first argument is in K(G,0))
module _ {G' : AbGroup ℓ} {H' : AbGroup ℓ'} where
private
G = fst G'
H = fst H'
strG = snd G'
strH = snd H'
0G = 0g strG
0H = 0g strH
_+G_ = _+Gr_ strG
_+H_ = _+Gr_ strH
-H_ = -Gr_ strH
-G_ = -Gr_ strG
·₀' : H → (m : ℕ) → EM G' m → EM (G' ⨂ H') m
·₀' h =
elim+2
(_⊗ h)
(elimGroupoid _ (λ _ → emsquash)
embase
(λ g → emloop (g ⊗ h))
λ g l →
compPathR→PathP
(sym (∙assoc _ _ _
∙∙ cong₂ _∙_ (sym (emloop-comp _ _ _)
∙ cong emloop (sym (⊗DistL+⊗ g l h))) refl
∙∙ rCancel _)))
λ n f → trRec (isOfHLevelTrunc (4 + n))
λ { north → 0ₖ (suc (suc n))
; south → 0ₖ (suc (suc n))
; (merid a i) → EM→ΩEM+1 (suc n) (f (EM-raw→EM _ _ a)) i}
·₀ : G → (m : ℕ) → EM H' m → EM (G' ⨂ H') m
·₀ g =
elim+2 (λ h → g ⊗ h)
(elimGroupoid _ (λ _ → emsquash)
embase
(λ h → emloop (g ⊗ h))
λ h l → compPathR→PathP
(sym (∙assoc _ _ _
∙∙ cong₂ _∙_ (sym (emloop-comp _ _ _) ∙ cong emloop (sym (⊗DistR+⊗ g h l))) refl
∙∙ rCancel _)))
λ n f
→ trRec (isOfHLevelTrunc (4 + n))
λ { north → 0ₖ (suc (suc n))
; south → 0ₖ (suc (suc n))
; (merid a i) → EM→ΩEM+1 (suc n) (f (EM-raw→EM _ _ a)) i}
·₀-distr : (g h : G) → (m : ℕ) (x : EM H' m) → ·₀ (g +G h) m x ≡ ·₀ g m x +ₖ ·₀ h m x
·₀-distr g h =
elim+2
(⊗DistL+⊗ g h)
(elimSet _ (λ _ → emsquash _ _)
refl
(λ w → compPathR→PathP (sym ((λ i → emloop (⊗DistL+⊗ g h w i)
∙ (lUnit (sym (cong₂+₁ (emloop (g ⊗ w)) (emloop (h ⊗ w)) i)) (~ i)))
∙∙ cong₂ _∙_ (emloop-comp _ (g ⊗ w) (h ⊗ w)) refl
∙∙ rCancel _))))
λ m ind →
trElim (λ _ → isOfHLevelTruncPath)
λ { north → refl
; south → refl
; (merid a i) k → z m ind a k i}
where
z : (m : ℕ) → ((x : EM H' (suc m))
→ ·₀ (g +G h) (suc m) x
≡ ·₀ g (suc m) x +ₖ ·₀ h (suc m) x) → (a : EM-raw H' (suc m))
→ cong (·₀ (g +G h) (suc (suc m))) (cong ∣_∣ₕ (merid a)) ≡
cong₂ _+ₖ_
(cong (·₀ g (suc (suc m))) (cong ∣_∣ₕ (merid a)))
(cong (·₀ h (suc (suc m))) (cong ∣_∣ₕ (merid a)))
z m ind a = (λ i → EM→ΩEM+1 _ (ind (EM-raw→EM _ _ a) i))
∙∙ EM→ΩEM+1-hom _ (·₀ g (suc m) (EM-raw→EM H' (suc m) a))
(·₀ h (suc m) (EM-raw→EM H' (suc m) a))
∙∙ sym (cong₂+₂ m (cong (·₀ g (suc (suc m))) (cong ∣_∣ₕ (merid a)))
(cong (·₀ h (suc (suc m))) (cong ∣_∣ₕ (merid a))))
·₀0 : (m : ℕ) → (g : G) → ·₀ g m (0ₖ m) ≡ 0ₖ m
·₀0 zero = ⊗AnnihilR
·₀0 (suc zero) g = refl
·₀0 (suc (suc m)) g = refl
·₀'0 : (m : ℕ) (h : H) → ·₀' h m (0ₖ m) ≡ 0ₖ m
·₀'0 zero = ⊗AnnihilL
·₀'0 (suc zero) g = refl
·₀'0 (suc (suc m)) g = refl
0·₀ : (m : ℕ) → (x : _) → ·₀ 0G m x ≡ 0ₖ m
0·₀ =
elim+2 ⊗AnnihilL
(elimSet _ (λ _ → emsquash _ _)
refl
λ g → compPathR→PathP ((sym (emloop-1g _)
∙ cong emloop (sym (⊗AnnihilL g)))
∙∙ (λ i → rUnit (rUnit (cong (·₀ 0G 1) (emloop g)) i) i)
∙∙ sym (∙assoc _ _ _)))
λ n f → trElim (λ _ → isOfHLevelTruncPath)
λ { north → refl
; south → refl
; (merid a i) j → (cong (EM→ΩEM+1 (suc n)) (f (EM-raw→EM _ _ a))
∙ EM→ΩEM+1-0ₖ _) j i}
0·₀' : (m : ℕ) (g : _) → ·₀' 0H m g ≡ 0ₖ m
0·₀' =
elim+2
⊗AnnihilR
(elimSet _ (λ _ → emsquash _ _)
refl
λ g → compPathR→PathP (sym (∙assoc _ _ _
∙∙ sym (rUnit _) ∙ sym (rUnit _)
∙∙ (cong emloop (⊗AnnihilR g)
∙ emloop-1g _))))
λ n f → trElim (λ _ → isOfHLevelTruncPath)
λ { north → refl
; south → refl
; (merid a i) j → (cong (EM→ΩEM+1 (suc n)) (f (EM-raw→EM _ _ a))
∙ EM→ΩEM+1-0ₖ _) j i}
-- Definition of the cup product
cup∙ : ∀ n m → EM G' n → EM∙ H' m →∙ EM∙ (G' ⨂ H') (n +' m)
cup∙ =
ℕelim
(λ m g → (·₀ g m) , ·₀0 m g)
λ n f →
ℕelim
(λ g → (λ h → ·₀' h (suc n) g) , 0·₀' (suc n) g)
λ m _ → main n m f
where
main : (n m : ℕ) (ind : ((m : ℕ) → EM G' n → EM∙ H' m →∙ EM∙ (G' ⨂ H') (n +' m)))
→ EM G' (suc n) → EM∙ H' (suc m) →∙ EM∙ (G' ⨂ H') (suc (suc (n + m)))
main zero m ind =
elimGroupoid _ (λ _ → isOfHLevel↑∙ _ _)
((λ _ → 0ₖ (2 + m)) , refl)
(f m)
λ n h → finalpp m n h
where
f : (m : ℕ) → G → typ (Ω (EM∙ H' (suc m) →∙ EM∙ (G' ⨂ H') (suc (suc m)) ∙))
fst (f m g i) x = EM→ΩEM+1 _ (·₀ g _ x) i
snd (f zero g i) j = EM→ΩEM+1-0ₖ (suc zero) j i
snd (f (suc m) g i) j = EM→ΩEM+1-0ₖ (suc (suc m)) j i
f-hom-fst : (m : ℕ) (g h : G) → cong fst (f m (g +G h)) ≡ cong fst (f m g ∙ f m h)
f-hom-fst m g h =
(λ i j x → EM→ΩEM+1 _ (·₀-distr g h (suc m) x i) j)
∙∙ (λ i j x → EM→ΩEM+1-hom _ (·₀ g (suc m) x) (·₀ h (suc m) x) i j)
∙∙ sym (cong-∙ fst (f m g) (f m h))
f-hom : (m : ℕ) (g h : G) → f m (g +G h) ≡ f m g ∙ f m h
f-hom m g h = →∙Homogeneous≡Path (isHomogeneousEM _) _ _ (f-hom-fst m g h)
finalpp : (m : ℕ) (g h : G) → PathP (λ i → f m g i ≡ f m (g +G h) i) refl (f m h)
finalpp m g h =
compPathR→PathP (sym (rCancel _)
∙∙ cong (_∙ sym (f m (g +G h))) (f-hom m g h)
∙∙ sym (∙assoc _ _ _))
main (suc n) m ind =
trElim (λ _ → isOfHLevel↑∙ (2 + n) m)
λ { north → (λ _ → 0ₖ (3 + (n + m))) , refl
; south → (λ _ → 0ₖ (3 + (n + m))) , refl
; (merid a i) → Iso.inv (ΩfunExtIso _ _)
(EM→ΩEM+1∙ _ ∘∙ ind (suc m) (EM-raw→EM _ _ a)) i}
_⌣ₖ_ : {n m : ℕ} (x : EM G' n) (y : EM H' m) → EM (G' ⨂ H') (n +' m)
_⌣ₖ_ x y = cup∙ _ _ x .fst y
⌣ₖ-0ₖ : (n m : ℕ) (x : EM G' n) → (x ⌣ₖ 0ₖ m) ≡ 0ₖ (n +' m)
⌣ₖ-0ₖ n m x = cup∙ n m x .snd
0ₖ-⌣ₖ : (n m : ℕ) (x : EM H' m) → ((0ₖ n) ⌣ₖ x) ≡ 0ₖ (n +' m)
0ₖ-⌣ₖ zero m = 0·₀ _
0ₖ-⌣ₖ (suc zero) zero x = refl
0ₖ-⌣ₖ (suc (suc n)) zero x = refl
0ₖ-⌣ₖ (suc zero) (suc m) x = refl
0ₖ-⌣ₖ (suc (suc n)) (suc m) x = refl
module LeftDistributivity {G' : AbGroup ℓ} {H' : AbGroup ℓ'} where
private
distrl1 : (n m : ℕ) → EM H' m → EM H' m
→ EM∙ G' n →∙ EM∙ (G' ⨂ H') (n +' m)
fst (distrl1 n m x y) z = z ⌣ₖ (x +ₖ y)
snd (distrl1 n m x y) = 0ₖ-⌣ₖ n m _
distrl2 : (n m : ℕ) → EM H' m → EM H' m
→ EM∙ G' n →∙ EM∙ (G' ⨂ H') (n +' m)
fst (distrl2 n m x y) z = (z ⌣ₖ x) +ₖ (z ⌣ₖ y)
snd (distrl2 n m x y) =
cong₂ _+ₖ_ (0ₖ-⌣ₖ n m x) (0ₖ-⌣ₖ n m y) ∙ rUnitₖ _ (0ₖ (n +' m))
hLevLem : (n m : ℕ) → isOfHLevel (suc (suc m)) (EM∙ G' (suc n) →∙ EM∙ (G' ⨂ H') ((suc n) +' m))
hLevLem n m =
subst (isOfHLevel (suc (suc m)))
(λ i → EM∙ G' (suc n) →∙ EM∙ (G' ⨂ H')
((cong suc (+-comm m n) ∙ sym (+'≡+ (suc n) m)) i)) (isOfHLevel↑∙ m n)
mainDistrL : (n m : ℕ) (x y : EM H' (suc m))
→ distrl1 (suc n) (suc m) x y ≡ distrl2 (suc n) (suc m) x y
mainDistrL n zero =
wedgeConEM.fun H' H' 0 0
(λ _ _ → hLevLem _ _ _ _)
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt λ z → l x z))
(λ y → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt λ z → r y z ))
λ i → →∙Homogeneous≡ (isHomogeneousEM (suc (suc (n + 0))))
(funExt (λ z → l≡r z i))
where
l : (x : EM H' 1) (z : _)
→ (distrl1 (suc n) 1 embase x .fst z) ≡ (distrl2 (suc n) 1 embase x .fst z)
l x z = cong (z ⌣ₖ_) (lUnitₖ _ x)
∙∙ sym (lUnitₖ _ (z ⌣ₖ x))
∙∙ λ i → (⌣ₖ-0ₖ (suc n) (suc zero) z (~ i)) +ₖ (z ⌣ₖ x)
r : (z : EM H' 1) (x : EM G' (suc n))
→ (distrl1 (suc n) 1 z embase .fst x) ≡ (distrl2 (suc n) 1 z embase .fst x)
r y z = cong (z ⌣ₖ_) (rUnitₖ _ y)
∙∙ sym (rUnitₖ _ (z ⌣ₖ y))
∙∙ λ i → (z ⌣ₖ y) +ₖ (⌣ₖ-0ₖ (suc n) (suc zero) z (~ i))
l≡r : (z : EM G' (suc n)) → l embase z ≡ r embase z
l≡r z = sym (pathTypeMake _ _ (sym (⌣ₖ-0ₖ (suc n) (suc zero) z)))
mainDistrL n (suc m) =
elim2 (λ _ _ → isOfHLevelPath (4 + m) (hLevLem _ _) _ _)
(wedgeConEM.fun H' H' (suc m) (suc m)
(λ x y p q → isOfHLevelPlus {n = suc (suc m)} (suc m)
(hLevLem n (suc (suc m))
(distrl1 (suc n) (suc (suc m)) ∣ x ∣ ∣ y ∣)
(distrl2 (suc n) (suc (suc m)) ∣ x ∣ ∣ y ∣) p q))
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (l x)))
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (r x)))
λ i → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (λ z → l≡r z i)))
where
l : (x : EM-raw H' (suc (suc m))) (z : EM G' (suc n))
→ (distrl1 (suc n) (suc (suc m)) (0ₖ _) ∣ x ∣ₕ .fst z)
≡ (distrl2 (suc n) (suc (suc m)) (0ₖ _) ∣ x ∣ₕ .fst z)
l x z = cong (z ⌣ₖ_) (lUnitₖ (suc (suc m)) ∣ x ∣)
∙∙ sym (lUnitₖ _ (z ⌣ₖ ∣ x ∣))
∙∙ λ i → (⌣ₖ-0ₖ (suc n) (suc (suc m)) z (~ i)) +ₖ (z ⌣ₖ ∣ x ∣)
r : (x : EM-raw H' (suc (suc m))) (z : EM G' (suc n))
→ (distrl1 (suc n) (suc (suc m)) ∣ x ∣ₕ (0ₖ _) .fst z)
≡ (distrl2 (suc n) (suc (suc m)) ∣ x ∣ₕ (0ₖ _) .fst z)
r x z = cong (z ⌣ₖ_) (rUnitₖ (suc (suc m)) ∣ x ∣)
∙∙ sym (rUnitₖ _ (z ⌣ₖ ∣ x ∣))
∙∙ λ i → (z ⌣ₖ ∣ x ∣) +ₖ (⌣ₖ-0ₖ (suc n) (suc (suc m)) z (~ i))
l≡r : (z : EM G' (suc n)) → l north z ≡ r north z
l≡r z = sym (pathTypeMake _ _ (sym (⌣ₖ-0ₖ (suc n) (suc (suc m)) z)))
module RightDistributivity {G' : AbGroup ℓ} {H' : AbGroup ℓ'} where
private
G = fst G'
H = fst H'
strG = snd G'
strH = snd H'
0G = 0g strG
0H = 0g strH
_+G_ = _+Gr_ strG
_+H_ = _+Gr_ strH
-H_ = -Gr_ strH
-G_ = -Gr_ strG
distrr1 : (n m : ℕ) → EM G' n → EM G' n → EM∙ H' m →∙ EM∙ (G' ⨂ H') (n +' m)
fst (distrr1 n m x y) z = (x +ₖ y) ⌣ₖ z
snd (distrr1 n m x y) = ⌣ₖ-0ₖ n m _
distrr2 : (n m : ℕ) → EM G' n → EM G' n → EM∙ H' m →∙ EM∙ (G' ⨂ H') (n +' m)
fst (distrr2 n m x y) z = (x ⌣ₖ z) +ₖ (y ⌣ₖ z)
snd (distrr2 n m x y) = cong₂ _+ₖ_ (⌣ₖ-0ₖ n m x) (⌣ₖ-0ₖ n m y) ∙ rUnitₖ _ (0ₖ (n +' m))
mainDistrR : (n m : ℕ) (x y : EM G' (suc n))
→ distrr1 (suc n) (suc m) x y ≡ distrr2 (suc n) (suc m) x y
mainDistrR zero m =
wedgeConEM.fun G' G' 0 0
(λ _ _ → isOfHLevel↑∙ 1 m _ _)
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (l x)))
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (r x)))
λ i → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt λ z → l≡r z i)
where
l : (x : _) (z : _) → _ ≡ _
l x z =
(λ i → (lUnitₖ 1 x i) ⌣ₖ z)
∙∙ sym (lUnitₖ _ (x ⌣ₖ z))
∙∙ λ i → 0ₖ-⌣ₖ _ _ z (~ i) +ₖ (x ⌣ₖ z)
r : (x : _) (z : _) → _ ≡ _
r x z =
((λ i → (rUnitₖ 1 x i) ⌣ₖ z))
∙∙ sym (rUnitₖ _ _)
∙∙ λ i → (_⌣ₖ_ {n = 1} {m = suc m} x z) +ₖ 0ₖ-⌣ₖ (suc zero) (suc m) z (~ i)
l≡r : (z : _) → l embase z ≡ r embase z
l≡r z = pathTypeMake _ _ _
mainDistrR (suc n) m =
elim2 (λ _ _ → isOfHLevelPath (4 + n)
(isOfHLevel↑∙ (2 + n) m) _ _)
(wedgeConEM.fun _ _ _ _
(λ x y → isOfHLevelPath ((2 + n) + (2 + n))
(transport (λ i → isOfHLevel (((λ i → (+-comm n 2 (~ i) + (2 + n)))
∙ sym (+-assoc n 2 (2 + n))) (~ i))
(EM∙ H' (suc m) →∙ EM∙ ((fst (AbGroupPath (G' ⨂ H') (H' ⨂ G'))) ⨂-comm (~ i))
((+'-comm (suc m) (suc (suc n))) i)))
(isOfHLevelPlus n
(LeftDistributivity.hLevLem m (suc (suc n))))) _ _)
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (l x)))
(λ x → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt (r x)))
λ i → →∙Homogeneous≡ (isHomogeneousEM _)
(funExt λ z → r≡l z i))
where
l : (x : _) (z : _) → _ ≡ _
l x z = (λ i → (lUnitₖ _ ∣ x ∣ i) ⌣ₖ z)
∙∙ sym (lUnitₖ _ (∣ x ∣ ⌣ₖ z))
∙∙ λ i → 0ₖ-⌣ₖ _ _ z (~ i) +ₖ (∣ x ∣ ⌣ₖ z)
r : (x : _) (z : _) → _ ≡ _
r x z = (λ i → (rUnitₖ _ ∣ x ∣ i) ⌣ₖ z)
∙∙ sym (rUnitₖ _ (∣ x ∣ ⌣ₖ z))
∙∙ λ i → (∣ x ∣ ⌣ₖ z) +ₖ 0ₖ-⌣ₖ _ _ z (~ i)
r≡l : (z : _) → l north z ≡ r north z
r≡l z = pathTypeMake _ _ _
-- TODO: Summarise distributivity proofs
-- TODO: Associativity and graded commutativity, following Cubical.ZCohomology.RingStructure
-- The following lemmas will be needed to make the types match up.
| {
"alphanum_fraction": 0.4423064711,
"avg_line_length": 38.8814814815,
"ext": "agda",
"hexsha": "27b9757ef629d9f15cec7f384adc4912958a4ebe",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/EilenbergMacLane/CupProduct.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/EilenbergMacLane/CupProduct.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/EilenbergMacLane/CupProduct.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6848,
"size": 15747
} |
{-# OPTIONS --without-K --rewriting #-}
module Axiom.LEM where
open import Basics
open import Flat
open import lib.Basics
postulate LEM : {@♭ i : ULevel} (@♭ P : PropT i) → Dec (P holds)
| {
"alphanum_fraction": 0.6381909548,
"avg_line_length": 22.1111111111,
"ext": "agda",
"hexsha": "30f7bc8aa04e7977dab32d8b748e4f09d1c5e761",
"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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Axiom/LEM.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Axiom/LEM.agda",
"max_line_length": 66,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Axiom/LEM.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 63,
"size": 199
} |
module Generic.Test.Reify where
open import Generic.Core
open import Generic.Property.Reify
open import Generic.Test.Data.Fin
open import Generic.Test.Data.Vec
open import Data.Fin renaming (Fin to StdFin)
open import Data.Vec renaming (Vec to StdVec)
xs : Vec (Fin 4) 3
xs = fsuc (fsuc (fsuc fzero)) ∷ᵥ fzero ∷ᵥ fsuc fzero ∷ᵥ []ᵥ
xs′ : StdVec (StdFin 4) 3
xs′ = suc (suc (suc zero)) ∷ zero ∷ (suc zero) ∷ []
test : reflect xs ≡ xs′
test = refl
| {
"alphanum_fraction": 0.7066666667,
"avg_line_length": 23.6842105263,
"ext": "agda",
"hexsha": "4ffce7a8da956fa2d543df18884422506e3b4ac4",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z",
"max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "turion/Generic",
"max_forks_repo_path": "src/Generic/Test/Reify.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "turion/Generic",
"max_issues_repo_path": "src/Generic/Test/Reify.agda",
"max_line_length": 59,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "turion/Generic",
"max_stars_repo_path": "src/Generic/Test/Reify.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z",
"num_tokens": 161,
"size": 450
} |
{-# OPTIONS --cubical --no-import-sorts --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.Groups.Prelims where
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.GroupStructure
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Path
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.S1
open import Cubical.Homotopy.Loopspace
open import Cubical.Data.Sigma
open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec)
open import Cubical.HITs.SetTruncation renaming (elim to sElim ; map to sMap ; rec to sRec)
infixr 33 _⋄_
_⋄_ : _
_⋄_ = compIso
-- We strengthen the elimination rule for Hⁿ(S¹). We show that we only need to work with elements ∣ f ∣₂ (definitionally) sending loop to some loop p
-- and sending base to 0
elimFunS¹ : (n : ℕ) → (p : typ (Ω (coHomK-ptd (suc n)))) → S¹ → coHomK (suc n)
elimFunS¹ n p base = ∣ ptSn (suc n) ∣
elimFunS¹ n p (loop i) = p i
coHomPointedElimS¹ : ∀ {ℓ} (n : ℕ) {B : coHom (suc n) S¹ → Type ℓ}
→ ((x : coHom (suc n) S¹) → isProp (B x))
→ ((p : typ (Ω (coHomK-ptd (suc n)))) → B ∣ elimFunS¹ n p ∣₂)
→ (x : coHom (suc n) S¹) → B x
coHomPointedElimS¹ n {B = B} x p =
coHomPointedElim n base x
λ f Id → subst B
(cong ∣_∣₂ (funExt (λ {base → sym Id ; (loop i) j → doubleCompPath-filler (sym Id) (cong f loop) Id (~ j) i})))
(p (sym Id ∙∙ (cong f loop) ∙∙ Id))
coHomPointedElimS¹2 : ∀ {ℓ} (n : ℕ) {B : (x y : coHom (suc n) S¹) → Type ℓ}
→ ((x y : coHom (suc n) S¹) → isProp (B x y))
→ ((p q : typ (Ω (coHomK-ptd (suc n)))) → B ∣ elimFunS¹ n p ∣₂ ∣ elimFunS¹ n q ∣₂)
→ (x y : coHom (suc n) S¹) → B x y
coHomPointedElimS¹2 n {B = B} x p =
coHomPointedElim2 _ base x λ f g fId gId
→ subst2 B (cong ∣_∣₂ (funExt (λ {base → sym fId ; (loop i) j → doubleCompPath-filler (sym (fId)) (cong f loop) fId (~ j) i})))
(cong ∣_∣₂ (funExt (λ {base → sym gId ; (loop i) j → doubleCompPath-filler (sym (gId)) (cong g loop) gId (~ j) i})))
(p (sym fId ∙∙ cong f loop ∙∙ fId) (sym gId ∙∙ cong g loop ∙∙ gId))
-- We do the same thing for Sⁿ, n ≥ 2.
elimFunSⁿ : (n m : ℕ) (p : S₊ (suc m) → typ (Ω (coHomK-ptd (suc n))))
→ (S₊ (2 + m)) → coHomK (suc n)
elimFunSⁿ n m p north = ∣ ptSn (suc n) ∣
elimFunSⁿ n m p south = ∣ ptSn (suc n) ∣
elimFunSⁿ n m p (merid a i) = p a i
coHomPointedElimSⁿ : ∀ {ℓ} (n m : ℕ) {B : (x : coHom (suc n) (S₊ (2 + m))) → Type ℓ}
→ ((x : coHom (suc n) (S₊ (2 + m))) → isProp (B x))
→ ((p : _) → B ∣ elimFunSⁿ n m p ∣₂)
→ (x : coHom (suc n) (S₊ (2 + m))) → B x
coHomPointedElimSⁿ n m {B = B} isprop ind =
coHomPointedElim n north isprop
λ f fId → subst B (cong ∣_∣₂ (funExt (λ {north → sym fId
; south → sym fId ∙' cong f (merid (ptSn (suc m)))
; (merid a i) j → hcomp (λ k → λ {(i = i0) → fId (~ j ∧ k)
; (i = i1) → compPath'-filler (sym fId)
(cong f (merid (ptSn (suc m)))) k j
; (j = i1) → f (merid a i)})
(hcomp (λ k → λ {(i = i0) → f north ;
(i = i1) → f (merid (ptSn (suc m)) (j ∨ ~ k)) ;
(j = i1) → f (merid a i)})
(f (merid a i)))})))
(ind λ a → sym fId ∙∙ cong f (merid a) ∙ cong f (sym (merid (ptSn (suc m)))) ∙∙ fId)
0₀ = 0ₖ 0
0₁ = 0ₖ 1
0₂ = 0ₖ 2
0₃ = 0ₖ 3
0₄ = 0ₖ 4
S¹map : hLevelTrunc 3 S¹ → S¹
S¹map = trRec isGroupoidS¹ (idfun _)
S¹map-id : (x : hLevelTrunc 3 S¹) → Path (hLevelTrunc 3 S¹) ∣ S¹map x ∣ x
S¹map-id = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ a → refl
-- We prove that (S¹ → ∥ S¹ ∥) ≃ S¹ × ℤ (Needed for H¹(S¹)). Note that the truncation doesn't really matter, since S¹ is a groupoid.
-- Given a map f : S¹ → S¹, the idea is to send this to (f(base) , winding (f(loop))). For this to be
-- well-typed, we need to translate f(loop) into an element in Ω(S¹,base).
S¹→S¹≡S¹×Int : Iso (S¹ → hLevelTrunc 3 S¹) (S¹ × Int)
Iso.fun S¹→S¹≡S¹×Int f = S¹map (f base)
, winding (basechange2⁻ (S¹map (f base)) λ i → S¹map (f (loop i)))
Iso.inv S¹→S¹≡S¹×Int (s , int) base = ∣ s ∣
Iso.inv S¹→S¹≡S¹×Int (s , int) (loop i) = ∣ basechange2 s (intLoop int) i ∣
Iso.rightInv S¹→S¹≡S¹×Int (s , int) = ΣPathP (refl , ((λ i → winding (basechange2-retr s (λ i → intLoop int i) i))
∙ windingIntLoop int))
Iso.leftInv S¹→S¹≡S¹×Int f = funExt λ { base → S¹map-id (f base)
; (loop i) j → helper j i}
where
helper : PathP (λ i → S¹map-id (f base) i ≡ S¹map-id (f base) i)
(λ i → ∣ basechange2 (S¹map (f base))
(intLoop (winding (basechange2⁻ (S¹map (f base)) (λ i₁ → S¹map (f (loop i₁)))))) i ∣)
(cong f loop)
helper i j =
hcomp (λ k → λ { (i = i0) → cong ∣_∣ (basechange2 (S¹map (f base))
(intLoop (winding (basechange2⁻ (S¹map (f base)) (λ i₁ → S¹map (f (loop i₁))))))) j
; (i = i1) → S¹map-id (f (loop j)) k
; (j = i0) → S¹map-id (f base) (i ∧ k)
; (j = i1) → S¹map-id (f base) (i ∧ k)})
(helper2 i j)
where
helper2 : Path (Path (hLevelTrunc 3 _) _ _)
(cong ∣_∣ (basechange2 (S¹map (f base))
(intLoop
(winding
(basechange2⁻ (S¹map (f base))
(λ i₁ → S¹map (f (loop i₁))))))))
λ i → ∣ S¹map (f (loop i)) ∣
helper2 i j =
∣ ((cong (basechange2 (S¹map (f base)))
(decodeEncode base (basechange2⁻ (S¹map (f base))
(λ i₁ → S¹map (f (loop i₁)))))
∙ basechange2-sect (S¹map (f base))
(λ i → S¹map (f (loop i)))) i) j ∣
{- Proof that (S¹ → K₁) ≃ K₁ × ℤ. Needed for H¹(T²) -}
S1→K₁≡S1×Int : Iso ((S₊ 1) → coHomK 1) (coHomK 1 × Int)
S1→K₁≡S1×Int = S¹→S¹≡S¹×Int ⋄ prodIso (invIso (truncIdempotentIso 3 (isGroupoidS¹))) idIso
module _ (key : Unit') where
module P = lockedCohom key
private
_+K_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_+K_ {n = n} = P.+K n
-K_ : {n : ℕ} → coHomK n → coHomK n
-K_ {n = n} = P.-K n
_-K_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_-K_ {n = n} = P.-Kbin n
infixr 55 _+K_
infixr 55 -K_
infixr 56 _-K_
{- Proof that S¹→K2 is isomorphic to K2×K1 (as types). Needed for H²(T²) -}
S1→K2≡K2×K1' : Iso (S₊ 1 → coHomK 2) (coHomK 2 × coHomK 1)
Iso.fun S1→K2≡K2×K1' f = f base , ΩKn+1→Kn 1 (sym (P.rCancelK 2 (f base))
∙∙ cong (λ x → (f x) -K f base) loop
∙∙ P.rCancelK 2 (f base))
Iso.inv S1→K2≡K2×K1' = invmap
where
invmap : (∥ Susp S¹ ∥ 4) × (∥ S¹ ∥ 3) → S¹ → ∥ Susp S¹ ∥ 4
invmap (a , b) base = a +K 0₂
invmap (a , b) (loop i) = a +K Kn→ΩKn+1 1 b i
Iso.rightInv S1→K2≡K2×K1' (a , b) = ΣPathP ((P.rUnitK 2 a)
, (cong (ΩKn+1→Kn 1) (doubleCompPath-elim' (sym (P.rCancelK 2 (a +K 0₂)))
(λ i → (a +K Kn→ΩKn+1 1 b i) -K (a +K 0₂))
(P.rCancelK 2 (a +K 0₂)))
∙∙ cong (ΩKn+1→Kn 1) (congHelper2 (Kn→ΩKn+1 1 b) (λ x → (a +K x) -K (a +K 0₂))
(funExt (λ x → sym (cancelHelper a x)))
(P.rCancelK 2 (a +K 0₂)))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 1) b))
module _ where
cancelHelper : (a b : coHomK 2) → (a +K b) -K (a +K 0₂) ≡ b
cancelHelper a b = cong (λ x → (a +K b) -K x) (P.rUnitK 2 a)
∙ P.-cancelLK 2 a b
congHelper2 : (p : 0₂ ≡ 0₂) (f : coHomK 2 → coHomK 2) (id : (λ x → x) ≡ f) → (q : (f 0₂) ≡ 0₂)
→ (sym q) ∙ cong f p ∙ q ≡ p
congHelper2 p f = J (λ f _ → (q : (f 0₂) ≡ 0₂) → (sym q) ∙ cong f p ∙ q ≡ p)
λ q → (cong (sym q ∙_) (isCommΩK 2 p _) ∙∙ assoc _ _ _ ∙∙ cong (_∙ p) (lCancel q))
∙ sym (lUnit p)
conghelper3 : (x : coHomK 2) (p : x ≡ x) (f : coHomK 2 → coHomK 2) (id : (λ x → x) ≡ f) (q : f x ≡ x)
→ (sym q) ∙ cong f p ∙ q ≡ p
conghelper3 x p f = J (λ f _ → (q : (f x) ≡ x) → (sym q) ∙ cong f p ∙ q ≡ p)
λ q → (cong (sym q ∙_) (isCommΩK-based 2 x p _) ∙∙ assoc _ _ _ ∙∙ cong (_∙ p) (lCancel q))
∙ sym (lUnit p)
Iso.leftInv S1→K2≡K2×K1' a i base = P.rUnitK _ (a base) i
Iso.leftInv S1→K2≡K2×K1' a i (loop j) = loop-helper i j
where
loop-helper : PathP (λ i → P.rUnitK _ (a base) i ≡ P.rUnitK _ (a base) i)
(cong (a base +K_) (Kn→ΩKn+1 1 (ΩKn+1→Kn 1 ((sym (P.rCancelK 2 (a base))
∙∙ (λ i → a (loop i) -K (a (base)))
∙∙ P.rCancelK 2 (a base))))))
(cong a loop)
loop-helper i j =
hcomp (λ k → λ { (i = i0) → (G (doubleCompPath-elim'
(sym rP) (λ i₁ → a (loop i₁) -K a base) rP (~ k))) j
; (i = i1) → cong a loop j
; (j = i0) → P.rUnitK 2 (a base) i
; (j = i1) → P.rUnitK 2 (a base) i})
(loop-helper2 i j)
where
F : typ (Ω (coHomK-ptd 2)) → a base +K snd (coHomK-ptd 2) ≡ a base +K snd (coHomK-ptd 2)
F = cong (_+K_ {n = 2} (a base))
G : 0ₖ 2 ≡ 0ₖ 2 → a base +K snd (coHomK-ptd 2) ≡ a base +K snd (coHomK-ptd 2)
G p = F (Kn→ΩKn+1 1 (ΩKn+1→Kn 1 p))
rP : P.+K 2 (a base) (P.-K 2 (a base)) ≡ 0ₖ 2
rP = P.rCancelK 2 (a base)
lem : (x : coHomK 2) (p : x ≡ x) (q : 0₂ ≡ x)
→ Kn→ΩKn+1 1 (ΩKn+1→Kn 1 (q ∙ p ∙ sym q)) ≡ q ∙ p ∙ sym q
lem x p q = Iso.rightInv (Iso-Kn-ΩKn+1 1) (q ∙ p ∙ sym q)
subtr-lem : (a b : hLevelTrunc 4 (S₊ 2)) → a +K (b -K a) ≡ b
subtr-lem a b = P.commK 2 a (b -K a) ∙ P.-+cancelK 2 b a
subtr-lem-coher : PathP (λ i → subtr-lem (a base) (a base) i ≡ subtr-lem (a base) (a base) i)
(cong (a base +K_) (λ i₁ → a (loop i₁) -K a base))
λ i → a (loop i)
subtr-lem-coher i j = subtr-lem (a base) (a (loop j)) i
abstract
helperFun2 : {A : Type₀} {0A a b : A} (main : 0A ≡ 0A) (start : b ≡ b) (p : a ≡ a) (q : a ≡ b) (r : b ≡ 0A) (Q : a ≡ 0A)
(R : PathP (λ i → Q i ≡ Q i) p main)
→ start ≡ sym q ∙ p ∙ q
→ isComm∙ (A , 0A)
→ sym r ∙ start ∙ r ≡ main
helperFun2 main start p q r Q R startId comm =
sym r ∙ start ∙ r ≡[ i ]⟨ sym r ∙ startId i ∙ r ⟩
sym r ∙ (sym q ∙ p ∙ q) ∙ r ≡[ i ]⟨ sym r ∙ assoc (sym q) (p ∙ q) r (~ i) ⟩
sym r ∙ sym q ∙ (p ∙ q) ∙ r ≡[ i ]⟨ sym r ∙ sym q ∙ assoc p q r (~ i) ⟩
sym r ∙ sym q ∙ p ∙ q ∙ r ≡[ i ]⟨ assoc (sym r) (rUnit (sym q) i) (p ∙ lUnit (q ∙ r) i) i ⟩
(sym r ∙ sym q ∙ refl) ∙ p ∙ refl ∙ q ∙ r ≡[ i ]⟨ (sym r ∙ sym q ∙ λ j → Q (i ∧ j)) ∙ R i ∙ (λ j → Q ( i ∧ (~ j))) ∙ q ∙ r ⟩
(sym r ∙ sym q ∙ Q) ∙ main ∙ sym Q ∙ q ∙ r ≡[ i ]⟨ (sym r ∙ sym q ∙ Q) ∙ main ∙ sym Q ∙ symDistr (sym r) (sym q) (~ i) ⟩
(sym r ∙ sym q ∙ Q) ∙ main ∙ sym Q ∙ sym (sym r ∙ sym q) ≡[ i ]⟨ (assoc (sym r) (sym q) Q i) ∙ main ∙ symDistr (sym r ∙ sym q) Q (~ i) ⟩
((sym r ∙ sym q) ∙ Q) ∙ main ∙ sym ((sym r ∙ sym q) ∙ Q) ≡[ i ]⟨ ((sym r ∙ sym q) ∙ Q) ∙ comm main (sym ((sym r ∙ sym q) ∙ Q)) i ⟩
((sym r ∙ sym q) ∙ Q) ∙ sym ((sym r ∙ sym q) ∙ Q) ∙ main ≡⟨ assoc ((sym r ∙ sym q) ∙ Q) (sym ((sym r ∙ sym q) ∙ Q)) main ⟩
(((sym r ∙ sym q) ∙ Q) ∙ sym ((sym r ∙ sym q) ∙ Q)) ∙ main ≡[ i ]⟨ rCancel (((sym r ∙ sym q) ∙ Q)) i ∙ main ⟩
refl ∙ main ≡⟨ sym (lUnit main) ⟩
main ∎
congFunct₃ : ∀ {A B : Type₀} {a b c d : A} (f : A → B) (p : a ≡ b) (q : b ≡ c) (r : c ≡ d)
→ cong f (p ∙ q ∙ r) ≡ cong f p ∙ cong f q ∙ cong f r
congFunct₃ f p q r = congFunct f p (q ∙ r) ∙ cong (cong f p ∙_) (congFunct f q r)
lem₀ : G (sym rP ∙ (λ i₁ → a (loop i₁) -K a base) ∙ rP)
≡ F (sym rP ∙ (λ i₁ → a (loop i₁) -K a base) ∙ rP)
lem₀ = cong F (lem (a base -K (a base))
(λ i₁ → a (loop i₁) -K a base)
(sym (P.rCancelK 2 (a base))))
lem₁ : G (sym rP ∙ (λ i₁ → a (loop i₁) -K a base) ∙ rP)
≡ sym (λ i₁ → a base +K P.rCancelK 2 (a base) i₁) ∙
cong (a base +K_) (λ i₁ → a (loop i₁) -K a base) ∙
(λ i₁ → a base +K P.rCancelK 2 (a base) i₁)
lem₁ = lem₀ ∙ congFunct₃ (a base +K_) (sym rP)
(λ i₁ → a (loop i₁) -K a base)
rP
loop-helper2 : PathP (λ i → P.rUnitK _ (a base) i ≡ P.rUnitK _ (a base) i)
(cong (a base +K_) (Kn→ΩKn+1 1 (ΩKn+1→Kn 1 ((sym (P.rCancelK 2 (a base))
∙ (λ i → a (loop i) -K (a (base)))
∙ P.rCancelK 2 (a base))))))
(cong a loop)
loop-helper2 = compPathL→PathP (helperFun2 (cong a loop) _ _
(cong (a base +K_) (P.rCancelK 2 (a base))) _ _
subtr-lem-coher
lem₁
(isCommΩK-based 2 (a base)))
S1→K2≡K2×K1 : Iso (S₊ 1 → coHomK 2) (coHomK 2 × coHomK 1)
S1→K2≡K2×K1 = S1→K2≡K2×K1' unlock
| {
"alphanum_fraction": 0.4297649116,
"avg_line_length": 54.9501779359,
"ext": "agda",
"hexsha": "e3711a2590d307d34e32a57b31afe0f6d3dbd392",
"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": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/Groups/Prelims.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"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": "L-TChen/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/Groups/Prelims.agda",
"max_line_length": 156,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/Groups/Prelims.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5885,
"size": 15441
} |
module Everything where
import Algebra.Structures.Field
import Algebra.Structures.Bundles.Field
import Algebra.Linear.Core
import Algebra.Linear.Space
import Algebra.Linear.Space.Hom
import Algebra.Linear.Space.Product
import Algebra.Linear.Space.FiniteDimensional
import Algebra.Linear.Space.FiniteDimensional.Hom
import Algebra.Linear.Space.FiniteDimensional.Product
import Algebra.Linear.Construct
import Algebra.Linear.Construct.Vector
import Algebra.Linear.Construct.Matrix
import Algebra.Linear.Morphism
import Algebra.Linear.Morphism.Definitions
import Algebra.Linear.Morphism.VectorSpace
import Algebra.Linear.Morphism.Bundles
import Algebra.Linear.Morphism.Bundles.VectorSpace
import Algebra.Linear.Structures
import Algebra.Linear.Structures.VectorSpace
import Algebra.Linear.Structures.FiniteDimensional
import Algebra.Linear.Structures.Bundles
import Algebra.Linear.Structures.Bundles.FiniteDimensional
| {
"alphanum_fraction": 0.8729641694,
"avg_line_length": 30.7,
"ext": "agda",
"hexsha": "d74a356d2d22cbb83a59df2f69296dd0a4a22127",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "felko/linear-algebra",
"max_forks_repo_path": "Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "felko/linear-algebra",
"max_issues_repo_path": "Everything.agda",
"max_line_length": 58,
"max_stars_count": 15,
"max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "felko/linear-algebra",
"max_stars_repo_path": "Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z",
"num_tokens": 176,
"size": 921
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointwise lifting of relations to maybes
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Maybe.Relation.Binary.Pointwise where
open import Level
open import Data.Maybe.Base using (Maybe; just; nothing)
open import Function.Equivalence using (_⇔_; equivalence)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
------------------------------------------------------------------------
-- Definition
data Pointwise
{a b ℓ} {A : Set a} {B : Set b}
(R : REL A B ℓ) : REL (Maybe A) (Maybe B) (a ⊔ b ⊔ ℓ) where
just : ∀ {x y} → R x y → Pointwise R (just x) (just y)
nothing : Pointwise R nothing nothing
------------------------------------------------------------------------
-- Properties
module _ {a b ℓ} {A : Set a} {B : Set b} {R : REL A B ℓ} where
drop-just : ∀ {x y} → Pointwise R (just x) (just y) → R x y
drop-just (just p) = p
just-equivalence : ∀ {x y} → R x y ⇔ Pointwise R (just x) (just y)
just-equivalence = equivalence just drop-just
------------------------------------------------------------------------
-- Relational properties
module _ {a r} {A : Set a} {R : Rel A r} where
refl : Reflexive R → Reflexive (Pointwise R)
refl R-refl {just _} = just R-refl
refl R-refl {nothing} = nothing
reflexive : _≡_ ⇒ R → _≡_ ⇒ Pointwise R
reflexive reflexive P.refl = refl (reflexive P.refl)
module _ {a b r₁ r₂} {A : Set a} {B : Set b}
{R : REL A B r₁} {S : REL B A r₂} where
sym : Sym R S → Sym (Pointwise R) (Pointwise S)
sym R-sym (just p) = just (R-sym p)
sym R-sym nothing = nothing
module _ {a b c r₁ r₂ r₃} {A : Set a} {B : Set b} {C : Set c}
{R : REL A B r₁} {S : REL B C r₂} {T : REL A C r₃} where
trans : Trans R S T → Trans (Pointwise R) (Pointwise S) (Pointwise T)
trans R-trans (just p) (just q) = just (R-trans p q)
trans R-trans nothing nothing = nothing
module _ {a r} {A : Set a} {R : Rel A r} where
dec : Decidable R → Decidable (Pointwise R)
dec R-dec (just x) (just y) = Dec.map just-equivalence (R-dec x y)
dec R-dec (just x) nothing = no (λ ())
dec R-dec nothing (just y) = no (λ ())
dec R-dec nothing nothing = yes nothing
isEquivalence : IsEquivalence R → IsEquivalence (Pointwise R)
isEquivalence R-isEquivalence = record
{ refl = refl R.refl
; sym = sym R.sym
; trans = trans R.trans
} where module R = IsEquivalence R-isEquivalence
isDecEquivalence : IsDecEquivalence R → IsDecEquivalence (Pointwise R)
isDecEquivalence R-isDecEquivalence = record
{ isEquivalence = isEquivalence R.isEquivalence
; _≟_ = dec R._≟_
} where module R = IsDecEquivalence R-isDecEquivalence
module _ {c ℓ} where
setoid : Setoid c ℓ → Setoid c (c ⊔ ℓ)
setoid S = record
{ isEquivalence = isEquivalence S.isEquivalence
} where module S = Setoid S
decSetoid : DecSetoid c ℓ → DecSetoid c (c ⊔ ℓ)
decSetoid S = record
{ isDecEquivalence = isDecEquivalence S.isDecEquivalence
} where module S = DecSetoid S
| {
"alphanum_fraction": 0.5754257908,
"avg_line_length": 33.8969072165,
"ext": "agda",
"hexsha": "fbb818299e981749aaaf394300a7e19a216d6686",
"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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.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/Maybe/Relation/Binary/Pointwise.agda",
"max_line_length": 72,
"max_stars_count": 5,
"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/Maybe/Relation/Binary/Pointwise.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": 998,
"size": 3288
} |
module _ where
open import Agda.Builtin.Equality
postulate
A : Set
P : A → Set
data Flat (@♭ A : Set) : Set where
con : (@♭ x : A) → Flat A
-- it should not be able to unify x and y,
-- because the equality is not @♭.
test4 : (@♭ x : A) (@♭ y : A) → (x ≡ y) → P x → P y
test4 x y refl p = {!!}
| {
"alphanum_fraction": 0.5526315789,
"avg_line_length": 19,
"ext": "agda",
"hexsha": "781f02b7bb81b928f60231a839d5e2fa261393b9",
"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/FlatSplitFail.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/FlatSplitFail.agda",
"max_line_length": 51,
"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/FlatSplitFail.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": 117,
"size": 304
} |
{-# OPTIONS --without-K #-}
open import Base
module Homotopy.Pointed where
open import Integers
open import Homotopy.Truncation
open import Homotopy.Connected
record pType (i : Level) : Set (suc i) where
constructor ⋆[_,_]
field
∣_∣ : Set i -- \|
⋆ : ∣_∣ -- \*
open pType public
pType₀ : Set₁
pType₀ = pType zero
_→⋆_ : ∀ {i j} → (pType i → pType j → pType (max i j))
_→⋆_ A B = ⋆[ Σ (∣ A ∣ → ∣ B ∣) (λ f → f (⋆ A) ≡ ⋆ B), ((λ _ → ⋆ B) , refl) ]
τ⋆ : ∀ {i} → (ℕ₋₂ → pType i → pType i)
τ⋆ n ⋆[ X , x ] = ⋆[ τ n X , proj x ]
is-contr⋆ : ∀ {i} → (pType i → Set i)
is-contr⋆ ⋆[ X , x ] = is-contr X
is-connected⋆ : ∀ {i} → ℕ₋₂ → (pType i → Set i)
is-connected⋆ n ⋆[ X , x ] = is-connected n X
connected⋆-lt : ∀ {i} (k n : ℕ) (lt : k < S n) (X : pType i)
→ (is-connected⋆ ⟨ n ⟩ X → is-contr⋆ (τ⋆ ⟨ k ⟩ X))
connected⋆-lt .n n <n X p = p
connected⋆-lt k O (<S ()) X p
connected⋆-lt k (S n) (<S lt) X p =
connected⋆-lt k n lt X (connected-S-is-connected ⟨ n ⟩ p)
_≃⋆_ : ∀ {i j} → (pType i → pType j → Set (max i j))
⋆[ X , x ] ≃⋆ ⋆[ Y , y ] = Σ (X ≃ Y) (λ f → π₁ f x ≡ y)
id-equiv⋆ : ∀ {i} (X : pType i) → X ≃⋆ X
id-equiv⋆ ⋆[ X , x ] = (id-equiv X , refl)
equiv-compose⋆ : ∀ {i j k} {A : pType i} {B : pType j} {C : pType k}
→ (A ≃⋆ B → B ≃⋆ C → A ≃⋆ C)
equiv-compose⋆ (f , pf) (g , pg) = (equiv-compose f g , (ap (π₁ g) pf ∘ pg))
pType-eq-raw : ∀ {i} {X Y : pType i} (p : ∣ X ∣ ≡ ∣ Y ∣)
(q : transport (λ X → X) p (⋆ X) ≡ ⋆ Y) → X ≡ Y
pType-eq-raw {i} {⋆[ X , x ]} {⋆[ .X , .x ]} refl refl = refl
pType-eq : ∀ {i} {X Y : pType i} → (X ≃⋆ Y → X ≡ Y)
pType-eq (e , p) = pType-eq-raw (eq-to-path e) (trans-id-eq-to-path e _ ∘ p)
| {
"alphanum_fraction": 0.490942029,
"avg_line_length": 29.5714285714,
"ext": "agda",
"hexsha": "1fccbff47b622ed659cb13c9c9a560bd34569427",
"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/Pointed.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/Pointed.agda",
"max_line_length": 77,
"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/Homotopy/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": 851,
"size": 1656
} |
{-# OPTIONS --cubical --safe #-}
module Algebra.Construct.Free.Semilattice.Definition where
open import Prelude
infixr 5 _∷_
data 𝒦 (A : Type a) : Type a where
[] : 𝒦 A
_∷_ : A → 𝒦 A → 𝒦 A
com : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs
trunc : isSet (𝒦 A)
| {
"alphanum_fraction": 0.5442622951,
"avg_line_length": 21.7857142857,
"ext": "agda",
"hexsha": "b347a91d20e971712e22e349f029fe1191b34689",
"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": "Algebra/Construct/Free/Semilattice/Definition.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": "Algebra/Construct/Free/Semilattice/Definition.agda",
"max_line_length": 58,
"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": "Algebra/Construct/Free/Semilattice/Definition.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": 137,
"size": 305
} |
{-# OPTIONS --without-K #-}
open import HoTT.Base
open import HoTT.Equivalence
module HoTT.Identity.Universe {i} {A B : 𝒰 i} where
-- Axiom 2.10.3 - univalence
postulate
idtoeqv-equiv : isequiv (idtoeqv {A = A} {B = B})
=𝒰-equiv : (A == B) ≃ (A ≃ B)
=𝒰-equiv = idtoeqv , idtoeqv-equiv
module _ where
open qinv (isequiv→qinv idtoeqv-equiv)
abstract
ua : A ≃ B → A == B
ua = g
=𝒰-η : ua ∘ idtoeqv ~ id
=𝒰-η = η
=𝒰-β : idtoeqv ∘ ua ~ id
=𝒰-β = ε
_=𝒰_ = _≃_
| {
"alphanum_fraction": 0.5807770961,
"avg_line_length": 19.56,
"ext": "agda",
"hexsha": "263911ee88276a4d9e5d195aded8395f449ebc05",
"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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "michaelforney/hott",
"max_forks_repo_path": "HoTT/Identity/Universe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "michaelforney/hott",
"max_issues_repo_path": "HoTT/Identity/Universe.agda",
"max_line_length": 51,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "michaelforney/hott",
"max_stars_repo_path": "HoTT/Identity/Universe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 224,
"size": 489
} |
module hott.types.int where
open import hott.functions
open import hott.core
import hott.types.nat as nat
open nat using (ℕ)
data ℤ : Type₀ where
zero : ℤ
+ve : ℕ → ℤ
-ve : ℕ → ℤ
fromNat : ℕ → ℤ
fromNat nat.zero = zero
fromNat (nat.succ n) = +ve n
neg : ℤ → ℤ
neg zero = zero
neg (+ve n) = -ve n
neg (-ve n) = +ve n
suc : ℤ → ℤ
suc zero = +ve 0
suc (+ve x) = +ve (nat.succ x)
suc (-ve 0) = zero
suc (-ve (nat.succ x)) = -ve x
pred : ℤ → ℤ
pred zero = -ve 0
pred (-ve x) = -ve (nat.succ x)
pred (+ve 0) = zero
pred (+ve (nat.succ x)) = +ve x
suc∘pred~id : suc ∘ pred ~ id
suc∘pred~id zero = refl
suc∘pred~id (+ve 0) = refl
suc∘pred~id (+ve (nat.succ x)) = refl
suc∘pred~id (-ve x) = refl
pred∘suc~id : pred ∘ suc ~ id
pred∘suc~id zero = refl
pred∘suc~id (+ve x) = refl
pred∘suc~id (-ve 0) = refl
pred∘suc~id (-ve (nat.succ x)) = refl
| {
"alphanum_fraction": 0.4985221675,
"avg_line_length": 19.9019607843,
"ext": "agda",
"hexsha": "4d5ec9a2b93a6697edf34ee3d1d023236100c2f3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "piyush-kurur/hott",
"max_forks_repo_path": "agda/hott/types/int.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "piyush-kurur/hott",
"max_issues_repo_path": "agda/hott/types/int.agda",
"max_line_length": 44,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "piyush-kurur/hott",
"max_stars_repo_path": "agda/hott/types/int.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 397,
"size": 1015
} |
------------------------------------------------------------------------
-- Second-order abstract syntax
--
-- Examples of the formalisation framework in use
------------------------------------------------------------------------
module Examples where
-- | Algebraic structures
-- Monoids
import Monoid.Signature
import Monoid.Syntax
import Monoid.Equality
-- Commutative monoids
import CommMonoid.Signature
import CommMonoid.Syntax
import CommMonoid.Equality
-- Groups
import Group.Signature
import Group.Syntax
import Group.Equality
-- Commutative groups
import CommGroup.Signature
import CommGroup.Syntax
import CommGroup.Equality
-- Group actions
import GroupAction.Signature
import GroupAction.Syntax
import GroupAction.Equality
-- Semirings
import Semiring.Signature
import Semiring.Syntax
import Semiring.Equality
-- Rings
import Ring.Signature
import Ring.Syntax
import Ring.Equality
-- Commutative rings
import CommRing.Signature
import CommRing.Syntax
import CommRing.Equality
-- | Logic
-- Propositional logic
import PropLog.Signature
import PropLog.Syntax
import PropLog.Equality
-- First-order logic (with example proofs)
import FOL.Signature
import FOL.Syntax
import FOL.Equality
-- | Computational calculi
-- Combinatory logic
import Combinatory.Signature
import Combinatory.Syntax
import Combinatory.Equality
-- Untyped λ-calculus
import UTLC.Signature
import UTLC.Syntax
import UTLC.Equality
-- Simply-typed λ-calculus (with operational semantics and environment model)
import STLC.Signature
import STLC.Syntax
import STLC.Equality
import STLC.Model
-- Typed λ-calculus with product and sum types, and naturals (with example derivation)
import TLC.Signature
import TLC.Syntax
import TLC.Equality
-- PCF
import PCF.Signature
import PCF.Syntax
import PCF.Equality
-- | Miscellaneous
-- Lenses
import Lens.Signature
import Lens.Syntax
import Lens.Equality
-- Inception algebras
import Inception.Signature
import Inception.Syntax
import Inception.Equality
-- Substitution algebras
import Sub.Signature
import Sub.Syntax
import Sub.Equality
-- Partial differentiation (with some example proofs)
import PDiff.Signature
import PDiff.Syntax
import PDiff.Equality
| {
"alphanum_fraction": 0.762380736,
"avg_line_length": 18.974137931,
"ext": "agda",
"hexsha": "024711177c6a9655ab3507d16cfa804fed862f19",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Examples.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Examples.agda",
"max_line_length": 86,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Examples.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": 495,
"size": 2201
} |
{-# OPTIONS --without-K --safe #-}
module Experiment.Zero where
open import Level using (_⊔_)
-- Empty type
data ⊥ : Set where
-- Unit type
record ⊤ : Set where
constructor tt
-- Boolean
data Bool : Set where
true false : Bool
-- Natural number
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
-- Propositional Equality
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
-- Sum type
data _⊎_ {a} {b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
-- Dependent Product type
record Σ {a} {b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
fst : A
snd : B fst
-- Induction
⊤-ind : ∀ {p} {P : ⊤ → Set p} → P tt → ∀ x → P x
⊤-ind P⊤ tt = P⊤
⊥-ind : ∀ {p} {P : ⊥ → Set p} → ∀ x → P x
⊥-ind ()
Bool-ind : ∀ {p} {P : Bool → Set p} → P true → P false → ∀ x → P x
Bool-ind t e true = t
Bool-ind t e false = e
ℕ-ind : ∀ {p} {P : ℕ → Set p} → P zero → (∀ m → P m → P (suc m)) → ∀ n → P n
ℕ-ind P0 Ps zero = P0
ℕ-ind P0 Ps (suc n) = Ps n (ℕ-ind P0 Ps n)
≡-ind : ∀ {a p} {A : Set a}
(P : (x y : A) → x ≡ y → Set p) →
(∀ x → P x x refl) →
∀ x y (eq : x ≡ y) → P x y eq
≡-ind P Pr x .x refl = Pr x
⊎-ind : ∀ {a b p} {A : Set a} {B : Set b} {P : A ⊎ B → Set p} →
(∀ x → P (inj₁ x)) → (∀ y → P (inj₂ y)) → ∀ s → P s
⊎-ind i1 i2 (inj₁ x) = i1 x
⊎-ind i1 i2 (inj₂ y) = i2 y
Σ-ind : ∀ {a b p} {A : Set a} {B : A → Set b} {P : Σ A B → Set p} →
(∀ x y → P (x , y)) → ∀ p → P p
Σ-ind f (x , y) = f x y
| {
"alphanum_fraction": 0.4674983585,
"avg_line_length": 22.3970588235,
"ext": "agda",
"hexsha": "15211498c51d3fdb09bda4ed4d919c6c6228a802",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Experiment/Zero.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rei1024/agda-misc",
"max_issues_repo_path": "Experiment/Zero.agda",
"max_line_length": 76,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Experiment/Zero.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 703,
"size": 1523
} |
{-# OPTIONS --without-K --safe #-}
module Dodo.Binary.Intersection where
-- Stdlib imports
open import Level using (Level; _⊔_)
open import Data.Product as P
open import Data.Product using (_×_; _,_; swap; proj₁; proj₂)
open import Relation.Binary using (REL)
-- Local imports
open import Dodo.Binary.Equality
-- # Definitions
infixl 30 _∩₂_
_∩₂_ : {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
→ REL A B ℓ₁
→ REL A B ℓ₂
→ REL A B (ℓ₁ ⊔ ℓ₂)
_∩₂_ P Q x y = P x y × Q x y
-- # Properties
module _ {a b ℓ : Level} {A : Set a} {B : Set b} {R : REL A B ℓ} where
∩₂-idem : (R ∩₂ R) ⇔₂ R
∩₂-idem = ⇔: ⊆-proof ⊇-proof
where
⊆-proof : (R ∩₂ R) ⊆₂' R
⊆-proof _ _ = proj₁
⊇-proof : R ⊆₂' (R ∩₂ R)
⊇-proof _ _ Rxy = (Rxy , Rxy)
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
∩₂-comm : (P ∩₂ Q) ⇔₂ (Q ∩₂ P)
∩₂-comm = ⇔: (λ _ _ → swap) (λ _ _ → swap)
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-assoc : P ∩₂ (Q ∩₂ R) ⇔₂ (P ∩₂ Q) ∩₂ R
∩₂-assoc = ⇔: ⊆-proof ⊇-proof
where
⊆-proof : P ∩₂ (Q ∩₂ R) ⊆₂' (P ∩₂ Q) ∩₂ R
⊆-proof _ _ (Pxy , (Qxy , Rxy)) = ((Pxy , Qxy) , Rxy)
⊇-proof : (P ∩₂ Q) ∩₂ R ⊆₂' P ∩₂ (Q ∩₂ R)
⊇-proof _ _ ((Pxy , Qxy) , Rxy) = (Pxy , (Qxy , Rxy))
-- # Operations
-- ## Operations: ⊆₂
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-combine-⊆₂ : P ⊆₂ Q → P ⊆₂ R → P ⊆₂ (Q ∩₂ R)
∩₂-combine-⊆₂ (⊆: P⊆Q) (⊆: P⊆R) = ⊆: (λ x y Pxy → (P⊆Q x y Pxy , P⊆R x y Pxy))
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
∩₂-introˡ-⊆₂ : (P ∩₂ Q) ⊆₂ Q
∩₂-introˡ-⊆₂ = ⊆: λ _ _ → proj₂
∩₂-introʳ-⊆₂ : (P ∩₂ Q) ⊆₂ P
∩₂-introʳ-⊆₂ = ⊆: λ _ _ → proj₁
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-elimˡ-⊆₂ : P ⊆₂ (Q ∩₂ R) → P ⊆₂ R
∩₂-elimˡ-⊆₂ (⊆: P⊆[Q∩R]) = ⊆: (λ x y Pxy → proj₂ (P⊆[Q∩R] x y Pxy))
∩₂-elimʳ-⊆₂ : P ⊆₂ (Q ∩₂ R) → P ⊆₂ Q
∩₂-elimʳ-⊆₂ (⊆: P⊆[Q∩R]) = ⊆: (λ x y Pxy → proj₁ (P⊆[Q∩R] x y Pxy))
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-substˡ-⊆₂ : P ⊆₂ Q → (P ∩₂ R) ⊆₂ (Q ∩₂ R)
∩₂-substˡ-⊆₂ (⊆: P⊆Q) = ⊆: (λ x y → P.map₁ (P⊆Q x y))
∩₂-substʳ-⊆₂ : P ⊆₂ Q → (R ∩₂ P) ⊆₂ (R ∩₂ Q)
∩₂-substʳ-⊆₂ (⊆: P⊆Q) = ⊆: (λ x y → P.map₂ (P⊆Q x y))
-- ## Operations: ⇔₂
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-substˡ : P ⇔₂ Q → (P ∩₂ R) ⇔₂ (Q ∩₂ R)
∩₂-substˡ = ⇔₂-compose ∩₂-substˡ-⊆₂ ∩₂-substˡ-⊆₂
∩₂-substʳ : P ⇔₂ Q → (R ∩₂ P) ⇔₂ (R ∩₂ Q)
∩₂-substʳ = ⇔₂-compose ∩₂-substʳ-⊆₂ ∩₂-substʳ-⊆₂
| {
"alphanum_fraction": 0.4826388889,
"avg_line_length": 26.6666666667,
"ext": "agda",
"hexsha": "2e865f5cd9acf803096cfd59165c026e7fd0db7a",
"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": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "sourcedennis/agda-dodo",
"max_forks_repo_path": "src/Dodo/Binary/Intersection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"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": "sourcedennis/agda-dodo",
"max_issues_repo_path": "src/Dodo/Binary/Intersection.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "sourcedennis/agda-dodo",
"max_stars_repo_path": "src/Dodo/Binary/Intersection.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1663,
"size": 2880
} |
-- Andreas, 2015-12-10, issue reported by Andrea Vezzosi
open import Common.Equality
open import Common.Bool
id : Bool → Bool
id true = true
id false = false
is-id : ∀ x → x ≡ id x
is-id true = refl
is-id false = refl
postulate
P : Bool → Set
b : Bool
p : P (id b)
proof : P b
proof rewrite is-id b = p
| {
"alphanum_fraction": 0.6487341772,
"avg_line_length": 15.0476190476,
"ext": "agda",
"hexsha": "478dc932ec6e61f96c2ecca03135ebf691c10ea2",
"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/Issue520.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/Issue520.agda",
"max_line_length": 56,
"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/Issue520.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": 109,
"size": 316
} |
module Selective where
open import Prelude.Equality
open import Agda.Builtin.TrustMe
-----------------------------------------------------------------
-- id : ∀ {a} {A : Set a} → A → A
-- id x = x
id : ∀ {A : Set} → A → A
id x = x
{-# INLINE id #-}
infixl -10 id
syntax id {A = A} x = x ofType A
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x _ = x
{-# INLINE const #-}
flip : ∀ {a b c} {A : Set a} {B : Set b} {C : A → B → Set c} →
(∀ x y → C x y) → ∀ y x → C x y
flip f x y = f y x
{-# INLINE flip #-}
infixr 9 _∘_
_∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ x → B x → Set c}
(f : ∀ {x} (y : B x) → C x y) (g : ∀ x → B x) →
∀ x → C x (g x)
(f ∘ g) x = f (g x)
{-# INLINE _∘_ #-}
infixr -20 _$_
_$_ : ∀ {a b} {A : Set a} {B : A → Set b} → (∀ x → B x) → ∀ x → B x
f $ x = f x
------------------------------------------------------------------
data Either (A : Set) (B : Set) : Set where
left : A → Either A B
right : B → Either A B
either : ∀ {A : Set} {B : Set} {C : Set} →
(A → C) → (B → C) → Either A B → C
either f g (left x) = f x
either f g (right x) = g x
data Pair (a b : Set) : Set where
_×_ : a → b → Pair a b
------------------------------------------------------------------
record Functor (F : Set → Set) : Set₁ where
infixl 5 _<$>_
field
fmap : ∀ {A B} → (A → B) → F A → F B
-- Functor laws
fmap-id : ∀ {A} {x : F A} → fmap id x ≡ id x
fmap-compose : ∀ {A B C} {f : A → B} {g : B → C} {x : F A} →
fmap (g ∘ f) x ≡ (fmap g ∘ fmap f) x
_<$>_ = fmap
open Functor {{...}} public
instance
FunctorFunction : {X : Set} → Functor (λ Y → (X → Y))
fmap {{FunctorFunction}} f g = λ x → (f ∘ g) x
fmap-id {{FunctorFunction}} = refl
fmap-compose {{FunctorFunction}} = refl
record Applicative (F : Set → Set) : Set₁ where
infixl 5 _<*>_ _<*_ _*>_
field
overlap {{functor}} : Functor F
pure : ∀ {A} → A → F A
_<*>_ : ∀ {A B} → F (A → B) → F A → F B
-- Applicative laws
ap-identity : ∀ {A B} {f : F (A → B)} → (pure id <*> f) ≡ f
ap-homomorphism : ∀ {A B} {x : A} {f : A → B} →
pure f <*> pure x ≡ pure (f x)
ap-interchange : ∀ {A B} {x : A} {f : F (A → B)} →
f <*> pure x ≡ pure (_$ x) <*> f
-- ap-composition : ∀ {A B C} {x : F A} {f : F (A → B)} {g : F (B → C)} →
-- (pure (_∘_) <*> g <*> f <*> x) ≡ (g <*> (f <*> x))
fmap-pure-ap : ∀ {A B} {x : F A} {f : A → B} →
f <$> x ≡ pure f <*> x
_<*_ : ∀ {A B} → F A → F B → F A
a <* b = ⦇ const a b ⦈
_*>_ : ∀ {A B} → F A → F B → F B
a *> b = ⦇ (const id) a b ⦈
open Applicative {{...}} public
instance
ApplicativeFunction : {X : Set} → Applicative (λ Y → (X → Y))
pure {{ApplicativeFunction}} f = const f
_<*>_ {{ApplicativeFunction}} f g = λ x → f x (g x)
-- Applicative laws
ap-identity {{ApplicativeFunction}} = refl
ap-homomorphism {{ApplicativeFunction}} = refl
ap-interchange {{ApplicativeFunction}} = refl
fmap-pure-ap {{ApplicativeFunction}} {_} {_} {x} {f} = primTrustMe
-- f <$> x -- f <$> x
-- ≡⟨ {!!} ⟩
-- pure f <*> x
-- ∎
record Bifunctor (P : Set → Set → Set) : Set₁ where
field
bimap : ∀ {A B C D} → (A → B) → (C → D) → P A C → P B D
first : ∀ {A B C} → (A -> B) -> P A C -> P B C
second : ∀ {A B C} → (B -> C) -> P A B -> P A C
open Bifunctor {{...}} public
instance
BifunctorEither : Bifunctor Either
bimap {{BifunctorEither}} f _ (left a) = left (f a)
bimap {{BifunctorEither}} _ g (right b) = right (g b)
first {{BifunctorEither}} f = bimap f id
second {{BifunctorEither}} = bimap id
record Selective (F : Set → Set) : Set₁ where
field
overlap {{applicative}} : Applicative F
handle : ∀ {A B} → F (Either A B) → F (A → B) → F B
-- Laws:
-- (F1) Apply a pure function to the result:
f1 : ∀ {A B C} {f : B → C} {x : F (Either A B)} {y : F (A → B)} →
(f <$> (handle x y)) ≡ handle (second f <$> x) ((f ∘_) <$> y)
-- (F2) Apply a pure function to the left (error) branch:
f2 : ∀ {A B C} {f : A -> C} {x : F (Either A B)} {y : F (C → B)} →
handle (first f <$> x) y ≡ handle x ((_∘ f) <$> y)
-- (F3) Apply a pure function to the handler:
f3 : ∀ {A B C} {f : C → A → B} {x : F (Either A B)} {y : F C} →
(handle x (f <$> y)) ≡ handle (first (flip f) <$> x) (flip (_$_) <$> y)
-- (P1) Apply a pure handler:
p1 : ∀ {A B} {x : F (Either A B)} {y : A → B} →
handle x (pure y) ≡ (either y id <$> x)
-- (P2) Handle a pure error:
p2 : ∀ {A B} {x : A} {y : F (A → B)} →
handle (pure (left x)) y ≡ ((_$ x) <$> y)
-- -- (A1) Associativity
-- a1 : ∀ {A B C} {x : F (Either A B)}
-- {y : F (Either C (A → B))}
-- {z : F (C → A → B)} →
-- handle x (handle y z) ≡
-- handle (handle ((λ x → right x) <$> x) (λ a → bimap (λ x → (x × a)) (_$ a) y))
-- A1: handle x (handle y z) = handle (handle (f <$> x) (g <$> y)) (h <$> z)
-- where f x = Right <$> x
-- g y = \a -> bimap (,a) ($a) y
-- h z = uncurry z
-- a1 :: Selective f => f (Either a b) -> f (Either c (a -> b)) -> f (c -> a -> b) -> f b
-- a1 x y z = handle x (handle y z) === handle (handle (f <$> x) (g <$> y)) (h <$> z)
-- where
-- f x = Right <$> x
-- g y = \a -> bimap (,a) ($a) y
-- h z = uncurry z
open Selective {{...}} public
-- | 'Selective' is more powerful than 'Applicative': we can recover the
-- application operator '<*>'. In particular, the following 'Applicative' laws
-- hold when expressed using 'apS':
--
-- * Identity : pure id <*> v = v
-- * Homomorphism : pure f <*> pure x = pure (f x)
-- * Interchange : u <*> pure y = pure ($y) <*> u
-- * Composition : (.) <$> u <*> v <*> w = u <*> (v <*> w)
apS : ∀ {A B : Set} {F : Set → Set} {{_ : Selective F}} →
F (A → B) → F A → F B
apS f x = handle (left <$> f) (flip (_$_) <$> x)
---------------------------------------------------------------------
| {
"alphanum_fraction": 0.4336835194,
"avg_line_length": 32.4042553191,
"ext": "agda",
"hexsha": "679fbda37c4875d2e57ad788d041c35f0cf40a00",
"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": "4af28af701b65b45900bba2d92a526ce44a3be63",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tuura/selective-theory-agda",
"max_forks_repo_path": "src/Selective.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63",
"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": "tuura/selective-theory-agda",
"max_issues_repo_path": "src/Selective.agda",
"max_line_length": 90,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tuura/selective-theory-agda",
"max_stars_repo_path": "src/Selective.agda",
"max_stars_repo_stars_event_max_datetime": "2020-06-22T12:31:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-11T14:42:19.000Z",
"num_tokens": 2301,
"size": 6092
} |
module SizedIO.ConsoleObject where
open import Size
open import SizedIO.Console
open import SizedIO.Object
open import SizedIO.IOObject
-- A console object is an IO object for the IO interface of console
ConsoleObject : (i : Size) → (iface : Interface) → Set
ConsoleObject i iface = IOObject consoleI iface i
| {
"alphanum_fraction": 0.7753164557,
"avg_line_length": 22.5714285714,
"ext": "agda",
"hexsha": "2361a0c96969340cb498a86dbc385c823a478277",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "src/SizedIO/ConsoleObject.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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": "agda/ooAgda",
"max_issues_repo_path": "src/SizedIO/ConsoleObject.agda",
"max_line_length": 68,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "src/SizedIO/ConsoleObject.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 76,
"size": 316
} |
module Acc where
data Rel(A : Set) : Set1 where
rel : (A -> A -> Set) -> Rel A
_is_than_ : {A : Set} -> A -> Rel A -> A -> Set
x is rel f than y = f x y
data Acc {A : Set} (less : Rel A) (x : A) : Set where
acc : ((y : A) -> x is less than y -> Acc less y) -> Acc less x
data WO {A : Set} (less : Rel A) : Set where
wo : ((x : A) -> Acc less x) -> WO less
data False : Set where
data True : Set where
tt : True
data Nat : Set where
Z : Nat
S : Nat -> Nat
data ∏ {A : Set} (f : A -> Set) : Set where
∏I : ((z : A) -> f z) -> ∏ f
data Ord : Set where
z : Ord
lim : (Nat -> Ord) -> Ord
zp : Ord -> Ord
zp z = z
zp (lim f) = lim (\x -> zp (f x))
_<_ : Ord -> Ord -> Set
z < _ = True
lim _ < z = False
lim f < lim g = ∏ \(n : Nat) -> f n < g n
ltNat : Nat -> Nat -> Set
ltNat Z Z = False
ltNat Z (S n) = True
ltNat (S m) (S n) = ltNat m n
ltNat (S m) Z = False
ltNatRel : Rel Nat
ltNatRel = rel ltNat
postulate woltNat : WO ltNatRel
| {
"alphanum_fraction": 0.5222797927,
"avg_line_length": 18.5576923077,
"ext": "agda",
"hexsha": "ef0d111c0f92b5241460c7533b2ec51566eb6e6d",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/Termination/Acc.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/Termination/Acc.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/Termination/Acc.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": 387,
"size": 965
} |
{-# OPTIONS --cumulativity #-}
open import Agda.Builtin.Equality
mutual
X : Set
X = _
Y : Set₁
Y = Set
test : _≡_ {A = Set₁} X Y
test = refl
| {
"alphanum_fraction": 0.5732484076,
"avg_line_length": 11.2142857143,
"ext": "agda",
"hexsha": "56fc09d6c554e24cb1021773835fd84f6f4d09a8",
"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/Cumulativity-bad-meta-solution2.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/Cumulativity-bad-meta-solution2.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Cumulativity-bad-meta-solution2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 60,
"size": 157
} |
------------------------------------------------------------------------
-- Potentially cyclic precedence graphs
------------------------------------------------------------------------
module Mixfix.Cyclic.PrecedenceGraph where
open import Data.Fin using (Fin)
open import Data.Nat using (ℕ)
open import Data.Vec as Vec using (allFin)
open import Data.List using (List)
open import Data.Product using (∃)
open import Mixfix.Fixity
open import Mixfix.Operator
open import Mixfix.Expr hiding (module PrecedenceGraph)
-- Precedence graphs are represented by the number of precedence
-- levels, plus functions mapping node identifiers (precedences) to
-- node contents and successor precedences.
record PrecedenceGraph : Set where
field
-- The number of precedence levels.
levels : ℕ
-- Precedence levels.
Precedence : Set
Precedence = Fin levels
field
-- The precedence level's operators.
ops : Precedence → (fix : Fixity) → List (∃ (Operator fix))
-- The immediate successors of the precedence level.
↑ : Precedence → List Precedence
-- All precedence levels.
anyPrecedence : List Precedence
anyPrecedence = Vec.toList (allFin levels)
-- Potentially cyclic precedence graphs.
cyclic : PrecedenceGraphInterface
cyclic = record
{ PrecedenceGraph = PrecedenceGraph
; Precedence = PrecedenceGraph.Precedence
; ops = PrecedenceGraph.ops
; ↑ = PrecedenceGraph.↑
; anyPrecedence = PrecedenceGraph.anyPrecedence
}
| {
"alphanum_fraction": 0.6588940706,
"avg_line_length": 29.431372549,
"ext": "agda",
"hexsha": "ac039581a6fad6f15934984e45ccfa7ae0655c13",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "Mixfix/Cyclic/PrecedenceGraph.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "Mixfix/Cyclic/PrecedenceGraph.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yurrriq/parser-combinators",
"max_stars_repo_path": "Mixfix/Cyclic/PrecedenceGraph.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z",
"num_tokens": 352,
"size": 1501
} |
------------------------------------------------------------------------
-- This module establishes that the recognisers are as expressive as
-- possible when the alphabet is Bool (this could be generalised to
-- arbitrary finite alphabets), whereas this is not the case when the
-- alphabet is ℕ
------------------------------------------------------------------------
module TotalRecognisers.LeftRecursion.ExpressiveStrength where
open import Algebra
open import Codata.Musical.Notation
open import Data.Bool as Bool hiding (_∧_)
open import Data.Empty
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence
using (_⇔_; equivalence; module Equivalence)
open import Data.List
import Data.List.Properties as ListProp
open import Data.List.Reverse
open import Data.Nat as Nat
open import Data.Nat.InfinitelyOften as Inf
import Data.Nat.Properties as NatProp
open import Data.Product
open import Data.Sum
open import Relation.Binary
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Negation
private
module ListMonoid {A : Set} = Monoid (ListProp.++-monoid A)
module NatOrder = DecTotalOrder NatProp.≤-decTotalOrder
import TotalRecognisers.LeftRecursion
open TotalRecognisers.LeftRecursion Bool using (_∧_; left-zero)
private
open module LR {Tok : Set} = TotalRecognisers.LeftRecursion Tok
hiding (P; ∞⟨_⟩P; _∧_; left-zero; _∷_)
P : Set → Bool → Set
P Tok = LR.P {Tok}
∞⟨_⟩P : Bool → Set → Bool → Set
∞⟨ b ⟩P Tok n = LR.∞⟨_⟩P {Tok} b n
open import TotalRecognisers.LeftRecursion.Lib Bool hiding (_∷_)
------------------------------------------------------------------------
-- A boring lemma
private
lemma : (f : List Bool → Bool) →
(false ∧ f [ true ] ∨ false ∧ f [ false ]) ∨ f [] ≡ f []
lemma f = cong₂ (λ b₁ b₂ → (b₁ ∨ b₂) ∨ f [])
(left-zero (f [ true ]))
(left-zero (f [ false ]))
------------------------------------------------------------------------
-- Expressive strength
-- For every grammar there is an equivalent decidable predicate.
grammar⇒pred : ∀ {Tok n} (p : P Tok n) →
∃ λ (f : List Tok → Bool) → ∀ {s} → s ∈ p ⇔ T (f s)
grammar⇒pred p =
((λ s → ⌊ s ∈? p ⌋) , λ {_} → equivalence fromWitness toWitness)
-- When the alphabet is Bool the other direction holds: for every
-- decidable predicate there is a corresponding grammar.
--
-- Note that the grammars constructed by the proof are all "infinite
-- LL(1)".
pred⇒grammar : (f : List Bool → Bool) →
∃ λ (p : P Bool (f [])) → ∀ {s} → s ∈ p ⇔ T (f s)
pred⇒grammar f =
(p f , λ {s} → equivalence (p-sound f) (p-complete f s))
where
p : (f : List Bool → Bool) → P Bool (f [])
p f = cast (lemma f)
( ♯? (sat id ) · ♯ p (f ∘ _∷_ true )
∣ ♯? (sat not) · ♯ p (f ∘ _∷_ false)
∣ accept-if-true (f [])
)
p-sound : ∀ f {s} → s ∈ p f → T (f s)
p-sound f (cast (∣-right s∈)) with AcceptIfTrue.sound (f []) s∈
... | (refl , ok) = ok
p-sound f (cast (∣-left (∣-left (t∈ · s∈)))) with drop-♭♯ (f [ true ]) t∈
... | sat {t = true} _ = p-sound (f ∘ _∷_ true ) s∈
... | sat {t = false} ()
p-sound f (cast (∣-left (∣-right (t∈ · s∈)))) with drop-♭♯ (f [ false ]) t∈
... | sat {t = false} _ = p-sound (f ∘ _∷_ false) s∈
... | sat {t = true} ()
p-complete : ∀ f s → T (f s) → s ∈ p f
p-complete f [] ok =
cast (∣-right {n₁ = false ∧ f [ true ] ∨ false ∧ f [ false ]} $
AcceptIfTrue.complete ok)
p-complete f (true ∷ bs) ok =
cast (∣-left $ ∣-left $
add-♭♯ (f [ true ]) (sat _) ·
p-complete (f ∘ _∷_ true ) bs ok)
p-complete f (false ∷ bs) ok =
cast (∣-left $ ∣-right {n₁ = false ∧ f [ true ]} $
add-♭♯ (f [ false ]) (sat _) ·
p-complete (f ∘ _∷_ false) bs ok)
-- An alternative proof which uses a left recursive definition of the
-- grammar to avoid the use of a cast.
pred⇒grammar′ : (f : List Bool → Bool) →
∃ λ (p : P Bool (f [])) → ∀ {s} → s ∈ p ⇔ T (f s)
pred⇒grammar′ f =
(p f , λ {s} → equivalence (p-sound f) (p-complete f s))
where
extend : {A B : Set} → (List A → B) → A → (List A → B)
extend f x = λ xs → f (xs ∷ʳ x)
p : (f : List Bool → Bool) → P Bool (f [])
p f = ♯ p (extend f true ) · ♯? (sat id )
∣ ♯ p (extend f false) · ♯? (sat not)
∣ accept-if-true (f [])
p-sound : ∀ f {s} → s ∈ p f → T (f s)
p-sound f (∣-right s∈) with AcceptIfTrue.sound (f []) s∈
... | (refl , ok) = ok
p-sound f (∣-left (∣-left (s∈ · t∈))) with drop-♭♯ (f [ true ]) t∈
... | sat {t = true} _ = p-sound (extend f true ) s∈
... | sat {t = false} ()
p-sound f (∣-left (∣-right (s∈ · t∈))) with drop-♭♯ (f [ false ]) t∈
... | sat {t = false} _ = p-sound (extend f false) s∈
... | sat {t = true} ()
p-complete′ : ∀ f {s} → Reverse s → T (f s) → s ∈ p f
p-complete′ f [] ok =
∣-right {n₁ = false} $ AcceptIfTrue.complete ok
p-complete′ f (bs ∶ rs ∶ʳ true ) ok =
∣-left {n₁ = false} $ ∣-left {n₁ = false} $
p-complete′ (extend f true ) rs ok ·
add-♭♯ (f [ true ]) (sat _)
p-complete′ f (bs ∶ rs ∶ʳ false) ok =
∣-left {n₁ = false} $ ∣-right {n₁ = false} $
p-complete′ (extend f false) rs ok ·
add-♭♯ (f [ false ]) (sat _)
p-complete : ∀ f s → T (f s) → s ∈ p f
p-complete f s = p-complete′ f (reverseView s)
-- If infinite alphabets are allowed the result is different: there
-- are decidable predicates which cannot be realised as grammars. The
-- proof below shows that a recogniser for natural number strings
-- cannot accept exactly the strings of the form "nn".
module NotExpressible where
-- A "pair" is a string containing two equal elements.
pair : ℕ → List ℕ
pair n = n ∷ n ∷ []
-- OnlyPairs p is inhabited iff p only accepts pairs and empty
-- strings. (Empty strings are allowed due to the presence of the
-- nonempty combinator.)
OnlyPairs : ∀ {n} → P ℕ n → Set
OnlyPairs p = ∀ {n s} → n ∷ s ∈ p → s ≡ [ n ]
-- ManyPairs p is inhabited iff p accepts infinitely many pairs.
ManyPairs : ∀ {n} → P ℕ n → Set
ManyPairs p = Inf (λ n → pair n ∈ p)
-- AcceptsNonEmptyString p is inhabited iff p accepts a non-empty
-- string.
AcceptsNonEmptyString : ∀ {Tok n} → P Tok n → Set
AcceptsNonEmptyString p = ∃₂ λ t s → t ∷ s ∈ p
-- If a recogniser does not accept any non-empty string, then it
-- either accepts the empty string or no string at all.
nullable-or-fail : ∀ {Tok n} {p : P Tok n} →
¬ AcceptsNonEmptyString p →
[] ∈ p ⊎ (∀ s → ¬ s ∈ p)
nullable-or-fail {p = p} ¬a with [] ∈? p
... | yes []∈p = inj₁ []∈p
... | no []∉p = inj₂ helper
where
helper : ∀ s → ¬ s ∈ p
helper [] = []∉p
helper (t ∷ s) = ¬a ∘ _,_ t ∘ _,_ s
-- If p₁ · p₂ accepts infinitely many pairs, and nothing but pairs
-- (or the empty string), then at most one of p₁ and p₂ accepts a
-- non-empty string. This follows because p₁ and p₂ are independent
-- of each other. For instance, if p₁ accepted n and p₂ accepted i
-- and j, then p₁ · p₂ would accept both ni and nj, and if p₁
-- accepted mm and p₂ accepted n then p₁ · p₂ would accept mmn.
at-most-one : ∀ {n₁ n₂} {p₁ : ∞⟨ n₂ ⟩P ℕ n₁} {p₂ : ∞⟨ n₁ ⟩P ℕ n₂} →
OnlyPairs (p₁ · p₂) →
ManyPairs (p₁ · p₂) →
AcceptsNonEmptyString (♭? p₁) →
AcceptsNonEmptyString (♭? p₂) → ⊥
at-most-one op mp (n₁ , s₁ , n₁s₁∈p₁) (n₂ , s₂ , n₂s₂∈p₂)
with op (n₁s₁∈p₁ · n₂s₂∈p₂)
at-most-one _ _ (_ , _ ∷ [] , _) (_ , _ , _) | ()
at-most-one _ _ (_ , _ ∷ _ ∷ _ , _) (_ , _ , _) | ()
at-most-one {p₁ = p₁} {p₂} op mp
(n , [] , n∈p₁) (.n , .[] , n∈p₂) | refl =
twoDifferentWitnesses mp helper
where
¬pair : ∀ {i s} → s ∈ p₁ · p₂ → n ≢ i → s ≢ pair i
¬pair (_·_ {s₁ = []} _ ii∈p₂) n≢i refl with op (n∈p₁ · ii∈p₂)
... | ()
¬pair (_·_ {s₁ = i ∷ []} i∈p₁ _) n≢i refl with op (i∈p₁ · n∈p₂)
¬pair (_·_ {s₁ = .n ∷ []} n∈p₁ _) n≢n refl | refl = n≢n refl
¬pair (_·_ {s₁ = i ∷ .i ∷ []} ii∈p₁ _) n≢i refl with op (ii∈p₁ · n∈p₂)
... | ()
¬pair (_·_ {s₁ = _ ∷ _ ∷ _ ∷ _} _ _) _ ()
helper : ¬ ∃₂ λ i j → i ≢ j × pair i ∈ p₁ · p₂ × pair j ∈ p₁ · p₂
helper (i , j , i≢j , ii∈ , jj∈) with Nat._≟_ n i
helper (.n , j , n≢j , nn∈ , jj∈) | yes refl = ¬pair jj∈ n≢j refl
helper (i , j , i≢j , ii∈ , jj∈) | no n≢i = ¬pair ii∈ n≢i refl
-- OnlyPairs and ManyPairs are mutually exclusive.
¬pairs : ∀ {n} (p : P ℕ n) → OnlyPairs p → ManyPairs p → ⊥
¬pairs fail op mp = witness mp (helper ∘ proj₂)
where
helper : ∀ {t} → ¬ pair t ∈ fail
helper ()
¬pairs empty op mp = witness mp (helper ∘ proj₂)
where
helper : ∀ {t} → ¬ pair t ∈ empty
helper ()
¬pairs (sat f) op mp = witness mp (helper ∘ proj₂)
where
helper : ∀ {t} → ¬ pair t ∈ sat f
helper ()
¬pairs (nonempty p) op mp =
¬pairs p (op ∘ nonempty) (Inf.map helper mp)
where
helper : ∀ {n} → pair n ∈ nonempty p → pair n ∈ p
helper (nonempty pr) = pr
¬pairs (cast eq p) op mp = ¬pairs p (op ∘ cast) (Inf.map helper mp)
where
helper : ∀ {n} → pair n ∈ cast eq p → pair n ∈ p
helper (cast pr) = pr
-- The most interesting cases are _∣_ and _·_. For the choice
-- combinator we make use of the fact that if p₁ ∣ p₂ accepts
-- infinitely many pairs, then at least one of p₁ and p₂ do. (We are
-- deriving a contradiction, so the use of classical reasoning is
-- unproblematic.)
¬pairs (p₁ ∣ p₂) op mp = commutes-with-∪ (Inf.map split mp) helper
where
helper : ¬ (ManyPairs p₁ ⊎ ManyPairs p₂)
helper (inj₁ mp₁) = ¬pairs p₁ (op ∘ ∣-left) mp₁
helper (inj₂ mp₂) = ¬pairs p₂ (op ∘ ∣-right {p₁ = p₁}) mp₂
split : ∀ {s} → s ∈ p₁ ∣ p₂ → s ∈ p₁ ⊎ s ∈ p₂
split (∣-left s∈p₁) = inj₁ s∈p₁
split (∣-right s∈p₂) = inj₂ s∈p₂
-- For the sequencing combinator we make use of the fact that the
-- argument recognisers cannot both accept non-empty strings.
¬pairs (p₁ · p₂) op mp =
excluded-middle λ a₁? →
excluded-middle λ a₂? →
helper a₁? a₂?
where
continue : {n n′ : Bool} (p : ∞⟨ n′ ⟩P ℕ n) → n′ ≡ true →
OnlyPairs (♭? p) → ManyPairs (♭? p) → ⊥
continue p eq with forced? p
continue p refl | true = ¬pairs p
continue p () | false
helper : Dec (AcceptsNonEmptyString (♭? p₁)) →
Dec (AcceptsNonEmptyString (♭? p₂)) → ⊥
helper (yes a₁) (yes a₂) = at-most-one op mp a₁ a₂
helper (no ¬a₁) _ with nullable-or-fail ¬a₁
... | inj₁ []∈p₁ =
continue p₂ (⇒ []∈p₁) (op ∘ _·_ []∈p₁) (Inf.map right mp)
where
right : ∀ {s} → s ∈ p₁ · p₂ → s ∈ ♭? p₂
right (_·_ {s₁ = []} _ ∈p₂) = ∈p₂
right (_·_ {s₁ = _ ∷ _} ∈p₁ _) = ⊥-elim (¬a₁ (-, -, ∈p₁))
... | inj₂ is-fail = witness mp (∉ ∘ proj₂)
where
∉ : ∀ {s} → ¬ s ∈ p₁ · p₂
∉ (∈p₁ · _) = is-fail _ ∈p₁
helper _ (no ¬a₂) with nullable-or-fail ¬a₂
... | inj₁ []∈p₂ =
continue p₁ (⇒ []∈p₂)
(op ∘ (λ ∈p₁ → cast∈ (proj₂ ListMonoid.identity _) refl
(∈p₁ · []∈p₂)))
(Inf.map left mp)
where
left : ∀ {s} → s ∈ p₁ · p₂ → s ∈ ♭? p₁
left (_·_ {s₂ = _ ∷ _} _ ∈p₂) = ⊥-elim (¬a₂ (-, -, ∈p₂))
left (_·_ {s₁ = s₁} {s₂ = []} ∈p₁ _) =
cast∈ (sym $ proj₂ ListMonoid.identity s₁) refl ∈p₁
... | inj₂ is-fail = witness mp (∉ ∘ proj₂)
where
∉ : ∀ {s} → ¬ s ∈ p₁ · p₂
∉ (_ · ∈p₂) = is-fail _ ∈p₂
-- Note that it is easy to decide whether a string is a pair or not.
pair? : List ℕ → Bool
pair? (m ∷ n ∷ []) = ⌊ Nat._≟_ m n ⌋
pair? _ = false
-- This means that there are decidable predicates over token strings
-- which cannot be realised using the recogniser combinators.
not-realisable :
¬ ∃₂ (λ n (p : P ℕ n) → ∀ {s} → s ∈ p ⇔ T (pair? s))
not-realisable (_ , p , hyp) = ¬pairs p op mp
where
op : OnlyPairs p
op {n} {[]} s∈p = ⊥-elim (Equivalence.to hyp ⟨$⟩ s∈p)
op {n} { m ∷ []} s∈p with toWitness (Equivalence.to hyp ⟨$⟩ s∈p)
op {n} {.n ∷ []} s∈p | refl = refl
op {n} {_ ∷ _ ∷ _} s∈p = ⊥-elim (Equivalence.to hyp ⟨$⟩ s∈p)
mp : ManyPairs p
mp (i , ¬pair) =
¬pair i NatOrder.refl $ Equivalence.from hyp ⟨$⟩ fromWitness refl
not-expressible :
∃₂ λ (Tok : Set) (f : List Tok → Bool) →
¬ ∃₂ (λ n (p : P Tok n) → ∀ {s} → s ∈ p ⇔ T (f s))
not-expressible = (ℕ , pair? , not-realisable)
where open NotExpressible
| {
"alphanum_fraction": 0.5351679546,
"avg_line_length": 36.7594202899,
"ext": "agda",
"hexsha": "664a1bbc974bca3735d0e7640d056d7c16d5edc2",
"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/LeftRecursion/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/LeftRecursion/ExpressiveStrength.agda",
"max_line_length": 77,
"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/LeftRecursion/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": 4665,
"size": 12682
} |
module Lemmachine.Spike where
open import Data.Fin
open import Data.Digit
-- 3.9 Quality Values
DIGIT = Decimal
data qvalue : DIGIT → DIGIT → DIGIT → Set where
zero : (d₁ d₂ d₃ : DIGIT) → qvalue d₁ d₂ d₃
one : qvalue zero zero zero
| {
"alphanum_fraction": 0.7112970711,
"avg_line_length": 19.9166666667,
"ext": "agda",
"hexsha": "f878c0580018411c80cb6854059771b003ffab8a",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "src/Lemmachine/Spike.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "src/Lemmachine/Spike.agda",
"max_line_length": 47,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "src/Lemmachine/Spike.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 83,
"size": 239
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Commutativity where
open import Cubical.Foundations.Prelude
open import Cubical.Categories.Category
private
variable
ℓ ℓ' : Level
module _ {C : Precategory ℓ ℓ'} where
open Precategory C
compSq : ∀ {x y z w u v} {f : C [ x , y ]} {g h} {k : C [ z , w ]} {l} {m} {n : C [ u , v ]}
-- square 1
→ f ⋆ g ≡ h ⋆ k
-- square 2 (sharing g)
→ k ⋆ l ≡ m ⋆ n
→ f ⋆ (g ⋆ l) ≡ (h ⋆ m) ⋆ n
compSq {f = f} {g} {h} {k} {l} {m} {n} p q
= f ⋆ (g ⋆ l)
≡⟨ sym (⋆Assoc _ _ _) ⟩
(f ⋆ g) ⋆ l
≡⟨ cong (_⋆ l) p ⟩
(h ⋆ k) ⋆ l
≡⟨ ⋆Assoc _ _ _ ⟩
h ⋆ (k ⋆ l)
≡⟨ cong (h ⋆_) q ⟩
h ⋆ (m ⋆ n)
≡⟨ sym (⋆Assoc _ _ _) ⟩
(h ⋆ m) ⋆ n
∎
| {
"alphanum_fraction": 0.4427480916,
"avg_line_length": 23.1176470588,
"ext": "agda",
"hexsha": "815052f20b9a0360ec06d656e53bdc54009cf618",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Categories/Commutativity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Categories/Commutativity.agda",
"max_line_length": 94,
"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/Categories/Commutativity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 388,
"size": 786
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lexicographic induction
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Induction.Lexicographic where
open import Data.Product
open import Induction
open import Level
-- The structure of lexicographic induction.
Σ-Rec : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : A → Set b} →
RecStruct A (ℓ₁ ⊔ b) ℓ₂ → (∀ x → RecStruct (B x) ℓ₁ ℓ₃) →
RecStruct (Σ A B) _ _
Σ-Rec RecA RecB P (x , y) =
-- Either x is constant and y is "smaller", ...
RecB x (λ y' → P (x , y')) y
×
-- ...or x is "smaller" and y is arbitrary.
RecA (λ x' → ∀ y' → P (x' , y')) x
_⊗_ : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b} →
RecStruct A (ℓ₁ ⊔ b) ℓ₂ → RecStruct B ℓ₁ ℓ₃ →
RecStruct (A × B) _ _
RecA ⊗ RecB = Σ-Rec RecA (λ _ → RecB)
-- Constructs a recursor builder for lexicographic induction.
Σ-rec-builder :
∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : A → Set b}
{RecA : RecStruct A (ℓ₁ ⊔ b) ℓ₂}
{RecB : ∀ x → RecStruct (B x) ℓ₁ ℓ₃} →
RecursorBuilder RecA → (∀ x → RecursorBuilder (RecB x)) →
RecursorBuilder (Σ-Rec RecA RecB)
Σ-rec-builder {RecA = RecA} {RecB = RecB} recA recB P f (x , y) =
(p₁ x y p₂x , p₂x)
where
p₁ : ∀ x y →
RecA (λ x' → ∀ y' → P (x' , y')) x →
RecB x (λ y' → P (x , y')) y
p₁ x y x-rec = recB x
(λ y' → P (x , y'))
(λ y y-rec → f (x , y) (y-rec , x-rec))
y
p₂ : ∀ x → RecA (λ x' → ∀ y' → P (x' , y')) x
p₂ = recA (λ x → ∀ y → P (x , y))
(λ x x-rec y → f (x , y) (p₁ x y x-rec , x-rec))
p₂x = p₂ x
[_⊗_] : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b}
{RecA : RecStruct A (ℓ₁ ⊔ b) ℓ₂} {RecB : RecStruct B ℓ₁ ℓ₃} →
RecursorBuilder RecA → RecursorBuilder RecB →
RecursorBuilder (RecA ⊗ RecB)
[ recA ⊗ recB ] = Σ-rec-builder recA (λ _ → recB)
------------------------------------------------------------------------
-- Example
private
open import Data.Nat
open import Induction.Nat as N
-- The Ackermann function à la Rózsa Péter.
ackermann : ℕ → ℕ → ℕ
ackermann m n =
build [ N.recBuilder ⊗ N.recBuilder ]
(λ _ → ℕ)
(λ { (zero , n) _ → 1 + n
; (suc m , zero) (_ , ackm•) → ackm• 1
; (suc m , suc n) (ack[1+m]n , ackm•) → ackm• ack[1+m]n
})
(m , n)
| {
"alphanum_fraction": 0.4536741214,
"avg_line_length": 30.5365853659,
"ext": "agda",
"hexsha": "bfa30777eaf75ec27b9d722039bea801c4576c60",
"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/Induction/Lexicographic.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/Induction/Lexicographic.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Induction/Lexicographic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 943,
"size": 2504
} |
{-
This file contains:
- Fibers of induced map between set truncations is the set truncation of fibers
modulo a certain equivalence relation defined by π₁ of the base.
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.SetTruncation.Fibers where
open import Cubical.HITs.SetTruncation.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Path
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as Prop
open import Cubical.HITs.SetTruncation as Set
open import Cubical.HITs.SetQuotients as SetQuot
open import Cubical.Relation.Binary
private
variable
ℓ ℓ' : Level
module _
{X : Type ℓ }
{Y : Type ℓ'}
(f : X → Y) where
private
∥f∥₂ : ∥ X ∥₂ → ∥ Y ∥₂
∥f∥₂ = Set.map f
module _ (y : Y) where
open Iso
isSetFiber∥∥₂ : isSet (fiber ∥f∥₂ ∣ y ∣₂)
isSetFiber∥∥₂ = isOfHLevelΣ 2 squash₂ (λ _ → isProp→isSet (squash₂ _ _))
fiberRel : ∥ fiber f y ∥₂ → ∥ fiber f y ∥₂ → Type ℓ
fiberRel a b = Set.map fst a ≡ Set.map fst b
private
proj : ∥ fiber f y ∥₂ / fiberRel → ∥ X ∥₂
proj = SetQuot.rec squash₂ (Set.map fst) (λ _ _ p → p)
∥fiber∥₂/R→fiber∥∥₂ : ∥ fiber f y ∥₂ / fiberRel → fiber ∥f∥₂ ∣ y ∣₂
∥fiber∥₂/R→fiber∥∥₂ = SetQuot.rec isSetFiber∥∥₂ ∥fiber∥₂→fiber∥∥₂ feq
where
fiber→fiber∥∥₂ : fiber f y → fiber ∥f∥₂ ∣ y ∣₂
fiber→fiber∥∥₂ (x , p) = ∣ x ∣₂ , cong ∣_∣₂ p
∥fiber∥₂→fiber∥∥₂ : ∥ fiber f y ∥₂ → fiber ∥f∥₂ ∣ y ∣₂
∥fiber∥₂→fiber∥∥₂ = Set.rec isSetFiber∥∥₂ fiber→fiber∥∥₂
feq : (a b : ∥ fiber f y ∥₂) (r : fiberRel a b) → ∥fiber∥₂→fiber∥∥₂ a ≡ ∥fiber∥₂→fiber∥∥₂ b
feq =
Set.elim2 (λ _ _ → isProp→isSet (isPropΠ (λ _ → isSetFiber∥∥₂ _ _))) λ _ _ p →
ΣPathP (p , isSet→isSet' squash₂ _ _ _ _)
mereFiber→∥fiber∥₂/R : (x : X) → ∥ f x ≡ y ∥ → ∥ fiber f y ∥₂ / fiberRel
mereFiber→∥fiber∥₂/R x = Prop.rec→Set squash/ (λ p → [ ∣ _ , p ∣₂ ]) (λ _ _ → eq/ _ _ refl)
fiber∥∥₂→∥fiber∥₂/R : fiber ∥f∥₂ ∣ y ∣₂ → ∥ fiber f y ∥₂ / fiberRel
fiber∥∥₂→∥fiber∥₂/R =
uncurry
(Set.elim (λ _ → isSetΠ λ _ → squash/) λ x p →
mereFiber→∥fiber∥₂/R x (PathIdTrunc₀Iso .fun p))
∥fiber∥₂/R→fiber∥∥₂→fst : (q : ∥ fiber f y ∥₂ / fiberRel) → ∥fiber∥₂/R→fiber∥∥₂ q .fst ≡ proj q
∥fiber∥₂/R→fiber∥∥₂→fst =
SetQuot.elimProp (λ _ → squash₂ _ _)
(Set.elim (λ _ → isProp→isSet (squash₂ _ _)) (λ _ → refl))
fiber∥∥₂→∥fiber∥₂/R→proj : (x : fiber ∥f∥₂ ∣ y ∣₂) → proj (fiber∥∥₂→∥fiber∥₂/R x) ≡ x .fst
fiber∥∥₂→∥fiber∥₂/R→proj =
uncurry
(Set.elim (λ _ → isSetΠ λ _ → isProp→isSet (squash₂ _ _)) λ x p →
Prop.elim {P = λ t → proj (mereFiber→∥fiber∥₂/R x t) ≡ ∣ x ∣₂}
(λ _ → squash₂ _ _)
(λ _ → refl)
(PathIdTrunc₀Iso .fun p))
∥fiber∥₂/R→fiber∥∥₂→∥fiber∥₂/R :
(x : ∥ fiber f y ∥₂ / fiberRel) → fiber∥∥₂→∥fiber∥₂/R (∥fiber∥₂/R→fiber∥∥₂ x) ≡ x
∥fiber∥₂/R→fiber∥∥₂→∥fiber∥₂/R =
SetQuot.elimProp (λ _ → squash/ _ _)
(Set.elim (λ _ → isProp→isSet (squash/ _ _))
(λ _ → eq/ _ _ refl))
fiber∥∥₂→∥fiber∥₂/R→fiber∥∥₂ :
(x : fiber ∥f∥₂ ∣ y ∣₂) → ∥fiber∥₂/R→fiber∥∥₂ (fiber∥∥₂→∥fiber∥₂/R x) ≡ x
fiber∥∥₂→∥fiber∥₂/R→fiber∥∥₂ x =
Σ≡Prop
(λ _ → squash₂ _ _)
(∥fiber∥₂/R→fiber∥∥₂→fst (fiber∥∥₂→∥fiber∥₂/R x) ∙ fiber∥∥₂→∥fiber∥₂/R→proj x)
Iso-∥fiber∥₂/R-fiber∥∥₂ : Iso (∥ fiber f y ∥₂ / fiberRel) (fiber ∥f∥₂ ∣ y ∣₂)
Iso-∥fiber∥₂/R-fiber∥∥₂ .fun = ∥fiber∥₂/R→fiber∥∥₂
Iso-∥fiber∥₂/R-fiber∥∥₂ .inv = fiber∥∥₂→∥fiber∥₂/R
Iso-∥fiber∥₂/R-fiber∥∥₂ .leftInv = ∥fiber∥₂/R→fiber∥∥₂→∥fiber∥₂/R
Iso-∥fiber∥₂/R-fiber∥∥₂ .rightInv = fiber∥∥₂→∥fiber∥₂/R→fiber∥∥₂
-- main results
∥fiber∥₂/R≃fiber∥∥₂ : ∥ fiber f y ∥₂ / fiberRel ≃ fiber ∥f∥₂ ∣ y ∣₂
∥fiber∥₂/R≃fiber∥∥₂ = isoToEquiv Iso-∥fiber∥₂/R-fiber∥∥₂
-- the relation is an equivalence relation
open BinaryRelation
open isEquivRel
isEquivRelFiberRel : isEquivRel fiberRel
isEquivRelFiberRel .reflexive _ = refl
isEquivRelFiberRel .symmetric _ _ = sym
isEquivRelFiberRel .transitive _ _ _ = _∙_
-- alternative characterization of the relation in terms of equality in Y and fiber f y
∣transport∣ : ∥ y ≡ y ∥₂ → ∥ fiber f y ∥₂ → ∥ fiber f y ∥₂
∣transport∣ = Set.rec2 squash₂ (λ s (x , q) → ∣ x , q ∙ s ∣₂)
fiberRel2 : (x x' : ∥ fiber f y ∥₂) → Type (ℓ-max ℓ ℓ')
fiberRel2 x x' = ∥ Σ[ s ∈ ∥ y ≡ y ∥₂ ] ∣transport∣ s x ≡ x' ∥
fiberRel2→1 : ∀ x x' → fiberRel2 x x' → fiberRel x x'
fiberRel2→1 =
Set.elim2 (λ _ _ → isSetΠ λ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ →
Prop.rec (squash₂ _ _)
(uncurry
(Set.elim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 squash₂ _ _) λ _ →
cong (Set.map fst)))
fiberRel1→2 : ∀ x x' → fiberRel x x' → fiberRel2 x x'
fiberRel1→2 =
Set.elim2 (λ _ _ → isSetΠ λ _ → isProp→isSet squash) λ a b p →
Prop.rec squash
(λ q →
let
filler = doubleCompPath-filler (sym (a .snd)) (cong f q) (b .snd)
in
∣ ∣ filler i1 ∣₂ , cong ∣_∣₂ (ΣPathP (q , adjustLemma (flipSquare filler))) ∣)
(PathIdTrunc₀Iso .Iso.fun p)
where
adjustLemma : {x y z w : Y} {p : x ≡ y} {q : x ≡ z} {r : z ≡ w} {s : y ≡ w}
→ PathP (λ i → p i ≡ r i) q s
→ PathP (λ i → p i ≡ w) (q ∙ r) s
adjustLemma {p = p} {q} {r} {s} α i j =
hcomp
(λ k → λ
{ (i = i0) → compPath-filler q r k j
; (i = i1) → s j
; (j = i0) → p i
; (j = i1) → r (i ∨ k)})
(α i j)
fiberRel1≃2 : ∀ x x' → fiberRel x x' ≃ fiberRel2 x x'
fiberRel1≃2 _ _ =
propBiimpl→Equiv (squash₂ _ _) squash (fiberRel1→2 _ _) (fiberRel2→1 _ _)
| {
"alphanum_fraction": 0.5641581845,
"avg_line_length": 35.0467836257,
"ext": "agda",
"hexsha": "f183bc1eb2b419a34b6ae2da6930130dd9128352",
"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/HITs/SetTruncation/Fibers.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/HITs/SetTruncation/Fibers.agda",
"max_line_length": 99,
"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/HITs/SetTruncation/Fibers.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2666,
"size": 5993
} |
{- Formal verification of authenticated append-only skiplists in Agda, version 1.0.
Copyright (c) 2021 Victor C Miraldo.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Data.Unit.NonEta
open import Data.Empty
open import Data.Sum
open import Data.Product
open import Data.Product.Properties
open import Data.Fin hiding (_<_; _≤_)
open import Data.Fin.Properties using () renaming (_≟_ to _≟Fin_)
open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_)
open import Data.Nat.Properties
open import Data.List renaming (map to List-map)
open import Data.List.Properties using (∷-injective; length-map)
open import Data.List.Relation.Unary.Any renaming (map to Any-map)
open import Data.List.Relation.Unary.All renaming (lookup to All-lookup; map to All-map)
open import Data.List.Relation.Unary.All.Properties hiding (All-map)
open import Data.List.Relation.Unary.Any.Properties renaming (map⁺ to Any-map⁺)
open import Data.List.Relation.Binary.Pointwise using (decidable-≡)
open import Data.Bool hiding (_<_; _≤_)
open import Data.Maybe renaming (map to Maybe-map)
open import Function
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Core
open import Relation.Nullary
-- This module defines the DepRel type, which represents the class of AAOSLs we
-- consider, and proves properties about any DepRel.
module AAOSL.Abstract.DepRel where
open import AAOSL.Lemmas
open import AAOSL.Abstract.Hash
-- TODO-1: make names same as paper (lvlof -> maxlvl, etc.)
-- The important bit is that we must have a dependency relation
-- between these indexes.
record DepRel : Set₁ where
field
lvlof : ℕ → ℕ
lvlof-z : lvlof 0 ≡ 0
lvlof-s : ∀ m → 0 < lvlof (suc m)
HopFrom : ℕ → Set
HopFrom = Fin ∘ lvlof
field
hop-tgt : {m : ℕ} → HopFrom m → ℕ
hop-tgt-inj : {m : ℕ}{h h' : HopFrom m}
→ hop-tgt h ≡ hop-tgt h'
→ h ≡ h'
hop-< : {m : ℕ}(h : HopFrom m)
→ hop-tgt h < m
-- This property requires that any pair of hops is either nested or
-- non-overlapping. When nonoverlapping, one end may coincide and
-- when nested, both ends may coincide. As a diagram,
--
-- h₂
-- ⌜⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⌝
-- ∣ ∣
-- ∣ h₁ ∣
-- ∣ ⌜⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⌝ |
-- | | | |
-- tgt h₂ <I tgt h₁ ⋯ j₁ j₂
-- ↑
-- The only option for j₁
-- is right here. It can be
-- the same as j₂ though.
-- For more intuition on this, check
-- Hops.agda
--
hops-nested-or-nonoverlapping : ∀{j₁ j₂}{h₁ : HopFrom j₁}{h₂ : HopFrom j₂}
→ hop-tgt h₂ < hop-tgt h₁
→ hop-tgt h₁ < j₂
→ j₁ ≤ j₂
_≟Hop_ : {s : ℕ}(h l : HopFrom s) → Dec (h ≡ l)
_≟Hop_ = _≟Fin_
| {
"alphanum_fraction": 0.5685483871,
"avg_line_length": 37.9294117647,
"ext": "agda",
"hexsha": "70902783d0cfe7d7ebac3c37ce08771d13c7d315",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-02-18T04:33:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-12-22T00:01:03.000Z",
"max_forks_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/aaosl-agda",
"max_forks_repo_path": "AAOSL/Abstract/DepRel.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0",
"max_issues_repo_issues_event_max_datetime": "2021-02-12T04:16:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-01-04T03:45:34.000Z",
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/aaosl-agda",
"max_issues_repo_path": "AAOSL/Abstract/DepRel.agda",
"max_line_length": 111,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/aaosl-agda",
"max_stars_repo_path": "AAOSL/Abstract/DepRel.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-31T10:16:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-22T00:01:00.000Z",
"num_tokens": 961,
"size": 3224
} |
-- Andreas, 2012-01-30, bug reported by Nisse
-- {-# OPTIONS -v tc.term.absurd:50 -v tc.signature:30 -v tc.conv.atom:30 -v tc.conv.elim:50 #-}
module Issue557 where
data ⊥ : Set where
postulate
A : Set
a : (⊥ → ⊥) → A
F : A → Set
f : (a : A) → F a
module M (I : Set → Set) where
x : A
x = a (λ ())
y : A
y = M.x (λ A → A)
z : F y
z = f y
-- cause was absurd lambda in a module, i.e., under a telescope (I : Set -> Set)
-- (λ ()) must be replaced by (absurd I) not just by (absurd)
| {
"alphanum_fraction": 0.562,
"avg_line_length": 19.2307692308,
"ext": "agda",
"hexsha": "4e0ca7e6bd1ca737b7b4b7252e4f18163452cd0f",
"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/Issue557.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/Issue557.agda",
"max_line_length": 96,
"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/Issue557.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": 194,
"size": 500
} |
module Data.Real.Complete where
import Prelude
import Data.Real.Gauge
import Data.Rational
open Prelude
open Data.Real.Gauge
open Data.Rational
Complete : Set -> Set
Complete A = Gauge -> A
unit : {A : Set} -> A -> Complete A
unit x ε = x
join : {A : Set} -> Complete (Complete A) -> Complete A
join f ε = f ε2 ε2
where
ε2 = ε / fromNat 2
infixr 10 _==>_
data _==>_ (A B : Set) : Set where
uniformCts : (Gauge -> Gauge) -> (A -> B) -> A ==> B
modulus : {A B : Set} -> (A ==> B) -> Gauge -> Gauge
modulus (uniformCts μ _) = μ
forgetUniformCts : {A B : Set} -> (A ==> B) -> A -> B
forgetUniformCts (uniformCts _ f) = f
mapC : {A B : Set} -> (A ==> B) -> Complete A -> Complete B
mapC (uniformCts μ f) x ε = f (x (μ ε))
bind : {A B : Set} -> (A ==> Complete B) -> Complete A -> Complete B
bind f x = join $ mapC f x
mapC2 : {A B C : Set} -> (A ==> B ==> C) -> Complete A -> Complete B -> Complete C
mapC2 f x y ε = mapC ≈fx y ε2
where
ε2 = ε / fromNat 2
≈fx = mapC f x ε2
_○_ : {A B C : Set} -> (B ==> C) -> (A ==> B) -> A ==> C
f ○ g = uniformCts μ h
where
μ = modulus f ∘ modulus g
h = forgetUniformCts f ∘ forgetUniformCts g
constCts : {A B : Set} -> A -> B ==> A
constCts a = uniformCts (const $ fromNat 1) (const a)
| {
"alphanum_fraction": 0.5661124307,
"avg_line_length": 22.9636363636,
"ext": "agda",
"hexsha": "55da491507b12e7c0527511f13c4ac936eddb00e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Real/Complete.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Real/Complete.agda",
"max_line_length": 82,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Real/Complete.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": 472,
"size": 1263
} |
module Issue1148 where
foo : Set → Set
foo = {!!}
| {
"alphanum_fraction": 0.5925925926,
"avg_line_length": 6.75,
"ext": "agda",
"hexsha": "83ef832691ba45f5f6c35e34b13a05ee79f06c25",
"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/interaction/Issue1148.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/interaction/Issue1148.agda",
"max_line_length": 22,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "masondesu/agda",
"max_stars_repo_path": "test/interaction/Issue1148.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 16,
"size": 54
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Any predicate transformer for fresh lists
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Fresh.Relation.Unary.Any where
open import Level using (Level; _⊔_; Lift)
open import Data.Empty
open import Data.Product using (∃; _,_; -,_)
open import Data.Sum.Base using (_⊎_; [_,_]′; inj₁; inj₂)
open import Function.Equivalence using (_⇔_; equivalence)
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Sum using (_⊎-dec_)
open import Relation.Unary as U
open import Relation.Binary as B using (Rel)
open import Data.List.Fresh using (List#; []; cons; _∷#_; _#_)
private
variable
a p q r : Level
A : Set a
module _ {A : Set a} {R : Rel A r} (P : Pred A p) where
data Any : List# A R → Set (p ⊔ a ⊔ r) where
here : ∀ {x xs pr} → P x → Any (cons x xs pr)
there : ∀ {x xs pr} → Any xs → Any (cons x xs pr)
module _ {R : Rel A r} {P : Pred A p} {x} {xs : List# A R} {pr} where
head : ¬ Any P xs → Any P (cons x xs pr) → P x
head ¬tail (here p) = p
head ¬tail (there ps) = ⊥-elim (¬tail ps)
tail : ¬ P x → Any P (cons x xs pr) → Any P xs
tail ¬head (here p) = ⊥-elim (¬head p)
tail ¬head (there ps) = ps
toSum : Any P (cons x xs pr) → P x ⊎ Any P xs
toSum (here p) = inj₁ p
toSum (there ps) = inj₂ ps
fromSum : P x ⊎ Any P xs → Any P (cons x xs pr)
fromSum = [ here , there ]′
⊎⇔Any : (P x ⊎ Any P xs) ⇔ Any P (cons x xs pr)
⊎⇔Any = equivalence fromSum toSum
module _ {R : Rel A r} {P : Pred A p} {Q : Pred A q} where
map : {xs : List# A R} → ∀[ P ⇒ Q ] → Any P xs → Any Q xs
map p⇒q (here p) = here (p⇒q p)
map p⇒q (there p) = there (map p⇒q p)
module _ {R : Rel A r} {P : Pred A p} where
witness : {xs : List# A R} → Any P xs → ∃ P
witness (here p) = -, p
witness (there ps) = witness ps
remove : (xs : List# A R) → Any P xs → List# A R
remove-# : ∀ {x} {xs : List# A R} p → x # xs → x # (remove xs p)
remove (_ ∷# xs) (here _) = xs
remove (cons x xs pr) (there k) = cons x (remove xs k) (remove-# k pr)
remove-# (here x) (p , ps) = ps
remove-# (there k) (p , ps) = p , remove-# k ps
infixl 4 _─_
_─_ = remove
module _ {R : Rel A r} {P : Pred A p} (P? : Decidable P) where
any? : (xs : List# A R) → Dec (Any P xs)
any? [] = no (λ ())
any? (x ∷# xs) = Dec.map ⊎⇔Any (P? x ⊎-dec any? xs)
| {
"alphanum_fraction": 0.5398264984,
"avg_line_length": 30.1904761905,
"ext": "agda",
"hexsha": "9be2df423fb4eaed64dedc9b941989252fe5e136",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/Any.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/Any.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Fresh/Relation/Unary/Any.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 922,
"size": 2536
} |
module Prelude where
open import Level public hiding (zero) renaming (suc to sucℓ)
open import Size public
open import Function public
open import Data.List using (List; _∷_; []; [_]) public
open import Data.Unit using (⊤; tt) public
open import Data.Nat using (ℕ; suc; zero; _+_) public
open import Data.Sum using (inj₁; inj₂) renaming (_⊎_ to _⊕_)public
open import Data.Product public hiding (map; zip)
open import Codata.Thunk public
open import Relation.Unary hiding (_∈_; Empty) public
open import Relation.Binary.PropositionalEquality hiding ([_]) public
open import Relation.Ternary.Separation public
open import Relation.Ternary.Separation.Allstar public
| {
"alphanum_fraction": 0.7784431138,
"avg_line_length": 35.1578947368,
"ext": "agda",
"hexsha": "db4ab0c5f89bc72f11eb538d66aaed883e62161b",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Prelude.agda",
"max_line_length": 69,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 179,
"size": 668
} |
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Equality
{-# BUILTIN REWRITE _≡_ #-}
record Box (P : Set) : Set where
constructor box
field
unbox : P
open Box public
postulate
A : Set
a : A
f : Box A → A
f= : f (box a) ≡ a
{-# REWRITE f= #-}
[a] : Box A
unbox [a] = a
-- Works thanks to eta
test1 : [a] ≡ box a
test1 = refl
-- Should work as well
test2 : f [a] ≡ f (box a)
test2 = refl
| {
"alphanum_fraction": 0.5811138015,
"avg_line_length": 14.2413793103,
"ext": "agda",
"hexsha": "d1ab79fdfd7c8139b3e00b5484b6de33d182e1ab",
"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/Succeed/Issue3335.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/Succeed/Issue3335.agda",
"max_line_length": 33,
"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/Succeed/Issue3335.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 154,
"size": 413
} |
{-# OPTIONS --without-K #-}
module Data.Word8 where
import Data.Word8.Primitive as Prim
open Prim renaming (primWord8fromNat to to𝕎; primWord8toNat to from𝕎) public
open import Agda.Builtin.Bool using (Bool; true; false)
open import Relation.Nullary using (yes; no)
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe)
infix 4 _≟_
_≟_ : Decidable {A = Word8} _≡_
w₁ ≟ w₂ with w₁ == w₂
... | true = yes trustMe
... | false = no whatever
where postulate whatever : _
-- toℕ : Word8 → Nat
-- toℕ = primWord8toNat
| {
"alphanum_fraction": 0.7405159332,
"avg_line_length": 26.36,
"ext": "agda",
"hexsha": "ff498d78d2b89802cf054c9d02c3d52e84a583ae",
"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": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bytes-agda",
"max_forks_repo_path": "src/Data/Word8.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"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": "semenov-vladyslav/bytes-agda",
"max_issues_repo_path": "src/Data/Word8.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bytes-agda",
"max_stars_repo_path": "src/Data/Word8.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 198,
"size": 659
} |
{-# OPTIONS --copatterns #-}
module Issue939 where
record Sigma (A : Set)(P : A → Set) : Set where
field
fst : A
.snd : P fst
open Sigma
postulate
A : Set
P : A → Set
x : A
.p : P x
ex : Sigma A P
ex = record
{ fst = x
; snd = p
}
ex' : Sigma A P
fst ex' = x
snd ex' = p
-- Giving p yields the following error:
-- Identifier p is declared irrelevant, so it cannot be used here
-- when checking that the expression p has type P (fst ex')
-- Fixed. Andreas, 2013-11-05
| {
"alphanum_fraction": 0.586407767,
"avg_line_length": 15.6060606061,
"ext": "agda",
"hexsha": "1647bfb11f27975f408277d5e2b7a2a3d95b2461",
"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/Issue939.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/Issue939.agda",
"max_line_length": 65,
"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/Issue939.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": 168,
"size": 515
} |
module plfa-code.Decidable where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ; zero; suc)
open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using ()
renaming (contradiction to ¬¬-intro)
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥; ⊥-elim)
open import plfa-code.Relations using (_<_; z<s; s<s)
open import plfa-code.Isomorphism using (_⇔_)
data Bool : Set where
true : Bool
false : Bool
open Data.Nat using (_≤_; z≤n; s≤s)
infix 4 _≤ᵇ_
_≤ᵇ_ : ℕ → ℕ → Bool
zero ≤ᵇ n = true
suc m ≤ᵇ zero = false
suc m ≤ᵇ suc n = m ≤ᵇ n
_ : (2 ≤ᵇ 4) ≡ true
_ =
begin
2 ≤ᵇ 4
≡⟨⟩
1 ≤ᵇ 3
≡⟨⟩
0 ≤ᵇ 2
≡⟨⟩
true
∎
_ : (4 ≤ᵇ 2) ≡ false
_ =
begin
4 ≤ᵇ 2
≡⟨⟩
3 ≤ᵇ 1
≡⟨⟩
2 ≤ᵇ 0
≡⟨⟩
false
∎
T : Bool → Set
T true = ⊤
T false = ⊥
T→≡ : ∀ (b : Bool) → T b → b ≡ true
T→≡ true tt = refl
T→≡ false ()
≡→T : ∀ {b : Bool} → b ≡ true → T b
≡→T refl = tt
≤ᵇ→≤ : ∀ (m n : ℕ) → T (m ≤ᵇ n) → m ≤ n
≤ᵇ→≤ zero n tt = z≤n
≤ᵇ→≤ (suc m) zero ()
≤ᵇ→≤ (suc m) (suc n) t = s≤s (≤ᵇ→≤ m n t)
≤→≤ᵇ : ∀ {m n : ℕ} → m ≤ n → T (m ≤ᵇ n)
≤→≤ᵇ z≤n = tt
≤→≤ᵇ (s≤s m≤n) = ≤→≤ᵇ m≤n
data Dec (A : Set) : Set where
yes : A → Dec A
no : ¬ A → Dec A
¬s≤z : ∀ {m : ℕ} → ¬ (suc m ≤ zero)
¬s≤z ()
¬s≤s : ∀ {m n : ℕ} → ¬ (m ≤ n) → ¬ (suc m ≤ suc n)
¬s≤s ¬m≤n (s≤s m≤n) = ¬m≤n m≤n
_≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n)
zero ≤? n = yes z≤n
suc m ≤? zero = no ¬s≤z
suc m ≤? suc n with m ≤? n
... | yes m≤n = yes (s≤s m≤n)
... | no ¬m≤n = no (¬s≤s ¬m≤n)
---------- practice ----------
open Eq using (cong)
_<?_ : ∀ (m n : ℕ) → Dec (m < n)
zero <? zero = no (λ ())
zero <? suc n = yes z<s
suc m <? zero = no (λ ())
suc m <? suc n with m <? n
... | yes m<n = yes (s<s m<n)
... | no ¬m<n = no λ{ (s<s m<n) → ¬m<n m<n}
_≡ℕ?_ : ∀ (m n : ℕ) → Dec (m ≡ n)
zero ≡ℕ? zero = yes refl
zero ≡ℕ? suc n = no (λ ())
suc m ≡ℕ? zero = no (λ ())
suc m ≡ℕ? suc n with m ≡ℕ? n
(suc m ≡ℕ? suc n) | yes m≡n = yes (cong suc m≡n)
(suc m ≡ℕ? suc n) | no ¬m≡n = no λ{ refl → ¬m≡n refl}
------------------------------
_≤?′_ : ∀ (m n : ℕ) → Dec (m ≤ n)
m ≤?′ n with m ≤ᵇ n | ≤ᵇ→≤ m n | ≤→≤ᵇ {m} {n}
... | true | p | _ = yes (p tt)
... | false | _ | ¬p = no ¬p
⌊_⌋ : ∀ {A : Set} → Dec A → Bool
⌊ yes _ ⌋ = true
⌊ no _ ⌋ = false
_≤ᵇ′_ : ℕ → ℕ → Bool
m ≤ᵇ′ n = ⌊ m ≤? n ⌋
toWitness : ∀ {A : Set} {D : Dec A} → T ⌊ D ⌋ → A
toWitness {A} {yes x} tt = x
toWitness {A} {no ¬x} ()
fromWitness : ∀ {A : Set} {D : Dec A} → A → T ⌊ D ⌋
fromWitness {A} {yes x} _ = tt
fromWitness {A} {no ¬x} x = ¬x x
≤ᵇ′→≤ : ∀ {m n : ℕ} → T (m ≤ᵇ′ n) → m ≤ n
≤ᵇ′→≤ = toWitness
≤→≤ᵇ′ : ∀ {m n : ℕ} → m ≤ n → T (m ≤ᵇ′ n)
≤→≤ᵇ′ = fromWitness
infixr 6 _∧_
_∧_ : Bool → Bool → Bool
true ∧ true = true
false ∧ _ = false
_ ∧ false = false
infixr 6 _×-dec_
_×-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A × B)
yes x ×-dec yes y = yes ⟨ x , y ⟩
no ¬x ×-dec _ = no λ{ ⟨ x , y ⟩ → ¬x x}
_ ×-dec no ¬y = no λ{ ⟨ x , y ⟩ → ¬y y}
infixr 5 _∨_
_∨_ : Bool → Bool → Bool
true ∨ _ = true
_ ∨ true = true
false ∨ false = false
infixr 5 _⊎-dec_
_⊎-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A ⊎ B)
yes x ⊎-dec _ = yes (inj₁ x)
_ ⊎-dec yes y = yes (inj₂ y)
no ¬x ⊎-dec no ¬y = no λ{ (inj₁ x) → ¬x x ; (inj₂ y) → ¬y y }
not : Bool → Bool
not true = false
not false = true
¬? : ∀ {A : Set} → Dec A → Dec (¬ A)
¬? (yes x) = no (¬¬-intro x)
¬? (no ¬x) = yes ¬x
_⊃_ : Bool → Bool → Bool
_ ⊃ true = true
false ⊃ _ = true
true ⊃ false = false
_→-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A → B)
_ →-dec yes y = yes (λ _ → y)
no ¬x →-dec _ = yes (λ x → ⊥-elim (¬x x))
yes x →-dec no ¬y = no (λ f → ¬y (f x))
---------- practice ----------
∧-× : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∧ ⌊ y ⌋ ≡ ⌊ x ×-dec y ⌋
∧-× (yes x) (yes y) = refl
∧-× (yes x) (no ¬y) = refl
∧-× (no x) _ = refl
-- I think there is a typo, so I write ∨-⊎ instead of the origin ∨-×
∨-⊎ : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∨ ⌊ y ⌋ ≡ ⌊ x ⊎-dec y ⌋
∨-⊎ (yes x) _ = refl
∨-⊎ (no ¬x) (yes y) = refl
∨-⊎ (no ¬x) (no ¬y) = refl
not-¬ : ∀ {A : Set} (x : Dec A) → not ⌊ x ⌋ ≡ ⌊ ¬? x ⌋
not-¬ (yes x) = refl
not-¬ (no ¬x) = refl
| {
"alphanum_fraction": 0.4428320141,
"avg_line_length": 22.8542713568,
"ext": "agda",
"hexsha": "37120dcd9255d4ede41e428d38f223e559bf5474",
"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": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "chirsz-ever/plfa-code",
"max_forks_repo_path": "src/plfa-code/Decidable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"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": "chirsz-ever/plfa-code",
"max_issues_repo_path": "src/plfa-code/Decidable.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "chirsz-ever/plfa-code",
"max_stars_repo_path": "src/plfa-code/Decidable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2336,
"size": 4548
} |
module IrrelevantProjections where
import Common.Irrelevance
record [_] (A : Set) : Set where
field
.inflate : A
open [_] using (inflate)
-- Should fail, since proj isn't declared irrelevant.
proj : ∀ {A} → [ A ] → A
proj x = inflate x
| {
"alphanum_fraction": 0.6734693878,
"avg_line_length": 18.8461538462,
"ext": "agda",
"hexsha": "558f9d3b9e734019fc096c156335407901af49d8",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/IrrelevantProjections.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"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": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/IrrelevantProjections.agda",
"max_line_length": 53,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/IrrelevantProjections.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": 72,
"size": 245
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.SuspAdjointLoop where
module SuspAdjointLoop {i j} (X : Ptd i) (Y : Ptd j) where
private
A = fst X; a₀ = snd X
B = fst Y; b₀ = snd Y
R : {b : B}
→ Σ (Suspension A → B) (λ h → h (north A) == b)
→ Σ (A → (b == b)) (λ k → k a₀ == idp)
R (h , idp) =
(λ a → ap h (merid A a ∙ ! (merid A a₀))) ,
ap (ap h) (!-inv-r (merid A a₀))
L : {b : B}
→ Σ (A → (b == b)) (λ k → k a₀ == idp)
→ Σ (Suspension A → B) (λ h → h (north A) == b)
L {b} (k , _) = (SuspensionRec.f A b b k) , idp
{- Show that R ∘ L ∼ idf -}
R-L : {b : B} → ∀ K → R {b} (L K) == K
R-L {b} (k , kpt) = ⊙λ= R-L-fst R-L-snd
where
R-L-fst : (a : A)
→ ap (SuspensionRec.f A b b k) (merid A a ∙ ! (merid A a₀)) == k a
R-L-fst a =
ap-∙ (SuspensionRec.f A b b k) (merid A a) (! (merid A a₀))
∙ ap2 _∙_ (SuspensionRec.glue-β A b b k a)
(ap-! (SuspensionRec.f A b b k) (merid A a₀)
∙ ap ! (SuspensionRec.glue-β A b b k a₀ ∙ kpt))
∙ ∙-unit-r (k a)
-- lemmas generalize to do some path induction for R-L-snd
lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₁ a₂ : A}
(p : a₁ == a₂) {q r : f a₁ == f a₂} {s : f a₁ == f a₁}
(α : ap f p == q) (β : q == r) (γ : q ∙ ! r == s) (δ : s == idp)
(σ : !-inv-r r == transport (λ t → t ∙ ! r == idp) β (γ ∙ δ))
→ ap (ap f) (!-inv-r p)
== (ap-∙ f p (! p) ∙ ap2 _∙_ α (ap-! f p ∙ ap ! (α ∙ β)) ∙ γ) ∙ δ
lemma₁ f idp idp idp γ idp σ = σ
lemma₂ : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp)
→ idp == transport (λ t → t ∙ idp == idp) α (∙-unit-r p ∙ α)
lemma₂ idp = idp
R-L-snd : ap (ap (SuspensionRec.f A b b k)) (!-inv-r (merid A a₀))
== R-L-fst a₀ ∙ kpt
R-L-snd =
ap (ap (SuspensionRec.f A b b k)) (!-inv-r (merid A a₀))
=⟨ lemma₁ (SuspensionRec.f A b b k) (merid A a₀)
(SuspensionRec.glue-β A b b k a₀)
kpt (∙-unit-r (k a₀)) kpt (lemma₂ kpt) ⟩
R-L-fst a₀ ∙ kpt ∎
{- Show that L ∘ R ∼ idf -}
L-R : {b : B} → ∀ H → L {b} (R H) == H
L-R (h , idp) = ⊙λ= L-R-fst idp
where
fst-lemma : ∀ {i j} {A : Type i} {B : Type j} {x y z : A}
(f : A → B) (p : x == y) (q : z == y)
→ ap f p == ap f (p ∙ ! q) ∙' ap f q
fst-lemma _ idp idp = idp
L-R-fst : (σ : Suspension A) →
SuspensionRec.f A (h (north _)) (h (north _)) (fst (R (h , idp))) σ == h σ
L-R-fst = Suspension-elim A
idp
(ap h (merid A a₀))
(λ a → ↓-='-in $
ap h (merid A a)
=⟨ fst-lemma h (merid A a) (merid A a₀) ⟩
ap h (merid A a ∙ ! (merid A a₀)) ∙' ap h (merid A a₀)
=⟨ ! (SuspensionRec.glue-β A _ _ (fst (R (h , idp))) a)
|in-ctx (λ w → w ∙' (ap h (merid A a₀))) ⟩
ap (fst (L (R (h , idp)))) (merid A a) ∙' ap h (merid A a₀)
∎)
{- Show that R respects basepoint -}
pres-ident : {b : B}
→ R {b} ((λ _ → b) , idp) == ((λ _ → idp) , idp)
pres-ident {b} = ⊙λ=
(λ a → ap-cst b (merid A a ∙ ! (merid A a₀)))
(ap (ap (λ _ → b)) (!-inv-r (merid A a₀))
=⟨ lemma (merid A a₀) b ⟩
ap-cst b (merid A a₀ ∙ ! (merid A a₀))
=⟨ ! (∙-unit-r _) ⟩
ap-cst b (merid A a₀ ∙ ! (merid A a₀)) ∙ idp ∎)
where
lemma : ∀ {i j} {A : Type i} {B : Type j} {x y : A} (p : x == y) (b : B)
→ ap (ap (λ _ → b)) (!-inv-r p) == ap-cst b (p ∙ ! p)
lemma idp b = idp
{- Show that if there is a composition operation ⊙ on B, then R respects
that composition, that is R {b ⊙ c} (F ⊙ G) == R {b} F ∙ R {c} G -}
-- lift a composition operation on the codomain to the function space
comp-lift : ∀ {i j} {A : Type i} {B C D : Type j}
(a : A) (b : B) (c : C) (_⊙_ : B → C → D)
→ Σ (A → B) (λ f → f a == b)
→ Σ (A → C) (λ g → g a == c)
→ Σ (A → D) (λ h → h a == b ⊙ c)
comp-lift a b c _⊙_ (f , fpt) (g , gpt) =
(λ x → f x ⊙ g x) , ap2 _⊙_ fpt gpt
pres-comp-fst : ∀ {i j} {A : Type i} {B : Type j} (f g : A → B)
(_⊙_ : B → B → B) {a₁ a₂ : A} (p : a₁ == a₂)
→ ap (λ x → f x ⊙ g x) p == ap2 _⊙_ (ap f p) (ap g p)
pres-comp-fst f g _⊙_ idp = idp
pres-comp-snd : ∀ {i j} {A : Type i} {B : Type j} (f g : A → B)
(_⊙_ : B → B → B) {a₁ a₂ : A} (q : a₁ == a₂)
→ ap (ap (λ x → f x ⊙ g x)) (!-inv-r q)
== pres-comp-fst f g _⊙_ (q ∙ ! q)
∙ ap2 (ap2 _⊙_) (ap (ap f) (!-inv-r q)) (ap (ap g) (!-inv-r q))
pres-comp-snd f g _⊙_ idp = idp
pres-comp : {b c : B} (_⊙_ : B → B → B)
(F : Σ (Suspension A → B) (λ f → f (north A) == b))
(G : Σ (Suspension A → B) (λ f → f (north A) == c))
→ R (comp-lift (north A) b c _⊙_ F G)
== comp-lift a₀ idp idp (ap2 _⊙_) (R F) (R G)
pres-comp _⊙_ (f , idp) (g , idp) = ⊙λ=
(λ a → pres-comp-fst f g _⊙_ (merid A a ∙ ! (merid A a₀)))
(pres-comp-snd f g _⊙_ (merid A a₀))
eqv : fst (⊙Susp X ⊙→ Y) ≃ fst (X ⊙→ ⊙Ω Y)
eqv = equiv R L R-L L-R
⊙path : (⊙Susp X ⊙→ Y) == (X ⊙→ ⊙Ω Y)
⊙path = ⊙ua eqv pres-ident
| {
"alphanum_fraction": 0.4377231257,
"avg_line_length": 36.273381295,
"ext": "agda",
"hexsha": "fbc6248e11a68734ff420525f97f46d4dd1e9679",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danbornside/HoTT-Agda",
"max_forks_repo_path": "homotopy/SuspAdjointLoop.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "danbornside/HoTT-Agda",
"max_issues_repo_path": "homotopy/SuspAdjointLoop.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danbornside/HoTT-Agda",
"max_stars_repo_path": "homotopy/SuspAdjointLoop.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2357,
"size": 5042
} |
{-# OPTIONS --without-K --safe #-}
-- Monoidal natural transformations between lax and strong symmetric
-- monoidal functors.
--
-- NOTE. Symmetric monoidal natural transformations are really just
-- monoidal natural transformations that happen to go between
-- symmetric monoidal functors. No additional conditions are
-- necessary. Nevertheless, the definitions in this module are useful
-- when one is working in a symmetric monoidal setting. They also
-- help Agda's type checker by bundling the (symmetric monoidal)
-- categories and functors involved.
--
-- See
-- * John Baez, Some definitions everyone should know,
-- https://math.ucr.edu/home/baez/qg-fall2004/definitions.pdf
-- * https://ncatlab.org/nlab/show/monoidal+natural+transformation
module Categories.NaturalTransformation.Monoidal.Symmetric where
open import Level
open import Categories.Category.Monoidal using (SymmetricMonoidalCategory)
import Categories.Functor.Monoidal.Symmetric as BMF
open import Categories.Functor.Monoidal.Properties using ()
renaming (∘-SymmetricMonoidal to _∘Fˡ_; ∘-StrongSymmetricMonoidal to _∘Fˢ_)
open import Categories.NaturalTransformation as NT using (NaturalTransformation)
import Categories.NaturalTransformation.Monoidal as MNT
module Lax where
open BMF.Lax using (SymmetricMonoidalFunctor)
open MNT.Lax using (IsMonoidalNaturalTransformation)
open SymmetricMonoidalFunctor using ()
renaming (F to UF; monoidalFunctor to MF)
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural transformations between symmetric monoidal functors.
record SymmetricMonoidalNaturalTransformation
(F G : SymmetricMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalTransformation (UF F) (UF G)
isMonoidal : IsMonoidalNaturalTransformation (MF F) (MF G) U
open NaturalTransformation U public
open IsMonoidalNaturalTransformation isMonoidal public
-- To shorten some definitions
private
_⇛_ = SymmetricMonoidalNaturalTransformation
module U = MNT.Lax
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Conversions
⌊_⌋ : {F G : SymmetricMonoidalFunctor C D} →
F ⇛ G → U.MonoidalNaturalTransformation (MF F) (MF G)
⌊ α ⌋ = record { U = U ; isMonoidal = isMonoidal }
where open SymmetricMonoidalNaturalTransformation α
⌈_⌉ : {F G : SymmetricMonoidalFunctor C D} →
U.MonoidalNaturalTransformation (MF F) (MF G) → F ⇛ G
⌈ α ⌉ = record { U = U ; isMonoidal = isMonoidal }
where open U.MonoidalNaturalTransformation α
-- Identity and compositions
infixr 9 _∘ᵥ_
id : {F : SymmetricMonoidalFunctor C D} → F ⇛ F
id = ⌈ U.id ⌉
_∘ᵥ_ : {F G H : SymmetricMonoidalFunctor C D} → G ⇛ H → F ⇛ G → F ⇛ H
α ∘ᵥ β = ⌈ ⌊ α ⌋ U.∘ᵥ ⌊ β ⌋ ⌉
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{E : SymmetricMonoidalCategory o″ ℓ″ e″} where
infixr 9 _∘ₕ_ _∘ˡ_ _∘ʳ_
_∘ₕ_ : {F G : SymmetricMonoidalFunctor C D}
{H I : SymmetricMonoidalFunctor D E} →
H ⇛ I → F ⇛ G → (H ∘Fˡ F) ⇛ (I ∘Fˡ G)
α ∘ₕ β = ⌈ ⌊ α ⌋ U.∘ₕ ⌊ β ⌋ ⌉
_∘ˡ_ : {F G : SymmetricMonoidalFunctor C D}
(H : SymmetricMonoidalFunctor D E) → F ⇛ G → (H ∘Fˡ F) ⇛ (H ∘Fˡ G)
H ∘ˡ α = id {F = H} ∘ₕ α
_∘ʳ_ : {G H : SymmetricMonoidalFunctor D E} →
G ⇛ H → (F : SymmetricMonoidalFunctor C D) → (G ∘Fˡ F) ⇛ (H ∘Fˡ F)
α ∘ʳ F = α ∘ₕ id {F = F}
module Strong where
open BMF.Strong using (SymmetricMonoidalFunctor)
open MNT.Strong using (IsMonoidalNaturalTransformation)
open SymmetricMonoidalFunctor using () renaming
( F to UF
; monoidalFunctor to MF
; laxSymmetricMonoidalFunctor to laxBMF
)
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural transformations between symmetric strong
-- monoidal functors.
record SymmetricMonoidalNaturalTransformation
(F G : SymmetricMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalTransformation (UF F) (UF G)
isMonoidal : IsMonoidalNaturalTransformation (MF F) (MF G) U
laxBNT : Lax.SymmetricMonoidalNaturalTransformation (laxBMF F) (laxBMF G)
laxBNT = record { U = U ; isMonoidal = isMonoidal }
open Lax.SymmetricMonoidalNaturalTransformation laxBNT public
hiding (U; isMonoidal)
-- To shorten some definitions
private
_⇛_ = SymmetricMonoidalNaturalTransformation
module U = MNT.Strong
module _ {o ℓ e o′ ℓ′ e′}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′} where
-- Conversions
⌊_⌋ : {F G : SymmetricMonoidalFunctor C D} →
F ⇛ G → U.MonoidalNaturalTransformation (MF F) (MF G)
⌊ α ⌋ = record { U = U ; isMonoidal = isMonoidal }
where open SymmetricMonoidalNaturalTransformation α
⌈_⌉ : {F G : SymmetricMonoidalFunctor C D} →
U.MonoidalNaturalTransformation (MF F) (MF G) → F ⇛ G
⌈ α ⌉ = record { U = U ; isMonoidal = isMonoidal }
where open U.MonoidalNaturalTransformation α
-- Identity and compositions
infixr 9 _∘ᵥ_
id : {F : SymmetricMonoidalFunctor C D} → F ⇛ F
id = ⌈ U.id ⌉
_∘ᵥ_ : {F G H : SymmetricMonoidalFunctor C D} → G ⇛ H → F ⇛ G → F ⇛ H
α ∘ᵥ β = ⌈ ⌊ α ⌋ U.∘ᵥ ⌊ β ⌋ ⌉
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : SymmetricMonoidalCategory o ℓ e}
{D : SymmetricMonoidalCategory o′ ℓ′ e′}
{E : SymmetricMonoidalCategory o″ ℓ″ e″} where
infixr 9 _∘ₕ_ _∘ˡ_ _∘ʳ_
_∘ₕ_ : {F G : SymmetricMonoidalFunctor C D}
{H I : SymmetricMonoidalFunctor D E} →
H ⇛ I → F ⇛ G → (H ∘Fˢ F) ⇛ (I ∘Fˢ G)
-- NOTE: this definition is clearly equivalent to
--
-- α ∘ₕ β = ⌈ ⌊ α ⌋ U.∘ₕ ⌊ β ⌋ ⌉
--
-- but the latter takes an unreasonably long time to typecheck,
-- while the unfolded version typechecks almost immediately.
α ∘ₕ β = record
{ U = C.U
; isMonoidal = record
{ ε-compat = C.ε-compat
; ⊗-homo-compat = C.⊗-homo-compat
}
}
where module C = U.MonoidalNaturalTransformation (⌊ α ⌋ U.∘ₕ ⌊ β ⌋)
_∘ˡ_ : {F G : SymmetricMonoidalFunctor C D}
(H : SymmetricMonoidalFunctor D E) → F ⇛ G → (H ∘Fˢ F) ⇛ (H ∘Fˢ G)
H ∘ˡ α = id {F = H} ∘ₕ α
_∘ʳ_ : {G H : SymmetricMonoidalFunctor D E} →
G ⇛ H → (F : SymmetricMonoidalFunctor C D) → (G ∘Fˢ F) ⇛ (H ∘Fˢ F)
α ∘ʳ F = α ∘ₕ id {F = F}
| {
"alphanum_fraction": 0.625090331,
"avg_line_length": 35.3010204082,
"ext": "agda",
"hexsha": "1d32d9db34a34c51095ee8befdebe03e9810ef6b",
"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": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sstucki/agda-categories",
"max_forks_repo_path": "src/Categories/NaturalTransformation/Monoidal/Symmetric.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823",
"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": "sstucki/agda-categories",
"max_issues_repo_path": "src/Categories/NaturalTransformation/Monoidal/Symmetric.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sstucki/agda-categories",
"max_stars_repo_path": "src/Categories/NaturalTransformation/Monoidal/Symmetric.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2403,
"size": 6919
} |
{-# OPTIONS --rewriting #-}
module Properties.DecSubtyping where
open import Agda.Builtin.Equality using (_≡_; refl)
open import FFI.Data.Either using (Either; Left; Right; mapLR; swapLR; cond)
open import Luau.Subtyping using (_<:_; _≮:_; Tree; Language; ¬Language; witness; unknown; never; scalar; function; scalar-function; scalar-function-ok; scalar-function-err; scalar-function-tgt; scalar-scalar; function-scalar; function-ok; function-ok₁; function-ok₂; function-err; function-tgt; left; right; _,_)
open import Luau.Type using (Type; Scalar; nil; number; string; boolean; never; unknown; _⇒_; _∪_; _∩_)
open import Luau.TypeNormalization using (_∪ⁿ_; _∩ⁿ_)
open import Luau.TypeSaturation using (saturate)
open import Properties.Contradiction using (CONTRADICTION; ¬)
open import Properties.Functions using (_∘_)
open import Properties.Subtyping using (<:-refl; <:-trans; ≮:-trans-<:; <:-trans-≮:; <:-never; <:-unknown; <:-∪-left; <:-∪-right; <:-∪-lub; ≮:-∪-left; ≮:-∪-right; <:-∩-left; <:-∩-right; <:-∩-glb; ≮:-∩-left; ≮:-∩-right; dec-language; scalar-<:; <:-everything; <:-function; ≮:-function-left; ≮:-function-right; <:-impl-¬≮:; <:-intersect; <:-function-∩-∪; <:-function-∩; <:-union; ≮:-left-∪; ≮:-right-∪; <:-∩-distr-∪; <:-impl-⊇; language-comp)
open import Properties.TypeNormalization using (FunType; Normal; never; unknown; _∩_; _∪_; _⇒_; normal; <:-normalize; normalize-<:; normal-∩ⁿ; normal-∪ⁿ; ∪-<:-∪ⁿ; ∪ⁿ-<:-∪; ∩ⁿ-<:-∩; ∩-<:-∩ⁿ; normalᶠ; fun-top; fun-function; fun-¬scalar)
open import Properties.TypeSaturation using (Overloads; Saturated; _⊆ᵒ_; _<:ᵒ_; defn; here; left; right; ov-language; ov-<:; saturated; normal-saturate; normal-overload-src; normal-overload-tgt; saturate-<:; <:-saturate; <:ᵒ-impl-<:; _>>=ˡ_; _>>=ʳ_)
open import Properties.Equality using (_≢_)
-- Honest this terminates, since saturation maintains the depth of nested arrows
{-# TERMINATING #-}
dec-subtypingˢⁿ : ∀ {T U} → Scalar T → Normal U → Either (T ≮: U) (T <: U)
dec-subtypingˢᶠ : ∀ {F G} → FunType F → Saturated F → FunType G → Either (F ≮: G) (F <:ᵒ G)
dec-subtypingᶠ : ∀ {F G} → FunType F → FunType G → Either (F ≮: G) (F <: G)
dec-subtypingᶠⁿ : ∀ {F U} → FunType F → Normal U → Either (F ≮: U) (F <: U)
dec-subtypingⁿ : ∀ {T U} → Normal T → Normal U → Either (T ≮: U) (T <: U)
dec-subtyping : ∀ T U → Either (T ≮: U) (T <: U)
dec-subtypingˢⁿ T U with dec-language _ (scalar T)
dec-subtypingˢⁿ T U | Left p = Left (witness (scalar T) (scalar T) p)
dec-subtypingˢⁿ T U | Right p = Right (scalar-<: T p)
dec-subtypingˢᶠ {F} {S ⇒ T} Fᶠ (defn sat-∩ sat-∪) (Sⁿ ⇒ Tⁿ) = result (top Fᶠ (λ o → o)) where
data Top G : Set where
defn : ∀ Sᵗ Tᵗ →
Overloads F (Sᵗ ⇒ Tᵗ) →
(∀ {S′ T′} → Overloads G (S′ ⇒ T′) → (S′ <: Sᵗ)) →
-------------
Top G
top : ∀ {G} → (FunType G) → (G ⊆ᵒ F) → Top G
top {S′ ⇒ T′} _ G⊆F = defn S′ T′ (G⊆F here) (λ { here → <:-refl })
top (Gᶠ ∩ Hᶠ) G⊆F with top Gᶠ (G⊆F ∘ left) | top Hᶠ (G⊆F ∘ right)
top (Gᶠ ∩ Hᶠ) G⊆F | defn Rᵗ Sᵗ p p₁ | defn Tᵗ Uᵗ q q₁ with sat-∪ p q
top (Gᶠ ∩ Hᶠ) G⊆F | defn Rᵗ Sᵗ p p₁ | defn Tᵗ Uᵗ q q₁ | defn n r r₁ = defn _ _ n
(λ { (left o) → <:-trans (<:-trans (p₁ o) <:-∪-left) r ; (right o) → <:-trans (<:-trans (q₁ o) <:-∪-right) r })
result : Top F → Either (F ≮: (S ⇒ T)) (F <:ᵒ (S ⇒ T))
result (defn Sᵗ Tᵗ oᵗ srcᵗ) with dec-subtypingⁿ Sⁿ (normal-overload-src Fᶠ oᵗ)
result (defn Sᵗ Tᵗ oᵗ srcᵗ) | Left (witness s Ss ¬Sᵗs) = Left (witness (function-err s) (ov-language Fᶠ (λ o → function-err (<:-impl-⊇ (srcᵗ o) s ¬Sᵗs))) (function-err Ss))
result (defn Sᵗ Tᵗ oᵗ srcᵗ) | Right S<:Sᵗ = result₀ (largest Fᶠ (λ o → o)) where
data LargestSrc (G : Type) : Set where
yes : ∀ S₀ T₀ →
Overloads F (S₀ ⇒ T₀) →
T₀ <: T →
(∀ {S′ T′} → Overloads G (S′ ⇒ T′) → T′ <: T → (S′ <: S₀)) →
-----------------------
LargestSrc G
no : ∀ S₀ T₀ →
Overloads F (S₀ ⇒ T₀) →
T₀ ≮: T →
(∀ {S′ T′} → Overloads G (S′ ⇒ T′) → T₀ <: T′) →
-----------------------
LargestSrc G
largest : ∀ {G} → (FunType G) → (G ⊆ᵒ F) → LargestSrc G
largest {S′ ⇒ T′} (S′ⁿ ⇒ T′ⁿ) G⊆F with dec-subtypingⁿ T′ⁿ Tⁿ
largest {S′ ⇒ T′} (S′ⁿ ⇒ T′ⁿ) G⊆F | Left T′≮:T = no S′ T′ (G⊆F here) T′≮:T λ { here → <:-refl }
largest {S′ ⇒ T′} (S′ⁿ ⇒ T′ⁿ) G⊆F | Right T′<:T = yes S′ T′ (G⊆F here) T′<:T (λ { here _ → <:-refl })
largest (Gᶠ ∩ Hᶠ) GH⊆F with largest Gᶠ (GH⊆F ∘ left) | largest Hᶠ (GH⊆F ∘ right)
largest (Gᶠ ∩ Hᶠ) GH⊆F | no S₁ T₁ o₁ T₁≮:T tgt₁ | no S₂ T₂ o₂ T₂≮:T tgt₂ with sat-∩ o₁ o₂
largest (Gᶠ ∩ Hᶠ) GH⊆F | no S₁ T₁ o₁ T₁≮:T tgt₁ | no S₂ T₂ o₂ T₂≮:T tgt₂ | defn o src tgt with dec-subtypingⁿ (normal-overload-tgt Fᶠ o) Tⁿ
largest (Gᶠ ∩ Hᶠ) GH⊆F | no S₁ T₁ o₁ T₁≮:T tgt₁ | no S₂ T₂ o₂ T₂≮:T tgt₂ | defn o src tgt | Left T₀≮:T = no _ _ o T₀≮:T (λ { (left o) → <:-trans tgt (<:-trans <:-∩-left (tgt₁ o)) ; (right o) → <:-trans tgt (<:-trans <:-∩-right (tgt₂ o)) })
largest (Gᶠ ∩ Hᶠ) GH⊆F | no S₁ T₁ o₁ T₁≮:T tgt₁ | no S₂ T₂ o₂ T₂≮:T tgt₂ | defn o src tgt | Right T₀<:T = yes _ _ o T₀<:T (λ { (left o) p → CONTRADICTION (<:-impl-¬≮: p (<:-trans-≮: (tgt₁ o) T₁≮:T)) ; (right o) p → CONTRADICTION (<:-impl-¬≮: p (<:-trans-≮: (tgt₂ o) T₂≮:T)) })
largest (Gᶠ ∩ Hᶠ) GH⊆F | no S₁ T₁ o₁ T₁≮:T tgt₁ | yes S₂ T₂ o₂ T₂<:T src₂ = yes S₂ T₂ o₂ T₂<:T (λ { (left o) p → CONTRADICTION (<:-impl-¬≮: p (<:-trans-≮: (tgt₁ o) T₁≮:T)) ; (right o) p → src₂ o p })
largest (Gᶠ ∩ Hᶠ) GH⊆F | yes S₁ T₁ o₁ T₁<:T src₁ | no S₂ T₂ o₂ T₂≮:T tgt₂ = yes S₁ T₁ o₁ T₁<:T (λ { (left o) p → src₁ o p ; (right o) p → CONTRADICTION (<:-impl-¬≮: p (<:-trans-≮: (tgt₂ o) T₂≮:T)) })
largest (Gᶠ ∩ Hᶠ) GH⊆F | yes S₁ T₁ o₁ T₁<:T src₁ | yes S₂ T₂ o₂ T₂<:T src₂ with sat-∪ o₁ o₂
largest (Gᶠ ∩ Hᶠ) GH⊆F | yes S₁ T₁ o₁ T₁<:T src₁ | yes S₂ T₂ o₂ T₂<:T src₂ | defn o src tgt = yes _ _ o (<:-trans tgt (<:-∪-lub T₁<:T T₂<:T))
(λ { (left o) T′<:T → <:-trans (src₁ o T′<:T) (<:-trans <:-∪-left src)
; (right o) T′<:T → <:-trans (src₂ o T′<:T) (<:-trans <:-∪-right src)
})
result₀ : LargestSrc F → Either (F ≮: (S ⇒ T)) (F <:ᵒ (S ⇒ T))
result₀ (no S₀ T₀ o₀ (witness t T₀t ¬Tt) tgt₀) = Left (witness (function-tgt t) (ov-language Fᶠ (λ o → function-tgt (tgt₀ o t T₀t))) (function-tgt ¬Tt))
result₀ (yes S₀ T₀ o₀ T₀<:T src₀) with dec-subtypingⁿ Sⁿ (normal-overload-src Fᶠ o₀)
result₀ (yes S₀ T₀ o₀ T₀<:T src₀) | Right S<:S₀ = Right λ { here → defn o₀ S<:S₀ T₀<:T }
result₀ (yes S₀ T₀ o₀ T₀<:T src₀) | Left (witness s Ss ¬S₀s) = Left (result₁ (smallest Fᶠ (λ o → o))) where
data SmallestTgt (G : Type) : Set where
defn : ∀ S₁ T₁ →
Overloads F (S₁ ⇒ T₁) →
Language S₁ s →
(∀ {S′ T′} → Overloads G (S′ ⇒ T′) → Language S′ s → (T₁ <: T′)) →
-----------------------
SmallestTgt G
smallest : ∀ {G} → (FunType G) → (G ⊆ᵒ F) → SmallestTgt G
smallest {S′ ⇒ T′} _ G⊆F with dec-language S′ s
smallest {S′ ⇒ T′} _ G⊆F | Left ¬S′s = defn Sᵗ Tᵗ oᵗ (S<:Sᵗ s Ss) λ { here S′s → CONTRADICTION (language-comp s ¬S′s S′s) }
smallest {S′ ⇒ T′} _ G⊆F | Right S′s = defn S′ T′ (G⊆F here) S′s (λ { here _ → <:-refl })
smallest (Gᶠ ∩ Hᶠ) GH⊆F with smallest Gᶠ (GH⊆F ∘ left) | smallest Hᶠ (GH⊆F ∘ right)
smallest (Gᶠ ∩ Hᶠ) GH⊆F | defn S₁ T₁ o₁ R₁s tgt₁ | defn S₂ T₂ o₂ R₂s tgt₂ with sat-∩ o₁ o₂
smallest (Gᶠ ∩ Hᶠ) GH⊆F | defn S₁ T₁ o₁ R₁s tgt₁ | defn S₂ T₂ o₂ R₂s tgt₂ | defn o src tgt = defn _ _ o (src s (R₁s , R₂s))
(λ { (left o) S′s → <:-trans (<:-trans tgt <:-∩-left) (tgt₁ o S′s)
; (right o) S′s → <:-trans (<:-trans tgt <:-∩-right) (tgt₂ o S′s)
})
result₁ : SmallestTgt F → (F ≮: (S ⇒ T))
result₁ (defn S₁ T₁ o₁ S₁s tgt₁) with dec-subtypingⁿ (normal-overload-tgt Fᶠ o₁) Tⁿ
result₁ (defn S₁ T₁ o₁ S₁s tgt₁) | Right T₁<:T = CONTRADICTION (language-comp s ¬S₀s (src₀ o₁ T₁<:T s S₁s))
result₁ (defn S₁ T₁ o₁ S₁s tgt₁) | Left (witness t T₁t ¬Tt) = witness (function-ok s t) (ov-language Fᶠ lemma) (function-ok Ss ¬Tt) where
lemma : ∀ {S′ T′} → Overloads F (S′ ⇒ T′) → Language (S′ ⇒ T′) (function-ok s t)
lemma {S′} o with dec-language S′ s
lemma {S′} o | Left ¬S′s = function-ok₁ ¬S′s
lemma {S′} o | Right S′s = function-ok₂ (tgt₁ o S′s t T₁t)
dec-subtypingˢᶠ F Fˢ (G ∩ H) with dec-subtypingˢᶠ F Fˢ G | dec-subtypingˢᶠ F Fˢ H
dec-subtypingˢᶠ F Fˢ (G ∩ H) | Left F≮:G | _ = Left (≮:-∩-left F≮:G)
dec-subtypingˢᶠ F Fˢ (G ∩ H) | _ | Left F≮:H = Left (≮:-∩-right F≮:H)
dec-subtypingˢᶠ F Fˢ (G ∩ H) | Right F<:G | Right F<:H = Right (λ { (left o) → F<:G o ; (right o) → F<:H o })
dec-subtypingᶠ F G with dec-subtypingˢᶠ (normal-saturate F) (saturated F) G
dec-subtypingᶠ F G | Left H≮:G = Left (<:-trans-≮: (saturate-<: F) H≮:G)
dec-subtypingᶠ F G | Right H<:G = Right (<:-trans (<:-saturate F) (<:ᵒ-impl-<: (normal-saturate F) G H<:G))
dec-subtypingᶠⁿ T never = Left (witness function (fun-function T) never)
dec-subtypingᶠⁿ T unknown = Right <:-unknown
dec-subtypingᶠⁿ T (U ⇒ V) = dec-subtypingᶠ T (U ⇒ V)
dec-subtypingᶠⁿ T (U ∩ V) = dec-subtypingᶠ T (U ∩ V)
dec-subtypingᶠⁿ T (U ∪ V) with dec-subtypingᶠⁿ T U
dec-subtypingᶠⁿ T (U ∪ V) | Left (witness t p q) = Left (witness t p (q , fun-¬scalar V T p))
dec-subtypingᶠⁿ T (U ∪ V) | Right p = Right (<:-trans p <:-∪-left)
dec-subtypingⁿ never U = Right <:-never
dec-subtypingⁿ unknown unknown = Right <:-refl
dec-subtypingⁿ unknown U with dec-subtypingᶠⁿ (never ⇒ unknown) U
dec-subtypingⁿ unknown U | Left p = Left (<:-trans-≮: <:-unknown p)
dec-subtypingⁿ unknown U | Right p₁ with dec-subtypingˢⁿ number U
dec-subtypingⁿ unknown U | Right p₁ | Left p = Left (<:-trans-≮: <:-unknown p)
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ with dec-subtypingˢⁿ string U
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Left p = Left (<:-trans-≮: <:-unknown p)
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ with dec-subtypingˢⁿ nil U
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Left p = Left (<:-trans-≮: <:-unknown p)
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ with dec-subtypingˢⁿ boolean U
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ | Left p = Left (<:-trans-≮: <:-unknown p)
dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ | Right p₅ = Right (<:-trans <:-everything (<:-∪-lub p₁ (<:-∪-lub p₂ (<:-∪-lub p₃ (<:-∪-lub p₄ p₅)))))
dec-subtypingⁿ (S ⇒ T) U = dec-subtypingᶠⁿ (S ⇒ T) U
dec-subtypingⁿ (S ∩ T) U = dec-subtypingᶠⁿ (S ∩ T) U
dec-subtypingⁿ (S ∪ T) U with dec-subtypingⁿ S U | dec-subtypingˢⁿ T U
dec-subtypingⁿ (S ∪ T) U | Left p | q = Left (≮:-∪-left p)
dec-subtypingⁿ (S ∪ T) U | Right p | Left q = Left (≮:-∪-right q)
dec-subtypingⁿ (S ∪ T) U | Right p | Right q = Right (<:-∪-lub p q)
dec-subtyping T U with dec-subtypingⁿ (normal T) (normal U)
dec-subtyping T U | Left p = Left (<:-trans-≮: (normalize-<: T) (≮:-trans-<: p (<:-normalize U)))
dec-subtyping T U | Right p = Right (<:-trans (<:-normalize T) (<:-trans p (normalize-<: U)))
-- As a corollary, for saturated functions
-- <:ᵒ coincides with <:, that is F is a subtype of (S ⇒ T) precisely
-- when one of its overloads is.
<:-impl-<:ᵒ : ∀ {F G} → FunType F → Saturated F → FunType G → (F <: G) → (F <:ᵒ G)
<:-impl-<:ᵒ {F} {G} Fᶠ Fˢ Gᶠ F<:G with dec-subtypingˢᶠ Fᶠ Fˢ Gᶠ
<:-impl-<:ᵒ {F} {G} Fᶠ Fˢ Gᶠ F<:G | Left F≮:G = CONTRADICTION (<:-impl-¬≮: F<:G F≮:G)
<:-impl-<:ᵒ {F} {G} Fᶠ Fˢ Gᶠ F<:G | Right F<:ᵒG = F<:ᵒG
| {
"alphanum_fraction": 0.5785267547,
"avg_line_length": 65.7828571429,
"ext": "agda",
"hexsha": "8dc7a44630fa3b8a19e6af5a10e0ed2f9490594e",
"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": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sthagen/Roblox-luau",
"max_forks_repo_path": "prototyping/Properties/DecSubtyping.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
"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": "sthagen/Roblox-luau",
"max_issues_repo_path": "prototyping/Properties/DecSubtyping.agda",
"max_line_length": 442,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Libertus-Lab/luau",
"max_stars_repo_path": "prototyping/Properties/DecSubtyping.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z",
"num_tokens": 5278,
"size": 11512
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.JoinFunc where
module F {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : A → C) (g : B → D) where
fg-glue : (ab : A × B) → left (f (fst ab)) == right (g (snd ab)) :> (C * D)
fg-glue (a , b) = glue (f a , g b)
to : A * B → C * D
to = To.f module M where
module To = PushoutRec (left ∘ f) (right ∘ g) fg-glue
open M public
module _ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} where
_**_[_] : (A → C) → (B → D) → A * B → C * D
f ** g [ ab ] = M.to ab where
module M = F f g
| {
"alphanum_fraction": 0.4735152488,
"avg_line_length": 24.92,
"ext": "agda",
"hexsha": "ee09c161067d566f33339f55efc6ae8bcb0f2819",
"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": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_forks_repo_path": "homotopy/JoinFunc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"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": "UlrikBuchholtz/HoTT-Agda",
"max_issues_repo_path": "homotopy/JoinFunc.agda",
"max_line_length": 102,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/JoinFunc.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 252,
"size": 623
} |
module Function.Multi where
open import Data
open import Data.Tuple
open import Data.Tuple.Raise
open import Data.Tuple.RaiseTypeᵣ
open import Functional
import Lvl
import Lvl.MultiFunctions as Lvl
open import Numeral.Natural
open import Type
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable n : ℕ
infixr 0 _⇉_
-- The type of a multivariate function (nested by repeated application of (_→_)) of different types and levels constructed by a tuple list of types.
-- This is useful when one needs a function of arbitrary length or by arbitrary argument types.
-- Essentially:
-- ((A,B,C,D,..) ⇉ R)
-- = (A → (B → (C → (D → (.. → R)))))
-- = (A → B → C → D → .. → R)
-- Example:
-- open import Syntax.Number
-- f : (Unit{0} , Unit{1} , Unit{2}) ⇉ Unit{3}
-- f <> <> <> = <>
_⇉_ : ∀{ℓ𝓈 : Lvl.Level ^ n} → Types(ℓ𝓈) → Type{ℓ} → Type{ℓ Lvl.⊔ (Lvl.⨆ ℓ𝓈)}
_⇉_ {n = 0} _ B = B
_⇉_ {n = 1} A B = A → B
_⇉_ {n = 𝐒(𝐒(n))} (A , As) B = A → (As ⇉ B)
-- TODO: Does it work with Functional.swap(foldᵣ(_→ᶠ_)) ?
_⇉ᵢₘₚₗ_ : ∀{ℓ𝓈 : Lvl.Level ^ n} → Types(ℓ𝓈) → Type{ℓ} → Type{ℓ Lvl.⊔ (Lvl.⨆ ℓ𝓈)}
_⇉ᵢₘₚₗ_ {n = 0} _ B = B
_⇉ᵢₘₚₗ_ {n = 1} A B = {A} → B
_⇉ᵢₘₚₗ_ {n = 𝐒(𝐒(n))} (A , As) B = {A} → (As ⇉ᵢₘₚₗ B)
_⇉ᵢₙₛₜ_ : ∀{ℓ𝓈 : Lvl.Level ^ n} → Types(ℓ𝓈) → Type{ℓ} → Type{ℓ Lvl.⊔ (Lvl.⨆ ℓ𝓈)}
_⇉ᵢₙₛₜ_ {n = 0} _ B = B
_⇉ᵢₙₛₜ_ {n = 1} A B = ⦃ A ⦄ → B
_⇉ᵢₙₛₜ_ {n = 𝐒(𝐒(n))} (A , As) B = ⦃ A ⦄ → (As ⇉ᵢₙₛₜ B)
| {
"alphanum_fraction": 0.5447811448,
"avg_line_length": 34.5348837209,
"ext": "agda",
"hexsha": "c9369c803cda918da51084e53d9a118cfbdaf2d9",
"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": "Function/Multi.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": "Function/Multi.agda",
"max_line_length": 148,
"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": "Function/Multi.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": 757,
"size": 1485
} |
------------------------------------------------------------------------------
-- Equivalence of definitions of total lists
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LFPs.List where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Nat.UnaryNumbers
------------------------------------------------------------------------------
module LFP where
-- List is a least fixed-point of a functor
-- The functor.
ListF : (D → Set) → D → Set
ListF A xs = xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')
-- List is the least fixed-point of ListF. i.e.
postulate
List : D → Set
-- List is a pre-fixed point of ListF, i.e.
--
-- ListF List ≤ List.
--
-- Peter: It corresponds to the introduction rules.
List-in : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →
List xs
-- The higher-order version.
List-in-ho : {xs : D} → ListF List xs → List xs
-- List is the least pre-fixed point of ListF, i.e.
--
-- ∀ A. ListF A ≤ A ⇒ List ≤ A.
--
-- Peter: It corresponds to the elimination rule of an inductively
-- defined predicate.
List-ind :
(A : D → Set) →
(∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →
∀ {xs} → List xs → A xs
-- Higher-order version.
List-ind-ho :
(A : D → Set) →
(∀ {xs} → ListF A xs → A xs) →
∀ {xs} → List xs → A xs
----------------------------------------------------------------------------
-- List-in and List-in-ho are equivalents
List-in-fo : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →
List xs
List-in-fo = List-in-ho
List-in-ho' : {xs : D} → ListF List xs → List xs
List-in-ho' = List-in-ho
----------------------------------------------------------------------------
-- List-ind and List-ind-ho are equivalents
List-ind-fo :
(A : D → Set) →
(∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →
∀ {xs} → List xs → A xs
List-ind-fo = List-ind-ho
List-ind-ho' :
(A : D → Set) →
(∀ {xs} → ListF A xs → A xs) →
∀ {xs} → List xs → A xs
List-ind-ho' = List-ind
----------------------------------------------------------------------------
-- The data constructors of List.
lnil : List []
lnil = List-in (inj₁ refl)
lcons : ∀ x {xs} → List xs → List (x ∷ xs)
lcons x {xs} Lxs = List-in (inj₂ (x , xs , refl , Lxs))
----------------------------------------------------------------------------
-- The type theoretical induction principle for List.
List-ind' : (A : D → Set) →
A [] →
(∀ x {xs} → A xs → A (x ∷ xs)) →
∀ {xs} → List xs → A xs
List-ind' A A[] is = List-ind A prf
where
prf : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs
prf (inj₁ xs≡[]) = subst A (sym xs≡[]) A[]
prf (inj₂ (x' , xs' , h₁ , Axs')) = subst A (sym h₁) (is x' Axs')
----------------------------------------------------------------------------
-- Example
xs : D
xs = 0' ∷ true ∷ 1' ∷ false ∷ []
xs-List : List xs
xs-List = lcons 0' (lcons true (lcons 1' (lcons false lnil)))
------------------------------------------------------------------------------
module Data where
data List : D → Set where
lnil : List []
lcons : ∀ x {xs} → List xs → List (x ∷ xs)
-- Induction principle.
List-ind : (A : D → Set) →
A [] →
(∀ x {xs} → A xs → A (x ∷ xs)) →
∀ {xs} → List xs → A xs
List-ind A A[] h lnil = A[]
List-ind A A[] h (lcons x Lxs) = h x (List-ind A A[] h Lxs)
----------------------------------------------------------------------------
-- List-in
List-in : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs') →
List xs
List-in {xs} h = case prf₁ prf₂ h
where
prf₁ : xs ≡ [] → List xs
prf₁ xs≡[] = subst List (sym xs≡[]) lnil
prf₂ : ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ List xs' → List xs
prf₂ (x' , xs' , prf , Lxs') = subst List (sym prf) (lcons x' Lxs')
----------------------------------------------------------------------------
-- The fixed-point induction principle for List.
List-ind' :
(A : D → Set) →
(∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') → A xs) →
∀ {xs} → List xs → A xs
List-ind' A h Lxs = List-ind A h₁ h₂ Lxs
where
h₁ : A []
h₁ = h (inj₁ refl)
h₂ : ∀ y {ys} → A ys → A (y ∷ ys)
h₂ y {ys} Ays = h (inj₂ (y , ys , refl , Ays))
| {
"alphanum_fraction": 0.3843252305,
"avg_line_length": 31.1895424837,
"ext": "agda",
"hexsha": "11089e25fc9714c377e6102dc8b0e36c80a1030f",
"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/fixed-points/LFPs/List.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/fixed-points/LFPs/List.agda",
"max_line_length": 79,
"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/fixed-points/LFPs/List.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": 1529,
"size": 4772
} |
{-
https://github.com/mietek/lamport-timestamps
An Agda formalisation of Lamport timestamps.
Made by Miëtek Bak. Published under the MIT X11 license.
-}
module Everything where
import Prelude
-- Processes, clocks, timestamps, messages, and events are defined as abstract interfaces.
import AbstractInterfaces
import BasicConcreteImplementations
-- Lamport’s clock condition yields a strict total order on events across all processes.
import OrdersAndEqualities
| {
"alphanum_fraction": 0.8016877637,
"avg_line_length": 18.96,
"ext": "agda",
"hexsha": "46845e567fe789439016a81bf307a052d75400f7",
"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": "b685baa99230c3d5fd1e41c66d325575b70308c4",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/lamport-timestamps",
"max_forks_repo_path": "Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b685baa99230c3d5fd1e41c66d325575b70308c4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/lamport-timestamps",
"max_issues_repo_path": "Everything.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b685baa99230c3d5fd1e41c66d325575b70308c4",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/lamport-timestamps",
"max_stars_repo_path": "Everything.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 101,
"size": 474
} |
------------------------------------------------------------------------
-- A language of parser equivalence proofs
------------------------------------------------------------------------
-- This module defines yet another set of equivalence relations and
-- preorders for parsers. For symmetric kinds these relations are
-- equalities (compatible equivalence relations) by construction, and
-- they are sound and complete with respect to the previously defined
-- equivalences (see TotalParserCombinators.Congruence.Sound for the
-- soundness proof). This means that parser and language equivalence
-- are also equalities. The related orderings are compatible
-- preorders.
module TotalParserCombinators.Congruence where
open import Codata.Musical.Notation
open import Data.List
open import Data.List.Relation.Binary.BagAndSetEquality
using (bag) renaming (_∼[_]_ to _List-∼[_]_)
open import Data.Maybe hiding (_>>=_)
open import Data.Nat hiding (_^_)
open import Data.Product
open import Data.Vec.Recursive
open import Function
open import Function.Related using (Symmetric-kind; ⌊_⌋)
open import Relation.Binary.PropositionalEquality using (_≡_; _≗_)
open import TotalParserCombinators.Derivative using (D)
open import TotalParserCombinators.CoinductiveEquality as CE
using (_∼[_]c_; _∷_)
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics
hiding ([_-_]_⊛_; [_-_]_>>=_)
infixl 50 [_-_]_⊛_ [_-_-_-_]_⊛_ _<$>_
infix 10 [_-_]_>>=_ [_-_-_-_]_>>=_
infixl 5 _∣_
infix 5 _∷_
infix 4 _∼[_]P_ ∞⟨_⟩_∼[_]P_ _≅P_ _≈P_
infix 3 _∎
infixr 2 _∼⟨_⟩_ _≅⟨_⟩_
------------------------------------------------------------------------
-- Helper functions
flatten₁ : {A : Set} → Maybe (Maybe A ^ 2) → Maybe A
flatten₁ nothing = nothing
flatten₁ (just (m , _)) = m
flatten₂ : {A : Set} → Maybe (Maybe A ^ 2) → Maybe A
flatten₂ nothing = nothing
flatten₂ (just (_ , m)) = m
------------------------------------------------------------------------
-- Equivalence proof programs
mutual
_≅P_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁
p₁ ≅P p₂ = p₁ ∼[ parser ]P p₂
_≈P_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁
p₁ ≈P p₂ = p₁ ∼[ language ]P p₂
data _∼[_]P_ {Tok} :
∀ {R xs₁ xs₂} →
Parser Tok R xs₁ → Kind → Parser Tok R xs₂ → Set₁ where
-- This constructor, which corresponds to CE._∷_, ensures that the
-- relation is complete.
_∷_ : ∀ {k R xs₁ xs₂}
{p₁ : Parser Tok R xs₁}
{p₂ : Parser Tok R xs₂}
(xs₁≈xs₂ : xs₁ List-∼[ k ] xs₂)
(Dp₁≈Dp₂ : ∀ t → ∞ (D t p₁ ∼[ k ]P D t p₂)) →
p₁ ∼[ k ]P p₂
-- Equational reasoning.
_∎ : ∀ {k R xs} (p : Parser Tok R xs) → p ∼[ k ]P p
_∼⟨_⟩_ : ∀ {k R xs₁ xs₂ xs₃}
(p₁ : Parser Tok R xs₁)
{p₂ : Parser Tok R xs₂}
{p₃ : Parser Tok R xs₃}
(p₁≈p₂ : p₁ ∼[ k ]P p₂) (p₂≈p₃ : p₂ ∼[ k ]P p₃) →
p₁ ∼[ k ]P p₃
_≅⟨_⟩_ : ∀ {k R xs₁ xs₂ xs₃}
(p₁ : Parser Tok R xs₁)
{p₂ : Parser Tok R xs₂}
{p₃ : Parser Tok R xs₃}
(p₁≅p₂ : p₁ ≅P p₂) (p₂≈p₃ : p₂ ∼[ k ]P p₃) →
p₁ ∼[ k ]P p₃
sym : ∀ {k : Symmetric-kind} {R xs₁ xs₂}
{p₁ : Parser Tok R xs₁}
{p₂ : Parser Tok R xs₂}
(p₁≈p₂ : p₁ ∼[ ⌊ k ⌋ ]P p₂) → p₂ ∼[ ⌊ k ⌋ ]P p₁
-- Congruences.
return : ∀ {k R} {x₁ x₂ : R}
(x₁≡x₂ : x₁ ≡ x₂) → return x₁ ∼[ k ]P return x₂
fail : ∀ {k R} → fail {R = R} ∼[ k ]P fail {R = R}
token : ∀ {k} → token ∼[ k ]P token
_∣_ : ∀ {k R xs₁ xs₂ xs₃ xs₄}
{p₁ : Parser Tok R xs₁}
{p₂ : Parser Tok R xs₂}
{p₃ : Parser Tok R xs₃}
{p₄ : Parser Tok R xs₄}
(p₁≈p₃ : p₁ ∼[ k ]P p₃) (p₂≈p₄ : p₂ ∼[ k ]P p₄) →
p₁ ∣ p₂ ∼[ k ]P p₃ ∣ p₄
_<$>_ : ∀ {k R₁ R₂} {f₁ f₂ : R₁ → R₂} {xs₁ xs₂}
{p₁ : Parser Tok R₁ xs₁}
{p₂ : Parser Tok R₁ xs₂}
(f₁≗f₂ : f₁ ≗ f₂) (p₁≈p₂ : p₁ ∼[ k ]P p₂) →
f₁ <$> p₁ ∼[ k ]P f₂ <$> p₂
[_-_]_⊛_ :
∀ {k R₁ R₂} xs₁xs₂ fs₁fs₂ →
let xs₁ = flatten₁ xs₁xs₂; xs₂ = flatten₂ xs₁xs₂
fs₁ = flatten₁ fs₁fs₂; fs₂ = flatten₂ fs₁fs₂ in
{p₁ : ∞⟨ xs₁ ⟩Parser Tok (R₁ → R₂) (flatten fs₁)}
{p₂ : ∞⟨ fs₁ ⟩Parser Tok R₁ (flatten xs₁)}
{p₃ : ∞⟨ xs₂ ⟩Parser Tok (R₁ → R₂) (flatten fs₂)}
{p₄ : ∞⟨ fs₂ ⟩Parser Tok R₁ (flatten xs₂)}
(p₁≈p₃ : ∞⟨ xs₁xs₂ ⟩ p₁ ∼[ k ]P p₃)
(p₂≈p₄ : ∞⟨ fs₁fs₂ ⟩ p₂ ∼[ k ]P p₄) →
p₁ ⊛ p₂ ∼[ k ]P p₃ ⊛ p₄
[_-_]_>>=_ :
∀ {k R₁ R₂} (f₁f₂ : Maybe (Maybe (R₁ → List R₂) ^ 2)) xs₁xs₂ →
let f₁ = flatten₁ f₁f₂; f₂ = flatten₂ f₁f₂
xs₁ = flatten₁ xs₁xs₂; xs₂ = flatten₂ xs₁xs₂ in
{p₁ : ∞⟨ f₁ ⟩Parser Tok R₁ (flatten xs₁)}
{p₂ : (x : R₁) → ∞⟨ xs₁ ⟩Parser Tok R₂ (apply f₁ x)}
{p₃ : ∞⟨ f₂ ⟩Parser Tok R₁ (flatten xs₂)}
{p₄ : (x : R₁) → ∞⟨ xs₂ ⟩Parser Tok R₂ (apply f₂ x)}
(p₁≈p₃ : ∞⟨ f₁f₂ ⟩ p₁ ∼[ k ]P p₃)
(p₂≈p₄ : ∀ x → ∞⟨ xs₁xs₂ ⟩ p₂ x ∼[ k ]P p₄ x) →
p₁ >>= p₂ ∼[ k ]P p₃ >>= p₄
nonempty : ∀ {k R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂}
(p₁≈p₂ : p₁ ∼[ k ]P p₂) → nonempty p₁ ∼[ k ]P nonempty p₂
cast : ∀ {k R xs₁ xs₂ xs₁′ xs₂′}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂}
{xs₁≈xs₁′ : xs₁ List-∼[ bag ] xs₁′}
{xs₂≈xs₂′ : xs₂ List-∼[ bag ] xs₂′}
(p₁≈p₂ : p₁ ∼[ k ]P p₂) →
cast xs₁≈xs₁′ p₁ ∼[ k ]P cast xs₂≈xs₂′ p₂
-- Certain proofs can be coinductive if both sides are delayed.
∞⟨_⟩_∼[_]P_ :
∀ {Tok R xs₁ xs₂} {A : Set} (m₁m₂ : Maybe (Maybe A ^ 2)) →
∞⟨ flatten₁ m₁m₂ ⟩Parser Tok R xs₁ → Kind →
∞⟨ flatten₂ m₁m₂ ⟩Parser Tok R xs₂ → Set₁
∞⟨ nothing ⟩ p₁ ∼[ k ]P p₂ = ∞ (♭ p₁ ∼[ k ]P ♭ p₂)
∞⟨ just _ ⟩ p₁ ∼[ k ]P p₂ = ♭? p₁ ∼[ k ]P ♭? p₂
------------------------------------------------------------------------
-- Some derived combinators
[_-_-_-_]_⊛_ :
∀ {k Tok R₁ R₂} xs₁ xs₂ fs₁ fs₂
{p₁ : ∞⟨ xs₁ ⟩Parser Tok (R₁ → R₂) (flatten fs₁)}
{p₂ : ∞⟨ fs₁ ⟩Parser Tok R₁ (flatten xs₁)}
{p₃ : ∞⟨ xs₂ ⟩Parser Tok (R₁ → R₂) (flatten fs₂)}
{p₄ : ∞⟨ fs₂ ⟩Parser Tok R₁ (flatten xs₂)} →
♭? p₁ ∼[ k ]P ♭? p₃ → ♭? p₂ ∼[ k ]P ♭? p₄ → p₁ ⊛ p₂ ∼[ k ]P p₃ ⊛ p₄
[ xs₁ - xs₂ - fs₁ - fs₂ ] p₁≈p₃ ⊛ p₂≈p₄ =
[ just (xs₁ , xs₂) - just (fs₁ , fs₂) ] p₁≈p₃ ⊛ p₂≈p₄
[_-_-_-_]_>>=_ :
∀ {k Tok R₁ R₂} (f₁ f₂ : Maybe (R₁ → List R₂)) xs₁ xs₂
{p₁ : ∞⟨ f₁ ⟩Parser Tok R₁ (flatten xs₁)}
{p₂ : (x : R₁) → ∞⟨ xs₁ ⟩Parser Tok R₂ (apply f₁ x)}
{p₃ : ∞⟨ f₂ ⟩Parser Tok R₁ (flatten xs₂)}
{p₄ : (x : R₁) → ∞⟨ xs₂ ⟩Parser Tok R₂ (apply f₂ x)} →
♭? p₁ ∼[ k ]P ♭? p₃ → (∀ x → ♭? (p₂ x) ∼[ k ]P ♭? (p₄ x)) →
p₁ >>= p₂ ∼[ k ]P p₃ >>= p₄
[ f₁ - f₂ - xs₁ - xs₂ ] p₁≈p₃ >>= p₂≈p₄ =
[ just (f₁ , f₂) - just (xs₁ , xs₂) ] p₁≈p₃ >>= p₂≈p₄
------------------------------------------------------------------------
-- Completeness
complete : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁}
{p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ] p₂ → p₁ ∼[ k ]P p₂
complete = complete′ ∘ CE.complete
where
complete′ : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁}
{p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ]c p₂ → p₁ ∼[ k ]P p₂
complete′ (xs₁≈xs₂ ∷ Dp₁≈Dp₂) =
xs₁≈xs₂ ∷ λ t → ♯ complete′ (♭ (Dp₁≈Dp₂ t))
| {
"alphanum_fraction": 0.4891952804,
"avg_line_length": 36.2644230769,
"ext": "agda",
"hexsha": "1b931f8ffe5ab413a9fc40bf5daa62f3bb437db9",
"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/Congruence.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/Congruence.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/Congruence.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": 3188,
"size": 7543
} |
module Logics.Or where
open import Function
open import Logics.And
------------------------------------------------------------------------
-- definitions
infixl 4 _∨_
data _∨_ (P Q : Set) : Set where
∨-intro₀ : P → P ∨ Q
∨-intro₁ : Q → P ∨ Q
------------------------------------------------------------------------
-- internal stuffs
private
p→r+q→r+p∨q=r : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R
p→r+q→r+p∨q=r pr _ (∨-intro₀ p) = pr p
p→r+q→r+p∨q=r _ qr (∨-intro₁ q) = qr q
∨-comm′ : ∀ {P Q} → (P ∨ Q) → (Q ∨ P)
∨-comm′ (∨-intro₀ p) = ∨-intro₁ p
∨-comm′ (∨-intro₁ q) = ∨-intro₀ q
∨-assoc₀ : ∀ {P Q R} → ((P ∨ Q) ∨ R) → (P ∨ (Q ∨ R))
∨-assoc₀ (∨-intro₀ (∨-intro₀ x)) = ∨-intro₀ x
∨-assoc₀ (∨-intro₀ (∨-intro₁ x)) = ∨-intro₁ $ ∨-intro₀ x
∨-assoc₀ (∨-intro₁ x) = ∨-intro₁ $ ∨-intro₁ x
∨-assoc₁ : ∀ {P Q R} → (P ∨ (Q ∨ R)) → ((P ∨ Q) ∨ R)
∨-assoc₁ (∨-intro₀ x) = ∨-intro₀ $ ∨-intro₀ x
∨-assoc₁ (∨-intro₁ (∨-intro₀ x)) = ∨-intro₀ $ ∨-intro₁ x
∨-assoc₁ (∨-intro₁ (∨-intro₁ x)) = ∨-intro₁ x
∨-elim : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R
∨-elim = p→r+q→r+p∨q=r
∨-comm : ∀ {P Q} → (P ∨ Q) ⇔ (Q ∨ P)
∨-comm = ∧-intro ∨-comm′ ∨-comm′
∨-assoc : ∀ {P Q R} → (P ∨ (Q ∨ R)) ⇔ ((P ∨ Q) ∨ R)
∨-assoc = ∧-intro ∨-assoc₁ ∨-assoc₀
------------------------------------------------------------------------
-- public aliases
or-elim : ∀ {P Q n} {R : Set n} → (P → R) → (Q → R) → (P ∨ Q) → R
or-elim = ∨-elim
or-comm : ∀ {P Q} → (P ∨ Q) ⇔ (Q ∨ P)
or-comm = ∨-comm
or-assoc : ∀ {P Q R} → (P ∨ (Q ∨ R)) ⇔ ((P ∨ Q) ∨ R)
or-assoc = ∨-assoc
| {
"alphanum_fraction": 0.3891992551,
"avg_line_length": 27.775862069,
"ext": "agda",
"hexsha": "9edc424100a393a68869bdbf3aafafd26a70e512",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Logics/Or.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Logics/Or.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Logics/Or.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 776,
"size": 1611
} |
{-# OPTIONS --without-K #-}
module function.isomorphism.coherent where
open import sum
open import equality.core
open import equality.calculus
open import equality.reasoning
open import function.core
open import function.isomorphism.core
open import function.overloading
open import overloading.core
coherent : ∀ {i j} {X : Set i}{Y : Set j} → X ≅ Y → Set _
coherent f = ∀ x → ap to (iso₁ x) ≡ iso₂ (to x)
-- this definition says that the two possible proofs that
-- to (from (to x)) ≡ to x
-- are equal
where
open _≅_ f
coherent' : ∀ {i j} {X : Set i}{Y : Set j} → X ≅ Y → Set _
coherent' f = ∀ y → ap from (iso₂ y) ≡ iso₁ (from y)
where
open _≅_ f
-- coherent isomorphisms
_≅'_ : ∀ {i j} → (X : Set i)(Y : Set j) → Set _
X ≅' Y = Σ (X ≅ Y) coherent
instance
iso'-is-fun : ∀ {i j}{X : Set i}{Y : Set j}
→ Coercion (X ≅' Y) (X → Y)
iso'-is-fun = record
{ coerce = λ isom → apply (proj₁ isom) }
iso'-is-iso : ∀ {i j}{X : Set i}{Y : Set j}
→ Coercion (X ≅' Y) (X ≅ Y)
iso'-is-iso = record
{ coerce = proj₁ }
-- technical lemma: substiting a fixpoint proof into itself is like
-- applying the function
lem-subst-fixpoint : ∀ {i}{X : Set i}
(f : X → X)(x : X)
(p : f x ≡ x)
→ subst (λ x → f x ≡ x) (sym p) p
≡ ap f p
lem-subst-fixpoint {i}{X} f x p = begin
subst (λ x → f x ≡ x) (p ⁻¹) p
≡⟨ lem (f x) (sym p) ⟩
ap f (sym (sym p)) · p · sym p
≡⟨ ap (λ z → ap f z · p · sym p)
(double-inverse p) ⟩
ap f p · p · sym p
≡⟨ associativity (ap f p) p (sym p) ⟩
ap f p · (p · sym p)
≡⟨ ap (λ z → ap f p · z) (left-inverse p) ⟩
ap f p · refl
≡⟨ left-unit (ap f p) ⟩
ap f p
∎
where
open ≡-Reasoning
lem : (y : X) (q : x ≡ y)
→ subst (λ z → f z ≡ z) q p
≡ ap f (sym q) · p · q
lem .x refl = sym (left-unit p)
lem-whiskering : ∀ {i} {X : Set i}
(f : X → X) (H : (x : X) → f x ≡ x)
(x : X) → ap f (H x) ≡ H (f x)
lem-whiskering f H x = begin
ap f (H x)
≡⟨ sym (lem-subst-fixpoint f x (H x)) ⟩
subst (λ z → f z ≡ z) (sym (H x)) (H x)
≡⟨ ap' H (sym (H x)) ⟩
H (f x)
∎
where
open ≡-Reasoning
lem-homotopy-nat : ∀ {i j}{X : Set i}{Y : Set j}
{x x' : X}{f g : X → Y}
(H : (x : X) → f x ≡ g x) (p : x ≡ x')
→ H x · ap g p ≡ ap f p · H x'
lem-homotopy-nat H refl = left-unit _
co-coherence : ∀ {i j}{X : Set i}{Y : Set j}
(isom : X ≅ Y)
→ coherent isom
→ coherent' isom
co-coherence (iso f g H K) coherence y =
subst (λ z → ap g (K z) ≡ H (g z)) (K y) lem
where
open ≡-Reasoning
lem : ap g (K (f (g y)))
≡ H (g (f (g y)))
lem = begin
ap g (K (f (g y)))
≡⟨ ap (ap g) (sym (coherence (g y))) ⟩
ap g (ap f (H (g y)))
≡⟨ ap-hom f g _ ⟩
ap (g ∘ f) (H (g y))
≡⟨ lem-whiskering (g ∘ f) H (g y) ⟩
H (g (f (g y)))
∎
sym≅' : ∀ {i j}{X : Set i}{Y : Set j}
→ X ≅' Y → Y ≅' X
sym≅' (isom , γ) = sym≅ isom , co-coherence isom γ
--- Vogt's lemma. See http://ncatlab.org/nlab/show/homotopy+equivalence
vogt-lemma : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y)
→ let open _≅_ isom
in Σ ((y : Y) → to (from y) ≡ y) λ iso' →
coherent (iso to from iso₁ iso')
vogt-lemma {X = X}{Y = Y} isom = K' , γ
where
open _≅_ isom
renaming (to to f ; from to g ; iso₁ to H ; iso₂ to K)
-- Outline of the proof
-- --------------------
--
-- We want to find a homotopy K' : f g → id such that f K' ≡ H f.
--
-- To do so, we first prove that the following diagram of
-- homotopies:
--
-- f H g f
-- f g f g f ---------> f g f
-- | |
-- f g K f | | K f
-- | |
-- v v
-- f g f -------------> f
-- f H
--
-- commutes. We then observe that f appears on the right side of
-- every element in the diagram, except the bottom row, so if we
-- define:
--
-- K' = (f g K) ⁻¹ · (f H g f) · (K f)
--
-- we get that K' f must be equal to the bottom row, which is
-- exactly the required coherence condition.
open ≡-Reasoning
-- the diagram above commutes
lem : (x : X)
→ ap f (H (g (f x))) · K (f x)
≡ ap (f ∘ g) (K (f x)) · ap f (H x)
lem x = begin
ap f (H (g (f x))) · K (f x)
≡⟨ ap (λ z → ap f z · K (f x))
(sym (lem-whiskering (g ∘ f) H x)) ⟩
ap f (ap (g ∘ f) (H x)) · K (f x)
≡⟨ ap (λ z → z · K (f x))
(ap-hom (g ∘ f) f (H x)) ⟩
ap (f ∘ g ∘ f) (H x) · K (f x)
≡⟨ sym (lem-homotopy-nat (λ x → K (f x)) (H x)) ⟩
K (f (g (f x))) · ap f (H x)
≡⟨ ap (λ z → z · ap f (H x))
(sym (lem-whiskering (f ∘ g) K (f x))) ⟩
ap (f ∘ g) (K (f x)) · ap f (H x)
∎
K' : (y : Y) → f (g y) ≡ y
K' y = ap (f ∘ g) (sym (K y))
· ap f (H (g y))
· K y
iso' = iso f g H K'
-- now we can just compute using the groupoid laws
γ : coherent iso'
γ x = sym $ begin
K' (f x)
≡⟨ refl ⟩
ap (f ∘ g) (sym (K (f x))) ·
ap f (H (g (f x))) · K (f x)
≡⟨ associativity (ap (f ∘ g) (sym (K (f x))))
(ap f (H (g (f x))))
(K (f x)) ⟩
ap (f ∘ g) (sym (K (f x))) ·
(ap f (H (g (f x))) · K (f x))
≡⟨ ap (λ z → ap (f ∘ g) (sym (K (f x))) · z) (lem x) ⟩
ap (f ∘ g) (sym (K (f x))) ·
(ap (f ∘ g) (K (f x)) · ap f (H x))
≡⟨ ap (λ z → z · (ap (f ∘ g) (K (f x)) · ap f (H x)))
(ap-inv (f ∘ g) (K (f x))) ⟩
sym (ap (f ∘ g) (K (f x))) ·
(ap (f ∘ g) (K (f x)) · ap f (H x))
≡⟨ sym (associativity (sym (ap (f ∘ g) (K (f x))))
(ap (f ∘ g) (K (f x)))
(ap f (H x))) ⟩
( sym (ap (f ∘ g) (K (f x))) ·
ap (f ∘ g) (K (f x)) ) ·
ap f (H x)
≡⟨ ap (λ z → z · ap f (H x))
(right-inverse (ap (f ∘ g) (K (f x)))) ⟩
refl · ap f (H x)
≡⟨ right-unit (ap f (H x)) ⟩
ap f (H x)
∎
≅⇒≅' : ∀ {i j} {X : Set i}{Y : Set j} → X ≅ Y → X ≅' Y
≅⇒≅' {X = X}{Y = Y} isom = iso to from iso₁ (proj₁ v) , proj₂ v
where
open _≅_ isom
open import sum
abstract
v : Σ ((y : Y) → to (from y) ≡ y) λ iso₂'
→ coherent (iso to from iso₁ iso₂')
v = vogt-lemma isom
| {
"alphanum_fraction": 0.4127126231,
"avg_line_length": 30.7431192661,
"ext": "agda",
"hexsha": "ae9371af346d87a060079242c4e12f933a7e8791",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "function/isomorphism/coherent.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/function/isomorphism/coherent.agda",
"max_line_length": 71,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "function/isomorphism/coherent.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 2668,
"size": 6702
} |
open import Prelude
module Implicits.Improved.Stack.Expressiveness where
open import Coinduction
open import Data.Fin.Substitution
open import Implicits.Oliveira.Types
open import Implicits.Oliveira.Terms
open import Implicits.Oliveira.Contexts
open import Implicits.Oliveira.Substitutions
open import Implicits.Oliveira.Deterministic.Resolution as D
open import Implicits.Oliveira.Ambiguous.Resolution as A
open import Implicits.Improved.Stack.Resolution as F
open import Implicits.Improved.Infinite.Resolution as ∞
module Finite⊆Infinite where
p : ∀ {ν} {a} {Δ : ICtx ν} {s} → Δ F.& s ⊢ᵣ a → Δ ∞.⊢ᵣ a
p (r-simp a a↓τ) = r-simp a (lem a↓τ)
where
lem : ∀ {ν} {a τ r} {Δ : ICtx ν} {r∈Δ : r List.∈ Δ} {s : Stack Δ} →
Δ F.& s , r∈Δ ⊢ a ↓ τ → Δ ∞.⊢ a ↓ τ
lem (i-simp τ) = i-simp τ
lem (i-iabs _ ⊢ᵣa b↓τ) = i-iabs (♯ (p ⊢ᵣa)) (lem b↓τ)
lem (i-tabs b a[/b]↓τ) = i-tabs b (lem a[/b]↓τ)
p (r-iabs x) = r-iabs (p x)
p (r-tabs x) = r-tabs (p x)
module Finite⊆OliveiraAmbiguous where
p : ∀ {ν} {a} {Δ : ICtx ν} {s} → Δ F.& s ⊢ᵣ a → Δ A.⊢ᵣ a
p (r-simp a a↓τ) = lem a↓τ (r-ivar a)
where
lem : ∀ {ν} {a r τ} {Δ : ICtx ν} {r∈Δ : r List.∈ Δ} {s} →
Δ F.& s , r∈Δ ⊢ a ↓ τ → Δ A.⊢ᵣ a → Δ A.⊢ᵣ simpl τ
lem (i-simp τ) K⊢ᵣτ = K⊢ᵣτ
lem (i-iabs _ ⊢ᵣa b↓τ) K⊢ᵣa⇒b = lem b↓τ (r-iapp K⊢ᵣa⇒b (p ⊢ᵣa))
lem (i-tabs b a[/b]↓τ) K⊢ᵣ∀a = lem a[/b]↓τ (r-tapp b K⊢ᵣ∀a)
p (r-iabs x) = r-iabs (p x)
p (r-tabs x) = r-tabs (p x)
module OliveiraDeterministic⊆Finite where
open FirstLemmas
-- Oliveira's termination condition is part of the well-formdness of types
-- So we assume here that ⊢term x holds for all types x
p : ∀ {ν} {a : Type ν} {Δ : ICtx ν} s →
(∀ {μ} (x : Type μ) → ⊢term x) → Δ D.⊢ᵣ a → Δ F.& s ⊢ᵣ a
p s term (r-simp {ρ = r} x r↓a) =
r-simp (proj₁ $ FirstLemmas.first⟶∈ x) (lem (proj₁ $ first⟶∈ x) s r↓a)
where
lem : ∀ {ν r'} {Δ : ICtx ν} (r∈Δ : r' List.∈ Δ) {a r} s → Δ D.⊢ r ↓ a → Δ F.& s , r∈Δ ⊢ r ↓ a
lem r∈Δ s (i-simp a) = i-simp a
lem r∈Δ s (i-iabs {ρ₁ = ρ₁} ⊢ᵣρ₁ ρ₂↓τ) =
i-iabs (push< s r∈Δ {!!}) (p (s push ρ₁ for r∈Δ) term ⊢ᵣρ₁) (lem r∈Δ s ρ₂↓τ)
lem r∈Δ s (i-tabs b x₁) = i-tabs b (lem r∈Δ s x₁)
p s term (r-iabs ρ₁ {ρ₂ = ρ₂} x) = r-iabs (p (s prepend ρ₂) term x)
p s term (r-tabs x) = r-tabs (p (stack-weaken s) term x)
| {
"alphanum_fraction": 0.5660059047,
"avg_line_length": 39.5166666667,
"ext": "agda",
"hexsha": "9f3afe4176fdba102979efd8f01f5501ff1095e3",
"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/Stack/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/Stack/Expressiveness.agda",
"max_line_length": 99,
"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/Stack/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": 1149,
"size": 2371
} |
module PointedFrac where
open import Data.Sum
open import Data.Product
record ∙_ (A : Set) : Set where
constructor ⇡
field
focus : A
open ∙_
-- Paths between values---identical to dynamic semantics?
data _⟷_ : {A B : Set} → ∙ A → ∙ B → Set1 where
id : {A : Set} → (x : A) → (⇡ x) ⟷ (⇡ x)
swap₊₁ : {A B : Set} → {x : A} → _⟷_ {A ⊎ B} {B ⊎ A} (⇡ (inj₁ x)) (⇡ (inj₂ x))
swap₊₂ : {A B : Set} → {y : B} → _⟷_ {A ⊎ B} {B ⊎ A} (⇡ (inj₂ y)) (⇡ (inj₁ y))
swap× : {A B : Set} → {x : A} → {y : B} → ⇡ (x , y) ⟷ ⇡ (y , x)
-- ...and so on
-- shorter arrow for a shorter definition!
data _↔_ : Set → Set → Set1 where
id : {A : Set} → A ↔ A
swap₊ : {A B : Set} → (A ⊎ B) ↔ (B ⊎ A)
swap× : {A B : Set} → (A × B) ↔ (B × A)
-- Theorem, equivalent to stepping: if c : A ↔ B and v : A, then there exists v' : B and c' : (∙ v) ⟷ (∙ v')
eval : {A B : Set} → (A ↔ B) → (v : A) → Σ[ v' ∈ B ] ((⇡ v) ⟷ (⇡ v'))
eval id v = v , id v
eval swap₊ (inj₁ x) = inj₂ x , swap₊₁
eval swap₊ (inj₂ y) = inj₁ y , swap₊₂
eval swap× (x , y) = (y , x) , swap×
-- Theorem, equivalent to backwards stepping:
-- if c : A ↔ B and v' : B, then there exists v : A and c' : (∙ v) ⟷ (∙ v')
evalB : {A B : Set} → (A ↔ B) → (v' : B) → Σ[ v ∈ A ] ((⇡ v) ⟷ (⇡ v'))
evalB id v = v , id v
evalB swap₊ (inj₁ x) = inj₂ x , swap₊₂
evalB swap₊ (inj₂ y) = inj₁ y , swap₊₁
evalB swap× (x , y) = (y , x) , swap×
-- if c : A ↔ B and v : A, then evalB c (eval c v) ⟷ v
right-inv : {A B : Set} → (c : A ↔ B) → (v : A) → ⇡ (proj₁ (evalB c (proj₁ (eval c v)))) ⟷ ⇡ v
right-inv id v = id v
right-inv swap₊ (inj₁ x) = id (inj₁ x)
right-inv swap₊ (inj₂ y) = id (inj₂ y)
right-inv swap× v = id v
-- left-inv should be just as easy.
-- we should also be able to make a statement about proj₂ associated with back-and-forth
-- and create a function that maps c to its inverse, and 'prove' eval c = evalB @ inverse c
-- "forget" the extra structure
↓ : {A B : Set} → {x : A} → {y : B} → (⇡ x) ⟷ (⇡ y) → A ↔ B
↓ {A} {.A} {x} (id .x) = id
↓ swap₊₁ = swap₊
↓ swap₊₂ = swap₊
↓ swap× = swap×
| {
"alphanum_fraction": 0.5082846004,
"avg_line_length": 33.0967741935,
"ext": "agda",
"hexsha": "5e5db90c8ba503142c58fbeaf7ada8d5adceed2b",
"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": "PointedFrac.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": "PointedFrac.agda",
"max_line_length": 108,
"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": "PointedFrac.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": 931,
"size": 2052
} |
{-# OPTIONS --without-K --exact-split #-}
module localizations-rings where
import subrings
open subrings public
is-invertible-Ring :
{l1 : Level} (R : Ring l1) (x : type-Ring R) → UU l1
is-invertible-Ring R =
is-invertible-Monoid (multiplicative-monoid-Ring R)
is-prop-is-invertible-Ring :
{l1 : Level} (R : Ring l1) (x : type-Ring R) →
is-prop (is-invertible-Ring R x)
is-prop-is-invertible-Ring R =
is-prop-is-invertible-Monoid (multiplicative-monoid-Ring R)
--------------------------------------------------------------------------------
{- We introduce homomorphism that invert specific elements -}
inverts-element-hom-Ring :
{l1 l2 : Level} (R1 : Ring l1) (R2 : Ring l2) (x : type-Ring R1) →
(f : hom-Ring R1 R2) → UU l2
inverts-element-hom-Ring R1 R2 x f =
is-invertible-Ring R2 (map-hom-Ring R1 R2 f x)
is-prop-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → is-prop (inverts-element-hom-Ring R S x f)
is-prop-inverts-element-hom-Ring R S x f =
is-prop-is-invertible-Ring S (map-hom-Ring R S f x)
inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → inverts-element-hom-Ring R S x f → type-Ring S
inv-inverts-element-hom-Ring R S x f H = pr1 H
is-left-inverse-inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
Id ( mul-Ring S
( inv-inverts-element-hom-Ring R S x f H)
( map-hom-Ring R S f x))
( unit-Ring S)
is-left-inverse-inv-inverts-element-hom-Ring R S x f H = pr1 (pr2 H)
is-right-inverse-inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
Id ( mul-Ring S
( map-hom-Ring R S f x)
( inv-inverts-element-hom-Ring R S x f H))
( unit-Ring S)
is-right-inverse-inv-inverts-element-hom-Ring R S x f H = pr2 (pr2 H)
inverts-element-comp-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(g : hom-Ring S T) (f : hom-Ring R S) → inverts-element-hom-Ring R S x f →
inverts-element-hom-Ring R T x (comp-hom-Ring R S T g f)
inverts-element-comp-hom-Ring R S T x g f H =
pair
( map-hom-Ring S T g (inv-inverts-element-hom-Ring R S x f H))
( pair
( ( inv
( preserves-mul-hom-Ring S T g
( inv-inverts-element-hom-Ring R S x f H)
( map-hom-Ring R S f x))) ∙
( ( ap
( map-hom-Ring S T g)
( is-left-inverse-inv-inverts-element-hom-Ring R S x f H)) ∙
( preserves-unit-hom-Ring S T g)))
( ( inv
( preserves-mul-hom-Ring S T g
( map-hom-Ring R S f x)
( inv-inverts-element-hom-Ring R S x f H))) ∙
( ( ap
( map-hom-Ring S T g)
( is-right-inverse-inv-inverts-element-hom-Ring R S x f H)) ∙
( preserves-unit-hom-Ring S T g))))
{- We state the universal property of the localization of a Ring at a single
element x ∈ R. -}
precomp-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
hom-Ring S T → Σ (hom-Ring R T) (inverts-element-hom-Ring R T x)
precomp-universal-property-localization-Ring R S T x f H g =
pair (comp-hom-Ring R S T g f) (inverts-element-comp-hom-Ring R S T x g f H)
universal-property-localization-Ring :
(l : Level) {l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → inverts-element-hom-Ring R S x f → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-localization-Ring l R S x f H =
(T : Ring l) →
is-equiv (precomp-universal-property-localization-Ring R S T x f H)
unique-extension-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
is-contr
(Σ (hom-Ring S T) (λ g → htpy-hom-Ring R T (comp-hom-Ring R S T g f) h))
unique-extension-universal-property-localization-Ring R S T x f H up-f h K =
is-contr-equiv'
( fib (precomp-universal-property-localization-Ring R S T x f H) (pair h K))
( equiv-tot ( λ g →
( equiv-htpy-hom-Ring-eq R T (comp-hom-Ring R S T g f) h) ∘e
( equiv-Eq-total-subtype-eq
( is-prop-inverts-element-hom-Ring R T x)
( precomp-universal-property-localization-Ring R S T x f H g)
( pair h K))))
( is-contr-map-is-equiv (up-f T) (pair h K))
center-unique-extension-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
Σ (hom-Ring S T) (λ g → htpy-hom-Ring R T (comp-hom-Ring R S T g f) h)
center-unique-extension-universal-property-localization-Ring R S T x f H up-f h K =
center
( unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
map-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) → hom-Ring S T
map-universal-property-localization-Ring R S T x f H up-f h K =
pr1 ( center-unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
htpy-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
(up-f : universal-property-localization-Ring l3 R S x f H) →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
htpy-hom-Ring R T (comp-hom-Ring R S T (map-universal-property-localization-Ring R S T x f H up-f h K) f) h
htpy-universal-property-localization-Ring R S T x f H up-f h K =
pr2 ( center-unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
{- We show that the type of localizations of a ring R at an element x is
contractible. -}
is-equiv-up-localization-up-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (inverts-f : inverts-element-hom-Ring R S x f) →
(g : hom-Ring R T) (inverts-g : inverts-element-hom-Ring R T x g) →
(h : hom-Ring S T) (H : htpy-hom-Ring R T (comp-hom-Ring R S T h f) g) →
({l : Level} → universal-property-localization-Ring l R S x f inverts-f) →
({l : Level} → universal-property-localization-Ring l R T x g inverts-g) →
is-iso-hom-Ring S T h
is-equiv-up-localization-up-localization-Ring R S T x f inverts-f g inverts-g h H up-f up-g = {!is-iso-is-equiv-hom-Ring!}
--------------------------------------------------------------------------------
{- We introduce homomorphisms that invert all elements of a subset of a ring -}
inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R) →
(f : hom-Ring R S) → UU (l1 ⊔ l2 ⊔ l3)
inverts-subset-hom-Ring R S P f =
(x : type-Ring R) (p : type-Prop (P x)) → inverts-element-hom-Ring R S x f
is-prop-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R) →
(f : hom-Ring R S) → is-prop (inverts-subset-hom-Ring R S P f)
is-prop-inverts-subset-hom-Ring R S P f =
is-prop-Π (λ x → is-prop-Π (λ p → is-prop-inverts-element-hom-Ring R S x f))
inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) → type-Ring S
inv-inverts-subset-hom-Ring R S P f H x p =
inv-inverts-element-hom-Ring R S x f (H x p)
is-left-inverse-inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) →
Id (mul-Ring S (inv-inverts-subset-hom-Ring R S P f H x p) (map-hom-Ring R S f x)) (unit-Ring S)
is-left-inverse-inv-inverts-subset-hom-Ring R S P f H x p =
is-left-inverse-inv-inverts-element-hom-Ring R S x f (H x p)
is-right-inverse-inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) →
Id (mul-Ring S (map-hom-Ring R S f x) (inv-inverts-subset-hom-Ring R S P f H x p)) (unit-Ring S)
is-right-inverse-inv-inverts-subset-hom-Ring R S P f H x p =
is-right-inverse-inv-inverts-element-hom-Ring R S x f (H x p)
inverts-subset-comp-hom-Ring :
{l1 l2 l3 l4 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3)
(P : subset-Ring l4 R) (g : hom-Ring S T) (f : hom-Ring R S) →
inverts-subset-hom-Ring R S P f →
inverts-subset-hom-Ring R T P (comp-hom-Ring R S T g f)
inverts-subset-comp-hom-Ring R S T P g f H x p =
inverts-element-comp-hom-Ring R S T x g f (H x p)
{- We state the universal property of the localization of a Ring at a subset
of R. -}
precomp-universal-property-localization-subset-Ring :
{l1 l2 l3 l4 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3)
(P : subset-Ring l4 R) →
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f) →
hom-Ring S T → Σ (hom-Ring R T) (inverts-subset-hom-Ring R T P)
precomp-universal-property-localization-subset-Ring R S T P f H g =
pair (comp-hom-Ring R S T g f) (inverts-subset-comp-hom-Ring R S T P g f H)
universal-property-localization-subset-Ring :
(l : Level) {l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2)
(P : subset-Ring l3 R) (f : hom-Ring R S) →
inverts-subset-hom-Ring R S P f → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-localization-subset-Ring l R S P f H =
(T : Ring l) →
is-equiv (precomp-universal-property-localization-subset-Ring R S T P f H)
| {
"alphanum_fraction": 0.6197770238,
"avg_line_length": 45.2412280702,
"ext": "agda",
"hexsha": "4aab197725fc3d963bcb4d4e3f8c37467bb6dac2",
"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/localizations-rings.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/localizations-rings.agda",
"max_line_length": 122,
"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/localizations-rings.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": 3810,
"size": 10315
} |
module reflnat where
data ℕ : Set where
Z : ℕ
S : ℕ -> ℕ
_+_ : ℕ -> ℕ -> ℕ
n + Z = n
n + S m = S (n + m)
infixr 10 _+_
infixr 20 _*_
_*_ : ℕ -> ℕ -> ℕ
n * Z = Z
n * S m = n * m + n
data Bool : Set where
tt : Bool
ff : Bool
data ⊤ : Set where
true : ⊤
data ⊥ : Set where
Atom : Bool -> Set
Atom tt = ⊤
Atom ff = ⊥
_==Bool_ : ℕ -> ℕ -> Bool
Z ==Bool Z = tt
(S n) ==Bool (S m) = n ==Bool m
_ ==Bool _ = ff
-- Z ==Bool (S _) = ff
-- (S _) ==Bool Z = ff
_==_ : ℕ -> ℕ -> Set
n == m = Atom ( n ==Bool m)
Refl : Set
Refl = (n : ℕ) -> n == n
refl : Refl
refl Z = true
refl (S n) = refl n
| {
"alphanum_fraction": 0.4324734446,
"avg_line_length": 10.9833333333,
"ext": "agda",
"hexsha": "4a55f09bdd1af018bea62646a338e27c696c9252",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/reflnat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/reflnat.agda",
"max_line_length": 32,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/reflnat.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 281,
"size": 659
} |
{-# OPTIONS --cubical-compatible #-}
variable
@0 A : Set
data D : Set₁ where
c : A → D
| {
"alphanum_fraction": 0.5806451613,
"avg_line_length": 11.625,
"ext": "agda",
"hexsha": "a7f8d8e8915d3157e75461a5ad4b385002daf228",
"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": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue5410-3.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue5410-3.agda",
"max_line_length": 36,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Fail/Issue5410-3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 31,
"size": 93
} |
module Logic.Predicate where
open import Functional
import Lvl
open import Logic
open import Logic.Propositional
open import Type
open import Type.Properties.Inhabited
------------------------------------------
-- Existential quantification (Existance, Exists)
module _ {ℓ₁}{ℓ₂} where
record ∃ {Obj : Type{ℓ₁}} (Pred : Obj → Stmt{ℓ₂}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where
eta-equality
constructor [∃]-intro
field
witness : Obj
⦃ proof ⦄ : Pred(witness)
[∃]-witness : ∀{Obj}{Pred} → ∃{Obj}(Pred) → Obj
[∃]-witness([∃]-intro(x) ⦃ _ ⦄ ) = x
[∃]-proof : ∀{Obj}{Pred} → (e : ∃{Obj}(Pred)) → Pred([∃]-witness(e))
[∃]-proof([∃]-intro(_) ⦃ proof ⦄ ) = proof
[∃]-elim : ∀{ℓ₃}{Obj}{Pred}{Z : Stmt{ℓ₃}} → (∀{x : Obj} → Pred(x) → Z) → (∃{Obj} Pred) → Z
[∃]-elim (f) ([∃]-intro(_) ⦃ proof ⦄) = f(proof)
syntax ∃{T}(λ x → y) = ∃❪ x ꞉ T ❫․ y
{- TODO: This would allow the syntax: ∃ₗ x ↦ P(x)
∃ₗ_ = ∃
infixl 1 ∃ₗ_
-}
private variable ℓ : Lvl.Level
private variable Obj X Y Z W : Type{ℓ}
private variable Pred P Q R : X → Type{ℓ}
[∃]-map-proof : (∀{x} → P(x) → Q(x)) → ((∃ P) → (∃ Q))
[∃]-map-proof (f) ([∃]-intro(x) ⦃ proof ⦄) = [∃]-intro(x) ⦃ f(proof) ⦄
[∃]-map : (f : X → X) → (∀{x} → P(x) → Q(f(x))) → ((∃ P) → (∃ Q))
[∃]-map f p ([∃]-intro(x) ⦃ proof ⦄) = [∃]-intro(f(x)) ⦃ p(proof) ⦄
[∃]-map₂ : (f : X → Y → Z) → (∀{x y} → P(x) → Q(y) → R(f x y)) → ((∃ P) → (∃ Q) → (∃ R))
[∃]-map₂ f p ([∃]-intro(x) ⦃ proof₁ ⦄) ([∃]-intro(y) ⦃ proof₂ ⦄) = [∃]-intro(f x y) ⦃ p proof₁ proof₂ ⦄
[∃]-map-proof-dependent : (ep : ∃ P) → (P(∃.witness ep) → Q(∃.witness ep)) → (∃ Q)
[∃]-map-proof-dependent ([∃]-intro(x) ⦃ proof ⦄) f = [∃]-intro(x) ⦃ f(proof) ⦄
------------------------------------------
-- Universal quantification (Forall, All)
∀ₗ : (Pred : Obj → Stmt{ℓ}) → Stmt
∀ₗ (Pred) = (∀{x} → Pred(x))
[∀]-intro : ((a : Obj) → Pred(a)) → ∀ₗ(x ↦ Pred(x))
[∀]-intro p{a} = p(a)
[∀]-elim : ∀ₗ(x ↦ Pred(x)) → (a : Obj) → Pred(a)
[∀]-elim p(a) = p{a}
-- Eliminates universal quantification for a non-empty domain using a witnessed existence which proves that the domain is non-empty.
[∀ₑ]-elim : ⦃ _ : ◊ Obj ⦄ → ∀{P : Obj → Stmt{ℓ}} → ∀ₗ(x ↦ P(x)) → P([◊]-existence)
[∀ₑ]-elim {Obj = Obj} ⦃ proof ⦄ {P} apx = [∀]-elim {Obj = Obj}{P} apx(◊.existence(proof))
syntax ∀ₗ{T}(λ x → y) = ∀❪ x ꞉ T ❫․ y
∀⁰ : (Pred : Stmt{ℓ}) → Stmt
∀⁰ = id
∀¹ : (Pred : X → Stmt{ℓ}) → Stmt
∀¹ (Pred) = ∀⁰(∀ₗ ∘₀ Pred)
-- ∀¹ (Pred) = (∀{x} → Pred(x))
∀² : (Pred : X → Y → Stmt{ℓ}) → Stmt
∀² (Pred) = ∀¹(∀ₗ ∘₁ Pred)
-- ∀² (Pred) = (∀{x}{y} → Pred(x)(y))
∀³ : (Pred : X → Y → Z → Stmt{ℓ}) → Stmt
∀³ (Pred) = ∀²(∀ₗ ∘₂ Pred)
-- ∀³ (Pred) = (∀{x}{y}{z} → Pred(x)(y)(z))
∀⁴ : (Pred : X → Y → Z → W → Stmt{ℓ}) → Stmt
∀⁴ (Pred) = ∀³(∀ₗ ∘₃ Pred)
-- ∀⁴ (Pred) = (∀{x}{y}{z}{w} → Pred(x)(y)(z)(w))
| {
"alphanum_fraction": 0.4782298358,
"avg_line_length": 31.4831460674,
"ext": "agda",
"hexsha": "afbf66122eaac1cd17eb8ed66e0d7c1bb93c3152",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Logic/Predicate.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Logic/Predicate.agda",
"max_line_length": 132,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Logic/Predicate.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": 1330,
"size": 2802
} |
------------------------------------------------------------------------
-- Parsing of matching parentheses, along with a correctness proof
------------------------------------------------------------------------
-- A solution to an exercise set by Helmut Schwichtenberg.
module TotalRecognisers.LeftRecursion.MatchingParentheses where
open import Algebra
open import Codata.Musical.Notation
open import Data.Bool
open import Data.List
open import Data.List.Properties
open import Data.Product
open import Function.Equivalence
open import Relation.Binary hiding (_⇔_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import Relation.Nullary.Decidable as Decidable
private
module ListMonoid {A : Set} = Monoid (++-monoid A)
import TotalRecognisers.LeftRecursion as LR
import TotalRecognisers.LeftRecursion.Lib as Lib
-- Parentheses.
data Paren : Set where
⟦ ⟧ : Paren
-- Strings of matching parentheses.
data Matching : List Paren → Set where
nil : Matching []
app : ∀ {xs ys}
(p₁ : Matching xs) (p₂ : Matching ys) → Matching (xs ++ ys)
par : ∀ {xs} (p : Matching xs) → Matching ([ ⟦ ] ++ xs ++ [ ⟧ ])
-- Our goal: decide Matching.
Goal : Set
Goal = ∀ xs → Dec (Matching xs)
-- Equality of parentheses is decidable.
_≟-Paren_ : Decidable (_≡_ {A = Paren})
⟦ ≟-Paren ⟦ = yes P.refl
⟦ ≟-Paren ⟧ = no λ()
⟧ ≟-Paren ⟦ = no λ()
⟧ ≟-Paren ⟧ = yes P.refl
open LR Paren hiding (_∷_)
private
open module Tok = Lib.Tok Paren _≟-Paren_ using (tok)
-- A (left and right recursive) grammar for matching parentheses. Note
-- the use of nonempty; without the two occurrences of nonempty the
-- grammar would not be well-formed.
matching : P _
matching =
empty
∣ ♯ nonempty matching · ♯ nonempty matching
∣ ♯ (tok ⟦ · ♯ matching) · ♯ tok ⟧
-- We can decide membership of matching.
decide-matching : ∀ xs → Dec (xs ∈ matching)
decide-matching xs = xs ∈? matching
-- Membership of matching is equivalent to satisfaction of Matching.
∈m⇔M : ∀ {xs} → (xs ∈ matching) ⇔ Matching xs
∈m⇔M = equivalence to from
where
to : ∀ {xs} → xs ∈ matching → Matching xs
to (∣-left (∣-left empty)) = nil
to (∣-left (∣-right (nonempty p₁ · nonempty p₂))) = app (to p₁) (to p₂)
to (∣-right (⟦∈ · p · ⟧∈))
rewrite Tok.sound ⟦∈ | Tok.sound ⟧∈ = par (to p)
from : ∀ {xs} → Matching xs → xs ∈ matching
from nil = ∣-left (∣-left empty)
from (app {xs = []} p₁ p₂) = from p₂
from (app {xs = x ∷ xs} {ys = []} p₁ p₂) rewrite proj₂ ListMonoid.identity xs = from p₁
from (app {xs = _ ∷ _} {ys = _ ∷ _} p₁ p₂) = ∣-left (∣-right {n₁ = true} (nonempty (from p₁) · nonempty (from p₂)))
from (par p) = ∣-right {n₁ = true} (Tok.complete · from p · Tok.complete)
-- And thus we reach our goal.
goal : Goal
goal xs = Decidable.map ∈m⇔M (decide-matching xs)
-- Some examples.
ex₁ : Dec (Matching [])
ex₁ = goal _ -- = yes nil
ex₂ : Dec (Matching (⟦ ∷ ⟧ ∷ []))
ex₂ = goal _ -- = yes (par nil)
ex₃ : Dec (Matching (⟦ ∷ ⟧ ∷ ⟦ ∷ ⟧ ∷ []))
ex₃ = goal _ -- = yes (app (par nil) (par nil))
ex₄ : Dec (Matching (⟦ ∷ ⟧ ∷ ⟦ ∷ []))
ex₄ = goal _ -- = no (λ x → …)
| {
"alphanum_fraction": 0.5926153846,
"avg_line_length": 30.0925925926,
"ext": "agda",
"hexsha": "8d79b628da43c5bb60aa19409c3cf1a908a32de3",
"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/LeftRecursion/MatchingParentheses.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/LeftRecursion/MatchingParentheses.agda",
"max_line_length": 118,
"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/LeftRecursion/MatchingParentheses.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": 996,
"size": 3250
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists where every pair of elements are related (symmetrically)
------------------------------------------------------------------------
-- Core modules are not meant to be used directly outside of the
-- standard library.
-- This module should be removable if and when Agda issue
-- https://github.com/agda/agda/issues/3210 is fixed
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Rel)
module Data.List.Relation.Unary.AllPairs.Core
{a ℓ} {A : Set a} (R : Rel A ℓ) where
open import Level
open import Data.List.Base
open import Data.List.Relation.Unary.All
------------------------------------------------------------------------
-- Definition
-- AllPairs R xs means that every pair of elements (x , y) in xs is a
-- member of relation R (as long as x comes before y in the list).
infixr 5 _∷_
data AllPairs : List A → Set (a ⊔ ℓ) where
[] : AllPairs []
_∷_ : ∀ {x xs} → All (R x) xs → AllPairs xs → AllPairs (x ∷ xs)
| {
"alphanum_fraction": 0.5463049579,
"avg_line_length": 30.5428571429,
"ext": "agda",
"hexsha": "0a4cd7f4815006cbc67b0585bbb0b9ca3015adb3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 249,
"size": 1069
} |
open import OutsideIn.Prelude
open import OutsideIn.X
module OutsideIn.Inference.ConstraintGen(x : X) where
import OutsideIn.Constraints as C
import OutsideIn.TypeSchema as TS
import OutsideIn.Expressions as E
import OutsideIn.Environments as V
open X(x) renaming (funType to _⟶_; appType to _··_)
open C(x)
open TS(x)
open E(x)
open V(x)
open import Data.Vec
private module PlusN-m n = Monad (PlusN-is-monad {n})
module PlusN-f n = Functor (Monad.is-functor (PlusN-is-monad {n}))
module TypeSchema-f {n} = Functor (type-schema-is-functor {n})
module Type-f = Functor (type-is-functor)
module QC-f = Functor (qconstraint-is-functor)
module Exp-f₁ {tv} {r} = Functor (expression-is-functor₁ {tv} {r})
module Exp-f₂ {ev} {r} = Functor (expression-is-functor₂ {ev} {r})
module Constraint-f {s} = Functor (constraint-is-functor {s})
module Vec-f {n} = Functor (vec-is-functor {n})
open Monad (type-is-monad) using () renaming (unit to TVar)
private
upindex : {X : Set → Set}{tv : Set} → ⦃ is-functor : Functor X ⦄ → X tv → X (Ⓢ tv)
upindex ⦃ is-functor ⦄ e = suc <$> e
where open Functor (is-functor)
_↑c : {tv : Set}{s : Strata} → (Constraint tv s) → (Constraint (Ⓢ tv) s)
_↑c {s = s} = upindex ⦃ constraint-is-functor {s} ⦄
_↑e : {ev tv : Set}{r : Shape} → (Expression ev tv r) → (Expression ev (Ⓢ tv) r)
_↑e = upindex ⦃ expression-is-functor₂ ⦄
_↑a : {ev tv : Set}{r : Shape} → (Alternatives ev tv r) → (Alternatives ev (Ⓢ tv) r)
_↑a = upindex ⦃ alternatives-is-functor₂ ⦄
_↑t : {tv : Set} → (Type tv) → (Type (Ⓢ tv))
_↑t = upindex ⦃ type-is-functor ⦄
_↑q : {tv : Set} → (QConstraint tv) → (QConstraint (Ⓢ tv))
_↑q = upindex ⦃ qconstraint-is-functor ⦄
infixr 7 _↑e
infixr 7 _↑c
infixr 7 _↑t
infixr 7 _↑a
applyAll : ∀{tv}(n : ℕ) → Type tv → Type (tv ⨁ n)
applyAll zero x = x
applyAll (suc n) x = applyAll n ((x ↑t) ·· (TVar zero))
funType : ∀{tv}{n} → Vec (Type tv) n → Type tv → Type tv
funType [] t = t
funType (x ∷ xs) t = x ⟶ (funType xs t)
upType : ∀ {n}{tv} → Type tv → Type (tv ⨁ n)
upType {n} t = Type-f.map (Monad.unit (PlusN-is-monad {n})) t
upGamma : ∀ {n}{ev}{tv} → Environment ev tv → Environment ev (tv ⨁ n)
upGamma {n} Γ = TypeSchema-f.map (Monad.unit (PlusN-is-monad {n})) ∘ Γ
upExp : ∀ {n}{ev}{tv}{r} → Expression ev tv r → Expression ev (tv ⨁ n) r
upExp {n} e = Exp-f₂.map (Monad.unit (PlusN-is-monad {n})) e
upAlts : ∀ {n}{ev}{tv}{r} → Alternatives ev tv r → Alternatives ev (tv ⨁ n) r
upAlts {n} e = Functor.map alternatives-is-functor₂ (Monad.unit (PlusN-is-monad {n})) e
mutual
syntax alternativeConstraintGen Γ α₀ α₁ alt C = Γ ►′ alt ∶ α₀ ⟶ α₁ ↝ C
data alternativeConstraintGen {ev : Set}{tv : Set}(Γ : Environment ev tv)(α₀ α₁ : Type tv) :
{r : Shape} → Alternative ev tv r → Constraint tv Extended → Set where
Simple : ∀ {r}{n}{v : Name ev (Datacon n)}{e : Expression _ _ r}{a}{τs}{T}{C}
→ let δ = TVar zero
in Γ v ≡ DC∀ a · τs ⟶ T
→ addAll (Vec-f.map (_↑t) τs) (upGamma {a} Γ ↑Γ) ► (upExp {a} e ↑e) ∶ δ ↝ C
→ Γ ►′ v →′ e ∶ α₀ ⟶ α₁ ↝ Ⅎ′ a · (Ⅎ δ ∼′ (upType {a} α₁ ↑t) ∧′ C) ∧′ applyAll a (TVar T) ∼′ upType {a} α₀
GADT : ∀ {r}{n}{v : Name ev (Datacon n)}{e : Expression _ _ r}{a}{b}{Q}{τs}{T}{C}
→ let δ = TVar zero
in Γ v ≡ DC∀′ a , b · Q ⇒ τs ⟶ T
→ addAll (Vec-f.map (_↑t) τs) (upGamma {b} (upGamma {a} Γ) ↑Γ)
► (upExp {b} (upExp {a} e) ↑e) ∶ δ ↝ C
→ Γ ►′ v →′ e ∶ α₀ ⟶ α₁ ↝ Ⅎ′ a · Ⅎ′ b · (Imp′ Q (Ⅎ (C ∧′ δ ∼′ (upType {b} (upType {a} α₁) ↑t))))
∧′ upType {b} (upType {a} α₀) ∼′ Type-f.map (PlusN-m.unit b) (applyAll a (TVar T))
syntax alternativesConstraintGen Γ α₀ α₁ alts C = Γ ►► alts ∶ α₀ ⟶ α₁ ↝ C
data alternativesConstraintGen {ev : Set}{tv : Set}(Γ : Environment ev tv)(α₀ α₁ : Type tv) :
{r : Shape} → Alternatives ev tv r → Constraint tv Extended → Set where
NoAlternative : Γ ►► esac ∶ α₀ ⟶ α₁ ↝ ε′
AnAlternative : ∀ {r₁ r₂}{a : Alternative _ _ r₁}{as : Alternatives _ _ r₂}{C₁}{C₂}
→ Γ ►′ a ∶ α₀ ⟶ α₁ ↝ C₁
→ Γ ►► as ∶ α₀ ⟶ α₁ ↝ C₂
→ Γ ►► a ∣ as ∶ α₀ ⟶ α₁ ↝ C₂
syntax constraintGen a c b d = a ► b ∶ c ↝ d
data constraintGen {ev : Set}{tv : Set}
(Γ : Environment ev tv)(τ : Type tv) : {r : Shape} →
Expression ev tv r → Constraint tv Extended → Set where
VarCon₁ : ∀ {v}{n}{q}{t}
→ Γ (N v) ≡ ∀′ n · q ⇒ t
→ Γ ► Var (N v) ∶ τ ↝ Ⅎ′ n · QC q ∧′ upType {n} τ ∼′ t
VarCon₂ : ∀ {n}{d}{a}{τs : Vec _ n}{k}
→ Γ (DC d) ≡ DC∀ a · τs ⟶ k
→ Γ ► Var (DC d) ∶ τ ↝ Ⅎ′ a · upType {a} τ ∼′ funType τs (applyAll a (TVar k))
VarCon₃ : ∀ {n}{d}{a}{b}{Q}{τs : Vec _ n}{k}
→ Γ (DC d) ≡ DC∀′ a , b · Q ⇒ τs ⟶ k
→ Γ ► Var (DC d) ∶ τ ↝ Ⅎ′ a · Ⅎ′ b ·
QC Q ∧′ upType {b} (upType {a} τ) ∼′ funType τs (upType {b} (applyAll a (TVar k)))
App : ∀ {r₁}{r₂}{e₁ : Expression _ _ r₁}{e₂ : Expression _ _ r₂}{C₁}{C₂}
→ let α₀ = TVar zero
α₁ = TVar (suc zero)
α₂ = TVar (suc (suc zero))
in upGamma {3} Γ ► upExp {3} e₁ ∶ α₀ ↝ C₁
→ upGamma {3} Γ ► upExp {3} e₂ ∶ α₁ ↝ C₂
→ Γ ► e₁ · e₂ ∶ τ ↝ Ⅎ Ⅎ Ⅎ C₁ ∧′ C₂ ∧′ α₀ ∼′ (α₁ ⟶ α₂) ∧′ upType {3} τ ∼′ α₂
Abs : ∀ {r}{e : Expression _ _ r}{C}
→ let α₀ = TVar zero
α₁ = TVar (suc zero)
in ⟨ ∀′ 0 · ε ⇒ α₀ ⟩, upGamma {2} Γ ► upExp {2} e ∶ α₁ ↝ C
→ Γ ► λ′ e ∶ τ ↝ Ⅎ Ⅎ C ∧′ upType {2} τ ∼′ (α₀ ⟶ α₁)
Let : ∀{r₁}{r₂}{x : Expression _ _ r₁}{y : Expression _ _ r₂}{C₁}{C₂}
→ let α₀ = TVar zero
α₁ = TVar (suc zero)
in upGamma {2} Γ ► upExp {2} x ∶ α₀ ↝ C₁
→ ⟨ ∀′ 0 · ε ⇒ α₀ ⟩, upGamma {2} Γ ► upExp {2} y ∶ α₁ ↝ C₂
→ Γ ► let₁ x in′ y ∶ τ ↝ Ⅎ Ⅎ C₁ ∧′ C₂ ∧′ upType {2} τ ∼′ α₁
LetA : ∀{r₁}{r₂}{x : Expression _ _ r₁}{y : Expression _ _ r₂}{t}{C₁}{C₂}
→ let α₀ = TVar zero
α₁ = TVar (suc zero)
in upGamma {2} Γ ► upExp {2} x ∶ α₀ ↝ C₁
→ ⟨ ∀′ 0 · ε ⇒ α₀ ⟩, upGamma {2} Γ ► upExp {2} y ∶ α₁ ↝ C₂
→ Γ ► let₂ x ∷ t in′ y ∶ τ ↝ Ⅎ Ⅎ C₁ ∧′ C₂ ∧′ upType {2} τ ∼′ α₁ ∧′ upType {2} t ∼′ α₀
GLetA : ∀{n}{r₁}{r₂}{x : Expression _ _ r₁}{y : Expression _ _ r₂}{Q}{t}{C}{C₂}
→ let α₀ = upType {n} (TVar zero)
α₁ = upType {n} (TVar (suc zero))
up2 = PlusN-f.map n (PlusN-m.unit 2)
in upGamma {n} (upGamma {2} Γ) ► Exp-f₂.map up2 x ∶ α₀ ↝ C
→ upGamma {n} (upGamma {2} (⟨ ∀′ n · Q ⇒ t ⟩, Γ)) ► upExp {n} (upExp {2} y) ∶ α₁ ↝ C₂
→ Γ ► let₃ n · x ∷ Q ⇒ t in′ y ∶ τ ↝ Ⅎ Ⅎ Ⅎ′ n · Imp′ (QC-f.map up2 Q) (C ∧′ α₀ ∼′ Type-f.map up2 t)
∧′ C₂ ∧′ upType {n} (upType {2} τ) ∼′ α₁
Case : ∀{r₁}{r₂}{x : Expression _ _ r₁}{alts : Alternatives _ _ r₂}{C₁}{C₂}
→ let α₀ = TVar zero
α₁ = TVar (suc zero)
in upGamma {2} Γ ► upExp {2} x ∶ α₀ ↝ C₁
→ upGamma {2} Γ ►► upAlts {2} alts ∶ α₀ ⟶ α₁ ↝ C₂
→ Γ ► case x of alts ∶ τ ↝ Ⅎ Ⅎ C₁ ∧′ C₂
genConstraint : {ev : Set}{tv : Set}{r : Shape}
(Γ : Environment ev tv)(e : Expression ev tv r)(τ : Type tv) → ∃ (λ C → Γ ► e ∶ τ ↝ C)
genConstraintAlternative : {ev : Set}{tv : Set}{r : Shape} (Γ : Environment ev tv)(a : Alternative ev tv r)(α₀ α₁ : Type tv)
→ ∃ (λ C → Γ ►′ a ∶ α₀ ⟶ α₁ ↝ C)
genConstraintAlternative Γ (n →′ e) α₀ α₁ with Γ n | inspect Γ n
... | DC∀ a · τs ⟶ k | iC p with genConstraint (addAll (Vec-f.map _↑t τs) (upGamma {a} Γ ↑Γ)) (upExp {a} e ↑e) (TVar zero)
... | C , p₂ = _ , Simple p p₂
genConstraintAlternative Γ (n →′ e) α₀ α₁
| DC∀′ a , b · Q ⇒ τs ⟶ k | iC p with genConstraint (addAll (Vec-f.map _↑t τs) (upGamma {b} (upGamma {a} Γ) ↑Γ))
(upExp {b} (upExp {a} e) ↑e)
(TVar zero)
... | C , p₂ = _ , GADT p p₂
genConstraintAlternatives : {ev : Set}{tv : Set}{r : Shape} (Γ : Environment ev tv)(a : Alternatives ev tv r)(α₀ α₁ : Type tv)
→ ∃ (λ C → Γ ►► a ∶ α₀ ⟶ α₁ ↝ C)
genConstraintAlternatives Γ esac α₀ α₁ = _ , NoAlternative
genConstraintAlternatives Γ (a ∣ as) α₀ α₁ with genConstraintAlternative Γ a α₀ α₁ | genConstraintAlternatives Γ as α₀ α₁
... | C₁ , p₁ | C₂ , p₂ = _ , AnAlternative p₁ p₂
genConstraint Γ (Var (N v)) τ with Γ (N v) | inspect Γ (N v)
... | ∀′ n · q ⇒ t | iC prf = _ , VarCon₁ prf
genConstraint Γ (Var (DC d)) τ with Γ (DC d) | inspect Γ (DC d)
... | DC∀ a · τs ⟶ k | iC prf = _ , VarCon₂ prf
... | DC∀′ a , b · q ⇒ τs ⟶ k | iC prf = _ , VarCon₃ prf
genConstraint Γ (e₁ · e₂) τ with genConstraint (upGamma {3} Γ) (upExp {3} e₁) (TVar zero)
| genConstraint (upGamma {3} Γ) (upExp {3} e₂) (TVar (suc zero))
... | C₁ , p₁ | C₂ , p₂ = _ , App p₁ p₂
genConstraint Γ (λ′ e′) τ with genConstraint (⟨ ∀′ 0 · ε ⇒ TVar zero ⟩, upGamma {2} Γ) (upExp {2} e′) (TVar (suc zero))
... | C , p = _ , Abs p
genConstraint Γ (let₁ x in′ y) τ with genConstraint (upGamma {2} Γ) (upExp {2} x) (TVar zero)
| genConstraint (⟨ ∀′ 0 · ε ⇒ TVar zero ⟩, upGamma {2} Γ) (upExp {2} y) (TVar (suc zero))
... | C₁ , p₁ | C₂ , p₂ = _ , Let p₁ p₂
genConstraint Γ (let₂ x ∷ t in′ y) τ with genConstraint (upGamma {2} Γ) (upExp {2} x) (TVar zero)
| genConstraint (⟨ ∀′ 0 · ε ⇒ TVar zero ⟩, upGamma {2} Γ) (upExp {2} y) (TVar (suc zero))
... | C₁ , p₁ | C₂ , p₂ = _ , LetA p₁ p₂
genConstraint Γ (let₃ n · x ∷ Q ⇒ t in′ y) τ with genConstraint (upGamma {n} (upGamma {2} Γ))
(Exp-f₂.map (PlusN-f.map n (PlusN-m.unit 2)) x)
(upType {n} (TVar zero))
| genConstraint (upGamma {n} (upGamma {2} (⟨ ∀′ n · Q ⇒ t ⟩, Γ)))
(upExp {n} (upExp {2} y))
(upType {n} (TVar (suc zero)))
... | C₁ , p₁ | C₂ , p₂ = _ , GLetA p₁ p₂
genConstraint Γ (case x of alts) τ with genConstraint (upGamma {2} Γ) (upExp {2} x) (TVar zero)
| genConstraintAlternatives (upGamma {2} Γ) (upAlts {2} alts) (TVar zero) (TVar (suc zero))
... | C₁ , p₁ | C₂ , p₂ = _ , Case p₁ p₂
| {
"alphanum_fraction": 0.4611688652,
"avg_line_length": 59.0051546392,
"ext": "agda",
"hexsha": "42d7ba3674d2136ea21e6eb9fe43ab419426ea6d",
"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": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "liamoc/outside-in",
"max_forks_repo_path": "OutsideIn/Inference/ConstraintGen.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"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": "liamoc/outside-in",
"max_issues_repo_path": "OutsideIn/Inference/ConstraintGen.agda",
"max_line_length": 132,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "liamoc/outside-in",
"max_stars_repo_path": "OutsideIn/Inference/ConstraintGen.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z",
"num_tokens": 4290,
"size": 11447
} |
------------------------------------------------------------------------
-- The coinductive type family Coherently
------------------------------------------------------------------------
-- This type family is used to define the lenses in
-- Lens.Non-dependent.Higher.Coinductive and
-- Lens.Non-dependent.Higher.Coinductive.Small.
{-# OPTIONS --cubical --guardedness #-}
import Equality.Path as P
module Lens.Non-dependent.Higher.Coherently.Coinductive
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
import Equality.Path.Univalence as EPU
open import Prelude
open import Bijection equality-with-J as B using (_↔_)
import Bijection P.equality-with-J as PB
open import Container.Indexed equality-with-J
open import Container.Indexed.M.Codata eq
import Container.Indexed.M.Function equality-with-J as F
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq using (_≃_)
import Equivalence P.equality-with-J as PEq
open import Function-universe equality-with-J hiding (id; _∘_)
import Function-universe P.equality-with-J as PF
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional.One-step eq as O
using (∥_∥¹; ∣_∣)
open import Univalence-axiom equality-with-J
import Univalence-axiom P.equality-with-J as PU
import Lens.Non-dependent.Higher.Coherently.Not-coinductive eq as NC
private
variable
a b ℓ p p₁ p₂ : Level
A A₁ A₂ B C : Type a
f q x y : A
n : ℕ
------------------------------------------------------------------------
-- The type family
-- Coherently P step f means that f and all variants of f built using
-- step (in a certain way) satisfy the property P.
--
-- Paolo Capriotti came up with a coinductive definition of lenses.
-- Andrea Vezzosi suggested that one could use a kind of indexed
-- M-type to make it easier to prove that two variants of coinductive
-- lenses are equivalent: the lemma Coherently-cong-≡ below is based
-- on his idea, and Coherently is a less general variant of the M-type
-- that he suggested. See also Coherently-with-restriction′ below,
-- which is defined as an indexed M-type.
record Coherently
{A : Type a} {B : Type b}
(P : {A : Type a} → (A → B) → Type p)
(step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B)
(f : A → B) : Type p where
coinductive
field
property : P f
coherent : Coherently P step (step f property)
open Coherently public
------------------------------------------------------------------------
-- An equivalence
-- Coherently is pointwise equivalent to NC.Coherently (assuming
-- univalence).
Coherently≃Not-coinductive-coherently :
{B : Type b}
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B} →
Univalence (lsuc a ⊔ b ⊔ p) →
Univalence (lsuc a ⊔ b) →
Coherently P step f ≃ NC.Coherently P step f
Coherently≃Not-coinductive-coherently
{a = a} {B = B} {P = P} {step = step} {f = f} univ₁ univ₂ =
block λ b →
Coherently P step f ↝⟨ Eq.↔→≃ to from
(_↔_.from ≡↔≡ ∘ to-from)
(_↔_.from ≡↔≡ ∘ from-to) ⟩
M (CC step) (_ , f) ↝⟨ carriers-of-final-coalgebras-equivalent
(M-coalgebra (CC step) , M-final univ₁ univ₂)
(F.M-coalgebra b ext (CC step) , F.M-final b ext ext)
_ ⟩
F.M (CC step) (_ , f) ↔⟨⟩
NC.Coherently P step f □
where
CC = NC.Coherently-container P
to :
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} {f : A → B} →
Coherently P step f → M (CC step) (_ , f)
to c .out-M .proj₁ = c .property
to c .out-M .proj₂ _ = to (c .coherent)
from :
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} {f : A → B} →
M (CC step) (_ , f) → Coherently P step f
from c .property = c .out-M .proj₁
from c .coherent = from (c .out-M .proj₂ _)
to-from :
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} {f : A → B} →
(c : M (CC step) (_ , f)) →
to (from c) P.≡ c
to-from c i .out-M .proj₁ = c .out-M .proj₁
to-from c i .out-M .proj₂ _ = to-from (c .out-M .proj₂ _) i
from-to :
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} {f : A → B} →
(c : Coherently P step f) →
from (to c) P.≡ c
from-to c i .property = c .property
from-to c i .coherent = from-to (c .coherent) i
------------------------------------------------------------------------
-- Preservation lemmas
private
-- A preservation lemma for Coherently.
--
-- The lemma does not use the univalence argument, instead it uses
-- EPU.univ (and EPU.≃⇒≡) directly.
Coherently-cong-≡ :
Block "Coherently-cong-≡" →
{A : Type a}
{P₁ P₂ : {A : Type a} → (A → B) → Type p}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B} →
Univalence p →
(P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) →
({A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) →
Coherently P₁ step₁ f P.≡ Coherently P₂ step₂ f
Coherently-cong-≡
{a = a} {B = B} {p = p} ⊠ {P₁ = P₁} {P₂ = P₂}
{step₁ = step₁} {step₂ = step₂} {f = f} _ P₁≃P₂′ step₁≡step₂ =
P.cong (λ ((P , step) :
∃ λ (P : (A : Type a) → (A → B) → Type p) →
{A : Type a} (f : A → B) → P A f → ∥ A ∥¹ → B) →
Coherently (P _) step f) $
P.Σ-≡,≡→≡′
(P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) →
EPU.≃⇒≡ (P₁≃P₂ f))
(P.implicit-extensionality P.ext λ A → P.⟨ext⟩ λ f →
P.subst (λ P → {A : Type a} (f : A → B) → P A f → ∥ A ∥¹ → B)
(P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) →
EPU.≃⇒≡ (P₁≃P₂ f))
step₁ f P.≡⟨ P.trans (P.cong (_$ f) $ P.sym $
P.push-subst-implicit-application
(P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f))
(λ P A → (f : A → B) → P A f → ∥ A ∥¹ → B)
{f = const _} {g = step₁}) $
P.sym $ P.push-subst-application
(P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) → EPU.≃⇒≡ (P₁≃P₂ f))
(λ P f → P A f → ∥ A ∥¹ → B)
{f = const f} {g = step₁} ⟩
P.subst (λ P → P A f → ∥ A ∥¹ → B)
(P.⟨ext⟩ λ A → P.⟨ext⟩ λ (f : A → B) →
EPU.≃⇒≡ (P₁≃P₂ f))
(step₁ f) P.≡⟨⟩
P.subst (λ P → P → ∥ A ∥¹ → B)
(EPU.≃⇒≡ (P₁≃P₂ f))
(step₁ f) P.≡⟨ P.sym $
PU.transport-theorem
(λ P → P → ∥ A ∥¹ → B)
(PF.→-cong₁ _)
(λ _ → P.refl)
EPU.univ
(P₁≃P₂ f)
(step₁ f) ⟩
PF.→-cong₁ _ (P₁≃P₂ f) (step₁ f) P.≡⟨⟩
step₁ f ∘ PEq._≃_.from (P₁≃P₂ f) P.≡⟨ P.⟨ext⟩ (_↔_.to ≡↔≡ ∘ step₁≡step₂ f) ⟩∎
step₂ f ∎)
where
P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f PEq.≃ P₂ f
P₁≃P₂ f = _↔_.to ≃↔≃ (P₁≃P₂′ f)
-- A "computation rule".
to-Coherently-cong-≡-property :
(bl : Block "Coherently-cong-≡")
{A : Type a} {B : Type b}
{P₁ P₂ : {A : Type a} → (A → B) → Type p}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B}
(univ : Univalence p)
(P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f)
(step₁≡step₂ :
{A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x)
(c : Coherently P₁ step₁ f) →
PU.≡⇒→ (Coherently-cong-≡ bl univ P₁≃P₂ step₁≡step₂) c .property P.≡
_≃_.to (P₁≃P₂ f) (c .property)
to-Coherently-cong-≡-property
⊠ {P₁ = P₁} {P₂ = P₂} {f = f} _ P₁≃P₂ step₁≡step₂ c =
P.transport (λ _ → P₂ f) P.0̲
(_≃_.to (P₁≃P₂ f) (P.transport (λ _ → P₁ f) P.0̲ (c .property))) P.≡⟨ P.cong (_$ _≃_.to (P₁≃P₂ f)
(P.transport (λ _ → P₁ f) P.0̲ (c .property))) $
P.transport-refl P.0̲ ⟩
_≃_.to (P₁≃P₂ f) (P.transport (λ _ → P₁ f) P.0̲ (c .property)) P.≡⟨ P.cong (λ g → _≃_.to (P₁≃P₂ f) (g (c .property))) $
P.transport-refl P.0̲ ⟩∎
_≃_.to (P₁≃P₂ f) (c .property) ∎
-- Another "computation rule".
from-Coherently-cong-≡-property :
(bl : Block "Coherently-cong-≡")
{A : Type a} {B : Type b}
{P₁ P₂ : {A : Type a} → (A → B) → Type p}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B}
(univ : Univalence p)
(P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f)
(step₁≡step₂ :
{A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x)
(c : Coherently P₂ step₂ f) →
PEq._≃_.from
(PU.≡⇒≃ (Coherently-cong-≡ bl {step₁ = step₁} univ
P₁≃P₂ step₁≡step₂))
c .property P.≡
_≃_.from (P₁≃P₂ f) (c .property)
from-Coherently-cong-≡-property
⊠ {P₁ = P₁} {P₂ = P₂} {f = f} _ P₁≃P₂ step₁≡step₂ c =
P.transport (λ _ → P₁ f) P.0̲
(_≃_.from (P₁≃P₂ f) (P.transport (λ _ → P₂ f) P.0̲ (c .property))) P.≡⟨ P.cong (_$ _≃_.from (P₁≃P₂ f)
(P.transport (λ _ → P₂ f) P.0̲ (c .property))) $
P.transport-refl P.0̲ ⟩
_≃_.from (P₁≃P₂ f) (P.transport (λ _ → P₂ f) P.0̲ (c .property)) P.≡⟨ P.cong (λ g → _≃_.from (P₁≃P₂ f) (g (c .property))) $
P.transport-refl P.0̲ ⟩∎
_≃_.from (P₁≃P₂ f) (c .property) ∎
-- A preservation lemma for Coherently.
--
-- The two directions of this equivalence compute the property
-- fields in certain ways, see the "unit tests" below.
--
-- Note that P₁ and P₂ have to target the same universe. A more
-- general result is given below (Coherently-cong).
Coherently-cong-≃ :
{A : Type a}
{P₁ P₂ : {A : Type a} → (A → B) → Type p}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B} →
Univalence p →
(P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) →
({A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) →
Coherently P₁ step₁ f ≃ Coherently P₂ step₂ f
Coherently-cong-≃
{P₁ = P₁} {P₂ = P₂} {step₁ = step₁} {step₂ = step₂} {f = f}
univ P₁≃P₂ step₁≡step₂ =
block λ bl →
Eq.with-other-inverse
(Eq.with-other-function
(equiv bl)
(to bl)
(_↔_.from ≡↔≡ ∘ ≡to bl))
(from bl)
(_↔_.from ≡↔≡ ∘ ≡from bl)
where
equiv :
Block "Coherently-cong-≡" →
Coherently P₁ step₁ f ≃ Coherently P₂ step₂ f
equiv bl =
_↔_.from ≃↔≃ $ PU.≡⇒≃ $
Coherently-cong-≡ bl univ P₁≃P₂ step₁≡step₂
to :
Block "Coherently-cong-≡" →
Coherently P₁ step₁ f → Coherently P₂ step₂ f
to _ c .property = _≃_.to (P₁≃P₂ f) (c .property)
to bl c .coherent =
P.subst
(Coherently P₂ step₂)
(P.cong (step₂ f) $
to-Coherently-cong-≡-property bl univ P₁≃P₂ step₁≡step₂ c) $
_≃_.to (equiv bl) c .coherent
≡to : ∀ bl c → _≃_.to (equiv bl) c P.≡ to bl c
≡to bl c i .property = to-Coherently-cong-≡-property
bl univ P₁≃P₂ step₁≡step₂ c i
≡to bl c i .coherent = lemma i
where
lemma :
P.[ (λ i → Coherently P₂ step₂
(step₂ f
(to-Coherently-cong-≡-property
bl univ P₁≃P₂ step₁≡step₂ c i))) ]
_≃_.to (equiv bl) c .coherent ≡
P.subst
(Coherently P₂ step₂)
(P.cong (step₂ f) $
to-Coherently-cong-≡-property bl univ P₁≃P₂ step₁≡step₂ c)
(_≃_.to (equiv bl) c .coherent)
lemma =
PB._↔_.from (P.heterogeneous↔homogeneous _) P.refl
from :
Block "Coherently-cong-≡" →
Coherently P₂ step₂ f → Coherently P₁ step₁ f
from _ c .property = _≃_.from (P₁≃P₂ f) (c .property)
from bl c .coherent =
P.subst
(Coherently P₁ step₁)
(P.cong (step₁ f) $
from-Coherently-cong-≡-property bl univ P₁≃P₂ step₁≡step₂ c) $
_≃_.from (equiv bl) c .coherent
≡from : ∀ bl c → _≃_.from (equiv bl) c P.≡ from bl c
≡from bl c i .property = from-Coherently-cong-≡-property
bl univ P₁≃P₂ step₁≡step₂ c i
≡from bl c i .coherent = lemma i
where
lemma :
P.[ (λ i → Coherently P₁ step₁
(step₁ f
(from-Coherently-cong-≡-property
bl univ P₁≃P₂ step₁≡step₂ c i))) ]
_≃_.from (equiv bl) c .coherent ≡
P.subst
(Coherently P₁ step₁)
(P.cong (step₁ f) $
from-Coherently-cong-≡-property
bl univ P₁≃P₂ step₁≡step₂ c)
(_≃_.from (equiv bl) c .coherent)
lemma =
PB._↔_.from (P.heterogeneous↔homogeneous _) P.refl
-- Unit tests that ensure that Coherently-cong-≃ computes the
-- property fields in certain ways.
module _
{A : Type a}
{P₁ P₂ : {A : Type a} → (A → B) → Type p}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B}
{univ : Univalence p}
{P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f}
{step₁≡step₂ :
{A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x}
where
_ :
{c : Coherently P₁ step₁ f} →
_≃_.to (Coherently-cong-≃ univ P₁≃P₂ step₁≡step₂) c .property ≡
_≃_.to (P₁≃P₂ f) (c .property)
_ = refl _
_ :
{c : Coherently P₂ step₂ f} →
_≃_.from (Coherently-cong-≃ {step₁ = step₁} univ
P₁≃P₂ step₁≡step₂)
c .property ≡
_≃_.from (P₁≃P₂ f) (c .property)
_ = refl _
-- A lemma involving Coherently and ↑.
Coherently-↑ :
{A : Type a}
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B} →
Coherently (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f ≃
Coherently P step f
Coherently-↑ {ℓ = ℓ} {P = P} {step = step} =
Eq.↔→≃
to
from
(_↔_.from ≡↔≡ ∘ to-from)
(_↔_.from ≡↔≡ ∘ from-to)
where
to :
Coherently (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f →
Coherently P step f
to c .property = lower (c .property)
to c .coherent = to (c .coherent)
from :
Coherently P step f →
Coherently (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f
from c .property = lift (c .property)
from c .coherent = from (c .coherent)
to-from :
(c : Coherently P step f) →
to (from c) P.≡ c
to-from c i .property = c .property
to-from c i .coherent = to-from (c .coherent) i
from-to :
(c : Coherently (↑ ℓ ∘ P) ((_∘ lower) ∘ step) f) →
from (to c) P.≡ c
from-to c i .property = c .property
from-to c i .coherent = from-to (c .coherent) i
-- A preservation lemma for Coherently.
--
-- The two directions of this equivalence compute the property
-- fields in certain ways, see the "unit tests" below.
Coherently-cong :
{A : Type a}
{P₁ : {A : Type a} → (A → B) → Type p₁}
{P₂ : {A : Type a} → (A → B) → Type p₂}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B} →
Univalence (p₁ ⊔ p₂) →
(P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f) →
({A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x) →
Coherently P₁ step₁ f ≃ Coherently P₂ step₂ f
Coherently-cong
{p₁ = p₁} {p₂ = p₂}
{P₁ = P₁} {P₂ = P₂} {step₁ = step₁} {step₂ = step₂} {f = f}
univ P₁≃P₂ step₁≡step₂ =
Coherently P₁ step₁ f ↝⟨ inverse Coherently-↑ ⟩
Coherently (↑ p₂ ∘ P₁) ((_∘ lower) ∘ step₁) f ↝⟨ Coherently-cong-≃
univ
(λ f →
↑ p₂ (P₁ f) ↔⟨ B.↑↔ ⟩
P₁ f ↝⟨ P₁≃P₂ f ⟩
P₂ f ↔⟨ inverse B.↑↔ ⟩□
↑ p₁ (P₂ f) □)
((_∘ lower) ∘ step₁≡step₂) ⟩
Coherently (↑ p₁ ∘ P₂) ((_∘ lower) ∘ step₂) f ↝⟨ Coherently-↑ ⟩□
Coherently P₂ step₂ f □
-- Unit tests that ensure that Coherently-cong computes the
-- property fields in certain ways.
module _
{A : Type a}
{P₁ : {A : Type a} → (A → B) → Type p₁}
{P₂ : {A : Type a} → (A → B) → Type p₂}
{step₁ : {A : Type a} (f : A → B) → P₁ f → ∥ A ∥¹ → B}
{step₂ : {A : Type a} (f : A → B) → P₂ f → ∥ A ∥¹ → B}
{f : A → B}
{univ : Univalence (p₁ ⊔ p₂)}
{P₁≃P₂ : {A : Type a} (f : A → B) → P₁ f ≃ P₂ f}
{step₁≡step₂ :
{A : Type a} (f : A → B) (x : P₂ f) →
step₁ f (_≃_.from (P₁≃P₂ f) x) ≡ step₂ f x}
where
_ :
{c : Coherently P₁ step₁ f} →
_≃_.to (Coherently-cong univ P₁≃P₂ step₁≡step₂) c .property ≡
_≃_.to (P₁≃P₂ f) (c .property)
_ = refl _
_ :
{c : Coherently P₂ step₂ f} →
_≃_.from (Coherently-cong {step₁ = step₁} univ P₁≃P₂ step₁≡step₂)
c .property ≡
_≃_.from (P₁≃P₂ f) (c .property)
_ = refl _
-- Another preservation lemma for Coherently.
Coherently-cong′ :
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B} →
Univalence a →
(A₁≃A₂ : A₁ ≃ A₂) →
Coherently P step (f ∘ _≃_.to A₁≃A₂) ≃ Coherently P step f
Coherently-cong′ {f = f} {P = P} {step = step} univ A₁≃A₂ =
≃-elim₁ univ
(λ A₁≃A₂ →
Coherently P step (f ∘ _≃_.to A₁≃A₂) ≃
Coherently P step f)
Eq.id
A₁≃A₂
------------------------------------------------------------------------
-- Another lemma
-- A "computation rule".
subst-Coherently-property :
∀ {A : C → Type a} {B : Type b}
{P : C → {A : Type a} → (A → B) → Type p}
{step : (c : C) {A : Type a} (f : A → B) → P c f → ∥ A ∥¹ → B}
{f : (c : C) → A c → B} {eq : x ≡ y} {c} →
subst (λ x → Coherently (P x) (step x) (f x)) eq c .property ≡
subst (λ x → P x (f x)) eq (c .property)
subst-Coherently-property
{P = P} {step = step} {f = f} {eq = eq} {c = c} =
elim¹
(λ eq →
subst (λ x → Coherently (P x) (step x) (f x)) eq c .property ≡
subst (λ x → P x (f x)) eq (c .property))
(subst (λ x → Coherently (P x) (step x) (f x)) (refl _) c .property ≡⟨ cong property $ subst-refl _ _ ⟩
c .property ≡⟨ sym $ subst-refl _ _ ⟩∎
subst (λ x → P x (f x)) (refl _) (c .property) ∎)
eq
------------------------------------------------------------------------
-- Coherently-with-restriction
-- A variant of Coherently. An extra predicate Q is included, so that
-- one can restrict the "f" functions (and their domains).
record Coherently-with-restriction
{A : Type a} {B : Type b}
(P : {A : Type a} → (A → B) → Type p)
(step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B)
(f : A → B)
(Q : {A : Type a} → (A → B) → Type q)
(pres : {A : Type a} {f : A → B} {p : P f} →
Q f → Q (step f p))
(q : Q f) : Type p where
coinductive
field
property : P f
coherent :
Coherently-with-restriction
P step (step f property)
Q pres (pres q)
open Coherently-with-restriction public
-- Coherently P step f is equivalent to
-- Coherently-with-restriction P step f Q pres q.
Coherently≃Coherently-with-restriction :
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B}
{Q : {A : Type a} → (A → B) → Type q}
{pres : {A : Type a} {f : A → B} {p : P f} → Q f → Q (step f p)}
{q : Q f} →
Coherently P step f ≃ Coherently-with-restriction P step f Q pres q
Coherently≃Coherently-with-restriction
{P = P} {step = step} {Q = Q} {pres = pres} =
Eq.↔→≃ to (from _)
(λ c → _↔_.from ≡↔≡ (to-from c))
(λ c → _↔_.from ≡↔≡ (from-to _ c))
where
to :
Coherently P step f →
Coherently-with-restriction P step f Q pres q
to c .property = c .property
to c .coherent = to (c .coherent)
from :
∀ q →
Coherently-with-restriction P step f Q pres q →
Coherently P step f
from _ c .property = c .property
from _ c .coherent = from _ (c .coherent)
to-from :
(c : Coherently-with-restriction P step f Q pres q) →
to (from q c) P.≡ c
to-from c i .property = c .property
to-from c i .coherent = to-from (c .coherent) i
from-to : ∀ q (c : Coherently P step f) → from q (to c) P.≡ c
from-to _ c i .property = c .property
from-to q c i .coherent = from-to (pres q) (c .coherent) i
-- A container that is used to define Coherently-with-restriction′.
Coherently-with-restriction-container :
{B : Type b}
(P : {A : Type a} → (A → B) → Type p)
(step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B) →
(Q : {A : Type a} → (A → B) → Type q) →
({A : Type a} {f : A → B} {p : P f} → Q f → Q (step f p)) →
Container (∃ λ (A : Type a) → ∃ λ (f : A → B) → Q f) p lzero
Coherently-with-restriction-container P step _ pres = λ where
.Shape (_ , f , _) → P f
.Position _ → ⊤
.index {o = A , f , q} {s = p} _ → ∥ A ∥¹ , step f p , pres q
-- A variant of Coherently-with-restriction, defined using an indexed
-- container.
Coherently-with-restriction′ :
{A : Type a} {B : Type b}
(P : {A : Type a} → (A → B) → Type p)
(step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B) →
(f : A → B) →
(Q : {A : Type a} → (A → B) → Type q) →
({A : Type a} {f : A → B} {p : P f} → Q f → Q (step f p)) →
Q f →
Type (lsuc a ⊔ b ⊔ p ⊔ q)
Coherently-with-restriction′ P step f Q pres q =
M (Coherently-with-restriction-container P step Q pres) (_ , f , q)
-- Coherently-with-restriction P step f Q pres q is equivalent to
-- Coherently-with-restriction′ P step f Q pres q.
Coherently-with-restriction≃Coherently-with-restriction′ :
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B}
{Q : {A : Type a} → (A → B) → Type q}
{pres : {A : Type a} {f : A → B} {p : P f} → Q f → Q (step f p)}
{q : Q f} →
Coherently-with-restriction P step f Q pres q ≃
Coherently-with-restriction′ P step f Q pres q
Coherently-with-restriction≃Coherently-with-restriction′
{P = P} {step = step} {Q = Q} {pres = pres} =
Eq.↔→≃ to (from _)
(λ c → _↔_.from ≡↔≡ (to-from _ c))
(λ c → _↔_.from ≡↔≡ (from-to c))
where
to :
Coherently-with-restriction P step f Q pres q →
Coherently-with-restriction′ P step f Q pres q
to c .out-M .proj₁ = c .property
to c .out-M .proj₂ _ = to (c .coherent)
from :
∀ q →
Coherently-with-restriction′ P step f Q pres q →
Coherently-with-restriction P step f Q pres q
from _ c .property = c .out-M .proj₁
from _ c .coherent = from _ (c .out-M .proj₂ _)
to-from :
∀ q (c : Coherently-with-restriction′ P step f Q pres q) →
to (from q c) P.≡ c
to-from _ c i .out-M .proj₁ = c .out-M .proj₁
to-from q c i .out-M .proj₂ _ = to-from (pres q) (c .out-M .proj₂ _) i
from-to :
(c : Coherently-with-restriction P step f Q pres q) →
from q (to c) P.≡ c
from-to c i .property = c .property
from-to c i .coherent = from-to (c .coherent) i
------------------------------------------------------------------------
-- H-levels
-- I think that Paolo Capriotti suggested that one could prove that
-- certain instances of Coherently have certain h-levels by using the
-- result (due to Ahrens, Capriotti and Spadotti, see "Non-wellfounded
-- trees in Homotopy Type Theory") that M-types for indexed containers
-- have h-level n if all shapes have h-level n. The use of containers
-- with "restrictions" is my idea.
-- If P f has h-level n for every function f for which Q holds, then
-- Coherently-with-restriction P step f Q pres q has h-level n
-- (assuming univalence).
H-level-Coherently-with-restriction :
Univalence (lsuc a ⊔ b ⊔ p ⊔ q) →
Univalence (lsuc a ⊔ b ⊔ q) →
{B : Type b}
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B}
{Q : {A : Type a} → (A → B) → Type q}
{pres : {A : Type a} {f : A → B} {p : P f} → Q f → Q (step f p)}
{q : Q f} →
({A : Type a} {f : A → B} → Q f → H-level n (P f)) →
H-level n (Coherently-with-restriction P step f Q pres q)
H-level-Coherently-with-restriction
{n = n} univ₁ univ₂ {B = B} {P = P} {step = step} {f = f} {Q = Q}
{pres = pres} {q = q} =
(∀ {A} {f : A → B} → Q f → H-level n (P f)) ↝⟨ (λ h (_ , _ , q) → h q) ⟩
(((_ , f , _) : ∃ λ A → ∃ λ (f : A → B) → Q f) → H-level n (P f)) ↝⟨ (λ h → H-level-M univ₁ univ₂ h) ⟩
H-level n (Coherently-with-restriction′ P step f Q pres q) ↝⟨ H-level-cong _ n
(inverse Coherently-with-restriction≃Coherently-with-restriction′) ⟩□
H-level n (Coherently-with-restriction P step f Q pres q) □
-- If P f has h-level n, and (for any f and p) P (step f p) has
-- h-level n when P f has h-level n, then Coherently P step f has
-- h-level n (assuming univalence).
H-level-Coherently :
{B : Type b}
{P : {A : Type a} → (A → B) → Type p}
{step : {A : Type a} (f : A → B) → P f → ∥ A ∥¹ → B}
{f : A → B} →
Univalence (lsuc a ⊔ b ⊔ p) →
H-level n (P f) →
({A : Type a} {f : A → B} {p : P f} →
H-level n (P f) → H-level n (P (step f p))) →
H-level n (Coherently P step f)
H-level-Coherently {n = n} {P = P} {step = step} {f = f} univ h₁ h₂ =
$⟨ H-level-Coherently-with-restriction univ univ id ⟩
H-level n
(Coherently-with-restriction P step f
(λ f → H-level n (P f)) h₂ h₁) ↝⟨ H-level-cong _ n (inverse Coherently≃Coherently-with-restriction) ⦂ (_ → _) ⟩□
H-level n (Coherently P step f) □
-- A variant of H-level-Coherently for type-valued functions.
H-level-Coherently-→Type :
{P : {A : Type a} → (A → Type f) → Type p}
{step : {A : Type a} (F : A → Type f) → P F → ∥ A ∥¹ → Type f}
{F : A → Type f} →
Univalence (lsuc a ⊔ p ⊔ lsuc f) →
Univalence (lsuc (a ⊔ f)) →
((a : A) → H-level n (F a)) →
({A : Type a} {F : A → Type f} →
((a : A) → H-level n (F a)) → H-level n (P F)) →
({A : Type a} {F : A → Type f} {p : P F} →
((a : A) → H-level n (F a)) →
(a : A) → H-level n (step F p ∣ a ∣)) →
H-level n (Coherently P step F)
H-level-Coherently-→Type
{a = a} {f = f} {n = n} {P = P} {step = step} {F = F}
univ₁ univ₂ h₁ h₂ h₃ =
$⟨ H-level-Coherently-with-restriction univ₁ univ₂ h₂ ⟩
H-level n
(Coherently-with-restriction P step F
(λ F → ∀ a → H-level n (F a)) h₃′ h₁) ↝⟨ H-level-cong _ n (inverse Coherently≃Coherently-with-restriction) ⦂ (_ → _) ⟩□
H-level n (Coherently P step F) □
where
h₃′ :
{A : Type a} {F : A → Type f} {p : P F} →
((a : A) → H-level n (F a)) →
(a : ∥ A ∥¹) → H-level n (step F p a)
h₃′ h = O.elim λ where
.O.∣∣ʳ → h₃ h
.O.∣∣-constantʳ _ _ → H-level-propositional ext n _ _
| {
"alphanum_fraction": 0.4678757543,
"avg_line_length": 37.9791666667,
"ext": "agda",
"hexsha": "edd4458b091a824a6c8e0cbda4a77030366cadd1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z",
"max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/dependent-lenses",
"max_forks_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/dependent-lenses",
"max_issues_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive.agda",
"max_line_length": 145,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/dependent-lenses",
"max_stars_repo_path": "src/Lens/Non-dependent/Higher/Coherently/Coinductive.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z",
"num_tokens": 10900,
"size": 29168
} |
module Haskell.Prim.Real where
open import Haskell.Prim
open import Haskell.Prim.Ord
open import Haskell.Prim.Enum
open import Haskell.Prim.Num
open import Haskell.Prim.Eq
open import Haskell.Prim.Int
open import Haskell.Prim.Integer
-- infixr 8 _^_ _^^_
-- infixl 7 _/_ _`quot`_ _`rem`_ _`div`_ _`mod`_
-- infixl 7 _%_
data Ratio (a : Set) : Set where
_:%_ : a -> a -> Ratio a
record Integral (a : Set) : Set where
field
toInteger : a -> Integer
open Integral ⦃ ... ⦄ public
instance
isIntegralInt : Integral Int
isIntegralInt . toInteger n = intToInteger n
infinity : Ratio Integer
notANumber : Ratio Integer
infinity = (toInteger 1) :% (toInteger 0)
notANumber = (toInteger 0) :% (toInteger 0)
-- _%_ : {{Integral a}} -> a -> a -> Ratio a
numerator : Ratio a -> a
denominator : Ratio a -> a
-- reduce : {{Integral a}} -> a -> a -> Ratio a
numerator (x :% _) = x
denominator (_ :% y) = y
-- record Real {Num a} (a : Set) : Set where
-- field
-- toRational : a -> Ratio Integer
| {
"alphanum_fraction": 0.6466019417,
"avg_line_length": 20.6,
"ext": "agda",
"hexsha": "1cc20f5c1cbe629f0e4dac5a32b27de74d94f21f",
"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": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ioanasv/agda2hs",
"max_forks_repo_path": "lib/Haskell/Prim/Real.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"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": "ioanasv/agda2hs",
"max_issues_repo_path": "lib/Haskell/Prim/Real.agda",
"max_line_length": 49,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ioanasv/agda2hs",
"max_stars_repo_path": "lib/Haskell/Prim/Real.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z",
"num_tokens": 334,
"size": 1030
} |
------------------------------------------------------------------------------
-- The gcd is commutative
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.GCD.Total.CommutativeI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Induction.NonAcc.LexicographicI
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.PropertiesI
open import FOTC.Program.GCD.Total.ConversionRulesI
open import FOTC.Program.GCD.Total.GCD
------------------------------------------------------------------------------
-- Informal proof:
-- 1. gcd 0 n = n -- gcd def
-- = gcd n 0 -- gcd def
-- 2. gcd n 0 = n -- gcd def
-- = gcd 0 n -- gcd def
-- 3.1. Case: S m > S n
-- gcd (S m) (S n) = gcd (S m - S n) (S n) -- gcd def
-- = gcd (S n) (S m - S n) -- IH
-- = gcd (S n) (S m) -- gcd def
-- 3.2. Case: S m ≮ S n
-- gcd (S m) (S n) = gcd (S m) (S n - S m) -- gcd def
-- = gcd (S n - S m) (S m) -- IH
-- = gcd (S n) (S m) -- gcd def
------------------------------------------------------------------------------
-- Commutativity property.
Comm : D → D → Set
Comm t t' = gcd t t' ≡ gcd t' t
{-# ATP definition Comm #-}
x>y→y≯x : ∀ {m n} → N m → N n → m > n → n ≯ m
x>y→y≯x nzero Nn 0>n = ⊥-elim (0>x→⊥ Nn 0>n)
{-# CATCHALL #-}
x>y→y≯x Nm nzero _ = 0≯x Nm
x>y→y≯x (nsucc {m} Nm) (nsucc {n} Nn) Sm>Sn =
trans (lt-SS m n) (x>y→y≯x Nm Nn (trans (sym (lt-SS n m)) Sm>Sn))
postulate x≯Sy→Sy>x : ∀ {m n} → N m → N n → m ≯ succ₁ n → succ₁ n > m
-- x≯Sy→Sy>x {n = n} nzero Nn _ = <-0S n
-- x≯Sy→Sy>x {n = n} (nsucc {m} Nm) Nn h = {!!}
------------------------------------------------------------------------------
-- gcd 0 0 is commutative.
gcd-00-comm : Comm zero zero
gcd-00-comm = refl
------------------------------------------------------------------------------
-- gcd (succ₁ n) 0 is commutative.
gcd-S0-comm : ∀ n → Comm (succ₁ n) zero
gcd-S0-comm n = trans (gcd-S0 n) (sym (gcd-0S n))
------------------------------------------------------------------------------
-- gcd (succ₁ m) (succ₁ n) when succ₁ m > succ₁ n is commutative.
gcd-S>S-comm : ∀ {m n} → N m → N n →
Comm (succ₁ m ∸ succ₁ n) (succ₁ n) →
succ₁ m > succ₁ n →
Comm (succ₁ m) (succ₁ n)
gcd-S>S-comm {m} {n} Nm Nn ih Sm>Sn =
gcd (succ₁ m) (succ₁ n)
≡⟨ gcd-S>S m n Sm>Sn ⟩
gcd (succ₁ m ∸ succ₁ n) (succ₁ n)
≡⟨ ih ⟩
gcd (succ₁ n) (succ₁ m ∸ succ₁ n)
≡⟨ sym (gcd-S≯S n m (x>y→y≯x (nsucc Nm) (nsucc Nn) Sm>Sn)) ⟩
gcd (succ₁ n) (succ₁ m) ∎
------------------------------------------------------------------------------
-- gcd (succ₁ m) (succ₁ n) when succ₁ m ≯ succ₁ n is commutative.
gcd-S≯S-comm : ∀ {m n} → N m → N n →
Comm (succ₁ m) (succ₁ n ∸ succ₁ m) →
succ₁ m ≯ succ₁ n →
Comm (succ₁ m) (succ₁ n)
gcd-S≯S-comm {m} {n} Nm Nn ih Sm≯Sn =
gcd (succ₁ m) (succ₁ n)
≡⟨ gcd-S≯S m n Sm≯Sn ⟩
gcd (succ₁ m) (succ₁ n ∸ succ₁ m)
≡⟨ ih ⟩
gcd (succ₁ n ∸ succ₁ m) (succ₁ m)
≡⟨ sym (gcd-S>S n m (x≯Sy→Sy>x (nsucc Nm) Nn Sm≯Sn)) ⟩
gcd (succ₁ n) (succ₁ m) ∎
------------------------------------------------------------------------------
-- gcd m n when m > n is commutative.
gcd-x>y-comm :
∀ {m n} → N m → N n →
(∀ {o p} → N o → N p → Lexi o p m n → Comm o p) →
m > n →
Comm m n
gcd-x>y-comm nzero Nn _ 0>n = ⊥-elim (0>x→⊥ Nn 0>n)
gcd-x>y-comm (nsucc {n} _) nzero _ _ = gcd-S0-comm n
gcd-x>y-comm (nsucc {m} Nm) (nsucc {n} Nn) ah Sm>Sn = gcd-S>S-comm Nm Nn ih Sm>Sn
where
-- Inductive hypothesis.
ih : Comm (succ₁ m ∸ succ₁ n) (succ₁ n)
ih = ah {succ₁ m ∸ succ₁ n}
{succ₁ n}
(∸-N (nsucc Nm) (nsucc Nn))
(nsucc Nn)
([Sx∸Sy,Sy]<[Sx,Sy] Nm Nn)
------------------------------------------------------------------------------
-- gcd m n when m ≯ n is commutative.
gcd-x≯y-comm :
∀ {m n} → N m → N n →
(∀ {o p} → N o → N p → Lexi o p m n → Comm o p) →
m ≯ n →
Comm m n
gcd-x≯y-comm nzero nzero _ _ = gcd-00-comm
gcd-x≯y-comm nzero (nsucc {n} _) _ _ = sym (gcd-S0-comm n)
gcd-x≯y-comm (nsucc _) nzero _ Sm≯0 = ⊥-elim (S≯0→⊥ Sm≯0)
gcd-x≯y-comm (nsucc {m} Nm) (nsucc {n} Nn) ah Sm≯Sn = gcd-S≯S-comm Nm Nn ih Sm≯Sn
where
-- Inductive hypothesis.
ih : Comm (succ₁ m) (succ₁ n ∸ succ₁ m)
ih = ah {succ₁ m}
{succ₁ n ∸ succ₁ m}
(nsucc Nm)
(∸-N (nsucc Nn) (nsucc Nm))
([Sx,Sy∸Sx]<[Sx,Sy] Nm Nn)
------------------------------------------------------------------------------
-- gcd is commutative.
gcd-comm : ∀ {m n} → N m → N n → Comm m n
gcd-comm = Lexi-wfind A h
where
A : D → D → Set
A i j = Comm i j
h : ∀ {i j} → N i → N j → (∀ {k l} → N k → N l → Lexi k l i j → A k l) →
A i j
h Ni Nj ah = case (gcd-x>y-comm Ni Nj ah)
(gcd-x≯y-comm Ni Nj ah)
(x>y∨x≯y Ni Nj)
| {
"alphanum_fraction": 0.4241926656,
"avg_line_length": 36.298013245,
"ext": "agda",
"hexsha": "2e00de36f1d93b8fb9376fef886c1ab206489fb9",
"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/Program/GCD/Total/CommutativeI.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/Program/GCD/Total/CommutativeI.agda",
"max_line_length": 81,
"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/Program/GCD/Total/CommutativeI.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": 1964,
"size": 5481
} |
{-# OPTIONS --type-in-type #-}
module TooFewArgsWrongType where
open import AgdaPrelude
myFun : Vec Nat Zero -> Nat -> Nat
myFun x y = y
myApp : Nat
myApp = (myFun Zero)
| {
"alphanum_fraction": 0.683908046,
"avg_line_length": 15.8181818182,
"ext": "agda",
"hexsha": "21ccd0a4aabac35e51b1689421f4572fc266d4e5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "JoeyEremondi/lambda-pi-constraint",
"max_forks_repo_path": "thesisExamples/TooFewArgsWrongType.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "JoeyEremondi/lambda-pi-constraint",
"max_issues_repo_path": "thesisExamples/TooFewArgsWrongType.agda",
"max_line_length": 34,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "JoeyEremondi/lambda-pi-constraint",
"max_stars_repo_path": "thesisExamples/TooFewArgsWrongType.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-05T20:21:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-16T11:14:56.000Z",
"num_tokens": 54,
"size": 174
} |
module HoleFilling where
data Bool : Set where
false : Bool
true : Bool
_∧_ : Bool → Bool → Bool
false ∧ b = false
true ∧ b = b
| {
"alphanum_fraction": 0.6323529412,
"avg_line_length": 13.6,
"ext": "agda",
"hexsha": "a4053dee3d7726f01456b79bbee80e14b36dbdc3",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z",
"max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shouya/thinking-dumps",
"max_forks_repo_path": "learyouanagda/HoleFilling.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc",
"max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shouya/thinking-dumps",
"max_issues_repo_path": "learyouanagda/HoleFilling.agda",
"max_line_length": 24,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shouya/thinking-dumps",
"max_stars_repo_path": "learyouanagda/HoleFilling.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z",
"num_tokens": 47,
"size": 136
} |
open import Agda.Builtin.Nat
record R : Set where
field
x : Nat
open R {{...}}
f₁ f₂ : R
-- This is fine.
x ⦃ f₁ ⦄ = 0
-- WAS: THIS WORKS BUT MAKES NO SENSE!!!
f₂ ⦃ .x ⦄ = 0
-- Error:
-- Cannot eliminate type R with pattern ⦃ .x ⦄ (suggestion: write .(x)
-- for a dot pattern, or remove the braces for a postfix projection)
-- when checking the clause left hand side
-- f₂ ⦃ .x ⦄
| {
"alphanum_fraction": 0.6208651399,
"avg_line_length": 17.0869565217,
"ext": "agda",
"hexsha": "dc84e610cb9ad064c6efc346c0c7372184093270",
"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/Issue3289.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/Issue3289.agda",
"max_line_length": 70,
"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/Issue3289.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 143,
"size": 393
} |
module _ where
postulate
F : Set → Set
A : Set
module A (X : Set) where
postulate T : Set
module B where
private module M = A A
open M
postulate t : F T
postulate
op : {A : Set} → A → A → A
open A A
foo : F T
foo = op B.t {!!} -- ?0 : F .ReduceNotInScope.B.M.T
| {
"alphanum_fraction": 0.573943662,
"avg_line_length": 12.347826087,
"ext": "agda",
"hexsha": "4c6f12d22a73d93c44dbab8e13ac273d4d2f910a",
"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/Issue721.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/Issue721.agda",
"max_line_length": 53,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue721.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": 109,
"size": 284
} |
module Formalization.ClassicalPropositionalLogic.Syntax where
import Lvl
open import Functional
open import Sets.PredicateSet using (PredSet)
open import Type
private variable ℓₚ ℓ : Lvl.Level
module _ (P : Type{ℓₚ}) where
-- Formulas.
-- Inductive definition of the grammatical elements of the language of propositional logic.
-- Note: It is possible to reduce the number of formula variants to for example {•,¬,∨} or {•,¬,∧} (This is called propositional adequacy/functional completeness).
data Formula : Type{ℓₚ} where
•_ : P → Formula -- Propositional constants
⊤ : Formula -- Tautology (Top / True)
⊥ : Formula -- Contradiction (Bottom / False)
¬_ : Formula → Formula -- Negation (Not)
_∧_ : Formula → Formula → Formula -- Conjunction (And)
_∨_ : Formula → Formula → Formula -- Disjunction (Or)
_⟶_ : Formula → Formula → Formula -- Implication
_⟷_ : Formula → Formula → Formula -- Equivalence
Formulas : Type{ℓₚ Lvl.⊔ Lvl.𝐒(ℓ)}
Formulas{ℓ} = PredSet{ℓ}(Formula)
infix 1011 •_
infix 1010 ¬_ ¬¬_
infixr 1005 _∧_
infixr 1004 _∨_
infixr 1000 _⟷_ _⟶_
module _ {P : Type{ℓₚ}} where
-- Double negation
-- ¬¬_ : Formula(P) → Formula(P)
-- ¬¬_ : (¬_) ∘ (¬_)
-- Reverse implication
_⟵_ : Formula(P) → Formula(P) → Formula(P)
_⟵_ = swap(_⟶_)
-- (Nor)
_⊽_ : Formula(P) → Formula(P) → Formula(P)
_⊽_ = (¬_) ∘₂ (_∨_)
-- (Nand)
_⊼_ : Formula(P) → Formula(P) → Formula(P)
_⊼_ = (¬_) ∘₂ (_∧_)
-- (Exclusive or / Xor)
_⊻_ : Formula(P) → Formula(P) → Formula(P)
_⊻_ = (¬_) ∘₂ (_⟷_)
infixl 1000 _⟵_
| {
"alphanum_fraction": 0.6286972939,
"avg_line_length": 27.3965517241,
"ext": "agda",
"hexsha": "cd77557cf5ec8446ee245ee6d428fa161204acf1",
"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/ClassicalPropositionalLogic/Syntax.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/ClassicalPropositionalLogic/Syntax.agda",
"max_line_length": 165,
"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/ClassicalPropositionalLogic/Syntax.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": 574,
"size": 1589
} |
-- 2010-10-15
module Issue331 where
record ⊤ : Set where
constructor tt
data Wrap (I : Set) : Set where
wrap : I → Wrap I
data B (I : Set) : Wrap I → Set₁ where
b₁ : ∀ i → B I (wrap i)
b₂ : {w : Wrap I} → B I w → B I w
b₃ : (X : Set){w : Wrap I}(f : X → B I w) → B I w
ok : B ⊤ (wrap tt)
ok = b₂ (b₁ _)
-- Issue 331 was: Unsolved meta: _45 : ⊤
bad : Set → B ⊤ (wrap tt)
bad X = b₃ X λ x → b₁ _
| {
"alphanum_fraction": 0.5304136253,
"avg_line_length": 17.8695652174,
"ext": "agda",
"hexsha": "66a009c9d309da28b11da27935980d025ad50281",
"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/Issue331.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/Issue331.agda",
"max_line_length": 51,
"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/Issue331.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": 177,
"size": 411
} |
open import guarded-recursion.prelude
module guarded-recursion.model where
-- ℂʷᵒᵖ (ℂ^{ω}^{op})
-- Notation:
-- For the category ℂ we use superscript 'c' to disambiguate (e.g. _→ᶜ_)
-- We use ᵖ for the presheaf category.
module Presheaf
{o m}
(Objᶜ : Type_ o)
(_→ᶜ_ : Objᶜ → Objᶜ → Type_ m)
(idᶜ : {A : Objᶜ} → A →ᶜ A)
(_∘ᶜ_ : {A B C : Objᶜ} → (B →ᶜ C) → (A →ᶜ B) → (A →ᶜ C))
(∘-idᶜ : {A B : Objᶜ} {f : A →ᶜ B} → f ∘ᶜ idᶜ ≡ f)
(id-∘ᶜ : {A B : Objᶜ} {f : A →ᶜ B} → idᶜ ∘ᶜ f ≡ f)
(∘-assocᶜ : {A B C D : Objᶜ}
{f : C →ᶜ D} {g : B →ᶜ C} {h : A →ᶜ B}
→ (f ∘ᶜ g) ∘ᶜ h ≡ f ∘ᶜ (g ∘ᶜ h))
(𝟙ᶜ : Objᶜ)
(!ᶜ : {A : Objᶜ} → A →ᶜ 𝟙ᶜ)
(!-uniqᶜ : {A : Objᶜ} {f : A →ᶜ 𝟙ᶜ} → f ≡ !ᶜ)
where
-- Index preserving maps
_→ᶜ°_ : (A B : ℕ → Objᶜ) → Type_ _
A →ᶜ° B = (n : ℕ) → A n →ᶜ B n
Endoᶜ° : (ℕ → Objᶜ) → Type_ _
Endoᶜ° A = A →ᶜ° A
-- Restriction maps
Rmap : (ℕ → Objᶜ) → Type_ _
Rmap A = (A ∘ S) →ᶜ° A
Objᵖ : Type_ _
Objᵖ = Σ (ℕ → Objᶜ) Rmap
_→ᵖ_ : Objᵖ → Objᵖ → Type_ _
(A , rᴬ) →ᵖ (B , rᴮ) = Σ (A →ᶜ° B) λ f →
(n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n)
[_]ᵖ : Objᶜ → Objᵖ
[ A ]ᵖ = (λ _ → A) , (λ _ → idᶜ)
⟨_⟩ᵖ : {A B : Objᶜ} → A →ᶜ B → [ A ]ᵖ →ᵖ [ B ]ᵖ
⟨ f ⟩ᵖ = (λ _ → f) , (λ n → ∘-idᶜ ∙ ! id-∘ᶜ)
idᵖ : {A : Objᵖ} → A →ᵖ A
idᵖ = (λ n → idᶜ) , (λ n → id-∘ᶜ ∙ ! ∘-idᶜ)
{-
B ---f--> D
^ ^
| |
g h
| |
A ---i--> C
-}
module _ {A B C D}
(f : B →ᶜ D) (g : A →ᶜ B)
(h : C →ᶜ D) (i : A →ᶜ C) where
Squareᶜ = f ∘ᶜ g ≡ h ∘ᶜ i
module _ {A B C} {f f' : B →ᶜ C} {g g' : A →ᶜ B} where
ap-∘ᶜ : f ≡ f' → g ≡ g' → f ∘ᶜ g ≡ f' ∘ᶜ g'
ap-∘ᶜ p q = ap (λ x → x ∘ᶜ g) p ∙ ap (_∘ᶜ_ f') q
!-irrᶜ : {A : Objᶜ} {f g : A →ᶜ 𝟙ᶜ} → f ≡ g
!-irrᶜ = !-uniqᶜ ∙ ! !-uniqᶜ
∘-!ᶜ : {A : Objᶜ} {f : 𝟙ᶜ →ᶜ A} { !g : 𝟙ᶜ →ᶜ 𝟙ᶜ} → f ∘ᶜ !g ≡ f
∘-!ᶜ = ap-∘ᶜ idp !-irrᶜ ∙ ∘-idᶜ
with-∘-assocᶜ : {A B C C' D : Objᶜ}
{f : C →ᶜ D} {g : B →ᶜ C}
{f' : C' →ᶜ D} {g' : B →ᶜ C'}
{h : A →ᶜ B}
→ f ∘ᶜ g ≡ f' ∘ᶜ g'
→ f ∘ᶜ (g ∘ᶜ h) ≡ f' ∘ᶜ (g' ∘ᶜ h)
with-∘-assocᶜ p = ! ∘-assocᶜ ∙ ap-∘ᶜ p idp ∙ ∘-assocᶜ
with-!∘-assocᶜ : {A B B' C D : Objᶜ}
{f : C →ᶜ D}
{g : B →ᶜ C} {h : A →ᶜ B}
{g' : B' →ᶜ C} {h' : A →ᶜ B'}
→ g ∘ᶜ h ≡ g' ∘ᶜ h'
→ (f ∘ᶜ g) ∘ᶜ h ≡ (f ∘ᶜ g') ∘ᶜ h'
with-!∘-assocᶜ p = ∘-assocᶜ ∙ ap-∘ᶜ idp p ∙ ! ∘-assocᶜ
{-
B ---f--> D ---e--> F
^ ^ ^
| | |
g L h R j
| | |
A ---i--> C ---k--> E
-}
module _
{A B C D E F}
{f : B →ᶜ D} {g : A →ᶜ B}
{h : C →ᶜ D} {i : A →ᶜ C}
{e : D →ᶜ F}
{j : E →ᶜ F} {k : C →ᶜ E}
(L : Squareᶜ f g h i)
(R : Squareᶜ e h j k) where
private
efg-ehi : (e ∘ᶜ f) ∘ᶜ g ≡ e ∘ᶜ (h ∘ᶜ i)
efg-ehi = ∘-assocᶜ ∙ ap-∘ᶜ idp L
ehi-jki : e ∘ᶜ (h ∘ᶜ i) ≡ j ∘ᶜ (k ∘ᶜ i)
ehi-jki = ! ∘-assocᶜ ∙ ap-∘ᶜ R idp ∙ ∘-assocᶜ
LR : Squareᶜ (e ∘ᶜ f) g j (k ∘ᶜ i)
LR = efg-ehi ∙ ehi-jki
{-
X
/ . \
/ . \
/ . \
f/ .u! \g
/ . \
v v v
A <---fst--- A×B ---snd---> B
-}
module _
{A B A×B X : Objᶜ}
{fstᶜ : A×B →ᶜ A}
{sndᶜ : A×B →ᶜ B}
{f : X →ᶜ A}
{g : X →ᶜ B}
(u! : X →ᶜ A×B)
(fst-u! : fstᶜ ∘ᶜ u! ≡ f)
(snd-u! : sndᶜ ∘ᶜ u! ≡ g)
where
1-ProductDiagram = fst-u! , snd-u!
module ProductDiagram
{A B A×B : Objᶜ}
{fstᶜ : A×B →ᶜ A}
{sndᶜ : A×B →ᶜ B}
{<_,_>ᶜ : ∀ {X} → X →ᶜ A → X →ᶜ B → X →ᶜ A×B}
(fst-<,> : ∀ {X} {f : X →ᶜ A} {g : X →ᶜ B}
→ fstᶜ ∘ᶜ < f , g >ᶜ ≡ f)
(snd-<,> : ∀ {X} {f : X →ᶜ A} {g : X →ᶜ B}
→ sndᶜ ∘ᶜ < f , g >ᶜ ≡ g)
(<,>-uniq! : ∀ {A B X : Objᶜ} {f : X →ᶜ A×B}
→ < fstᶜ ∘ᶜ f , sndᶜ ∘ᶜ f >ᶜ ≡ f)
where
module _ {X} {f : X →ᶜ A} {g : X →ᶜ B} where
1-productDiagram = 1-ProductDiagram < f , g >ᶜ fst-<,> snd-<,>
infixr 9 _∘ᵖ_
_∘ᵖ_ : {A B C : Objᵖ} → (B →ᵖ C) → (A →ᵖ B) → (A →ᵖ C)
(f , ☐f) ∘ᵖ (g , ☐g) = (λ n → f n ∘ᶜ g n)
, (λ n → LR (☐g n) (☐f n))
-- TODO: the real thing™
_≡ᵖ_ : {A B : Objᵖ} (f g : A →ᵖ B) → Type_ _
(f , _) ≡ᵖ (g , _) = ∀ n → f n ≡ g n
infix 2 _≡ᵖ_
∘-idᵖ : {A B : Objᵖ} {f : A →ᵖ B} → f ∘ᵖ idᵖ ≡ᵖ f
∘-idᵖ _ = ∘-idᶜ
id-∘ᵖ : {A B : Objᵖ} {f : A →ᵖ B} → idᵖ ∘ᵖ f ≡ᵖ f
id-∘ᵖ _ = id-∘ᶜ
∘-assocᵖ : {A B C D : Objᵖ}
{f : C →ᵖ D} {g : B →ᵖ C} {h : A →ᵖ B}
→ (f ∘ᵖ g) ∘ᵖ h ≡ᵖ f ∘ᵖ (g ∘ᵖ h)
∘-assocᵖ _ = ∘-assocᶜ
𝟙ᵖ : Objᵖ
𝟙ᵖ = (λ _ → 𝟙ᶜ) , (λ _ → idᶜ)
!ᵖ : {A : Objᵖ} → A →ᵖ 𝟙ᵖ
!ᵖ = (λ _ → !ᶜ) , (λ _ → !-irrᶜ)
!-uniqᵖ : {A : Objᵖ} {f : A →ᵖ 𝟙ᵖ} → f ≡ᵖ !ᵖ
!-uniqᵖ _ = !-uniqᶜ
▸ : Objᵖ → Objᵖ
▸ (A , rᴬ) = ▸A , ▸rᴬ
module Later where
▸A : ℕ → Objᶜ
▸A 0 = 𝟙ᶜ
▸A (S n) = A n
▸rᴬ : (n : ℕ) → ▸A (1 + n) →ᶜ ▸A n
▸rᴬ 0 = !ᶜ
▸rᴬ (S n) = rᴬ n
-- ▸ functor action on morphisms
▸[_] : {A B : Objᵖ} → (A →ᵖ B) → ▸ A →ᵖ ▸ B
▸[_] {A , rᴬ} {B , rᴮ} (f , ☐) = ▸f , ▸☐
module Later[] where
open Later A rᴬ
open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)
▸f : ▸A →ᶜ° ▸B
▸f 0 = !ᶜ
▸f (S n) = f n
▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬ n ≡ ▸rᴮ n ∘ᶜ ▸f (1 + n)
▸☐ 0 = !-irrᶜ
▸☐ (S n) = ☐ n
▸-id : {A : Objᵖ}
→ ▸[ idᵖ {A} ] ≡ᵖ idᵖ
▸-id 0 = !-irrᶜ
▸-id (S n) = idp
▸-∘ : {A B C : Objᵖ} {f : B →ᵖ C} {g : A →ᵖ B}
→ ▸[ f ∘ᵖ g ] ≡ᵖ ▸[ f ] ∘ᵖ ▸[ g ]
▸-∘ 0 = !-irrᶜ
▸-∘ (S n) = idp
{-
▸-[]ᵖ : {A : Objᶜ} → ▸ [ A ]ᵖ →ᵖ [ A ]ᵖ
▸-[]ᵖ {A} = ▸f , ▸☐
where
open Later (λ _ → A) (λ _ → idᶜ)
▸f : ▸A →ᶜ° (λ _ → A)
▸f O = {!!}
▸f (S n) = idᶜ
▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬ n ≡ idᶜ ∘ᶜ ▸f (1 + n)
▸☐ O = {!!}
▸☐ (S n) = idp
-}
next : {A : Objᵖ} → A →ᵖ ▸ A
next {A , rᴬ} = f , ☐
module Next where
open Later A rᴬ
f : (n : ℕ) → A n →ᶜ ▸A n
f 0 = !ᶜ
f (S n) = rᴬ n
☐ : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ ▸rᴬ n ∘ᶜ f (1 + n)
☐ 0 = idp
☐ (S n) = idp
next-nat : {A B : Objᵖ} {f : A →ᵖ B} → ▸[ f ] ∘ᵖ next ≡ᵖ next ∘ᵖ f
next-nat 0 = !-irrᶜ
next-nat {f = f , ☐} (S n) = ☐ n
module _ {A : Objᵖ} (f : A →ᵖ A) where
Contractive = Σ (▸ A →ᵖ A) λ g → f ≡ᵖ g ∘ᵖ next
module _ {A B : Objᶜ} {i : B →ᶜ B} {f : A →ᶜ B} where
id-∘ᶜ' : i ≡ idᶜ → i ∘ᶜ f ≡ f
id-∘ᶜ' p = ap-∘ᶜ p idp ∙ id-∘ᶜ
module _ {A B : Objᶜ} {i : A →ᶜ A} {f : A →ᶜ B} where
∘-idᶜ' : i ≡ idᶜ → f ∘ᶜ i ≡ f
∘-idᶜ' p = ap-∘ᶜ idp p ∙ ∘-idᶜ
fix1 : {A : Objᵖ} (f : ▸ A →ᵖ A) → 𝟙ᵖ →ᵖ A
fix1 {A , rᴬ} (f , ☐) = fixf , λ n → ∘-idᶜ ∙ fix☐ n
module Fix1 where
open Later A rᴬ
fixf : (n : ℕ) → 𝟙ᶜ →ᶜ A n
fixf 0 = f 0
fixf (S n) = f (S n) ∘ᶜ fixf n
fix☐ : (n : ℕ) → fixf n ≡ rᴬ n ∘ᶜ fixf (1 + n)
fix☐ 0 = ! ∘-!ᶜ ∙ with-∘-assocᶜ (☐ 0)
fix☐ (S n) = ap-∘ᶜ idp (fix☐ n) ∙ with-∘-assocᶜ (☐ (S n))
module WithProducts
(_×ᶜ_ : Objᶜ → Objᶜ → Objᶜ)
-- projections
(fstᶜ : ∀ {A B} → (A ×ᶜ B) →ᶜ A)
(sndᶜ : ∀ {A B} → (A ×ᶜ B) →ᶜ B)
-- injection (pair creation)
(<_,_>ᶜ : ∀ {A B C} → A →ᶜ B → A →ᶜ C → A →ᶜ (B ×ᶜ C))
-- computation rules
(fst-<,> : ∀ {A B C} {f : A →ᶜ B} {g : A →ᶜ C}
→ fstᶜ ∘ᶜ < f , g >ᶜ ≡ f)
(snd-<,> : ∀ {A B C} {f : A →ᶜ B} {g : A →ᶜ C}
→ sndᶜ ∘ᶜ < f , g >ᶜ ≡ g)
-- universal property
(<,>-uniq! : ∀ {A B X : Objᶜ} {f : X →ᶜ (A ×ᶜ B)}
→ < fstᶜ ∘ᶜ f , sndᶜ ∘ᶜ f >ᶜ ≡ f)
where
firstᶜ : ∀ {A B C} → A →ᶜ B → (A ×ᶜ C) →ᶜ (B ×ᶜ C)
firstᶜ f = < f ∘ᶜ fstᶜ , sndᶜ >ᶜ
secondᶜ : ∀ {A B C} → B →ᶜ C → (A ×ᶜ B) →ᶜ (A ×ᶜ C)
secondᶜ f = < fstᶜ , f ∘ᶜ sndᶜ >ᶜ
<_×_>ᶜ : ∀ {A B C D} (f : A →ᶜ C) (g : B →ᶜ D) → (A ×ᶜ B) →ᶜ (C ×ᶜ D)
< f × g >ᶜ = < f ∘ᶜ fstᶜ , g ∘ᶜ sndᶜ >ᶜ
module _ {A B C} {f f' : A →ᶜ B} {g g' : A →ᶜ C} where
≡<_,_> : f ≡ f' → g ≡ g' → < f , g >ᶜ ≡ < f' , g' >ᶜ
≡< p , q > = ap (λ f → < f , g >ᶜ) p ∙ ap (λ g → < f' , g >ᶜ) q
module _ {A B C X} {f₀ : A →ᶜ B} {f₁ : A →ᶜ C} {g : X →ᶜ A} where
<,>-∘ : < f₀ , f₁ >ᶜ ∘ᶜ g ≡ < f₀ ∘ᶜ g , f₁ ∘ᶜ g >ᶜ
<,>-∘ = ! <,>-uniq! ∙ ≡< ! ∘-assocᶜ ∙ ap-∘ᶜ fst-<,> idp
, ! ∘-assocᶜ ∙ ap-∘ᶜ snd-<,> idp >
module _ {A B} where
-- η-rule
<fst,snd> : < fstᶜ , sndᶜ >ᶜ ≡ idᶜ {A ×ᶜ B}
<fst,snd> = ≡< ! ∘-idᶜ , ! ∘-idᶜ > ∙ <,>-uniq!
<fst,id∘snd> : < fstᶜ , idᶜ ∘ᶜ sndᶜ >ᶜ ≡ idᶜ {A ×ᶜ B}
<fst,id∘snd> = ≡< idp , id-∘ᶜ > ∙ <fst,snd>
_×ᶜ°_ : (A B : ℕ → Objᶜ) → ℕ → Objᶜ
(A ×ᶜ° B) n = A n ×ᶜ B n
_×ʳ_ : {A B : ℕ → Objᶜ} → Rmap A → Rmap B → Rmap (A ×ᶜ° B)
(rᴬ ×ʳ rᴮ) n = < rᴬ n × rᴮ n >ᶜ
_×ᵖ_ : Objᵖ → Objᵖ → Objᵖ
(A , rᴬ) ×ᵖ (B , rᴮ) = (A ×ᶜ° B) , (rᴬ ×ʳ rᴮ)
fstᵖ : ∀ {A B} → (A ×ᵖ B) →ᵖ A
fstᵖ = (λ _ → fstᶜ) , (λ _ → fst-<,>)
sndᵖ : ∀ {A B} → (A ×ᵖ B) →ᵖ B
sndᵖ = (λ _ → sndᶜ) , (λ _ → snd-<,>)
<_,_>ᵖ : ∀ {A B C} → A →ᵖ B → A →ᵖ C → A →ᵖ (B ×ᵖ C)
<_,_>ᵖ {A , rᴬ} {B , rᴮ} {C , rᶜ} (f , f☐) (g , g☐) =
(λ n → < f n , g n >ᶜ) ,
(λ n → <,>-∘
∙ ≡< f☐ n ∙ ap-∘ᶜ idp (! fst-<,>) ∙ ! ∘-assocᶜ
, g☐ n ∙ ap-∘ᶜ idp (! snd-<,>) ∙ ! ∘-assocᶜ >
∙ ! <,>-∘)
firstᵖ : ∀ {A B C} → A →ᵖ B → (A ×ᵖ C) →ᵖ (B ×ᵖ C)
firstᵖ f = < f ∘ᵖ fstᵖ , sndᵖ >ᵖ
▸-× : {A B : Objᵖ} → ▸(A ×ᵖ B) →ᵖ (▸ A ×ᵖ ▸ B)
▸-× {A , rᴬ} {B , rᴮ} = ▸f , ▸☐
module LaterProduct where
open Later A rᴬ
open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)
open Later (A ×ᶜ° B) (rᴬ ×ʳ rᴮ) renaming (▸A to ▸AB; ▸rᴬ to ▸rᴬᴮ)
▸f : ▸AB →ᶜ° (▸A ×ᶜ° ▸B)
▸f 0 = < !ᶜ , !ᶜ >ᶜ
▸f (S n) = idᶜ
▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬᴮ n ≡ (▸rᴬ ×ʳ ▸rᴮ) n ∘ᶜ ▸f (1 + n)
▸☐ 0 = <,>-∘ ∙ ≡< !-irrᶜ , !-irrᶜ > ∙ ! ∘-idᶜ
▸☐ (S n) = id-∘ᶜ ∙ ! ∘-idᶜ
_^_ : Objᶜ → ℕ → Objᶜ
A ^ 0 = 𝟙ᶜ
A ^(S n) = A ×ᶜ (A ^ n)
fix : {A B : Objᵖ} (f : (B ×ᵖ ▸ A) →ᵖ A) → B →ᵖ A
fix {A , rᴬ} {B , rᴮ} (f , ☐) = fixf , fix☐
module Fix where
open Later A rᴬ
open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)
fixf : (n : ℕ) → B n →ᶜ A n
fixf 0 = f 0 ∘ᶜ < idᶜ , !ᶜ >ᶜ
fixf (S n) = f (S n) ∘ᶜ < idᶜ , fixf n ∘ᶜ rᴮ n >ᶜ
fix☐ : (n : ℕ) → fixf n ∘ᶜ rᴮ n ≡ rᴬ n ∘ᶜ fixf (1 + n)
fix☐ 0 = ∘-assocᶜ ∙ ap-∘ᶜ idp (<,>-∘ ∙ ≡< id-∘ᶜ ∙ ! (∘-idᶜ' fst-<,>) ∙ ! ∘-assocᶜ , !-irrᶜ > ∙ ! <,>-∘) ∙ with-∘-assocᶜ (☐ 0)
fix☐ (S n) = ∘-assocᶜ ∙ ap-∘ᶜ idp (<,>-∘ ∙ ≡< id-∘ᶜ ∙ ! (∘-idᶜ' fst-<,>) ∙ ! ∘-assocᶜ , h > ∙ ! <,>-∘) ∙ with-∘-assocᶜ (☐ (S n))
where h = ap-∘ᶜ (fix☐ n) idp ∙ with-!∘-assocᶜ (! snd-<,>)
module _ {A} where
initᶜ : ∀ n → (A ^(1 + n)) →ᶜ (A ^ n)
initᶜ 0 = !ᶜ
initᶜ (S n) = secondᶜ (initᶜ n)
module Str1
(A : Objᶜ)
where
Aᵖ = [ A ]ᵖ
Str : ℕ → Objᶜ
Str n = A ^(1 + n)
rStr : (n : ℕ) → Str (1 + n) →ᶜ Str n
rStr = λ n → initᶜ (1 + n)
Strᵖ : Objᵖ
Strᵖ = Str , rStr
open Later Str (snd Strᵖ) renaming (▸A to ▸Str; ▸rᴬ to ▸rStr)
roll : (n : ℕ) → (A ^ n) →ᶜ ▸Str n
roll 0 = !ᶜ -- or idᶜ {𝟙ᶜ}
roll (S n) = idᶜ
unroll : (n : ℕ) → ▸Str n →ᶜ (A ^ n)
unroll 0 = !ᶜ -- or idᶜ {𝟙ᶜ}
unroll (S n) = idᶜ
hdᵖ : Strᵖ →ᵖ Aᵖ
hdᵖ = (λ _ → fstᶜ) , (λ n → fst-<,> ∙ ! id-∘ᶜ)
tlᵖ : Strᵖ →ᵖ ▸ Strᵖ
tlᵖ = f , ☐
where
f : (n : ℕ) → Str n →ᶜ ▸Str n
f n = roll n ∘ᶜ sndᶜ
☐ : (n : ℕ) → f n ∘ᶜ rStr n ≡ ▸rStr n ∘ᶜ f (1 + n)
☐ 0 = !-irrᶜ
☐ (S n) = ∘-assocᶜ ∙ id-∘ᶜ ∙ snd-<,> ∙ ap-∘ᶜ idp (! id-∘ᶜ)
∷ᵖ : (Aᵖ ×ᵖ ▸ Strᵖ) →ᵖ Strᵖ
∷ᵖ = f , ☐
where
f : (n : ℕ) → (A ×ᶜ ▸Str n) →ᶜ Str n
f n = secondᶜ (unroll n)
☐ : (n : ℕ) → f n ∘ᶜ snd (Aᵖ ×ᵖ ▸ Strᵖ) n ≡ rStr n ∘ᶜ f (1 + n)
☐ 0 = <,>-∘ ∙ ≡< fst-<,> ∙ id-∘ᶜ , !-irrᶜ > ∙ !(∘-idᶜ' <fst,id∘snd>)
☐ (S n) = id-∘ᶜ' <fst,id∘snd> ∙ ≡< id-∘ᶜ , idp > ∙ !(∘-idᶜ' <fst,id∘snd>)
repeatᵖ : (𝟙ᵖ →ᵖ Aᵖ) → 𝟙ᵖ →ᵖ Strᵖ
repeatᵖ f = fix1 it
where it : ▸ Strᵖ →ᵖ Strᵖ
it = ∷ᵖ ∘ᵖ < f ∘ᵖ !ᵖ , idᵖ >ᵖ
{-
iterate f x = x ∷ iterate f (f x)
or
iterate f = (∷) id (iterate f ∘ f)
-}
{-
iterateᵖ : (Aᵖ →ᵖ Aᵖ) → Aᵖ →ᵖ Strᵖ
iterateᵖ f = fix it -- sndᵖ ∘ᵖ fix it ∘ᵖ !ᵖ
where
it : Aᵖ ×ᵖ ▸ Strᵖ →ᵖ Strᵖ
it = < fstᵖ , ∷ᵖ >ᵖ ∘ᵖ firstᵖ (f ∘ᵖ {!!}) ∘ᵖ ▸-×
-}
{-
mapᵖ : ([ A ]ᵖ →ᵖ [ A ]ᵖ) → Strᵖ →ᵖ Strᵖ
mapᵖ f = {!fix!}
-}
Objᶜ↑ : ℕ → Endo (ℕ → Objᶜ)
Objᶜ↑ k A n = A (n + k)
↑ᶜ° : ∀ k {A B} → A →ᶜ° B → Objᶜ↑ k A →ᶜ° Objᶜ↑ k B
↑ᶜ° k f n = f (n + k)
↑r : ∀ k {A} → Rmap A → Rmap (Objᶜ↑ k A)
↑r k rᴬ n = rᴬ (n + k)
Objᵖ↑ : ℕ → Endo Objᵖ
Objᵖ↑ k (A , rᴬ) = Objᶜ↑ k A , ↑r k rᴬ
r* : {A : ℕ → Objᶜ}
(rᴬ : Rmap A)
(n : ℕ) → A (1 + n) →ᶜ A 0
r* rᴬ 0 = rᴬ 0
r* rᴬ (S n) = r* rᴬ n ∘ᶜ rᴬ (S n)
module _
{A B : ℕ → Objᶜ}
{rᴬ : (n : ℕ) → A (1 + n) →ᶜ A n}
{rᴮ : (n : ℕ) → B (1 + n) →ᶜ B n}
(f : (n : ℕ) → A n →ᶜ B n)
(☐f : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n))
where
☐* : (n : ℕ) → f 0 ∘ᶜ r* rᴬ n ≡ r* rᴮ n ∘ᶜ f (1 + n)
☐* 0 = ☐f 0
☐* (S n) = ! ∘-assocᶜ
∙ ap-∘ᶜ (☐* n) idp
∙ ∘-assocᶜ
∙ ap-∘ᶜ idp (☐f (S n))
∙ ! ∘-assocᶜ
module _
{A B : ℕ → Objᶜ}
{rᴬ : (n : ℕ) → A (1 + n) →ᶜ A n}
{rᴮ : (n : ℕ) → B (1 + n) →ᶜ B n}
(f : (n : ℕ) → A n →ᶜ B n)
(☐f : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n))
(k : ℕ)
where
--☐*' : (n : ℕ) → f k ∘ᶜ r* (↑r k rᴬ) n ≡ r* (↑r k rᴮ) n ∘ᶜ f ((1 + n) + k)
--☐*' n = ☐* (↑ᶜ° k f) {!!} n
module WithMore -- TODO upto topos
-- Initial object
(𝟘ᶜ : Objᶜ)
(¡ᶜ : {A : Objᶜ} → 𝟘ᶜ →ᶜ A)
(¡-uniqᶜ : {A : Objᶜ} {f : 𝟘ᶜ →ᶜ A} → ¡ᶜ ≡ f)
-- Coproducts
(_+ᶜ_ : Objᶜ → Objᶜ → Objᶜ)
-- injections
(inlᶜ : ∀ {A B} → A →ᶜ (A +ᶜ B))
(inrᶜ : ∀ {A B} → B →ᶜ (A +ᶜ B))
-- projection (coproduct elimination)
([_,_]ᶜ : ∀ {A B C} → B →ᶜ A → C →ᶜ A → (B +ᶜ C) →ᶜ A)
-- computation rules
([,]-inl : ∀ {A B C} {f : B →ᶜ A} {g : C →ᶜ A}
→ [ f , g ]ᶜ ∘ᶜ inlᶜ ≡ f)
([,]-inr : ∀ {A B C} {f : B →ᶜ A} {g : C →ᶜ A}
→ [ f , g ]ᶜ ∘ᶜ inrᶜ ≡ g)
-- universal property
([,]-uniq! : ∀ {A B X : Objᶜ} {f : (A +ᶜ B) →ᶜ X}
→ [ f ∘ᶜ inlᶜ , f ∘ᶜ inrᶜ ]ᶜ ≡ f)
where
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.3440874462,
"avg_line_length": 29.3106796117,
"ext": "agda",
"hexsha": "f032f20f76590b23868086b91291c0bb9de216b4",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-11-16T16:21:54.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-08-19T12:37:53.000Z",
"max_forks_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "np/guarded-recursion",
"max_forks_repo_path": "guarded-recursion/model.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"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": "np/guarded-recursion",
"max_issues_repo_path": "guarded-recursion/model.agda",
"max_line_length": 139,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "np/guarded-recursion",
"max_stars_repo_path": "guarded-recursion/model.agda",
"max_stars_repo_stars_event_max_datetime": "2016-12-06T23:04:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-06T23:04:56.000Z",
"num_tokens": 9497,
"size": 15095
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.