Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --cubical #-}
module Cubical.Experiments.Brunerie where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Data.Bool
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.HITs.S1
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open import Cubical.HITs.Join
open import Cubical.HITs.Hopf
open import Cubical.HITs.SetTruncation
open import Cubical.HITs.GroupoidTruncation
open import Cubical.HITs.2GroupoidTruncation
-- This code is adapted from examples/brunerie3.ctt on the pi4s3_nobug branch of cubicaltt
ptType : Type₁
ptType = Σ[ A ∈ Type₀ ] A
pt : ∀ (A : ptType) → A .fst
pt A = A .snd
ptBool ptS¹ ptS² ptS³ : ptType
ptBool = (Bool , true)
ptS¹ = (S¹ , base)
ptS² = (S² , base)
ptS³ = (S³ , base)
pt∥_∥₁ pt∥_∥₂ : ptType → ptType
pt∥ A , a ∥₁ = ∥ A ∥₁ , ∣ a ∣₁
pt∥ A , a ∥₂ = ∥ A ∥₂ , ∣ a ∣₂
ptjoin : ptType → Type₀ → ptType
ptjoin (A , a) B = join A B , inl a
Ω Ω² Ω³ : ptType → ptType
Ω (A , a) = (Path A a a) , refl
Ω² A = Ω (Ω A)
Ω³ A = Ω (Ω² A)
mapΩrefl : {A : ptType} {B : Type₀} (f : A .fst → B) → Ω A .fst → Ω (B , f (pt A)) .fst
mapΩrefl f p i = f (p i)
mapΩ²refl : {A : ptType} {B : Type₀} (f : A .fst → B) → Ω² A .fst → Ω² (B , f (pt A)) .fst
mapΩ²refl f p i j = f (p i j)
mapΩ³refl : {A : ptType} {B : Type₀} (f : A .fst → B) → Ω³ A .fst → Ω³ (B , f (pt A)) .fst
mapΩ³refl f p i j k = f (p i j k)
PROP SET GROUPOID TWOGROUPOID : ∀ ℓ → Type (ℓ-suc ℓ)
PROP ℓ = Σ (Type ℓ) isProp
SET ℓ = Σ (Type ℓ) isSet
GROUPOID ℓ = Σ (Type ℓ) isGroupoid
TWOGROUPOID ℓ = Σ (Type ℓ) is2Groupoid
meridS² : S¹ → Path S² base base
meridS² base _ = base
meridS² (loop i) j = surf i j
alpha : join S¹ S¹ → S²
alpha (inl x) = base
alpha (inr y) = base
alpha (push x y i) = (meridS² y ∙ meridS² x) i
connectionBoth : {A : Type₀} {a : A} (p : Path A a a) → PathP (λ i → Path A (p i) (p i)) p p
connectionBoth {a = a} p i j =
hcomp
(λ k → λ
{ (i = i0) → p (j ∨ ~ k)
; (i = i1) → p (j ∧ k)
; (j = i0) → p (i ∨ ~ k)
; (j = i1) → p (i ∧ k)
})
a
data PostTotalHopf : Type₀ where
base : S¹ → PostTotalHopf
loop : (x : S¹) → PathP (λ i → Path PostTotalHopf (base x) (base (rotLoop x (~ i)))) refl refl
tee12 : (x : S²) → HopfS² x → PostTotalHopf
tee12 base y = base y
tee12 (surf i j) y =
hcomp
(λ k → λ
{ (i = i0) → base y
; (i = i1) → base y
; (j = i0) → base y
; (j = i1) → base (rotLoopInv y (~ i) k)
})
(loop (unglue (i ∨ ~ i ∨ j ∨ ~ j) y) i j)
tee34 : PostTotalHopf → join S¹ S¹
tee34 (base x) = inl x
tee34 (loop x i j) =
hcomp
(λ k → λ
{ (i = i0) → push x x (j ∧ ~ k)
; (i = i1) → push x x (j ∧ ~ k)
; (j = i0) → inl x
; (j = i1) → push (rotLoop x (~ i)) x (~ k)
})
(push x x j)
tee : (x : S²) → HopfS² x → join S¹ S¹
tee x y = tee34 (tee12 x y)
fibΩ : {B : ptType} (P : B .fst → Type₀) → P (pt B) → Ω B .fst → Type₀
fibΩ P f p = PathP (λ i → P (p i)) f f
fibΩ² : {B : ptType} (P : B .fst → Type₀) → P (pt B) → Ω² B .fst → Type₀
fibΩ² P f = fibΩ (fibΩ P f) refl
fibΩ³ : {B : ptType} (P : B .fst → Type₀) → P (pt B) → Ω³ B .fst → Type₀
fibΩ³ P f = fibΩ² (fibΩ P f) refl
Ω³Hopf : Ω³ ptS² .fst → Type₀
Ω³Hopf = fibΩ³ HopfS² base
fibContrΩ³Hopf : ∀ p → Ω³Hopf p
fibContrΩ³Hopf p i j k =
hcomp
(λ m → λ
{ (i = i0) → base
; (i = i1) → base
; (j = i0) → base
; (j = i1) → base
; (k = i0) → base
; (k = i1) →
isSetΩS¹ refl refl
(λ i j → transp (λ n → HopfS² (p i j n)) (i ∨ ~ i ∨ j ∨ ~ j) base)
(λ _ _ → base)
m i j
})
(transp (λ n → HopfS² (p i j (k ∧ n))) (i ∨ ~ i ∨ j ∨ ~ j ∨ ~ k) base)
h : Ω³ ptS² .fst → Ω³ (ptjoin ptS¹ S¹) .fst
h p i j k = tee (p i j k) (fibContrΩ³Hopf p i j k)
multTwoAux : (x : S²) → Path (Path ∥ S² ∥₂ ∣ x ∣₂ ∣ x ∣₂) refl refl
multTwoAux base i j = ∣ surf i j ∣₂
multTwoAux (surf k l) i j =
hcomp
(λ m → λ
{ (i = i0) → ∣ surf k l ∣₂
; (i = i1) → ∣ surf k l ∣₂
; (j = i0) → ∣ surf k l ∣₂
; (j = i1) → ∣ surf k l ∣₂
; (k = i0) → ∣ surf i j ∣₂
; (k = i1) → ∣ surf i j ∣₂
; (l = i0) → ∣ surf i j ∣₂
; (l = i1) → squash₂ _ _ _ _ _ _ (λ k i j → step₁ k i j) refl m k i j
})
(step₁ k i j)
where
step₁ : I → I → I → ∥ S² ∥₂
step₁ k i j =
hcomp {A = ∥ S² ∥₂}
(λ m → λ
{ (i = i0) → ∣ surf k (l ∧ m) ∣₂
; (i = i1) → ∣ surf k (l ∧ m) ∣₂
; (j = i0) → ∣ surf k (l ∧ m) ∣₂
; (j = i1) → ∣ surf k (l ∧ m) ∣₂
; (k = i0) → ∣ surf i j ∣₂
; (k = i1) → ∣ surf i j ∣₂
; (l = i0) → ∣ surf i j ∣₂
})
∣ surf i j ∣₂
multTwoTildeAux : (t : ∥ S² ∥₂) → Path (Path ∥ S² ∥₂ t t) refl refl
multTwoTildeAux ∣ x ∣₂ = multTwoAux x
multTwoTildeAux (squash₂ _ _ _ _ _ _ t u k l m n) i j =
squash₂ _ _ _ _ _ _
(λ k l m → multTwoTildeAux (t k l m) i j)
(λ k l m → multTwoTildeAux (u k l m) i j)
k l m n
multTwoEquivAux : Path (Path (∥ S² ∥₂ ≃ ∥ S² ∥₂) (idEquiv _) (idEquiv _)) refl refl
multTwoEquivAux i j =
( f i j
, hcomp
(λ l → λ
{ (i = i0) → isPropIsEquiv _ (idIsEquiv _) (idIsEquiv _) l
; (i = i1) → isPropIsEquiv _ (idIsEquiv _) (idIsEquiv _) l
; (j = i0) → isPropIsEquiv _ (idIsEquiv _) (idIsEquiv _) l
; (j = i1) →
isPropIsEquiv _
(transp (λ k → isEquiv (f i k)) (i ∨ ~ i) (idIsEquiv _))
(idIsEquiv _)
l
})
(transp (λ k → isEquiv (f i (j ∧ k))) (i ∨ ~ i ∨ ~ j) (idIsEquiv _))
)
where
f : I → I → ∥ S² ∥₂ → ∥ S² ∥₂
f i j t = multTwoTildeAux t i j
tHopf³ : S³ → Type₀
tHopf³ base = ∥ S² ∥₂
tHopf³ (surf i j k) =
Glue ∥ S² ∥₂
(λ { (i = i0) → (∥ S² ∥₂ , idEquiv _)
; (i = i1) → (∥ S² ∥₂ , idEquiv _)
; (j = i0) → (∥ S² ∥₂ , idEquiv _)
; (j = i1) → (∥ S² ∥₂ , idEquiv _)
; (k = i0) → (∥ S² ∥₂ , multTwoEquivAux i j)
; (k = i1) → (∥ S² ∥₂ , idEquiv _)
})
π₃S³ : Ω³ ptS³ .fst → Ω² pt∥ ptS² ∥₂ .fst
π₃S³ p i j = transp (λ k → tHopf³ (p j k i)) i0 ∣ base ∣₂
postulate
is2GroupoidGROUPOID : ∀ {ℓ} → is2Groupoid (GROUPOID ℓ)
isGroupoidSET : ∀ {ℓ} → isGroupoid (SET ℓ)
codeS² : S² → GROUPOID _
codeS² s = ∥ HopfS² s ∥₁ , squash₁
codeTruncS² : ∥ S² ∥₂ → GROUPOID _
codeTruncS² = rec2GroupoidTrunc is2GroupoidGROUPOID codeS²
encodeTruncS² : Ω pt∥ ptS² ∥₂ .fst → ∥ S¹ ∥₁
encodeTruncS² p = transp (λ i → codeTruncS² (p i) .fst) i0 ∣ base ∣₁
codeS¹ : S¹ → SET _
codeS¹ s = ∥ helix s ∥₀ , squash₀
codeTruncS¹ : ∥ S¹ ∥₁ → SET _
codeTruncS¹ = recGroupoidTrunc isGroupoidSET codeS¹
encodeTruncS¹ : Ω pt∥ ptS¹ ∥₁ .fst → ∥ Int ∥₀
encodeTruncS¹ p = transp (λ i → codeTruncS¹ (p i) .fst) i0 ∣ pos zero ∣₀
-- THE BIG GAME
f3 : Ω³ ptS³ .fst → Ω³ (ptjoin ptS¹ S¹) .fst
f3 = mapΩ³refl S³→joinS¹S¹
f4 : Ω³ (ptjoin ptS¹ S¹) .fst → Ω³ ptS² .fst
f4 = mapΩ³refl alpha
f5 : Ω³ ptS² .fst → Ω³ (ptjoin ptS¹ S¹) .fst
f5 = h
f6 : Ω³ (ptjoin ptS¹ S¹) .fst → Ω³ ptS³ .fst
f6 = mapΩ³refl joinS¹S¹→S³
f7 : Ω³ ptS³ .fst → Ω² pt∥ ptS² ∥₂ .fst
f7 = π₃S³
g8 : Ω² pt∥ ptS² ∥₂ .fst → Ω pt∥ ptS¹ ∥₁ .fst
g8 = mapΩrefl encodeTruncS²
g9 : Ω pt∥ ptS¹ ∥₁ .fst → ∥ Int ∥₀
g9 = encodeTruncS¹
g10 : ∥ Int ∥₀ → Int
g10 = elimSetTrunc (λ _ → isSetInt) (idfun Int)
-- don't run me
brunerie : Int
brunerie = g10 (g9 (g8 (f7 (f6 (f5 (f4 (f3 (λ i j k → surf i j k))))))))
-- simpler tests
test63 : ℕ → Int
test63 n = g10 (g9 (g8 (f7 (63n n))))
where
63n : ℕ → Ω³ ptS³ .fst
63n zero i j k = surf i j k
63n (suc n) = f6 (f3 (63n n))
foo : Ω³ ptS² .fst
foo i j k =
hcomp
(λ l → λ
{ (i = i0) → surf l l
; (i = i1) → surf l l
; (j = i0) → surf l l
; (j = i1) → surf l l
; (k = i0) → surf l l
; (k = i1) → surf l l
})
base
sorghum : Ω³ ptS² .fst
sorghum i j k =
hcomp
(λ l → λ
{ (i = i0) → surf j l
; (i = i1) → surf k (~ l)
; (j = i0) → surf k (i ∧ ~ l)
; (j = i1) → surf k (i ∧ ~ l)
; (k = i0) → surf j (i ∨ l)
; (k = i1) → surf j (i ∨ l)
})
(hcomp
(λ l → λ
{ (i = i0) → base
; (i = i1) → surf j l
; (j = i0) → surf k i
; (j = i1) → surf k i
; (k = i0) → surf j (i ∧ l)
; (k = i1) → surf j (i ∧ l)
})
(surf k i))
goo : Ω³ ptS² .fst → Int
goo x = g10 (g9 (g8 (f7 (f6 (f5 x)))))
| {
"alphanum_fraction": 0.5161366872,
"avg_line_length": 26.5031446541,
"ext": "agda",
"hexsha": "cf6ecd02982b540fe46f52fbac0763fa8c4248dc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cj-xu/cubical",
"max_forks_repo_path": "Cubical/Experiments/Brunerie.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cj-xu/cubical",
"max_issues_repo_path": "Cubical/Experiments/Brunerie.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cj-xu/cubical",
"max_stars_repo_path": "Cubical/Experiments/Brunerie.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4037,
"size": 8428
} |
{-# OPTIONS --cubical-compatible #-}
postulate
A : Set
B : A → Set
T = (@0 x : A) → B x
| {
"alphanum_fraction": 0.5161290323,
"avg_line_length": 13.2857142857,
"ext": "agda",
"hexsha": "1b2f42291f295f715615122d9b6c334a62f58840",
"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/Issue4784a.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/Issue4784a.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/Issue4784a.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 35,
"size": 93
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The basic code for equational reasoning with a partial relation
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Reasoning.Base.Partial
{a ℓ} {A : Set a} (_∼_ : Rel A ℓ) (trans : Transitive _∼_)
where
open import Level using (_⊔_)
open import Relation.Binary.PropositionalEquality.Core as P
using (_≡_)
infix 4 _IsRelatedTo_
infix 3 _∎⟨_⟩
infixr 2 step-∼ step-≡ step-≡˘
infixr 2 _≡⟨⟩_
infix 1 begin_
------------------------------------------------------------------------
-- Definition of "related to"
-- This seemingly unnecessary type is used to make it possible to
-- infer arguments even if the underlying equality evaluates.
data _IsRelatedTo_ (x y : A) : Set ℓ where
relTo : (x∼y : x ∼ y) → x IsRelatedTo y
------------------------------------------------------------------------
-- Reasoning combinators
-- Note that the arguments to the `step`s are not provided in their
-- "natural" order and syntax declarations are later used to re-order
-- them. This is because the `step` ordering allows the type-checker to
-- better infer the middle argument `y` from the `_IsRelatedTo_`
-- argument (see issue 622).
--
-- This has two practical benefits. First it speeds up type-checking by
-- approximately a factor of 5. Secondly it allows the combinators to be
-- used with macros that use reflection, e.g. `Tactic.RingSolver`, where
-- they need to be able to extract `y` using reflection.
-- Beginning of a proof
begin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y
begin relTo x∼y = x∼y
-- Standard step with the relation
step-∼ : ∀ x {y z} → y IsRelatedTo z → x ∼ y → x IsRelatedTo z
step-∼ _ (relTo y∼z) x∼y = relTo (trans x∼y y∼z)
-- Step with a non-trivial propositional equality
step-≡ : ∀ x {y z} → y IsRelatedTo z → x ≡ y → x IsRelatedTo z
step-≡ _ x∼z P.refl = x∼z
-- Step with a flipped non-trivial propositional equality
step-≡˘ : ∀ x {y z} → y IsRelatedTo z → y ≡ x → x IsRelatedTo z
step-≡˘ _ x∼z P.refl = x∼z
-- Step with a trivial propositional equality
_≡⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y
_ ≡⟨⟩ x∼y = x∼y
-- Termination step
_∎⟨_⟩ : ∀ x → x ∼ x → x IsRelatedTo x
_ ∎⟨ x∼x ⟩ = relTo x∼x
-- Syntax declarations
syntax step-∼ x y∼z x∼y = x ∼⟨ x∼y ⟩ y∼z
syntax step-≡ x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
syntax step-≡˘ x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z
| {
"alphanum_fraction": 0.593092497,
"avg_line_length": 30.3493975904,
"ext": "agda",
"hexsha": "43ca14ec597e30df0002bb96e55a214a4600ce3f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Base/Partial.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": 824,
"size": 2519
} |
{-# OPTIONS --universe-polymorphism #-}
open import Data.Bool using ( Bool ; true ; false ; _∧_ )
open import Data.Empty using ()
open import Data.List using ( List ; [] ; _∷_ ; _++_ ; map )
open import Data.List.Any using ( here ; there )
open import Data.List.Membership.Propositional using ()
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Data.Product using ( ∃ ; ∄ ; _×_ ; _,_ )
open import Data.Unit using ()
open import Level using ( zero )
open import Relation.Binary using ()
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )
open import Relation.Nullary using ( Dec ; yes ; no )
open import Relation.Unary using ( _∈_ ; _⊆_ )
module Web.Semantic.Util where
infixr 9 _∘_
id : ∀ {X : Set} → X → X
id x = x
_∘_ : ∀ {X Y Z : Set} → (Y → Z) → (X → Y) → (X → Z)
(f ∘ g) = λ x → f (g x)
Setoid : Set₁
Setoid = Relation.Binary.Setoid zero zero
Subset : Set → Set₁
Subset X = X → Set
⁅_⁆ : ∀ {X} → X → Subset X
⁅ x ⁆ y = x ≡ y
⊆-refl : ∀ {X} (P : Subset X) → (P ⊆ P)
⊆-refl P x∈P = x∈P
_⁻¹ : ∀ {X Y : Set} → Subset (X × Y) → Subset (Y × X)
(R ⁻¹) (y , x) = R (x , y)
-- Some proofs are classical, and depend on excluded middle.
ExclMiddle : Set₁
ExclMiddle = ∀ (X : Set) → Dec X
ExclMiddle₁ : Set₂
ExclMiddle₁ = ∀ (X : Set₁) → Dec X
smaller-excl-middle : ExclMiddle₁ → ExclMiddle
smaller-excl-middle excl-middle₁ X = X? where
data Large : Set₁ where
large : X → Large
X? : Dec X
X? with excl-middle₁ Large
X? | yes (large x) = yes x
X? | no ¬x = no (λ x → ¬x (large x))
-- Some nameclashes between the standard library and semantic web terminology:
-- ⊤ and ⊥ are used for concepts, and T is used to range over T-Boxes.
open Data.Bool public using () renaming ( T to □ )
open Data.Empty public using () renaming ( ⊥ to False ; ⊥-elim to elim )
open Data.Unit public using ( tt ) renaming ( ⊤ to True )
□-proj₁ : ∀ {b c} → □(b ∧ c) → □ b
□-proj₁ {true} □c = tt
□-proj₁ {false} ()
□-proj₂ : ∀ {b c} → □(b ∧ c) → □ c
□-proj₂ {true} □c = □c
□-proj₂ {false} ()
-- Convert back and forth from Dec and Bool.
is : ∀ {ℓ} {X : Set ℓ} → Dec X → Bool
is (yes _) = true
is (no _) = false
is✓ : ∀ {ℓ} {X : Set ℓ} {x : Dec X} → □(is x) → X
is✓ {ℓ} {X} {yes x} _ = x
is✓ {ℓ} {X} {no _} ()
is! : ∀ {ℓ} {X : Set ℓ} {x : Dec X} → X → □(is x)
is! {ℓ} {X} {yes _} x = tt
is! {ℓ} {X} {no ¬x} x = ¬x x
-- Finite sets are ones backed by a list
open Data.List.Membership.Propositional public using () renaming ( _∈_ to _∈ˡ_ )
Finite : Set → Set
Finite X = ∃ λ xs → ∀ (x : X) → (x ∈ˡ xs)
False∈Fin : False ∈ Finite
False∈Fin = ([] , λ ())
⊎-resp-Fin : ∀ {X Y} → (X ∈ Finite) → (Y ∈ Finite) → ((X ⊎ Y) ∈ Finite)
⊎-resp-Fin {X} {Y} (xs , ∀x∙x∈xs) (ys , ∀y∙y∈ys) =
((map inj₁ xs ++ map inj₂ ys) , lemma) where
lemma₁ : ∀ {x : X} {xs : List X} →
(x ∈ˡ xs) → (inj₁ x ∈ˡ (map inj₁ xs ++ map inj₂ ys))
lemma₁ (here refl) = here refl
lemma₁ (there x∈xs) = there (lemma₁ x∈xs)
lemma₂ : ∀ (xs : List X) {y : Y} {ys : List Y} →
(y ∈ˡ ys) → (inj₂ y ∈ˡ (map inj₁ xs ++ map inj₂ ys))
lemma₂ [] (here refl) = here refl
lemma₂ [] (there y∈ys) = there (lemma₂ [] y∈ys)
lemma₂ (x ∷ xs) y∈ys = there (lemma₂ xs y∈ys)
lemma : ∀ x → (x ∈ˡ (map inj₁ xs ++ map inj₂ ys))
lemma (inj₁ x) = lemma₁ (∀x∙x∈xs x)
lemma (inj₂ y) = lemma₂ xs (∀y∙y∈ys y)
-- symmetric monoidal structure of sum
_⟨⊎⟩_ : ∀ {W X Y Z : Set} → (W → X) → (Y → Z) → (W ⊎ Y) → (X ⊎ Z)
_⟨⊎⟩_ f g (inj₁ x) = inj₁ (f x)
_⟨⊎⟩_ f g (inj₂ y) = inj₂ (g y)
_≡⊎≡_ : ∀ {X Y Z : Set} {f g : (X ⊎ Y) → Z} →
(∀ x → (f (inj₁ x) ≡ g (inj₁ x))) → (∀ x → (f (inj₂ x) ≡ g (inj₂ x))) →
∀ x → (f x ≡ g x)
(f₁≡g₁ ≡⊎≡ f₂≡g₂) (inj₁ x) = f₁≡g₁ x
(f₁≡g₁ ≡⊎≡ f₂≡g₂) (inj₂ y) = f₂≡g₂ y
⊎-swap : ∀ {X Y : Set} → (X ⊎ Y) → (Y ⊎ X)
⊎-swap (inj₁ x) = inj₂ x
⊎-swap (inj₂ y) = inj₁ y
⊎-assoc : ∀ {X Y Z : Set} → ((X ⊎ Y) ⊎ Z) → (X ⊎ (Y ⊎ Z))
⊎-assoc (inj₁ (inj₁ x)) = inj₁ x
⊎-assoc (inj₁ (inj₂ y)) = inj₂ (inj₁ y)
⊎-assoc (inj₂ z) = inj₂ (inj₂ z)
⊎-assoc⁻¹ : ∀ {X Y Z : Set} → (X ⊎ (Y ⊎ Z)) → ((X ⊎ Y) ⊎ Z)
⊎-assoc⁻¹ (inj₁ x) = inj₁ (inj₁ x)
⊎-assoc⁻¹ (inj₂ (inj₁ y)) = inj₁ (inj₂ y)
⊎-assoc⁻¹ (inj₂ (inj₂ z)) = inj₂ z
⊎-unit₁ : ∀ {X : Set} → (False ⊎ X) → X
⊎-unit₁ (inj₁ ())
⊎-unit₁ (inj₂ x) = x
⊎-unit₂ : ∀ {X : Set} → (X ⊎ False) → X
⊎-unit₂ (inj₁ x) = x
⊎-unit₂ (inj₂ ())
inj⁻¹ : ∀ {X : Set} → (X ⊎ X) → X
inj⁻¹ (inj₁ x) = x
inj⁻¹ (inj₂ x) = x
-- A set divided, like Gaul, into three parts
infix 6 _⊕_⊕_
data _⊕_⊕_ (X V Y : Set) : Set where
inode : (x : X) → (X ⊕ V ⊕ Y) -- Imported node
bnode : (v : V) → (X ⊕ V ⊕ Y) -- Blank node
enode : (y : Y) → (X ⊕ V ⊕ Y) -- Exported node
_⟨⊕⟩_⟨⊕⟩_ : ∀ {U V W X Y Z} → (W → X) → (U → V) → (Y → Z) →
(W ⊕ U ⊕ Y) → (X ⊕ V ⊕ Z)
(f ⟨⊕⟩ g ⟨⊕⟩ h) (inode w) = inode (f w)
(f ⟨⊕⟩ g ⟨⊕⟩ h) (bnode u) = bnode (g u)
(f ⟨⊕⟩ g ⟨⊕⟩ h) (enode y) = enode (h y)
_[⊕]_[⊕]_ : ∀ {X V Y Z : Set} → (X → Z) → (V → Z) → (Y → Z) →
(X ⊕ V ⊕ Y) → Z
(f [⊕] g [⊕] h) (inode x) = f x
(f [⊕] g [⊕] h) (bnode v) = g v
(f [⊕] g [⊕] h) (enode y) = h y
left : ∀ {V W X Y Z} → (X ⊕ V ⊕ Y) → (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z)
left (inode x) = inode x
left (bnode v) = bnode (inode v)
left (enode y) = bnode (bnode y)
right : ∀ {V W X Y Z} → (Y ⊕ W ⊕ Z) → (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z)
right (inode y) = bnode (bnode y)
right (bnode w) = bnode (enode w)
right (enode z) = enode z
hmerge : ∀ {V W X Y Z A : Set} →
((X ⊕ V ⊕ Y) → A) → ((Y ⊕ W ⊕ Z) → A) →
(X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) → A
hmerge f g (inode x) = f (inode x)
hmerge f g (bnode (inode v)) = f (bnode v)
hmerge f g (bnode (bnode y)) = g (inode y)
hmerge f g (bnode (enode w)) = g (bnode w)
hmerge f g (enode z) = g (enode z)
→-dist-⊕ : ∀ {V X Y Z : Set} → ((X ⊕ V ⊕ Y) → Z) →
((X → Z) × (V → Z) × (Y → Z))
→-dist-⊕ i = ((i ∘ inode) , (i ∘ bnode) , (i ∘ enode))
up : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (X₁ ⊕ V₁ ⊕ Y₁) →
((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))
up (inode x) = inode (inj₁ x)
up (bnode v) = bnode (inj₁ v)
up (enode y) = enode (inj₁ y)
down : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (X₂ ⊕ V₂ ⊕ Y₂) →
((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))
down (inode x) = inode (inj₂ x)
down (bnode v) = bnode (inj₂ v)
down (enode y) = enode (inj₂ y)
vmerge : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂ A : Set} →
((X₁ ⊕ V₁ ⊕ Y₁) → A) → ((X₂ ⊕ V₂ ⊕ Y₂) → A) →
((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂)) → A
vmerge j k (inode (inj₁ x)) = j (inode x)
vmerge j k (inode (inj₂ x)) = k (inode x)
vmerge j k (bnode (inj₁ v)) = j (bnode v)
vmerge j k (bnode (inj₂ v)) = k (bnode v)
vmerge j k (enode (inj₁ y)) = j (enode y)
vmerge j k (enode (inj₂ y)) = k (enode y)
| {
"alphanum_fraction": 0.51149954,
"avg_line_length": 29.3783783784,
"ext": "agda",
"hexsha": "8c4b7f25fcd927e19824c90d5ba8f95d3152999d",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/Util.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/Util.agda",
"max_line_length": 81,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/Util.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 3192,
"size": 6522
} |
module Fail.TuplePat where
open import Haskell.Prelude
fst₃ : a × b × c → a
fst₃ (x ∷ xs) = x
{-# COMPILE AGDA2HS fst₃ #-}
| {
"alphanum_fraction": 0.6377952756,
"avg_line_length": 12.7,
"ext": "agda",
"hexsha": "ed5504e28a7270f882977aa7ae2969792e9a6629",
"lang": "Agda",
"max_forks_count": 18,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z",
"max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "seanpm2001/agda2hs",
"max_forks_repo_path": "test/Fail/TuplePat.agda",
"max_issues_count": 63,
"max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "seanpm2001/agda2hs",
"max_issues_repo_path": "test/Fail/TuplePat.agda",
"max_line_length": 28,
"max_stars_count": 55,
"max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dxts/agda2hs",
"max_stars_repo_path": "test/Fail/TuplePat.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z",
"num_tokens": 49,
"size": 127
} |
{-
This second-order signature was created from the following second-order syntax description:
syntax Lens | L
type
S : 0-ary
A : 0-ary
term
get : S -> A
put : S A -> S
theory
(PG) s : S a : A |> get (put (s, a)) = a
(GP) s : S |> put (s, get(s)) = s
(PP) s : S a b : A |> put (put(s, a), b) = put (s, a)
-}
module Lens.Signature where
open import SOAS.Context
-- Type declaration
data LT : Set where
S : LT
A : LT
open import SOAS.Syntax.Signature LT public
open import SOAS.Syntax.Build LT public
-- Operator symbols
data Lₒ : Set where
getₒ putₒ : Lₒ
-- Term signature
L:Sig : Signature Lₒ
L:Sig = sig λ
{ getₒ → (⊢₀ S) ⟼₁ A
; putₒ → (⊢₀ S) , (⊢₀ A) ⟼₂ S
}
open Signature L:Sig public
| {
"alphanum_fraction": 0.5822281167,
"avg_line_length": 16.3913043478,
"ext": "agda",
"hexsha": "bbc6478ef3e8cec4c59571ed096da0d9774213a8",
"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/Lens/Signature.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/Lens/Signature.agda",
"max_line_length": 91,
"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/Lens/Signature.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": 291,
"size": 754
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Modulo.Properties where
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open import Cubical.Data.Fin
open import Cubical.Data.Sigma
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.HITs.Modulo.Base
open import Cubical.HITs.Modulo.FinEquiv public
private
variable
ℓ : Level
k : ℕ
-- `Modulo 0` is easily shown equivalent to `ℕ`, because we don't need
-- to account for the path constructor at all.
Modulo0≡ℕ : Modulo 0 ≡ ℕ
Modulo0≡ℕ = isoToPath lemma
where
open Iso
lemma : Iso (Modulo 0) ℕ
fun lemma (embed n) = n
inv lemma = embed
rightInv lemma n = refl
leftInv lemma (embed n) = refl
isSetModulo0 : isSet (Modulo 0)
isSetModulo0 = subst isSet (sym Modulo0≡ℕ) isSetℕ
-- `Modulo 1` is contractible just like `Fin 1`
isContrModulo1 : isContr (Modulo 1)
isContrModulo1
= value , λ
{ (embed n) → universal n
; (step n i) → universal-path n i
}
where
value : Modulo 1
value = embed 0
universal : ∀ n → value ≡ embed n
universal zero = refl
universal (suc n) = universal n ∙ step n
universal-path
: ∀ n → PathP (λ i → value ≡ step n i) (universal n) (universal (suc n))
universal-path n i j
= compPath-filler (universal n) (step n) i j
-- `expand o k m` is congruent to `m` modulo `k`, so there is a path
-- between their image in `Modulo k`.
steps : ∀ m o → embed {k = k} m ≡ embed (expand o k m)
steps m zero = refl
steps {k} m (suc o) = steps m o ∙ ztep (expand o k m)
steps≡
: ∀ m n
→ PathP (λ i → embed {k} m ≡ ztep (expand n k m) i)
(steps m n)
(steps m (suc n))
steps≡ m n = λ i j → compPath-filler (steps m n) (ztep (expand n _ m)) i j
stepOver : ∀ m n o → expand o k m ≡ n → embed {k = k} m ≡ embed n
stepOver m n o p = steps m o ∙ cong embed p
-- `Modulo k` is a set for all `k`, because we can transport the
-- evidence from either `ℕ` or `Fin k`.
isSetModulo : isSet (Modulo k)
isSetModulo {0} = isSetModulo0
isSetModulo {suc k} = subst isSet (sym Modulo≡Fin) isSetFin
| {
"alphanum_fraction": 0.6809180918,
"avg_line_length": 27.4320987654,
"ext": "agda",
"hexsha": "734ebc505cc580d33eded3e8446da911cab43fa8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/Modulo/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/Modulo/Properties.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/Modulo/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 767,
"size": 2222
} |
open import OutsideIn.Prelude
open import OutsideIn.X
module OutsideIn.Constraints( x : X) where
open X(x)
data Strata : Set where
Flat : Strata
Extended : Strata
data Implication (knot : Set → Set)(n : Set) : Set where
∃_·_⊃_ : (v : ℕ) → QConstraint n → knot (n ⨁ v) → Implication knot n
{- SYNTAX -}
data Constraint (n : Set) : Strata → Set where
QC : ∀ {x} → QConstraint n → Constraint n x
Imp : Implication (λ n → Constraint n Flat) n → Constraint n Flat
Imp′ : QConstraint n → Constraint n Extended → Constraint n Extended
_∧′_ : ∀ {x} → Constraint n x → Constraint n x → Constraint n x
Ⅎ_ : Constraint (Ⓢ n) Extended → Constraint n Extended
ε′ : ∀ {n}{x} → Constraint n x
ε′ = QC ε
_∼′_ : ∀ {n}{x} → Type n → Type n → Constraint n x
τ₁ ∼′ τ₂ = QC (τ₁ ∼ τ₂)
Ⅎ′_·_ : {n : Set}(v : ℕ) → Constraint (n ⨁ v) Extended → Constraint n Extended
Ⅎ′ (suc n) · c = Ⅎ (Ⅎ′ n · c)
Ⅎ′ zero · c = c
infixl 6 Ⅎ′_·_
{-
toAE : {n : Set}{s : Strata} → Constraint n s → Constraint n Extended
toAE (QC x) = QC x
toAE (a ∧′ b) = toAE a ∧′ toAE b
toAE (Imp (∃ n · Q ⊃ C)) = Imp (∃ n · Q ⊃ toAE C)
toAE (Ⅎ c) = Ⅎ c
-}
infixl 6 Ⅎ_
infixl 7 _∧′_
{- INSTANCES -}
private
pn-is-functor = λ {n} → Monad.is-functor (PlusN-is-monad {n})
module PlusN-f n = Functor (Monad.is-functor (PlusN-is-monad {n}))
module Ⓢ-f = Functor Ⓢ-is-functor
module Type-f = Functor (type-is-functor)
module QC-f = Functor (qconstraint-is-functor)
private
fmap-c : ∀ {s}{a b} → (a → b) → Constraint a s → Constraint b s
fmap-c f (QC x) = QC (QC-f.map f x)
fmap-c f (C₁ ∧′ C₂) = (fmap-c f C₁) ∧′ (fmap-c f C₂)
fmap-c f (Imp′ Q C) = Imp′ (QC-f.map f Q) (fmap-c f C)
fmap-c f (Imp (∃ n · Q ⊃ C)) = Imp (∃ n · (QC-f.map f Q) ⊃ (fmap-c (pn.map f) C))
where module pn = PlusN-f n
fmap-c f (Ⅎ C) = Ⅎ (fmap-c (Ⓢ-f.map f) C)
fmap-c-id : ∀{s}{A : Set} {f : A → A} → isIdentity f → isIdentity (fmap-c {s} f)
fmap-c-id {f = f} isid {QC x } = cong QC (QC-f.identity isid)
fmap-c-id {f = f} isid {Imp′ Q C } = cong₂ Imp′ (QC-f.identity isid) (fmap-c-id isid)
fmap-c-id {f = f} isid {Imp(∃ n · Q ⊃ C)} = cong Imp
(cong₂ (∃_·_⊃_ n)
(QC-f.identity isid)
(fmap-c-id (pn.identity isid)))
where module pn = PlusN-f n
fmap-c-id {f = f} isid {C₁ ∧′ C₂} = cong₂ _∧′_ (fmap-c-id isid) (fmap-c-id isid)
fmap-c-id {f = f} isid {Ⅎ C } = cong Ⅎ_ (fmap-c-id (Ⓢ-f.identity isid))
fmap-c-comp : {s : Strata}{A B C : Set} {f : A → B} {g : B → C} {x : Constraint A s}
→ fmap-c (g ∘ f) x ≡ fmap-c g (fmap-c f x)
fmap-c-comp {x = QC x} = cong QC QC-f.composite
fmap-c-comp {x = Imp′ Q C} = cong₂ Imp′ (QC-f.composite) (fmap-c-comp)
fmap-c-comp {x = C₁ ∧′ C₂} = cong₂ _∧′_ (fmap-c-comp {x = C₁}) (fmap-c-comp {x = C₂})
fmap-c-comp {x = Ⅎ C} = cong Ⅎ_ (combine-composite′ ⦃ Ⓢ-is-functor ⦄ fmap-c fmap-c-comp)
fmap-c-comp {x = Imp(∃ n · Q ⊃ C)} = cong Imp
(cong₂ (∃_·_⊃_ n) QC-f.composite
(combine-composite′ ⦃ pn-is-functor {n}⦄
fmap-c fmap-c-comp))
where module pn = PlusN-f n
constraint-is-functor : ∀ {s : Strata} → Functor (λ n → Constraint n s)
constraint-is-functor = record { map = fmap-c
; identity = fmap-c-id
; composite = fmap-c-comp
}
| {
"alphanum_fraction": 0.490310592,
"avg_line_length": 40.5053763441,
"ext": "agda",
"hexsha": "17e5e368a02181747daea0ad0e159bddbd6a4bef",
"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/Constraints.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/Constraints.agda",
"max_line_length": 94,
"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/Constraints.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": 1350,
"size": 3767
} |
module Agda.Builtin.TrustMe where
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Erase
private
postulate
unsafePrimTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
primTrustMe = primEraseEquality unsafePrimTrustMe
{-# DISPLAY primEraseEquality unsafePrimTrustMe = primTrustMe #-}
| {
"alphanum_fraction": 0.7122905028,
"avg_line_length": 25.5714285714,
"ext": "agda",
"hexsha": "71507197c48cddcddc19316e9c94a352cd54805e",
"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": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "bennn/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"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": "bennn/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda",
"max_line_length": 65,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "bennn/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 118,
"size": 358
} |
{-
This second-order term syntax was created from the following second-order syntax description:
syntax Ring | R
type
* : 0-ary
term
zero : * | 𝟘
add : * * -> * | _⊕_ l20
one : * | 𝟙
mult : * * -> * | _⊗_ l30
neg : * -> * | ⊖_ r50
theory
(𝟘U⊕ᴸ) a |> add (zero, a) = a
(𝟘U⊕ᴿ) a |> add (a, zero) = a
(⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
(⊕C) a b |> add(a, b) = add(b, a)
(𝟙U⊗ᴸ) a |> mult (one, a) = a
(𝟙U⊗ᴿ) a |> mult (a, one) = a
(⊗A) a b c |> mult (mult(a, b), c) = mult (a, mult(b, c))
(⊗D⊕ᴸ) a b c |> mult (a, add (b, c)) = add (mult(a, b), mult(a, c))
(⊗D⊕ᴿ) a b c |> mult (add (a, b), c) = add (mult(a, c), mult(b, c))
(𝟘X⊗ᴸ) a |> mult (zero, a) = zero
(𝟘X⊗ᴿ) a |> mult (a, zero) = zero
(⊖N⊕ᴸ) a |> add (neg (a), a) = zero
(⊖N⊕ᴿ) a |> add (a, neg (a)) = zero
-}
module Ring.Syntax where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Construction.Structure
open import SOAS.ContextMaps.Inductive
open import SOAS.Metatheory.Syntax
open import Ring.Signature
private
variable
Γ Δ Π : Ctx
α : *T
𝔛 : Familyₛ
-- Inductive term declaration
module R:Terms (𝔛 : Familyₛ) where
data R : Familyₛ where
var : ℐ ⇾̣ R
mvar : 𝔛 α Π → Sub R Π Γ → R α Γ
𝟘 : R * Γ
_⊕_ : R * Γ → R * Γ → R * Γ
𝟙 : R * Γ
_⊗_ : R * Γ → R * Γ → R * Γ
⊖_ : R * Γ → R * Γ
infixl 20 _⊕_
infixl 30 _⊗_
infixr 50 ⊖_
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛
Rᵃ : MetaAlg R
Rᵃ = record
{ 𝑎𝑙𝑔 = λ where
(zeroₒ ⋮ _) → 𝟘
(addₒ ⋮ a , b) → _⊕_ a b
(oneₒ ⋮ _) → 𝟙
(multₒ ⋮ a , b) → _⊗_ a b
(negₒ ⋮ a) → ⊖_ a
; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) }
module Rᵃ = MetaAlg Rᵃ
module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where
open MetaAlg 𝒜ᵃ
𝕤𝕖𝕞 : R ⇾̣ 𝒜
𝕊 : Sub R Π Γ → Π ~[ 𝒜 ]↝ Γ
𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t
𝕊 (t ◂ σ) (old v) = 𝕊 σ v
𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε)
𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v
𝕤𝕖𝕞 𝟘 = 𝑎𝑙𝑔 (zeroₒ ⋮ tt)
𝕤𝕖𝕞 (_⊕_ a b) = 𝑎𝑙𝑔 (addₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞 𝟙 = 𝑎𝑙𝑔 (oneₒ ⋮ tt)
𝕤𝕖𝕞 (_⊗_ a b) = 𝑎𝑙𝑔 (multₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞 (⊖_ a) = 𝑎𝑙𝑔 (negₒ ⋮ 𝕤𝕖𝕞 a)
𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ Rᵃ 𝒜ᵃ 𝕤𝕖𝕞
𝕤𝕖𝕞ᵃ⇒ = record
{ ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t }
; ⟨𝑣𝑎𝑟⟩ = refl
; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } }
where
open ≡-Reasoning
⟨𝑎𝑙𝑔⟩ : (t : ⅀ R α Γ) → 𝕤𝕖𝕞 (Rᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t)
⟨𝑎𝑙𝑔⟩ (zeroₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (addₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (oneₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (multₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (negₒ ⋮ _) = refl
𝕊-tab : (mε : Π ~[ R ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v)
𝕊-tab mε new = refl
𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v
module _ (g : R ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ Rᵃ 𝒜ᵃ g) where
open MetaAlg⇒ gᵃ⇒
𝕤𝕖𝕞! : (t : R α Γ) → 𝕤𝕖𝕞 t ≡ g t
𝕊-ix : (mε : Sub R Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v)
𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x
𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v
𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε))
= trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε))
𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩
𝕤𝕖𝕞! 𝟘 = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (_⊕_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! 𝟙 = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (_⊗_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (⊖_ a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩
-- Syntax instance for the signature
R:Syn : Syntax
R:Syn = record
{ ⅀F = ⅀F
; ⅀:CS = ⅀:CompatStr
; mvarᵢ = R:Terms.mvar
; 𝕋:Init = λ 𝔛 → let open R:Terms 𝔛 in record
{ ⊥ = R ⋉ Rᵃ
; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ }
; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } }
-- Instantiation of the syntax and metatheory
open Syntax R:Syn public
open R:Terms public
open import SOAS.Families.Build public
open import SOAS.Syntax.Shorthands Rᵃ public
open import SOAS.Metatheory R:Syn public
| {
"alphanum_fraction": 0.4965260546,
"avg_line_length": 26.1688311688,
"ext": "agda",
"hexsha": "6bc95c421b5892229c3d00b214c0635a9056342d",
"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/Ring/Syntax.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/Ring/Syntax.agda",
"max_line_length": 93,
"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/Ring/Syntax.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": 2662,
"size": 4030
} |
module Issue826-2 where
open import Common.Coinduction
data _≡_ {A : Set} (x y : A) : Set where
data D : Set where
c : ∞ D → D
delay : D → ∞ D
delay x = ♯ x
data P : D → Set where
o : (x : ∞ D) → P (♭ x) → P (c x)
postulate
h : (x : D) → P x → P x
f : (x : D) → P (c (delay x)) → P x
f x (o .(delay x) p) = h x p
g : (x : D) → P x → P (c (delay x))
g x p = h (c (delay x)) (o (delay x) p)
postulate
bar : (x : ∞ D) (p : P (♭ x)) →
h (c x) (o x (h (♭ x) p)) ≡ o x p
foo : (x : D) (p : P (c (delay x))) → g x (f x p) ≡ p
foo x (o .(delay x) p) = goal
where
x′ = _
goal : _ ≡ o x′ p
goal = bar x′ p
-- The following error message seems to indicate that an expression is
-- not forced properly:
--
-- Bug.agda:30,26-30
-- ♭ (.Bug.♯-0 x) != x of type D
-- when checking that the expression goal has type
-- g x (f x (o (.Bug.♯-0 x) p)) ≡ o (.Bug.♯-0 x) p
--
-- Thus it seems as if this problem affects plain type-checking as
-- well.
| {
"alphanum_fraction": 0.5097636177,
"avg_line_length": 20.7021276596,
"ext": "agda",
"hexsha": "0ef9241cac1dfc31468ddf49de11acb4d652493c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue826-2.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue826-2.agda",
"max_line_length": 70,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue826-2.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": 417,
"size": 973
} |
{- 2010-09-17 a small case study to test irrelevance -}
module IrrelevanceCaseStudyPartialFunctions where
data _≡_ {A : Set}(a : A) : A → Set where
refl : a ≡ a
record ⊤ : Set where
record Sigma (A : Set)(B : A → Set) : Set where
constructor _,_
field
fst : A
snd : B fst
syntax Sigma A (λ x → B) = Σ x ∈ A , B
data Subset (A : Set)(P : A → Set) : Set where
_#_ : (elem : A) → .(P elem) → Subset A P
elimSubset : ∀ {A C : Set} {P} →
Subset A P → ((a : A) → .(P a) → C) → C
elimSubset (a # p) k = k a p
syntax Subset A (λ x → P) = ⁅ x ∈ A ∣ P ⁆
elem : {A : Set}{P : A → Set} → ⁅ x ∈ A ∣ P x ⁆ → A
elem (x # p) = x
elim₂ : ∀ {A C : Set} {P Q : A → Set} →
Subset A (λ x → Sigma (P x) (λ _ → Q x)) →
((a : A) → .(P a) → .(Q a) → C) → C
elim₂ (a # (p , q)) k = k a p q
record _⇀_ (A B : Set) : Set1 where
constructor mkParFun
field
dom : A → Set
_′_ : ⁅ x ∈ A ∣ dom x ⁆ → B
open _⇀_ public
syntax mkParFun dom f = f ↾ dom
pure : {A B : Set} → (A → B) → A ⇀ B
pure f = record { dom = λ x → ⊤ ; _′_ = λ a → f (elem a) }
_∘_ : {A B C : Set} → (B ⇀ C) → (A ⇀ B) → A ⇀ C
(g ↾ Q) ∘ (f ↾ P) = gf ↾ QP where
QP : _ → Set
QP x = Σ x∈P ∈ P x , Q (f (x # x∈P))
gf : Subset _ QP → _
gf (x # (p , q)) = g (f (x # p) # q)
_⊑_ : {A B : Set} → (f f' : A ⇀ B) → Set
(f ↾ P) ⊑ (f' ↾ P') =
Σ φ ∈ (∀ {x} → P x → P' x) ,
(∀ {x} (p : P x) → f (x # p) ≡ f' (x # φ p))
| {
"alphanum_fraction": 0.4423611111,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "858f75e485818197067557665f092a4b33e4dcaf",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/IrrelevanceCaseStudyPartialFunctions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/IrrelevanceCaseStudyPartialFunctions.agda",
"max_line_length": 58,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/IrrelevanceCaseStudyPartialFunctions.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": 670,
"size": 1440
} |
-- P: <E[new s]> --> (vcd) <E[(c,d)]>
module Properties.StepNew where
open import Data.Maybe hiding (All)
open import Data.List
open import Data.List.All
open import Data.Product
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Typing
open import Syntax
open import Global
open import Channel
open import Values
open import Session
open import Schedule
open import ProcessSyntax
open import ProcessRun
open import Properties.Base
tch : SType → Type
tch s = (TPair (TChan (SType.force s)) (TChan (SType.force (dual s))))
mknew : ∀ {Φ} → (s : SType) → Expr (tch s ∷ Φ) TUnit → Expr Φ TUnit
mknew s E = letbind (split-all-right _) (new [] s) E
mklhs : ∀ {Φ} → (s : SType) → Expr (tch s ∷ Φ) TUnit → Proc Φ
mklhs s E = exp (mknew s E)
mkrhs : ∀ {Φ} → (s : SType) → Expr (tch s ∷ Φ) TUnit → Proc Φ
mkrhs s E = res s (exp (letbind (left (left (split-all-right _))) (pair (left (rght [])) (here []) (here [])) E))
reduction : (s : SType) (E : Expr (tch s ∷ []) TUnit) →
let lhs = (runProc [] (mklhs s E) (vnil []-inactive)) in
let rhs = (runProc [] (mkrhs s E) (vnil []-inactive)) in
one-step lhs ≡
(New , proj₁ rhs , proj₂ rhs)
reduction s E
with ssplit-refl-left-inactive []
... | G' , ina-G' , ss-GG'
= refl
-- reduction in open context
open-reduction-type : Set
open-reduction-type = ∀ {Φ} (s : SType) (E : Expr (tch s ∷ Φ) TUnit) (ϱ : VEnv [] Φ) →
let lhs = (runProc [] (mklhs s E) ϱ) in
let rhs = (runProc [] (mkrhs s E) ϱ) in
one-step lhs ≡ (New , proj₁ rhs , proj₂ rhs)
open-reduction : open-reduction-type
open-reduction{Φ} s E ϱ
with runProc [] (exp (mknew s E)) ϱ
... | rpse
rewrite split-env-right-lemma0 ϱ
| split-rotate-lemma {Φ}
| split-env-right-lemma ϱ
with ssplit-compose (ss-left{(SType.force s) , POSNEG} ss-[]) (ss-left ss-[])
... | ssc
= refl
{-
-- reduction in open context with further resources
pairs : ∀ {A : Set} {B : A → Set} {p1 p2 : Σ A λ x → B x }
→ p1 ≡ p2 → Σ (proj₁ p1 ≡ proj₁ p2) λ { refl → proj₂ p1 ≡ proj₂ p2 }
pairs {A} {B} refl = refl , refl
split-env-right-lemma0' :
∀ {Φ G} (ϱ : VEnv G Φ) →
let gis = ssplit-refl-right-inactive G in
(split-env (split-all-right Φ) ϱ
≡
((proj₁ gis , G) , proj₂ (proj₂ gis) , vnil (proj₁ (proj₂ gis)) , ϱ))
split-env-right-lemma0' (vnil []-inactive) = refl
split-env-right-lemma0' (vnil (::-inactive ina))
with split-env-right-lemma0' (vnil ina)
... | ih
with pairs ih
... | p1== , p2==
= {!!}
split-env-right-lemma0'{t ∷ Φ} (vcons ssp v ϱ)
with split-env-right-lemma0' ϱ
... | ih
with split-env (split-all-right Φ) ϱ
... | sesar
= {!!}
full-reduction-type : Set
full-reduction-type = ∀ {Φ G} (s : SType) (E : Expr (tch s ∷ Φ) TUnit) (ϱ : VEnv G Φ) →
let lhs = runProc G (mklhs s E) ϱ in
let rhs = runProc G (mkrhs s E) ϱ in
single-step (proj₁ lhs ++ G , proj₂ lhs) ≡ (New , proj₁ rhs ++ G , proj₂ rhs)
full-reduction : full-reduction-type
full-reduction{Φ}{G} s E ϱ
with ssplit-refl-left-inactive G
... | ssrli
rewrite split-env-right-lemma0' ϱ
| split-rotate-lemma {Φ}
= {!!}
-}
| {
"alphanum_fraction": 0.6171171171,
"avg_line_length": 28,
"ext": "agda",
"hexsha": "6a7a481b8ccb30d32860cbc6c2dd6f5ef3b07cf8",
"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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "peterthiemann/definitional-session",
"max_forks_repo_path": "src/Properties/StepNew.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"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": "peterthiemann/definitional-session",
"max_issues_repo_path": "src/Properties/StepNew.agda",
"max_line_length": 113,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "peterthiemann/definitional-session",
"max_stars_repo_path": "src/Properties/StepNew.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z",
"num_tokens": 1173,
"size": 3108
} |
-- Andreas, 2019-06-17, LAIM 2019, issue #3855
-- Only allow erased definitions in erased context.
open import Common.IO
open import Common.Unit
open import Common.String
open import Common.Bool
@0 noWorld : String
noWorld = "Hallo, Welt!"
-- Illegal definition, should raise a type error.
world : Bool → String
world true = "Hello world!"
world false = noWorld
main = putStrLn (world false)
| {
"alphanum_fraction": 0.7386934673,
"avg_line_length": 20.9473684211,
"ext": "agda",
"hexsha": "cde55f068fe5c3b8d32155a81dd66ce4aaadbd2e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue3855a.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue3855a.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue3855a.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 103,
"size": 398
} |
{-# OPTIONS --copatterns #-}
open import Common.Size
record R (i : Size) : Set where
inductive
constructor delay
field
force : (j : Size< i) → R j
open R
inh : (i : Size) → R i
force (inh i) j = inh j
-- Should give termination error
data ⊥ : Set where
elim : R ∞ → ⊥
elim (delay f) = elim (f ∞)
-- Gives termination error, as expected.
| {
"alphanum_fraction": 0.614084507,
"avg_line_length": 14.7916666667,
"ext": "agda",
"hexsha": "f72a0bf33ca3b7defdb5076efaa8a8dbc84a4248",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "hborum/agda",
"max_forks_repo_path": "test/Fail/Issue1015OnlyRecord.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/Issue1015OnlyRecord.agda",
"max_line_length": 40,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/Issue1015OnlyRecord.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": 115,
"size": 355
} |
module WrongNamedArgument where
postulate
f : {A : Set₁} → A → A
test : Set → Set
test = f {B = Set}
-- Good error:
-- Function does not accept argument {B = _}
-- when checking that {B = Set} are valid arguments to a function of
-- type {A : Set₁} → A → A
| {
"alphanum_fraction": 0.6311787072,
"avg_line_length": 18.7857142857,
"ext": "agda",
"hexsha": "29f7a5ef7fe115b95bcce393438d8586ec3f3aad",
"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/WrongNamedArgument.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/WrongNamedArgument.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/WrongNamedArgument.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": 82,
"size": 263
} |
-----------------------------------
-- First order logic
-----------------------------------
module sv20.assign2.SetTheory.Logic where
infix 4 _,_
infix 3 ¬_
infix 1 _∧_
infix 1 _∨_
infix 0 _⇔_
-- Some First order logic I need.
-- ∧ data type (conjunction).
data _∧_ (A B : Set) : Set where
_,_ : A → B → A ∧ B
∧-proj₁ : ∀ {A B} → A ∧ B → A
∧-proj₁ (a , _) = a
∧-proj₂ : ∀ {A B} → A ∧ B → B
∧-proj₂ (_ , b) = b
-- ∨ data type (disjunction), with many useful properties.
data _∨_ (A B : Set) : Set where
inj₁ : A → A ∨ B
inj₂ : B → A ∨ B
∨-e : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C
∨-e A B C (inj₁ a) i₁ i₂ = i₁ a
∨-e A B C (inj₂ b) i₁ i₂ = i₂ b
∨-sym : (A B : Set) → A ∨ B → B ∨ A
∨-sym A B (inj₁ a) = inj₂ a
∨-sym A B (inj₂ b) = inj₁ b
trivial : (A : Set) → A → A
trivial _ A = A
∨-idem : (A : Set) → A ∨ A → A
∨-idem A (inj₁ a) = a
∨-idem A (inj₂ a) = a
∨-prop₁ : {A B C : Set} → (A ∨ B → C) → A → C
∨-prop₁ i a = i (inj₁ a)
∨-prop₂ : {A B C : Set} → (A ∨ B → C) → B → C
∨-prop₂ i b = i (inj₂ b)
∨-prop₃ : {A B C : Set} → A ∨ B → (A → C) → C ∨ B
∨-prop₃ (inj₁ x) i = inj₁ (i x)
∨-prop₃ (inj₂ x) i = inj₂ x
∨-prop₄ : {A B C : Set} → A ∨ B → (B → C) → A ∨ C
∨-prop₄ (inj₁ x) x₁ = inj₁ x
∨-prop₄ (inj₂ x) x₁ = inj₂ (x₁ x)
∨-prop₅ : {A B C D : Set} → A ∨ B → (A → C) → (B → D) → C ∨ D
∨-prop₅ (inj₁ a) a→c b→d = inj₁ (a→c a)
∨-prop₅ (inj₂ b) a→c b→d = inj₂ (b→d b)
∨-∧ : {A B : Set} → (A ∧ B) ∨ (B ∧ A) → A ∧ B
∨-∧ (inj₁ (a , b)) = a , b
∨-∧ (inj₂ (b , a)) = a , b
-- Bi-implication.
_⇔_ : Set → Set → Set
A ⇔ B = (A → B) ∧ (B → A)
⇔-p : (A B C : Set) → A ⇔ (B ∧ C) → (C → B) → A ⇔ C
⇔-p A B C (h₁ , h₂) h₃ = prf₁ , prf₂
where
prf₁ : A → C
prf₁ A = ∧-proj₂ (h₁ A)
prf₂ : C → A
prf₂ C = h₂ ((h₃ C) , C)
-- Empty data type.
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
data ⊤ : Set where
tt : ⊤
-- Negation
¬_ : Set → Set
¬ A = A → ⊥
cont : (A : Set) → A ∧ ¬ A → ⊥
cont _ (x , ¬x) = ¬x x
| {
"alphanum_fraction": 0.4380122951,
"avg_line_length": 19.52,
"ext": "agda",
"hexsha": "a0a65543b5fa08ad7fa234224d55a8fde2d3e285",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda",
"max_line_length": 61,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1041,
"size": 1952
} |
module Issue690a where
postulate A : Set
data T : Set → Set where
c : T (T A)
| {
"alphanum_fraction": 0.6463414634,
"avg_line_length": 11.7142857143,
"ext": "agda",
"hexsha": "9fa795a8375959a076a4e25b304d2b2a55ceae34",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue690a.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue690a.agda",
"max_line_length": 24,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/fail/Issue690a.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": 28,
"size": 82
} |
open import Oscar.Prelude
open import Oscar.Class
module Oscar.Class.Hmap where
module Hmap
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
{𝔯₁} {𝔯₂}
(ℜ₁ : 𝔛₁ → 𝔛₂ → Ø 𝔯₁)
(ℜ₂ : 𝔛₁ → 𝔛₂ → Ø 𝔯₂)
= ℭLASS (ℜ₁ , ℜ₂)
(∀ x y
→ ℜ₁ x y → ℜ₂ x y)
module _
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
{𝔯₁} {𝔯₂}
{ℜ₁ : 𝔛₁ → 𝔛₂ → Ø 𝔯₁}
{ℜ₂ : 𝔛₁ → 𝔛₂ → Ø 𝔯₂}
where
hmap = Hmap.method ℜ₁ ℜ₂
module _
{𝔵} {𝔛 : Ø 𝔵}
{𝔯₁} {𝔯₂}
{ℜ₁ : 𝔛 → 𝔛 → Ø 𝔯₁}
{ℜ₂ : 𝔛 → 𝔛 → Ø 𝔯₂}
where
smap : ⦃ _ : Hmap.class ℜ₁ ℜ₂ ⦄ → ∀ {x y} → ℜ₁ x y → ℜ₂ x y
smap = Hmap.method ℜ₁ ℜ₂ _ _
§ = smap
module _
{𝔵} {𝔛 : Ø 𝔵}
{𝔯₁} {𝔯₂}
{ℜ₁ : 𝔛 → 𝔛 → Ø 𝔯₁}
(ℜ₂ : 𝔛 → 𝔛 → Ø 𝔯₂)
where
smap[_] : ⦃ _ : Hmap.class ℜ₁ ℜ₂ ⦄ → ∀ {x y} → ℜ₁ x y → ℜ₂ x y
smap[_] = Hmap.method ℜ₁ ℜ₂ _ _
§[_] = smap[_]
| {
"alphanum_fraction": 0.4657534247,
"avg_line_length": 17.8444444444,
"ext": "agda",
"hexsha": "1a1afcc01ab3d9596da8ef301c83e6bb363ee0ee",
"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/Hmap.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/Hmap.agda",
"max_line_length": 64,
"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/Hmap.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 544,
"size": 803
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Equality.DecSetoid directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Data.List.Relation.Equality.DecSetoid
{a ℓ} (DS : DecSetoid a ℓ) where
open import Data.List.Relation.Binary.Equality.DecSetoid DS public
| {
"alphanum_fraction": 0.5274949084,
"avg_line_length": 30.6875,
"ext": "agda",
"hexsha": "9496fada128a0ec5356b780ae6c06a1df8a8b379",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Equality/DecSetoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Equality/DecSetoid.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/Data/List/Relation/Equality/DecSetoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 92,
"size": 491
} |
{-# OPTIONS --safe --warning=error --cubical --without-K #-}
open import Agda.Primitive
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Naturals
open import Basic
module File1 where
{-
Let's define the integers. Answers can be found in commit 4d7aad52e014daeb48fe5fb6854d3b6e0080012a.
If you want to learn how to type something, remember the Emacs action is M-x describe-char with the cursor on a character.
-}
data ℤ : Set where
pos : ℕ → ℤ
neg : ℕ → ℤ
congZero : pos 0 ≡ neg 0
{-
A bit odd! We defined an integer to be "a natural tagged as positive", "a natural tagged as negative", or "a witness that pos 0 = neg 0".
This is obvious nonsense (how can two things be equal if they were made from different constructors?! what even does it mean for "pos 0 ≡ neg 0" to be an integer?!) until you let go of your preconceptions about what it means for two things to be equal.
-}
-- Just to help you realise how odd this is, we'll use some new Cubical definitions to manifest a really weird element of ℤ which is neither a `pos` nor a `neg`. Don't worry too much about this for now.
oddThing : ℤ
oddThing = congZero i1
-- Even odder, the integer we just made is equal to 0. Think how strange this is: it's not built using the only constructor that could build `pos 0`, but it's still equal to `pos 0`.
oddThing2 : pos 0 ≡ oddThing
oddThing2 = congZero
{-
Add 1 to an integer. The first cases are easy, but the last case is very odd and we will discuss it in detail.
-}
incr : ℤ → ℤ
incr (pos x) = pos (succ x)
incr (neg zero) = pos 1
incr (neg (succ x)) = neg x
-- First of all, we have in scope an "integer" `congZero` which is of type `pos 0 ≡ neg 0` - huh?!
incr (congZero i) = {!!}
{-
This one looks different from the non-cubical world.
Goal: ℤ
———— Boundary ——————————————————————————————————————————————
i = i0 ⊢ pos 1
i = i1 ⊢ pos 1
————————————————————————————————————————————————————————————
i : I
———— Constraints ———————————————————————————————————————————
pos 1 = ?0 (i = i1) : ℤ
pos 1 = ?0 (i = i0) : ℤ
The constraints look pretty normal, telling you that goal 0 needs to be equal to `pos 1`.
But there's stuff about this `i : I` here. What's that?
Recall that Cubical alters the definition of ≡. Given any element of X, an element of X ≡ Y contains content for how that element corresponds to a Y, and vice versa.
Homotopy type theory, and Cubical Agda, prefer to think of a more general structure on top of that data, though: not only can we go from an X to a Y, but we also store *how* we get there.
More abstractly, we store how to traverse a path from X to Y. The `i` here is telling us where along that path we are; the template goes from the special symbol `i0` to the special symbol `i1`, and `i` is notionally somewhere between those two points.
This gives some nice composability properties: if we know that X ≡ Y and that Y ≡ Z, we can compose the two paths to get a path X ≡ Z.
Cubical Agda's great innovation is that all this has computational content: proofs about X can be transported along the path to obtain for free proofs about Z.
Having told Agda that `incr (pos x) = pos (succ x)`, it can infer that `incr (pos 0) = pos 1`.
So our goal of constructing a path `incr congZero : incr (pos 0) ≡ incr (neg 0)` is in fact the requirement to construct a path `pos 1 ≡ incr (neg 0)`.
Similarly, we told it that `incr (neg 0) = pos 1`, so our path `incr congZero` is actually of type `pos 1 ≡ pos 1`
The `I` from the goal is the template of the path `congZero n` which we are trying to construct from `pos 1` to `pos 1`.
The `i0` and `i1` are the templates for the start and end points of the path, i.e. they both indicate `pos 1`.
What we really wanted to write here was `incr congZero`. For reasons I don't understand, Agda doesn't accept this.
We are forced to descend to the level of actually implementing the path from `pos 1` to `pos 1` by telling Agda where each `i` goes, even though there's an obvious way (`refl`) to specify the entire path at once.
Agda can automatically infer the correct hole-fill, but you can try it with `pos 1`.
-}
{-
Let's show that successors of naturals are nonzero.
We do this using a new technique that only makes sense in Cubical-land.
Given a path from `succ a` to `0`, we need to show False.
The assumed member of `succ a ≡ 0` is a path that tells us how to get from `succ a` to `0` in a way that is preserved by function application.
That is, it tells us how to show `f (succ a) ≡ f 0` for any `f`. (The function `subst` captures this ability to move functions from one end of a path to the other.)
So if we pick `f` appropriately so that it outputs `False` at 0 but something else (anything else, as long as we can construct it!) at `succ a`, we will be done.
-}
succNonzero : {a : ℕ} → succ a ≡ 0 → False
succNonzero {a} sa=0 = subst f sa=0 {!!}
where
f : ℕ → Set
f zero = False
f (succ i) = {!!}
{-
Let's show that these equality things aren't *too* weird. We'll show that even though `pos 0` is equal to `congZero i1`, it's actually the *only* other `pos` which is equal to `congZero i1`. (You'd hope this would be the case; otherwise we'd have several `pos` being equal to each other.)
Cubical Agda gives us a magical way to do this. Recall that we can move functions along paths (the `subst` from above, which lets us take an `x ≡ y` and an `f` to get `f x → f y`); we can actually also do the same thing viewed as transforming the *entire path* `x ≡ y` using `f` into `f x ≡ f y`.
This is the function `cong`.
If we can somehow create a function that "strips off `pos`", then that function can transform the path `pos a ≡ pos b` into a path `a ≡ b`.
-}
toNat : ℤ → ℕ
toNat z = {!!}
posInjective : {a b : ℕ} → pos a ≡ pos b → a ≡ b
posInjective pr = cong toNat pr
{-
Finally, we can use the injectivity of `pos` in the obvious way to prove that only `pos 0` is `congZero i1`.
-}
notTooOdd : (n : ℕ) → (pos n ≡ congZero i1) → n ≡ 0
notTooOdd zero pr = refl
notTooOdd (succ n) pr = posInjective (pr ∙ sym congZero)
{-
Let's show that `pos` is injective in a different way, inspired by how you might do this kind of thing in a non-Cubical world. We'll go by induction, which means the interesting case will be `pos (succ a) ≡ pos (succ b) → pos a ≡ pos b`.
This is a classic example of moving a path wholesale along a function; in this case, the function is "decrement".
-}
decr : ℤ → ℤ -- TODO hole this
decr z = {!!}
posDecr : {a b : ℕ} → pos (succ a) ≡ pos (succ b) → pos a ≡ pos b
posDecr {a} {b} pr = cong decr pr
posInjective' : {a b : ℕ} → pos a ≡ pos b → a ≡ b
-- The two easy cases first
posInjective' {zero} {zero} x = refl
posInjective' {succ a} {succ b} x = cong succ (posInjective (posDecr x))
{-
We need to transform `pos zero ≡ pos (succ b)` into `zero ≡ succ b`.
We could do this using the proof of `posInjective` - moving the path along `toNat` - but it is also interesting to construct the path `zero ≡ succ b` manually using `subst`.
To use `subst`, we need to construct a function from ℤ which is "a type we can populate" at `pos zero` (i.e. at one end of the path), and `zero ≡ succ b` at `pos (succ b)` (i.e. at the other end of the path); then we will be able to move from the populated type to `zero ≡ succ b` using that function.
These two are quite hard!
-}
posInjective' {zero} {succ b} x = subst t x {!!}
where
t : ℤ → Set
t z = {!!}
posInjective' {succ a} {zero} x = subst t x {!!}
where
t : ℤ → Set
t z = {!!}
{-
What does equality mean on the level of types, rather than values?
Univalence, the axiom which Cubical provides computational meaning to, basically says "identity really means isomorphism".
I will gloss over a lot of detail there, but here is a witness to `ℤ ≡ ℤ` that is not `refl`!
-}
incrDecrInverse1 : (a : ℤ) → incr (decr a) ≡ a
incrDecrInverse1 (pos zero) = sym congZero
incrDecrInverse1 (pos (succ x)) = refl
incrDecrInverse1 (neg x) = refl
{-
The remaining case is worth talking about.
We need a path from incr (decr (congZero j)) to congZero j.
That is, we need a path from incr (neg 1) to congZero j; i.e. from neg 0 to congZero j.
We already have a path from neg 0 to pos 0 - namely `sym congZero`.
But `sym congZero` goes from `neg 0` to every point along `sym congZero` - and `congZero j` is also a point along `sym congZero`, because `sym` just means "reverse the path"!
So we can get the path we need by truncating `sym congZero`, using the `∧` ("min") operation (a special builtin primitive in Cubical).
The path, parameterised by `i` with `j` fixed, is "go backwards (`sym`) along `congZero` to the min of `i` and where `j` lies on this path (`~ j`), but then don't go any further".
Here, `~` means essentially "negate"; if you got to position `i` travelling forward on path `p`, then you got to position `~ i` travelling backward on path `sym p`.
This is probably best done if you draw a little picture.
-}
incrDecrInverse1 (congZero j) i = sym congZero (i ∧ (~ j))
incrDecrInverse2 : (a : ℤ) → decr (incr a) ≡ a
incrDecrInverse2 x = {!!}
incrIso : ℤ ≡ ℤ
incrIso = isoToPath (iso incr decr incrDecrInverse1 incrDecrInverse2)
{-
Unexpected! Cubical has let us prove that ℤ ≡ ℤ in a very nonstandard way. What use is this? Who knows.
-}
| {
"alphanum_fraction": 0.691234846,
"avg_line_length": 51.4972375691,
"ext": "agda",
"hexsha": "3e3babfca4e48f46e5e0acdf3fb6e9479d564333",
"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": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/CubicalTutorial",
"max_forks_repo_path": "File1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"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": "Smaug123/CubicalTutorial",
"max_issues_repo_path": "File1.agda",
"max_line_length": 301,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/CubicalTutorial",
"max_stars_repo_path": "File1.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-16T23:14:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-26T17:02:42.000Z",
"num_tokens": 2795,
"size": 9321
} |
module Issue2845 where
open import Agda.Builtin.Nat
open import Agda.Primitive.Cubical
open import Agda.Builtin.Equality
Ex1 : Nat
Ex1 = primComp (λ i → Nat) i0 (λ i → isOneEmpty) zero
test1 : Ex1 ≡ zero
test1 = refl
Ex2 : (i : I) → Nat
Ex2 i = primComp (λ i → Nat) i (λ { _ (i = i1) → zero}) zero
test2 : ∀ i → Ex2 i ≡ zero
test2 i = refl
Ex3 : (i : I) (p : I → Nat) → Nat
Ex3 i p = primComp (λ i → Nat) i (λ { k (i = i1) → suc (p k)}) (suc (p i0))
test3 : ∀ i p → Ex3 i p ≡ suc _
test3 i p = refl
| {
"alphanum_fraction": 0.5968379447,
"avg_line_length": 21.0833333333,
"ext": "agda",
"hexsha": "fe914c88c71a258a3d42187d261e30adb1ddd74c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/Issue2845.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/Issue2845.agda",
"max_line_length": 75,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/Issue2845.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 212,
"size": 506
} |
{-# OPTIONS --without-K --exact-split --safe #-}
module Universes where
open import Agda.Primitive public
renaming (
Level to Universe -- We speak of universes rather than of levels.
; lzero to 𝓤₀ -- Our first universe is called 𝓤₀
; lsuc to _⁺ -- The universe after 𝓤 is 𝓤 ⁺
; Setω to 𝓤ω -- There is a universe 𝓤ω strictly above 𝓤₀, 𝓤₁, ⋯ , 𝓤ₙ, ⋯
)
using (_⊔_) -- Least upper bound of two universes, e.g. 𝓤₀ ⊔ 𝓤₁ is 𝓤₁
Type = λ ℓ → Set ℓ
_̇ : (𝓤 : Universe) → Type (𝓤 ⁺)
𝓤 ̇ = Type 𝓤
𝓤₁ = 𝓤₀ ⁺
𝓤₂ = 𝓤₁ ⁺
𝓤₃ = 𝓤₂ ⁺
_⁺⁺ : Universe → Universe
𝓤 ⁺⁺ = 𝓤 ⁺ ⁺
universe-of : {𝓤 : Universe} (X : 𝓤 ̇ ) → Universe
universe-of {𝓤} X = 𝓤
infix 1 _̇
| {
"alphanum_fraction": 0.5397039031,
"avg_line_length": 23.21875,
"ext": "agda",
"hexsha": "c33d26199d60e5e09deb692930e2e0847855c716",
"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": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sym-cereal/proofs",
"max_forks_repo_path": "HoTT-UT-Agda/Universes.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"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": "sym-cereal/proofs",
"max_issues_repo_path": "HoTT-UT-Agda/Universes.agda",
"max_line_length": 88,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UnsoundWitch/proofs",
"max_stars_repo_path": "HoTT-UT-Agda/Universes.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T10:58:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-03T03:29:40.000Z",
"num_tokens": 324,
"size": 743
} |
{-# OPTIONS --cubical --safe #-}
module Lemmas where
open import Cubical.Core.Everything using (_≡_; Level; Type)
open import Data.Fin using (Fin; toℕ; fromℕ<; zero; suc)
open import Data.Integer using (ℤ; +_; -[1+_])
open import Data.Nat
open import Data.Nat.Properties using (≤-step)
open import Relation.Nullary.Decidable using (False)
open import Relation.Nullary using (yes; no)
k≤n⇒n-k≤n : (k n : ℕ) → k ≤ n → n ∸ k ≤ n
k≤n⇒n-k≤n zero zero z≤n = z≤n
k≤n⇒n-k≤n zero (suc n) z≤n = s≤s (k≤n⇒n-k≤n zero n z≤n)
k≤n⇒n-k≤n (suc k) zero ()
k≤n⇒n-k≤n (suc k) (suc n) (s≤s p) = ≤-step (k≤n⇒n-k≤n k n p)
finN<N : {n : ℕ} → (k : Fin n) → toℕ k < n
finN<N zero = s≤s z≤n
finN<N (suc k) = s≤s (finN<N k)
suc≤-injective : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n
suc≤-injective (s≤s p) = p
-- revMod k = n - k
revMod : ∀ {n : ℕ} → Fin (suc n) → Fin (suc n)
revMod {n} k = fromℕ< (s≤s (k≤n⇒n-k≤n (toℕ k) n (suc≤-injective (finN<N k))))
| {
"alphanum_fraction": 0.5438247012,
"avg_line_length": 32.3870967742,
"ext": "agda",
"hexsha": "167087aa2feda043d7c36f9573fec80a6a0d96b5",
"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/Lemmas.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/Lemmas.agda",
"max_line_length": 77,
"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/Lemmas.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": 475,
"size": 1004
} |
open import Data.ByteString.Primitive using ( ByteStringStrict ; ByteStringStrict² ; ByteStringLazy ; ByteStringLazy² )
open import Data.Bool using ( Bool )
open import Data.Char using ( Char )
open import Data.Natural using ( Natural )
open import Data.String using ( String )
module Data.ByteString.UTF8.Primitive where
postulate
fromStringStrict : String → ByteStringStrict
toStringStrict : ByteStringStrict → String
lengthStrict : ByteStringStrict → Natural
spanStrict : (Char → Bool) → ByteStringStrict → ByteStringStrict²
breakStrict : (Char → Bool) → ByteStringStrict → ByteStringStrict²
{-# IMPORT Data.ByteString.UTF8 #-}
{-# COMPILED fromStringStrict Data.ByteString.UTF8.fromString #-}
{-# COMPILED toStringStrict Data.ByteString.UTF8.toString #-}
{-# COMPILED lengthStrict fromIntegral . Data.ByteString.UTF8.length #-}
{-# COMPILED spanStrict Data.ByteString.UTF8.span #-}
{-# COMPILED breakStrict Data.ByteString.UTF8.break #-}
postulate
fromStringLazy : String → ByteStringLazy
toStringLazy : ByteStringLazy → String
lengthLazy : ByteStringLazy → Natural
spanLazy : (Char → Bool) → ByteStringLazy → ByteStringLazy²
breakLazy : (Char → Bool) → ByteStringLazy → ByteStringLazy²
{-# IMPORT Data.ByteString.Lazy.UTF8 #-}
{-# COMPILED fromStringLazy Data.ByteString.Lazy.UTF8.fromString #-}
{-# COMPILED toStringLazy Data.ByteString.Lazy.UTF8.toString #-}
{-# COMPILED lengthLazy fromIntegral . Data.ByteString.Lazy.UTF8.length #-}
{-# COMPILED spanLazy Data.ByteString.Lazy.UTF8.span #-}
{-# COMPILED breakLazy Data.ByteString.Lazy.UTF8.break #-}
| {
"alphanum_fraction": 0.7613065327,
"avg_line_length": 43.027027027,
"ext": "agda",
"hexsha": "829164f7b92c07a3d49bccb972e48e03c673ed88",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/Data/ByteString/UTF8/Primitive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"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": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/Data/ByteString/UTF8/Primitive.agda",
"max_line_length": 120,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/Data/ByteString/UTF8/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 355,
"size": 1592
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommSemiring where
open import Cubical.Algebra.CommSemiring.Base public
| {
"alphanum_fraction": 0.7899159664,
"avg_line_length": 23.8,
"ext": "agda",
"hexsha": "9e2d02243761be451109f067d3da71ba996e0747",
"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/CommSemiring.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/CommSemiring.agda",
"max_line_length": 52,
"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/CommSemiring.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 27,
"size": 119
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import cw.FinCW
open import cw.FinBoundary
open import cohomology.Theory
{- The reason that RephraseDualizedFirstFinBoundary did not handle this case
is because [FinSkeleton n] does not compute. -}
module cw.cohomology.cochainequiv.DualizedFirstBoundary (OT : OrdinaryTheory lzero)
(⊙fin-skel : ⊙FinSkeleton 1) where
open OrdinaryTheory OT
open FreeAbelianGroup
private
fin-skel = ⊙FinSkeleton.skel ⊙fin-skel
I = AttachedFinSkeleton.numCells fin-skel
I₋₁ = AttachedFinSkeleton.skel fin-skel
module FAG = FreeAbelianGroup (Fin I)
module FAG₋₁ = FreeAbelianGroup (Fin I₋₁)
open FAG renaming (FreeAbGroup to G) using ()
open FAG₋₁ renaming (FreeAbGroup to G₋₁) using ()
abstract
rephrase-dualized-first-boundary-in-degree : ∀ g <I
→ GroupHom.f (Freeness.extend _ (C2-abgroup 0) g) (GroupHom.f (fboundary-last fin-skel) (FAG.insert <I))
== Group.sum (C2 0) (λ <I₋₁ → Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁))
rephrase-dualized-first-boundary-in-degree g <I =
γ.f (GroupHom.f (fboundary-last fin-skel) (FAG.insert <I))
=⟨ ap γ.f $ app= (is-equiv.g-f (FAG.Freeness.extend-is-equiv G₋₁) (fboundary'-last fin-skel)) <I ⟩
γ.f (G₋₁.sum (λ <I₋₁ → G₋₁.exp (FAG₋₁.insert <I₋₁) (fdegree-last fin-skel <I <I₋₁)))
=⟨ γ.pres-sum (λ <I₋₁ → G₋₁.exp (FAG₋₁.insert <I₋₁) (fdegree-last fin-skel <I <I₋₁)) ⟩
C⁰2.sum (λ <I₋₁ → (γ.f (G₋₁.exp (FAG₋₁.insert <I₋₁) (fdegree-last fin-skel <I <I₋₁))))
=⟨ ap C⁰2.sum (λ= λ <I₋₁ → γ.pres-exp (FAG₋₁.insert <I₋₁) (fdegree-last fin-skel <I <I₋₁)) ⟩
C⁰2.sum (λ <I₋₁ → (C⁰2.exp (γ.f (FAG₋₁.insert <I₋₁)) (fdegree-last fin-skel <I <I₋₁)))
=⟨ ap C⁰2.sum
(λ= λ <I₋₁ → ap (λ g → C⁰2.exp g (fdegree-last fin-skel <I <I₋₁)) $
app= (is-equiv.g-f (FAG₋₁.Freeness.extend-is-equiv C⁰2) g) <I₋₁) ⟩
C⁰2.sum (λ <I₋₁ → (C⁰2.exp (g <I₋₁) (fdegree-last fin-skel <I <I₋₁)))
=∎
where
C⁰2 : AbGroup lzero
C⁰2 = C2-abgroup 0
module C⁰2 = AbGroup C⁰2
γ : G₋₁.grp →ᴳ C⁰2.grp
γ = FAG₋₁.Freeness.extend C⁰2 g
module γ = GroupHom γ
| {
"alphanum_fraction": 0.6334405145,
"avg_line_length": 40.3148148148,
"ext": "agda",
"hexsha": "ec3e9b0b30c45e004e2b3a594677b84e6837b469",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.agda",
"max_line_length": 109,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.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": 900,
"size": 2177
} |
-- Andreas, 2021-12-22, issue #5705 reported by ksqsf
open import Agda.Builtin.Equality
crash : Set ≡ Set9223372036854775808
crash = refl
-- This should fail, but crashes in Agda 2.6.2 due to Int overflow.
| {
"alphanum_fraction": 0.7464114833,
"avg_line_length": 23.2222222222,
"ext": "agda",
"hexsha": "d5d5e19192615ae96f742ad6321c05c2ad8e4865",
"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": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue5705.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"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": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue5705.agda",
"max_line_length": 67,
"max_stars_count": 1989,
"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/Issue5705.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": 71,
"size": 209
} |
module Categories.Coend where
| {
"alphanum_fraction": 0.8666666667,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "5edc0a66c5ba822281f697fd6402be082df1b71f",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Coend.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Coend.agda",
"max_line_length": 29,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Coend.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 6,
"size": 30
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.DStructures.Structures.Type where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Functions.FunExtEquiv
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Relation.Binary
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
private
variable
ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓ≅A ℓB ℓ≅B ℓ≅ᴰ ℓP : Level
-- a type is a URGStr with the relation given by its identity type
𝒮-type : (A : Type ℓ) → URGStr A ℓ
𝒮-type A = make-𝒮 {_≅_ = _≡_} (λ _ → refl) isContrSingl
𝒮ᴰ-type : {A : Type ℓA} (B : A → Type ℓB)
→ URGStrᴰ (𝒮-type A) B ℓB
𝒮ᴰ-type {A = A} B = make-𝒮ᴰ (λ b p b' → PathP (λ i → B (p i)) b b')
(λ _ → refl)
λ _ b → isContrSingl b
-- subtypes are displayed structures
𝒮ᴰ-subtype : {A : Type ℓ} (P : A → hProp ℓ')
→ URGStrᴰ (𝒮-type A)
(λ a → P a .fst)
ℓ-zero
𝒮ᴰ-subtype P
= make-𝒮ᴰ (λ _ _ _ → Unit)
(λ _ → tt)
λ a p → isContrRespectEquiv (invEquiv (Σ-contractSnd (λ _ → isContrUnit)))
(inhProp→isContr p (P a .snd))
-- a subtype induces a URG structure on itself
Subtype→Sub-𝒮ᴰ : {A : Type ℓA} (P : A → hProp ℓP)
(StrA : URGStr A ℓ≅A)
→ URGStrᴰ StrA (λ a → P a .fst) ℓ-zero
Subtype→Sub-𝒮ᴰ P StrA =
make-𝒮ᴰ (λ _ _ _ → Unit)
(λ _ → tt)
(λ a p → isContrRespectEquiv (invEquiv (Σ-contractSnd (λ _ → isContrUnit)))
(inhProp→isContr p (P a .snd)))
-- uniqueness of small URG structures
private
module _ {A : Type ℓA} (𝒮 : URGStr A ℓA) where
open URGStr
𝒮' = 𝒮-type A
≅-≡ : _≅_ 𝒮' ≡ _≅_ 𝒮
≅-≡ = funExt₂ (λ a a' → ua (isUnivalent→isUnivalent' (_≅_ 𝒮) (ρ 𝒮) (uni 𝒮) a a'))
ρ-≡ : PathP (λ i → isRefl (≅-≡ i)) (ρ 𝒮') (ρ 𝒮)
ρ-≡ = funExt (λ a → toPathP (p a))
where
p : (a : A) → transport (λ i → ≅-≡ i a a) refl ≡ (ρ 𝒮 a)
p a = uaβ (isUnivalent→isUnivalent' (_≅_ 𝒮) (ρ 𝒮) (uni 𝒮) a a) refl ∙ transportRefl (ρ 𝒮 a)
u : (a : A) → (transport (λ i → ≅-≡ i a a) refl) ≡ (subst (λ a' → (_≅_ 𝒮) a a') refl (ρ 𝒮 a))
u a = uaβ (isUnivalent→isUnivalent' (_≅_ 𝒮) (ρ 𝒮) (uni 𝒮) a a) refl
uni-≡ : PathP (λ i → isUnivalent (≅-≡ i) (ρ-≡ i)) (uni 𝒮') (uni 𝒮)
uni-≡ = isProp→PathP (λ i → isPropΠ2 (λ a a' → isPropIsEquiv (≡→R (≅-≡ i) (ρ-≡ i)))) (uni 𝒮') (uni 𝒮)
𝒮-uniqueness : (A : Type ℓA) → isContr (URGStr A ℓA)
𝒮-uniqueness A .fst = 𝒮-type A
𝒮-uniqueness A .snd 𝒮 = sym (η-URGStr (𝒮-type A)) ∙∙ (λ i → p i) ∙∙ η-URGStr 𝒮
where
p = λ (i : I) → urgstr (≅-≡ 𝒮 i) (ρ-≡ 𝒮 i) (uni-≡ 𝒮 i)
| {
"alphanum_fraction": 0.5483200554,
"avg_line_length": 33.9647058824,
"ext": "agda",
"hexsha": "409f0bffb6b2fedf9e1aef5ff1f649f30d3cac2a",
"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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Structures/Type.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Structures/Type.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Structures/Type.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1271,
"size": 2887
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Rational numbers
------------------------------------------------------------------------
module Data.Rational where
import Algebra
import Data.Bool.Properties as Bool
open import Function
open import Data.Integer as ℤ using (ℤ; ∣_∣; +_; -_)
open import Data.Integer.Divisibility as ℤDiv using (Coprime)
import Data.Integer.Properties as ℤ
open import Data.Nat.Divisibility as ℕDiv using (_∣_)
import Data.Nat.Coprimality as C
open import Data.Nat as ℕ using (ℕ; zero; suc)
open import Data.Sum
import Level
open import Relation.Nullary.Decidable
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl; cong; cong₂)
open P.≡-Reasoning
------------------------------------------------------------------------
-- The definition
-- Rational numbers in reduced form. Note that there is exactly one
-- representative for every rational number. (This is the reason for
-- using "True" below. If Agda had proof irrelevance, then it would
-- suffice to use "isCoprime : Coprime numerator denominator".)
record ℚ : Set where
field
numerator : ℤ
denominator-1 : ℕ
isCoprime : True (C.coprime? ∣ numerator ∣ (suc denominator-1))
denominator : ℤ
denominator = + suc denominator-1
coprime : Coprime numerator denominator
coprime = toWitness isCoprime
-- Constructs rational numbers. The arguments have to be in reduced
-- form.
infixl 7 _÷_
_÷_ : (numerator : ℤ) (denominator : ℕ)
{coprime : True (C.coprime? ∣ numerator ∣ denominator)}
{≢0 : False (ℕ._≟_ denominator 0)} →
ℚ
(n ÷ zero) {≢0 = ()}
(n ÷ suc d) {c} =
record { numerator = n; denominator-1 = d; isCoprime = c }
private
-- Note that the implicit arguments do not need to be given for
-- concrete inputs:
0/1 : ℚ
0/1 = + 0 ÷ 1
-½ : ℚ
-½ = - + 1 ÷ 2
------------------------------------------------------------------------
-- Equality
-- Equality of rational numbers.
infix 4 _≃_
_≃_ : Rel ℚ Level.zero
p ≃ q = numerator p ℤ.* denominator q ≡
numerator q ℤ.* denominator p
where open ℚ
-- _≃_ coincides with propositional equality.
≡⇒≃ : _≡_ ⇒ _≃_
≡⇒≃ refl = refl
≃⇒≡ : _≃_ ⇒ _≡_
≃⇒≡ {i = p} {j = q} =
helper (numerator p) (denominator-1 p) (isCoprime p)
(numerator q) (denominator-1 q) (isCoprime q)
where
open ℚ
helper : ∀ n₁ d₁ c₁ n₂ d₂ c₂ →
n₁ ℤ.* + suc d₂ ≡ n₂ ℤ.* + suc d₁ →
(n₁ ÷ suc d₁) {c₁} ≡ (n₂ ÷ suc d₂) {c₂}
helper n₁ d₁ c₁ n₂ d₂ c₂ eq
with Poset.antisym ℕDiv.poset 1+d₁∣1+d₂ 1+d₂∣1+d₁
where
1+d₁∣1+d₂ : suc d₁ ∣ suc d₂
1+d₁∣1+d₂ = ℤDiv.coprime-divisor (+ suc d₁) n₁ (+ suc d₂)
(C.sym $ toWitness c₁) $
ℕDiv.divides ∣ n₂ ∣ (begin
∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ ℤ.abs-*-commute n₂ (+ suc d₁) ⟩
∣ n₂ ∣ ℕ.* suc d₁ ∎)
1+d₂∣1+d₁ : suc d₂ ∣ suc d₁
1+d₂∣1+d₁ = ℤDiv.coprime-divisor (+ suc d₂) n₂ (+ suc d₁)
(C.sym $ toWitness c₂) $
ℕDiv.divides ∣ n₁ ∣ (begin
∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ cong ∣_∣ (P.sym eq) ⟩
∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ ℤ.abs-*-commute n₁ (+ suc d₂) ⟩
∣ n₁ ∣ ℕ.* suc d₂ ∎)
helper n₁ d c₁ n₂ .d c₂ eq | refl with ℤ.cancel-*-right
n₁ n₂ (+ suc d) (λ ()) eq
helper n d c₁ .n .d c₂ eq | refl | refl with Bool.proof-irrelevance c₁ c₂
helper n d c .n .d .c eq | refl | refl | refl = refl
------------------------------------------------------------------------
-- Equality is decidable
infix 4 _≟_
_≟_ : Decidable {A = ℚ} _≡_
p ≟ q with ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≟
ℚ.numerator q ℤ.* ℚ.denominator p
p ≟ q | yes pq≃qp = yes (≃⇒≡ pq≃qp)
p ≟ q | no ¬pq≃qp = no (¬pq≃qp ∘ ≡⇒≃)
------------------------------------------------------------------------
-- Ordering
infix 4 _≤_ _≤?_
data _≤_ : ℚ → ℚ → Set where
*≤* : ∀ {p q} →
ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤
ℚ.numerator q ℤ.* ℚ.denominator p →
p ≤ q
drop-*≤* : ∀ {p q} → p ≤ q →
ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤
ℚ.numerator q ℤ.* ℚ.denominator p
drop-*≤* (*≤* pq≤qp) = pq≤qp
_≤?_ : Decidable _≤_
p ≤? q with ℚ.numerator p ℤ.* ℚ.denominator q ℤ.≤?
ℚ.numerator q ℤ.* ℚ.denominator p
p ≤? q | yes pq≤qp = yes (*≤* pq≤qp)
p ≤? q | no ¬pq≤qp = no (λ { (*≤* pq≤qp) → ¬pq≤qp pq≤qp })
decTotalOrder : DecTotalOrder _ _ _
decTotalOrder = record
{ Carrier = ℚ
; _≈_ = _≡_
; _≤_ = _≤_
; isDecTotalOrder = record
{ isTotalOrder = record
{ isPartialOrder = record
{ isPreorder = record
{ isEquivalence = P.isEquivalence
; reflexive = refl′
; trans = trans
}
; antisym = antisym
}
; total = total
}
; _≟_ = _≟_
; _≤?_ = _≤?_
}
}
where
module ℤO = DecTotalOrder ℤ.decTotalOrder
refl′ : _≡_ ⇒ _≤_
refl′ refl = *≤* ℤO.refl
trans : Transitive _≤_
trans {i = p} {j = q} {k = r} (*≤* le₁) (*≤* le₂)
= *≤* (ℤ.cancel-*-+-right-≤ _ _ _
(lemma
(ℚ.numerator p) (ℚ.denominator p)
(ℚ.numerator q) (ℚ.denominator q)
(ℚ.numerator r) (ℚ.denominator r)
(ℤ.*-+-right-mono (ℚ.denominator-1 r) le₁)
(ℤ.*-+-right-mono (ℚ.denominator-1 p) le₂)))
where
open Algebra.CommutativeRing ℤ.commutativeRing
lemma : ∀ n₁ d₁ n₂ d₂ n₃ d₃ →
n₁ ℤ.* d₂ ℤ.* d₃ ℤ.≤ n₂ ℤ.* d₁ ℤ.* d₃ →
n₂ ℤ.* d₃ ℤ.* d₁ ℤ.≤ n₃ ℤ.* d₂ ℤ.* d₁ →
n₁ ℤ.* d₃ ℤ.* d₂ ℤ.≤ n₃ ℤ.* d₁ ℤ.* d₂
lemma n₁ d₁ n₂ d₂ n₃ d₃
rewrite *-assoc n₁ d₂ d₃
| *-comm d₂ d₃
| sym (*-assoc n₁ d₃ d₂)
| *-assoc n₃ d₂ d₁
| *-comm d₂ d₁
| sym (*-assoc n₃ d₁ d₂)
| *-assoc n₂ d₁ d₃
| *-comm d₁ d₃
| sym (*-assoc n₂ d₃ d₁)
= ℤO.trans
antisym : Antisymmetric _≡_ _≤_
antisym (*≤* le₁) (*≤* le₂) = ≃⇒≡ (ℤO.antisym le₁ le₂)
total : Total _≤_
total p q =
[ inj₁ ∘′ *≤* , inj₂ ∘′ *≤* ]′
(ℤO.total (ℚ.numerator p ℤ.* ℚ.denominator q)
(ℚ.numerator q ℤ.* ℚ.denominator p))
| {
"alphanum_fraction": 0.4956254797,
"avg_line_length": 29.8853211009,
"ext": "agda",
"hexsha": "66be57e0141ea0b7418a1ed2bd05c42ae5c90a10",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Rational.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 2397,
"size": 6515
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Construction.Properties.Presheaves.CartesianClosed where
open import Level
open import Data.Unit
open import Data.Product using (_,_; proj₁; proj₂)
open import Function.Equality using (Π) renaming (_∘_ to _∙_)
open import Relation.Binary
open import Categories.Category.Core using (Category)
open import Categories.Category.CartesianClosed
open import Categories.Category.CartesianClosed.Canonical renaming (CartesianClosed to CCartesianClosed)
open import Categories.Category.Construction.Presheaves
open import Categories.Category.Instance.Setoids
open import Categories.Functor
open import Categories.Functor.Hom
open import Categories.Functor.Properties
open import Categories.Functor.Presheaf
open import Categories.NaturalTransformation
import Categories.Category.Construction.Properties.Presheaves.Cartesian as Preₚ
import Categories.Morphism.Reasoning as MR
import Relation.Binary.Reasoning.Setoid as SetoidR
open Π using (_⟨$⟩_)
module HasClosed {o ℓ e} (C : Category o ℓ e) where
private
module C = Category C
open C
module _ (F G : Presheaf C (Setoids ℓ e)) where
private
module F = Functor F
module G = Functor G
open Preₚ C
open IsCartesian o o
Presheaf^ : Presheaf C (Setoids (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e))
Presheaf^ = record
{ F₀ = λ X → Hom[ Presheaves C ][ Presheaves× Hom[ C ][-, X ] G , F ]
; F₁ = λ {A B} f → record
{ _⟨$⟩_ = λ α →
let module α = NaturalTransformation α using (η; commute)
in ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ where (g , S) → α.η X ⟨$⟩ (f ∘ g , S)
; cong = λ where (eq₁ , eq₂) → Π.cong (α.η X) (∘-resp-≈ʳ eq₁ , eq₂)
}
; commute = λ { {Z} {W} g {h , x} {i , y} (eq₁ , eq₂) →
let open SetoidR (F.₀ W)
in begin
α.η W ⟨$⟩ (f ∘ C.id ∘ h ∘ g , G.₁ g ⟨$⟩ x) ≈⟨ Π.cong (α.η W) (Equiv.trans (pullˡ id-comm) (center Equiv.refl) , Setoid.refl (G.₀ W)) ⟩
α.η W ⟨$⟩ (C.id ∘ (f ∘ h) ∘ g , G.₁ g ⟨$⟩ x) ≈⟨ α.commute g (∘-resp-≈ʳ eq₁ , eq₂) ⟩
F.₁ g ⟨$⟩ (α.η Z ⟨$⟩ (f ∘ i , y)) ∎ }
}
; cong = λ eq (eq₁ , eq₂) → eq (∘-resp-≈ʳ eq₁ , eq₂)
}
; identity = λ eq (eq₁ , eq₂) → eq (Equiv.trans identityˡ eq₁ , eq₂)
; homomorphism = λ eq (eq₁ , eq₂) → eq (pullʳ (∘-resp-≈ʳ eq₁) , eq₂)
; F-resp-≈ = λ where eq eq′ (eq₁ , eq₂) → eq′ (∘-resp-≈ eq eq₁ , eq₂)
} where open MR C
module IsCartesianClosed {o} (C : Category o o o) where
private
module C = Category C using (id; _∘_; _≈_; identityˡ; identityʳ; module Equiv)
P = Presheaves′ o o C
open HasClosed C using (Presheaf^)
open Preₚ.IsCartesian C o o using (Presheaves-Cartesian)
open MR C
CanonicalCCC : CCartesianClosed P
CanonicalCCC = record
{ ⊤ = PC.terminal.⊤
; _×_ = PC._×_
; ! = PC.!
; π₁ = PC.π₁
; π₂ = PC.π₂
; ⟨_,_⟩ = PC.⟨_,_⟩
; !-unique = PC.!-unique
; π₁-comp = λ {_ _ f} {_ g} → PC.project₁ {h = f} {g}
; π₂-comp = λ {_ _ f} {_ g} → PC.project₂ {h = f} {g}
; ⟨,⟩-unique = λ {_ _ _ f g h} → PC.unique {h = h} {i = f} {j = g}
; _^_ = Presheaf^
; eval = λ {F G} →
let module F = Functor F
module G = Functor G
in ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ { (α , x) →
let module α = NaturalTransformation α
in α.η X ⟨$⟩ (C.id , x) }
; cong = λ where (eq₁ , eq₂) → eq₁ (C.Equiv.refl , eq₂)
}
; commute = λ { {Y} {Z} f {α , x} {β , y} (eq₁ , eq₂) →
let module α = NaturalTransformation α
module β = NaturalTransformation β
open SetoidR (F.₀ Z)
in begin
α.η Z ⟨$⟩ (f C.∘ C.id , G.₁ f ⟨$⟩ x) ≈⟨ eq₁ ((C.Equiv.trans id-comm (C.Equiv.sym C.identityˡ)) , Setoid.refl (G.₀ Z)) ⟩
β.η Z ⟨$⟩ (C.id C.∘ C.id C.∘ f , G.₁ f ⟨$⟩ x) ≈⟨ β.commute f (C.Equiv.refl , eq₂) ⟩
F.₁ f ⟨$⟩ (β.η Y ⟨$⟩ (C.id , y)) ∎ }
}
; curry = λ {F G H} α →
let module F = Functor F
module G = Functor G
module H = Functor H
module α = NaturalTransformation α
in ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ x → ntHelper record
{ η = λ Y → record
{ _⟨$⟩_ = λ where (f , y) → α.η Y ⟨$⟩ (F.₁ f ⟨$⟩ x , y)
; cong = λ where (eq₁ , eq₂) → Π.cong (α.η _) (F.F-resp-≈ eq₁ (Setoid.refl (F.₀ _)) , eq₂)
}
; commute = λ { {Y} {Z} f {g , y} {h , z} (eq₁ , eq₂) →
let open SetoidR (H.₀ Z)
open Setoid (G.₀ Z)
in begin
α.η Z ⟨$⟩ (F.F₁ (C.id C.∘ g C.∘ f) ⟨$⟩ x , G.F₁ f ⟨$⟩ y)
≈⟨ Π.cong (α.η Z) (F.F-resp-≈ C.identityˡ (Setoid.refl (F.₀ X)) , refl) ⟩
α.η Z ⟨$⟩ (F.F₁ (g C.∘ f) ⟨$⟩ x , G.F₁ f ⟨$⟩ y)
≈⟨ Π.cong (α.η Z) (F.homomorphism (Setoid.refl (F.₀ X)) , refl) ⟩
α.η Z ⟨$⟩ (F.F₁ f ⟨$⟩ (F.F₁ g ⟨$⟩ x) , G.F₁ f ⟨$⟩ y)
≈⟨ α.commute f (F.F-resp-≈ eq₁ (Setoid.refl (F.₀ X)) , eq₂) ⟩
H.F₁ f ⟨$⟩ (α.η Y ⟨$⟩ (F.F₁ h ⟨$⟩ x , z))
∎ }
}
; cong = λ where eq (eq₁ , eq₂) → Π.cong (α.η _) (F.F-resp-≈ eq₁ eq , eq₂)
}
; commute = λ { {X} {Y} f {x} {y} eq {Z} {g , z} {h , w} (eq₁ , eq₂) →
let open SetoidR (F.₀ Z)
helper : g C.≈ h → Setoid._≈_ (F.₀ X) x y →
Setoid._≈_ (F.₀ Z) (F.₁ g ⟨$⟩ (F.₁ f ⟨$⟩ x)) (F.₁ (f C.∘ h) ⟨$⟩ y)
helper eq eq′ = begin
F.₁ g ⟨$⟩ (F.₁ f ⟨$⟩ x) ≈⟨ F.F-resp-≈ eq (Setoid.refl (F.₀ Y)) ⟩
F.₁ h ⟨$⟩ (F.₁ f ⟨$⟩ x) ≈˘⟨ F.homomorphism (Setoid.sym (F.₀ X) eq′) ⟩
F.₁ (f C.∘ h) ⟨$⟩ y ∎
in Π.cong (α.η _) (helper eq₁ eq , eq₂) }
}
; eval-comp = λ {F G H} {α} → λ { (eq₁ , eq₂) →
let module H = Functor H
module α = NaturalTransformation α
in Π.cong (α.η _) (H.identity eq₁ , eq₂) }
; curry-resp-≈ = λ { {F} {G} eq eq₁ (eq₂ , eq₃) →
let module G = Functor G
in eq (G.F-resp-≈ eq₂ eq₁ , eq₃) }
; curry-unique = λ {F G H} {α β} eq {X} {x y} eq₁ → λ { {Y} {f , z} {g , w} (eq₂ , eq₃) →
let module F = Functor F
module G = Functor G
module H = Functor H
module α = NaturalTransformation α
module β = NaturalTransformation β
module αXx = NaturalTransformation (α.η X ⟨$⟩ x)
open Setoid (H.₀ Y)
open SetoidR (G.₀ Y)
in begin
αXx.η Y ⟨$⟩ (f , z)
≈⟨ Π.cong (αXx.η _) (C.Equiv.sym C.identityʳ , refl) ⟩
αXx.η Y ⟨$⟩ (f C.∘ C.id , z)
≈⟨ α.sym-commute f (Setoid.refl (F.₀ X)) (C.Equiv.refl , refl) ⟩
NaturalTransformation.η (α.η Y ⟨$⟩ (F.F₁ f ⟨$⟩ x)) Y ⟨$⟩ (C.id , z)
≈⟨ eq (F.F-resp-≈ eq₂ eq₁ , eq₃) ⟩
β.η Y ⟨$⟩ (F.F₁ g ⟨$⟩ y , w)
∎ }
}
where module PC = Presheaves-Cartesian
Presheaves-CartesianClosed : CartesianClosed P
Presheaves-CartesianClosed = Equivalence.fromCanonical P CanonicalCCC
| {
"alphanum_fraction": 0.4925373134,
"avg_line_length": 42.4593023256,
"ext": "agda",
"hexsha": "5e331f24778a8cbb58e3adf33a9015b8a038f13a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/CartesianClosed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/CartesianClosed.agda",
"max_line_length": 150,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/Properties/Presheaves/CartesianClosed.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": 2789,
"size": 7303
} |
------------------------------------------------------------------------
-- The delay monad, defined using increasing sequences of potential
-- values
------------------------------------------------------------------------
{-# OPTIONS --safe #-}
module Delay-monad.Alternative where
open import Equality.Propositional
open import Prelude hiding (↑)
------------------------------------------------------------------------
-- _↓_ and _↑
module _ {a} {A : Type a} where
infix 4 _↑ _↓_
-- x ↓ y means that the computation x has the value y.
_↓_ : Maybe A → A → Type a
x ↓ y = x ≡ just y
-- x ↑ means that the computation x does not have a value.
_↑ : Maybe A → Type a
x ↑ = x ≡ nothing
------------------------------------------------------------------------
-- An alternative definition of the delay monad
module _ {a} {A : Type a} where
-- The property of being an increasing sequence.
LE : Maybe A → Maybe A → Type a
LE x y = x ≡ y ⊎ (x ↑ × ¬ y ↑)
Increasing-at : ℕ → (ℕ → Maybe A) → Type a
Increasing-at n f = LE (f n) (f (suc n))
Increasing : (ℕ → Maybe A) → Type a
Increasing f = ∀ n → Increasing-at n f
-- An alternative definition of the delay monad.
Delay : ∀ {a} → Type a → Type a
Delay A = ∃ λ (f : ℕ → Maybe A) → Increasing f
| {
"alphanum_fraction": 0.4781591264,
"avg_line_length": 25.64,
"ext": "agda",
"hexsha": "19c97ea31ef76b20a904aeeb89e318a475315945",
"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": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "src/Delay-monad/Alternative.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"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/partiality-monad",
"max_issues_repo_path": "src/Delay-monad/Alternative.agda",
"max_line_length": 72,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "src/Delay-monad/Alternative.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 324,
"size": 1282
} |
module Issue481InstantiatedImportOnly where
import Common.Issue481ParametrizedModule Set
-- pointless, should yield error
| {
"alphanum_fraction": 0.8699186992,
"avg_line_length": 24.6,
"ext": "agda",
"hexsha": "5ed9d8834e7bb2887b13275384609c242450cb5b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue481InstantiatedImportOnly.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue481InstantiatedImportOnly.agda",
"max_line_length": 44,
"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/Issue481InstantiatedImportOnly.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": 27,
"size": 123
} |
{-# OPTIONS --cubical --safe #-}
module HITs.PropositionalTruncation where
open import Cubical.HITs.PropositionalTruncation
using (squash; ∥_∥; ∣_∣; rec)
renaming (rec→Set to rec→set)
public
| {
"alphanum_fraction": 0.7236180905,
"avg_line_length": 22.1111111111,
"ext": "agda",
"hexsha": "f27c27d28ca9e65ce397b7e11f536a606b784455",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/masters-thesis",
"max_forks_repo_path": "agda/HITs/PropositionalTruncation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"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/masters-thesis",
"max_issues_repo_path": "agda/HITs/PropositionalTruncation.agda",
"max_line_length": 48,
"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": "HITs/PropositionalTruncation.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": 68,
"size": 199
} |
------------------------------------------------------------------------
-- Lists with fast append
------------------------------------------------------------------------
module Data.DifferenceList where
open import Data.List as L using (List)
open import Data.Function
open import Data.Nat
infixr 5 _∷_ _++_
DiffList : Set → Set
DiffList a = List a → List a
lift : ∀ {a} → (List a → List a) → (DiffList a → DiffList a)
lift f xs = λ k → f (xs k)
[] : ∀ {a} → DiffList a
[] = λ k → k
_∷_ : ∀ {a} → a → DiffList a → DiffList a
_∷_ x = lift (L._∷_ x)
[_] : ∀ {a} → a → DiffList a
[ x ] = x ∷ []
_++_ : ∀ {a} → DiffList a → DiffList a → DiffList a
xs ++ ys = λ k → xs (ys k)
toList : ∀ {a} → DiffList a → List a
toList xs = xs L.[]
-- fromList xs is linear in the length of xs.
fromList : ∀ {a} → List a → DiffList a
fromList xs = λ k → xs ⟨ L._++_ ⟩ k
-- It is OK to use L._++_ here, since map is linear in the length of
-- the list anyway.
map : ∀ {a b} → (a → b) → DiffList a → DiffList b
map f xs = λ k → L.map f (toList xs) ⟨ L._++_ ⟩ k
-- concat is linear in the length of the outer list.
concat : ∀ {a} → DiffList (DiffList a) → DiffList a
concat xs = concat' (toList xs)
where
concat' : ∀ {a} → List (DiffList a) → DiffList a
concat' = L.foldr _++_ []
take : ∀ {a} → ℕ → DiffList a → DiffList a
take n = lift (L.take n)
drop : ∀ {a} → ℕ → DiffList a → DiffList a
drop n = lift (L.drop n)
| {
"alphanum_fraction": 0.5246826516,
"avg_line_length": 24.4482758621,
"ext": "agda",
"hexsha": "d51cfa30100810f58db56bcf3cb79907944b5d2d",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Data/DifferenceList.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Data/DifferenceList.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Data/DifferenceList.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": 474,
"size": 1418
} |
module FStream.Core where
------------------------------------------------------------------------
-- Core module of effectful streams
------------------------------------------------------------------------
open import Library
mutual
record FStream {i : Size} {ℓ₁ ℓ₂} (C : Container ℓ₁) (A : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where
inductive
field
inF : ⟦ C ⟧ (FStream' {i} C A)
record FStream' {i : Size} {ℓ₁ ℓ₂} (C : Container ℓ₁) (A : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where
constructor _≺_
coinductive
field
head : A
tail : {j : Size< i} → FStream {j} C A
open FStream public
open FStream' public
-- TODO Remove nonworking things and put all auxiliary functions in Util.agda
postulate
_►_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} →
⟦ C ⟧ A → FStream C A → FStream C A
--inF (a ► as) = fmap (λ x → x ≺ as) a
-- Caution, this one pushes the side effects down one tick
mutual
_►'_ : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} →
A → FStream {i} C A → FStream {i} C A
inF (a ►' as) = fmap (aux a) (inF as)
aux : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} →
A → FStream' {i} C A → FStream' {i} C A
head (aux a as) = a
tail (aux a as) = head as ►' tail as
-- TODO Write without the direct recursion
{-# TERMINATING #-}
_►⋯' : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} → A → FStream {i} C A
a ►⋯' = a ►' (a ►⋯')
mutual
map : ∀ {i ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {B : Set ℓ₃} →
(A → B) → FStream {i} C A → FStream {i} C B
inF (map f as) = fmap (map' f) (inF as)
map' : ∀ {i ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {B : Set ℓ₃} →
(A → B) → FStream' {i} C A → FStream' {i} C B
head (map' f as) = f (head as)
tail (map' f as) = map f (tail as)
mutual
constantly : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} →
⟦ C ⟧ A → FStream {i} C A
inF (constantly ca) = fmap (constantly' ca) ca
constantly' : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} →
⟦ C ⟧ A → A → FStream' {i} C A
head (constantly' ca a) = a
tail (constantly' ca a) = constantly ca
repeat : {A : Set} → {C : Container ℓ₀} → ⟦ C ⟧ A -> FStream C A
proj₁ (inF (repeat (proj₁ , proj₂))) = proj₁
head (proj₂ (inF (repeat (proj₁ , proj₂))) x) = proj₂ x
tail (proj₂ (inF (repeat (proj₁ , proj₂))) x) = repeat (proj₁ , proj₂)
mutual
corec : ∀ {i ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {X : Set ℓ₃} →
(X → A × ⟦ C ⟧ X) → ⟦ C ⟧ X → FStream {i} C A
inF (corec f x) = fmap (corec' f) x
corec' : ∀ {i ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {X : Set ℓ₃} →
(X → A × ⟦ C ⟧ X) → X → FStream' {i} C A
head (corec' f x) = proj₁ (f x)
tail (corec' f x) = corec f (proj₂ (f x))
{-
Stuff that doesn't obviously work:
* drop, _at_ (Since side effects would have to be thrown away)
(One could at most delay the side effects somehow?)
* _▸⋯ (Only if the given value is effectful or the functor is pointed, i.e. has a null effect (like Applicative or Monad), or by delaying the side effects)
-}
| {
"alphanum_fraction": 0.5386424731,
"avg_line_length": 31.3263157895,
"ext": "agda",
"hexsha": "b9a295e749962b1d7c140da4fd638bf2d5e10975",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z",
"max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "zimbatm/condatis",
"max_forks_repo_path": "FStream/Core.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "zimbatm/condatis",
"max_issues_repo_path": "FStream/Core.agda",
"max_line_length": 156,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "Aerate/condatis",
"max_stars_repo_path": "FStream/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z",
"num_tokens": 1242,
"size": 2976
} |
module lift-tests where
open import lib
open import cedille-types
open import convervsion
open import ctxt
open import lift
open import syntax-util
open import to-string
t0 = Lft posinfo-gen "X" (Parens posinfo-gen (mlam "x" (mlam "y" (mvar "y"))) posinfo-gen)
(LiftArrow (LiftStar posinfo-gen) (LiftArrow (LiftStar posinfo-gen) (LiftStar posinfo-gen)))
t = TpApp (TpApp t0 (mall "X" (Tkk star) (TpArrow (mtpvar "X") (mtpvar "X")))) (mtpvar "False")
s = type-to-string t
s1 = type-to-string (hnf new-ctxt tt t)
| {
"alphanum_fraction": 0.6988636364,
"avg_line_length": 27.7894736842,
"ext": "agda",
"hexsha": "1fa110a74b8795b815fab0476aecd29d2cd680d5",
"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/lift-tests.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/lift-tests.agda",
"max_line_length": 99,
"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/lift-tests.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 181,
"size": 528
} |
-- 2012-03-08 Andreas
module NoTerminationCheck3 where
data Bool : Set where
true false : Bool
f : Bool -> Bool
f true = true
{-# NO_TERMINATION_CHECK #-}
f false = false
-- error: cannot place pragma inbetween clauses
| {
"alphanum_fraction": 0.71875,
"avg_line_length": 17.2307692308,
"ext": "agda",
"hexsha": "0ddfa2177f55a154962e3a8da3fb1530578fac88",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/NoTerminationCheck3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/NoTerminationCheck3.agda",
"max_line_length": 47,
"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/fail/NoTerminationCheck3.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": 62,
"size": 224
} |
module Foundation.Primitive where
open import Agda.Primitive
infix -65536 ℞_
℞_ : ∀ ℓ → Set _
℞_ ℓ = Set ℓ
⟰ : Level → Level
⟰ = lsuc
infix -65536 ℞₁_
℞₁_ : ∀ ℓ → Set _
℞₁_ ℓ = ℞ ⟰ ℓ
𝟘 : Level
𝟘 = lzero
open import Agda.Primitive using (_⊔_) public
| {
"alphanum_fraction": 0.62890625,
"avg_line_length": 12.1904761905,
"ext": "agda",
"hexsha": "319b5160941f08a0daf129896412ac392349b0a5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Foundation/Primitive.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Foundation/Primitive.agda",
"max_line_length": 45,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Foundation/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 116,
"size": 256
} |
{-# OPTIONS --safe #-}
module Cubical.Codata.EverythingSafe where
| {
"alphanum_fraction": 0.7424242424,
"avg_line_length": 22,
"ext": "agda",
"hexsha": "0f7a3646886040b88f65b1d84ab1296f0be00a43",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Codata/EverythingSafe.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Codata/EverythingSafe.agda",
"max_line_length": 42,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Codata/EverythingSafe.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 16,
"size": 66
} |
module OscarEverything where
open import OscarPrelude
| {
"alphanum_fraction": 0.8727272727,
"avg_line_length": 13.75,
"ext": "agda",
"hexsha": "e55fa379ec049e066147403eb9922ed104a341dc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Everything.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Everything.agda",
"max_line_length": 28,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Everything.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 11,
"size": 55
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.SphereEndomorphism
open import groups.Pointed
open import groups.SphereEndomorphism
open import groups.FromSusp
open import cohomology.Theory
module cohomology.SphereEndomorphism (CT : CohomologyTheory lzero) (n : ℤ) (m : ℕ) where
open CohomologyTheory CT
open import cohomology.Cogroup CT n
(Susp-cogroup-structure (⊙Sphere m))
(⊙Sphere (S m))
private
C-fmap' : Trunc-⊙Sphere-endo (S m) → (C n (⊙Sphere (S m)) →ᴳ C n (⊙Sphere (S m)))
C-fmap' = Trunc-rec λ f → C-fmap n f
CEl-fmap' : Trunc-⊙Sphere-endo (S m) → (CEl n (⊙Sphere (S m)) → CEl n (⊙Sphere (S m)))
CEl-fmap' f = GroupHom.f (C-fmap' f)
C-fmap'-hom : Trunc-⊙SphereS-endo-group m →ᴳ
(hom-group (C n (⊙Sphere (S m))) (C-abgroup n (⊙Sphere (S m))))
C-fmap'-hom = group-hom C-fmap'
(Trunc-elim λ f → Trunc-elim λ g → C-fmap-preserves-comp f g)
CEl-fmap'-η : ∀ (f : Trunc-⊙Sphere-endo (S m)) (g : CEl n (⊙Sphere (S m)))
→ CEl-fmap' f g == Group.exp (C n (⊙Sphere (S m))) g (Trunc-⊙SphereS-endo-degree m f)
CEl-fmap'-η f g =
CEl-fmap' f g
=⟨ ! $ ap (λ f → CEl-fmap' f g) $ is-equiv.f-g (Trunc-⊙SphereS-endo-⊙group-is-infinite-cyclic m) f ⟩
CEl-fmap' (Group.exp (Trunc-⊙SphereS-endo-group m) [ ⊙idf _ ] (Trunc-⊙SphereS-endo-degree m f)) g
=⟨ GroupHom.pres-exp
(app-hom g ∘ᴳ C-fmap'-hom)
[ ⊙idf _ ]
(Trunc-⊙SphereS-endo-degree m f) ⟩
Group.exp
(C n (⊙Sphere (S m)))
(CEl-fmap' [ ⊙idf _ ] g)
(Trunc-⊙SphereS-endo-degree m f)
=⟨ ap (λ g → Group.exp (C n (⊙Sphere (S m))) g (Trunc-⊙SphereS-endo-degree m f)) $
CEl-fmap-idf n g ⟩
Group.exp
(C n (⊙Sphere (S m))) g
(Trunc-⊙SphereS-endo-degree m f)
=∎
abstract
CEl-fmap-⊙Sphere-endo-η : ∀ (f : ⊙Sphere-endo (S m)) (g : CEl n (⊙Sphere (S m)))
→ CEl-fmap n f g == Group.exp (C n (⊙Sphere (S m))) g (⊙SphereS-endo-degree m f)
CEl-fmap-⊙Sphere-endo-η f = CEl-fmap'-η [ f ]
| {
"alphanum_fraction": 0.5707410972,
"avg_line_length": 39.2075471698,
"ext": "agda",
"hexsha": "51b26c1a81e3c9074fc9ff774516d90023f54716",
"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/cohomology/SphereEndomorphism.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/cohomology/SphereEndomorphism.agda",
"max_line_length": 108,
"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/cohomology/SphereEndomorphism.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": 855,
"size": 2078
} |
{-# OPTIONS --rewriting #-}
module CF.Contexts.Rewriting where
open import Data.List
open import Data.List.Properties
open import Agda.Builtin.Equality.Rewrite
open import Relation.Binary.PropositionalEquality
open import CF.Types
++-assoc-← : ∀ (xs ys zs : List Ty) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs
++-assoc-← = λ x y z → sym (++-assoc x y z)
++-identityʳ-← : ∀ (xs : List Ty) → xs ++ [] ≡ xs
++-identityʳ-← xs = ++-identityʳ xs
{-# REWRITE ++-assoc-← #-}
{-# REWRITE ++-identityʳ-← #-}
| {
"alphanum_fraction": 0.6224899598,
"avg_line_length": 26.2105263158,
"ext": "agda",
"hexsha": "8d3f39fdcb797ddc11ef96e1b98e1d8deb1b38ab",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ajrouvoet/jvm.agda",
"max_forks_repo_path": "src/CF/Contexts/Rewriting.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"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": "ajrouvoet/jvm.agda",
"max_issues_repo_path": "src/CF/Contexts/Rewriting.agda",
"max_line_length": 73,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ajrouvoet/jvm.agda",
"max_stars_repo_path": "src/CF/Contexts/Rewriting.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z",
"num_tokens": 163,
"size": 498
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Examples showing how the reflective ring solver may be used.
------------------------------------------------------------------------
module README.Tactic.RingSolver where
-- You can ignore this bit! We're just overloading the literals Agda uses for
-- numbers. This bit isn't necessary if you're just using Nats, or if you
-- construct your type directly. We only really do it here so that we can use
-- different numeric types in the same file.
open import Agda.Builtin.FromNat
open import Data.Nat using (ℕ)
open import Data.Integer using (ℤ)
import Data.Nat.Literals as ℕ
import Data.Integer.Literals as ℤ
instance
numberNat : Number ℕ
numberNat = ℕ.number
instance
numberInt : Number ℤ
numberInt = ℤ.number
------------------------------------------------------------------------------
-- Imports!
open import Data.List as List using (List; _∷_; [])
open import Function
open import Relation.Binary.PropositionalEquality as ≡
using (subst; _≡_; module ≡-Reasoning)
open import Data.Bool as Bool using (Bool; true; false; if_then_else_)
open import Data.Unit using (⊤; tt)
open import Tactic.RingSolver.Core.AlmostCommutativeRing using (AlmostCommutativeRing)
------------------------------------------------------------------------------
-- Integer examples
------------------------------------------------------------------------------
module IntegerExamples where
open import Data.Integer.Tactic.RingSolver
open AlmostCommutativeRing ring
-- Everything is automatic: you just ask Agda to solve it and it does!
lemma₁ : ∀ x y → x + y * 1 + 3 ≈ 3 + 1 + y + x + - 1
lemma₁ = solve-∀
lemma₂ : ∀ x y → (x + y) ^ 2 ≈ x ^ 2 + 2 * x * y + y ^ 2
lemma₂ = solve-∀
-- It can interact with manual proofs as well.
lemma₃ : ∀ x y → x + y * 1 + 3 ≈ 2 + 1 + y + x
lemma₃ x y = begin
x + y * 1 + 3 ≡⟨ +-comm x (y * 1) ⟨ +-cong ⟩ refl ⟩
y * 1 + x + 3 ≡⟨ solve (x ∷ y ∷ []) ⟩
3 + y + x ≡⟨⟩
2 + 1 + y + x ∎
where open ≡-Reasoning
------------------------------------------------------------------------------
-- Natural examples
------------------------------------------------------------------------------
module NaturalExamples where
open import Data.Nat.Tactic.RingSolver
open AlmostCommutativeRing ring
-- The solver is flexible enough to work with ℕ (even though it asks
-- for rings!)
lemma₁ : ∀ x y → x + y * 1 + 3 ≈ 2 + 1 + y + x
lemma₁ = solve-∀
------------------------------------------------------------------------------
-- Checking invariants
------------------------------------------------------------------------------
-- The solver makes it easy to prove invariants, without having to rewrite
-- proof code every time something changes in the data structure.
module _ {a} {A : Set a} (_≤_ : A → A → Bool) where
open import Data.Nat.Tactic.RingSolver
open AlmostCommutativeRing ring
-- A Skew Heap, indexed by its size.
data Tree : ℕ → Set a where
leaf : Tree 0
node : ∀ {n m} → A → Tree n → Tree m → Tree (1 + n + m)
-- A substitution operator, to clean things up.
infixr 1 _⇒_
_⇒_ : ∀ {n} → Tree n → ∀ {m} → n ≈ m → Tree m
x ⇒ n≈m = subst Tree n≈m x
open ≡-Reasoning
_∪_ : ∀ {n m} → Tree n → Tree m → Tree (n + m)
leaf ∪ ys = ys
node {a} {b} x xl xr ∪ leaf =
node x xl xr ⇒ solve (a ∷ b ∷ [])
node {a} {b} x xl xr ∪ node {c} {d} y yl yr =
if x ≤ y
then node x (node y yl yr ∪ xr) xl ⇒ begin
1 + (1 + c + d + b) + a ≡⟨ solve (a ∷ b ∷ c ∷ d ∷ []) ⟩
1 + a + b + (1 + c + d) ∎
else node y (node x xl xr ∪ yr) yl ⇒ begin
1 + (1 + a + b + d) + c ≡⟨ solve (a ∷ b ∷ c ∷ d ∷ []) ⟩
1 + a + b + (1 + c + d) ∎
| {
"alphanum_fraction": 0.493513233,
"avg_line_length": 34.1061946903,
"ext": "agda",
"hexsha": "333e51c26acd622199c10dae5ed80ee4ee06cac5",
"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/README/Tactic/RingSolver.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/README/Tactic/RingSolver.agda",
"max_line_length": 86,
"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/README/Tactic/RingSolver.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": 1111,
"size": 3854
} |
{-# OPTIONS --sized-types #-}
-- {-# OPTIONS -v tc.size.solve:100 -v tc.meta.new:50 #-}
module CheckSizeMetaBounds where
open import Common.Size
postulate
Size< : (_ : Size) → Set
{-# BUILTIN SIZELT Size< #-}
data Nat {i : Size} : Set where
zero : Nat
suc : {j : Size< i} → Nat {j} → Nat
one : Nat
one = suc {i = ∞} zero
data ⊥ : Set where
record ⊤ : Set where
NonZero : Nat → Set
NonZero zero = ⊥
NonZero (suc n) = ⊤
-- magic conversion must of course fail
magic : {i : Size} → Nat {∞} → Nat {i}
magic zero = zero
magic (suc n) = suc (magic n)
lem : (n : Nat) → NonZero n → NonZero (magic n)
lem (zero) ()
lem (suc n) _ = _
-- otherwise, we exploit it for an infinite loop
loop : {i : Size} → (x : Nat {i}) → NonZero x → ⊥
loop zero ()
loop (suc {j} n) p = loop {j} (magic one) (lem one _)
bot : ⊥
bot = loop one _
| {
"alphanum_fraction": 0.5894988067,
"avg_line_length": 19.9523809524,
"ext": "agda",
"hexsha": "07372ac028f746f29b491ec60b001e59100f4347",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/fail/CheckSizeMetaBounds.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/fail/CheckSizeMetaBounds.agda",
"max_line_length": 57,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/CheckSizeMetaBounds.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": 299,
"size": 838
} |
-- The bug documented below was exposed by the fix to issue 274.
module Issue274 where
open import Common.Level
record Q a : Set (a ⊔ a) where
record R a : Set a where
field q : Q a
A : Set₁
A = Set
postulate
ℓ : Level
r : R (ℓ ⊔ ℓ)
foo : R ℓ
foo = r
-- Issue274.agda:32,7-8
-- ℓ ⊔ ℓ !=< ℓ of type Level
-- when checking that the expression r has type R ℓ
| {
"alphanum_fraction": 0.6363636364,
"avg_line_length": 14.96,
"ext": "agda",
"hexsha": "40a38978e55aaf4bc9d3d9452bbb692b86e3ac07",
"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/Issue274.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/Issue274.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue274.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": 135,
"size": 374
} |
{-# OPTIONS --copatterns #-}
module SplitResult where
open import Common.Product
test : {A B : Set} (a : A) (b : B) → A × B
test a b = {!!}
-- expected:
-- proj₁ (test a b) = {!!}
-- proj₂ (test a b) = {!!}
testFun : {A B : Set} (a : A) (b : B) → A × B
testFun = {!!}
-- expected:
-- testFun a b = {!!}
record FunRec A : Set where
field funField : A → A
open FunRec
testFunRec : ∀{A} → FunRec A
testFunRec = {!!}
-- expected (since 2016-05-03):
-- funField testFunRec = {!!}
| {
"alphanum_fraction": 0.5548654244,
"avg_line_length": 18.5769230769,
"ext": "agda",
"hexsha": "4e326e7794ecc5a14305ba5e2d8645644608004f",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/interaction/SplitResult.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/interaction/SplitResult.agda",
"max_line_length": 45,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/interaction/SplitResult.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": 172,
"size": 483
} |
{-# OPTIONS --without-K --rewriting #-}
module lib.types.Suspension where
open import lib.types.Suspension.Core public
open import lib.types.Suspension.Flip public
open import lib.types.Suspension.Iterated public
open import lib.types.Suspension.IteratedFlip public
open import lib.types.Suspension.IteratedTrunc public
open import lib.types.Suspension.IteratedEquivs public
open import lib.types.Suspension.Trunc public
| {
"alphanum_fraction": 0.829787234,
"avg_line_length": 35.25,
"ext": "agda",
"hexsha": "d9278d3e6c1a161a355293e3f5d8dcf4829c5409",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Suspension.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Suspension.agda",
"max_line_length": 54,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Suspension.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": 99,
"size": 423
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Rational numbers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Rational where
open import Data.Integer as ℤ using (ℤ; +_)
open import Data.String using (String; _++_)
------------------------------------------------------------------------
-- Publicly re-export contents of core module
open import Data.Rational.Base public
------------------------------------------------------------------------
-- Publicly re-export queries
open import Data.Nat.Properties public
using (_≟_; _≤?_)
------------------------------------------------------------------------
-- Method for displaying rationals
show : ℚ → String
show p = ℤ.show (↥ p) ++ "/" ++ ℤ.show (↧ p)
------------------------------------------------------------------------
-- Deprecated
-- Version 1.0
open import Data.Rational.Properties public
using (drop-*≤*; ≃⇒≡; ≡⇒≃)
| {
"alphanum_fraction": 0.38791423,
"avg_line_length": 27,
"ext": "agda",
"hexsha": "d6e4deb6b8f03f967852f64c17268cae2114e97e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Rational.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Rational.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/Data/Rational.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 188,
"size": 1026
} |
module Data.Num.Redundant.Properties where
open import Data.Num.Bij
open import Data.Num.Redundant renaming (_+_ to _+R_)
open import Data.Nat renaming (_<_ to _<ℕ_)
open import Data.Nat.Etc
open import Data.Nat.Properties.Simple
open import Data.Sum
open import Data.List hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Negation using (contradiction; contraposition)
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; cong; cong₂; trans; sym; inspect)
open PropEq.≡-Reasoning
--------------------------------------------------------------------------------
-- Digits
--------------------------------------------------------------------------------
⊕-comm : (a b : Digit) → a ⊕ b ≡ b ⊕ a
⊕-comm zero zero = refl
⊕-comm zero one = refl
⊕-comm zero two = refl
⊕-comm one zero = refl
⊕-comm one one = refl
⊕-comm one two = refl
⊕-comm two zero = refl
⊕-comm two one = refl
⊕-comm two two = refl
⊕-assoc : (a b c : Digit) → (a ⊕ b) ⊕ c ≡ a ⊕ (b ⊕ c)
⊕-assoc zero b c = refl
⊕-assoc one zero c = refl
⊕-assoc one one zero = refl
⊕-assoc one one one = refl
⊕-assoc one one two = refl
⊕-assoc one two zero = refl
⊕-assoc one two one = refl
⊕-assoc one two two = refl
⊕-assoc two zero c = refl
⊕-assoc two one zero = refl
⊕-assoc two one one = refl
⊕-assoc two one two = refl
⊕-assoc two two zero = refl
⊕-assoc two two one = refl
⊕-assoc two two two = refl
⊕-right-identity : (a : Digit) → a ⊕ zero ≡ a
⊕-right-identity zero = refl
⊕-right-identity one = refl
⊕-right-identity two = refl
⊙-comm : (a b : Digit) → a ⊙ b ≡ b ⊙ a
⊙-comm zero zero = refl
⊙-comm zero one = refl
⊙-comm zero two = refl
⊙-comm one zero = refl
⊙-comm one one = refl
⊙-comm one two = refl
⊙-comm two zero = refl
⊙-comm two one = refl
⊙-comm two two = refl
--------------------------------------------------------------------------------
-- Sequence of Digits
--------------------------------------------------------------------------------
{-
[x∷xs≡0⇒xs≡0] : (d : Digit) → (xs : Redundant) → [ d ∷ xs ] ≡ [ zero ∷ [] ] → [ xs ] ≡ [ zero ∷ [] ]
[x∷xs≡0⇒xs≡0] d [] _ = refl
[x∷xs≡0⇒xs≡0] zero (zero ∷ xs) p = {! no-zero-divisor 2 (0 + 2 * [ xs ]) (λ ()) p !}
[x∷xs≡0⇒xs≡0] zero (one ∷ xs) p = {! !}
[x∷xs≡0⇒xs≡0] zero (two ∷ xs) p = {! !}
-- no-zero-divisor 2 ([ x ] + 2 * [ xs ]) (λ ()) p
[x∷xs≡0⇒xs≡0] one (x ∷ xs) p = contradiction p (λ ())
[x∷xs≡0⇒xs≡0] two (x ∷ xs) p = contradiction p (λ ())
[>>xs]≡2*[xs] : (xs : Redundant) → [ >> xs ] ≡ *2 [ xs ]
[>>xs]≡2*[xs] xs = refl
[n>>>xs]≡2^n*[xs] : (n : ℕ) → (xs : Redundant) → [ n >>> xs ] ≡ 2 ^ n *Bij [ xs ]
[n>>>xs]≡2^n*[xs] zero xs = sym (+-right-identity [ xs ])
[n>>>xs]≡2^n*[xs] (suc n) xs =
begin
[ n >>> (zero ∷ xs) ]
≡⟨ [n>>>xs]≡2^n*[xs] n (zero ∷ xs) ⟩
2 ^ n * [ zero ∷ xs ]
≡⟨ sym (*-assoc (2 ^ n) 2 [ xs ]) ⟩
2 ^ n * 2 * [ xs ]
≡⟨ cong (λ x → x * [ xs ]) (*-comm (2 ^ n) 2) ⟩
2 * 2 ^ n * [ xs ]
∎
-- >> 0 ≈ 0
>>-zero : (xs : Redundant) → xs ≈ zero ∷ [] → >> xs ≈ zero ∷ []
>>-zero [] _ = eq refl
>>-zero (x ∷ xs) (eq x∷xs≈0) = eq (begin
*2 [ x ∷ xs ]
≡⟨ cong (λ w → 2 * w) x∷xs≈0 ⟩
2 * 0
≡⟨ *-right-zero 2 ⟩
0
∎)
-- << 0 ≈ 0
<<-zero : (xs : Redundant) → xs ≈ zero ∷ [] → << xs ≈ zero ∷ []
<<-zero [] _ = eq refl
<<-zero (x ∷ xs) (eq x∷xs≡0) = eq ([x∷xs≡0⇒xs≡0] x xs x∷xs≡0)
-}
{-
>>>-zero : ∀ {n} (xs : Redundant) → {xs≈0 : xs ≈ zero ∷ []} → n >>> xs ≈ zero ∷ []
>>>-zero {n} xs {eq xs≡0} = eq (
begin
[ n >>> xs ]
≡⟨ [n>>>xs]≡2^n*[xs] n xs ⟩
2 ^ n * [ xs ]
≡⟨ cong (λ x → 2 ^ n * x) xs≡0 ⟩
2 ^ n * 0
≡⟨ *-right-zero (2 ^ n) ⟩
0
∎)
<<<-zero : (n : ℕ) (xs : Redundant) → {xs≈0 : xs ≈ zero ∷ []} → n <<< xs ≈ zero ∷ []
<<<-zero zero [] = eq refl
<<<-zero (suc n) [] = eq refl
<<<-zero zero (x ∷ xs) {x∷xs≈0} = x∷xs≈0
<<<-zero (suc n) (x ∷ xs) {eq x∷xs≡0} = <<<-zero n xs {eq ([x∷xs≡0⇒xs≡0] x xs x∷xs≡0)}
-}
--------------------------------------------------------------------------------
-- Properties of the relations on Redundant
--------------------------------------------------------------------------------
≈-Setoid : Setoid _ _
≈-Setoid = record
{ Carrier = Redundant
; _≈_ = _≈_
; isEquivalence = record
{ refl = ≈-refl
; sym = ≈-sym
; trans = ≈-trans
}
}
where
≈-refl : Reflexive _≈_
≈-refl = eq refl
≈-sym : Symmetric _≈_
≈-sym (eq a≈b) = eq (sym a≈b)
≈-trans : Transitive _≈_
≈-trans (eq a≈b) (eq b≈c) = eq (trans a≈b b≈c)
private
≤-isDecTotalOrder = DecTotalOrder.isDecTotalOrder decTotalOrder
≤-isTotalOrder = IsDecTotalOrder.isTotalOrder ≤-isDecTotalOrder
≤-total = IsTotalOrder.total ≤-isTotalOrder
≤-isPartialOrder = IsTotalOrder.isPartialOrder ≤-isTotalOrder
≤-antisym = IsPartialOrder.antisym ≤-isPartialOrder
≤-isPreorder = IsPartialOrder.isPreorder ≤-isPartialOrder
≤-isEquivalence = IsPreorder.isEquivalence ≤-isPreorder
≤-reflexive = IsPreorder.reflexive ≤-isPreorder
≤-trans = IsPreorder.trans ≤-isPreorder
≲-refl : _≈_ ⇒ _≲_
≲-refl (eq [x]≡[y]) = {! !} -- le (≤-reflexive [x]≡[y])
≲-trans : Transitive _≲_
≲-trans [a]≤[b] [b]≤[c] = {! !} -- le (≤-trans [a]≤[b] [b]≤[c])
≲-antisym : Antisymmetric _≈_ _≲_
≲-antisym [x]≤[y] [y]≤[x] = {! !} -- eq (≤-antisym [x]≤[y] [y]≤[x])
≲-isPreorder : IsPreorder _ _
≲-isPreorder = record
{ isEquivalence = Setoid.isEquivalence ≈-Setoid
; reflexive = ≲-refl
; trans = ≲-trans
}
≲-isPartialOrder : IsPartialOrder _ _
≲-isPartialOrder = record
{ isPreorder = ≲-isPreorder
; antisym = ≲-antisym
}
{-
≲-total : Total _≲_
≲-total x y with ≤-total [ x ] [ y ]
≲-total x y | inj₁ [x]≤[y] = inj₁ ? -- (le [x]≤[y])
≲-total x y | inj₂ [y]≤[x] = inj₂ ? -- (le [y]≤[x])
≲-isTotalOrder : IsTotalOrder _ _
≲-isTotalOrder = record
{ isPartialOrder = ≲-isPartialOrder
; total = ≲-total
}
≲-isDecTotalOrder : IsDecTotalOrder _ _
≲-isDecTotalOrder = record
{ isTotalOrder = ≲-isTotalOrder
; _≟_ = _≈?_
; _≤?_ = _≲?_
}
≲-decTotalOrder : DecTotalOrder _ _ _
≲-decTotalOrder = record
{ Carrier = Redundant
; _≈_ = _≈_
; _≤_ = _≲_
; isDecTotalOrder = ≲-isDecTotalOrder
}
a≲a+1 : (a : Redundant) → a ≲ incr one a
a≲a+1 [] = le z≤n
a≲a+1 (x ∷ xs) = le {! !}
<-asym : Asymmetric _<_
<-asym {[]} {[]} (le ()) (le [y]<[[]])
<-asym {[]} {y ∷ ys} (le [x]<[y]) (le [y]<[[]]) = {! !}
<-asym {x ∷ xs} {[]} (le [x]<[y]) (le [y]<[x∷xs]) = {! !}
<-asym {x ∷ xs} {y ∷ ys} (le [x]<[y]) (le [y]<[x∷xs]) = {! !}
<-irr : Irreflexive _≈_ _<_ -- goal: ¬ (x < y)
<-irr {a} {b} (eq [a]≡[b]) (le [a]<[b]) = {! !}
trichotomous : Trichotomous _≈_ _<_
trichotomous x y with x ≈? y
trichotomous x y | yes p = tri≈ {! !} p {! !}
trichotomous x y | no ¬p with incr one x ≲? y
trichotomous x y | no ¬p | yes q = tri< q ¬p {! !}
trichotomous x y | no ¬p | no ¬q = tri> ¬q ¬p {! !}
-}
{-
begin
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
∎
-}
| {
"alphanum_fraction": 0.4740057011,
"avg_line_length": 29.2341269841,
"ext": "agda",
"hexsha": "ffb9c156687a9a457171e4d46bb2dba5e8f56d13",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/Data/Num/Redundant/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "legacy/Data/Num/Redundant/Properties.agda",
"max_line_length": 100,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/Data/Num/Redundant/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 3129,
"size": 7367
} |
-- Andreas, 2018-03-03, issue #2989
-- Internal error, fixable with additional 'reduce'.
-- {-# OPTIONS --show-implicit --show-irrelevant #-}
-- {-# OPTIONS -v tc.rec:70 -v tc:10 #-}
postulate
N : Set
P : N → Set
record Σ (A : Set) (B : A → Set) : Set where
constructor pair
field
fst : A
snd : B fst
Σ' : (A : Set) → (A → Set) → Set
Σ' = Σ
record R : Set where
constructor mkR
field
.p : Σ' N P
f : R → Set
f x = let mkR (pair k p) = x in N
-- WAS:
-- Internal error in Agda.TypeChecking.Records.getRecordTypeFields
-- Error goes away if Σ' is replaced by Σ
-- or field is made relevant
-- SAME Problem:
-- f x = let record { p = pair k p } = x in N
-- f x = let record { p = record { fst = k ; snd = p }} = x in N
| {
"alphanum_fraction": 0.5855614973,
"avg_line_length": 20.7777777778,
"ext": "agda",
"hexsha": "672ca6ab225cc49124243249acc8f26cfd3277cf",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/Issue2989.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/Issue2989.agda",
"max_line_length": 66,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/Issue2989.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 265,
"size": 748
} |
module Derivative where
open import Sets
open import Functor
import Isomorphism
∂ : U -> U
∂ (K A) = K [0]
∂ Id = K [1]
∂ (F + G) = ∂ F + ∂ G
∂ (F × G) = ∂ F × G + F × ∂ G
open Semantics
-- Plugging a hole
plug-∂ : {X : Set}(F : U) -> ⟦ ∂ F ⟧ X -> X -> ⟦ F ⟧ X
plug-∂ (K _) () x
plug-∂ Id <> x = x
plug-∂ (F + G) (inl c) x = inl (plug-∂ F c x)
plug-∂ (F + G) (inr c) x = inr (plug-∂ G c x)
plug-∂ (F × G) (inl < c , g >) x = < plug-∂ F c x , g >
plug-∂ (F × G) (inr < f , c >) x = < f , plug-∂ G c x >
| {
"alphanum_fraction": 0.4097472924,
"avg_line_length": 22.16,
"ext": "agda",
"hexsha": "3159287729235ebbe5a1dc33490e5fdd2c8f6d80",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/clowns/Derivative.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/clowns/Derivative.agda",
"max_line_length": 57,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/clowns/Derivative.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": 285,
"size": 554
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommAlgebra where
open import Cubical.Algebra.CommAlgebra.Base public
open import Cubical.Algebra.CommAlgebra.Properties public
| {
"alphanum_fraction": 0.8171428571,
"avg_line_length": 29.1666666667,
"ext": "agda",
"hexsha": "d150261beb9346de59555b4368514fda9a50b4f9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommAlgebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommAlgebra.agda",
"max_line_length": 57,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommAlgebra.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 39,
"size": 175
} |
-- Andreas, 2012-01-12
module Common.Irrelevance where
open import Common.Level
postulate
.irrAxiom : ∀ {a}{A : Set a} → .A → A
{-# BUILTIN IRRAXIOM irrAxiom #-}
record Squash {a}(A : Set a) : Set a where
constructor squash
field
.unsquash : A
open Squash public
| {
"alphanum_fraction": 0.6714801444,
"avg_line_length": 17.3125,
"ext": "agda",
"hexsha": "ce3712cb82f877d7c137bdc8c0c7da4cf5eeeaf9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "test/Common/Irrelevance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/agda-kanso",
"max_issues_repo_path": "test/Common/Irrelevance.agda",
"max_line_length": 42,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/Common/Irrelevance.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 99,
"size": 277
} |
-- define ∑ and ∏ as the bigOps of a Ring when interpreted
-- as an additive/multiplicative monoid
{-# OPTIONS --safe #-}
module Cubical.Algebra.Ring.BigOps where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Bool
open import Cubical.Data.Nat using (ℕ ; zero ; suc)
open import Cubical.Data.Sigma
open import Cubical.Data.FinData
open import Cubical.Algebra.Monoid.BigOp
open import Cubical.Algebra.Ring.Base
open import Cubical.Algebra.Ring.Properties
private
variable
ℓ ℓ' : Level
module KroneckerDelta (R' : Ring ℓ) where
private
R = fst R'
open RingStr (snd R')
δ : {n : ℕ} (i j : Fin n) → R
δ i j = if i == j then 1r else 0r
module Sum (R' : Ring ℓ) where
private
R = fst R'
open RingStr (snd R')
open MonoidBigOp (Ring→AddMonoid R')
open RingTheory R'
open KroneckerDelta R'
∑ = bigOp
∑Ext = bigOpExt
∑0r = bigOpε
∑Last = bigOpLast
∑Split : ∀ {n} → (V W : FinVec R n) → ∑ (λ i → V i + W i) ≡ ∑ V + ∑ W
∑Split = bigOpSplit +Comm
∑Split++ : ∀ {n m : ℕ} (V : FinVec R n) (W : FinVec R m)
→ ∑ (V ++Fin W) ≡ ∑ V + ∑ W
∑Split++ = bigOpSplit++ +Comm
∑Mulrdist : ∀ {n} → (x : R) → (V : FinVec R n)
→ x · ∑ V ≡ ∑ λ i → x · V i
∑Mulrdist {n = zero} x _ = 0RightAnnihilates x
∑Mulrdist {n = suc n} x V =
x · (V zero + ∑ (V ∘ suc)) ≡⟨ ·DistR+ _ _ _ ⟩
x · V zero + x · ∑ (V ∘ suc) ≡⟨ (λ i → x · V zero + ∑Mulrdist x (V ∘ suc) i) ⟩
x · V zero + ∑ (λ i → x · V (suc i)) ∎
∑Mulldist : ∀ {n} → (x : R) → (V : FinVec R n)
→ (∑ V) · x ≡ ∑ λ i → V i · x
∑Mulldist {n = zero} x _ = 0LeftAnnihilates x
∑Mulldist {n = suc n} x V =
(V zero + ∑ (V ∘ suc)) · x ≡⟨ ·DistL+ _ _ _ ⟩
V zero · x + (∑ (V ∘ suc)) · x ≡⟨ (λ i → V zero · x + ∑Mulldist x (V ∘ suc) i) ⟩
V zero · x + ∑ (λ i → V (suc i) · x) ∎
∑Mulr0 : ∀ {n} → (V : FinVec R n) → ∑ (λ i → V i · 0r) ≡ 0r
∑Mulr0 V = sym (∑Mulldist 0r V) ∙ 0RightAnnihilates _
∑Mul0r : ∀ {n} → (V : FinVec R n) → ∑ (λ i → 0r · V i) ≡ 0r
∑Mul0r V = sym (∑Mulrdist 0r V) ∙ 0LeftAnnihilates _
∑Mulr1 : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → V i · δ i j) ≡ V j
∑Mulr1 (suc n) V zero = (λ k → ·IdR (V zero) k + ∑Mulr0 (V ∘ suc) k) ∙ +IdR (V zero)
∑Mulr1 (suc n) V (suc j) =
(λ i → 0RightAnnihilates (V zero) i + ∑ (λ x → V (suc x) · δ x j))
∙∙ +IdL _ ∙∙ ∑Mulr1 n (V ∘ suc) j
∑Mul1r : (n : ℕ) (V : FinVec R n) → (j : Fin n) → ∑ (λ i → (δ j i) · V i) ≡ V j
∑Mul1r (suc n) V zero = (λ k → ·IdL (V zero) k + ∑Mul0r (V ∘ suc) k) ∙ +IdR (V zero)
∑Mul1r (suc n) V (suc j) =
(λ i → 0LeftAnnihilates (V zero) i + ∑ (λ i → (δ j i) · V (suc i)))
∙∙ +IdL _ ∙∙ ∑Mul1r n (V ∘ suc) j
∑Dist- : ∀ {n : ℕ} (V : FinVec R n) → ∑ (λ i → - V i) ≡ - ∑ V
∑Dist- V = ∑Ext (λ i → -IsMult-1 (V i)) ∙ sym (∑Mulrdist _ V) ∙ sym (-IsMult-1 _)
module SumMap
(Ar@(A , Astr) : Ring ℓ)
(Br@(B , Bstr) : Ring ℓ')
(f'@(f , fstr) : RingHom Ar Br)
where
open IsRingHom fstr
open RingStr Astr using ()
renaming
( _+_ to _+A_ )
open RingStr Bstr using ()
renaming
( _+_ to _+B_ )
∑Map : {n : ℕ} → (V : FinVec A n) → f (Sum.∑ Ar V) ≡ Sum.∑ Br (λ k → f (V k))
∑Map {n = zero} V = pres0
∑Map {n = suc n} V =
f ((V zero) +A helper) ≡⟨ pres+ (V zero) helper ⟩
((f (V zero)) +B (f helper)) ≡⟨ cong (λ X → f (V zero) +B X) (∑Map (λ k → (V ∘ suc) k)) ⟩
Sum.∑ Br (λ k → f (V k)) ∎
where
helper : _
helper = foldrFin _+A_ (RingStr.0r (snd Ar)) (λ x → V (suc x))
-- anything interesting to prove here?
module Product (R' : Ring ℓ) where
private
R = fst R'
open RingStr (snd R')
open RingTheory R'
open MonoidBigOp (Ring→MultMonoid R')
∏ = bigOp
∏Ext = bigOpExt
∏0r = bigOpε
∏Last = bigOpLast
-- only holds in CommRings!
-- ∏Split : ∀ {n} → (V W : FinVec R n) → ∏ (λ i → V i · W i) ≡ ∏ V · ∏ W
-- ∏Split = bigOpSplit MultR' ·-comm
| {
"alphanum_fraction": 0.5108128262,
"avg_line_length": 30.4772727273,
"ext": "agda",
"hexsha": "d9526ea343e1e14a5b5fdaad368cbfa48cb84b89",
"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/Ring/BigOps.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/Ring/BigOps.agda",
"max_line_length": 112,
"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/Ring/BigOps.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1770,
"size": 4023
} |
module UpTo where
open import Level
open import Relation.Binary using (Rel; IsEquivalence)
open import Data.Product
open import Categories.Support.Equivalence
open import Categories.Category
open import Categories.2-Category
open import Categories.Functor
open import Categories.NaturalTransformation
renaming (id to natId; _≡_ to _≡N_; setoid to natSetoid)
hiding (_∘ˡ_; _∘ʳ_)
open import Categories.Support.EqReasoning
open import NaturalTransFacts
Cat₀ = Category zero zero zero
EndoFunctor : Cat₀ → Set zero
EndoFunctor C = Functor C C
record Endo⇒ (C₁ : Cat₀) (F₁ : EndoFunctor C₁)
(C₂ : Cat₀) (F₂ : EndoFunctor C₂)
: Set zero where
field
T : Functor C₁ C₂
ρ : NaturalTransformation (T ∘ F₁) (F₂ ∘ T)
record UpTo⇒ {C₁ : Cat₀} {F : EndoFunctor C₁}
{C₂ : Cat₀} {G : EndoFunctor C₂}
(S₁ S₂ : Endo⇒ C₁ F C₂ G)
: Set zero where
module S₁ = Endo⇒ S₁
module S₂ = Endo⇒ S₂
field
γ : NaturalTransformation S₁.T S₂.T
-- The following diagram must commute
-- T₁F - ρ₁ -> GT₁
-- | |
-- γF Gγ
-- | |
-- v v
-- T₂G - ρ₂ -> GT₂
.square : S₂.ρ ∘₁ (γ ∘ʳ F) ≡N (G ∘ˡ γ) ∘₁ S₁.ρ
record _≡U_ {C₁ : Cat₀} {C₂ : Cat₀}
{F : EndoFunctor C₁} {G : EndoFunctor C₂}
{T₁ T₂ : Endo⇒ C₁ F C₂ G}
(A : UpTo⇒ T₁ T₂) (B : UpTo⇒ T₁ T₂) : Set where
field
≡U-proof : UpTo⇒.γ A ≡N UpTo⇒.γ B
open _≡U_
infix 4 _≡U_
.≡U-equiv : {C₁ : Cat₀} {C₂ : Cat₀}
{F : EndoFunctor C₁} {G : EndoFunctor C₂} →
{A B : Endo⇒ C₁ F C₂ G} →
IsEquivalence {A = UpTo⇒ A B} (_≡U_ {C₁} {C₂} {F} {G})
≡U-equiv =
record
{ refl = λ {A} → record { ≡U-proof = Setoid.refl natSetoid {UpTo⇒.γ A} }
; sym = λ {A} {B} p → record {
≡U-proof = Setoid.sym natSetoid {UpTo⇒.γ A} {UpTo⇒.γ B} (≡U-proof p) }
; trans = λ {A} {B} {C} p₁ p₂ → record {
≡U-proof = Setoid.trans natSetoid {UpTo⇒.γ A} {UpTo⇒.γ B} {UpTo⇒.γ C}
(≡U-proof p₁) (≡U-proof p₂) }
}
id-UpTo⇒ : {C₁ : Cat₀} {F : EndoFunctor C₁}
{C₂ : Cat₀} {G : EndoFunctor C₂}
{A : Endo⇒ C₁ F C₂ G} → UpTo⇒ A A
id-UpTo⇒ {C₁} {F} {C₂} {G} {A} =
record
{ γ = natId
; square =
begin
Endo⇒.ρ A ∘₁ (natId {F = Endo⇒.T A} ∘ʳ F)
↓⟨ ∘₁-resp-≡
{f = Endo⇒.ρ A} {h = Endo⇒.ρ A}
{g = natId {F = Endo⇒.T A} ∘ʳ F}
{i = natId {F = Endo⇒.T A ∘ F}}
(Setoid.refl natSetoid {Endo⇒.ρ A})
(identityNatʳ {F = Endo⇒.T A} F)
⟩
Endo⇒.ρ A ∘₁ (natId {F = Endo⇒.T A ∘ F})
↓⟨ identity₁ʳ {X = Endo⇒.ρ A} ⟩
Endo⇒.ρ A
↑⟨ identity₁ˡ {X = Endo⇒.ρ A} ⟩
natId {F = G ∘ Endo⇒.T A} ∘₁ Endo⇒.ρ A
↑⟨ ∘₁-resp-≡
{f = G ∘ˡ natId {F = Endo⇒.T A}}
{h = natId {F = G ∘ Endo⇒.T A}}
{g = Endo⇒.ρ A} {i = Endo⇒.ρ A}
(identityNatˡ {F = Endo⇒.T A} G)
(Setoid.refl natSetoid {Endo⇒.ρ A})
⟩
(G ∘ˡ natId {F = Endo⇒.T A}) ∘₁ Endo⇒.ρ A
∎
}
where
open SetoidReasoning (natSetoid {F = Endo⇒.T A ∘ F} {G ∘ Endo⇒.T A})
_•_ : {C₁ : Cat₀} {F : EndoFunctor C₁}
{C₂ : Cat₀} {G : EndoFunctor C₂}
{A B C : Endo⇒ C₁ F C₂ G} →
UpTo⇒ B C → UpTo⇒ A B → UpTo⇒ A C
_•_ {F = F} {G = G} {A = A} {B} {C} g f =
record
{ γ = γ ∘₁ φ
; square =
-- AF - A.ρ -> GA
-- | |
-- φF Gφ
-- | |
-- v v
-- BF - B.ρ -> GB
-- | |
-- γF Gγ
-- | |
-- v v
-- CF - C.ρ -> GC
begin
C.ρ ∘₁ ((γ ∘₁ φ) ∘ʳ F)
↓⟨ ∘₁-resp-≡ʳ
{f = C.ρ} {(γ ∘₁ φ) ∘ʳ F} {(γ ∘ʳ F) ∘₁ (φ ∘ʳ F)}
(∘ʳ-distr-∘₁ γ φ F)
⟩
C.ρ ∘₁ ((γ ∘ʳ F) ∘₁ (φ ∘ʳ F))
↑⟨ assoc₁ {X = (φ ∘ʳ F)} {(γ ∘ʳ F)} {C.ρ} ⟩
(C.ρ ∘₁ (γ ∘ʳ F)) ∘₁ (φ ∘ʳ F)
↓⟨ ∘₁-resp-≡ˡ
{f = C.ρ ∘₁ (γ ∘ʳ F)} {G ∘ˡ γ ∘₁ B.ρ} {φ ∘ʳ F}
(UpTo⇒.square g)
⟩
(G ∘ˡ γ ∘₁ B.ρ) ∘₁ (φ ∘ʳ F)
↓⟨ assoc₁ {X = (φ ∘ʳ F)} {B.ρ} {G ∘ˡ γ} ⟩
(G ∘ˡ γ) ∘₁ (B.ρ ∘₁ (φ ∘ʳ F))
↓⟨ ∘₁-resp-≡ʳ
{f = G ∘ˡ γ} {B.ρ ∘₁ (φ ∘ʳ F)} {(G ∘ˡ φ) ∘₁ A.ρ}
(UpTo⇒.square f)
⟩
(G ∘ˡ γ) ∘₁ ((G ∘ˡ φ) ∘₁ A.ρ)
↑⟨ assoc₁ {X = A.ρ} {G ∘ˡ φ} {G ∘ˡ γ} ⟩
((G ∘ˡ γ) ∘₁ (G ∘ˡ φ)) ∘₁ A.ρ
↑⟨ ∘₁-resp-≡ˡ
{f = G ∘ˡ (γ ∘₁ φ)} {(G ∘ˡ γ) ∘₁ (G ∘ˡ φ)} {A.ρ}
(∘ˡ-distr-∘₁ G γ φ)
⟩
(G ∘ˡ (γ ∘₁ φ)) ∘₁ A.ρ
∎
}
where
module A = Endo⇒ A
module B = Endo⇒ B
module C = Endo⇒ C
open SetoidReasoning (natSetoid {F = A.T ∘ F} {G ∘ C.T})
φ : A.T ⇒ B.T
φ = UpTo⇒.γ f
γ : B.T ⇒ C.T
γ = UpTo⇒.γ g
-- | Category of morphisms between endofunctors, where the morphisms
-- are certain natural transformations (see UpTo⇒).
-- This category will be the the setting in which we can talk about
-- properties of up-to techniques.
EndoMor : Σ Cat₀ (λ C → Functor C C) →
Σ Cat₀ (λ C → Functor C C) →
Cat₀
EndoMor (C₁ , F) (C₂ , G) =
record
{ Obj = Endo⇒ C₁ F C₂ G
; _⇒_ = UpTo⇒
; _≡_ = _≡U_
; id = id-UpTo⇒
; _∘_ = _•_
; assoc = λ {_} {_} {_} {_} {f} {g} {h} →
record { ≡U-proof = assoc₁ {X = UpTo⇒.γ f} {UpTo⇒.γ g} {UpTo⇒.γ h} }
; identityˡ = λ {_} {_} {f} →
record { ≡U-proof = identity₁ˡ {X = UpTo⇒.γ f} }
; identityʳ = λ {_} {_} {f} →
record { ≡U-proof = identity₁ʳ {X = UpTo⇒.γ f} }
; equiv = ≡U-equiv
; ∘-resp-≡ = λ {_} {_} {_} {f} {h} {g} {i} f≡h g≡i → record {
≡U-proof = ∘₁-resp-≡ {f = UpTo⇒.γ f} {UpTo⇒.γ h}
{UpTo⇒.γ g} {UpTo⇒.γ i}
(≡U-proof f≡h) (≡U-proof g≡i) }
}
-- | The 2-category of endofunctors, their morphisms and UpTo⇒ as 2-cells.
-- This is the 2-category of endofunctors defined by Lenisa, Power and Watanabe.
{-
Endo : 2-Category (suc zero) zero zero zero
Endo = record
{ Obj = Σ Cat₀ (λ C → Functor C C)
; _⇒_ = EndoMor
; id = record
{ F₀ = λ _ → record { T = id ; ρ = natId }
; F₁ = λ _ → id-UpTo⇒
; identity = IsEquivalence.refl ≡U-equiv
; homomorphism = λ {_} {_} {_} {_} {F} → {!!}
; F-resp-≡ = {!!}
}
; —∘— = {!!}
; assoc = {!!}
; identityˡ = {!!}
; identityʳ = {!!}
}
-}
| {
"alphanum_fraction": 0.4430863254,
"avg_line_length": 31.1666666667,
"ext": "agda",
"hexsha": "a81d3601a3a0343d5279799a141cf3c6fd47fd94",
"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": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "UpTo-Properties/UpTo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"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": "hbasold/Sandbox",
"max_issues_repo_path": "UpTo-Properties/UpTo.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "UpTo-Properties/UpTo.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3028,
"size": 6545
} |
open import Oscar.Prelude
open import Oscar.Class.IsDecidable
open import Oscar.Data.Fin
open import Oscar.Data.Decidable
open import Oscar.Data.Proposequality
module Oscar.Class.IsDecidable.Fin where
instance
IsDecidableFin : ∀ {n} → IsDecidable (Fin n)
IsDecidableFin .IsDecidable._≟_ ∅ ∅ = ↑ ∅
IsDecidableFin .IsDecidable._≟_ ∅ (↑ _) = ↓ λ ()
IsDecidableFin .IsDecidable._≟_ (↑ _) ∅ = ↓ λ ()
IsDecidableFin .IsDecidable._≟_ (↑ x) (↑ y) with x ≟ y
… | ↑ ∅ = ↑ ∅
… | ↓ x≢y = ↓ λ {∅ → x≢y ∅}
| {
"alphanum_fraction": 0.6549019608,
"avg_line_length": 26.8421052632,
"ext": "agda",
"hexsha": "e611d3e046f20abbb37fdde5f2ed96c230276329",
"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/IsDecidable/Fin.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/IsDecidable/Fin.agda",
"max_line_length": 56,
"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/IsDecidable/Fin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 193,
"size": 510
} |
------------------------------------------------------------------------------
-- Even predicate
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Even where
open import FOTC.Base
open import FOTC.Data.Nat.Type
------------------------------------------------------------------------------
data Even : D → Set where
ezero : Even zero
enext : ∀ {n} → Even n → Even (succ₁ (succ₁ n))
Even-ind : (A : D → Set) →
A zero →
(∀ {n} → A n → A (succ₁ (succ₁ n))) →
∀ {n} → Even n → A n
Even-ind A A0 h ezero = A0
Even-ind A A0 h (enext En) = h (Even-ind A A0 h En)
Even→N : ∀ {n} → Even n → N n
Even→N ezero = nzero
Even→N (enext En) = nsucc (nsucc (Even→N En))
| {
"alphanum_fraction": 0.3820704376,
"avg_line_length": 30.2258064516,
"ext": "agda",
"hexsha": "1c10510d44e0775ad2a859ad05a6d61731b10add",
"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/thesis/report/FOTC/Even.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/thesis/report/FOTC/Even.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/thesis/report/FOTC/Even.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": 234,
"size": 937
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.LawvereTheories where
-- Category of Lawvere Theories
open import Level
open import Categories.Category.Core using (Category)
open import Categories.Functor.Cartesian using (CartesianF)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (_≃_; associator; sym-associator; unitorˡ; unitorʳ; unitor²; refl; sym; trans; _ⓘₕ_)
open import Categories.Theory.Lawvere using (LawvereTheory; LT-Hom; LT-id; LT-∘)
LawvereTheories : (ℓ e : Level) → Category (suc (ℓ ⊔ e)) (ℓ ⊔ e) (ℓ ⊔ e)
LawvereTheories ℓ e = record
{ Obj = LawvereTheory ℓ e
; _⇒_ = LT-Hom
; _≈_ = λ H₁ H₂ → cartF.F H₁ ≃ cartF.F H₂
; id = LT-id
; _∘_ = LT-∘
; assoc = λ { {f = f} {g} {h} → associator (cartF.F f) (cartF.F g) (cartF.F h) }
; sym-assoc = λ { {f = f} {g} {h} → sym-associator (cartF.F f) (cartF.F g) (cartF.F h) }
; identityˡ = unitorˡ
; identityʳ = unitorʳ
; identity² = unitor²
; equiv = record { refl = refl ; sym = sym ; trans = trans }
; ∘-resp-≈ = _ⓘₕ_
}
where open LT-Hom
| {
"alphanum_fraction": 0.6585820896,
"avg_line_length": 35.7333333333,
"ext": "agda",
"hexsha": "483337ef5c464b698d715bdd7fcdab40c577bfed",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda",
"max_line_length": 91,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/LawvereTheories.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": 403,
"size": 1072
} |
module Oscar.Data.Maybe where
open import Data.Maybe public using (Maybe; nothing; just)
-- open import Oscar.Data.Maybe.Core public
-- --open import Data.Maybe public using (maybe)
-- -- open import Relation.Binary.PropositionalEquality
-- -- open import Data.Empty
-- -- unMaybe : ∀ {A : Set} {x y : A} {B : Set} {m : Maybe B} → maybe (λ _ → x) y m ≡ y → x ≢ y → m ≡ nothing
-- -- unMaybe {m = just x₁} x₂ x₃ = ⊥-elim (x₃ x₂)
-- -- unMaybe {m = nothing} x₁ x₂ = refl
-- -- unMaybe' : ∀ {A : Set} {y : A} {B : Set} {x : B → A} {m : Maybe B} → maybe (λ b → x b) y m ≡ y → (∀ b → x b ≢ y) → m ≡ nothing
-- -- unMaybe' {m = just x₁} x₂ x₃ = ⊥-elim (x₃ x₁ x₂)
-- -- unMaybe' {m = nothing} x₁ x₂ = refl
-- -- just≢nothing : ∀ {A B : Set} → (x : B → A) → ∀ b → Maybe.just (x b) ≢ nothing
-- -- just≢nothing x b ()
-- -- unMaybeJust' : ∀ {A B : Set} {P : B → A} {m : Maybe B} {n : A} {x : B} → maybe (λ b → P b) n m ≡ P x → (∀ b → P b ≢ n) → (∀ {y y'} → P y ≡ P y' → y ≡ y') → m ≡ just x
-- -- unMaybeJust' {m = just x} x₂ x₃ inj rewrite inj x₂ = refl
-- -- unMaybeJust' {m = nothing} x₁ x₂ _ = ⊥-elim (x₂ _ (sym x₁))
| {
"alphanum_fraction": 0.5254237288,
"avg_line_length": 41.5185185185,
"ext": "agda",
"hexsha": "6f298e69a2760d9bbe17790a895f75ea87cd48ba",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Data/Maybe.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Data/Maybe.agda",
"max_line_length": 172,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Data/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 459,
"size": 1121
} |
{-# OPTIONS --rewriting #-}
module CF.Transform.Compile.ToJVM.Rewriting where
open import Data.List.Properties
open import Data.List.Relation.Binary.Permutation.Propositional
open import Agda.Builtin.Equality.Rewrite
{-# REWRITE map-++-commute #-}
| {
"alphanum_fraction": 0.7777777778,
"avg_line_length": 22.9090909091,
"ext": "agda",
"hexsha": "5a8b70fca07cc98c4cc8796951125d4632aee751",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ajrouvoet/jvm.agda",
"max_forks_repo_path": "src/CF/Transform/Compile/ToJVM/Rewriting.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"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": "ajrouvoet/jvm.agda",
"max_issues_repo_path": "src/CF/Transform/Compile/ToJVM/Rewriting.agda",
"max_line_length": 63,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ajrouvoet/jvm.agda",
"max_stars_repo_path": "src/CF/Transform/Compile/ToJVM/Rewriting.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z",
"num_tokens": 60,
"size": 252
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.RawRing where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Sigma
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Algebra.RingSolver.AlmostRing hiding (⟨_⟩)
private
variable
ℓ : Level
record RawRing : Type (ℓ-suc ℓ) where
constructor rawring
field
Carrier : Type ℓ
0r : Carrier
1r : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
infixl 8 _·_
infixl 7 -_
infixl 6 _+_
⟨_⟩ : RawRing → Type ℓ
⟨_⟩ = RawRing.Carrier
AlmostRing→RawRing : AlmostRing {ℓ} → RawRing {ℓ}
AlmostRing→RawRing (almostring Carrier 0r 1r _+_ _·_ -_ isAlmostRing) =
rawring Carrier 0r 1r _+_ _·_ -_
| {
"alphanum_fraction": 0.6598062954,
"avg_line_length": 22.9444444444,
"ext": "agda",
"hexsha": "c5377cf237faa5689a72495ec211827055529fe5",
"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/Algebra/RingSolver/RawRing.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/Algebra/RingSolver/RawRing.agda",
"max_line_length": 71,
"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/Algebra/RingSolver/RawRing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 273,
"size": 826
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Finite.Fin.Construction.Poset where
open import Data.Nat using (ℕ; z≤n; s≤s)
open import Data.Sum
open import Data.Product using (Σ; _,_; _×_)
open import Data.Fin
open import Data.Fin.Patterns
open import Relation.Binary.PropositionalEquality as ≡
open import Categories.Category.Finite.Fin
open import Categories.Category
private
card : ∀ {n} → Fin n → Fin n → ℕ
card {ℕ.suc n} zero y = 1
card {ℕ.suc n} (suc x) zero = 0
card {ℕ.suc n} (suc x) (suc y) = card x y
id : ∀ n {a : Fin n} → Fin (card a a)
id .(ℕ.suc _) {zero} = 0F
id (ℕ.suc n) {suc a} = id n
comp : ∀ n {a b c : Fin n} → Fin (card b c) → Fin (card a b) → Fin (card a c)
comp (ℕ.suc n) {0F} {b} {c} f g = 0F
comp (ℕ.suc n) {suc a} {suc b} {suc c} f g = comp n f g
assoc : ∀ n {a b c d : Fin n} {f : Fin (card a b)} {g : Fin (card b c)} {h : Fin (card c d)} →
comp n (comp n h g) f ≡ comp n h (comp n g f)
assoc (ℕ.suc n) {0F} {b} {c} {d} {f} {g} {h} = refl
assoc (ℕ.suc n) {suc a} {suc b} {suc c} {suc d} {f} {g} {h} = assoc n
identityˡ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n (id n) f ≡ f
identityˡ (ℕ.suc n) {0F} {b} {0F} = refl
identityˡ (ℕ.suc n) {suc a} {suc b} {f} = identityˡ n
identityʳ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n f (id n) ≡ f
identityʳ (ℕ.suc n) {0F} {b} {0F} = refl
identityʳ (ℕ.suc n) {suc a} {suc b} {f} = identityʳ n
card-rel : ∀ {n} (x y : Fin n) → card x y ≡ 1 × x ≤ y ⊎ card x y ≡ 0 × y < x
card-rel {ℕ.suc n} 0F y = inj₁ (refl , z≤n)
card-rel {ℕ.suc n} (suc x) 0F = inj₂ (refl , s≤s z≤n)
card-rel {ℕ.suc n} (suc x) (suc y) with card-rel x y
... | inj₁ (eq , x≤y) = inj₁ (eq , s≤s x≤y)
... | inj₂ (eq , y<x) = inj₂ (eq , s≤s y<x)
card-sound₁ : ∀ {n} (x y : Fin n) → card x y ≡ 1 → x ≤ y
card-sound₁ 0F 0F eq = z≤n
card-sound₁ 0F (suc y) eq = z≤n
card-sound₁ (suc x) (suc y) eq = s≤s (card-sound₁ x y eq)
card-sound₂ : ∀ {n} (x y : Fin n) → card x y ≡ 0 → y ≤ x
card-sound₂ (suc x) 0F eq = z≤n
card-sound₂ (suc x) (suc y) eq = s≤s (card-sound₂ x y eq)
card-complete₁ : ∀ {n} {x y : Fin n} → x ≤ y → card x y ≡ 1
card-complete₁ {.(ℕ.suc _)} {0F} {0F} x≤y = refl
card-complete₁ {.(ℕ.suc _)} {0F} {suc y} x≤y = refl
card-complete₁ {.(ℕ.suc _)} {suc x} {suc y} (s≤s x≤y) = card-complete₁ x≤y
card-complete₂ : ∀ {n} {x y : Fin n} → y < x → card x y ≡ 0
card-complete₂ {.(ℕ.suc _)} {suc x} {0F} y<x = refl
card-complete₂ {.(ℕ.suc _)} {suc x} {suc y} (s≤s y<x) = card-complete₂ y<x
module _ (size : ℕ) where
PosetShape : FinCatShape
PosetShape = record
{ size = size
; ∣_⇒_∣ = card
; hasShape = record
{ id = id size
; _∘_ = comp size
; assoc = assoc size
; identityˡ = identityˡ size
; identityʳ = identityʳ size
}
}
Poset : ℕ → Category _ _ _
Poset size = FinCategory (PosetShape size)
module Poset size = Category (Poset size)
| {
"alphanum_fraction": 0.535866361,
"avg_line_length": 35.091954023,
"ext": "agda",
"hexsha": "c21ee8c4becdaf26b9c012e1f45531b5ce22d922",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Finite/Fin/Construction/Poset.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Finite/Fin/Construction/Poset.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Finite/Fin/Construction/Poset.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1347,
"size": 3053
} |
-- Andreas, 2017-01-05, issue #2376
-- Ensure correct printing for termination error
-- {-# OPTIONS -v term.clause:30 #-}
postulate
id : ∀{a}{A : Set a} → A → A
A : Set
P : A → Set
f : {a : A} → P a → {b : A} → P b → Set
f = λ p → f (id p) -- id to prevent eta-contration before termination checking
-- Expected termination error:
-- ...
-- Problematic calls:
-- f (id p)
| {
"alphanum_fraction": 0.5818181818,
"avg_line_length": 21.3888888889,
"ext": "agda",
"hexsha": "90efa55186abdfb221c8f0c3c99508ee21e9bef1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2376Lambda.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue2376Lambda.agda",
"max_line_length": 79,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2376Lambda.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": 132,
"size": 385
} |
{-# OPTIONS --cubical --safe #-}
module Algebra.Construct.Free.Semilattice.Relation.Unary.Any.Properties where
open import Prelude hiding (⊥; ⊤)
open import Algebra.Construct.Free.Semilattice.Eliminators
open import Algebra.Construct.Free.Semilattice.Definition
open import Cubical.Foundations.HLevels
open import Data.Empty.UniversePolymorphic
open import HITs.PropositionalTruncation.Sugar
open import HITs.PropositionalTruncation.Properties
open import HITs.PropositionalTruncation
open import Data.Unit.UniversePolymorphic
open import Algebra.Construct.Free.Semilattice.Relation.Unary.Any.Def
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Decidable.Properties
open import Relation.Nullary.Decidable.Logic
private
variable p : Level
P∃◇ : ∀ {p} {P : A → Type p} → ∀ xs → ◇ P xs → ∥ ∃ P ∥
P∃◇ {A = A} {P = P} = ∥ P∃◇′ ∥⇓
where
P∃◇′ : xs ∈𝒦 A ⇒∥ (◇ P xs → ∥ ∃ P ∥) ∥
∥ P∃◇′ ∥-prop p q i ◇Pxs = squash (p ◇Pxs) (q ◇Pxs) i
∥ P∃◇′ ∥[] ()
∥ P∃◇′ ∥ x ∷ xs ⟨ Pxs ⟩ ◇Pxs =
◇Pxs >>=
either′
(λ Px → ∣ x , Px ∣ )
(λ ◇Pxxs → Pxs ◇Pxxs)
| {
"alphanum_fraction": 0.6875,
"avg_line_length": 32.9411764706,
"ext": "agda",
"hexsha": "bac9ba89dde59b31cb66b098ce3d33427306d827",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Properties.agda",
"max_line_length": 77,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 408,
"size": 1120
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Structures.NAryOp where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Nat
open import Cubical.Data.Vec
open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)
private
variable
ℓ ℓ' : Level
-- TODO: generalize to different target type?
nAryFunStructure : (n : ℕ) → Type (ℓ-max (ℓ-suc ℓ) (nAryLevel ℓ ℓ n))
nAryFunStructure {ℓ = ℓ} n = TypeWithStr _ (λ (X : Type ℓ) → nAryOp n X X)
-- iso for n-ary functions
nAryFunIso : (n : ℕ) → StrIso (λ (X : Type ℓ) → nAryOp n X X) ℓ
nAryFunIso n (X , fX) (Y , fY) f =
(xs : Vec X n) → equivFun f (fX $ⁿ xs) ≡ fY $ⁿ map (equivFun f) xs
nAryFunSNS : (n : ℕ) → SNS {ℓ} _ (nAryFunIso n)
nAryFunSNS n = SNS-≡→SNS-PathP (nAryFunIso n) (nAryFunExtEquiv n)
-- Some specializations that are not used at the moment, but kept as
-- they might become useful later.
private
-- unary
unaryFunIso : StrIso (λ (X : Type ℓ) → nAryOp 1 X X) ℓ
unaryFunIso (A , f) (B , g) e =
(x : A) → equivFun e (f x) ≡ g (equivFun e x)
unaryFunSNS : SNS {ℓ} _ unaryFunIso
unaryFunSNS = SNS-≡→SNS-PathP unaryFunIso (λ s t → compEquiv lem (nAryFunExtEquiv 1 s t))
where
lem : ∀ {X} → {s t : X → X} →
((x : X) → s x ≡ t x) ≃
((xs : Vec X 1) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))
lem {X} {s} {t} = isoToEquiv f
where
f : Iso ((x : X) → s x ≡ t x)
((xs : Vec X 1) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))
Iso.fun f p (x ∷ []) = p x
Iso.inv f p x = p (x ∷ [])
Iso.rightInv f p _ xs@(x ∷ []) = p xs
Iso.leftInv f p _ = p
-- binary
binaryFunIso : StrIso (λ (X : Type ℓ) → nAryOp 2 X X) ℓ
binaryFunIso (A , f) (B , g) e =
(x y : A) → equivFun e (f x y) ≡ g (equivFun e x) (equivFun e y)
binaryFunSNS : SNS {ℓ} _ binaryFunIso
binaryFunSNS = SNS-≡→SNS-PathP binaryFunIso (λ s t → compEquiv lem (nAryFunExtEquiv 2 s t))
where
lem : ∀ {X} → {s t : X → X → X} →
((x y : X) → s x y ≡ t x y) ≃
((xs : Vec X 2) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))
lem {X} {s} {t} = isoToEquiv f
where
f : Iso ((x y : X) → s x y ≡ t x y)
((xs : Vec X 2) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))
Iso.fun f p (x ∷ y ∷ []) = p x y
Iso.inv f p x y = p (x ∷ y ∷ [])
Iso.rightInv f p _ xs@(x ∷ y ∷ []) = p xs
Iso.leftInv f p _ = p
| {
"alphanum_fraction": 0.5336150595,
"avg_line_length": 35.1756756757,
"ext": "agda",
"hexsha": "aaf38af83e21d72252e41d58aa802511e34e0ee1",
"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": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmester0/cubical",
"max_forks_repo_path": "Cubical/Structures/NAryOp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"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": "cmester0/cubical",
"max_issues_repo_path": "Cubical/Structures/NAryOp.agda",
"max_line_length": 93,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmester0/cubical",
"max_stars_repo_path": "Cubical/Structures/NAryOp.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z",
"num_tokens": 1071,
"size": 2603
} |
{-# OPTIONS --safe #-}
module STLC.Denotational where
open import STLC.Syntax
open import STLC.Typing
open import Data.Nat using (ℕ; suc)
open import Data.Fin using (Fin) renaming (zero to fzero; suc to fsuc)
open import Data.Product using (_×_; _,_; proj₁; proj₂)
open import Data.Unit using (⊤; tt)
private
variable
n : ℕ
Γ : Ctx n
A : Type
⟦_⟧ : Type → Set
⟦ A ⇒ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧
⟦ unit ⟧ = ⊤
⟦ A ×' B ⟧ = ⟦ A ⟧ × ⟦ B ⟧
data Env : Ctx n → Set where
∅ : Env ●
⟨_,_⟩ : Env Γ → ⟦ A ⟧ → Env (Γ ,- A)
lookup : Env {n} Γ → (v : Fin n) → ⟦ find Γ v ⟧
lookup ⟨ ρ , term ⟩ fzero = term
lookup ⟨ ρ , term ⟩ (fsuc n) = lookup ρ n
⟦_⟧⟨_⟩ : ∀ {term : Term n} {type : Type} → (Γ ⊢ term ∈ type) → Env Γ → ⟦ type ⟧
⟦ ty-abs body ⟧⟨ ρ ⟩ = λ x → ⟦ body ⟧⟨ ⟨ ρ , x ⟩ ⟩
⟦ ty-app f x ⟧⟨ ρ ⟩ = ⟦ f ⟧⟨ ρ ⟩ ⟦ x ⟧⟨ ρ ⟩
⟦ ty-var v ⟧⟨ ρ ⟩ = lookup ρ v
⟦ ty-⋆ ⟧⟨ _ ⟩ = tt
⟦ ty-pair l r ⟧⟨ ρ ⟩ = ⟦ l ⟧⟨ ρ ⟩ , ⟦ r ⟧⟨ ρ ⟩
⟦ ty-projₗ p ⟧⟨ ρ ⟩ = proj₁ ⟦ p ⟧⟨ ρ ⟩
⟦ ty-projᵣ p ⟧⟨ ρ ⟩ = proj₂ ⟦ p ⟧⟨ ρ ⟩
| {
"alphanum_fraction": 0.5005005005,
"avg_line_length": 26.2894736842,
"ext": "agda",
"hexsha": "817839b92ff66406a26a0751abe5fe8260ce5bb1",
"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": "59bc9648f326b7359801fb31ff6f957a166876fc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "TrulyNonstrict/STLC",
"max_forks_repo_path": "STLC/Denotational.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc",
"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": "TrulyNonstrict/STLC",
"max_issues_repo_path": "STLC/Denotational.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TypesLogicsCats/STLC",
"max_stars_repo_path": "STLC/Denotational.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-16T23:53:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-16T23:53:48.000Z",
"num_tokens": 518,
"size": 999
} |
module Types.Tail1 where
open import Data.Fin
open import Data.Nat
open import Function using (_∘_)
open import Types.Direction
import Types.IND1 as IND
private
variable
n : ℕ
-- session types restricted to tail recursion
-- can be recognized by type of TChan constructor
data Type : Set
data SType (n : ℕ) : Set
data GType (n : ℕ) : Set
data Type where
TUnit TInt : Type
TPair : (t₁ t₂ : Type) → Type
TChan : (s : IND.SType 0) → Type
data SType n where
gdd : (g : GType n) → SType n
rec : (g : GType (suc n)) → SType n
var : (x : Fin n) → SType n
data GType n where
transmit : (d : Dir) (t : Type) (s : SType n) → GType n
choice : (d : Dir) (m : ℕ) (alt : Fin m → SType n) → GType n
end : GType n
-- naive definition of duality for tail recursive session types
-- message types are ignored as they are closed
dualS : SType n → SType n
dualG : GType n → GType n
dualS (gdd g) = gdd (dualG g)
dualS (rec g) = rec (dualG g)
dualS (var x) = var x
dualG (transmit d t s) = transmit (dual-dir d) t (dualS s)
dualG (choice d m alt) = choice (dual-dir d) m (dualS ∘ alt)
dualG end = end
| {
"alphanum_fraction": 0.6523297491,
"avg_line_length": 22.7755102041,
"ext": "agda",
"hexsha": "4a52f6dbb766b93c52da45e147f606debea3cbde",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-07T16:12:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-07T16:12:50.000Z",
"max_forks_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "peterthiemann/dual-session",
"max_forks_repo_path": "src/Types/Tail1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "peterthiemann/dual-session",
"max_issues_repo_path": "src/Types/Tail1.agda",
"max_line_length": 63,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "peterthiemann/dual-session",
"max_stars_repo_path": "src/Types/Tail1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:43:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-13T05:43:25.000Z",
"num_tokens": 406,
"size": 1116
} |
-- A Beth model of normal forms
open import Library hiding (_∈_; All)
module NfModel (Base : Set) where
import Formulas ; open module Form = Formulas Base
import Derivations; open module Der = Derivations Base
-- Beth model
-- A cover for Γ is the skeleton of a case tree that can be formed in Γ.
-- It contains the (neutral) scrutinees we case over and the markers (hole)
-- for the leaves that have to be filled by the branches of the case statement.
data Cover (Γ : Cxt) : Set where
hole : Cover Γ
falseC : (t : Ne Γ False) → Cover Γ
orC : ∀{A B} (t : Ne Γ (A ∨ B)) (c : Cover (Γ ∙ A)) (d : Cover (Γ ∙ B)) → Cover Γ
-- Choice of names.
-- hole : has the same role as the hole-evaluation context (identity).
-- falseC: basically falseE.
-- orC : basically orE.
-- Given c : Cover Γ, a path p : Δ ∈ c leads us from the root to one of the leaves (hole)
-- of the case tree. Δ is the context at the leaf.
data _∈_ Δ : ({Γ} : Cxt) (c : Cover Γ) → Set where
here : Δ ∈ hole {Δ}
left : ∀{Γ A B c d} {t : Ne Γ (A ∨ B)} (e : Δ ∈ c) → Δ ∈ orC t c d
right : ∀{Γ A B c d} {t : Ne Γ (A ∨ B)} (e : Δ ∈ d) → Δ ∈ orC t c d
-- Given a case tree c : Cover Γ and a context-indexed set P,
-- f : All c P is an assignment of things in P Δ to holes
-- of type Δ reached by pathes e : Δ ∈ c.
All : ∀{Γ} (c : Cover Γ) (P : (Δ : Cxt) → Set) → Set
All c P = ∀{Δ} (e : Δ ∈ c) → P Δ
-- We can also use All c P with a property P on context,
-- to express that all holes of c satify P.
-- We might want to depend on the path e : Δ ∈ c also:
All' : ∀{Γ} (c : Cover Γ) (P : ∀ {Δ} (e : Δ ∈ c) → Set) → Set
All' c P = ∀{Δ} (e : Δ ∈ c) → P e
-- If c : Cover Γ and e : Δ ∈ C, then Δ must be an extension of Γ.
-- Here, we only prove that it is a thinning.
coverWk : ∀{Γ} {c : Cover Γ} → All c (_≤ Γ)
coverWk here = id≤
coverWk (left e) = coverWk e • weak id≤
coverWk (right e) = coverWk e • weak id≤
-- We can substitute leaves in the case tree by case trees in turn.
-- The following is a ``parallel substitution'' operations for covers.
-- If c : Cover Γ and f is a mapping from the leaves of c to case trees
-- we can graft f onto c to get a new case tree transC c f.
-- Here, the case tree substitution is given as a function from pathes
-- p : Δ ∈ c to covers.
transC : ∀{Γ} (c : Cover Γ) (f : All c Cover) → Cover Γ
transC hole f = f here
transC (falseC t) f = falseC t
transC (orC t c d) f = orC t (transC c (f ∘ left)) (transC d (f ∘ right))
-- Composition of pathes.
-- Assume a c : Cover Γ and a substitution f : Δ ∈ c → ∁over Δ and a path e : Δ ∈ c.
-- Then any path p : Φ ∈ f e can be extended to a path q : Φ ∈ transC c f
-- by essentially concatenating e and p.
-- Note that we maintain f only for the sake of typing.
-- trans∈ : ∀{Γ} (c : Cover Γ) (f : All c Cover) →
-- ∀ {Δ} (e : Δ ∈ c) {Φ} → Φ ∈ f e → Φ ∈ transC c f
trans∈ : ∀{Γ} (c : Cover Γ) (f : All c Cover) →
All' c λ {Δ} (e : Δ ∈ c) → All (f e) (_∈ transC c f)
trans∈ hole f here = id
trans∈ (falseC t) f ()
trans∈ (orC t c d) f (left e) = left ∘ trans∈ c (f ∘ left ) e
trans∈ (orC t c d) f (right e) = right ∘ trans∈ d (f ∘ right) e
-- Splitting of pathes.
-- In a situation similar to the previous lemma:
-- If we have a path q : Φ ∈ transC c f we can split it into some
-- e : Δ ∈ c and p : Φ ∈ f e.
split∈ : ∀{Γ} (c : Cover Γ) (f : All c Cover) {Φ} (q : Φ ∈ transC c f)
→ ∃ λ Δ → ∃ λ (e : Δ ∈ c) → Φ ∈ f e
split∈ hole f q = _ , _ , q
split∈ (falseC t) f ()
split∈ (orC t c d) f (left q) with split∈ c (f ∘ left) q
... | Δ , e₁ , e₂ = Δ , left e₁ , e₂
split∈ (orC t c d) f (right q) with split∈ d (f ∘ right) q
... | Δ , e₁ , e₂ = Δ , right e₁ , e₂
-- Syntactic paste (from Thorsten).
-- If for each leave e : Δ ∈ c of a case tree c : Cover Γ we have a normal form
-- f e : Nf Δ A of type A, grafting these nfs onto c gives us a Nf Γ A.
pasteNf : ∀{A Γ} (c : Cover Γ) (f : All c λ Δ → Nf Δ A) → Nf Γ A
pasteNf hole f = f here
pasteNf (falseC t) f = falseE t
pasteNf (orC t c d) f = orE t (pasteNf c (f ∘ left)) (pasteNf d (f ∘ right))
-- Weakening covers: A case tree in Γ can be transported to a thinning Δ
-- by weakening all the scrutinees.
-- monC : ∀{Γ Δ} (τ : Δ ≤ Γ) (c : Cover Γ) → Cover Δ
monC : Mon Cover
monC τ hole = hole
monC τ (falseC t) = falseC (monNe τ t)
monC τ (orC t c d) = orC (monNe τ t) (monC (lift τ) c) (monC (lift τ) d)
-- Undoing a weakening on a path.
--
-- If we have a path e : Φ ∈ monC τ c in a case tree c : Cover Γ transported
-- to Δ via thinning τ : Δ ≤ Γ, we also get a path e' : Ψ ∈ c in the original
-- case tree c such that Ψ is a strenthening of Φ (Φ ≤ Ψ).
mon∈ : ∀{Γ Δ Φ} (c : Cover Γ) (τ : Δ ≤ Γ) (e : Φ ∈ monC τ c) → ∃ λ Ψ → Ψ ∈ c × Φ ≤ Ψ
mon∈ hole τ here = _ , here , τ
mon∈ (falseC t) τ ()
mon∈ (orC t c d) τ (left e) with mon∈ c (lift τ) e
... | Ψ , e' , σ = Ψ , left e' , σ
mon∈ (orC t c d) τ (right e) with mon∈ d (lift τ) e
... | Ψ , e' , σ = Ψ , right e' , σ
-- Packaging a case tree with its valuation.
CovExt : (Γ : Cxt) (P : Cxt → Set) → Set
CovExt Γ P = Σ (Cover Γ) λ c → All c P
transCE : ∀ {P Γ} (c : Cover Γ) (f : All c λ Δ → CovExt Δ P) → CovExt Γ P
transCE c f = transC c (proj₁ ∘ f) , λ e →
let _ , e₁ , e₂ = split∈ c (proj₁ ∘ f) e
in f e₁ .proj₂ e₂
monCE : ∀{P} → Mon P → Mon λ Γ → CovExt Γ P
monCE monP τ (c , f) = monC τ c , λ {Φ} e →
let Ψ , e' , σ = mon∈ c τ e
in monP σ (f {Ψ} e')
-- The syntactic Beth model.
-- We interpret base propositions Atom P by their normal deriviations.
-- ("Normal" is important; "neutral is not sufficient since we need case trees here.)
-- The negative connectives True, ∧, and ⇒ are explained as usual by η-expansion
-- and the meta-level connective.
-- The positive connectives False and ∨ are inhabited by case trees.
-- In case False, the tree has no leaves.
-- In case A ∨ B, each leaf must be in the semantics of either A or B.
T⟦_⟧ : (A : Form) (Γ : Cxt) → Set
T⟦ Atom P ⟧ Γ = Nf Γ (Atom P)
T⟦ True ⟧ Γ = ⊤
T⟦ False ⟧ Γ = CovExt Γ λ Δ → ⊥
T⟦ A ∨ B ⟧ Γ = CovExt Γ λ Δ → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ
T⟦ A ∧ B ⟧ Γ = T⟦ A ⟧ Γ × T⟦ B ⟧ Γ
T⟦ A ⇒ B ⟧ Γ = ∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ B ⟧ Δ
-- Monotonicity of the model is proven by induction on the proposition,
-- using monotonicity of covers and the built-in monotonicity at implication.
-- monT : ∀ A {Γ Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Γ → T⟦ A ⟧ Δ
monT : ∀ A → Mon T⟦ A ⟧
monT (Atom P) = monNf
monT True = _
monT False = monCE λ τ ()
monT (A ∨ B) = monCE λ τ → map-⊎ (monT A τ) (monT B τ)
monT (A ∧ B) τ (a , b) = monT A τ a , monT B τ b
monT (A ⇒ B) τ f σ = f (σ • τ)
-- Reflection / reification, proven simultaneously by induction on the proposition.
-- Reflection is η-expansion (and recursively reflection);
-- at positive connections we build a case tree with a single scrutinee: the neutral
-- we are reflecting.
-- At implication, we need reification, which produces introductions
-- and reifies the stored case trees.
mutual
reflect : ∀{Γ} A (t : Ne Γ A) → T⟦ A ⟧ Γ
reflect (Atom P) t = ne t
reflect True t = _
reflect False t = falseC t , λ()
reflect (A ∨ B) t = orC t hole hole , λ where
(left here) → inj₁ (reflect A (hyp top))
(right here) → inj₂ (reflect B (hyp top))
reflect (A ∧ B) t = reflect A (andE₁ t) , reflect B (andE₂ t)
reflect (A ⇒ B) t τ a = reflect B (impE (monNe τ t) (reify A a))
reify : ∀{Γ} A (⟦f⟧ : T⟦ A ⟧ Γ) → Nf Γ A
reify (Atom P) t = t
reify True _ = trueI
reify False (c , f) = pasteNf c (⊥-elim ∘ f)
reify (A ∨ B) (c , f) = pasteNf c ([ orI₁ ∘ reify A , orI₂ ∘ reify B ] ∘ f)
reify (A ∧ B) (a , b) = andI (reify A a) (reify B b)
reify (A ⇒ B) ⟦f⟧ = impI (reify B (⟦f⟧ (weak id≤) (reflect A (hyp top))))
-- Semantic paste.
-- This grafts semantic values f onto a case tree c : Cover Γ.
-- For atomic propositions, this is grafting of normal forms (defined before).
paste : ∀ A {Γ} (c : Cover Γ) (f : All c (T⟦ A ⟧)) → T⟦ A ⟧ Γ
paste (Atom P) = pasteNf
paste True = _
paste False = transCE
paste (A ∨ B) = transCE
paste (A ∧ B) c f = paste A c (proj₁ ∘ f) , paste B c (proj₂ ∘ f)
paste (A ⇒ B) c f τ a = paste B (monC τ c) λ {Δ} e →
let Ψ , e' , σ = mon∈ c τ e
in f e' σ (monT A (coverWk e) a)
-- Fundamental theorem
-- Extension of T⟦_⟧ to contexts
G⟦_⟧ : ∀ (Γ Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × T⟦ A ⟧ Δ
-- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG : ∀{Γ} → Mon G⟦ Γ ⟧
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , monT A τ a
-- Variable case.
fundH : ∀{Γ Δ A} (x : Hyp A Γ) (γ : G⟦ Γ ⟧ Δ) → T⟦ A ⟧ Δ
fundH top = proj₂
fundH (pop x) = fundH x ∘ proj₁
-- A lemma for the orE case.
orElim : ∀ {Γ A B E} → T⟦ A ∨ B ⟧ Γ →
(∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ E ⟧ Δ) →
(∀{Δ} (τ : Δ ≤ Γ) → T⟦ B ⟧ Δ → T⟦ E ⟧ Δ) →
T⟦ E ⟧ Γ
orElim (c , f) g h = paste _ c λ e → case f e of [ g (coverWk e) , h (coverWk e) ]
-- A lemma for the falseE case.
-- Casts an empty cover into any semantic value (by contradiction).
falseElim : ∀{Γ A} → T⟦ False ⟧ Γ → T⟦ A ⟧ Γ
falseElim (c , f) = paste _ c (⊥-elim ∘ f)
-- The fundamental theorem
fund : ∀{Γ A} (t : Γ ⊢ A) {Δ} (γ : G⟦ Γ ⟧ Δ) → T⟦ A ⟧ Δ
fund (hyp x) = fundH x
fund (impI t) γ τ a = fund t (monG τ γ , a)
fund (impE t u) γ = fund t γ id≤ (fund u γ)
fund (andI t u) γ = fund t γ , fund u γ
fund (andE₁ t) = proj₁ ∘ fund t
fund (andE₂ t) = proj₂ ∘ fund t
fund (orI₁ t) γ = hole , inj₁ ∘ λ{ here → fund t γ }
fund (orI₂ t) γ = hole , inj₂ ∘ λ{ here → fund t γ }
fund (orE t u v) γ = orElim (fund t γ)
(λ τ a → fund u (monG τ γ , a))
(λ τ b → fund v (monG τ γ , b))
fund (falseE t) γ = falseElim (fund t γ)
fund trueI γ = _
-- Identity environment
ide : ∀ Γ → G⟦ Γ ⟧ Γ
ide ε = _
ide (Γ ∙ A) = monG (weak id≤) (ide Γ) , reflect A (hyp top)
-- Normalization
norm : ∀{Γ A} (t : Γ ⊢ A) → Nf Γ A
norm t = reify _ (fund t (ide _))
-- Q.E.D. -}
| {
"alphanum_fraction": 0.5617517957,
"avg_line_length": 34.3287671233,
"ext": "agda",
"hexsha": "4c9b0b610f4093388dedad35b2e4c3c1b5b27445",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/NfModel.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src/NfModel.agda",
"max_line_length": 89,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/NfModel.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 4066,
"size": 10024
} |
module Computability.Enumeration.Diagonal where
open import Computability.Prelude
open import Computability.Function
open import Computability.Data.Fin.Opposite
open import Computability.Data.Nat.Iteration
open import Computability.Enumeration.Base
open import Data.Nat using (_∸_; pred; ⌊_/2⌋; _≤_; _<_; s≤s; z≤n)
open import Data.Nat.Properties using (+-suc; +-assoc; +-comm; +-identityʳ)
open import Data.Nat.Properties using (*-suc; *-assoc; *-comm; *-zeroʳ)
open import Data.Nat.Properties using (≤-step)
open import Data.Fin using (Fin; zero; suc; inject₁; fromℕ; fromℕ<; toℕ; opposite)
open import Data.Fin.Properties using (toℕ<n; toℕ-fromℕ; toℕ-inject₁; fromℕ<-toℕ)
open import Relation.Binary.PropositionalEquality using (_≢_; cong; sym)
open Relation.Binary.PropositionalEquality.≡-Reasoning
Diagonal : Set
Diagonal = Σ[ k ∈ ℕ ] Fin (suc k)
step-Diag : Diagonal → Diagonal
step-Diag (k , zero) = suc k , fromℕ (suc k)
step-Diag (k , suc i) = k , inject₁ i
triangle : ℕ → ℕ
triangle k = ⌊ suc k * k /2⌋
enum-Diag : ℕ → Diagonal
enum-Diag n = iterate step-Diag n (zero , zero)
code-Diag : Diagonal → ℕ
code-Diag (k , i) = toℕ (opposite i) + triangle k
module TriangleProperties where
elim-⌊/2⌋ : ∀ k i → ⌊ i * 2 + k /2⌋ ≡ i + ⌊ k /2⌋
elim-⌊/2⌋ k zero = refl
elim-⌊/2⌋ k (suc i) rewrite elim-⌊/2⌋ k i = refl
rewrite-triangle : (k : ℕ) → suc (k + suc (k + k * suc k)) ≡ suc k * 2 + (k + k * k)
rewrite-triangle k
rewrite *-comm k (suc k)
| +-suc k (k + (k + k * k))
| *-comm k 2
| +-identityʳ k
| +-assoc k k (k + k * k) = refl
triangle-relation : ∀ k → triangle (suc k) ≡ suc k + triangle k
triangle-relation k =
begin
⌊ suc (suc k) * suc k /2⌋
≡⟨ cong ⌊_/2⌋ (rewrite-triangle k) ⟩
⌊ suc k * 2 + suc k * k /2⌋
≡⟨ elim-⌊/2⌋ (suc k * k) (suc k) ⟩
suc k + ⌊ suc k * k /2⌋
∎
open TriangleProperties
step-Diag-suc : ∀ d → code-Diag (step-Diag d) ≡ suc (code-Diag d)
step-Diag-suc (k , zero)
rewrite opposite-fromℕ k
| toℕ-fromℕ k
| triangle-relation k = refl
step-Diag-suc (k , suc i)
rewrite opposite-inject₁-suc i
| toℕ-inject₁ (opposite i) = refl
code-Diag-LInv : ∀ n → code-Diag (enum-Diag n) ≡ n
code-Diag-LInv zero = refl
code-Diag-LInv (suc n) =
begin
code-Diag (step-Diag (enum-Diag n))
≡⟨ step-Diag-suc (enum-Diag n) ⟩
suc (code-Diag (enum-Diag n))
≡⟨ cong suc (code-Diag-LInv n) ⟩
suc n
∎
enum-Diag-Fin-Order : ∀ k i → (lt : i < suc k) → iterate step-Diag i (k , fromℕ k) ≡ (k , opposite (fromℕ< lt))
enum-Diag-Fin-Order k zero lt = refl
enum-Diag-Fin-Order k (suc i) (s≤s lt)
rewrite enum-Diag-Fin-Order k i (≤-step lt)
| opposite-fromℕ< i k lt = refl
enum-Diag-Fin : ∀ k (i : Fin (suc k)) → iterate step-Diag (toℕ i) (k , fromℕ k) ≡ (k , opposite i)
enum-Diag-Fin k i =
begin
iterate step-Diag (toℕ i) (k , fromℕ k)
≡⟨ enum-Diag-Fin-Order k (toℕ i) (toℕ<n i)⟩
(k , opposite (fromℕ< (toℕ<n i)))
≡⟨ cong (λ e → k , opposite e) (fromℕ<-toℕ i (toℕ<n i)) ⟩
(k , opposite i)
∎
enum-Diag-triangle : ∀ k → enum-Diag (triangle k) ≡ (k , fromℕ k)
enum-Diag-triangle zero = refl
enum-Diag-triangle (suc k) =
begin
enum-Diag (triangle (suc k))
≡⟨ cong enum-Diag (triangle-relation k) ⟩
enum-Diag (suc k + triangle k)
≡⟨ split-iterate step-Diag (zero , zero) (suc k) (triangle k) ⟩
iterate step-Diag (suc k) (enum-Diag (triangle k))
≡⟨ cong (iterate step-Diag (suc k)) (enum-Diag-triangle k) ⟩
iterate step-Diag (suc k) (k , fromℕ k)
≡⟨ sym (cong (λ e → iterate step-Diag (suc e) (k , fromℕ k)) (toℕ-fromℕ k)) ⟩
iterate step-Diag (suc (toℕ (fromℕ k))) (k , fromℕ k)
≡⟨ cong step-Diag (enum-Diag-Fin k (fromℕ k)) ⟩
step-Diag (k , opposite (fromℕ k))
≡⟨ cong (λ e → step-Diag (k , e)) (opposite-fromℕ k) ⟩
step-Diag (k , zero)
∎
code-Diag-RInv : ∀ d → enum-Diag (code-Diag d) ≡ d
code-Diag-RInv (k , i) =
begin
enum-Diag (toℕ (opposite i) + triangle k)
≡⟨ split-iterate step-Diag (zero , zero) (toℕ (opposite i)) (triangle k) ⟩
iterate step-Diag (toℕ (opposite i)) (enum-Diag (triangle k))
≡⟨ cong (iterate step-Diag (toℕ (opposite i))) (enum-Diag-triangle k) ⟩
iterate step-Diag (toℕ (opposite i)) (k , fromℕ k)
≡⟨ enum-Diag-Fin k (opposite i) ⟩
k , opposite (opposite i)
≡⟨ cong (λ e → k , e) (opposite-opposite i) ⟩
k , i
∎
open Enumerable
Diag-Enumerable : Enumerable Diagonal
enum Diag-Enumerable = enum-Diag
proj₁ (bijective Diag-Enumerable) {x = n₀} {y = n₁} eq =
begin
n₀
≡⟨ sym (code-Diag-LInv n₀) ⟩
code-Diag (enum-Diag n₀)
≡⟨ cong code-Diag eq ⟩
code-Diag (enum-Diag n₁)
≡⟨ code-Diag-LInv n₁ ⟩
n₁
∎
proj₁ (proj₂ (bijective Diag-Enumerable) d) = code-Diag d
proj₂ (proj₂ (bijective Diag-Enumerable) d) = code-Diag-RInv d
| {
"alphanum_fraction": 0.6152570481,
"avg_line_length": 33.5,
"ext": "agda",
"hexsha": "7690257a97be5e823e91fe61e97f7ebba6a5b549",
"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": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jesyspa/computability-in-agda",
"max_forks_repo_path": "Computability/Enumeration/Diagonal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"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": "jesyspa/computability-in-agda",
"max_issues_repo_path": "Computability/Enumeration/Diagonal.agda",
"max_line_length": 111,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jesyspa/computability-in-agda",
"max_stars_repo_path": "Computability/Enumeration/Diagonal.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z",
"num_tokens": 2039,
"size": 4824
} |
module Issue4869 where
open import Agda.Builtin.Nat
infix 4 _≤_
data _≤_ : Nat → Nat → Set where
z≤n : ∀ {n} → zero ≤ n
s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n
foo : 2 ≤ 1 → Nat
foo (s≤s ()) = 123
| {
"alphanum_fraction": 0.5358851675,
"avg_line_length": 16.0769230769,
"ext": "agda",
"hexsha": "10f352792f855416f21635744ca67c55dfb4696b",
"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/Issue4869.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/Issue4869.agda",
"max_line_length": 45,
"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/Issue4869.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": 100,
"size": 209
} |
module RecursiveInstanceSearch where
open import Common.Prelude
open import Common.Product
_&&_ : Bool → Bool → Bool
true && b = b
false && _ = false
record Eq (A : Set) : Set where
constructor eq
field
_==_ : A → A → Bool
open Eq {{...}} public
instance
eq-Bool : Eq Bool
eq-Bool = eq aux where
aux : Bool → Bool → Bool
aux true true = true
aux false false = true
aux _ _ = false
eq-Nat : Eq Nat
eq-Nat = eq aux where
aux : Nat → Nat → Bool
aux zero zero = true
aux (suc n) (suc m) = aux n m
aux _ _ = false
eq-Maybe : {A : Set} {{_ : Eq A}} → Eq (Maybe A)
eq-Maybe {A} = eq aux where
aux : Maybe A → Maybe A → Bool
aux nothing nothing = true
aux (just y) (just z) = (y == z)
aux _ _ = false
eq-List : {A : Set} {{_ : Eq A}} → Eq (List A)
eq-List {A} = eq aux where
aux : List A → List A → Bool
aux [] [] = true
aux (x ∷ l) (y ∷ l') = (x == y) && (aux l l')
aux _ _ = false
eq-× : {A B : Set} {{_ : Eq A}} {{_ : Eq B}} → Eq (A × B)
eq-× {A} {B} = eq (λ x y → (proj₁ x == proj₁ y) && (proj₂ x == proj₂ y))
test₂ : Bool
test₂ = (3 == 4)
test₃ : Bool
test₃ = ((just 9) == nothing)
test₃' : Bool
test₃' = (nothing == just 6)
test₄ : Bool
test₄ = (true ∷ []) == (false ∷ [])
test₅ : Bool
test₅ = (just ((true ,′ (1 ,′ just 0)) ∷ []) == just ((true , (1 , just 0)) ∷ []))
| {
"alphanum_fraction": 0.5202898551,
"avg_line_length": 20.9090909091,
"ext": "agda",
"hexsha": "c913059c7e79291f02c443404a1592085f3fc3bf",
"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/RecursiveInstanceSearch.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/RecursiveInstanceSearch.agda",
"max_line_length": 82,
"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/RecursiveInstanceSearch.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": 526,
"size": 1380
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Nullary relations (some core definitions)
------------------------------------------------------------------------
-- The definitions in this file are reexported by Relation.Nullary.
module Relation.Nullary.Core where
open import Data.Empty
open import Level
-- Negation.
infix 3 ¬_
¬_ : ∀ {ℓ} → Set ℓ → Set ℓ
¬ P = P → ⊥
-- Decidable relations.
data Dec {p} (P : Set p) : Set p where
yes : ( p : P) → Dec P
no : (¬p : ¬ P) → Dec P
| {
"alphanum_fraction": 0.4666666667,
"avg_line_length": 21.3461538462,
"ext": "agda",
"hexsha": "d8b07577332150a3feaa3e519906ed1e04614879",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 136,
"size": 555
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Orders.Partial.Definition
open import Setoids.Setoids
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Groups.Orders.Partial.Definition {n m : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ : A → A → A} (G : Group S _+_) where
open Group G
open Setoid S
record PartiallyOrderedGroup {p : _} {_<_ : Rel {_} {p} A} (pOrder : SetoidPartialOrder S _<_) : Set (lsuc n ⊔ m ⊔ p) where
field
orderRespectsAddition : {a b : A} → (a < b) → (c : A) → (a + c) < (b + c)
| {
"alphanum_fraction": 0.6542207792,
"avg_line_length": 34.2222222222,
"ext": "agda",
"hexsha": "093b2184ae52017bc92201b38ff2c4b255fc1470",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Groups/Orders/Partial/Definition.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Groups/Orders/Partial/Definition.agda",
"max_line_length": 126,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Groups/Orders/Partial/Definition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 211,
"size": 616
} |
-- This test case is aimed at checking that one can give RTS options
-- (as well as other options) using the Emacs mode. It does not test
-- backend options.
| {
"alphanum_fraction": 0.7405063291,
"avg_line_length": 39.5,
"ext": "agda",
"hexsha": "9c63f5823c95ed37091abcf146c7018edba5037c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue3235.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue3235.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue3235.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 37,
"size": 158
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.MayerVietorisUnreduced 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.Prelude
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Sigma
open import Cubical.HITs.Pushout
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.HITs.Susp
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2)
open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁)
open import Cubical.Data.Nat
open import Cubical.Algebra.Group
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3)
open GroupHom
module MV {ℓ ℓ' ℓ''} (A : Type ℓ) (B : Type ℓ') (C : Type ℓ'') (f : C → A) (g : C → B) where
-- Proof from Brunerie 2016.
-- We first define the three morphisms involved: i, Δ and d.
private
i* : (n : ℕ) → coHom n (Pushout f g) → coHom n A × coHom n B
i* n = sRec (isSet× setTruncIsSet setTruncIsSet) λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂
iIsHom : (n : ℕ) → isGroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B) (i* n)
iIsHom n = sElim2 (λ _ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _) λ _ _ → refl
i : (n : ℕ) → GroupHom (coHomGr n (Pushout f g)) (×coHomGr n A B)
GroupHom.fun (i n) = i* n
GroupHom.isHom (i n) = iIsHom n
private
distrLem : (n : ℕ) (x y z w : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ (z +[ n ]ₖ w) ≡ (x -[ n ]ₖ z) +[ n ]ₖ (y -[ n ]ₖ w)
distrLem n x y z w = cong (λ z → (x +[ n ]ₖ y) +[ n ]ₖ z) (-distrₖ n z w)
∙∙ sym (assocₖ n x y ((-[ n ]ₖ z) +[ n ]ₖ (-[ n ]ₖ w)))
∙∙ cong (λ y → x +[ n ]ₖ y) (commₖ n y ((-[ n ]ₖ z) +[ n ]ₖ (-[ n ]ₖ w)) ∙ sym (assocₖ n _ _ _))
∙∙ assocₖ n _ _ _
∙∙ cong (λ y → (x -[ n ]ₖ z) +[ n ]ₖ y) (commₖ n (-[ n ]ₖ w) y)
Δ' : (n : ℕ) → coHom n A × coHom n B → coHom n C
Δ' n (α , β) = coHomFun n f α -[ n ]ₕ coHomFun n g β
Δ'-isMorph : (n : ℕ) → isGroupHom (×coHomGr n A B) (coHomGr n C) (Δ' n)
Δ'-isMorph n =
prodElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _ )
λ f' x1 g' x2 i → ∣ (λ x → distrLem n (f' (f x)) (g' (f x)) (x1 (g x)) (x2 (g x)) i) ∣₂
Δ : (n : ℕ) → GroupHom (×coHomGr n A B) (coHomGr n C)
GroupHom.fun (Δ n) = Δ' n
GroupHom.isHom (Δ n) = Δ'-isMorph n
d-pre : (n : ℕ) → (C → coHomK n) → Pushout f g → coHomK (suc n)
d-pre n γ (inl x) = 0ₖ (suc n)
d-pre n γ (inr x) = 0ₖ (suc n)
d-pre n γ (push a i) = Kn→ΩKn+1 n (γ a) i
dHomHelper : (n : ℕ) (h l : C → coHomK n) (x : Pushout f g)
→ d-pre n (λ x → h x +[ n ]ₖ l x) x ≡ d-pre n h x +[ suc n ]ₖ d-pre n l x
dHomHelper n h l (inl x) = sym (rUnitₖ (suc n) (0ₖ (suc n)))
dHomHelper n h l (inr x) = sym (lUnitₖ (suc n) (0ₖ (suc n)))
dHomHelper n h l (push a i) j =
hcomp (λ k → λ { (i = i0) → rUnitₖ (suc n) (0ₖ (suc n)) (~ j)
; (i = i1) → lUnitₖ (suc n) (0ₖ (suc n)) (~ j)
; (j = i0) → Kn→ΩKn+1-hom n (h a) (l a) (~ k) i
; (j = i1) → cong₂Funct (λ x y → x +[ (suc n) ]ₖ y) (Kn→ΩKn+1 n (h a)) (Kn→ΩKn+1 n (l a)) (~ k) i })
(hcomp (λ k → λ { (i = i0) → rUnitₖ (suc n) (0ₖ (suc n)) (~ j)
; (i = i1) → lUnitₖ (suc n) (Kn→ΩKn+1 n (l a) k) (~ j)})
(hcomp (λ k → λ { (i = i0) → rUnitₖ (suc n) (0ₖ (suc n)) (~ j)
; (i = i1) → lUnitₖ≡rUnitₖ (suc n) (~ k) (~ j)
; (j = i0) → Kn→ΩKn+1 n (h a) i
; (j = i1) → (Kn→ΩKn+1 n (h a) i) +[ (suc n) ]ₖ coHom-pt (suc n)})
(rUnitₖ (suc n) (Kn→ΩKn+1 n (h a) i) (~ j))))
dIsHom : (n : ℕ) → isGroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂)
dIsHom n = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ f g i → ∣ funExt (λ x → dHomHelper n f g x) i ∣₂
d : (n : ℕ) → GroupHom (coHomGr n C) (coHomGr (suc n) (Pushout f g))
GroupHom.fun (d n) = sRec setTruncIsSet λ a → ∣ d-pre n a ∣₂
GroupHom.isHom (d n) = dIsHom n
-- The long exact sequence
Im-d⊂Ker-i : (n : ℕ) (x : ⟨ (coHomGr (suc n) (Pushout f g)) ⟩)
→ isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x
→ isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x
Im-d⊂Ker-i n = sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _)
λ a → pRec (isOfHLevelPath' 1 (isSet× setTruncIsSet setTruncIsSet) _ _)
(sigmaElim (λ _ → isOfHLevelPath 2 (isSet× setTruncIsSet setTruncIsSet) _ _)
λ δ b i → sRec (isSet× setTruncIsSet setTruncIsSet)
(λ δ → ∣ (λ x → δ (inl x)) ∣₂ , ∣ (λ x → δ (inr x)) ∣₂ ) (b (~ i)))
Ker-i⊂Im-d : (n : ℕ) (x : ⟨ coHomGr (suc n) (Pushout f g) ⟩)
→ isInKer (coHomGr (suc n) (Pushout f g)) (×coHomGr (suc n) A B) (i (suc n)) x
→ isInIm (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) x
Ker-i⊂Im-d n =
sElim (λ _ → isSetΠ λ _ → isProp→isSet propTruncIsProp)
λ a p → pRec {A = (λ x → a (inl x)) ≡ λ _ → 0ₖ (suc n)}
(isProp→ propTruncIsProp)
(λ p1 → pRec propTruncIsProp λ p2 → ∣ ∣ (λ c → ΩKn+1→Kn n (sym (cong (λ F → F (f c)) p1)
∙∙ cong a (push c)
∙∙ cong (λ F → F (g c)) p2)) ∣₂
, cong ∣_∣₂ (funExt (λ δ → helper a p1 p2 δ)) ∣₁)
(Iso.fun PathIdTrunc₀Iso (cong fst p))
(Iso.fun PathIdTrunc₀Iso (cong snd p))
where
helper : (F : (Pushout f g) → coHomK (suc n))
(p1 : Path (_ → coHomK (suc n)) (λ a₁ → F (inl a₁)) (λ _ → coHom-pt (suc n)))
(p2 : Path (_ → coHomK (suc n)) (λ a₁ → F (inr a₁)) (λ _ → coHom-pt (suc n)))
→ (δ : Pushout f g)
→ d-pre n (λ c → ΩKn+1→Kn n ((λ i₁ → p1 (~ i₁) (f c))
∙∙ cong F (push c)
∙∙ cong (λ F → F (g c)) p2)) δ
≡ F δ
helper F p1 p2 (inl x) = sym (cong (λ f → f x) p1)
helper F p1 p2 (inr x) = sym (cong (λ f → f x) p2)
helper F p1 p2 (push a i) j =
hcomp (λ k → λ { (i = i0) → p1 (~ j) (f a)
; (i = i1) → p2 (~ j) (g a)
; (j = i0) → Iso.rightInv (Iso-Kn-ΩKn+1 n) ((λ i₁ → p1 (~ i₁) (f a))
∙∙ cong F (push a)
∙∙ cong (λ F₁ → F₁ (g a)) p2) (~ k) i
; (j = i1) → F (push a i)})
(doubleCompPath-filler (sym (cong (λ F → F (f a)) p1)) (cong F (push a)) (cong (λ F → F (g a)) p2) (~ j) i)
open GroupHom
Im-i⊂Ker-Δ : (n : ℕ) (x : ⟨ ×coHomGr n A B ⟩)
→ isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) x
→ isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) x
Im-i⊂Ker-Δ n (Fa , Fb) =
sElim {B = λ Fa → (Fb : _) → isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) (Fa , Fb)
→ isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) (Fa , Fb)}
(λ _ → isSetΠ2 λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _)
(λ Fa → sElim (λ _ → isSetΠ λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ Fb → pRec (setTruncIsSet _ _)
(sigmaElim (λ x → isProp→isSet (setTruncIsSet _ _))
λ Fd p → helper n Fa Fb Fd p))
Fa
Fb
where
helper : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n) (Fd : (Pushout f g) → coHomK n)
→ (fun (i n) ∣ Fd ∣₂ ≡ (∣ Fa ∣₂ , ∣ Fb ∣₂))
→ (fun (Δ n)) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n
helper n Fa Fb Fd p = cong (fun (Δ n)) (sym p)
∙∙ (λ i → ∣ (λ x → Fd (inl (f x))) ∣₂ -[ n ]ₕ ∣ (λ x → Fd (push x (~ i))) ∣₂ )
∙∙ rCancelₕ n ∣ (λ x → Fd (inl (f x))) ∣₂
Ker-Δ⊂Im-i : (n : ℕ) (a : ⟨ ×coHomGr n A B ⟩)
→ isInKer (×coHomGr n A B) (coHomGr n C) (Δ n) a
→ isInIm (coHomGr n (Pushout f g)) (×coHomGr n A B) (i n) a
Ker-Δ⊂Im-i n = prodElim (λ _ → isSetΠ (λ _ → isProp→isSet propTruncIsProp))
(λ Fa Fb p → pRec propTruncIsProp
(λ q → ∣ ∣ helpFun Fa Fb q ∣₂ , refl ∣₁)
(helper Fa Fb p))
where
helper : (Fa : A → coHomK n) (Fb : B → coHomK n)
→ fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂) ≡ 0ₕ n
→ ∥ Path (_ → _) (λ c → Fa (f c)) (λ c → Fb (g c)) ∥₁
helper Fa Fb p = Iso.fun PathIdTrunc₀Iso
(sym (cong ∣_∣₂ (funExt (λ x → sym (assocₖ n _ _ _)
∙∙ cong (λ y → Fa (f x) +[ n ]ₖ y) (lCancelₖ n (Fb (g x)))
∙∙ rUnitₖ n (Fa (f x)))))
∙∙ cong (λ x → x +[ n ]ₕ ∣ (λ c → Fb (g c)) ∣₂) p
∙∙ lUnitₕ n _)
helpFun : (Fa : A → coHomK n) (Fb : B → coHomK n)
→ ((λ c → Fa (f c)) ≡ (λ c → Fb (g c)))
→ Pushout f g → coHomK n
helpFun Fa Fb p (inl x) = Fa x
helpFun Fa Fb p (inr x) = Fb x
helpFun Fa Fb p (push a i) = p i a
private
distrHelper : (n : ℕ) (p q : _)
→ ΩKn+1→Kn n p +[ n ]ₖ (-[ n ]ₖ ΩKn+1→Kn n q) ≡ ΩKn+1→Kn n (p ∙ sym q)
distrHelper n p q = cong (λ x → ΩKn+1→Kn n p +[ n ]ₖ x) helper ∙ sym (ΩKn+1→Kn-hom n _ _)
where
helper : -[ n ]ₖ ΩKn+1→Kn n q ≡ ΩKn+1→Kn n (sym q)
helper =
sym (rUnitₖ n _)
∙∙ cong (λ x → (-[ n ]ₖ (ΩKn+1→Kn n q)) +[ n ]ₖ x) (sym helper2)
∙∙ (assocₖ n _ _ _ ∙∙ cong (λ x → x +[ n ]ₖ (ΩKn+1→Kn n (sym q))) (lCancelₖ n _) ∙∙ lUnitₖ n _)
where
helper2 : ΩKn+1→Kn n q +[ n ]ₖ (ΩKn+1→Kn n (sym q)) ≡ coHom-pt n
helper2 = sym (ΩKn+1→Kn-hom n q (sym q)) ∙∙ cong (ΩKn+1→Kn n) (rCancel q) ∙∙ ΩKn+1→Kn-refl n
Ker-d⊂Im-Δ : (n : ℕ) (a : coHom n C)
→ isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a
→ isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a
Ker-d⊂Im-Δ n =
sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp)
λ Fc p → pRec propTruncIsProp (λ p → ∣ (∣ (λ a → ΩKn+1→Kn n (cong (λ f → f (inl a)) p)) ∣₂ ,
∣ (λ b → ΩKn+1→Kn n (cong (λ f → f (inr b)) p)) ∣₂) ,
Iso.inv (PathIdTrunc₀Iso) ∣ funExt (λ c → helper2 Fc p c) ∣₁ ∣₁)
(Iso.fun (PathIdTrunc₀Iso) p)
where
helper2 : (Fc : C → coHomK n)
(p : d-pre n Fc ≡ (λ _ → coHom-pt (suc n))) (c : C)
→ ΩKn+1→Kn n (λ i₁ → p i₁ (inl (f c))) -[ n ]ₖ (ΩKn+1→Kn n (λ i₁ → p i₁ (inr (g c)))) ≡ Fc c
helper2 Fc p c = distrHelper n _ _ ∙∙ cong (ΩKn+1→Kn n) helper3 ∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) (Fc c)
where
helper3 : (λ i₁ → p i₁ (inl (f c))) ∙ sym (λ i₁ → p i₁ (inr (g c))) ≡ Kn→ΩKn+1 n (Fc c)
helper3 = cong ((λ i₁ → p i₁ (inl (f c))) ∙_) (lUnit _) ∙ sym (PathP→compPathR (cong (λ f → cong f (push c)) p))
Im-Δ⊂Ker-d : (n : ℕ) (a : coHom n C)
→ isInIm (×coHomGr n A B) (coHomGr n C) (Δ n) a
→ isInKer (coHomGr n C) (coHomGr (suc n) (Pushout f g)) (d n) a
Im-Δ⊂Ker-d n =
sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ Fc → pRec (isOfHLevelPath' 1 setTruncIsSet _ _)
(sigmaProdElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ Fa Fb p → pRec (isOfHLevelPath' 1 setTruncIsSet _ _)
(λ q → ((λ i → fun (d n) ∣ (q (~ i)) ∣₂) ∙ dΔ-Id n Fa Fb))
(Iso.fun (PathIdTrunc₀Iso) p))
where
d-preLeftId : (n : ℕ) (Fa : A → coHomK n)(d : (Pushout f g))
→ d-pre n (Fa ∘ f) d ≡ 0ₖ (suc n)
d-preLeftId n Fa (inl x) = Kn→ΩKn+1 n (Fa x)
d-preLeftId n Fa (inr x) = refl
d-preLeftId n Fa (push a i) j = Kn→ΩKn+1 n (Fa (f a)) (j ∨ i)
d-preRightId : (n : ℕ) (Fb : B → coHomK n) (d : (Pushout f g))
→ d-pre n (Fb ∘ g) d ≡ 0ₖ (suc n)
d-preRightId n Fb (inl x) = refl
d-preRightId n Fb (inr x) = sym (Kn→ΩKn+1 n (Fb x))
d-preRightId n Fb (push a i) j = Kn→ΩKn+1 n (Fb (g a)) (~ j ∧ i)
dΔ-Id : (n : ℕ) (Fa : A → coHomK n) (Fb : B → coHomK n)
→ fun (d n) (fun (Δ n) (∣ Fa ∣₂ , ∣ Fb ∣₂)) ≡ 0ₕ (suc n)
dΔ-Id n Fa Fb = -distrLemma n (suc n) (d n) ∣ Fa ∘ f ∣₂ ∣ Fb ∘ g ∣₂
∙∙ (λ i → ∣ (λ x → d-preLeftId n Fa x i) ∣₂ -[ (suc n) ]ₕ ∣ (λ x → d-preRightId n Fb x i) ∣₂)
∙∙ rCancelₕ (suc n) (0ₕ (suc n))
| {
"alphanum_fraction": 0.4502625438,
"avg_line_length": 55.2903225806,
"ext": "agda",
"hexsha": "881f65fb3e82620a7c11a105c53191f31604e787",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda",
"max_line_length": 133,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/MayerVietorisUnreduced.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5691,
"size": 13712
} |
module Lib where
open import Data.List
open import Relation.Binary.PropositionalEquality
data _∧_ (A : Set) (B : Set) : Set where
∧-intro : A → B → (A ∧ B)
--------------------------------
-- Extension with Pairs and Sums
--------------------------------
--------------------------------
-- Basic Set-up
--------------------------------
record Sg (S : Set) (T : S → Set) : Set where
constructor _,_
field
ffst : S
ssnd : T ffst
open Sg public
--pair type on the agda level
_*_ : Set → Set → Set
S * T = Sg S \ _ → T
--proj functions on the agda level
fst : {A B : Set} → A * B → A
fst (a , b) = a
snd : {A B : Set} → A * B → B
snd (a , b) = b
--sum type on the agda level
data _⨄_ (A : Set) (B : Set) : Set where
tl : (a : A) → A ⨄ B
tr : (b : B) → A ⨄ B
--typeofSum : ∀ {A B : Set} (sum : A ⨄ B) → Set
--typeofSum {A = A} (tl _) = A
--typeofSum {B = B} (tr _) = B
-- Pointer into a list. It is similar to list membership as defined in
-- Data.List.AnyMembership, rather than going through propositional
-- equality, it asserts the existence of the referenced element
-- directly.
module ListReference where
infix 4 _∈_
data _∈_ {A : Set} : A → List A → Set where
hd : ∀ {x xs} → x ∈ (x ∷ xs)
tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
open ListReference public
mapIdx : {A B : Set} → (f : A → B) →
{x : A} {xs : List A} → x ∈ xs → f x ∈ map f xs
mapIdx f hd = hd
mapIdx f (tl x₁) = tl (mapIdx f x₁)
-- Extension of lists at the front and, as a generalization, extension
-- of lists somewhere in the middle.
module ListExtension where
open import Relation.Binary.PropositionalEquality
-- Extension of a list by consing elements at the front.
data _↝_ {A : Set} : List A → List A → Set where
↝-refl : ∀ {Γ} → Γ ↝ Γ
↝-extend : ∀ {Γ Γ' τ} → Γ ↝ Γ' → Γ ↝ (τ ∷ Γ')
-- Combining two transitive extensions.
↝-trans : ∀ {A : Set}{Γ Γ' Γ'' : List A} → Γ ↝ Γ' → Γ' ↝ Γ'' → Γ ↝ Γ''
↝-trans Γ↝Γ' ↝-refl = Γ↝Γ'
↝-trans Γ↝Γ' (↝-extend Γ'↝Γ'') = ↝-extend (↝-trans Γ↝Γ' Γ'↝Γ'')
-- Of course, ↝-refl is the identity for combining two extensions.
lem-↝-refl-id : ∀ {A : Set} {Γ Γ' : List A} →
(Γ↝Γ' : Γ ↝ Γ') →
Γ↝Γ' ≡ (↝-trans ↝-refl Γ↝Γ')
lem-↝-refl-id ↝-refl = refl
lem-↝-refl-id (↝-extend Γ↝Γ') = cong ↝-extend (lem-↝-refl-id Γ↝Γ')
-- Extending a list in the middle:
data _↝_↝_ {A : Set} : List A → List A → List A → Set where
-- First prepend the extension list to the common suffix
↝↝-base : ∀ {Γ Γ''} → Γ ↝ Γ'' → Γ ↝ [] ↝ Γ''
-- ... and then add the common prefix
↝↝-extend : ∀ {Γ Γ' Γ'' τ} →
Γ ↝ Γ' ↝ Γ'' → (τ ∷ Γ) ↝ (τ ∷ Γ') ↝ (τ ∷ Γ'')
open ListExtension public
---------------------------------
-- helper functions for rewriting
---------------------------------
→tl : ∀ {A B x' y'} (x y : A ⨄ B)→ x ≡ y → x ≡ tl x' → y ≡ tl y' → x' ≡ y'
→tl {x' = x'} px py a b c rewrite b | c with py | a
... | H | refl = refl
-- →tl {α} {α'} {.y'} {y'} px py a b c | refl | ._ | refl | ._ | refl = ? -- rewrite b | c = {!!}
→tr : ∀ {A B x' y'} (x y : A ⨄ B)→ x ≡ y → x ≡ tr x' → y ≡ tr y' → x' ≡ y'
→tr px py a b c rewrite c | b with px | a
... | H | refl = refl
--------------------------------- | {
"alphanum_fraction": 0.4727810651,
"avg_line_length": 33.137254902,
"ext": "agda",
"hexsha": "7ab7a85a449e7a4c39b6f797b931c67c11ed97f1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-10-15T09:01:37.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-10-15T09:01:37.000Z",
"max_forks_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "luminousfennell/polybta",
"max_forks_repo_path": "Lib.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"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": "luminousfennell/polybta",
"max_issues_repo_path": "Lib.agda",
"max_line_length": 97,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "luminousfennell/polybta",
"max_stars_repo_path": "Lib.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-15T04:35:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-15T04:35:29.000Z",
"num_tokens": 1263,
"size": 3380
} |
module Base where
module Classes where
record LeastUpperBound {ℓ} (A : Set ℓ) : Set ℓ where
infixl 6 _⊔_
field
_⊔_ : A → A → A
open LeastUpperBound ⦃ … ⦄ public
record Successor {ℓ} (A : Set ℓ) : Set ℓ where
field
↑ : A → A
open Successor ⦃ … ⦄ public
module Primitive where
import Agda.Primitive as P
open Classes
instance LeastUpperBoundLevel : LeastUpperBound P.Level
LeastUpperBound._⊔_ LeastUpperBoundLevel = P._⊔_
instance SuccessorLevel : Successor P.Level
Successor.↑ SuccessorLevel = P.lsuc
open Primitive
open Classes
infix -65536 ℞_
℞_ : ∀ ℓ → Set _
℞_ ℓ = Set ℓ
record IsIndexedReflexive {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) {ℓ} (ėq : ∀ {𝑥} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ) : ℞ 𝔵 ⊔ 𝔞 ⊔ ℓ where
private
infix 4 _≈̇_
_≈̇_ = ėq
field
ṙeflexivity : ∀ {𝑥} (a : 𝔄 𝑥) → a ≈̇ a
open IsIndexedReflexive ⦃ … ⦄ public
record IsIndexedSymmetric {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) {ℓ} (ėq : ∀ {𝑥} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ) : ℞ 𝔵 ⊔ 𝔞 ⊔ ℓ where
private
infix 4 _≈̇_
_≈̇_ = ėq
field
ṡymmetry : ∀ {𝑥} (a b : 𝔄 𝑥) → a ≈̇ b → b ≈̇ a
open IsIndexedSymmetric ⦃ … ⦄ public
record IsIndexedTransitive {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) {ℓ} (ėq : ∀ {𝑥} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ) : ℞ 𝔵 ⊔ 𝔞 ⊔ ℓ where
private
infix 4 _≈̇_
_≈̇_ = ėq
field
ṫransitivity : ∀ {𝑥} (a b c : 𝔄 𝑥) → a ≈̇ b → b ≈̇ c → a ≈̇ c
open IsIndexedTransitive ⦃ … ⦄ public
record IsIndexedEquivalence {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) {ℓ} (ėq : ∀ {𝑥 : 𝔛} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ) : ℞ 𝔵 ⊔ 𝔞 ⊔ ℓ where
field
⦃ isReflexive ⦄ : IsIndexedReflexive 𝔄 ėq
⦃ isSymmetric ⦄ : IsIndexedSymmetric 𝔄 ėq
⦃ isTransitive ⦄ : IsIndexedTransitive 𝔄 ėq
open IsIndexedEquivalence ⦃ … ⦄ public
record IndexedEquivalence {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) ℓ : ℞ 𝔵 ⊔ 𝔞 ⊔ ↑ ℓ where
infix 4 _≈̇_
field
_≈̇_ : ∀ {𝑥 : 𝔛} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ
⦃ isIndexedEquivalence ⦄ : IsIndexedEquivalence 𝔄 _≈̇_
open import Prelude.Nat
open import Prelude.Fin
open import Prelude.Equality
open import Prelude.Function
postulate
eFin : ∀ {n} → Fin n → Fin n → Set
eqFin : ∀ {n} → Fin n → Fin n → Set
eqFin = _≡_
module IndexedEquivalence₁ = IndexedEquivalence
open IndexedEquivalence₁ ⦃ … ⦄ renaming (_≈̇_ to _≈̇₁_)
module IndexedEquivalence₂ = IndexedEquivalence
open IndexedEquivalence₂ ⦃ … ⦄ renaming (_≈̇_ to _≈̇₂_)
postulate
instance IndexedEquivalenceFinProp : IndexedEquivalence Fin _
-- instance IsIndexedReflexiveEqFin : IsIndexedReflexive Fin _≡_
-- IsIndexedReflexive.ṙeflexivity IsIndexedReflexiveEqFin a = it
-- {-
-- instance IndexedEquivalenceProp : ∀ {𝔵} {𝔛 : Set 𝔵} {𝔞} {𝔄 : 𝔛 → Set 𝔞} → IndexedEquivalence 𝔄 𝔞
-- IndexedEquivalence._≈̇_ IndexedEquivalenceProp = _≡_
-- IsIndexedEquivalence.isReflexive (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceProp) = {!!}
-- IsIndexedEquivalence.isSymmetric (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceProp) = {!!}
-- IsIndexedEquivalence.isTransitive (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceProp) = {!!}
-- -}
-- instance IndexedEquivalenceFinProp : IndexedEquivalence Fin _
-- IndexedEquivalence._≈̇_ IndexedEquivalenceFinProp = _≡_
-- IsIndexedEquivalence.isReflexive (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceFinProp) = it
-- IsIndexedEquivalence.isSymmetric (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceFinProp) = {!!}
-- IsIndexedEquivalence.isTransitive (IndexedEquivalence.isIndexedEquivalence IndexedEquivalenceFinProp) = {!!}
-- someFin : Fin 5
-- someFin = suc (suc zero)
-- eqFinLemma : someFin ≈̇ someFin
-- eqFinLemma = ṙeflexivity someFin
-- record IsReflexive {𝔞} {𝔄 : Set 𝔞} {ℓ} (eq : 𝔄 → 𝔄 → Set ℓ) : ℞ 𝔞 ⊔ ℓ where
-- private
-- infix 4 _≈_
-- _≈_ = eq
-- field
-- reflexivity : ∀ a → a ≈ a
-- open IsReflexive ⦃ … ⦄
-- record IsSymmetric {𝔞} {𝔄 : Set 𝔞} {ℓ} (eq : 𝔄 → 𝔄 → Set ℓ) : ℞ 𝔞 ⊔ ℓ where
-- private
-- infix 4 _≈_
-- _≈_ = eq
-- field
-- symmetry : ∀ a b → a ≈ b → b ≈ a
-- open IsReflexive ⦃ … ⦄
-- record IsTransitive {𝔞} {𝔄 : Set 𝔞} {ℓ} (eq : 𝔄 → 𝔄 → Set ℓ) : ℞ 𝔞 ⊔ ℓ where
-- private
-- infix 4 _≈_
-- _≈_ = eq
-- field
-- transitivity : ∀ a b c → a ≈ b → b ≈ c → a ≈ c
-- open IsTransitive ⦃ … ⦄
-- record IsEquivalence {𝔞} {𝔄 : Set 𝔞} {ℓ} (eq : 𝔄 → 𝔄 → Set ℓ) : ℞ 𝔞 ⊔ ℓ where
-- field
-- ⦃ isReflexive ⦄ : IsReflexive eq
-- ⦃ isSymmetric ⦄ : IsSymmetric eq
-- ⦃ isTransitive ⦄ : IsTransitive eq
-- open IsEquivalence ⦃ … ⦄
-- record Equivalence {𝔞} {𝔄 : Set 𝔞} ℓ : ℞ 𝔞 ⊔ ↑ ℓ where
-- infix 4 _≈_
-- field
-- _≈_ : 𝔄 → 𝔄 → Set ℓ
-- ⦃ isEquivalence ⦄ : IsEquivalence _≈_
-- open Equivalence ⦃ … ⦄
-- data IndexedTree {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) : ℞ 𝔵 ⊔ 𝔞 where
-- leaf : IndexedTree 𝔄
-- _fork_ : IndexedTree 𝔄 → IndexedTree 𝔄 → IndexedTree 𝔄
-- variable : ∀ {𝑥} → 𝔄 𝑥 → IndexedTree 𝔄
-- infix 4 _≈ᵗ_
-- data _≈ᵗ_ {𝔵} {𝔛 : Set 𝔵} {𝔞} {𝔄 : 𝔛 → Set 𝔞} ⦃ _ : IndexedEquivalence 𝔄 𝔞 ⦄ : IndexedTree 𝔄 → IndexedTree 𝔄 → ℞ 𝔵 ⊔ 𝔞 where
-- leaf : leaf ≈ᵗ leaf
-- _fork_ : ∀ {left-t₁ left-t₂ right-t₁ right-t₂} →
-- left-t₁ ≈ᵗ left-t₂ →
-- right-t₁ ≈ᵗ right-t₂ →
-- left-t₁ fork right-t₁ ≈ᵗ left-t₂ fork right-t₂
-- variable : ∀ {a} → {left-x right-x : 𝔄 a} → left-x ≈̇ right-x → variable left-x ≈ᵗ variable right-x
-- -- reflexivityIndexedTreeEquality : ∀ {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) ⦃ _ : IndexedEquivalence 𝔄 𝔞 ⦄ (a : IndexedTree 𝔄) → a ≈ᵗ a
-- -- reflexivityIndexedTreeEquality 𝔄 leaf = leaf
-- -- reflexivityIndexedTreeEquality 𝔄 (a fork a₁) = (reflexivityIndexedTreeEquality 𝔄 _≈_ a) fork (reflexivityIndexedTreeEquality 𝔄 _≈_ a₁)
-- -- reflexivityIndexedTreeEquality 𝔄 (variable x₁) = variable (ṙeflexivity _)
-- -- -- instance IsEquivalenceIndexedTreeEquality : ∀ {𝔵} {𝔛 : Set 𝔵} {𝔞} (𝔄 : 𝔛 → Set 𝔞) {ℓ} (_≈_ : ∀ {𝑥} → 𝔄 𝑥 → 𝔄 𝑥 → Set ℓ) ⦃ _ : IsIndexedEquivalence 𝔄 _≈_ ⦄ → IsEquivalence ((IndexedTreeEquality 𝔄 _≈_))
-- -- -- IsReflexive.reflexivity (IsEquivalence.isReflexive (IsEquivalenceIndexedTreeEquality 𝔄 _≈_)) a = reflexivityIndexedTreeEquality 𝔄 _≈_ a
-- -- -- IsEquivalence.isSymmetric (IsEquivalenceIndexedTreeEquality 𝔄 _≈_) = {!!}
-- -- -- IsEquivalence.isTransitive (IsEquivalenceIndexedTreeEquality 𝔄 _≈_) = {!!}
-- -- -- data Tree {𝔞} (𝔄 : Set 𝔞) : ℞ 𝔞 where
-- -- -- leaf : Tree 𝔄
-- -- -- _fork_ : Tree 𝔄 → Tree 𝔄 → Tree 𝔄
-- -- -- variable : 𝔄 → Tree 𝔄
| {
"alphanum_fraction": 0.6251548947,
"avg_line_length": 33.625,
"ext": "agda",
"hexsha": "5f496c95a40402c5bb2c8be45039fb24f83752a0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Base.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Base.agda",
"max_line_length": 209,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2830,
"size": 6456
} |
-- exercises-01-monday.agda
open import Data.Nat
variable
A B C : Set
-- Exercise 1
add3 : ℕ → ℕ
add3 x = x + 3
tw : (A → A) → A → A
tw f n = f (f n) -- tw = λ f n → f (f n)
-- evaluate: "tw tw add3 1"; derive the result (in a comment) step by step
{-
tw tw add3 1 =
= tw (tw add3) 1 =
= (tw add3) (tw add3 1) =
= (tw add3) (add3 (add3 1))
= tw add3 7 =
= add3 (add3 7) =
= 13
-}
-- Exercise 2
-- derive lambda terms with the following types
f₀ : (A → B) → (B → C) → (A → C)
f₀ f g a = g (f a)
f₁ : (A → B) → ((A → C) → C) → ((B → C) → C)
f₁ f g h = g λ a -> h (f a)
f₂ : (A → B → C) → B → A → C
f₂ f b a = f a b
-- Exercise 3
-- derive a function tw-c which behaves the same as tw using only S, K (and I
-- which is defined using S and K below).
K : A → B → A
K = λ a b → a
S : (A → B → C) → (A → B) → A → C
S = λ f g x → f x (g x)
-- I = λ x → x
I : A → A
I {A} = S K (K {B = A})
{-
λ f n → f (f n) =
= λ f → λ n → f (f n) =
= λ f → S (λ n → f) (λ n → f n) =
= λ f → S (K f) f =
= S (λ f → S (K f) (λ f → f) =
= S (S (λ f → S) (λ f → (K f)) I =
= S (S (K S) K) I =
-}
tw-c : (A → A) → A → A
tw-c = S (S (K S) K) I
| {
"alphanum_fraction": 0.4409246575,
"avg_line_length": 17.4328358209,
"ext": "agda",
"hexsha": "3b8af5ba63501576f184f8c91471b6c2573831c7",
"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": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FoxySeta/mgs-2021",
"max_forks_repo_path": "Type Theory/exercises-01-monday.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "FoxySeta/mgs-2021",
"max_issues_repo_path": "Type Theory/exercises-01-monday.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FoxySeta/mgs-2021",
"max_stars_repo_path": "Type Theory/exercises-01-monday.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 546,
"size": 1168
} |
module Issue840a where
------------------------------------------------------------------------
-- Prelude
record ⊤ : Set where
data ⊥ : Set where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
data Bool : Set where
true false : Bool
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
postulate String : Set
{-# BUILTIN STRING String #-}
primitive primStringEquality : String → String → Bool
infixr 4 _,_
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
------------------------------------------------------------------------
-- Other stuff
mutual
infixl 5 _,_∶_
data Signature : Set₁ where
∅ : Signature
_,_∶_ : (Sig : Signature)
(ℓ : String)
(A : Record Sig → Set) →
Signature
record Record (Sig : Signature) : Set where
constructor rec
field fun : Record-fun Sig
Record-fun : Signature → Set
Record-fun ∅ = ⊤
Record-fun (Sig , ℓ ∶ A) = Σ (Record Sig) A
_∈_ : String → Signature → Set
ℓ ∈ ∅ = ⊥
ℓ ∈ (Sig , ℓ′ ∶ A) with primStringEquality ℓ ℓ′
... | true = ⊤
... | false = ℓ ∈ Sig
Restrict : (Sig : Signature) (ℓ : String) → ℓ ∈ Sig → Signature
Restrict ∅ ℓ ()
Restrict (Sig , ℓ′ ∶ A) ℓ ℓ∈ with primStringEquality ℓ ℓ′
... | true = Sig
... | false = Restrict Sig ℓ ℓ∈
Proj : (Sig : Signature) (ℓ : String) {ℓ∈ : ℓ ∈ Sig} →
Record (Restrict Sig ℓ ℓ∈) → Set
Proj ∅ ℓ {}
Proj (Sig , ℓ′ ∶ A) ℓ {ℓ∈} with primStringEquality ℓ ℓ′
... | true = A
... | false = Proj Sig ℓ {ℓ∈}
_∣_ : {Sig : Signature} → Record Sig →
(ℓ : String) {ℓ∈ : ℓ ∈ Sig} → Record (Restrict Sig ℓ ℓ∈)
_∣_ {Sig = ∅} r ℓ {}
_∣_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with primStringEquality ℓ ℓ′
... | true = Σ.proj₁ r
... | false = _∣_ (Σ.proj₁ r) ℓ {ℓ∈}
infixl 5 _·_
_·_ : {Sig : Signature} (r : Record Sig)
(ℓ : String) {ℓ∈ : ℓ ∈ Sig} →
Proj Sig ℓ {ℓ∈} (r ∣ ℓ)
_·_ {Sig = ∅} r ℓ {}
_·_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with primStringEquality ℓ ℓ′
... | true = Σ.proj₂ r
... | false = _·_ (Σ.proj₁ r) ℓ {ℓ∈}
R : Set → Signature
R A = ∅ , "f" ∶ (λ _ → A → A)
, "x" ∶ (λ _ → A)
, "lemma" ∶ (λ r → ∀ y → (r · "f") y ≡ y)
record GS (A B : Set) : Set where
field
get : A → B
set : A → B → A
get-set : ∀ a b → get (set a b) ≡ b
set-get : ∀ a → set a (get a) ≡ a
f : {A : Set} →
GS (Record (R A))
(Record (∅ , "f" ∶ (λ _ → A → A)
, "lemma" ∶ (λ r → ∀ x → (r · "f") x ≡ x)))
f = record
{ set = λ r f-lemma → rec (rec (rec (rec _
, f-lemma · "f")
, r · "x")
, f-lemma · "lemma")
; get-set = λ { (rec (rec (rec (_ , _) , _) , _))
(rec (rec (_ , _) , _)) → refl }
; set-get = λ { (rec (rec (rec (rec _ , _) , _) , _)) → refl }
}
| {
"alphanum_fraction": 0.4480892797,
"avg_line_length": 25.2735042735,
"ext": "agda",
"hexsha": "adfa205c1c9019600de5ef946dcfa148f9e57912",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue840a.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/Issue840a.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/Issue840a.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": 1117,
"size": 2957
} |
open import Relation.Binary.Core
module PLRTree.Insert.Heap {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import Data.Sum
open import Order.Total _≤_ tot≤
open import PLRTree {A}
open import PLRTree.Compound {A}
open import PLRTree.Insert _≤_ tot≤
open import PLRTree.Insert.Properties _≤_ tot≤
open import PLRTree.Heap _≤_
open import PLRTree.Heap.Properties _≤_ trans≤
lemma-insert-≤* : {x y : A}{t : PLRTree} → x ≤ y → x ≤* t → x ≤* insert y t
lemma-insert-≤* {y = y} x≤y (lf≤* x) = nd≤* x≤y (lf≤* x) (lf≤* x)
lemma-insert-≤* {y = y} x≤y (nd≤* {perfect} {x} {z} {l} {r} x≤z x≤*l x≤*r)
with tot≤ y z | l | r
... | inj₁ y≤z | leaf | leaf = nd≤* x≤y (nd≤* x≤z x≤*r x≤*r) x≤*r
... | inj₁ y≤z | node _ _ _ _ | leaf = nd≤* x≤y (lemma-insert-≤* x≤z x≤*l) x≤*r
... | inj₁ y≤z | leaf | node _ _ _ _ = nd≤* x≤y (nd≤* x≤z x≤*l x≤*l) x≤*r
... | inj₁ y≤z | node _ _ _ _ | node _ _ _ _ = nd≤* x≤y (lemma-insert-≤* x≤z x≤*l) x≤*r
... | inj₂ z≤y | leaf | leaf = nd≤* x≤z (nd≤* x≤y x≤*r x≤*r) x≤*r
... | inj₂ z≤y | node _ _ _ _ | leaf = nd≤* x≤z (lemma-insert-≤* x≤y x≤*l) x≤*r
... | inj₂ z≤y | leaf | node _ _ _ _ = nd≤* x≤z (nd≤* x≤y x≤*l x≤*l) x≤*r
... | inj₂ z≤y | node _ _ _ _ | node _ _ _ _ = nd≤* x≤z (lemma-insert-≤* x≤y x≤*l) x≤*r
lemma-insert-≤* {y = y} x≤y (nd≤* {left} {x} {z} {l} {r} x≤z x≤*l x≤*r)
with tot≤ y z
... | inj₁ y≤z
with insert z l | lemma-insert-≤* (trans≤ x≤y y≤z) x≤*l | lemma-insert-compound z l
... | node perfect z' l' r' | x≤*lᵢ | compound = nd≤* x≤y x≤*lᵢ x≤*r
... | node right z' l' r' | x≤*lᵢ | compound = nd≤* x≤y x≤*lᵢ x≤*r
... | node left z' l' r' | x≤*lᵢ | compound = nd≤* x≤y x≤*lᵢ x≤*r
lemma-insert-≤* {y = y} x≤y (nd≤* {left} {x} {z} {l} {r} x≤z x≤*l x≤*r) | inj₂ z≤y
with insert y l | lemma-insert-≤* x≤y x≤*l | lemma-insert-compound y l
... | node perfect y' l' r' | x≤*lᵢ | compound = nd≤* x≤z x≤*lᵢ x≤*r
... | node right y' l' r' | x≤*lᵢ | compound = nd≤* x≤z x≤*lᵢ x≤*r
... | node left y' l' r' | x≤*lᵢ | compound = nd≤* x≤z x≤*lᵢ x≤*r
lemma-insert-≤* {y = y} x≤y (nd≤* {right} {x} {z} {l} {r} x≤z x≤*l x≤*r)
with tot≤ y z
... | inj₁ y≤z
with insert z r | lemma-insert-≤* (trans≤ x≤y y≤z) x≤*r | lemma-insert-compound z r
... | node perfect z' l' r' | x≤*rᵢ | compound = nd≤* x≤y x≤*l x≤*rᵢ
... | node right z' l' r' | x≤*rᵢ | compound = nd≤* x≤y x≤*l x≤*rᵢ
... | node left z' l' r' | x≤*rᵢ | compound = nd≤* x≤y x≤*l x≤*rᵢ
lemma-insert-≤* {y = y} x≤y (nd≤* {right} {x} {z} {l} {r} x≤z x≤*l x≤*r) | inj₂ z≤y
with insert y r | lemma-insert-≤* x≤y x≤*r | lemma-insert-compound y r
... | node perfect y' l' r' | x≤*rᵢ | compound = nd≤* x≤z x≤*l x≤*rᵢ
... | node right y' l' r' | x≤*rᵢ | compound = nd≤* x≤z x≤*l x≤*rᵢ
... | node left y' l' r' | x≤*rᵢ | compound = nd≤* x≤z x≤*l x≤*rᵢ
lemma-insert-≤*' : {x y : A}{t : PLRTree} → x ≤ y → y ≤* t → x ≤* insert y t
lemma-insert-≤*' x≤y y≤*t = lemma-≤-≤* x≤y (lemma-insert-≤* refl≤ y≤*t)
lemma-insert-heap : {t : PLRTree}(x : A) → Heap t → Heap (insert x t)
lemma-insert-heap x leaf = node (lf≤* x) (lf≤* x) leaf leaf
lemma-insert-heap x (node {perfect} {y} {l} {r} y≤*l y≤*r hl hr)
with tot≤ x y | l | r
... | inj₁ x≤y | leaf | leaf = node (nd≤* x≤y (lf≤* x) (lf≤* x)) (lf≤* x) (node (lf≤* y) (lf≤* y) leaf leaf) leaf
... | inj₁ x≤y | node _ _ _ _ | leaf = node (lemma-insert-≤*' x≤y y≤*l) (lf≤* x) (lemma-insert-heap y hl) hr
... | inj₁ x≤y | leaf | node _ _ _ _ = node (nd≤* x≤y (lf≤* x) (lf≤* x)) (lemma-≤-≤* x≤y y≤*r) (node y≤*l y≤*l hl hl) hr
... | inj₁ x≤y | node _ _ _ _ | node _ _ _ _ = node (lemma-insert-≤*' x≤y y≤*l) (lemma-≤-≤* x≤y y≤*r) (lemma-insert-heap y hl) hr
... | inj₂ y≤x | leaf | leaf = node (nd≤* y≤x (lf≤* y) (lf≤* y)) (lf≤* y) (node (lf≤* x) (lf≤* x) leaf leaf) leaf
... | inj₂ y≤x | node _ _ _ _ | leaf = node (lemma-insert-≤* y≤x y≤*l) y≤*r (lemma-insert-heap x hl) hr
... | inj₂ y≤x | leaf | node _ _ _ _ = node (nd≤* y≤x y≤*l y≤*l) y≤*r (lemma-insert-heap x hl) hr
... | inj₂ y≤x | node _ _ _ _ | node _ _ _ _ = node (lemma-insert-≤* y≤x y≤*l) y≤*r (lemma-insert-heap x hl) hr
lemma-insert-heap x (node {left} {y} {l} {r} y≤*l y≤*r hl hr)
with tot≤ x y
... | inj₁ x≤y
with insert y l | lemma-insert-heap y hl | lemma-insert-≤*' x≤y y≤*l | lemma-insert-compound y l
... | node perfect y' l' r' | hlᵢ | x≤*lᵢ | compound = node x≤*lᵢ (lemma-≤-≤* x≤y y≤*r) hlᵢ hr
... | node right y' l' r' | hlᵢ | x≤*lᵢ | compound = node x≤*lᵢ (lemma-≤-≤* x≤y y≤*r) hlᵢ hr
... | node left y' l' r' | hlᵢ | x≤*lᵢ | compound = node x≤*lᵢ (lemma-≤-≤* x≤y y≤*r) hlᵢ hr
lemma-insert-heap x (node {left} {y} {l} {r} y≤*l y≤*r hl hr) | inj₂ y≤x
with insert x l | lemma-insert-heap x hl | lemma-insert-≤* y≤x y≤*l | lemma-insert-compound x l
... | node perfect y' l' r' | hlᵢ | y≤*lᵢ | compound = node y≤*lᵢ y≤*r hlᵢ hr
... | node right y' l' r' | hlᵢ | y≤*lᵢ | compound = node y≤*lᵢ y≤*r hlᵢ hr
... | node left y' l' r' | hlᵢ | y≤*lᵢ | compound = node y≤*lᵢ y≤*r hlᵢ hr
lemma-insert-heap x (node {right} {y} {l} {r} y≤*l y≤*r hl hr)
with tot≤ x y
... | inj₁ x≤y
with insert y r | lemma-insert-heap y hr | lemma-insert-≤*' x≤y y≤*r | lemma-insert-compound y r
... | node perfect y' l' r' | hrᵢ | x≤*rᵢ | compound = node (lemma-≤-≤* x≤y y≤*l) x≤*rᵢ hl hrᵢ
... | node right y' l' r' | hrᵢ | x≤*rᵢ | compound = node (lemma-≤-≤* x≤y y≤*l) x≤*rᵢ hl hrᵢ
... | node left y' l' r' | hrᵢ | x≤*rᵢ | compound = node (lemma-≤-≤* x≤y y≤*l) x≤*rᵢ hl hrᵢ
lemma-insert-heap x (node {right} {y} {l} {r} y≤*l y≤*r hl hr) | inj₂ y≤x
with insert x r | lemma-insert-heap x hr | lemma-insert-≤* y≤x y≤*r | lemma-insert-compound x r
... | node perfect y' l' r' | hrᵢ | y≤*rᵢ | compound = node y≤*l y≤*rᵢ hl hrᵢ
... | node right y' l' r' | hrᵢ | y≤*rᵢ | compound = node y≤*l y≤*rᵢ hl hrᵢ
... | node left y' l' r' | hrᵢ | y≤*rᵢ | compound = node y≤*l y≤*rᵢ hl hrᵢ
| {
"alphanum_fraction": 0.5255758808,
"avg_line_length": 63.4838709677,
"ext": "agda",
"hexsha": "7b9a2ff731578e47c3e897a381bee56374bf23fd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/PLRTree/Insert/Heap.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/PLRTree/Insert/Heap.agda",
"max_line_length": 129,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/PLRTree/Insert/Heap.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 3239,
"size": 5904
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Yoneda where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence using (ua)
open import Cubical.Foundations.Function renaming (_∘_ to _◍_)
open import Cubical.Data.Sigma
open import Cubical.Foundations.Equiv
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Categories.Category
open import Cubical.Categories.Instances.Sets
open import Cubical.Categories.Instances.Functors
open import Cubical.Categories.NaturalTransformation
open import Cubical.Categories.Functor
open import Cubical.Categories.Presheaf
private
variable
ℓ ℓ' ℓ'' : Level
-- THE YONEDA LEMMA
open NatTrans
open NatTransP
open Functor
open Iso
module _ (A B : Type ℓ) (f : A → B) where
isInj = ∀ (x y : A) → (f x ≡ f y) → x ≡ y
isSurj = ∀ (b : B) → Σ[ a ∈ A ] f a ≡ b
bijectionToIso : isInj × isSurj
→ isIso f
bijectionToIso (i , s) = (λ b → fst (s b)) , (λ b → snd (s b)) , λ a → i (fst (s (f a))) a (snd (s (f a)))
module _ {C : Precategory ℓ ℓ'} ⦃ isCatC : isCategory C ⦄ where
open Precategory
yoneda : (F : Functor C (SET ℓ'))
→ (c : C .ob)
→ Iso ((FUNCTOR C (SET ℓ')) [ C [ c ,-] , F ]) (fst (F ⟅ c ⟆))
yoneda F c = theIso
where
natType = (FUNCTOR C (SET ℓ')) [ C [ c ,-] , F ]
setType = fst (F ⟅ c ⟆)
-- takes a natural transformation to what it does on id
ϕ : natType → setType
ϕ α = (α ⟦ _ ⟧) (C .id c)
-- takes an element x of F c and sends it to the (only) natural transformation
-- which takes the identity to x
Ψ : setType → natType
Ψ x .N-ob c = λ f → (F ⟪ f ⟫) x
Ψ x .N-hom g
= funExt (λ f → (F ⟪ f ⋆⟨ C ⟩ g ⟫) x
≡[ i ]⟨ (F .F-seq f g) i x ⟩
(F ⟪ g ⟫) ((F ⟪ f ⟫) x)
∎)
theIso : Iso natType setType
theIso .fun = ϕ
theIso .inv = Ψ
theIso .rightInv x i = F .F-id i x
theIso .leftInv α@(natTrans αo αh) = NatTrans-≡-intro (sym αo≡βo) (symP αh≡βh)
where
β = Ψ (ϕ α)
βo = β .N-ob
βh = β .N-hom
-- equivalence of action on objects follows
-- from simple equational reasoning using naturality
αo≡βo : αo ≡ βo
αo≡βo = funExt λ x → funExt λ f
→ αo x f
≡[ i ]⟨ αo x (C .⋆IdL f (~ i)) ⟩ -- expand into the bottom left of the naturality diagram
αo x (C .id c ⋆⟨ C ⟩ f)
≡[ i ]⟨ αh f i (C .id c) ⟩ -- apply naturality
(F ⟪ f ⟫) ((αo _) (C .id c))
∎
-- type aliases for natural transformation
NOType = N-ob-Type (C [ c ,-]) F
NHType = N-hom-Type (C [ c ,-]) F
-- equivalence of commutative squares follows from SET being a Category
αh≡βh : PathP (λ i → NHType (αo≡βo i)) αh βh -- αh βh
αh≡βh = isPropHomP αh βh αo≡βo
where
isProp-hom : ⦃ isCatSET : isCategory (SET ℓ') ⦄ → (ϕ : NOType) → isProp (NHType ϕ)
isProp-hom ⦃ isCatSET ⦄ γ = isPropImplicitΠ λ x
→ isPropImplicitΠ λ y
→ isPropΠ λ f
→ isCatSET .isSetHom {x = (C [ c , x ]) , (isCatC .isSetHom)} {F ⟅ y ⟆} _ _
isPropHomP : isOfHLevelDep 1 (λ ηo → NHType ηo)
isPropHomP = isOfHLevel→isOfHLevelDep 1 λ a → isProp-hom a
-- Naturality of the bijection
-- in the functor
-- it's equivalent to apply ϕ to α then do β ⟦ c ⟧
-- or apply ϕ the the composite nat trans α ◍ β
-- where ϕ takes a natural transformation to its representing element
yonedaIsNaturalInFunctor : ∀ {F G : Functor C (SET ℓ')} (c : C .ob)
→ (β : F ⇒ G)
→ (fun (yoneda G c) ◍ compTrans β) ≡ (β ⟦ c ⟧ ◍ fun (yoneda F c))
yonedaIsNaturalInFunctor {F = F} {G} c β = funExt λ α → refl
-- in the object
-- it's equivalent to apply ϕ and then F ⟪ f ⟫
-- or to apply ϕ to the natural transformation obtained by precomposing with f
yonedaIsNaturalInOb : ∀ {F : Functor C (SET ℓ')}
→ (c c' : C .ob)
→ (f : C [ c , c' ])
→ yoneda F c' .fun ◍ preComp f ≡ F ⟪ f ⟫ ◍ yoneda F c .fun
yonedaIsNaturalInOb {F = F} c c' f = funExt (λ α
→ (yoneda F c' .fun ◍ preComp f) α
≡⟨ refl ⟩
(α ⟦ c' ⟧) (f ⋆⟨ C ⟩ C .id c')
≡[ i ]⟨ (α ⟦ c' ⟧) (C .⋆IdR f i) ⟩
(α ⟦ c' ⟧) f
≡[ i ]⟨ (α ⟦ c' ⟧) (C .⋆IdL f (~ i)) ⟩
(α ⟦ c' ⟧) (C .id c ⋆⟨ C ⟩ f)
≡[ i ]⟨ (α .N-hom f i) (C .id c) ⟩
(F ⟪ f ⟫) ((α ⟦ c ⟧) (C .id c))
≡⟨ refl ⟩
((F ⟪ f ⟫) ◍ yoneda F c .fun) α
∎)
-- Yoneda embedding
-- TODO: probably want to rename/refactor
module _ {C : Precategory ℓ ℓ} ⦃ C-cat : isCategory C ⦄ where
open Functor
open NatTrans
open Precategory C
yo : ob → Functor (C ^op) (SET ℓ)
yo x .F-ob y .fst = C [ y , x ]
yo x .F-ob y .snd = C-cat .isSetHom
yo x .F-hom f g = f ⋆⟨ C ⟩ g
yo x .F-id i f = ⋆IdL f i
yo x .F-seq f g i h = ⋆Assoc g f h i
YO : Functor C (PreShv C ℓ)
YO .F-ob = yo
YO .F-hom f .N-ob z g = g ⋆⟨ C ⟩ f
YO .F-hom f .N-hom g i h = ⋆Assoc g h f i
YO .F-id = makeNatTransPath λ i _ → λ f → ⋆IdR f i
YO .F-seq f g = makeNatTransPath λ i _ → λ h → ⋆Assoc h f g (~ i)
module _ {x} (F : Functor (C ^op) (SET ℓ)) where
yo-yo-yo : NatTrans (yo x) F → F .F-ob x .fst
yo-yo-yo α = α .N-ob _ (id _)
no-no-no : F .F-ob x .fst → NatTrans (yo x) F
no-no-no a .N-ob y f = F .F-hom f a
no-no-no a .N-hom f = funExt λ g i → F .F-seq g f i a
yoIso : Iso (NatTrans (yo x) F) (F .F-ob x .fst)
yoIso .Iso.fun = yo-yo-yo
yoIso .Iso.inv = no-no-no
yoIso .Iso.rightInv b i = F .F-id i b
yoIso .Iso.leftInv a = makeNatTransPath (funExt λ _ → funExt rem)
where
rem : ∀ {z} (x₁ : C [ z , x ]) → F .F-hom x₁ (yo-yo-yo a) ≡ (a .N-ob z) x₁
rem g =
F .F-hom g (yo-yo-yo a)
≡[ i ]⟨ a .N-hom g (~ i) (id x) ⟩
a .N-hom g i0 (id x)
≡[ i ]⟨ a .N-ob _ (⋆IdR g i) ⟩
(a .N-ob _) g
∎
yoEquiv : NatTrans (yo x) F ≃ F .F-ob x .fst
yoEquiv = isoToEquiv yoIso
isFullYO : isFull YO
isFullYO x y F[f] = ∣ yo-yo-yo _ F[f] , yoIso {x} (yo y) .Iso.leftInv F[f] ∣
isFaithfulYO : isFaithful YO
isFaithfulYO x y f g p i =
hcomp
(λ j → λ{ (i = i0) → ⋆IdL f j; (i = i1) → ⋆IdL g j})
(yo-yo-yo _ (p i))
| {
"alphanum_fraction": 0.4936164108,
"avg_line_length": 36.1191709845,
"ext": "agda",
"hexsha": "70c58bc9f8d153a532676fd3c245caea4fee5a9e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/Categories/Yoneda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/Categories/Yoneda.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/Categories/Yoneda.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2602,
"size": 6971
} |
open import Relation.Binary.Core
module PLRTree.Push.Complete {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.Sum
open import Induction.WellFounded
open import PLRTree {A}
open import PLRTree.Drop _≤_ tot≤
open import PLRTree.Complete {A}
open import PLRTree.Equality {A}
open import PLRTree.Equality.Properties {A}
open import PLRTree.Order {A}
open import PLRTree.Order.Properties {A}
mutual
lemma-≃-push : {t t' : PLRTree} → t ≃ t' → (acc : Acc _≺_ t) → t ≃ push t acc
lemma-≃-push ≃lf _ = ≃lf
lemma-≃-push (≃nd x x' ≃lf ≃lf ≃lf) _ = ≃nd x x ≃lf ≃lf ≃lf
lemma-≃-push (≃nd x x' (≃nd {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'≃r' (≃nd .x₁ x'₁ _ l'₁≃r'₁ l₁≃l'₁)) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ =
let l₁≃l₁ = lemma-≃-≃ l₁≃r₁
in ≃nd x x (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) (≃nd x₁ x₁ l₁≃r₁ l₁≃r₁ l₁≃l₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂ ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂ ;
x₁l₁r₁≃x₁l₁r₁ = lemma-≃-≃ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)
in ≃nd x x₂ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) x₁l₁r₁≃push-xl₂r₂ x₁l₁r₁≃x₁l₁r₁
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
l₁≃l₁ = lemma-≃-≃ l₁≃r₁ ;
x₁l₁r₁≃xl₁r₁ = ≃nd x₁ x l₁≃r₁ l₁≃r₁ l₁≃l₁ ;
xl₁r₁≃push-xl₁r₁ = lemma-≃-push (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁ ;
x₁l₁r₁≃push-xl₁r₁ = trans≃ x₁l₁r₁≃xl₁r₁ xl₁r₁≃push-xl₁r₁
in ≃nd x x₁ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂ x₁l₁r₁≃push-xl₁r₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
l₁≃l₁ = lemma-≃-≃ l₁≃r₁ ;
x₁l₁r₁≃xl₁r₁ = ≃nd x₁ x l₁≃r₁ l₁≃r₁ l₁≃l₁ ;
xl₁r₁≃push-xl₁r₁ = lemma-≃-push (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁ ;
x₁l₁r₁≃push-xl₁r₁ = trans≃ x₁l₁r₁≃xl₁r₁ xl₁r₁≃push-xl₁r₁
in ≃nd x x₁ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂ x₁l₁r₁≃push-xl₁r₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂ ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂ ;
x₁l₁r₁≃x₁l₁r₁ = lemma-≃-≃ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)
in ≃nd x x₂ (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) x₁l₁r₁≃push-xl₂r₂ x₁l₁r₁≃x₁l₁r₁
lemma-push-≃ : {t t' : PLRTree} → t ≃ t' → (acc : Acc _≺_ t) → push t acc ≃ t
lemma-push-≃ t≃t' at = sym≃ (lemma-≃-push t≃t' at)
lemma-push-⋗ : {t t' : PLRTree} → t ⋗ t' → (acc : Acc _≺_ t) → push t acc ⋗ t'
lemma-push-⋗ (⋗lf x) _ = ⋗lf x
lemma-push-⋗ (⋗nd _ _ ≃lf _ ()) _
lemma-push-⋗ (⋗nd x x' (≃nd x₁ x₂ ≃lf ≃lf ≃lf) ≃lf (⋗lf .x₁)) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = ⋗nd x x' (≃nd x₁ x₂ ≃lf ≃lf ≃lf) ≃lf (⋗lf x₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ = ⋗nd x₂ x' (≃nd x₁ x ≃lf ≃lf ≃lf) ≃lf (⋗lf x₁)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ = ⋗nd x₁ x' (≃nd x x₂ ≃lf ≃lf ≃lf) ≃lf (⋗lf x)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ = ⋗nd x₁ x' (≃nd x x₂ ≃lf ≃lf ≃lf) ≃lf (⋗lf x)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ = ⋗nd x₂ x' (≃nd x₁ x ≃lf ≃lf ≃lf) ≃lf (⋗lf x₁)
lemma-push-⋗ (⋗nd _ _ (≃nd x₁ _ ≃lf (≃nd _ _ _ _ _) ()) ≃lf (⋗lf .x₁)) _
lemma-push-⋗ (⋗nd x x' (≃nd {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'≃r' (⋗nd .x₁ x'₁ _ l'₁≃r'₁ l₁⋗l'₁)) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = ⋗nd x x' (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂ ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂
in ⋗nd x₂ x' x₁l₁r₁≃push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in ⋗nd x₁ x' push-xl₁r₁≃x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in ⋗nd x₁ x' push-xl₁r₁≃x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂ ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) push-xl₁r₁≃x₂l₂r₂
in ⋗nd x₂ x' x₁l₁r₁≃push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-⋗-push : {t t' : PLRTree} → t ⋗ t' → (acc : Acc _≺_ t') → t ⋗ push t' acc
lemma-⋗-push (⋗lf x) _ = ⋗lf x
lemma-⋗-push (⋗nd x x' l≃r ≃lf l⋗l') _ = ⋗nd x x' l≃r ≃lf l⋗l'
lemma-⋗-push (⋗nd x x' l≃r (≃nd {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (⋗nd x₁ .x'₁ l₁≃r₁ _ l₁⋗l'₁)) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋗nd x x' l≃r (≃nd x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in ⋗nd x x'₂ l≃r x'₁l'₁r'₁≃push-x'l'₂r'₂ (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) ;
x₁l₁r₁⋗push-x'l'₁r'₁ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-x'l'₁r'₁
in ⋗nd x x'₁ l≃r push-x'l'₁r'₁≃x'₂l'₂r'₂ x₁l₁r₁⋗push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) ;
x₁l₁r₁⋗push-x'l'₁r'₁ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-x'l'₁r'₁
in ⋗nd x x'₁ l≃r push-x'l'₁r'₁≃x'₂l'₂r'₂ x₁l₁r₁⋗push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in ⋗nd x x'₂ l≃r x'₁l'₁r'₁≃push-x'l'₂r'₂ (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-⋘-push : {t t' : PLRTree} → t ⋘ t' → (acc : Acc _≺_ t') → t ⋘ push t' acc
lemma-⋘-push (x⋘ x y z) _ = x⋘ x y z
lemma-⋘-push (l⋘ _ _ () ≃lf ≃lf) _
lemma-⋘-push (l⋘ x x' l⋘r (≃nd {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (≃nd x₂ .x'₁ l₂≃r₂ _ l₂≃l'₁)) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = l⋘ x x' l⋘r (≃nd x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ l₂≃l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in l⋘ x x'₂ l⋘r x'₁l'₁r'₁≃push-x'l'₂r'₂ (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ l₂≃l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) ;
x₂l₂r₂≃push-x'l'₁r'₁ = trans≃ (≃nd x₂ x' l₂≃r₂ l'₁≃r'₁ l₂≃l'₁) (lemma-≃-push (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁)
in l⋘ x x'₁ l⋘r push-x'l'₁r'₁≃x'₂l'₂r'₂ x₂l₂r₂≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) ;
x₂l₂r₂≃push-x'l'₁r'₁ = trans≃ (≃nd x₂ x' l₂≃r₂ l'₁≃r'₁ l₂≃l'₁) (lemma-≃-push (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁)
in l⋘ x x'₁ l⋘r push-x'l'₁r'₁≃x'₂l'₂r'₂ x₂l₂r₂≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in l⋘ x x'₂ l⋘r x'₁l'₁r'₁≃push-x'l'₂r'₂ (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ l₂≃l'₁)
lemma-⋘-push (r⋘ x x' l⋙r ≃lf (⋗lf x₁)) _ = r⋘ x x' l⋙r ≃lf (⋗lf x₁)
lemma-⋘-push (r⋘ x x' l⋙r (≃nd {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (⋗nd x₁ .x'₁ l₁≃r₁ _ l₁⋗l'₁)) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = r⋘ x x' l⋙r (≃nd x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in r⋘ x x'₂ l⋙r x'₁l'₁r'₁≃push-x'l'₂r'₂ (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)
in r⋘ x x'₁ l⋙r push-x'l'₁r'₁≃x'₂l'₂r'₂ (lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-x'l'₁r'₁)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁≃x'₂l'₂r'₂ = trans≃ (lemma-push-≃ (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) acc-x'l'₁r'₁) (≃nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)
in r⋘ x x'₁ l⋙r push-x'l'₁r'₁≃x'₂l'₂r'₂ (lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-x'l'₁r'₁)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right perfect x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁≃push-x'l'₂r'₂ = trans≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂) (lemma-≃-push (sym≃ (≃nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁≃l'₂)) acc-x'l'₂r'₂)
in r⋘ x x'₂ l⋙r x'₁l'₁r'₁≃push-x'l'₂r'₂ (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-push-⋙ : {t t' : PLRTree} → t ⋙ t' → (acc : Acc _≺_ t) → push t acc ⋙ t'
lemma-push-⋙ (⋙p l⋗r) (acc rs) = ⋙p (lemma-push-⋗ l⋗r (acc rs))
lemma-push-⋙ (⋙l _ _ ≃lf _ ()) _
lemma-push-⋙ (⋙l _ _ (≃nd x₁ _ ≃lf _ _) () (⋗lf .x₁)) _
lemma-push-⋙ (⋙l x x' (≃nd {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'⋘r' (⋗nd .x₁ x₄ _ l₄≃r₄ l₁⋗r₄)) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = ⋙l x x' (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'⋘r' (⋗nd x₁ x₄ l₁≃r₁ l₄≃r₄ l₁⋗r₄)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) (lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂)
in ⋙l x₂ x' x₁l₁r₁≃push-xl₂r₂ l'⋘r' (⋗nd x₁ x₄ l₁≃r₁ l₄≃r₄ l₁⋗r₄)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)
in ⋙l x₁ x' push-xl₁r₁≃x₂l₂r₂ l'⋘r' (lemma-push-⋗ (⋗nd x x₄ l₁≃r₁ l₄≃r₄ l₁⋗r₄) acc-xl₁r₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)
in ⋙l x₁ x' push-xl₁r₁≃x₂l₂r₂ l'⋘r' (lemma-push-⋗ (⋗nd x x₄ l₁≃r₁ l₄≃r₄ l₁⋗r₄) acc-xl₁r₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) (lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂)
in ⋙l x₂ x' x₁l₁r₁≃push-xl₂r₂ l'⋘r' (⋗nd x₁ x₄ l₁≃r₁ l₄≃r₄ l₁⋗r₄)
lemma-push-⋙ (⋙r _ _ ≃lf (⋙p ()) ≃lf) _
lemma-push-⋙ (⋙r x x' (≃nd {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'⋙r' (≃nd .x₁ x₃ _ l₃≃r₃ l₁≃l₃)) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = ⋙r x x' (≃nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) l'⋙r' (≃nd x₁ x₃ l₁≃r₁ l₃≃r₃ l₁≃l₃)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) (lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂)
in ⋙r x₂ x' x₁l₁r₁≃push-xl₂r₂ l'⋙r' (≃nd x₁ x₃ l₁≃r₁ l₃≃r₃ l₁≃l₃)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
push-xl₁r₁≃x₃l₃r₃ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₃ l₁≃r₁ l₃≃r₃ l₁≃l₃)
in ⋙r x₁ x' push-xl₁r₁≃x₂l₂r₂ l'⋙r' push-xl₁r₁≃x₃l₃r₃
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁≃x₂l₂r₂ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) ;
push-xl₁r₁≃x₃l₃r₃ = trans≃ (lemma-push-≃ (≃nd x x₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) acc-xl₁r₁) (≃nd x x₃ l₁≃r₁ l₃≃r₃ l₁≃l₃)
in ⋙r x₁ x' push-xl₁r₁≃x₂l₂r₂ l'⋙r' push-xl₁r₁≃x₃l₃r₃
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁≃push-xl₂r₂ = trans≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂) (lemma-≃-push (sym≃ (≃nd x₁ x l₁≃r₁ l₂≃r₂ l₁≃l₂)) acc-xl₂r₂)
in ⋙r x₂ x' x₁l₁r₁≃push-xl₂r₂ l'⋙r' (≃nd x₁ x₃ l₁≃r₁ l₃≃r₃ l₁≃l₃)
mutual
lemma-⋙r-push : {l r l' r' : PLRTree}(x x' : A) → l ≃ r → l' ⋙ r' → l ≃ l' → (acc : Acc _≺_ (node right x' l' r')) → (node perfect x l r) ⋙ push (node right x' l' r') acc
lemma-⋙r-push x x' l≃r (⋙p (⋗lf x'₁)) (≃nd x₁ .x'₁ ≃lf ≃lf ≃lf) (acc rs)
with tot≤ x' x'₁
... | inj₁ x'≤x'₁ = ⋙r x x' l≃r (⋙p (⋗lf x'₁)) (≃nd x₁ x'₁ ≃lf ≃lf ≃lf)
... | inj₂ x'₁≤x' = ⋙r x x'₁ l≃r (⋙p (⋗lf x')) (≃nd x₁ x' ≃lf ≃lf ≃lf)
lemma-⋙r-push x x' l≃r (⋙p (⋗nd {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂)) (≃nd x₁ .x'₁ l₁≃r₁ _ l₁≃l'₁) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋙r x x' l≃r (⋙p (⋗nd x'₁ x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂)) (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r (⋙p x'₁l'₁r'₁⋗push-x'l'₂r'₂) (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋗x'₂l'₂r'₂ = lemma-push-⋗ (⋗nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r (⋙p push-x'l'₁r'₁⋗x'₂l'₂r'₂) x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋗x'₂l'₂r'₂ = lemma-push-⋗ (⋗nd x' x'₂ l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r (⋙p push-x'l'₁r'₁⋗x'₂l'₂r'₂) x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x'₁ x' l'₁≃r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r (⋙p x'₁l'₁r'₁⋗push-x'l'₂r'₂) (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
lemma-⋙r-push x x' l≃r (⋙l {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂) (≃nd x₁ .x'₁ l₁≃r₁ _ l₁≃l'₁) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋙r x x' l≃r (⋙l x'₁ x'₂ l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂) (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height left x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node left x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node left x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋙push-x'l'₂r'₂ = lemma-⋙l-push x'₁ x' l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂ acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r x'₁l'₁r'₁⋙push-x'l'₂r'₂ (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node left x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋙x'₂l'₂r'₂ = lemma-push-⋙ (⋙l x' x'₂ l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r push-x'l'₁r'₁⋙x'₂l'₂r'₂ x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node left x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋙x'₂l'₂r'₂ = lemma-push-⋙ (⋙l x' x'₂ l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r push-x'l'₁r'₁⋙x'₂l'₂r'₂ x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height left x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node left x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node left x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋙push-x'l'₂r'₂ = lemma-⋙l-push x'₁ x' l'₁≃r'₁ l'₂⋘r'₂ l'₁⋗r'₂ acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r x'₁l'₁r'₁⋙push-x'l'₂r'₂ (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
lemma-⋙r-push x x' l≃r (⋙r {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂) (≃nd x₁ .x'₁ l₁≃r₁ _ l₁≃l'₁) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋙r x x' l≃r (⋙r x'₁ x'₂ l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂) (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height right x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node right x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node right x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋙push-x'l'₂r'₂ = lemma-⋙r-push x'₁ x' l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂ acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r x'₁l'₁r'₁⋙push-x'l'₂r'₂ (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node right x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋙x'₂l'₂r'₂ = lemma-push-⋙ (⋙r x' x'₂ l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r push-x'l'₁r'₁⋙x'₂l'₂r'₂ x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height perfect x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node perfect x' l'₁ r'₁) (lemma-≺-left right x' (node perfect x'₁ l'₁ r'₁) (node right x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋙x'₂l'₂r'₂ = lemma-push-⋙ (⋙r x' x'₂ l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂) acc-x'l'₁r'₁ ;
x₁l₁r₁≃push-x'l'₁r'₁ = trans≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁) (lemma-≃-push (sym≃ (≃nd x₁ x' l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)) acc-x'l'₁r'₁)
in ⋙r x x'₁ l≃r push-x'l'₁r'₁⋙x'₂l'₂r'₂ x₁l₁r₁≃push-x'l'₁r'₁
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height right x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node right x' l'₂ r'₂) (lemma-≺-right right x' (node perfect x'₁ l'₁ r'₁) (node right x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋙push-x'l'₂r'₂ = lemma-⋙r-push x'₁ x' l'₁≃r'₁ l'₂⋙r'₂ l'₁≃l'₂ acc-x'l'₂r'₂
in ⋙r x x'₂ l≃r x'₁l'₁r'₁⋙push-x'l'₂r'₂ (≃nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁≃l'₁)
lemma-push-l⋘ : {l r l' r' : PLRTree}(x x' : A) → l ⋘ r → l' ≃ r' → r ≃ l' → (acc : Acc _≺_ (node left x l r)) → push (node left x l r) acc ⋘ node perfect x' l' r'
lemma-push-l⋘ x x' (x⋘ x₁ x₂ x₃) l'≃r' (≃nd .x₃ x'₁ ≃lf ≃lf ≃lf) (acc rs)
with tot≤ x x₁ | tot≤ x x₃ | tot≤ x₁ x₃
... | inj₁ x≤x₁ | inj₁ x≤x₃ | _ = l⋘ x x' (x⋘ x₁ x₂ x₃) l'≃r' (≃nd x₃ x'₁ ≃lf ≃lf ≃lf)
... | inj₁ x≤x₁ | inj₂ x₃≤x | _ = l⋘ x₃ x' (x⋘ x₁ x₂ x) l'≃r' (≃nd x x'₁ ≃lf ≃lf ≃lf)
... | inj₂ x₁≤x | inj₁ x≤x₃ | _
with tot≤ x x₂
... | inj₁ x≤x₂ = l⋘ x₁ x' (x⋘ x x₂ x₃) l'≃r' (≃nd x₃ x'₁ ≃lf ≃lf ≃lf)
... | inj₂ x₂≤x = l⋘ x₁ x' (x⋘ x₂ x x₃) l'≃r' (≃nd x₃ x'₁ ≃lf ≃lf ≃lf)
lemma-push-l⋘ x x' (x⋘ x₁ x₂ x₃) l'≃r' (≃nd .x₃ x'₁ ≃lf ≃lf ≃lf) (acc rs) | inj₂ x₁≤x | inj₂ x₃≤x | inj₁ x₁≤x₃
with tot≤ x x₂
... | inj₁ x≤x₂ = l⋘ x₁ x' (x⋘ x x₂ x₃) l'≃r' (≃nd x₃ x'₁ ≃lf ≃lf ≃lf)
... | inj₂ x₂≤x = l⋘ x₁ x' (x⋘ x₂ x x₃) l'≃r' (≃nd x₃ x'₁ ≃lf ≃lf ≃lf)
lemma-push-l⋘ x x' (x⋘ x₁ x₂ x₃) l'≃r' (≃nd .x₃ x'₁ ≃lf ≃lf ≃lf) (acc rs) | inj₂ x₁≤x | inj₂ x₃≤x | inj₂ x₃≤x₁ = l⋘ x₃ x' (x⋘ x₁ x₂ x) l'≃r' (≃nd x x'₁ ≃lf ≃lf ≃lf)
lemma-push-l⋘ x x' (l⋘ {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁⋘r₁ l₂≃r₂ r₁≃l₂) l'≃r' (≃nd .x₂ x'₁ _ l'₁≃r'₁ r₂≃l'₁) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = l⋘ x x' (l⋘ x₁ x₂ l₁⋘r₁ l₂≃r₂ r₁≃l₂) l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right left x (node left x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋘push-xl₂r₂ = lemma-⋘-push (l⋘ x₁ x l₁⋘r₁ l₂≃r₂ r₁≃l₂) acc-xl₂r₂ ;
push-xl₂r₂≃x'₁l'₁r'₁ = trans≃ (lemma-push-≃ (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁) acc-xl₂r₂) (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
in l⋘ x₂ x' x₁l₁r₁⋘push-xl₂r₂ l'≃r' push-xl₂r₂≃x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height left x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node left x l₁ r₁) (lemma-≺-left left x (node left x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋘x₂l₂r₂ = lemma-push-l⋘ x x₂ l₁⋘r₁ l₂≃r₂ r₁≃l₂ acc-xl₁r₁
in l⋘ x₁ x' push-xl₁r₁⋘x₂l₂r₂ l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height left x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node left x l₁ r₁) (lemma-≺-left left x (node left x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋘x₂l₂r₂ = lemma-push-l⋘ x x₂ l₁⋘r₁ l₂≃r₂ r₁≃l₂ acc-xl₁r₁
in l⋘ x₁ x' push-xl₁r₁⋘x₂l₂r₂ l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right left x (node left x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋘push-xl₂r₂ = lemma-⋘-push (l⋘ x₁ x l₁⋘r₁ l₂≃r₂ r₁≃l₂) acc-xl₂r₂ ;
push-xl₂r₂≃x'₁l'₁r'₁ = trans≃ (lemma-push-≃ (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁) acc-xl₂r₂) (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
in l⋘ x₂ x' x₁l₁r₁⋘push-xl₂r₂ l'≃r' push-xl₂r₂≃x'₁l'₁r'₁
lemma-push-l⋘ x x' (r⋘ {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁⋙r₁ l₂≃r₂ l₁⋗l₂) l'≃r' (≃nd .x₂ x'₁ _ l'₁≃r'₁ r₂≃l'₁) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = l⋘ x x' (r⋘ x₁ x₂ l₁⋙r₁ l₂≃r₂ l₁⋗l₂) l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right left x (node right x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋘push-xl₂r₂ = lemma-⋘-push (r⋘ x₁ x l₁⋙r₁ l₂≃r₂ l₁⋗l₂) acc-xl₂r₂ ;
push-xl₂r₂≃x'₁l'₁r'₁ = trans≃ (lemma-push-≃ (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁) acc-xl₂r₂) (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
in l⋘ x₂ x' x₁l₁r₁⋘push-xl₂r₂ l'≃r' push-xl₂r₂≃x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height right x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node right x l₁ r₁) (lemma-≺-left left x (node right x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋘x₂l₂r₂ = lemma-push-r⋘ x x₂ l₁⋙r₁ l₂≃r₂ l₁⋗l₂ acc-xl₁r₁
in l⋘ x₁ x' push-xl₁r₁⋘x₂l₂r₂ l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height right x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node right x l₁ r₁) (lemma-≺-left left x (node right x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋘x₂l₂r₂ = lemma-push-r⋘ x x₂ l₁⋙r₁ l₂≃r₂ l₁⋗l₂ acc-xl₁r₁
in l⋘ x₁ x' push-xl₁r₁⋘x₂l₂r₂ l'≃r' (≃nd x₂ x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right left x (node right x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋘push-xl₂r₂ = lemma-⋘-push (r⋘ x₁ x l₁⋙r₁ l₂≃r₂ l₁⋗l₂) acc-xl₂r₂ ;
push-xl₂r₂≃x'₁l'₁r'₁ = trans≃ (lemma-push-≃ (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁) acc-xl₂r₂) (≃nd x x'₁ l₂≃r₂ l'₁≃r'₁ r₂≃l'₁)
in l⋘ x₂ x' x₁l₁r₁⋘push-xl₂r₂ l'≃r' push-xl₂r₂≃x'₁l'₁r'₁
lemma-push-r⋘ : {l r l' r' : PLRTree}(x x' : A) → l ⋙ r → l' ≃ r' → l ⋗ l' → (acc : Acc _≺_ (node right x l r)) → push (node right x l r) acc ⋘ node perfect x' l' r'
lemma-push-r⋘ x x' (⋙p (⋗lf x₁)) ≃lf (⋗lf .x₁) (acc rs)
with tot≤ x x₁
... | inj₁ x≤x₁ = x⋘ x x₁ x'
... | inj₂ x₁≤x = x⋘ x₁ x x'
lemma-push-r⋘ _ _ (⋙p (⋗lf x₁)) _ (⋗nd .x₁ _ _ _ ()) _
lemma-push-r⋘ _ _ (⋙p (⋗nd x₁ _ _ _ ())) ≃lf (⋗lf .x₁) _
lemma-push-r⋘ x x' (⋙p (⋗nd {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂≃r₂ l₁⋗l₂)) l'≃r' (⋗nd .x₁ x'₁ _ l'₁≃r'₁ l₁⋗l'₁) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = r⋘ x x' (⋙p (⋗nd x₁ x₂ l₁≃r₁ l₂≃r₂ l₁⋗l₂)) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋗push-xl₂r₂ = lemma-⋗-push (⋗nd x₁ x l₁≃r₁ l₂≃r₂ l₁⋗l₂) acc-xl₂r₂
in r⋘ x₂ x' (⋙p x₁l₁r₁⋗push-xl₂r₂) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋗x₂l₂r₂ = lemma-push-⋗ (⋗nd x x₂ l₁≃r₁ l₂≃r₂ l₁⋗l₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' (⋙p push-xl₁r₁⋗x₂l₂r₂) l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
push-xl₁r₁⋗x₂l₂r₂ = lemma-push-⋗ (⋗nd x x₂ l₁≃r₁ l₂≃r₂ l₁⋗l₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' (⋙p push-xl₁r₁⋗x₂l₂r₂) l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height perfect x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node perfect x l₂ r₂) (lemma-≺-right perfect x (node perfect x₁ l₁ r₁) (node perfect x₂ l₂ r₂)) ;
x₁l₁r₁⋗push-xl₂r₂ = lemma-⋗-push (⋗nd x₁ x l₁≃r₁ l₂≃r₂ l₁⋗l₂) acc-xl₂r₂
in r⋘ x₂ x' (⋙p x₁l₁r₁⋗push-xl₂r₂) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-push-r⋘ _ _ (⋙l x₁ _ _ _ ()) _ (⋗lf .x₁) _
lemma-push-r⋘ x x' (⋙l {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) l'≃r' (⋗nd .x₁ x'₁ _ l'₁≃r'₁ l₁⋗l'₁) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = r⋘ x x' (⋙l x₁ x₂ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height left x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node left x l₂ r₂) (lemma-≺-right right x (node perfect x₁ l₁ r₁) (node left x₂ l₂ r₂)) ;
x₁l₁r₁⋙push-xl₂r₂ = lemma-⋙l-push x₁ x l₁≃r₁ l₂⋘r₂ l₁⋗r₂ acc-xl₂r₂
in r⋘ x₂ x' x₁l₁r₁⋙push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left right x (node perfect x₁ l₁ r₁) (node left x₂ l₂ r₂)) ;
push-xl₁r₁⋙x₂l₂r₂ = lemma-push-⋙ (⋙l x x₂ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' push-xl₁r₁⋙x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left right x (node perfect x₁ l₁ r₁) (node left x₂ l₂ r₂)) ;
push-xl₁r₁⋙x₂l₂r₂ = lemma-push-⋙ (⋙l x x₂ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' push-xl₁r₁⋙x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height left x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node left x l₂ r₂) (lemma-≺-right right x (node perfect x₁ l₁ r₁) (node left x₂ l₂ r₂)) ;
x₁l₁r₁⋙push-xl₂r₂ = lemma-⋙l-push x₁ x l₁≃r₁ l₂⋘r₂ l₁⋗r₂ acc-xl₂r₂
in r⋘ x₂ x' x₁l₁r₁⋙push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-push-r⋘ _ _ (⋙r x₁ _ ≃lf (⋙p ()) ≃lf) ≃lf (⋗lf .x₁) _
lemma-push-r⋘ _ _ (⋙r x₁ x₂ ≃lf (⋙l _ _ _ _ _) ()) ≃lf (⋗lf .x₁) _
lemma-push-r⋘ _ _ (⋙r x₁ x₂ ≃lf (⋙r _ _ _ _ _) ()) ≃lf (⋗lf .x₁) _
lemma-push-r⋘ x x' (⋙r {l₁} {r₁} {l₂} {r₂} x₁ x₂ l₁≃r₁ l₂⋙r₂ l₁≃l₂) l'≃r' (⋗nd .x₁ x'₁ _ l'₁≃r'₁ l₁⋗l'₁) (acc rs)
with tot≤ x x₁ | tot≤ x x₂ | tot≤ x₁ x₂
... | inj₁ x≤x₁ | inj₁ x≤x₂ | _ = r⋘ x x' (⋙r x₁ x₂ l₁≃r₁ l₂⋙r₂ l₁≃l₂) l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₁ x≤x₁ | inj₂ x₂≤x | _ rewrite lemma-≡-height right x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node right x l₂ r₂) (lemma-≺-right right x (node perfect x₁ l₁ r₁) (node right x₂ l₂ r₂)) ;
x₁l₁r₁⋙push-xl₂r₂ = lemma-⋙r-push x₁ x l₁≃r₁ l₂⋙r₂ l₁≃l₂ acc-xl₂r₂
in r⋘ x₂ x' x₁l₁r₁⋙push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
... | inj₂ x₁≤x | inj₁ x≤x₂ | _ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left right x (node perfect x₁ l₁ r₁) (node right x₂ l₂ r₂)) ;
push-xl₁r₁⋙x₂l₂r₂ = lemma-push-⋙ (⋙r x x₂ l₁≃r₁ l₂⋙r₂ l₁≃l₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' push-xl₁r₁⋙x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₁ x₁≤x₂ rewrite lemma-≡-height perfect x x₁ l₁ r₁ =
let acc-xl₁r₁ = rs (node perfect x l₁ r₁) (lemma-≺-left right x (node perfect x₁ l₁ r₁) (node right x₂ l₂ r₂)) ;
push-xl₁r₁⋙x₂l₂r₂ = lemma-push-⋙ (⋙r x x₂ l₁≃r₁ l₂⋙r₂ l₁≃l₂) acc-xl₁r₁ ;
push-xl₁r₁⋗x'₁l'₁r'₁ = lemma-push-⋗ (⋗nd x x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁) acc-xl₁r₁
in r⋘ x₁ x' push-xl₁r₁⋙x₂l₂r₂ l'≃r' push-xl₁r₁⋗x'₁l'₁r'₁
... | inj₂ x₁≤x | inj₂ x₂≤x | inj₂ x₂≤x₁ rewrite lemma-≡-height right x x₂ l₂ r₂ =
let acc-xl₂r₂ = rs (node right x l₂ r₂) (lemma-≺-right right x (node perfect x₁ l₁ r₁) (node right x₂ l₂ r₂)) ;
x₁l₁r₁⋙push-xl₂r₂ = lemma-⋙r-push x₁ x l₁≃r₁ l₂⋙r₂ l₁≃l₂ acc-xl₂r₂
in r⋘ x₂ x' x₁l₁r₁⋙push-xl₂r₂ l'≃r' (⋗nd x₁ x'₁ l₁≃r₁ l'₁≃r'₁ l₁⋗l'₁)
lemma-⋙l-push : {l r l' r' : PLRTree}(x x' : A) → l ≃ r → l' ⋘ r' → l ⋗ r' → (acc : Acc _≺_ (node left x' l' r')) → node perfect x l r ⋙ push (node left x' l' r') acc
lemma-⋙l-push x x' l≃r (x⋘ x'₁ x'₂ x'₃) (⋗nd x₁ .x'₃ x₂≃x₃ ≃lf (⋗lf x₂)) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₃ | tot≤ x'₁ x'₃
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₃ | _ = ⋙l x x' l≃r (x⋘ x'₁ x'₂ x'₃) (⋗nd x₁ x'₃ x₂≃x₃ ≃lf (⋗lf x₂))
... | inj₁ x'≤x'₁ | inj₂ x'₃≤x' | _ = ⋙l x x'₃ l≃r (x⋘ x'₁ x'₂ x') (⋗nd x₁ x' x₂≃x₃ ≃lf (⋗lf x₂))
... | inj₂ x'₁≤x' | inj₁ x'≤x'₃ | _
with tot≤ x' x'₂
... | inj₁ x'≤x'₂ = ⋙l x x'₁ l≃r (x⋘ x' x'₂ x'₃) (⋗nd x₁ x'₃ x₂≃x₃ ≃lf (⋗lf x₂))
... | inj₂ x'₂≤x' = ⋙l x x'₁ l≃r (x⋘ x'₂ x' x'₃) (⋗nd x₁ x'₃ x₂≃x₃ ≃lf (⋗lf x₂))
lemma-⋙l-push x x' l≃r (x⋘ x'₁ x'₂ x'₃) (⋗nd x₁ .x'₃ x₂≃x₃ ≃lf (⋗lf x₂)) (acc rs) | inj₂ x'₁≤x' | inj₂ x'₃≤x' | inj₁ x'₁≤x'₃
with tot≤ x' x'₂
... | inj₁ x'≤x'₂ = ⋙l x x'₁ l≃r (x⋘ x' x'₂ x'₃) (⋗nd x₁ x'₃ x₂≃x₃ ≃lf (⋗lf x₂))
... | inj₂ x'₂≤x' = ⋙l x x'₁ l≃r (x⋘ x'₂ x' x'₃) (⋗nd x₁ x'₃ x₂≃x₃ ≃lf (⋗lf x₂))
lemma-⋙l-push x x' l≃r (x⋘ x'₁ x'₂ x'₃) (⋗nd x₁ .x'₃ x₂≃x₃ ≃lf (⋗lf x₂)) (acc rs) | inj₂ x'₁≤x' | inj₂ x'₃≤x' | inj₂ x'₃≤x'₁ = ⋙l x x'₃ l≃r (x⋘ x'₁ x'₂ x') (⋗nd x₁ x' x₂≃x₃ ≃lf (⋗lf x₂))
lemma-⋙l-push x x' l≃r (l⋘ {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂) (⋗nd x₁ .x'₂ l₁≃r₁ _ l₁⋗l'₂) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋙l x x' l≃r (l⋘ x'₁ x'₂ l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂) (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right left x' (node left x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋘push-x'l'₂r'₂ = lemma-⋘-push (l⋘ x'₁ x' l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂) acc-x'l'₂r'₂ ;
x₁l₁r₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂) acc-x'l'₂r'₂
in ⋙l x x'₂ l≃r x'₁l'₁r'₁⋘push-x'l'₂r'₂ x₁l₁r₁⋗push-x'l'₂r'₂
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height left x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node left x' l'₁ r'₁) (lemma-≺-left left x' (node left x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋘x'₂l'₂r'₂ = lemma-push-l⋘ x' x'₂ l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂ acc-x'l'₁r'₁
in ⋙l x x'₁ l≃r push-x'l'₁r'₁⋘x'₂l'₂r'₂ (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height left x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node left x' l'₁ r'₁) (lemma-≺-left left x' (node left x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋘x'₂l'₂r'₂ = lemma-push-l⋘ x' x'₂ l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂ acc-x'l'₁r'₁
in ⋙l x x'₁ l≃r push-x'l'₁r'₁⋘x'₂l'₂r'₂ (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right left x' (node left x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋘push-x'l'₂r'₂ = lemma-⋘-push (l⋘ x'₁ x' l'₁⋘r'₁ l'₂≃r'₂ r'₁≃l'₂) acc-x'l'₂r'₂ ;
x₁l₁r₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂) acc-x'l'₂r'₂
in ⋙l x x'₂ l≃r x'₁l'₁r'₁⋘push-x'l'₂r'₂ x₁l₁r₁⋗push-x'l'₂r'₂
lemma-⋙l-push x x' l≃r (r⋘ {l'₁} {r'₁} {l'₂} {r'₂} x'₁ x'₂ l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂) (⋗nd x₁ .x'₂ l₁≃r₁ _ l₁⋗l'₂) (acc rs)
with tot≤ x' x'₁ | tot≤ x' x'₂ | tot≤ x'₁ x'₂
... | inj₁ x'≤x'₁ | inj₁ x'≤x'₂ | _ = ⋙l x x' l≃r (r⋘ x'₁ x'₂ l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂) (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₁ x'≤x'₁ | inj₂ x'₂≤x' | _ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right left x' (node right x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋘push-x'l'₂r'₂ = lemma-⋘-push (r⋘ x'₁ x' l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₂r'₂ ;
x₁l₁r₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂) acc-x'l'₂r'₂
in ⋙l x x'₂ l≃r x'₁l'₁r'₁⋘push-x'l'₂r'₂ x₁l₁r₁⋗push-x'l'₂r'₂
... | inj₂ x'₁≤x' | inj₁ x'≤x'₂ | _ rewrite lemma-≡-height right x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node right x' l'₁ r'₁) (lemma-≺-left left x' (node right x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋘x'₂l'₂r'₂ = lemma-push-r⋘ x' x'₂ l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂ acc-x'l'₁r'₁
in ⋙l x x'₁ l≃r push-x'l'₁r'₁⋘x'₂l'₂r'₂ (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₁ x'₁≤x'₂ rewrite lemma-≡-height right x' x'₁ l'₁ r'₁ =
let acc-x'l'₁r'₁ = rs (node right x' l'₁ r'₁) (lemma-≺-left left x' (node right x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
push-x'l'₁r'₁⋘x'₂l'₂r'₂ = lemma-push-r⋘ x' x'₂ l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂ acc-x'l'₁r'₁
in ⋙l x x'₁ l≃r push-x'l'₁r'₁⋘x'₂l'₂r'₂ (⋗nd x₁ x'₂ l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂)
... | inj₂ x'₁≤x' | inj₂ x'₂≤x' | inj₂ x'₂≤x'₁ rewrite lemma-≡-height perfect x' x'₂ l'₂ r'₂ =
let acc-x'l'₂r'₂ = rs (node perfect x' l'₂ r'₂) (lemma-≺-right left x' (node right x'₁ l'₁ r'₁) (node perfect x'₂ l'₂ r'₂)) ;
x'₁l'₁r'₁⋘push-x'l'₂r'₂ = lemma-⋘-push (r⋘ x'₁ x' l'₁⋙r'₁ l'₂≃r'₂ l'₁⋗l'₂) acc-x'l'₂r'₂ ;
x₁l₁r₁⋗push-x'l'₂r'₂ = lemma-⋗-push (⋗nd x₁ x' l₁≃r₁ l'₂≃r'₂ l₁⋗l'₂) acc-x'l'₂r'₂
in ⋙l x x'₂ l≃r x'₁l'₁r'₁⋘push-x'l'₂r'₂ x₁l₁r₁⋗push-x'l'₂r'₂
lemma-⋙-push : {t t' : PLRTree} → t ⋙ t' → (acc : Acc _≺_ t') → t ⋙ push t' acc
lemma-⋙-push (⋙p l⋗r) (acc rs) = ⋙p (lemma-⋗-push l⋗r (acc rs))
lemma-⋙-push (⋙l x x' l≃r l'⋘r' l⋗r') (acc rs) = lemma-⋙l-push x x' l≃r l'⋘r' l⋗r' (acc rs)
lemma-⋙-push (⋙r x x' l≃r l'⋙r' l≃l') (acc rs) = lemma-⋙r-push x x' l≃r l'⋙r' l≃l' (acc rs)
lemma-push-⋘ : {t t' : PLRTree} → t ⋘ t' → (acc : Acc _≺_ t) → push t acc ⋘ t'
lemma-push-⋘ (x⋘ x y z) _
with tot≤ x y
... | inj₁ x≤y = x⋘ x y z
... | inj₂ y≤x = x⋘ y x z
lemma-push-⋘ (l⋘ x x' l⋘r l'≃r' r≃l') (acc rs) = lemma-push-l⋘ x x' l⋘r l'≃r' r≃l' (acc rs)
lemma-push-⋘ (r⋘ x x' l⋙r l'≃r' l⋗l') (acc rs) = lemma-push-r⋘ x x' l⋙r l'≃r' l⋗l' (acc rs)
lemma-push-complete-≃ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ≃ r → (acc : Acc _≺_ (node perfect x l r)) → Complete (push (node perfect x l r) acc)
lemma-push-complete-≃ {l} {r} x cl cr l≃r (acc rs)
with l | r | l≃r | cl | cr
... | leaf | leaf | ≃lf | _ | _ = perfect x leaf leaf ≃lf
... | node perfect x' l' r' | node perfect x'' l'' r'' | ≃nd .x' .x'' l'≃r' l''≃r'' l'≃l'' | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = perfect x (perfect x' cl' cr' l'≃r') (perfect x'' cl'' cr'' l''≃r'') (≃nd x' x'' l'≃r' l''≃r'' l'≃l'')
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
xl''r''≃push-xl''r'' = lemma-≃-push (sym≃ (≃nd x x l'≃r' l''≃r'' l'≃l'')) acc-xl''r'' ;
x'l'r'≃push-xl''r'' = trans≃ (≃nd x' x l'≃r' l''≃r'' l'≃l'') xl''r''≃push-xl''r''
in perfect x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'l'r'≃push-xl''r''
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'≃xl'r' = lemma-push-≃ (≃nd x x l'≃r' l''≃r'' l'≃l'') acc-xl'r' ;
push-xl'r'≃x''l''r'' = trans≃ push-xl'r'≃xl'r' (≃nd x x'' l'≃r' l''≃r'' l'≃l'')
in perfect x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'≃x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'≃xl'r' = lemma-push-≃ (≃nd x x l'≃r' l''≃r'' l'≃l'') acc-xl'r' ;
push-xl'r'≃x''l''r'' = trans≃ push-xl'r'≃xl'r' (≃nd x x'' l'≃r' l''≃r'' l'≃l'')
in perfect x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'≃x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
xl''r''≃push-xl''r'' = lemma-≃-push (sym≃ (≃nd x x l'≃r' l''≃r'' l'≃l'')) acc-xl''r'' ;
x'l'r'≃push-xl''r'' = trans≃ (≃nd x' x l'≃r' l''≃r'' l'≃l'') xl''r''≃push-xl''r''
in perfect x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'l'r'≃push-xl''r''
lemma-push-complete-⋗ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋗ r → (acc : Acc _≺_ (node right x l r)) → Complete (push (node right x l r) acc)
lemma-push-complete-⋗ {l} {r} x cl cr l⋗r (acc rs)
with l | r | l⋗r | cl | cr
... | leaf | _ | () | _ | _
... | node perfect x' leaf leaf | leaf | ⋗lf .x' | perfect .x' leaf leaf ≃lf | leaf
with tot≤ x x'
... | inj₁ x≤x' = right x (perfect x' leaf leaf ≃lf) leaf (⋙p (⋗lf x'))
... | inj₂ x'≤x = right x' (perfect x leaf leaf ≃lf) leaf (⋙p (⋗lf x))
lemma-push-complete-⋗ x cl cr l⋗r (acc rs) | node perfect x' l' r' | node perfect x'' l'' r'' | ⋗nd .x' .x'' l'≃r' l''≃r'' l'⋗l'' | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = right x (perfect x' cl' cr' l'≃r') (perfect x'' cl'' cr'' l''≃r'') (⋙p (⋗nd x' x'' l'≃r' l''≃r'' l'⋗l''))
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
x'l'r'⋗push-xl''r'' = lemma-⋗-push (⋗nd x' x l'≃r' l''≃r'' l'⋗l'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') (⋙p x'l'r'⋗push-xl''r'')
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋗x''l''r'' = lemma-push-⋗ (⋗nd x x'' l'≃r' l''≃r'' l'⋗l'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') (⋙p push-xl'r'⋗x''l''r'')
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋗x''l''r'' = lemma-push-⋗ (⋗nd x x'' l'≃r' l''≃r'' l'⋗l'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') (⋙p push-xl'r'⋗x''l''r'')
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node perfect x'' l'' r'')) ;
x'l'r'⋗push-xl''r'' = lemma-⋗-push (⋗nd x' x l'≃r' l''≃r'' l'⋗l'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') (⋙p x'l'r'⋗push-xl''r'')
mutual
lemma-push-complete-⋙ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋙ r → (acc : Acc _≺_ (node right x l r)) → Complete (push (node right x l r) acc)
lemma-push-complete-⋙ {l} {r} x cl cr l⋙r (acc rs)
with l | r | l⋙r | cl | cr
... | leaf | _ | ⋙p () | _ | _
... | node perfect x' leaf leaf | leaf | ⋙p (⋗lf .x') | perfect .x' leaf leaf ≃lf | leaf =
lemma-push-complete-⋗ x (perfect x' leaf leaf ≃lf) leaf (⋗lf x') (acc rs)
... | node perfect x' l' r' | node perfect x'' l'' r'' | ⋙p (⋗nd .x' .x'' l'≃r' l''≃r'' l'⋗l'') | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _ =
lemma-push-complete-⋗ x (perfect x' cl' cr' l'≃r') (perfect x'' cl'' cr'' l''≃r'') (⋗nd x' x'' l'≃r' l''≃r'' l'⋗l'') (acc rs)
... | node perfect x' leaf leaf | node left _ _ _ | ⋙p () | _ | _
... | node perfect x' leaf leaf | node right _ _ _ | ⋙p () | _ | _
... | node perfect x' l' r' | node left x'' l'' r'' | ⋙l .x' .x'' l'≃r' l''⋘r'' l'⋗r'' | perfect .x' cl' cr' _ | left .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = right x (perfect x' cl' cr' l'≃r') (left x'' cl'' cr'' l''⋘r'') (⋙l x' x'' l'≃r' l''⋘r'' l'⋗r'')
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height left x x'' l'' r'' =
let acc-xl''r'' = rs (node left x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node left x'' l'' r'')) ;
x'l'r'⋙push-xl''r'' = lemma-⋙-push (⋙l x' x l'≃r' l''⋘r'' l'⋗r'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-⋘ x cl'' cr'' l''⋘r'' acc-xl''r'') x'l'r'⋙push-xl''r''
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node left x'' l'' r'')) ;
push-xl'r'⋙x''l''r'' = lemma-push-⋙ (⋙l x x'' l'≃r' l''⋘r'' l'⋗r'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (left x'' cl'' cr'' l''⋘r'') push-xl'r'⋙x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node left x'' l'' r'')) ;
push-xl'r'⋙x''l''r'' = lemma-push-⋙ (⋙l x x'' l'≃r' l''⋘r'' l'⋗r'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (left x'' cl'' cr'' l''⋘r'') push-xl'r'⋙x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height left x x'' l'' r'' =
let acc-xl''r'' = rs (node left x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node left x'' l'' r'')) ;
x'l'r'⋙push-xl''r'' = lemma-⋙-push (⋙l x' x l'≃r' l''⋘r'' l'⋗r'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-⋘ x cl'' cr'' l''⋘r'' acc-xl''r'') x'l'r'⋙push-xl''r''
lemma-push-complete-⋙ x cl cr l⋙r (acc rs)| node perfect x' l' r' | node right x'' l'' r'' | ⋙r .x' .x'' l'≃r' l''⋙r'' l'≃l'' | perfect .x' cl' cr' _ | right .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = right x (perfect x' cl' cr' l'≃r') (right x'' cl'' cr'' l''⋙r'') (⋙r x' x'' l'≃r' l''⋙r'' l'≃l'')
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height right x x'' l'' r'' =
let acc-xl''r'' = rs (node right x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node right x'' l'' r'')) ;
x'l'r'⋙push-xl''r'' = lemma-⋙-push (⋙r x' x l'≃r' l''⋙r'' l'≃l'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-⋙ x cl'' cr'' l''⋙r'' acc-xl''r'') x'l'r'⋙push-xl''r''
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node right x'' l'' r'')) ;
push-xl'r'⋙x''l''r'' = lemma-push-⋙ (⋙r x x'' l'≃r' l''⋙r'' l'≃l'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (right x'' cl'' cr'' l''⋙r'') push-xl'r'⋙x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' =
let acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left right x (node perfect x' l' r') (node right x'' l'' r'')) ;
push-xl'r'⋙x''l''r'' = lemma-push-⋙ (⋙r x x'' l'≃r' l''⋙r'' l'≃l'') acc-xl'r'
in right x' (lemma-push-complete-≃ x cl' cr' l'≃r' acc-xl'r') (right x'' cl'' cr'' l''⋙r'') push-xl'r'⋙x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height right x x'' l'' r'' =
let acc-xl''r'' = rs (node right x l'' r'') (lemma-≺-right right x (node perfect x' l' r') (node right x'' l'' r'')) ;
x'l'r'⋙push-xl''r'' = lemma-⋙-push (⋙r x' x l'≃r' l''⋙r'' l'≃l'') acc-xl''r''
in right x'' (perfect x' cl' cr' l'≃r') (lemma-push-complete-⋙ x cl'' cr'' l''⋙r'' acc-xl''r'') x'l'r'⋙push-xl''r''
lemma-push-complete-⋙ x cl cr l⋙r (acc rs) | node left _ _ _ | _ | ⋙p () | _ | _
lemma-push-complete-⋙ x cl cr l⋙r (acc rs) | node right _ _ _ | _ | ⋙p () | _ | _
lemma-push-complete-⋘ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋘ r → (acc : Acc _≺_ (node left x l r)) → Complete (push (node left x l r) acc)
lemma-push-complete-⋘ {l} {r} x cl cr l⋘r (acc rs)
with l | r | l⋘r | cl | cr
... | node left x' l' r' | node perfect x'' l'' r'' | l⋘ .x' .x'' l'⋘r' l''≃r'' r'≃l'' | left .x' cl' cr' _ | perfect .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = left x (left x' cl' cr' l'⋘r') (perfect x'' cl'' cr'' l''≃r'') (l⋘ x' x'' l'⋘r' l''≃r'' r'≃l'')
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right left x (node left x' l' r') (node perfect x'' l'' r'')) ;
xl''r''≃push-xl''r'' = lemma-≃-push (≃nd x x l''≃r'' l''≃r'' (lemma-≃-≃ l''≃r'')) acc-xl''r'' ;
x''l''r''≃push-xl''r'' = trans≃ (≃nd x'' x l''≃r'' l''≃r'' (lemma-≃-≃ l''≃r'')) xl''r''≃push-xl''r'' ;
x'l'r'⋘push-xl''r'' = lemma-⋘-push (l⋘ x' x l'⋘r' l''≃r'' r'≃l'') acc-xl''r''
in left x'' (left x' cl' cr' l'⋘r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'l'r'⋘push-xl''r''
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height left x x' l' r' =
let acc-xl'r' = rs (node left x l' r') (lemma-≺-left left x (node left x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋘x''l''r'' = lemma-push-⋘ (l⋘ x x'' l'⋘r' l''≃r'' r'≃l'') acc-xl'r'
in left x' (lemma-push-complete-⋘ x cl' cr' l'⋘r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'⋘x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height left x x' l' r' =
let acc-xl'r' = rs (node left x l' r') (lemma-≺-left left x (node left x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋘x''l''r'' = lemma-push-⋘ (l⋘ x x'' l'⋘r' l''≃r'' r'≃l'') acc-xl'r'
in left x' (lemma-push-complete-⋘ x cl' cr' l'⋘r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'⋘x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right left x (node left x' l' r') (node perfect x'' l'' r'')) ;
xl''r''≃push-xl''r'' = lemma-≃-push (≃nd x x l''≃r'' l''≃r'' (lemma-≃-≃ l''≃r'')) acc-xl''r'' ;
x''l''r''≃push-xl''r'' = trans≃ (≃nd x'' x l''≃r'' l''≃r'' (lemma-≃-≃ l''≃r'')) xl''r''≃push-xl''r'' ;
x'l'r'⋘push-xl''r'' = lemma-⋘-push (l⋘ x' x l'⋘r' l''≃r'' r'≃l'') acc-xl''r''
in left x'' (left x' cl' cr' l'⋘r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'l'r'⋘push-xl''r''
lemma-push-complete-⋘ x cl cr l⋘r (acc rs) | node right x' (node perfect x'' leaf leaf) leaf | node perfect x''' leaf leaf | x⋘ .x' .x'' .x''' | right .x' (perfect .x'' leaf leaf ≃lf) leaf (⋙p (⋗lf .x'')) | perfect .x''' leaf leaf ≃lf
with tot≤ x x' | tot≤ x x''' | tot≤ x' x'''
... | inj₁ x≤x' | inj₁ x≤x''' | _ = left x (right x' (perfect x'' leaf leaf ≃lf) leaf (⋙p (⋗lf x''))) (perfect x''' leaf leaf ≃lf) (x⋘ x' x'' x''')
... | inj₁ x≤x' | inj₂ x'''≤x | _ = left x''' (right x' (perfect x'' leaf leaf ≃lf) leaf (⋙p (⋗lf x''))) (perfect x leaf leaf ≃lf) (x⋘ x' x'' x)
... | inj₂ x'≤x | inj₁ x≤x''' | _ =
let acc-xx'' = rs (node right x (node perfect x'' leaf leaf) leaf) (lemma-≺-left left x (node right x' (node perfect x'' leaf leaf) leaf) (node perfect x''' leaf leaf)) ;
cdl = lemma-push-complete-⋙ x (perfect x'' leaf leaf ≃lf) leaf (⋙p (⋗lf x'')) acc-xx''
in left x' cdl (perfect x''' leaf leaf ≃lf) (lemma-push-⋘ (x⋘ x x'' x''') acc-xx'')
... | inj₂ x'≤x | inj₂ x'''≤x | inj₁ x'≤x''' =
let acc-xx'' = rs (node right x (node perfect x'' leaf leaf) leaf) (lemma-≺-left left x (node right x' (node perfect x'' leaf leaf) leaf) (node perfect x''' leaf leaf)) ;
cdl = lemma-push-complete-⋙ x (perfect x'' leaf leaf ≃lf) leaf (⋙p (⋗lf x'')) acc-xx''
in left x' cdl (perfect x''' leaf leaf ≃lf) (lemma-push-⋘ (x⋘ x x'' x''') acc-xx'')
... | inj₂ x'≤x | inj₂ x'''≤x | inj₂ x'''≤x' = left x''' (right x' (perfect x'' leaf leaf ≃lf) leaf (⋙p (⋗lf x''))) (perfect x leaf leaf ≃lf) (x⋘ x' x'' x)
lemma-push-complete-⋘ x cl cr l⋘r (acc rs) | node right x' l' r' | node perfect x'' l'' r'' | r⋘ .x' .x'' l'⋙r' l''≃r'' l'⋗l'' | right .x' cl' cr' _ | perfect .x'' cl'' cr'' _
with tot≤ x x' | tot≤ x x'' | tot≤ x' x''
... | inj₁ x≤x' | inj₁ x≤x'' | _ = left x (right x' cl' cr' l'⋙r') (perfect x'' cl'' cr'' l''≃r'') (r⋘ x' x'' l'⋙r' l''≃r'' l'⋗l'')
... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right left x (node right x' l' r') (node perfect x'' l'' r'')) ;
x'lr'⋘push-xl''r'' = lemma-⋘-push (r⋘ x' x l'⋙r' l''≃r'' l'⋗l'') acc-xl''r''
in left x'' (right x' cl' cr' l'⋙r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'lr'⋘push-xl''r''
... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height right x x' l' r' =
let acc-xl'r' = rs (node right x l' r') (lemma-≺-left left x (node right x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋘x''l''r'' = lemma-push-⋘ (r⋘ x x'' l'⋙r' l''≃r'' l'⋗l'') acc-xl'r'
in left x' (lemma-push-complete-⋙ x cl' cr' l'⋙r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'⋘x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height right x x' l' r' =
let acc-xl'r' = rs (node right x l' r') (lemma-≺-left left x (node right x' l' r') (node perfect x'' l'' r'')) ;
push-xl'r'⋘x''l''r'' = lemma-push-⋘ (r⋘ x x'' l'⋙r' l''≃r'' l'⋗l'') acc-xl'r'
in left x' (lemma-push-complete-⋙ x cl' cr' l'⋙r' acc-xl'r') (perfect x'' cl'' cr'' l''≃r'') push-xl'r'⋘x''l''r''
... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' =
let acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right left x (node right x' l' r') (node perfect x'' l'' r'')) ;
x'lr'⋘push-xl''r'' = lemma-⋘-push (r⋘ x' x l'⋙r' l''≃r'' l'⋗l'') acc-xl''r''
in left x'' (right x' cl' cr' l'⋙r') (lemma-push-complete-≃ x cl'' cr'' l''≃r'' acc-xl''r'') x'lr'⋘push-xl''r''
lemma-push-complete : {t : PLRTree} → Complete t → (acc : Acc _≺_ t) → Complete (push t acc)
lemma-push-complete leaf _ = leaf
lemma-push-complete (perfect {l} {r}x cl cr l≃r) (acc rs) = lemma-push-complete-≃ x cl cr l≃r (acc rs)
lemma-push-complete (left {l} {r}x cl cr l⋘r) (acc rs) = lemma-push-complete-⋘ x cl cr l⋘r (acc rs)
lemma-push-complete (right {l} {r}x cl cr l⋙r) (acc rs) = lemma-push-complete-⋙ x cl cr l⋙r (acc rs)
| {
"alphanum_fraction": 0.510608916,
"avg_line_length": 94.1162079511,
"ext": "agda",
"hexsha": "f16a590e5f9d2dcbc64319b99695afbbe252729c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/PLRTree/Push/Complete.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/PLRTree/Push/Complete.agda",
"max_line_length": 238,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/PLRTree/Push/Complete.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 34738,
"size": 61552
} |
{-# OPTIONS --experimental-irrelevance #-}
module ShapeIrrelevantIndexNoBecauseOfRecursion where
data ⊥ : Set where
record ⊤ : Set where
constructor trivial
data Bool : Set where
true false : Bool
True : Bool → Set
True false = ⊥
True true = ⊤
data D : ..(b : Bool) → Set where
c : {b : Bool} → True b → D b
-- because of the irrelevant index,
-- D is in essence an existental type D : Set
-- with constructor c : {b : Bool} → True b → D
fromD : {b : Bool} → D b → True b
fromD (c p) = p -- should fail
cast : .(a b : Bool) → D a → D b
cast _ _ x = x
bot : ⊥
bot = fromD (cast true false (c trivial))
| {
"alphanum_fraction": 0.6288492707,
"avg_line_length": 20.5666666667,
"ext": "agda",
"hexsha": "df08a5a68aa923693641cb02d52c6e56bf6f38f1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/ShapeIrrelevantIndexNoBecauseOfRecursion.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/ShapeIrrelevantIndexNoBecauseOfRecursion.agda",
"max_line_length": 53,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/ShapeIrrelevantIndexNoBecauseOfRecursion.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": 202,
"size": 617
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Monoidal.Structure
using (BraidedMonoidalCategory)
module Categories.Functor.Monoidal.Braided {o o′ ℓ ℓ′ e e′}
(C : BraidedMonoidalCategory o ℓ e) (D : BraidedMonoidalCategory o′ ℓ′ e′)
where
open import Level
open import Data.Product using (_,_)
open import Categories.Category using (module Commutation)
open import Categories.Functor using (Functor)
open import Categories.Functor.Monoidal
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism)
open NaturalIsomorphism
private
module C = BraidedMonoidalCategory C
module D = BraidedMonoidalCategory D
module Lax where
-- Lax braided monoidal functors.
record IsBraidedMonoidalFunctor (F : Functor C.U D.U)
: Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
open Functor F
field
isMonoidal : IsMonoidalFunctor C.monoidalCategory D.monoidalCategory F
open IsMonoidalFunctor isMonoidal public
open D
open Commutation D.U
-- coherence condition
field
braiding-compat : ∀ {X Y} →
[ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨
⊗-homo.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩
F₁ (C.braiding.⇒.η (X , Y))
≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩
⊗-homo.η (Y , X)
⟩
record BraidedMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isBraidedMonoidal : IsBraidedMonoidalFunctor F
open Functor F public
open IsBraidedMonoidalFunctor isBraidedMonoidal public
monoidalFunctor : MonoidalFunctor C.monoidalCategory D.monoidalCategory
monoidalFunctor = record { isMonoidal = isMonoidal }
module Strong where
-- Strong braided monoidal functors.
record IsBraidedMonoidalFunctor (F : Functor C.U D.U)
: Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
open Functor F
field
isStrongMonoidal : IsStrongMonoidalFunctor C.monoidalCategory
D.monoidalCategory F
open IsStrongMonoidalFunctor isStrongMonoidal public
open D
open Commutation D.U
-- coherence condition
field
braiding-compat : ∀ {X Y} →
[ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨
⊗-homo.⇒.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩
F₁ (C.braiding.⇒.η (X , Y))
≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩
⊗-homo.⇒.η (Y , X)
⟩
isLaxBraidedMonoidal : Lax.IsBraidedMonoidalFunctor F
isLaxBraidedMonoidal = record
{ isMonoidal = isMonoidal
; braiding-compat = braiding-compat
}
record BraidedMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isBraidedMonoidal : IsBraidedMonoidalFunctor F
open Functor F public
open IsBraidedMonoidalFunctor isBraidedMonoidal public
monoidalFunctor : StrongMonoidalFunctor C.monoidalCategory
D.monoidalCategory
monoidalFunctor = record { isStrongMonoidal = isStrongMonoidal }
| {
"alphanum_fraction": 0.5841375151,
"avg_line_length": 31.2830188679,
"ext": "agda",
"hexsha": "c3f2f5a6d00916bfdca300f793fac6d0932208d3",
"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": "f8a33de12956c729c7fb00a302f166a643eb6052",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "TOTBWF/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Monoidal/Braided.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052",
"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": "TOTBWF/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Monoidal/Braided.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TOTBWF/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Monoidal/Braided.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1027,
"size": 3316
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The reflexive transitive closures of McBride, Norell and Jansson
--
-- This module is DEPRECATED. Please use the
-- Relation.Binary.Construct.Closure.ReflexiveTransitive module directly
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Star where
open import Relation.Binary.Construct.Closure.ReflexiveTransitive public
| {
"alphanum_fraction": 0.5528942116,
"avg_line_length": 33.4,
"ext": "agda",
"hexsha": "5c95e015d9c95d68beeb5829c94f21e008906ac6",
"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.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.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/Data/Star.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 86,
"size": 501
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Truncation
open import lib.types.TwoSemiCategory
open import lib.two-semi-categories.Functor
open import lib.two-semi-categories.FunctorInverse
open import lib.two-semi-categories.GroupToCategory
module lib.two-semi-categories.FundamentalCategory where
module _ {i} (A : Type i) where
2-type-fundamental-cat : {{_ : has-level 2 A}} → TwoSemiCategory i i
2-type-fundamental-cat =
record
{ El = A
; Arr = _==_
; Arr-level = λ _ _ → ⟨⟩
; two-semi-cat-struct = record
{ comp = _∙_
; assoc = ∙-assoc
; pentagon-identity = ∙-assoc-pentagon
}
}
=ₜ-fundamental-cat : TwoSemiCategory i i
=ₜ-fundamental-cat =
record
{ El = Trunc 2 A
; Arr = _=ₜ_
; Arr-level = =ₜ-level
; two-semi-cat-struct = record
{ comp = λ {ta} → _∙ₜ_ {ta = ta}
; assoc = λ {ta} → ∙ₜ-assoc {ta = ta}
; pentagon-identity = λ {ta} → ∙ₜ-assoc-pentagon {ta = ta}
}
}
module _ {i} (A : Type i) where
2-type-to-=ₜ-fundamental-cat :
TwoSemiFunctor (2-type-fundamental-cat (Trunc 2 A))
(=ₜ-fundamental-cat A)
2-type-to-=ₜ-fundamental-cat =
record
{ F₀ = idf (Trunc 2 A)
; F₁ = λ {ta} {tb} → –> (=ₜ-equiv ta tb)
; pres-comp = –>-=ₜ-equiv-pres-∙
-- TODO: The following line takes a really long time to check.
-- Can we optimize this somehow?
; pres-comp-coh = λ {ta} → –>-=ₜ-equiv-pres-∙-coh {ta = ta}
}
private
module FunctorInv =
FunctorInverse 2-type-to-=ₜ-fundamental-cat
(idf-is-equiv (Trunc 2 A))
(λ ta tb → snd (=ₜ-equiv ta tb))
module InvFunctor = TwoSemiFunctor FunctorInv.functor
=ₜ-to-2-type-fundamental-cat :
TwoSemiFunctor (=ₜ-fundamental-cat A)
(2-type-fundamental-cat (Trunc 2 A))
=ₜ-to-2-type-fundamental-cat =
record
{ F₀ = idf (Trunc 2 A)
; F₁ = λ {ta} {tb} → <– (=ₜ-equiv ta tb)
; pres-comp = InvFunctor.pres-comp
; pres-comp-coh = InvFunctor.pres-comp-coh
}
module =ₜ-to-2-type-fundamental-cat = TwoSemiFunctor =ₜ-to-2-type-fundamental-cat
=ₜ-to-2-type-fundamental-cat-pres-comp-β : {a b c : A}
(p : a == b) (q : b == c)
→ =ₜ-to-2-type-fundamental-cat.pres-comp {x = [ a ]} {y = [ b ]} {z = [ c ]} [ p ]₁ [ q ]₁
== ap-∙ [_] p q
=ₜ-to-2-type-fundamental-cat-pres-comp-β {a} p@idp q@idp =
=ₛ-out (FunctorInv.pres-comp-β {[ a ]} {[ a ]} {[ a ]} [ idp ]₁ [ idp ]₁)
module _ {i} (C : Type i) (c₀ : C) {{C-level : has-level 1 C}} where
open import lib.groups.LoopSpace
fundamental-group-to-fundamental-groupoid :
TwoSemiFunctor (group-to-cat (Ω^S-group 0 ⊙[ C , c₀ ]))
(2-type-fundamental-cat C {{raise-level 1 C-level}})
fundamental-group-to-fundamental-groupoid =
record
{ F₀ = λ _ → c₀
; F₁ = λ p → p
; pres-comp = λ p q → idp
; pres-comp-coh =
λ p q r → =ₛ-in $
prop-path (has-level-apply (has-level-apply C-level _ _) _ _) _ _
}
| {
"alphanum_fraction": 0.5762214984,
"avg_line_length": 31.3265306122,
"ext": "agda",
"hexsha": "3fe8b4b34ea5120a40ead56259e2319d7df7c83f",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/two-semi-categories/FundamentalCategory.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/two-semi-categories/FundamentalCategory.agda",
"max_line_length": 94,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/two-semi-categories/FundamentalCategory.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": 1075,
"size": 3070
} |
module Basic.SmallStep where
import Data.Bool as Bool using (not)
open import Data.Bool hiding (not; if_then_else_)
open import Data.Empty
open import Data.Fin using (Fin; suc; zero; #_)
open import Data.Nat
open import Data.Nat.Properties.Simple
open import Data.Vec
open import Function
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Data.Unit hiding (_≤?_)
open import Data.Product
open import Data.Maybe
import Level as L
open import Basic.AST
open import Utils.Decidable
open import Utils.NatOrdLemmas
{-
Small-step semantics for While; see chapter 2.2 of the book.
The book uses the notational convenience of omitting the state on the right hand side
of the transition if there is no such state. We must define the same shorthand explicitly.
Since the book seems to do it, I also decided to index derivation sequences by their length.
This means also more cases for notatitonal shorthands. Otherwise, the definitions follow the book
faithfully.
Here I omit some commentary, since most of the things follow the same pattern as with big-step
semantics. However, I also include some lemmas specific to small-step semantics, which are
also included in the book.
-}
infixr 5 _∷_
mutual
-- Notational shorthands for derivation sequences:
-- Sequences with specified number of steps:
⟨_,_⟩_⟶_ : ∀ {n} → St n → State n → ℕ → State n → Set
⟨_,_⟩_⟶_ S s k s' = ⟨ S , s ⟩ k ⟶[ nothing , s' ]
⟨_,_⟩_⟶⟨_,_⟩ : ∀ {n} → St n → State n → ℕ → St n → State n → Set
⟨_,_⟩_⟶⟨_,_⟩ S s k S' s' = ⟨ S , s ⟩ k ⟶[ just S' , s' ]
-- Sequences with unspecified number of steps:
⟨_,_⟩⟶*⟨_,_⟩ : ∀ {n} → St n → State n → St n → State n → Set
⟨_,_⟩⟶*⟨_,_⟩ S s S' s' = ∃ λ n → ⟨ S , s ⟩ n ⟶[ just S' , s' ]
⟨_,_⟩⟶*_ : ∀ {n} → St n → State n → State n → Set
⟨_,_⟩⟶*_ S s s' = ∃ λ n → ⟨ S , s ⟩ n ⟶[ nothing , s' ]
-- Single-step transitions:
⟨_,_⟩⟶_ : ∀ {n} → St n → State n → State n → Set
⟨_,_⟩⟶_ S s s' = ⟨ S , s ⟩⟶[ nothing , s' ]
⟨_,_⟩⟶⟨_,_⟩ : ∀ {n} → St n → State n → St n → State n → Set
⟨_,_⟩⟶⟨_,_⟩ S s S' s' = ⟨ S , s ⟩⟶[ just S' , s' ]
data ⟨_,_⟩⟶[_,_] {n : ℕ} : St n → State n → Maybe (St n) → State n → Set where
ass :
∀ {x a s}
→ --------------------------------------
⟨ x := a , s ⟩⟶ ( s [ x ]≔ ⟦ a ⟧ᵉ s )
skip :
∀ {s}
→ ----------------
⟨ skip , s ⟩⟶ s
_◄ :
∀ {s s' S₁ S₂ S₁'} →
⟨ S₁ , s ⟩⟶⟨ S₁' , s' ⟩
→ --------------------------------------
⟨ (S₁ , S₂) , s ⟩⟶⟨ (S₁' , S₂) , s' ⟩
_∙ :
∀ {s s' S₁ S₂} →
⟨ S₁ , s ⟩⟶ s'
→ ------------------------------
⟨ (S₁ , S₂) , s ⟩⟶⟨ S₂ , s' ⟩
if-true :
∀ {b s S₁ S₂} → T (⟦ b ⟧ᵉ s)
→ ---------------------------------------
⟨ if b then S₁ else S₂ , s ⟩⟶⟨ S₁ , s ⟩
if-false :
∀ {b s S₁ S₂} → F (⟦ b ⟧ᵉ s)
→ ---------------------------------------
⟨ if b then S₁ else S₂ , s ⟩⟶⟨ S₂ , s ⟩
while :
∀ {b s S}
→ ----------------------------------------------------------------------
⟨ while b do S , s ⟩⟶⟨ (if b then (S , while b do S) else skip) , s ⟩
-- Derivation sequences
data ⟨_,_⟩_⟶[_,_] {n : ℕ} : St n → State n → ℕ → Maybe (St n) → State n → Set where
pause :
∀ {s S}
→ -----------------------
⟨ S , s ⟩ 0 ⟶⟨ S , s ⟩
_stop :
∀ {s s' S} →
⟨ S , s ⟩⟶ s'
→ -----------------
⟨ S , s ⟩ 1 ⟶ s'
_∷_ :
∀ {k s₁ s₂ s₃ S₁ S₂ S₃} →
⟨ S₁ , s₁ ⟩⟶⟨ S₂ , s₂ ⟩ → ⟨ S₂ , s₂ ⟩ k ⟶[ S₃ , s₃ ]
→ --------------------------------------------------------
⟨ S₁ , s₁ ⟩ suc k ⟶[ S₃ , s₃ ]
-- Example program derivation (very slow to check!)
private
prog : St 3
prog =
# 2 := lit 0 ,
while lte (var (# 1)) (var (# 0)) do
( # 2 := add (var (# 2)) (lit 1) ,
# 0 := sub (var (# 0)) (var (# 1)) )
-- -- Uncomment if you dare
-- prog-deriv :
-- ∀ {z} → ⟨ prog , 17 ∷ 5 ∷ z ∷ [] ⟩ _ ⟶ (2 ∷ 5 ∷ 3 ∷ [])
-- prog-deriv =
-- ass ∙ ∷
-- while ∷ if-true tt ∷ ass ∙ ◄ ∷ ass ∙ ∷
-- while ∷ if-true tt ∷ ass ∙ ◄ ∷ ass ∙ ∷
-- while ∷ if-true tt ∷ ass ∙ ◄ ∷ ass ∙ ∷
-- while ∷ if-false tt ∷ skip stop
-- Divergence
_divergesOnₛ_ : ∀ {n} → St n → State n → Set
prog divergesOnₛ s = ∀ {n s'} → ¬ ⟨ prog , s ⟩ n ⟶ s'
Divergentₛ : ∀ {n} → St n → Set
Divergentₛ prog = ∀ {s} → prog divergesOnₛ s
private
inf-loopₛ : ∀ {n} → Divergentₛ {n} (while tt do skip)
inf-loopₛ (() stop)
inf-loopₛ (while ∷ (() stop))
inf-loopₛ (while ∷ (if-true tt ∷ (() stop)))
inf-loopₛ (while ∷ (if-true tt ∷ ((() ◄) ∷ p)))
inf-loopₛ (while ∷ (if-true tt ∷ ((skip ∙) ∷ p))) = inf-loopₛ p
inf-loopₛ (while ∷ (if-false () ∷ p))
deterministicₛ :
∀ {n}{S : St n}{S' S'' s s' s''}
→ ⟨ S , s ⟩⟶[ S' , s' ] → ⟨ S , s ⟩⟶[ S'' , s'' ]
→ S' ≡ S'' × s' ≡ s''
deterministicₛ {n} = go where
go : ∀ {S : St n}{S' S'' s s' s''}
→ ⟨ S , s ⟩⟶[ S' , s' ] → ⟨ S , s ⟩⟶[ S'' , s'' ]
→ S' ≡ S'' × s' ≡ s''
go ass ass = refl , refl
go skip skip = refl , refl
go (p1 ◄) (p2 ◄) with go p1 p2
... | refl , refl = refl , refl
go (p1 ◄) (p2 ∙) with go p1 p2
... | () , _
go (p1 ∙) (p2 ◄) with go p1 p2
... | () , _
go (p1 ∙) (p2 ∙) with go p1 p2
... | refl , refl = refl , refl
go (if-true x) (if-true x₁) = refl , refl
go (if-true x) (if-false x₁) rewrite T→≡true x = ⊥-elim x₁
go (if-false x) (if-true x₁) rewrite T→≡true x₁ = ⊥-elim x
go (if-false x) (if-false x₁) = refl , refl
go while while = refl , refl
{-
Lemma 2.19 of the book: if we have a derivation over the composition of statements,
then there exists two derivations over the substatements, such that their lenghts
add up to the length of the original derivation.
-}
seq-split :
∀ {n k S₁ S₂}{s₁ s₃ : State n}
→ ⟨ (S₁ , S₂) , s₁ ⟩ k ⟶ s₃
→ Σ (State n × ℕ × ℕ) λ {(s₂ , k₁ , k₂)
→ ⟨ S₁ , s₁ ⟩ k₁ ⟶ s₂
× ⟨ S₂ , s₂ ⟩ k₂ ⟶ s₃
× k₁ + k₂ ≡ k}
seq-split (() stop)
seq-split (x ◄ ∷ p) with seq-split p
... | _ , p1 , p2 , prf = _ , x ∷ p1 , p2 , cong suc prf
seq-split (x ∙ ∷ p) = _ , x stop , p , refl
{-
Exercise 2.20.
-}
ex2-20 :
∃ λ n → ∃₂ λ (s s' : State n) → ∃₂ λ A B →
⟨ (A , B) , s ⟩⟶*⟨ B , s' ⟩ × ¬ ⟨ A , s ⟩⟶* s'
ex2-20 = 1 , (0 ∷ []) , (2 ∷ []) , A , (while b do A) , Deriv , ¬Deriv
where
A = zero := add (lit 1) (var zero)
b = lt (var zero) (lit 2)
Deriv = , ass ∙ ∷ while ∷ if-true tt ∷ ass ∙ ∷ pause
¬Deriv : ¬ ⟨ A , 0 ∷ [] ⟩⟶* (2 ∷ [])
¬Deriv (._ , () stop)
¬Deriv (._ , () ∷ proj₂)
{-
The converse of seq-split: two derivations can be appended to a single derivation
over the composition of the programs.
-}
append :
∀ {n k₁ k₂}{s s' s'' : State n}{A B}
→ ⟨ A , s ⟩ k₁ ⟶ s'
→ ⟨ B , s' ⟩ k₂ ⟶ s''
→ ⟨ (A , B) , s ⟩ (k₁ + k₂) ⟶ s''
append (x stop) p2 = (x ∙) ∷ p2
append (x ∷ p1) p2 = (x ◄) ∷ append p1 p2
-- Correctness of factorial (exactly the same proof as with big-step semantics)
private
⟦fac⟧ : ℕ → ℕ
⟦fac⟧ zero = 1
⟦fac⟧ (suc n) = suc n * ⟦fac⟧ n
fac-loop : St 3
fac-loop =
while lt (var (# 1)) (var (# 0)) do
( # 1 := add (lit 1) (var (# 1)) ,
# 2 := mul (var (# 1)) (var (# 2)) )
fac : St 3
fac =
# 1 := lit 0 ,
# 2 := lit 1 ,
fac-loop
fac-loop-ok :
∀ d i → ⟨ fac-loop , d + i ∷ i ∷ ⟦fac⟧ i ∷ [] ⟩⟶* (d + i ∷ d + i ∷ ⟦fac⟧ (d + i) ∷ [])
fac-loop-ok zero i =
, while ∷ if-false (¬A→FalseA $ a≮a i) ∷ skip stop
fac-loop-ok (suc d) i with fac-loop-ok d (suc i)
... | _ , next rewrite +-suc d i =
, while ∷ if-true (A→TrueA $ a<sb+a i d) ∷ ass ∙ ◄ ∷ ass ∙ ∷ next
fac-ok :
∀ n {i lim} → ⟨ fac , n ∷ i ∷ lim ∷ [] ⟩⟶* (n ∷ n ∷ ⟦fac⟧ n ∷ [])
fac-ok n with fac-loop-ok n 0
... | _ , loop-ok rewrite +-comm n 0 = , ass ∙ ∷ ass ∙ ∷ loop-ok
| {
"alphanum_fraction": 0.4605902129,
"avg_line_length": 30.1917293233,
"ext": "agda",
"hexsha": "92b7389210e65f6c0441cea0d8fe372b7d4976bf",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications",
"max_forks_repo_path": "Basic/SmallStep.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AndrasKovacs/SemanticsWithApplications",
"max_issues_repo_path": "Basic/SmallStep.agda",
"max_line_length": 97,
"max_stars_count": 8,
"max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications",
"max_stars_repo_path": "Basic/SmallStep.agda",
"max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z",
"num_tokens": 3232,
"size": 8031
} |
-- Andreas, 2015-09-18 Andreas, reported by Andrea
-- {-# OPTIONS -v impossible:10 #-}
-- {-# OPTIONS -v tc.cover.splittree:10 #-}
-- {-# OPTIONS -v tc.cc:30 #-}
open import Common.Bool
open import Common.Product
open import Common.Equality
postulate
A : Set
a : A
Works : A × A → Bool → A
Works (x , y) true = y
Works d false = a
works : ∀{x y} → Works (x , y) false ≡ a
works = refl
Test : A × (A × A) → Bool → A
Test (x , (y , z)) true = z
Test d false = a
test : ∀{x y z} → Test (x , (y , z)) false ≡ a
test = refl
-- ERROR WAS:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/CompiledClause/Match.hs:189
-- Behavior of clause compiler WAS:
-- splitting on 0 after expandCatchAlls True:
-- (x,(y,z)) true -> z
-- (_,_) false -> a
-- _ false -> a
-- splitting on 1 after expandCatchAlls False:
-- d false -> a
-- splitting on 1 after expandCatchAlls False: <== NOW: True
-- x (y,z) true -> z
-- _ (_,_) false -> a <== WAS MISSING
-- _ _ false -> a
-- splitting on 2 after expandCatchAlls False:
-- _ _ false -> a
-- splitting on 3 after expandCatchAlls False:
-- x y z true -> z
-- x y z false -> a <== WAS MISSING
| {
"alphanum_fraction": 0.6033925687,
"avg_line_length": 25.7916666667,
"ext": "agda",
"hexsha": "3fc4d0c890498829ab692d62671ae7183cd0ab63",
"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/Issue1650.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/Issue1650.agda",
"max_line_length": 80,
"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/Issue1650.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": 406,
"size": 1238
} |
-- Andreas, 2013-10-30
-- Test whether verbosity options are honored before file is loaded.
-- See Issue641.flags
module Issue641 where
-- Provoke a scope checking error.
open NoSuchModule
-- Expected output is some debug messages about importing, plus the error,
-- like:
-- Getting interface for Issue641
-- Check for cycle
-- Issue641 is not up-to-date.
-- Creating interface for Issue641.
-- visited:
-- Issue641.agda:9,6-18
-- No such module NoSuchModule
-- when scope checking the declaration
-- open NoSuchModule
| {
"alphanum_fraction": 0.7345794393,
"avg_line_length": 23.2608695652,
"ext": "agda",
"hexsha": "fa9be556ddb35f0508a913986df4ec7403ea853c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue641.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue641.agda",
"max_line_length": 74,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue641.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": 130,
"size": 535
} |
{-# OPTIONS --no-positivity-check #-}
module STLC.Coquand.Completeness where
open import STLC.Coquand.Normalisation public
open import STLC.Coquand.Convertibility public
--------------------------------------------------------------------------------
data CV : ∀ {Γ A} → Γ ⊢ A → Γ ⊩ A → Set
where
cv⎵ : ∀ {Γ} → {M : Γ ⊢ ⎵} {f : Γ ⊩ ⎵}
→ (h : ∀ {Γ′} → (η : Γ′ ∋⋆ Γ)
→ sub ⌊ η ⌋ M ∼ ⟦g⟧⟨ η ⟩ f)
→ CV M f
cv⊃ : ∀ {Γ A B} → {M : Γ ⊢ A ⇒ B} {f : Γ ⊩ A ⇒ B}
→ (h : ∀ {Γ′ N a} → (η : Γ′ ∋⋆ Γ) → CV N a
→ CV (sub ⌊ η ⌋ M ∙ N) (f ⟦∙⟧⟨ η ⟩ a))
→ CV M f
data CV⋆ : ∀ {Γ Ξ} → Γ ⊢⋆ Ξ → Γ ⊩⋆ Ξ → Set
where
∅ : ∀ {Γ} → {σ : Γ ⊢⋆ ∅}
→ CV⋆ σ ∅
_,_ : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ , A} {ρ : Γ ⊩⋆ Ξ} {a : Γ ⊩ A}
→ (κ : CV⋆ (σ ◐ wkᵣ {A} idᵣ) ρ) (k : CV (sub σ 0) a)
→ CV⋆ σ (ρ , a)
--------------------------------------------------------------------------------
postulate
congCV : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} {a : Γ ⊩ A}
→ M₁ ∼ M₂ → CV M₁ a
→ CV M₂ a
-- (cong↑⟨_⟩CV)
postulate
accCV : ∀ {Γ Γ′ A} → {M : Γ ⊢ A} {a : Γ ⊩ A}
→ (η : Γ′ ∋⋆ Γ) → CV M a
→ CV (sub ⌊ η ⌋ M) (acc η a)
-- (conglookupCV)
postulate
getCV : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ⊩⋆ Ξ}
→ (i : Ξ ∋ A) → CV⋆ σ ρ
→ CV (sub σ (𝓋 i)) (getᵥ ρ i)
-- (cong↑⟨_⟩CV⋆)
postulate
accCV⋆ : ∀ {Γ Γ′ Ξ} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ⊩⋆ Ξ}
→ (η : Γ′ ∋⋆ Γ) → CV⋆ σ ρ
→ CV⋆ (η ◑ σ) (η ⬗ ρ)
-- (cong↓⟨_⟩CV⋆)
postulate
getCV⋆ : ∀ {Γ Ξ Ξ′} → {σ : Γ ⊢⋆ Ξ′} {ρ : Γ ⊩⋆ Ξ′}
→ (η : Ξ′ ∋⋆ Ξ) → CV⋆ σ ρ
→ CV⋆ (σ ◐ η) (ρ ⬖ η)
--------------------------------------------------------------------------------
-- Lemma 8.
postulate
⟦_⟧CV : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ⊩⋆ Ξ}
→ (M : Ξ ⊢ A) → CV⋆ σ ρ
→ CV (sub σ M) (⟦ M ⟧ ρ)
postulate
⟦_⟧CV⋆ : ∀ {Γ Ξ Φ} → {σ₁ : Γ ⊢⋆ Ξ} {ρ : Γ ⊩⋆ Ξ}
→ (σ₂ : Ξ ⊢⋆ Φ) → CV⋆ σ₁ ρ
→ CV⋆ (σ₁ ● σ₂) (⟦ σ₂ ⟧⋆ ρ)
--------------------------------------------------------------------------------
-- Lemma 9.
mutual
postulate
lem₉ : ∀ {Γ A} → {M : Γ ⊢ A} {a : Γ ⊩ A}
→ CV M a
→ M ∼ reify a
postulate
aux₄₆₈ : ∀ {A Γ} → {M : Γ ⊢ A} {f : ∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A}
→ (∀ {Γ′} → (η : Γ′ ∋⋆ Γ) → sub ⌊ η ⌋ M ∼ f η)
→ CV M (⟪ f ⟫)
postulate
⌊_⌋CV⋆ : ∀ {Γ Γ′} → (η : Γ′ ∋⋆ Γ)
→ CV⋆ ⌊ η ⌋ ⌊ η ⌋ᵥ
idCV⋆ : ∀ {Γ} → CV⋆ ⌊ idᵣ ⌋ (idᵥ {Γ})
idCV⋆ = ⌊ idᵣ ⌋CV⋆
postulate
aux₄₆₉ : ∀ {Γ A} → (M : Γ ⊢ A)
→ sub ⌊ idᵣ ⌋ M ∼ nf M
--------------------------------------------------------------------------------
-- Theorem 2.
postulate
thm₂ : ∀ {Γ A} → (M : Γ ⊢ A)
→ M ∼ nf M
-- Theorem 3.
thm₃ : ∀ {Γ A} → (M₁ M₂ : Γ ⊢ A) → Eq (⟦ M₁ ⟧ idᵥ) (⟦ M₂ ⟧ idᵥ)
→ M₁ ∼ M₂
thm₃ M₁ M₂ e = thm₂ M₁
⦙ ≡→∼ (cor₁ M₁ M₂ e)
⦙ thm₂ M₂ ⁻¹
--------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.2562574493,
"avg_line_length": 26.4251968504,
"ext": "agda",
"hexsha": "8607dd7ee6b2e4fc528bd19c23ce9631d0ce8830",
"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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand-kovacs",
"max_forks_repo_path": "src/STLC/Coquand/Completeness.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"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/coquand-kovacs",
"max_issues_repo_path": "src/STLC/Coquand/Completeness.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand-kovacs",
"max_stars_repo_path": "src/STLC/Coquand/Completeness.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1531,
"size": 3356
} |
{-# OPTIONS --warning=error #-}
module UselessPrivatePragma where
postulate Char : Set
private
{-# BUILTIN CHAR Char #-}
| {
"alphanum_fraction": 0.6984126984,
"avg_line_length": 14,
"ext": "agda",
"hexsha": "2375116b1379765e3650ecafb09a94cdbefcd21a",
"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/UselessPrivatePragma.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/UselessPrivatePragma.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/UselessPrivatePragma.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": 30,
"size": 126
} |
{- SAMPLE PROGRAMS IN SOURCE LANGUAGE -}
open import Preliminaries
open import Source
open import Pilot2
open import Translation
open import Interp
open import Preorder
module Samples where
s2r : ∀ {Γ τ} → Γ Source.|- τ → (el ([ (⟨⟨ Γ ⟩⟩c) ]c ->p [ (|| τ ||) ]t))
s2r p = interpE || p ||e
-- this works
{- dbl (n : nat) : nat = 2 * n -}
dbl : ∀ {Γ} → Γ Source.|- (nat ->s nat)
dbl = lam (rec (var i0) z (suc (suc (force (var (iS i0))))))
-- this works
{- add (m n : nat) : nat = m + n -}
add : ∀ {Γ} → Γ Source.|- (nat ->s (nat ->s nat))
add = lam (lam (rec (var (iS i0)) (var i0) (suc (force (var (iS i0))))))
-- this works
{- mult (m n : nat) : nat = m * n -}
mult : ∀ {Γ} → Γ Source.|- (nat ->s (nat ->s nat))
mult = lam (lam (rec (var (iS i0)) z (app (app add (var (iS (iS i0)))) (force (var (iS i0))))))
-- this works
{- pred (n : nat) : nat = predecessor of n -}
pred : ∀ {Γ} → Γ Source.|- (nat ->s nat)
pred = lam (rec (var i0) z (var i0))
-- uhhhh
fastfib : ∀ {Γ} → Γ Source.|- (nat ->s (nat ×s nat))
fastfib =
lam (rec (var i0) (prod z (suc z))
(prod (split (force (var (iS i0))) (var (iS i0)))
(app (app add (split (force (var (iS i0))) (var i0))) (split (force (var (iS i0))) (var (iS i0))))))
-- hack : instead of having bool case analysis just do natural number recursion and return 1/0
-- this works
{- iszero (n : nat) : nat = z -> 1 | _ -> 0 -}
isz : ∀ {Γ} → Γ Source.|- (nat ->s nat)
isz = lam (rec (var i0) (suc z) z)
-- this works
{- leq (m n : nat) : nat = m ≤ n -}
leq : ∀ {Γ} → Γ Source.|- (nat ->s (nat ->s nat))
leq = lam (rec (var i0) (lam (suc z)) (lam (rec (var i0) z (app (force (var (iS (iS (iS (iS i0)))))) (var i0)))))
-- this works
{- eq (m n : nat) : nat = m = n -}
eq : ∀ {Γ} → Γ Source.|- (nat ->s (nat ->s nat))
eq = lam (rec (var i0) (lam (app isz (var i0))) (lam (rec (var i0) z (app (force (var (iS (iS (iS (iS i0)))))) (var i0)))))
-- this works
{- len (l : list τ) : nat = [] -> z | x :: xs -> 1 + len xs -}
len : ∀ {Γ τ} → Γ Source.|- (list τ ->s nat)
len = lam (listrec (var i0) z (suc (force (var (iS (iS i0))))))
-- this works
{- nth (n : nat) (l : list τ) : nat = [] -> 1 (return 1+len(l) if element not in list) | x :: xs -> if n = x then 0 else 1 + (nth n xs) -}
nth : ∀ {Γ} → Γ Source.|- (list nat ->s (nat ->s nat))
nth = lam (lam (listrec (var (iS i0)) (suc z) (rec (app (app eq (var (iS (iS (iS i0))))) (var i0)) (suc (force (var (iS (iS i0))))) z)))
-- this works
{- append (l1 l2 : list τ) : list τ = match l1 with [] -> l2 | x :: xs -> x :: (append xs ys) -}
append : ∀ {Γ τ} → Γ Source.|- (list τ ->s (list τ ->s list τ))
append = lam (lam (listrec (var (iS i0)) (var i0) (var i0 ::s force (var (iS (iS i0))))))
-- this works
{- rev (l : list τ) : list τ = [] -> [] | x :: xs -> append (rev xs) [x] -}
rev : ∀ {Γ τ} → Γ Source.|- (list τ ->s list τ)
rev = lam (listrec (var i0) nil (app (app append (force (var (iS (iS i0))))) (var i0 ::s nil)))
{-
{- fast rev -}
rev2piles : ∀ {Γ τ} → Γ Source.|- (list τ ->s (list τ ->s list τ))
rev2piles = lam (lam (listrec (var (iS i0)) (var i0) (app (app rev2piles (var (iS i0))) (var i0 ::s var (iS (iS (iS i0)))))))
fastrev : ∀ {Γ τ} → Γ Source.|- (list τ ->s list τ)
fastrev = lam (app (app rev2piles (var i0)) nil)
-}
-- this works
{- insert (l : list nat) (el : nat) : list nat = [] -> [el] | x :: xs -> (leq el x -> el :: x :: xs | x :: (insert el xs)) -}
insert : ∀ {Γ} → Γ Source.|- (list nat ->s (nat ->s list nat))
insert = lam (lam (listrec (var (iS i0)) (var i0 ::s nil)
(rec (app (app leq (var (iS (iS (iS i0))))) (var i0)) (var i0 ::s force (var (iS (iS i0))))
(var (iS (iS (iS (iS (iS i0))))) ::s (var (iS (iS i0)) ::s var (iS (iS (iS i0))))))))
-- this works
{- insertion sort (l : list nat) : list nat = [] -> [] | x :: xs -> insert x (isort xs) -}
isort : ∀ {Γ} → Γ Source.|- (list nat ->s list nat)
isort = lam (listrec (var i0) nil (app (app insert (force (var (iS (iS i0))))) (var i0)))
-- this works
{- map (l : list τ) (f : τ → τ') : list τ = [] -> [] | x :: xs -> f x :: map f xs -}
map : ∀ {Γ τ τ'} → Γ Source.|- ((τ ->s τ') ->s (list τ ->s list τ'))
map = lam (lam (listrec (var i0) nil (app (var (iS (iS (iS (iS i0))))) (var i0) ::s force (var (iS (iS i0))))))
dbl-trans : ∀ {Γ τ} → {!!} --el ([ (⟨⟨ Γ ⟩⟩c) ]c ->p [ (|| τ ||) ]t)
dbl-trans {Γ} = {!|| dbl ||e!}
example1 : ∀ {Γ τ} → {!!}
example1 {Γ} {τ} = {!!} --copy and paste from this goal to the thing below
{-
dbl-trans : ∀ {Γ} → ⟨⟨ Γ ⟩⟩c Pilot2.|- || nat ->s nat ||
dbl-trans = prod 0C
(lam
(prod
(plusC (l-proj (prod 0C (var i0)))
(l-proj
(rec (r-proj (prod 0C (var i0)))
(prod (plusC 1C (l-proj (prod 0C z))) (r-proj (prod 0C z)))
(prod
(plusC 1C
(l-proj
(prod
(l-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))
(s
(r-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))))))
(r-proj
(prod
(l-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))
(s
(r-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))))))))))))
(r-proj
(rec (r-proj (prod 0C (var i0)))
(prod (plusC 1C (l-proj (prod 0C z))) (r-proj (prod 0C z)))
(prod
(plusC 1C
(l-proj
(prod
(l-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))
(s
(r-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))))))
(r-proj
(prod
(l-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))
(s
(r-proj
(prod
(l-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0)))))))
(s
(r-proj
(prod
(plusC (l-proj (prod 0C (var (iS i0))))
(l-proj (r-proj (prod 0C (var (iS i0))))))
(r-proj (r-proj (prod 0C (var (iS i0))))))))))))))))))
aaa : ∀ {Γ} → interpE (r-proj (dbl-trans {Γ})) == {!!}
aaa = {!!}
interp-dbl-trans : ∀ {Γ} → Monotone (fst [ ⟨⟨ Γ ⟩⟩c ]c) (fst [ ⟨⟨ nat ->s nat ⟩⟩ ]t) (snd [ ⟨⟨ Γ ⟩⟩c ]c) (snd [ ⟨⟨ nat ->s nat ⟩⟩ ]t)
interp-dbl-trans {Γ} = monotone
(λ x →
monotone
(λ p₁ →
(natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) p₁))
(λ a b c →
nat-trans
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) a))
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) b))
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) b))
(fst
(♭h-fix-args (monotone (λ x₁ → 1 , 0) (λ x₁ y z₁ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y z₁ → fst (snd (fst z₁)) , snd (snd (fst z₁))))
((x , a) , a) ((x , b) , b) c))
(fst
(♭h-fix-el (monotone (λ x₁ → 1 , 0) (λ x₁ y z₁ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y z₁ → fst (snd (fst z₁)) , snd (snd (fst z₁))))
((x , a) , a) ((x , b) , b)
((Preorder-str.refl (snd [ ⟨⟨ Γ ⟩⟩c ]c) x , c) , c)))
,
♭nat-trans
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) a))
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) b))
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) b))
(snd
(♭h-fix-args (monotone (λ x₁ → 1 , 0) (λ x₁ y z₁ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y z₁ → fst (snd (fst z₁)) , snd (snd (fst z₁))))
((x , a) , a) ((x , b) , b) c))
(snd
(♭h-fix-el (monotone (λ x₁ → 1 , 0) (λ x₁ y z₁ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y z₁ → fst (snd (fst z₁)) , snd (snd (fst z₁))))
((x , a) , a) ((x , b) , b)
((Preorder-str.refl (snd [ ⟨⟨ Γ ⟩⟩c ]c) x , c) , c)))))
(λ x y z₁ w →
nat-trans
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(fst (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(fst
(♭h-fix-args (monotone (λ x₁ → 1 , 0) (λ x₁ y₁ z₂ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y₁ z₂ → fst (snd (fst z₂)) , snd (snd (fst z₂))))
((x , w) , w) ((y , w) , w) (♭nat-refl w)))
(fst
(♭h-fix-el (monotone (λ x₁ → 1 , 0) (λ x₁ y₁ z₂ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y₁ z₂ → fst (snd (fst z₂)) , snd (snd (fst z₂))))
((x , w) , w) ((y , w) , w) ((z₁ , ♭nat-refl w) , ♭nat-refl w)))
,
♭nat-trans
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(snd (natrec (1 , 0) (λ n x₂ → S (fst x₂) , S (S (snd x₂))) w))
(snd
(♭h-fix-args (monotone (λ x₁ → 1 , 0) (λ x₁ y₁ z₂ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y₁ z₂ → fst (snd (fst z₂)) , snd (snd (fst z₂))))
((x , w) , w) ((y , w) , w) (♭nat-refl w)))
(snd
(♭h-fix-el (monotone (λ x₁ → 1 , 0) (λ x₁ y₁ z₂ → <> , <>))
(monotone
(λ x₁ → S (fst (snd (fst x₁))) , S (S (snd (snd (fst x₁)))))
(λ x₁ y₁ z₂ → fst (snd (fst z₂)) , snd (snd (fst z₂))))
((x , w) , w) ((y , w) , w) ((z₁ , ♭nat-refl w) , ♭nat-refl w))))
-}
{-
{- halve (l : list nat) : (list nat * list nat) = splits a list in half -}
halve : ∀ {Γ} → Γ Source.|- (list nat ->s (list nat ×s list nat))
halve = lam (listrec (var i0)
(prod nil nil)
(listrec (var (iS i0))
(prod (var i0 ::s nil) nil)
(prod (var (iS (iS (iS i0))) ::s split (force (var (iS (iS i0)))) (var i0)) (var i0 ::s split (force (var (iS (iS i0)))) (var (iS i0))))))
test : ∀ {Γ τ} → {!!}
test {Γ} = {!s2r (app halve (z ::s (z ::s (z ::s nil))))!}
{- merge (l1 l2 : list nat) : list nat =
match l1 with
[] -> l2
x :: xs ->
match l2 with
[] -> x :: xs
y :: ys ->
x <= y -> x :: merge xs l2
_ -> y :: merge l1 ys -}
merge : ∀ {Γ} → Γ Source.|- ((list nat ×s list nat) ->s list nat)
merge = lam (listrec (split (var i0) (var i0))
(split (var i0) (var (iS i0)))
(listrec (split (var (iS (iS (iS i0)))) (var (iS i0)))
(split (var (iS (iS (iS i0)))) (var i0))
(rec (app (app leq (var (iS (iS (iS i0))))) (var i0))
(var (iS (iS (iS i0))) ::s force (var (iS (iS (iS (iS (iS i0)))))))
(var i0 ::s app merge (prod (split (var (iS (iS (iS (iS (iS (iS (iS (iS i0))))))))) (var (iS i0))) (var (iS (iS (iS i0)))))))))
{- mergesort (l : list nat) : list nat -}
msort : ∀ {Γ} → Γ Source.|- (list nat ->s list nat)
msort = lam (listrec (var i0)
nil
(listrec (var (iS i0))
(var i0 ::s nil)
(app merge (prod
(app msort (split (app halve (var (iS (iS (iS (iS (iS (iS i0)))))))) (var i0)))
(app msort (split (app halve (var (iS (iS (iS (iS (iS (iS i0)))))))) (var (iS i0))))))))
-}
| {
"alphanum_fraction": 0.2888687524,
"avg_line_length": 57.7630853994,
"ext": "agda",
"hexsha": "3d595415869ccc7844dd2e89a931aed5f4b70ab1",
"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": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "benhuds/Agda",
"max_forks_repo_path": "complexity/complexity-final/Samples.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "benhuds/Agda",
"max_issues_repo_path": "complexity/complexity-final/Samples.agda",
"max_line_length": 152,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "benhuds/Agda",
"max_stars_repo_path": "complexity/complexity-final/Samples.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z",
"num_tokens": 5916,
"size": 20968
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.HopfJunior where
-- We define the negation function and prove that it’s an equivalence
not : Bool → Bool
not true = false
not false = true
not-not : (b : Bool) → not (not b) == b
not-not true = idp
not-not false = idp
not-equiv : Bool ≃ Bool
not-equiv = equiv not not not-not not-not
-- Definition of the junior Hopf fibration
module HopfJunior = S¹RecType Bool not-equiv
open HopfJunior using (module Wt; Wt; cct; ppt; flattening-S¹)
HopfJunior : S¹ → Type₀
HopfJunior = HopfJunior.f
-- We get that the total space is the type Wt defined in the flattening lemma.
tot-is-Wt : Σ S¹ HopfJunior == Wt
tot-is-Wt = flattening-S¹
-- Now we prove that Wt is equivalent to S¹
private
-- Map from [Wt] to [S¹]
to-cct : Unit × Bool → S¹
to-cct _ = base
to-ppt : (x : Unit × Bool) → to-cct x == to-cct x
to-ppt (_ , true) = loop
to-ppt (_ , false) = idp
module To = Wt.Rec to-cct to-ppt
to : Wt → S¹
to = To.f
-- Map from [S¹] to [Wt]
from-base : Wt
from-base = cct tt true
from-loop : from-base == from-base
from-loop = ppt tt true ∙ ppt tt false
module From = S¹Rec from-base from-loop
from : S¹ → Wt
from = From.f
-- First composite
abstract
to-from : (x : S¹) → to (from x) == x
to-from = S¹-elim idp (↓-∘=idf-in to from
(ap to (ap from loop) =⟨ From.loop-β |in-ctx ap to ⟩
ap to (ppt tt true ∙ ppt tt false) =⟨ ap-∙ to (ppt tt true) (ppt tt false) ⟩
ap to (ppt tt true) ∙ ap to (ppt tt false) =⟨ To.pp-β (tt , true) |in-ctx (λ u → u ∙ ap to (ppt tt false)) ⟩
loop ∙ ap to (ppt tt false) =⟨ To.pp-β (tt , false) |in-ctx (λ u → loop ∙ u) ⟩
loop ∙ idp =⟨ ∙-unit-r loop ⟩
loop ∎))
-- Second composite
from-to-cct : (b : Bool) → from (to (cct tt b)) == cct tt b
from-to-cct true = idp
from-to-cct false = ! (ppt tt false)
abstract
from-to-ppt : (b : Bool) → ap from (ap to (ppt tt b)) ∙' from-to-cct (not b) == from-to-cct b ∙ ppt tt b
from-to-ppt true =
ap from (ap to (ppt tt true)) ∙' ! (ppt tt false) =⟨ To.pp-β (tt , true) |in-ctx (λ u → ap from u ∙' ! (ppt tt false)) ⟩
ap from loop ∙' ! (ppt tt false) =⟨ From.loop-β |in-ctx (λ u → u ∙' ! (ppt tt false)) ⟩
(ppt tt true ∙ ppt tt false) ∙' ! (ppt tt false) =⟨ lemma (ppt tt true) (ppt tt false) ⟩
ppt tt true ∎ where
lemma : ∀ {i} {A : Type i} {a b c : A} (p : a == b) (q : b == c) → (p ∙ q) ∙' (! q) == p
lemma idp idp = idp
from-to-ppt false =
ap from (ap to (ppt tt false)) =⟨ To.pp-β (tt , false) |in-ctx ap from ⟩
ap from (idp {a = base}) =⟨ ! (!-inv-l (ppt tt false)) ⟩
! (ppt tt false) ∙ ppt tt false ∎
from-to : (x : Wt) → from (to x) == x
from-to = Wt.elim (from-to-cct ∘ snd) (λ b → ↓-∘=idf-in from to (from-to-ppt (snd b)))
-- Conclusion
subresult : Wt ≃ S¹
subresult = equiv to from to-from from-to
-- Conclusion
result : Σ S¹ HopfJunior ≃ S¹
result = subresult ∘e (coe-equiv tot-is-Wt)
| {
"alphanum_fraction": 0.5535771065,
"avg_line_length": 31.7676767677,
"ext": "agda",
"hexsha": "29197dd72afd681d132a35c9cc34bef69b0dceec",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "homotopy/HopfJunior.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "homotopy/HopfJunior.agda",
"max_line_length": 126,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/HopfJunior.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 1151,
"size": 3145
} |
-- Andreas, Jesper, 2015-07-02 Error in copyScope
-- To trigger the bug, it is important that
-- the main module is in a subdirectory of the imported module.
module Issue1597.Main where
open import Issue1597 -- external import is needed
module B where
open A public -- public is needed
module C = B
postulate p : C.M.Nat
-- ERROR WAS: not in scope C.M.Nat
| {
"alphanum_fraction": 0.7247956403,
"avg_line_length": 21.5882352941,
"ext": "agda",
"hexsha": "8f03a00753e3dde5427df401a067c373e99447ad",
"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/Issue1597/Main.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/Issue1597/Main.agda",
"max_line_length": 63,
"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/Issue1597/Main.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": 102,
"size": 367
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists where at least one element satisfies a given property
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.Any {a} {A : Set a} where
open import Data.Empty
open import Data.Fin
open import Data.List.Base as List using (List; []; [_]; _∷_)
open import Data.Product as Prod using (∃; _,_)
open import Data.Sum as Sum using (_⊎_; inj₁; inj₂)
open import Level using (_⊔_)
open import Relation.Nullary using (¬_; yes; no)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Unary hiding (_∈_)
------------------------------------------------------------------------
-- Any P xs means that at least one element in xs satisfies P.
data Any {p} (P : A → Set p) : List A → Set (a ⊔ p) where
here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)
there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)
------------------------------------------------------------------------
-- Operations on Any
module _ {p} {P : A → Set p} {x xs} where
head : ¬ Any P xs → Any P (x ∷ xs) → P x
head ¬pxs (here px) = px
head ¬pxs (there pxs) = contradiction pxs ¬pxs
tail : ¬ P x → Any P (x ∷ xs) → Any P xs
tail ¬px (here px) = ⊥-elim (¬px px)
tail ¬px (there pxs) = pxs
map : ∀ {p q} {P : A → Set p} {Q : A → Set q} → P ⊆ Q → Any P ⊆ Any Q
map g (here px) = here (g px)
map g (there pxs) = there (map g pxs)
module _ {p} {P : A → Set p} where
-- `index x∈xs` is the list position (zero-based) which `x∈xs` points to.
index : ∀ {xs} → Any P xs → Fin (List.length xs)
index (here px) = zero
index (there pxs) = suc (index pxs)
lookup : ∀ {xs} → Any P xs → A
lookup {xs} p = List.lookup xs (index p)
_∷=_ : ∀ {xs} → Any P xs → A → List A
_∷=_ {xs} x∈xs v = xs List.[ index x∈xs ]∷= v
infixl 4 _─_
_─_ : ∀ xs → Any P xs → List A
xs ─ x∈xs = xs List.─ index x∈xs
-- If any element satisfies P, then P is satisfied.
satisfied : ∀ {p} {P : A → Set p} {xs} → Any P xs → ∃ P
satisfied (here px) = _ , px
satisfied (there pxs) = satisfied pxs
module _ {p} {P : A → Set p} {x xs} where
toSum : Any P (x ∷ xs) → P x ⊎ Any P xs
toSum (here px) = inj₁ px
toSum (there pxs) = inj₂ pxs
fromSum : P x ⊎ Any P xs → Any P (x ∷ xs)
fromSum (inj₁ px) = here px
fromSum (inj₂ pxs) = there pxs
------------------------------------------------------------------------
-- Properties of predicates preserved by Any
module _ {p} {P : A → Set p} where
any : Decidable P → Decidable (Any P)
any P? [] = no λ()
any P? (x ∷ xs) with P? x
... | yes px = yes (here px)
... | no ¬px = Dec.map′ there (tail ¬px) (any P? xs)
satisfiable : Satisfiable P → Satisfiable (Any P)
satisfiable (x , Px) = [ x ] , here Px
| {
"alphanum_fraction": 0.5177960301,
"avg_line_length": 32.1098901099,
"ext": "agda",
"hexsha": "3f8f337ce9f29d37c14648c697750edf28095c97",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 963,
"size": 2922
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Posets where
-- The category of partially ordered sets and order-preserving maps.
open import Level
open import Relation.Binary using (Poset; IsEquivalence; _Preserves_⟶_)
open import Relation.Binary.OrderMorphism using (_⇒-Poset_; id; _∘_)
open import Categories.Category
open Poset renaming (_≈_ to ₍_₎_≈_; _≤_ to ₍_₎_≤_)
open _⇒-Poset_
module _ {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where
infix 4 _≗_
-- Order morphisms preserve equality.
fun-resp-≈ : (f : A ⇒-Poset B) → fun f Preserves ₍ A ₎_≈_ ⟶ ₍ B ₎_≈_
fun-resp-≈ f x≈y = antisym B (monotone f (reflexive A x≈y))
(monotone f (reflexive A (Eq.sym A x≈y)))
-- Pointwise equality (on order preserving maps).
_≗_ : (f g : A ⇒-Poset B) → Set (a₁ ⊔ b₂)
f ≗ g = ∀ {x} → ₍ B ₎ fun f x ≈ fun g x
≗-isEquivalence : IsEquivalence _≗_
≗-isEquivalence = record
{ refl = Eq.refl B
; sym = λ f≈g → Eq.sym B f≈g
; trans = λ f≈g g≈h → Eq.trans B f≈g g≈h
}
module ≗ = IsEquivalence ≗-isEquivalence
-- The category of posets and order-preserving maps.
Posets : ∀ c ℓ₁ ℓ₂ → Category (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) (c ⊔ ℓ₂) (c ⊔ ℓ₁)
Posets c ℓ₁ ℓ₂ = record
{ Obj = Poset c ℓ₁ ℓ₂
; _⇒_ = _⇒-Poset_
; _≈_ = _≗_
; id = id
; _∘_ = _∘_
; assoc = λ {_ _ _ D} → Eq.refl D
; sym-assoc = λ {_ _ _ D} → Eq.refl D
; identityˡ = λ {_ B} → Eq.refl B
; identityʳ = λ {_ B} → Eq.refl B
; identity² = λ {A} → Eq.refl A
; equiv = ≗-isEquivalence
; ∘-resp-≈ = λ {_ _ C _ h} f≈h g≈i → Eq.trans C f≈h (fun-resp-≈ h g≈i)
}
where
| {
"alphanum_fraction": 0.5752369668,
"avg_line_length": 29.1034482759,
"ext": "agda",
"hexsha": "eaa6e7c656c620a7b9a4356d3442aa9286f43e81",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/Posets.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/Posets.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Instance/Posets.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 725,
"size": 1688
} |
module Automaton.NonDeterministic where
import Lvl
open import Data.Boolean
import Data.Boolean.Operators
open Data.Boolean.Operators.Programming
open import Data.List using (List) renaming (∅ to ε ; _⊰_ to _·_)
open import Functional
open import Logic
open import Sets.ExtensionalPredicateSet
open import Structure.Setoid
open import Type
-- Non-deterministic Automata
-- `State` (Q) is the set of states.
-- `Alphabet` (Σ) is the set of symbols/the alphabet.
-- `transition` (δ) is the transition function.
-- `start` (q₀) is the start state.
-- `Final` (F) is the subset of State which are the final/accepting states.
record NonDeterministic {ℓₚ ℓₛ ℓₑ ℓₐ} (State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑ}(State) ⦄ (Alphabet : Type{ℓₐ}) : Type{ℓₛ Lvl.⊔ ℓₑ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where
constructor nondeterministic
field
transition : State → Alphabet → PredSet{ℓₚ}(State)
start : State
Final : PredSet{ℓₚ}(State)
Word = List(Alphabet)
-- Chained transition using a word (list of characters).
wordTransition : State → Word → PredSet{ℓₑ}(State)
wordTransition initialState ε = • initialState
wordTransition initialState (a · l) = {!⋃ ?!} -- wordTransition (transition initialState a) l
{-
module LetterNotation where
Q = State
Σ = Alphabet
δ = transition
δ̂ = wordTransition
q₀ = start
F = Final
-- A word is accepted by the automaton when it can transition from the start state to a final state.
AcceptsWord : Word → Stmt
AcceptsWord = (_∈ Final) ∘ wordTransition start
-- The subset of State which are the accessible states from the start state by chained transitions.
Accessible : PredSet(State)
Accessible = ⊶(wordTransition start)
automatonTransition : Alphabet → NonDeterministic(State)(Alphabet)
transition (automatonTransition _) = transition
start (automatonTransition c) = transition start c
Final (automatonTransition _) = Final
automatonTransitionWord : Word → NonDeterministic(State)(Alphabet)
transition (automatonTransitionWord _) = transition
start (automatonTransitionWord w) = wordTransition start w
Final (automatonTransitionWord _) = Final
-}
| {
"alphanum_fraction": 0.7069120287,
"avg_line_length": 37.1333333333,
"ext": "agda",
"hexsha": "e718bcd244899efea71637f16ace86f60742b25b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Automaton/NonDeterministic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Automaton/NonDeterministic.agda",
"max_line_length": 164,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Automaton/NonDeterministic.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": 648,
"size": 2228
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Monoidal.Construction.Product where
-- The product A × B of (braided/symmetric) monoidal categories
-- A and B is again (braided/symmetric) monoidal.
open import Level using (_⊔_)
open import Data.Product using (_,_; dmap; zip; curry′; uncurry′)
open import Categories.Category using (Category)
open import Categories.Category.Product using (Product)
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Braided using (Braided)
open import Categories.Category.Monoidal.Symmetric using (Symmetric)
open import Categories.Functor using (Functor)
open import Categories.Functor.Bifunctor using (Bifunctor)
open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper)
open Category using (Obj)
module _ {o o′ ℓ ℓ′ e e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(M : Monoidal C) (N : Monoidal D) where
private
module M = Monoidal M
module N = Monoidal N
module ⊗₁ = Functor M.⊗
module ⊗₂ = Functor N.⊗
⊗ : Bifunctor (Product C D) (Product C D) (Product C D)
⊗ = record
{ F₀ = uncurry′ (zip (curry′ ⊗₁.₀) (curry′ ⊗₂.₀))
; F₁ = uncurry′ (zip (curry′ ⊗₁.₁) (curry′ ⊗₂.₁))
; identity = ⊗₁.identity , ⊗₂.identity
; homomorphism = ⊗₁.homomorphism , ⊗₂.homomorphism
; F-resp-≈ = uncurry′ (zip (curry′ ⊗₁.F-resp-≈) (curry′ ⊗₂.F-resp-≈))
}
unit : Obj (Product C D)
unit = M.unit , N.unit
Product-Monoidal : Monoidal (Product C D)
Product-Monoidal = record
{ ⊗ = ⊗
; unit = unit
; unitorˡ = record
{ from = M.unitorˡ.from , N.unitorˡ.from
; to = M.unitorˡ.to , N.unitorˡ.to
; iso = record
{ isoˡ = M.unitorˡ.isoˡ , N.unitorˡ.isoˡ
; isoʳ = M.unitorˡ.isoʳ , N.unitorˡ.isoʳ
}
}
; unitorʳ = record
{ from = M.unitorʳ.from , N.unitorʳ.from
; to = M.unitorʳ.to , N.unitorʳ.to
; iso = record
{ isoˡ = M.unitorʳ.isoˡ , N.unitorʳ.isoˡ
; isoʳ = M.unitorʳ.isoʳ , N.unitorʳ.isoʳ
}
}
; associator = record
{ from = M.associator.from , N.associator.from
; to = M.associator.to , N.associator.to
; iso = record
{ isoˡ = M.associator.isoˡ , N.associator.isoˡ
; isoʳ = M.associator.isoʳ , N.associator.isoʳ
}
}
; unitorˡ-commute-from = M.unitorˡ-commute-from , N.unitorˡ-commute-from
; unitorˡ-commute-to = M.unitorˡ-commute-to , N.unitorˡ-commute-to
; unitorʳ-commute-from = M.unitorʳ-commute-from , N.unitorʳ-commute-from
; unitorʳ-commute-to = M.unitorʳ-commute-to , N.unitorʳ-commute-to
; assoc-commute-from = M.assoc-commute-from , N.assoc-commute-from
; assoc-commute-to = M.assoc-commute-to , N.assoc-commute-to
; triangle = M.triangle , N.triangle
; pentagon = M.pentagon , N.pentagon
}
module _ {o o′ ℓ ℓ′ e e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
{M : Monoidal C} {N : Monoidal D} where
Product-Braided : Braided M → Braided N → Braided (Product-Monoidal M N)
Product-Braided BM BN = record
{ braiding = niHelper (record
{ η = λ{ ((W , X) , (Y , Z)) →
BM.braiding.⇒.η (W , Y) , BN.braiding.⇒.η (X , Z) }
; η⁻¹ = λ{ ((W , X) , (Y , Z)) →
BM.braiding.⇐.η (W , Y) , BN.braiding.⇐.η (X , Z) }
; commute = λ{ ((f , g) , (h , i)) →
BM.braiding.⇒.commute (f , h) , BN.braiding.⇒.commute (g , i) }
; iso = λ{ ((W , X) , (Y , Z)) → record
{ isoˡ = BM.braiding.iso.isoˡ (W , Y) , BN.braiding.iso.isoˡ (X , Z)
; isoʳ = BM.braiding.iso.isoʳ (W , Y) , BN.braiding.iso.isoʳ (X , Z)
} }
})
; hexagon₁ = BM.hexagon₁ , BN.hexagon₁
; hexagon₂ = BM.hexagon₂ , BN.hexagon₂
}
where
module BM = Braided BM
module BN = Braided BN
Product-Symmetric : Symmetric M → Symmetric N → Symmetric (Product-Monoidal M N)
Product-Symmetric SM SN = record
{ braided = Product-Braided SM.braided SN.braided
; commutative = SM.commutative , SN.commutative
}
where
module SM = Symmetric SM
module SN = Symmetric SN
Product-MonoidalCategory : ∀ {o o′ ℓ ℓ′ e e′} →
MonoidalCategory o ℓ e → MonoidalCategory o′ ℓ′ e′ →
MonoidalCategory (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
Product-MonoidalCategory C D = record
{ U = Product (C.U) (D.U)
; monoidal = Product-Monoidal (C.monoidal) (D.monoidal)
}
where
module C = MonoidalCategory C
module D = MonoidalCategory D
Product-BraidedMonoidalCategory : ∀ {o o′ ℓ ℓ′ e e′} →
BraidedMonoidalCategory o ℓ e → BraidedMonoidalCategory o′ ℓ′ e′ →
BraidedMonoidalCategory (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
Product-BraidedMonoidalCategory C D = record
{ U = Product (C.U) (D.U)
; monoidal = Product-Monoidal (C.monoidal) (D.monoidal)
; braided = Product-Braided (C.braided) (D.braided)
}
where
module C = BraidedMonoidalCategory C
module D = BraidedMonoidalCategory D
Product-SymmetricMonoidalCategory : ∀ {o o′ ℓ ℓ′ e e′} →
SymmetricMonoidalCategory o ℓ e → SymmetricMonoidalCategory o′ ℓ′ e′ →
SymmetricMonoidalCategory (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
Product-SymmetricMonoidalCategory C D = record
{ U = Product (C.U) (D.U)
; monoidal = Product-Monoidal (C.monoidal) (D.monoidal)
; symmetric = Product-Symmetric (C.symmetric) (D.symmetric)
}
where
module C = SymmetricMonoidalCategory C
module D = SymmetricMonoidalCategory D
| {
"alphanum_fraction": 0.5990081474,
"avg_line_length": 38.1486486486,
"ext": "agda",
"hexsha": "7a070452786cf2d49d1a5f26bb07890aeba951b2",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Construction/Product.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Construction/Product.agda",
"max_line_length": 82,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Construction/Product.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": 1988,
"size": 5646
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.