hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cb36a6c2da0bed3033d96eb8a7773678bbd78b30
| 11,424
|
agda
|
Agda
|
test/Succeed/Issue4868.agda
|
LaloHao/agda
|
7de768bb7bc65dbe1efa35c699cfa8b8f9510573
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4868.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4868.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Float
renaming ( primFloatEquality to _≡ᵇ_
; primFloatInequality to _≤ᵇ_
; primFloatLess to _<ᵇ_
; primFloatPlus to infixl 6 _+_
; primFloatMinus to infixl 6 _-_
; primFloatTimes to infixl 7 _*_
; primFloatDiv to infixl 7 _÷_
; primFloatPow to infix 8 _**_
; primFloatNegate to infix 9 -_
; primFloatSqrt to sqrt
; primFloatExp to e^_
; primFloatLog to log
; primFloatSin to sin
; primFloatCos to cos
; primFloatTan to tan
; primFloatASin to asin
; primFloatACos to acos
; primFloatATan to atan
; primFloatATan2 to atan2
; primFloatSinh to sinh
; primFloatCosh to cosh
; primFloatTanh to tanh
; primFloatASinh to asinh
; primFloatACosh to acosh
; primFloatATanh to atanh
; primFloatRound to round
; primFloatFloor to floor
; primFloatCeiling to ceiling
; primShowFloat to show
; primFloatToWord64 to toWord
; primFloatToRatio to toRatio
; primRatioToFloat to fromRatio
; primFloatDecode to decode
; primFloatEncode to encode
; primFloatIsInfinite to isInfinite
; primFloatIsNaN to isNaN
; primFloatIsNegativeZero to isNegativeZero
; primFloatIsSafeInteger to isSafeInteger
)
open import Agda.Builtin.Int
open import Agda.Builtin.Maybe
open import Agda.Builtin.Sigma
open import Agda.Builtin.Word
renaming ( primWord64ToNat to toℕ
)
-- Prelude
data ⊥ : Set where
_≢_ : {A : Set} (P Q : A) → Set
P ≢ Q = P ≡ Q → ⊥
NaN : Float
NaN = 0.0 ÷ 0.0
-NaN : Float
-NaN = - NaN
Infinity : Float
Infinity = 1.0 ÷ 0.0
-Infinity : Float
-Infinity = - Infinity
MaxFloat : Float
MaxFloat = 1.7976931348623157e308
MinFloat : Float
MinFloat = 2.2250738585072014e-308
MaxSafeIntF : Float
MaxSafeIntF = 9007199254740991.0
MaxSafeIntZ : Int
MaxSafeIntZ = pos 9007199254740991
-- * Tests
-- ** Relations
_ : -NaN ≡ NaN ; _ = refl
_ : -0.0 ≢ 0.0 ; _ = λ ()
_ : Infinity ≢ -Infinity ; _ = λ ()
_ : Infinity ≡ Infinity ; _ = refl
_ : -Infinity ≡ -Infinity ; _ = refl
_ : Infinity ≡ - -Infinity ; _ = refl
_ : Infinity ≢ -Infinity ; _ = λ ()
_ : NaN ≡ᵇ NaN ≡ false ; _ = refl
_ : -NaN ≡ᵇ NaN ≡ false ; _ = refl
_ : NaN ≡ᵇ -NaN ≡ false ; _ = refl
_ : -NaN ≡ᵇ -NaN ≡ false ; _ = refl
_ : Infinity ≡ᵇ Infinity ≡ true ; _ = refl
_ : -Infinity ≡ᵇ Infinity ≡ false ; _ = refl
_ : Infinity ≡ᵇ -Infinity ≡ false ; _ = refl
_ : -Infinity ≡ᵇ -Infinity ≡ true ; _ = refl
_ : MaxFloat ≡ᵇ MaxFloat ≡ true ; _ = refl
_ : MinFloat ≡ᵇ MinFloat ≡ true ; _ = refl
_ : 1.0 ≡ᵇ 1.5 ≡ false ; _ = refl
_ : 1.0 ≡ᵇ 1.0 ≡ true ; _ = refl
_ : 1.5 ≡ᵇ 1.5 ≡ true ; _ = refl
_ : NaN ≤ᵇ NaN ≡ false ; _ = refl
_ : -NaN ≤ᵇ NaN ≡ false ; _ = refl
_ : NaN ≤ᵇ -NaN ≡ false ; _ = refl
_ : -NaN ≤ᵇ -NaN ≡ false ; _ = refl
_ : NaN ≤ᵇ 5.0 ≡ false ; _ = refl
_ : -NaN ≤ᵇ 5.0 ≡ false ; _ = refl
_ : 5.0 ≤ᵇ -NaN ≡ false ; _ = refl
_ : -5.0 ≤ᵇ -NaN ≡ false ; _ = refl
_ : NaN ≤ᵇ Infinity ≡ false ; _ = refl
_ : -NaN ≤ᵇ Infinity ≡ false ; _ = refl
_ : Infinity ≤ᵇ -NaN ≡ false ; _ = refl
_ : -Infinity ≤ᵇ -NaN ≡ false ; _ = refl
_ : Infinity ≤ᵇ Infinity ≡ true ; _ = refl
_ : -Infinity ≤ᵇ Infinity ≡ true ; _ = refl
_ : Infinity ≤ᵇ -Infinity ≡ false ; _ = refl
_ : -Infinity ≤ᵇ -Infinity ≡ true ; _ = refl
_ : MaxFloat ≤ᵇ MaxFloat ≡ true ; _ = refl
_ : MinFloat ≤ᵇ MinFloat ≡ true ; _ = refl
_ : 1.0 ≤ᵇ 1.5 ≡ true ; _ = refl
_ : 1.0 ≤ᵇ 1.0 ≡ true ; _ = refl
_ : 1.5 ≤ᵇ 1.5 ≡ true ; _ = refl
_ : NaN <ᵇ NaN ≡ false ; _ = refl
_ : -NaN <ᵇ NaN ≡ false ; _ = refl
_ : NaN <ᵇ -NaN ≡ false ; _ = refl
_ : -NaN <ᵇ -NaN ≡ false ; _ = refl
_ : NaN <ᵇ 5.0 ≡ false ; _ = refl
_ : -NaN <ᵇ 5.0 ≡ false ; _ = refl
_ : 5.0 <ᵇ -NaN ≡ false ; _ = refl
_ : -5.0 <ᵇ -NaN ≡ false ; _ = refl
_ : NaN <ᵇ Infinity ≡ false ; _ = refl
_ : -NaN <ᵇ Infinity ≡ false ; _ = refl
_ : Infinity <ᵇ -NaN ≡ false ; _ = refl
_ : -Infinity <ᵇ -NaN ≡ false ; _ = refl
_ : Infinity <ᵇ Infinity ≡ false ; _ = refl
_ : -Infinity <ᵇ Infinity ≡ true ; _ = refl
_ : Infinity <ᵇ -Infinity ≡ false ; _ = refl
_ : -Infinity <ᵇ -Infinity ≡ false ; _ = refl
_ : MaxFloat <ᵇ MaxFloat ≡ false ; _ = refl
_ : MinFloat <ᵇ MinFloat ≡ false ; _ = refl
_ : 1.0 <ᵇ 1.5 ≡ true ; _ = refl
_ : 1.0 <ᵇ 1.0 ≡ false ; _ = refl
_ : 1.5 <ᵇ 1.5 ≡ false ; _ = refl
_ : isNaN NaN ≡ true ; _ = refl
_ : isNaN -NaN ≡ true ; _ = refl
_ : isNaN Infinity ≡ false ; _ = refl
_ : isNaN -Infinity ≡ false ; _ = refl
_ : isNaN 0.0 ≡ false ; _ = refl
_ : isNaN -0.0 ≡ false ; _ = refl
_ : isNaN 1.0 ≡ false ; _ = refl
_ : isNaN 1.5 ≡ false ; _ = refl
_ : isInfinite NaN ≡ false ; _ = refl
_ : isInfinite -NaN ≡ false ; _ = refl
_ : isInfinite Infinity ≡ true ; _ = refl
_ : isInfinite -Infinity ≡ true ; _ = refl
_ : isInfinite 0.0 ≡ false ; _ = refl
_ : isInfinite -0.0 ≡ false ; _ = refl
_ : isInfinite 1.0 ≡ false ; _ = refl
_ : isInfinite 1.5 ≡ false ; _ = refl
_ : isInfinite ((MaxFloat * MaxFloat) ÷ MaxFloat) ≡ true ; _ = refl
_ : isNegativeZero NaN ≡ false ; _ = refl
_ : isNegativeZero -NaN ≡ false ; _ = refl
_ : isNegativeZero Infinity ≡ false ; _ = refl
_ : isNegativeZero -Infinity ≡ false ; _ = refl
_ : isNegativeZero 0.0 ≡ false ; _ = refl
_ : isNegativeZero -0.0 ≡ true ; _ = refl
_ : isNegativeZero 1.0 ≡ false ; _ = refl
_ : isNegativeZero 1.5 ≡ false ; _ = refl
_ : isSafeInteger 1.0 ≡ true ; _ = refl
_ : isSafeInteger 1.5 ≡ false ; _ = refl
_ : isSafeInteger MaxFloat ≡ false ; _ = refl
_ : isSafeInteger MinFloat ≡ false ; _ = refl
_ : isSafeInteger MaxSafeIntF ≡ true ; _ = refl
-- ** Conversions
_ : show NaN ≡ "NaN" ; _ = refl
_ : show -NaN ≡ "NaN" ; _ = refl
_ : show 0.0 ≡ "0.0" ; _ = refl
_ : show -0.0 ≡ "-0.0" ; _ = refl
_ : show Infinity ≡ "Infinity" ; _ = refl
_ : show -Infinity ≡ "-Infinity" ; _ = refl
_ : show 1.0 ≡ "1.0" ; _ = refl
_ : show 1.5 ≡ "1.5" ; _ = refl
_ : toℕ (toWord 1.0) ≡ 4607182418800017408 ; _ = refl
_ : toℕ (toWord 1.5) ≡ 4609434218613702656 ; _ = refl
_ : toℕ (toWord 0.0) ≡ 0 ; _ = refl
_ : toℕ (toWord -0.0) ≡ 9223372036854775808 ; _ = refl
_ : toℕ (toWord NaN) ≡ 18444492273895866368 ; _ = refl
_ : toℕ (toWord -NaN) ≡ 18444492273895866368 ; _ = refl
_ : toℕ (toWord Infinity) ≡ 9218868437227405312 ; _ = refl
_ : toℕ (toWord -Infinity) ≡ 18442240474082181120 ; _ = refl
_ : round 1.0 ≡ just (pos 1) ; _ = refl
_ : round 1.5 ≡ just (pos 2) ; _ = refl
_ : round NaN ≡ nothing ; _ = refl
_ : round -NaN ≡ nothing ; _ = refl
_ : round Infinity ≡ nothing ; _ = refl
_ : round -Infinity ≡ nothing ; _ = refl
_ : round MinFloat ≡ just (pos 0) ; _ = refl
_ : round MaxFloat ≡ just (pos 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368) ; _ = refl
_ : floor 1.0 ≡ just (pos 1) ; _ = refl
_ : floor 1.5 ≡ just (pos 1) ; _ = refl
_ : floor NaN ≡ nothing ; _ = refl
_ : floor -NaN ≡ nothing ; _ = refl
_ : floor Infinity ≡ nothing ; _ = refl
_ : floor -Infinity ≡ nothing ; _ = refl
_ : floor MinFloat ≡ just (pos 0) ; _ = refl
_ : floor MaxFloat ≡ just (pos 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368) ; _ = refl
_ : ceiling 1.0 ≡ just (pos 1) ; _ = refl
_ : ceiling 1.5 ≡ just (pos 2) ; _ = refl
_ : ceiling NaN ≡ nothing ; _ = refl
_ : ceiling -NaN ≡ nothing ; _ = refl
_ : ceiling Infinity ≡ nothing ; _ = refl
_ : ceiling -Infinity ≡ nothing ; _ = refl
_ : ceiling MinFloat ≡ just (pos 1) ; _ = refl
_ : ceiling MaxFloat ≡ just (pos 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368) ; _ = refl
_ : decode NaN ≡ nothing ; _ = refl
_ : decode Infinity ≡ nothing ; _ = refl
_ : decode -Infinity ≡ nothing ; _ = refl
_ : decode 1.0 ≡ just (pos 1 , pos 0) ; _ = refl
_ : decode 1.5 ≡ just (pos 3 , negsuc 0) ; _ = refl
_ : decode MaxFloat ≡ just (MaxSafeIntZ , pos 971) ; _ = refl
_ : decode MinFloat ≡ just (pos 1 , negsuc 1021) ; _ = refl
_ : encode (pos 1) (pos 0) ≡ just 1.0 ; _ = refl
_ : encode (pos 3) (negsuc 0) ≡ just 1.5 ; _ = refl
_ : encode MaxSafeIntZ (pos 0) ≡ just MaxSafeIntF ; _ = refl
_ : encode MaxSafeIntZ (pos 971) ≡ just MaxFloat ; _ = refl
_ : encode MaxSafeIntZ (pos 972) ≡ nothing ; _ = refl
_ : encode (pos 1) (negsuc 1021) ≡ just MinFloat ; _ = refl
_ : encode MaxSafeIntZ (negsuc 1075) ≡ nothing ; _ = refl
_ : toRatio NaN ≡ (pos 0 , pos 0) ; _ = refl
_ : toRatio Infinity ≡ (pos 1 , pos 0) ; _ = refl
_ : toRatio -Infinity ≡ (negsuc 0 , pos 0) ; _ = refl
_ : toRatio 1.0 ≡ (pos 1 , pos 1) ; _ = refl
_ : toRatio 1.5 ≡ (pos 3 , pos 2) ; _ = refl
_ : fromRatio (pos 0) (pos 0) ≡ NaN ; _ = refl
_ : fromRatio (pos 1) (pos 0) ≡ Infinity ; _ = refl
_ : fromRatio (negsuc 0) (pos 0) ≡ -Infinity ; _ = refl
_ : fromRatio (pos 1) (pos 1) ≡ 1.0 ; _ = refl
_ : fromRatio (pos 3) (pos 2) ≡ 1.5 ; _ = refl
_ : e^ 1.0 ≡ 2.718281828459045 ; _ = refl
_ : sin (asin 0.6) ≡ 0.6 ; _ = refl
_ : cos (acos 0.6) ≡ 0.6 ; _ = refl
_ : tan (atan 0.4) ≡ 0.4 ; _ = refl
_ : tan (atan2 0.4 1.0) ≡ 0.4 ; _ = refl
| 42.786517
| 355
| 0.544468
|
d024c695574f5e2ea911b641290be28fbd69fa29
| 504
|
agda
|
Agda
|
prototyping/FFI/Data/Either.agda
|
morgoth990/luau
|
dbdf91f3cad8ea9e881b8cf99931f654faf65c2e
|
[
"MIT"
] | 1
|
2022-02-11T21:30:17.000Z
|
2022-02-11T21:30:17.000Z
|
prototyping/FFI/Data/Either.agda
|
morgoth990/luau
|
dbdf91f3cad8ea9e881b8cf99931f654faf65c2e
|
[
"MIT"
] | null | null | null |
prototyping/FFI/Data/Either.agda
|
morgoth990/luau
|
dbdf91f3cad8ea9e881b8cf99931f654faf65c2e
|
[
"MIT"
] | null | null | null |
module FFI.Data.Either where
{-# FOREIGN GHC import qualified Data.Either #-}
data Either (A B : Set) : Set where
Left : A → Either A B
Right : B → Either A B
{-# COMPILE GHC Either = data Data.Either.Either (Data.Either.Left|Data.Either.Right) #-}
mapLeft : ∀ {A B C} → (A → B) → (Either A C) → (Either B C)
mapLeft f (Left x) = Left (f x)
mapLeft f (Right x) = Right x
mapRight : ∀ {A B C} → (B → C) → (Either A B) → (Either A C)
mapRight f (Left x) = Left x
mapRight f (Right x) = Right (f x)
| 29.647059
| 89
| 0.617063
|
cb2433fa7c841a6b38923c33ba9d084c19017495
| 4,471
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Container/Combinator/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Container/Combinator/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Container/Combinator/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Correctness proofs for container combinators
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Container.Combinator.Properties where
open import Axiom.Extensionality.Propositional using (Extensionality)
open import Data.Container.Core
open import Data.Container.Combinator
open import Data.Container.Relation.Unary.Any
open import Data.Empty using (⊥-elim)
open import Data.Product as Prod using (∃; _,_; proj₁; proj₂; <_,_>; uncurry; curry)
open import Data.Sum as S using (inj₁; inj₂; [_,_]′; [_,_])
open import Function as F using (_∘′_)
open import Function.Inverse as Inv using (_↔_; inverse; module Inverse)
open import Level using (_⊔_; lower)
open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_)
-- I have proved some of the correctness statements under the
-- assumption of functional extensionality. I could have reformulated
-- the statements using suitable setoids, but I could not be bothered.
module Identity where
correct : ∀ {s p x} {X : Set x} → ⟦ id {s} {p} ⟧ X ↔ F.id X
correct {X = X} = inverse to from (λ _ → P.refl) (λ _ → P.refl)
where
to : ⟦ id ⟧ X → F.id X
to xs = proj₂ xs _
from : F.id X → ⟦ id ⟧ X
from x = (_ , λ _ → x)
module Constant (ext : ∀ {ℓ ℓ′} → Extensionality ℓ ℓ′) where
correct : ∀ {x p y} (X : Set x) {Y : Set y} → ⟦ const {x} {p ⊔ y} X ⟧ Y ↔ F.const X Y
correct {x} {y} X {Y} = inverse proj₁ from from∘to λ _ → P.refl
where
from : X → ⟦ const X ⟧ Y
from = < F.id , F.const (⊥-elim ∘′ lower) >
from∘to : (x : ⟦ const X ⟧ Y) → from (proj₁ x) ≡ x
from∘to xs = P.cong (proj₁ xs ,_) (ext (λ x → ⊥-elim (lower x)))
module Composition {s₁ s₂ p₁ p₂} (C₁ : Container s₁ p₁) (C₂ : Container s₂ p₂) where
correct : ∀ {x} {X : Set x} → ⟦ C₁ ∘ C₂ ⟧ X ↔ (⟦ C₁ ⟧ F.∘ ⟦ C₂ ⟧) X
correct {X = X} = inverse to from (λ _ → P.refl) (λ _ → P.refl)
where
to : ⟦ C₁ ∘ C₂ ⟧ X → ⟦ C₁ ⟧ (⟦ C₂ ⟧ X)
to ((s , f) , g) = (s , < f , curry (g ∘′ any) >)
from : ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) → ⟦ C₁ ∘ C₂ ⟧ X
from (s , f) = ((s , proj₁ F.∘ f) , uncurry (proj₂ F.∘ f) ∘′ ◇.proof)
module Product (ext : ∀ {ℓ ℓ′} → Extensionality ℓ ℓ′)
{s₁ s₂ p₁ p₂} (C₁ : Container s₁ p₁) (C₂ : Container s₂ p₂) where
correct : ∀ {x} {X : Set x} → ⟦ C₁ × C₂ ⟧ X ↔ (⟦ C₁ ⟧ X Prod.× ⟦ C₂ ⟧ X)
correct {X = X} = inverse to from from∘to (λ _ → P.refl)
where
to : ⟦ C₁ × C₂ ⟧ X → ⟦ C₁ ⟧ X Prod.× ⟦ C₂ ⟧ X
to ((s₁ , s₂) , f) = ((s₁ , f F.∘ inj₁) , (s₂ , f F.∘ inj₂))
from : ⟦ C₁ ⟧ X Prod.× ⟦ C₂ ⟧ X → ⟦ C₁ × C₂ ⟧ X
from ((s₁ , f₁) , (s₂ , f₂)) = ((s₁ , s₂) , [ f₁ , f₂ ]′)
from∘to : from F.∘ to ≗ F.id
from∘to (s , f) =
P.cong (s ,_) (ext [ (λ _ → P.refl) , (λ _ → P.refl) ])
module IndexedProduct {i s p} {I : Set i} (Cᵢ : I → Container s p) where
correct : ∀ {x} {X : Set x} → ⟦ Π I Cᵢ ⟧ X ↔ (∀ i → ⟦ Cᵢ i ⟧ X)
correct {X = X} = inverse to from (λ _ → P.refl) (λ _ → P.refl)
where
to : ⟦ Π I Cᵢ ⟧ X → ∀ i → ⟦ Cᵢ i ⟧ X
to (s , f) = λ i → (s i , λ p → f (i , p))
from : (∀ i → ⟦ Cᵢ i ⟧ X) → ⟦ Π I Cᵢ ⟧ X
from f = (proj₁ F.∘ f , uncurry (proj₂ F.∘ f))
module Sum {s₁ s₂ p} (C₁ : Container s₁ p) (C₂ : Container s₂ p) where
correct : ∀ {x} {X : Set x} → ⟦ C₁ ⊎ C₂ ⟧ X ↔ (⟦ C₁ ⟧ X S.⊎ ⟦ C₂ ⟧ X)
correct {X = X} = inverse to from from∘to to∘from
where
to : ⟦ C₁ ⊎ C₂ ⟧ X → ⟦ C₁ ⟧ X S.⊎ ⟦ C₂ ⟧ X
to (inj₁ s₁ , f) = inj₁ (s₁ , f)
to (inj₂ s₂ , f) = inj₂ (s₂ , f)
from : ⟦ C₁ ⟧ X S.⊎ ⟦ C₂ ⟧ X → ⟦ C₁ ⊎ C₂ ⟧ X
from = [ Prod.map inj₁ F.id , Prod.map inj₂ F.id ]′
from∘to : from F.∘ to ≗ F.id
from∘to (inj₁ s₁ , f) = P.refl
from∘to (inj₂ s₂ , f) = P.refl
to∘from : to F.∘ from ≗ F.id
to∘from = [ (λ _ → P.refl) , (λ _ → P.refl) ]
module IndexedSum {i s p} {I : Set i} (C : I → Container s p) where
correct : ∀ {x} {X : Set x} → ⟦ Σ I C ⟧ X ↔ (∃ λ i → ⟦ C i ⟧ X)
correct {X = X} = inverse to from (λ _ → P.refl) (λ _ → P.refl)
where
to : ⟦ Σ I C ⟧ X → ∃ λ i → ⟦ C i ⟧ X
to ((i , s) , f) = (i , (s , f))
from : (∃ λ i → ⟦ C i ⟧ X) → ⟦ Σ I C ⟧ X
from (i , (s , f)) = ((i , s) , f)
module ConstantExponentiation {i s p} {I : Set i} (C : Container s p) where
correct : ∀ {x} {X : Set x} → ⟦ const[ I ]⟶ C ⟧ X ↔ (I → ⟦ C ⟧ X)
correct = IndexedProduct.correct (F.const C)
| 36.647541
| 87
| 0.5104
|
390a0f3eb0969b3fe847979fb117510e93911d42
| 7,807
|
agda
|
Agda
|
Cubical/Categories/NaturalTransformation/Base.agda
|
Edlyr/cubical
|
5de11df25b79ee49d5c084fbbe6dfc66e4147a2e
|
[
"MIT"
] | null | null | null |
Cubical/Categories/NaturalTransformation/Base.agda
|
Edlyr/cubical
|
5de11df25b79ee49d5c084fbbe6dfc66e4147a2e
|
[
"MIT"
] | null | null | null |
Cubical/Categories/NaturalTransformation/Base.agda
|
Edlyr/cubical
|
5de11df25b79ee49d5c084fbbe6dfc66e4147a2e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.NaturalTransformation.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism renaming (iso to iIso)
open import Cubical.Data.Sigma
open import Cubical.Categories.Category
open import Cubical.Categories.Functor.Base
open import Cubical.Categories.Functor.Properties
open import Cubical.Categories.Commutativity
open import Cubical.Categories.Morphism renaming (isIso to isIsoC)
private
variable
ℓC ℓC' ℓD ℓD' : Level
module _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where
-- syntax for sequencing in category D
infixl 15 _⋆ᴰ_
private
_⋆ᴰ_ : ∀ {x y z} (f : D [ x , y ]) (g : D [ y , z ]) → D [ x , z ]
f ⋆ᴰ g = f ⋆⟨ D ⟩ g
open Precategory
open Functor
-- type aliases because it gets tedious typing it out all the time
N-ob-Type : (F G : Functor C D) → Type _
N-ob-Type F G = (x : C .ob) → D [(F .F-ob x) , (G .F-ob x)]
N-hom-Type : (F G : Functor C D) → N-ob-Type F G → Type _
N-hom-Type F G ϕ = {x y : C .ob} (f : C [ x , y ]) → (F .F-hom f) ⋆ᴰ (ϕ y) ≡ (ϕ x) ⋆ᴰ (G .F-hom f)
record NatTrans (F G : Functor C D) : Type (ℓ-max (ℓ-max ℓC ℓC') ℓD') where
constructor natTrans
field
-- components of the natural transformation
N-ob : N-ob-Type F G
-- naturality condition
N-hom : N-hom-Type F G N-ob
record NatIso (F G : Functor C D): Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
field
trans : NatTrans F G
open NatTrans trans
field
nIso : ∀ (x : C .ob) → isIsoC {C = D} (N-ob x)
open isIsoC
-- the three other commuting squares
sqRL : ∀ {x y : C .ob} {f : C [ x , y ]}
→ F ⟪ f ⟫ ≡ (N-ob x) ⋆ᴰ G ⟪ f ⟫ ⋆ᴰ (nIso y) .inv
sqRL {x} {y} {f} = invMoveR (isIso→areInv (nIso y)) (N-hom f)
sqLL : ∀ {x y : C .ob} {f : C [ x , y ]}
→ G ⟪ f ⟫ ⋆ᴰ (nIso y) .inv ≡ (nIso x) .inv ⋆ᴰ F ⟪ f ⟫
sqLL {x} {y} {f} = invMoveL (isIso→areInv (nIso x)) (sym sqRL')
where
sqRL' : F ⟪ f ⟫ ≡ (N-ob x) ⋆ᴰ ( G ⟪ f ⟫ ⋆ᴰ (nIso y) .inv )
sqRL' = sqRL ∙ (D .⋆Assoc _ _ _)
sqLR : ∀ {x y : C .ob} {f : C [ x , y ]}
→ G ⟪ f ⟫ ≡ (nIso x) .inv ⋆ᴰ F ⟪ f ⟫ ⋆ᴰ (N-ob y)
sqLR {x} {y} {f} = invMoveR (symAreInv (isIso→areInv (nIso y))) sqLL
open NatTrans
open NatIso
infix 10 NatTrans
syntax NatTrans F G = F ⇒ G
infix 9 NatIso
syntax NatIso F G = F ≅ᶜ G -- c superscript to indicate that this is in the context of categories
-- component of a natural transformation
infix 30 _⟦_⟧
_⟦_⟧ : ∀ {F G : Functor C D} → (F ⇒ G) → (x : C .ob) → D [(F .F-ob x) , (G .F-ob x)]
_⟦_⟧ = N-ob
idTrans : (F : Functor C D) → NatTrans F F
idTrans F .N-ob x = D .id (F .F-ob x)
idTrans F .N-hom f =
(F .F-hom f) ⋆ᴰ (idTrans F .N-ob _)
≡⟨ D .⋆IdR _ ⟩
F .F-hom f
≡⟨ sym (D .⋆IdL _) ⟩
(D .id (F .F-ob _)) ⋆ᴰ (F .F-hom f)
∎
syntax idTrans F = 1[ F ]
-- vertical sequencing
seqTrans : {F G H : Functor C D} (α : NatTrans F G) (β : NatTrans G H) → NatTrans F H
seqTrans α β .N-ob x = (α .N-ob x) ⋆ᴰ (β .N-ob x)
seqTrans {F} {G} {H} α β .N-hom f =
(F .F-hom f) ⋆ᴰ ((α .N-ob _) ⋆ᴰ (β .N-ob _))
≡⟨ sym (D .⋆Assoc _ _ _) ⟩
((F .F-hom f) ⋆ᴰ (α .N-ob _)) ⋆ᴰ (β .N-ob _)
≡[ i ]⟨ (α .N-hom f i) ⋆ᴰ (β .N-ob _) ⟩
((α .N-ob _) ⋆ᴰ (G .F-hom f)) ⋆ᴰ (β .N-ob _)
≡⟨ D .⋆Assoc _ _ _ ⟩
(α .N-ob _) ⋆ᴰ ((G .F-hom f) ⋆ᴰ (β .N-ob _))
≡[ i ]⟨ (α .N-ob _) ⋆ᴰ (β .N-hom f i) ⟩
(α .N-ob _) ⋆ᴰ ((β .N-ob _) ⋆ᴰ (H .F-hom f))
≡⟨ sym (D .⋆Assoc _ _ _) ⟩
((α .N-ob _) ⋆ᴰ (β .N-ob _)) ⋆ᴰ (H .F-hom f)
∎
compTrans : {F G H : Functor C D} (β : NatTrans G H) (α : NatTrans F G) → NatTrans F H
compTrans β α = seqTrans α β
infixl 8 seqTrans
syntax seqTrans α β = α ●ᵛ β
-- vertically sequence natural transformations whose
-- common functor is not definitional equal
seqTransP : {F G G' H : Functor C D} (p : G ≡ G')
→ (α : NatTrans F G) (β : NatTrans G' H)
→ NatTrans F H
seqTransP {F} {G} {G'} {H} p α β .N-ob x
-- sequence morphisms with non-judgementally equal (co)domain
= seqP {C = D} {p = Gx≡G'x} (α ⟦ x ⟧) (β ⟦ x ⟧)
where
Gx≡G'x : ∀ {x} → G ⟅ x ⟆ ≡ G' ⟅ x ⟆
Gx≡G'x {x} i = F-ob (p i) x
seqTransP {F} {G} {G'} {H} p α β .N-hom {x = x} {y} f
-- compose the two commuting squares
-- 1. α's commuting square
-- 2. β's commuting square, but extended to G since β is only G' ≡> H
= compSq {C = D} (α .N-hom f) βSq
where
-- functor equality implies equality of actions on objects and morphisms
Gx≡G'x : G ⟅ x ⟆ ≡ G' ⟅ x ⟆
Gx≡G'x i = F-ob (p i) x
Gy≡G'y : G ⟅ y ⟆ ≡ G' ⟅ y ⟆
Gy≡G'y i = F-ob (p i) y
Gf≡G'f : PathP (λ i → D [ Gx≡G'x i , Gy≡G'y i ]) (G ⟪ f ⟫) (G' ⟪ f ⟫)
Gf≡G'f i = p i ⟪ f ⟫
-- components of β extended out to Gx and Gy respectively
βx' = subst (λ a → D [ a , H ⟅ x ⟆ ]) (sym Gx≡G'x) (β ⟦ x ⟧)
βy' = subst (λ a → D [ a , H ⟅ y ⟆ ]) (sym Gy≡G'y) (β ⟦ y ⟧)
-- extensions are equal to originals
βy'≡βy : PathP (λ i → D [ Gy≡G'y i , H ⟅ y ⟆ ]) βy' (β ⟦ y ⟧)
βy'≡βy = symP (toPathP {A = λ i → D [ Gy≡G'y (~ i) , H ⟅ y ⟆ ]} refl)
βx≡βx' : PathP (λ i → D [ Gx≡G'x (~ i) , H ⟅ x ⟆ ]) (β ⟦ x ⟧) βx'
βx≡βx' = toPathP refl
-- left wall of square
left : PathP (λ i → D [ Gx≡G'x i , H ⟅ y ⟆ ]) (G ⟪ f ⟫ ⋆⟨ D ⟩ βy') (G' ⟪ f ⟫ ⋆⟨ D ⟩ β ⟦ y ⟧)
left i = Gf≡G'f i ⋆⟨ D ⟩ βy'≡βy i
-- right wall of square
right : PathP (λ i → D [ Gx≡G'x (~ i) , H ⟅ y ⟆ ]) (β ⟦ x ⟧ ⋆⟨ D ⟩ H ⟪ f ⟫) (βx' ⋆⟨ D ⟩ H ⟪ f ⟫)
right i = βx≡βx' i ⋆⟨ D ⟩ refl {x = H ⟪ f ⟫} i
-- putting it all together
βSq : G ⟪ f ⟫ ⋆⟨ D ⟩ βy' ≡ βx' ⋆⟨ D ⟩ H ⟪ f ⟫
βSq i = comp (λ k → D [ Gx≡G'x (~ k) , H ⟅ y ⟆ ])
(λ j → λ { (i = i0) → left (~ j)
; (i = i1) → right j })
(β .N-hom f i)
module _ ⦃ isCatD : isCategory D ⦄ {F G : Functor C D} {α β : NatTrans F G} where
open Precategory
open Functor
open NatTrans
makeNatTransPath : α .N-ob ≡ β .N-ob → α ≡ β
makeNatTransPath p i .N-ob = p i
makeNatTransPath p i .N-hom f = rem i
where
rem : PathP (λ i → (F .F-hom f) ⋆ᴰ (p i _) ≡ (p i _) ⋆ᴰ (G .F-hom f)) (α .N-hom f) (β .N-hom f)
rem = toPathP (isCatD .isSetHom _ _ _ _)
module _ ⦃ isCatD : isCategory D ⦄ {F F' G G' : Functor C D}
{α : NatTrans F G}
{β : NatTrans F' G'} where
open Precategory
open Functor
open NatTrans
makeNatTransPathP : ∀ (p : F ≡ F') (q : G ≡ G')
→ PathP (λ i → (x : C .ob) → D [ (p i) .F-ob x , (q i) .F-ob x ]) (α .N-ob) (β .N-ob)
→ PathP (λ i → NatTrans (p i) (q i)) α β
makeNatTransPathP p q P i .N-ob = P i
makeNatTransPathP p q P i .N-hom f = rem i
where
rem : PathP (λ i → ((p i) .F-hom f) ⋆ᴰ (P i _) ≡ (P i _) ⋆ᴰ ((q i) .F-hom f)) (α .N-hom f) (β .N-hom f)
rem = toPathP (isCatD .isSetHom _ _ _ _)
private
variable
ℓA ℓA' ℓB ℓB' : Level
module _ {B : Precategory ℓB ℓB'} {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} where
open NatTrans
-- whiskering
-- αF
_∘ˡ_ : ∀ {G H : Functor C D} (α : NatTrans G H) → (F : Functor B C)
→ NatTrans (G ∘F F) (H ∘F F)
(_∘ˡ_ {G} {H} α F) .N-ob x = α ⟦ F ⟅ x ⟆ ⟧
(_∘ˡ_ {G} {H} α F) .N-hom f = (α .N-hom) _
-- Kβ
_∘ʳ_ : ∀ (K : Functor C D) → {G H : Functor B C} (β : NatTrans G H)
→ NatTrans (K ∘F G) (K ∘F H)
(_∘ʳ_ K {G} {H} β) .N-ob x = K ⟪ β ⟦ x ⟧ ⟫
(_∘ʳ_ K {G} {H} β) .N-hom f = preserveCommF {C = C} {D = D} {K} (β .N-hom f)
| 35.008969
| 111
| 0.500833
|
cb2bed9957160994358c22a6c78b52b44e81085d
| 495
|
agda
|
Agda
|
test/Succeed/Issue3731.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3731.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3731.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-04-30, issue #3731
-- Compiler backend: Do not look for a main function if not the main module.
open import Agda.Builtin.Nat
module Issue3731 where
module M where
module main where
record R : Set where
field
main : Nat
data Main : Set where
main : Main
module N where
data main : Set where
module O where
record main : Set where
module P where
postulate
main : Nat
module Q where
abstract
main : Nat
main = 1
main : Nat
main = 0
| 14.558824
| 76
| 0.674747
|
d0e8a986189ef20a91c1f3f72ecf748e56cda47e
| 5,381
|
agda
|
Agda
|
Structure/Category/Functor/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Category/Functor/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Category/Functor/Equiv.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
import Lvl
open import Structure.Category
module Structure.Category.Functor.Equiv
{ℓₗₒ ℓᵣₒ ℓₗₘ ℓᵣₘ ℓₗₑ ℓᵣₑ : Lvl.Level}
{catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}}
{catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}}
where
open import Functional.Dependent as Fn using (_$_)
import Function.Equals
open Function.Equals.Dependent
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_)
open import Relator.Equals.Proofs
open import Relator.Equals.Proofs.Equiv
open import Structure.Category.Functor
open import Structure.Category.Functor.Functors as Functors
open import Structure.Category.Morphism.IdTransport
import Structure.Categorical.Names as Names
open import Structure.Category.NaturalTransformation
open import Structure.Category.Proofs
open import Structure.Categorical.Properties
open import Structure.Function
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
open Structure.Category
open Category ⦃ … ⦄
open CategoryObject
open Functor ⦃ … ⦄
private instance _ = category catₗ
private instance _ = category catᵣ
private open module MorphismEquivₗ {x}{y} = Equiv(morphism-equiv(catₗ){x}{y}) using () renaming (_≡_ to _≡ₗₘ_)
private open module MorphismEquivᵣ {x}{y} = Equiv(morphism-equiv(catᵣ){x}{y}) using () renaming (_≡_ to _≡ᵣₘ_)
module _
(f₁@([∃]-intro F₁) f₂@([∃]-intro F₂) : (catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ))
where
record _≡ᶠᵘⁿᶜᵗᵒʳ_ : Type{Lvl.of(Type.of(catₗ)) Lvl.⊔ Lvl.of(Type.of(catᵣ))} where
constructor intro
field
functor-proof : (F₁ ⊜ F₂)
map-proof : NaturalTransformation(f₁)(f₂) (\x → transport(catᵣ) (_⊜_.proof functor-proof {x}))
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity : Reflexivity(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Reflexivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity) = intro [≡]-intro
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Reflexivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-reflexivity {functor})) {f = f} =
trans-refl ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[]
id ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityₗ(_∘_)(id) ]
map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityᵣ(_∘_)(id) ]-sym
map(f) ∘ id 🝖[ _≡ᵣₘ_ ]-[]
map(f) ∘ trans-refl 🝖-end
where
trans-refl = \{x} → transport(catᵣ) ([≡]-intro {x = x})
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry : Symmetry(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Symmetry.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry xy) = symmetry(_⊜_) (_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof xy)
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Symmetry.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-symmetry {[∃]-intro F₁} {[∃]-intro F₂} (intro (intro fe) (intro me)))) {x}{y} {f = f} =
trans-sym(y) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityᵣ(_∘_)(id) ]-sym
(trans-sym(y) ∘ map(f)) ∘ id 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) ([∘]-on-transport-inverseᵣ catᵣ {ab = fe}) ]-sym
(trans-sym(y) ∘ map(f)) ∘ (trans(x) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ associate4-213-121 (category catᵣ) ]-sym
(trans-sym(y) ∘ (map(f) ∘ trans(x))) ∘ trans-sym(x) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) (congruence₂ᵣ(_∘_)(_) me) ]-sym
(trans-sym(y) ∘ (trans(y) ∘ map(f))) ∘ trans-sym(x) 🝖[ _≡ᵣₘ_ ]-[ associate4-213-121 (category catᵣ) ]
(trans-sym(y) ∘ trans(y)) ∘ (map(f) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) ([∘]-on-transport-inverseₗ catᵣ {ab = fe}) ]
id ∘ (map(f) ∘ trans-sym(x)) 🝖[ _≡ᵣₘ_ ]-[ Morphism.identityₗ(_∘_)(id) ]
map(f) ∘ trans-sym(x) 🝖-end
where
trans = \(x : Object(catₗ)) → transport catᵣ (fe{x})
trans-sym = \(x : Object(catₗ)) → transport catᵣ (symmetry(_≡ₑ_) (fe{x}))
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity : Transitivity(_≡ᶠᵘⁿᶜᵗᵒʳ_)
_≡ᶠᵘⁿᶜᵗᵒʳ_.functor-proof (Transitivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity (intro fe₁ _) (intro fe₂ _)) = transitivity(_⊜_) fe₁ fe₂
NaturalTransformation.natural (_≡ᶠᵘⁿᶜᵗᵒʳ_.map-proof (Transitivity.proof [≡ᶠᵘⁿᶜᵗᵒʳ]-transitivity {[∃]-intro F₁} {[∃]-intro F₂} {[∃]-intro F₃} (intro (intro fe₁) (intro me₁)) (intro (intro fe₂) (intro me₂)))) {x}{y} {f = f} =
transport catᵣ (transitivity(_≡ₑ_) (fe₁{y}) (fe₂{y})) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) (transport-of-transitivity catᵣ {ab = fe₁}{bc = fe₂}) ]
(transport catᵣ (fe₂{y}) ∘ transport catᵣ (fe₁{y})) ∘ map(f) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]
transport catᵣ (fe₂{y}) ∘ (transport catᵣ (fe₁{y}) ∘ map(f)) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) me₁ ]
transport catᵣ (fe₂{y}) ∘ (map(f) ∘ transport catᵣ (fe₁{x})) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]-sym
(transport catᵣ (fe₂{y}) ∘ map(f)) ∘ transport catᵣ (fe₁{x}) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ₗ(_∘_)(_) me₂ ]
(map(f) ∘ transport catᵣ (fe₂{x})) ∘ transport catᵣ (fe₁{x}) 🝖[ _≡ᵣₘ_ ]-[ Morphism.associativity(_∘_) ]
map(f) ∘ (transport catᵣ (fe₂{x}) ∘ transport catᵣ (fe₁{x})) 🝖[ _≡ᵣₘ_ ]-[ congruence₂ᵣ(_∘_)(_) (transport-of-transitivity catᵣ {ab = fe₁}{bc = fe₂}) ]-sym
map(f) ∘ transport catᵣ (transitivity(_≡ₑ_) (fe₁{x}) (fe₂{x})) 🝖-end
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence : Equivalence(_≡ᶠᵘⁿᶜᵗᵒʳ_)
[≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence = intro
instance
[≡ᶠᵘⁿᶜᵗᵒʳ]-equiv : Equiv(catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ)
[≡ᶠᵘⁿᶜᵗᵒʳ]-equiv = intro(_≡ᶠᵘⁿᶜᵗᵒʳ_) ⦃ [≡ᶠᵘⁿᶜᵗᵒʳ]-equivalence ⦄
| 52.754902
| 225
| 0.644118
|
1c3b99907c9998a7665c70ecac7691fcb03fb23b
| 558
|
agda
|
Agda
|
test/Fail/DontPrune.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/DontPrune.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/DontPrune.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2012-05-09
module DontPrune where
open import Common.Equality
open import Common.Product
data Bool : Set where
true false : Bool
test : (A : Set) →
let IF : Bool → A → A → A
IF = _
in (a b : A) →
(IF true a b ≡ a) × (IF false a b ≡ b)
test A a b = refl , refl
-- Expected result: unsolved metas
--
-- (unless someone implemented unification that produces definitions by case).
--
-- The test case should prevent overzealous pruning:
-- If the first equation pruned away the b, then the second
-- would have an unbound rhs.
| 23.25
| 78
| 0.666667
|
18f32581411200f6cec8e488ce637b4a0ec2dda2
| 10,388
|
agda
|
Agda
|
Cubical/Experiments/Brunerie.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/Brunerie.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/Brunerie.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Experiments.Brunerie where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Data.Bool
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.HITs.S1 hiding (encode)
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open import Cubical.HITs.Join
open import Cubical.HITs.SetTruncation as SetTrunc
open import Cubical.HITs.GroupoidTruncation as GroupoidTrunc
open import Cubical.HITs.2GroupoidTruncation as 2GroupoidTrunc
open import Cubical.HITs.Truncation as Trunc
open import Cubical.HITs.Susp renaming (toSusp to σ)
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Hopf
open S¹Hopf
-- This code is adapted from examples/brunerie3.ctt on the pi4s3_nobug branch of cubicaltt
Bool∙ S¹∙ S³∙ : Pointed₀
Bool∙ = (Bool , true)
S¹∙ = (S¹ , base)
S³∙ = (S³ , base)
∥_∥₃∙ ∥_∥₄∙ : Pointed₀ → Pointed₀
∥ A , a ∥₃∙ = ∥ A ∥₃ , ∣ a ∣₃
∥ A , a ∥₄∙ = ∥ A ∥₄ , ∣ a ∣₄
join∙ : Pointed₀ → Type₀ → Pointed₀
join∙ (A , a) B = join A B , inl a
Ω² Ω³ : Pointed₀ → Pointed₀
Ω² = Ω^ 2
Ω³ = Ω^ 3
mapΩrefl : {A : Pointed₀} {B : Type₀} (f : A .fst → B) → Ω A .fst → Ω (B , f (pt A)) .fst
mapΩrefl f p i = f (p i)
mapΩ²refl : {A : Pointed₀} {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 : Pointed₀} {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)
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 : Pointed₀} (P : B .fst → Type₀) → P (pt B) → Ω B .fst → Type₀
fibΩ P f p = PathP (λ i → P (p i)) f f
fibΩ² : {B : Pointed₀} (P : B .fst → Type₀) → P (pt B) → Ω² B .fst → Type₀
fibΩ² P f = fibΩ (fibΩ P f) refl
fibΩ³ : {B : Pointed₀} (P : B .fst → Type₀) → P (pt B) → Ω³ B .fst → Type₀
fibΩ³ P f = fibΩ² (fibΩ P f) refl
Ω³Hopf : Ω³ S²∙ .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 : Ω³ S²∙ .fst → Ω³ (join∙ S¹∙ 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³ : Ω³ S³∙ .fst → Ω² ∥ S²∙ ∥₄∙ .fst
π₃S³ p i j = transp (λ k → tHopf³ (p j k i)) i0 ∣ base ∣₄
codeS² : S² → hGroupoid _
codeS² s = ∥ HopfS² s ∥₃ , squash₃
codeTruncS² : ∥ S² ∥₄ → hGroupoid _
codeTruncS² = 2GroupoidTrunc.rec (isOfHLevelTypeOfHLevel 3) codeS²
encodeTruncS² : Ω ∥ S²∙ ∥₄∙ .fst → ∥ S¹ ∥₃
encodeTruncS² p = transp (λ i → codeTruncS² (p i) .fst) i0 ∣ base ∣₃
codeS¹ : S¹ → hSet _
codeS¹ s = ∥ helix s ∥₂ , squash₂
codeTruncS¹ : ∥ S¹ ∥₃ → hSet _
codeTruncS¹ = GroupoidTrunc.rec (isOfHLevelTypeOfHLevel 2) codeS¹
encodeTruncS¹ : Ω ∥ S¹∙ ∥₃∙ .fst → ∥ ℤ ∥₂
encodeTruncS¹ p = transp (λ i → codeTruncS¹ (p i) .fst) i0 ∣ pos zero ∣₂
-- THE BIG GAME
f3 : Ω³ S³∙ .fst → Ω³ (join∙ S¹∙ S¹) .fst
f3 = mapΩ³refl S³→joinS¹S¹
f4 : Ω³ (join∙ S¹∙ S¹) .fst → Ω³ S²∙ .fst
f4 = mapΩ³refl alpha
f5 : Ω³ S²∙ .fst → Ω³ (join∙ S¹∙ S¹) .fst
f5 = h
f6 : Ω³ (join∙ S¹∙ S¹) .fst → Ω³ S³∙ .fst
f6 = mapΩ³refl joinS¹S¹→S³
f7 : Ω³ S³∙ .fst → Ω² ∥ S²∙ ∥₄∙ .fst
f7 = π₃S³
g8 : Ω² ∥ S²∙ ∥₄∙ .fst → Ω ∥ S¹∙ ∥₃∙ .fst
g8 = mapΩrefl encodeTruncS²
g9 : Ω ∥ S¹∙ ∥₃∙ .fst → ∥ ℤ ∥₂
g9 = encodeTruncS¹
g10 : ∥ ℤ ∥₂ → ℤ
g10 = SetTrunc.rec isSetℤ (idfun ℤ)
-- don't run me
brunerie : ℤ
brunerie = g10 (g9 (g8 (f7 (f6 (f5 (f4 (f3 (λ i j k → surf i j k))))))))
-- simpler tests
test63 : ℕ → ℤ
test63 n = g10 (g9 (g8 (f7 (63n n))))
where
63n : ℕ → Ω³ S³∙ .fst
63n zero i j k = surf i j k
63n (suc n) = f6 (f3 (63n n))
foo : Ω³ S²∙ .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 : Ω³ S²∙ .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 : Ω³ S²∙ .fst → ℤ
goo x = g10 (g9 (g8 (f7 (f6 (f5 x)))))
{- Computation of an alternative definition of the Brunerie number
based on https://github.com/agda/cubical/pull/741. One should note
that this computation by no means is comparable to the one of the term
"brunerie" defined above. This computation starts in π₃S³ rather than
π₃S². -}
-- The brunerie element can be shown to correspond to the following map
η₃ : (join S¹ S¹ , inl base) →∙ (Susp S² , north)
fst η₃ (inl x) = north
fst η₃ (inr x) = north
fst η₃ (push a b i) =
(σ (S² , base) (S¹×S¹→S² a b) ∙ σ (S² , base) (S¹×S¹→S² a b)) i
where
S¹×S¹→S² : S¹ → S¹ → S²
S¹×S¹→S² base y = base
S¹×S¹→S² (loop i) base = base
S¹×S¹→S² (loop i) (loop j) = surf i j
snd η₃ = refl
K₂ = ∥ S² ∥₄
-- We will need a map Ω (Susp S²) → K₂. It turns out that the
-- following map is fast. It need a bit of work, however. It's
-- esentially the same map as you find in ZCohomology from ΩKₙ₊₁ to
-- Kₙ. This gives another definition of f7 which appears to work better.
module f7stuff where
_+₂_ : K₂ → K₂ → K₂
_+₂_ = 2GroupoidTrunc.elim (λ _ → isOfHLevelΠ 4 λ _ → squash₄)
λ { base x → x
; (surf i j) x → surfc x i j}
where
surfc : (x : K₂) → typ ((Ω^ 2) (K₂ , x))
surfc =
2GroupoidTrunc.elim
(λ _ → isOfHLevelPath 4 (isOfHLevelPath 4 squash₄ _ _) _ _)
(S²ToSetElim (λ _ → squash₄ _ _ _ _) λ i j → ∣ surf i j ∣₄)
K₂≃K₂ : (x : S²) → K₂ ≃ K₂
fst (K₂≃K₂ x) y = ∣ x ∣₄ +₂ y
snd (K₂≃K₂ x) = help x
where
help : (x : _) → isEquiv (λ y → ∣ x ∣₄ +₂ y)
help = S²ToSetElim (λ _ → isProp→isSet (isPropIsEquiv _))
(idEquiv _ .snd)
Code : Susp S² → Type ℓ-zero
Code north = K₂
Code south = K₂
Code (merid a i) = ua (K₂≃K₂ a) i
encode : (x : Susp S²) → north ≡ x → Code x
encode x = J (λ x p → Code x) ∣ base ∣₄
-- We now get an alternative definition of f7
f7' : typ (Ω (Susp∙ S²)) → K₂
f7' = f7stuff.encode north
-- We can define the Brunerie number by
brunerie' : ℤ
brunerie' = g10 (g9 (g8 λ i j → f7' λ k → η₃ .fst (push (loop i) (loop j) k)))
-- Computing it takes ~1s
brunerie'≡-2 : brunerie' ≡ -2
brunerie'≡-2 = refl
| 27.775401
| 96
| 0.533885
|
dcc3cd44ed240b70fd1b6d3e93def929b31c49d3
| 911
|
agda
|
Agda
|
src/Categories/GlobularSet.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/GlobularSet.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/GlobularSet.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
module Categories.GlobularSet where
-- Globular sets are defined in a Categorical context, but
-- should they be inside the Categories hierarchy?
open import Level
open import Data.Unit using (⊤)
open import Relation.Binary.PropositionalEquality using (refl)
open import Categories.Category
open import Categories.Category.Instance.Globe
open import Categories.Category.Instance.Sets
open import Categories.Functor
open import Categories.Functor.Presheaf
private
variable
o ℓ e : Level
GlobularSet : (o : Level) → Set (suc o)
GlobularSet o = Presheaf Globe (Sets o)
-- TODO? make universe polymorphic with polymorphic ⊤
Trivial : GlobularSet zero
Trivial = record
{ F₀ = λ _ → ⊤
; F₁ = λ _ x → x
; identity = refl
; homomorphism = refl
; F-resp-≈ = λ _ → refl
}
GlobularObject : Category o ℓ e → Set _
GlobularObject C = Functor (Category.op Globe) C
| 25.305556
| 62
| 0.735456
|
4a843eefe7ad4b663c1939b3725cba18567a08fe
| 47,288
|
agda
|
Agda
|
Agda/22-descent.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/22-descent.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/22-descent.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --allow-unsolved-metas --exact-split #-}
module 22-descent where
import 21-cubical-diagrams
open 21-cubical-diagrams public
-- Section 18.1 Five equivalent characterizations of pushouts
dep-cocone :
{ l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
( f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l5) →
UU (l1 ⊔ l2 ⊔ l3 ⊔ l5)
dep-cocone {S = S} {A} {B} f g c P =
Σ ((a : A) → P ((pr1 c) a)) (λ hA →
Σ ((b : B) → P (pr1 (pr2 c) b)) (λ hB →
(s : S) → Id (tr P (pr2 (pr2 c) s) (hA (f s))) (hB (g s))))
dep-cocone-map :
{ l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
( f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l5) →
( (x : X) → P x) → dep-cocone f g c P
dep-cocone-map f g c P h =
pair (λ a → h (pr1 c a)) (pair (λ b → h (pr1 (pr2 c) b)) (λ s → apd h (pr2 (pr2 c) s)))
{- Definition 18.1.1 The induction principle of pushouts -}
Ind-pushout :
{ l1 l2 l3 l4 : Level} (l : Level) →
{ S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3 ⊔ l4)
Ind-pushout l {X = X} f g c =
(P : X → UU l) → sec (dep-cocone-map f g c P)
{- Definition 18.1.2 The dependent universal property of pushouts -}
dependent-universal-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → UU _
dependent-universal-property-pushout l f g {X} c =
(P : X → UU l) → is-equiv (dep-cocone-map f g c P)
{- Remark 18.1.3. We compute the identity type of dep-cocone in order to
express the computation rules of the induction principle for pushouts. -}
coherence-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X)
(P : X → UU l5) (c' c'' : dep-cocone f g c P)
(K : (pr1 c') ~ (pr1 c'')) (L : (pr1 (pr2 c')) ~ (pr1 (pr2 c''))) →
UU (l1 ⊔ l5)
coherence-htpy-dep-cocone {S = S} f g c P
h h' K L =
(s : S) →
Id ( ((pr2 (pr2 h)) s) ∙ (L (g s)))
( (ap (tr P (pr2 (pr2 c) s)) (K (f s))) ∙ ((pr2 (pr2 h')) s))
htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s t : dep-cocone f g c P) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l5)))
htpy-dep-cocone {S = S} f g c P h h' =
Σ ( (pr1 h) ~ (pr1 h')) (λ K →
Σ ( (pr1 (pr2 h)) ~ (pr1 (pr2 h')))
( coherence-htpy-dep-cocone f g c P h h' K))
reflexive-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s : dep-cocone f g c P) →
htpy-dep-cocone f g c P s s
reflexive-htpy-dep-cocone f g (pair i (pair j H)) P
(pair hA (pair hB hS)) =
pair htpy-refl (pair htpy-refl htpy-right-unit)
htpy-dep-cocone-eq :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
{s t : dep-cocone f g c P} →
Id s t → htpy-dep-cocone f g c P s t
htpy-dep-cocone-eq f g c P {s} {.s} refl =
reflexive-htpy-dep-cocone f g c P s
abstract
is-contr-total-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s : dep-cocone f g c P) →
is-contr
( Σ (dep-cocone f g c P)
( htpy-dep-cocone f g c P s))
is-contr-total-htpy-dep-cocone
{S = S} {A} {B} f g {X} (pair i (pair j H)) P (pair hA (pair hB hS)) =
is-contr-total-Eq-structure
( λ α βγ K →
Σ (hB ~ (pr1 βγ)) (λ L →
coherence-htpy-dep-cocone f g
( pair i (pair j H)) P (pair hA (pair hB hS)) (pair α βγ) K L))
( is-contr-total-htpy hA)
( pair hA htpy-refl)
( is-contr-total-Eq-structure
( λ β γ L →
coherence-htpy-dep-cocone f g
( pair i (pair j H))
( P)
( pair hA (pair hB hS))
( pair hA (pair β γ))
( htpy-refl)
( L))
( is-contr-total-htpy hB)
( pair hB htpy-refl)
( is-contr-is-equiv
( Σ ((s : S) → Id (tr P (H s) (hA (f s))) (hB (g s))) (λ γ → hS ~ γ))
( tot (htpy-concat (htpy-inv htpy-right-unit)))
( is-equiv-tot-is-fiberwise-equiv
( is-equiv-htpy-concat (htpy-inv htpy-right-unit)))
( is-contr-total-htpy hS)))
abstract
is-equiv-htpy-dep-cocone-eq :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s t : dep-cocone f g c P) → is-equiv (htpy-dep-cocone-eq f g c P {s} {t})
is-equiv-htpy-dep-cocone-eq f g c P s =
fundamental-theorem-id s
( reflexive-htpy-dep-cocone f g c P s)
( is-contr-total-htpy-dep-cocone f g c P s)
( λ t → htpy-dep-cocone-eq f g c P {s} {t})
eq-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s t : dep-cocone f g c P) →
htpy-dep-cocone f g c P s t → Id s t
eq-htpy-dep-cocone f g c P s t =
inv-is-equiv (is-equiv-htpy-dep-cocone-eq f g c P s t)
issec-eq-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s t : dep-cocone f g c P) →
( ( htpy-dep-cocone-eq f g c P {s} {t}) ∘
( eq-htpy-dep-cocone f g c P s t)) ~ id
issec-eq-htpy-dep-cocone f g c P s t =
issec-inv-is-equiv
( is-equiv-htpy-dep-cocone-eq f g c P s t)
isretr-eq-htpy-dep-cocone :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
(s t : dep-cocone f g c P) →
( ( eq-htpy-dep-cocone f g c P s t) ∘
( htpy-dep-cocone-eq f g c P {s} {t})) ~ id
isretr-eq-htpy-dep-cocone f g c P s t =
isretr-inv-is-equiv
( is-equiv-htpy-dep-cocone-eq f g c P s t)
ind-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) →
Ind-pushout l f g c → (P : X → UU l) →
dep-cocone f g c P → (x : X) → P x
ind-pushout f g c ind-c P =
pr1 (ind-c P)
comp-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) →
( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) →
htpy-dep-cocone f g c P
( dep-cocone-map f g c P (ind-pushout f g c ind-c P h))
( h)
comp-pushout f g c ind-c P h =
htpy-dep-cocone-eq f g c P (pr2 (ind-c P) h)
left-comp-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) →
( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) →
( a : A) → Id (ind-pushout f g c ind-c P h (pr1 c a)) (pr1 h a)
left-comp-pushout f g c ind-c P h =
pr1 (comp-pushout f g c ind-c P h)
right-comp-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) →
( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) →
( b : B) → Id (ind-pushout f g c ind-c P h (pr1 (pr2 c) b)) (pr1 (pr2 h) b)
right-comp-pushout f g c ind-c P h =
pr1 (pr2 (comp-pushout f g c ind-c P h))
path-comp-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X) →
( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) →
coherence-htpy-dep-cocone f g c P
( dep-cocone-map f g c P (ind-pushout f g c ind-c P h))
( h)
( left-comp-pushout f g c ind-c P h)
( right-comp-pushout f g c ind-c P h)
path-comp-pushout f g c ind-c P h =
pr2 (pr2 (comp-pushout f g c ind-c P h))
abstract
uniqueness-dependent-universal-property-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} →
( f : S → A) (g : S → B) (c : cocone f g X)
( dup-c : dependent-universal-property-pushout l f g c) →
( P : X → UU l) ( h : dep-cocone f g c P) →
is-contr
( Σ ((x : X) → P x) (λ k →
htpy-dep-cocone f g c P (dep-cocone-map f g c P k) h))
uniqueness-dependent-universal-property-pushout f g c dup-c P h =
is-contr-is-equiv'
( fib (dep-cocone-map f g c P) h)
( tot (λ k → htpy-dep-cocone-eq f g c P))
( is-equiv-tot-is-fiberwise-equiv
( λ k → is-equiv-htpy-dep-cocone-eq f g c P
( dep-cocone-map f g c P k) h))
( is-contr-map-is-equiv (dup-c P) h)
{- This finishes the formalization of remark 18.1.3. -}
{- Before we state the main theorem of this section, we also state a dependent
version of the pullback property of pushouts. -}
cone-dependent-pullback-property-pushout :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
let i = pr1 c
j = pr1 (pr2 c)
H = pr2 (pr2 c)
in
cone
( λ (h : (a : A) → P (i a)) → λ (s : S) → tr P (H s) (h (f s)))
( λ (h : (b : B) → P (j b)) → λ s → h (g s))
( (x : X) → P x)
cone-dependent-pullback-property-pushout f g (pair i (pair j H)) P =
pair
( λ h → λ a → h (i a))
( pair
( λ h → λ b → h (j b))
( λ h → eq-htpy (λ s → apd h (H s))))
dependent-pullback-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ (l4 ⊔ lsuc l))))
dependent-pullback-property-pushout l {S} {A} {B} f g {X}
(pair i (pair j H)) =
(P : X → UU l) →
is-pullback
( λ (h : (a : A) → P (i a)) → λ s → tr P (H s) (h (f s)))
( λ (h : (b : B) → P (j b)) → λ s → h (g s))
( cone-dependent-pullback-property-pushout f g (pair i (pair j H)) P)
{- Theorem 18.1.4 The following properties are all equivalent:
1. universal-property-pushout
2. pullback-property-pushout
3. dependent-pullback-property-pushout
4. dependent-universal-property-pushout
5. Ind-pushout
We have already shown that 1 ↔ 2. Therefore we will first show that
3 ↔ 4 ↔ 5. Finally, we will show that 2 ↔ 3. Here are the precise references
to the proofs of those parts:
Proof of 1 → 2.
pullback-property-pushout-universal-property-pushout
Proof of 2 → 1
universal-property-pushout-pullback-property-pushout
Proof of 2 → 3
dependent-pullback-property-pullback-property-pushout
Proof of 3 → 2
pullback-property-dependent-pullback-property-pushout
Proof of 3 → 4
dependent-universal-property-dependent-pullback-property-pushout
Proof of 4 → 3
dependent-pullback-property-dependent-universal-property-pushout
Proof of 4 → 5
Ind-pushout-dependent-universal-property-pushout
Proof of 5 → 4
dependent-universal-property-pushout-Ind-pushout
-}
{- Proof of Theorem 18.1.4, (v) implies (iv). -}
dependent-naturality-square :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} (f f' : (x : A) → B x)
{x x' : A} (p : Id x x') {q : Id (f x) (f' x)} {q' : Id (f x') (f' x')} →
Id ((apd f p) ∙ q') ((ap (tr B p) q) ∙ (apd f' p)) →
Id (tr (λ y → Id (f y) (f' y)) p q) q'
dependent-naturality-square f f' refl {q} {q'} s =
inv (s ∙ (right-unit ∙ (ap-id q)))
htpy-eq-dep-cocone-map :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
( f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
( H : Ind-pushout l f g c) { P : X → UU l} (h h' : (x : X) → P x) →
Id (dep-cocone-map f g c P h) (dep-cocone-map f g c P h') → h ~ h'
htpy-eq-dep-cocone-map f g c ind-c {P} h h' p =
ind-pushout f g c ind-c
( λ x → Id (h x) (h' x))
( pair
( pr1 (htpy-dep-cocone-eq f g c P p))
( pair
( pr1 (pr2 (htpy-dep-cocone-eq f g c P p)))
( λ s →
dependent-naturality-square h h' (pr2 (pr2 c) s)
( pr2 (pr2 (htpy-dep-cocone-eq f g c P p)) s))))
dependent-universal-property-pushout-Ind-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
((l : Level) → Ind-pushout l f g c) →
((l : Level) → dependent-universal-property-pushout l f g c)
dependent-universal-property-pushout-Ind-pushout f g c ind-c l P =
is-equiv-has-inverse
( ind-pushout f g c (ind-c l) P)
( pr2 (ind-c l P))
( λ h → eq-htpy (htpy-eq-dep-cocone-map f g c (ind-c l)
( ind-pushout f g c (ind-c l) P (dep-cocone-map f g c P h))
( h)
( pr2 (ind-c l P) (dep-cocone-map f g c P h))))
{- Proof of Theorem 18.1.4, (iv) implies (v). -}
Ind-pushout-dependent-universal-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
((l : Level) → dependent-universal-property-pushout l f g c) →
((l : Level) → Ind-pushout l f g c)
Ind-pushout-dependent-universal-property-pushout f g c dup-c l P =
pr1 (dup-c l P)
{- Proof of Theorem 18.1.4, (iv) implies (iii). -}
triangle-dependent-pullback-property-pushout :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) →
let i = pr1 c
j = pr1 (pr2 c)
H = pr2 (pr2 c)
in
( dep-cocone-map f g c P) ~
( ( tot (λ h → tot (λ h' → htpy-eq))) ∘
( gap
( λ (h : (a : A) → P (i a)) → λ s → tr P (H s) (h (f s)))
( λ (h : (b : B) → P (j b)) → λ s → h (g s))
( cone-dependent-pullback-property-pushout f g c P)))
triangle-dependent-pullback-property-pushout f g (pair i (pair j H)) P h =
eq-pair refl (eq-pair refl (inv (issec-eq-htpy (λ x → apd h (H x)))))
dependent-pullback-property-dependent-universal-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
((l : Level) → dependent-universal-property-pushout l f g c) →
((l : Level) → dependent-pullback-property-pushout l f g c)
dependent-pullback-property-dependent-universal-property-pushout
f g (pair i (pair j H)) I l P =
let c = (pair i (pair j H)) in
is-equiv-right-factor
( dep-cocone-map f g c P)
( tot (λ h → tot λ h' → htpy-eq))
( gap
( λ h x → tr P (H x) (h (f x)))
( λ h x → h (g x))
( cone-dependent-pullback-property-pushout f g c P))
( triangle-dependent-pullback-property-pushout f g c P)
( is-equiv-tot-is-fiberwise-equiv
( λ h → is-equiv-tot-is-fiberwise-equiv
( λ h' → funext (λ x → tr P (H x) (h (f x))) (λ x → h' (g x)))))
( I l P)
{- Proof of Theorem 18.1.4, (iv) implies (iii). -}
dependent-universal-property-dependent-pullback-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
((l : Level) → dependent-pullback-property-pushout l f g c) →
((l : Level) → dependent-universal-property-pushout l f g c)
dependent-universal-property-dependent-pullback-property-pushout
f g (pair i (pair j H)) dpullback-c l P =
let c = (pair i (pair j H)) in
is-equiv-comp
( dep-cocone-map f g c P)
( tot (λ h → tot λ h' → htpy-eq))
( gap
( λ h x → tr P (H x) (h (f x)))
( λ h x → h (g x))
( cone-dependent-pullback-property-pushout f g c P))
( triangle-dependent-pullback-property-pushout f g c P)
( dpullback-c l P)
( is-equiv-tot-is-fiberwise-equiv
( λ h → is-equiv-tot-is-fiberwise-equiv
( λ h' → funext (λ x → tr P (H x) (h (f x))) (λ x → h' (g x)))))
{- Proof of Theorem 18.1.4, (iii) implies (ii). -}
concat-eq-htpy :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x}
(H : f ~ g) (K : g ~ h) → Id (eq-htpy (H ∙h K)) ((eq-htpy H) ∙ (eq-htpy K))
concat-eq-htpy {A = A} {B} {f} H K =
ind-htpy f
( λ g H →
( h : (x : A) → B x) (K : g ~ h) →
Id (eq-htpy (H ∙h K)) ((eq-htpy H) ∙ (eq-htpy K)))
( λ h K → ap (concat' f (eq-htpy K)) (inv (eq-htpy-htpy-refl _))) H _ K
pullback-property-dependent-pullback-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
dependent-pullback-property-pushout l f g c →
pullback-property-pushout l f g c
pullback-property-dependent-pullback-property-pushout
l f g (pair i (pair j H)) dpb Y =
is-pullback-htpy
( λ h s → tr (λ x → Y) (H s) (h (f s)))
( λ h → eq-htpy (λ s → inv (tr-triv (H s) (h (f s)))))
( λ h s → h (g s))
( htpy-refl)
{ c = pair
( λ h a → h (i a))
( pair (λ h b → h (j b)) (λ h → eq-htpy (h ·l H)))}
( cone-dependent-pullback-property-pushout
f g (pair i (pair j H)) (λ x → Y))
( pair
( λ h → refl)
( pair
( λ h → refl)
( λ h → right-unit ∙
( ( ap eq-htpy
( eq-htpy (λ s →
inv-con
( tr-triv (H s) (h (i (f s))))
( ap h (H s))
( apd h (H s))
( inv (apd-triv h (H s)))))) ∙
( concat-eq-htpy
( λ s → inv (tr-triv (H s) (h (i (f s)))))
( λ s → apd h (H s)))))))
( dpb (λ x → Y))
{- Proof of Theorem 18.1.4, (ii) implies (iii). -}
{- We first define the family of lifts, which is indexed by maps Y → X. -}
fam-lifts :
{l1 l2 l3 : Level} (Y : UU l1) {X : UU l2} (P : X → UU l3) →
(Y → X) → UU (l1 ⊔ l3)
fam-lifts Y P h = (y : Y) → P (h y)
tr-fam-lifts' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) →
(h : B → X) {f g : A → B} (H : f ~ g) →
fam-lifts A P (h ∘ f) → fam-lifts A P (h ∘ g)
tr-fam-lifts' P h {f} {g} H k s = tr (P ∘ h) (H s) (k s)
TR-EQ-HTPY-FAM-LIFTS :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) →
(h : B → X) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ l4)
TR-EQ-HTPY-FAM-LIFTS {A = A} P h H =
tr (fam-lifts A P) (eq-htpy (h ·l H)) ~ (tr-fam-lifts' P h H)
tr-eq-htpy-fam-lifts-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) →
(h : B → X) (f : A → B) → TR-EQ-HTPY-FAM-LIFTS P h (htpy-refl' f)
tr-eq-htpy-fam-lifts-htpy-refl P h f k =
ap (λ t → tr (fam-lifts _ P) t k) (eq-htpy-htpy-refl (h ∘ f))
abstract
tr-eq-htpy-fam-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) →
(h : B → X) {f g : A → B} (H : f ~ g) →
TR-EQ-HTPY-FAM-LIFTS P h H
tr-eq-htpy-fam-lifts P h {f} =
ind-htpy f
( λ g H → TR-EQ-HTPY-FAM-LIFTS P h H)
( tr-eq-htpy-fam-lifts-htpy-refl P h f)
compute-tr-eq-htpy-fam-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) →
(h : B → X) (f : A → B) →
Id ( tr-eq-htpy-fam-lifts P h (htpy-refl' f))
( tr-eq-htpy-fam-lifts-htpy-refl P h f)
compute-tr-eq-htpy-fam-lifts P h f =
comp-htpy f
( λ g H → TR-EQ-HTPY-FAM-LIFTS P h H)
( tr-eq-htpy-fam-lifts-htpy-refl P h f)
{- One of the basic operations on lifts is precomposition by an ordinary
function. -}
precompose-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) → (f : A → B) → (h : B → X) →
(fam-lifts B P h) → (fam-lifts A P (h ∘ f))
precompose-lifts P f h h' a = h' (f a)
{- Given two homotopic maps, their precomposition functions have different
codomains. However, there is a commuting triangle. We obtain this triangle
by homotopy induction. -}
TRIANGLE-PRECOMPOSE-LIFTS :
{ l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
( P : X → UU l4) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
TRIANGLE-PRECOMPOSE-LIFTS {A = A} {B} {X} P {f} {g} H =
(h : B → X) →
( (tr (fam-lifts A P) (eq-htpy (h ·l H))) ∘ (precompose-lifts P f h)) ~
( precompose-lifts P g h)
triangle-precompose-lifts-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) (f : A → B) → TRIANGLE-PRECOMPOSE-LIFTS P (htpy-refl' f)
triangle-precompose-lifts-htpy-refl {A = A} P f h h' =
tr-eq-htpy-fam-lifts-htpy-refl P h f (λ a → h' (f a))
abstract
triangle-precompose-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) {f g : A → B} (H : f ~ g) →
TRIANGLE-PRECOMPOSE-LIFTS P H
triangle-precompose-lifts {A = A} P {f} =
ind-htpy f
( λ g H → TRIANGLE-PRECOMPOSE-LIFTS P H)
( triangle-precompose-lifts-htpy-refl P f)
compute-triangle-precompose-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) (f : A → B) →
Id
( triangle-precompose-lifts P (htpy-refl' f))
( triangle-precompose-lifts-htpy-refl P f)
compute-triangle-precompose-lifts P f =
comp-htpy f
( λ g H → TRIANGLE-PRECOMPOSE-LIFTS P H)
( triangle-precompose-lifts-htpy-refl P f)
{- There is a similar commuting triangle with the computed transport function.
This time we don't use homotopy induction to construct the homotopy. We
give an explicit definition instead. -}
triangle-precompose-lifts' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) {f g : A → B} (H : f ~ g) → (h : B → X) →
( (tr-fam-lifts' P h H) ∘ (precompose-lifts P f h)) ~
( precompose-lifts P g h)
triangle-precompose-lifts' P H h k = eq-htpy (λ a → apd k (H a))
compute-triangle-precompose-lifts' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) (f : A → B) → (h : B → X) →
( triangle-precompose-lifts' P (htpy-refl' f) h) ~
( htpy-refl' ( precompose-lifts P f h))
compute-triangle-precompose-lifts' P f h k = eq-htpy-htpy-refl _
{- There is a coherence between the two commuting triangles. This coherence
is again constructed by homotopy induction. -}
COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
{f g : A → B} (H : f ~ g) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS {A = A} {B} {X} P {f} {g} H =
(h : B → X) →
( triangle-precompose-lifts P H h) ~
( ( ( tr-eq-htpy-fam-lifts P h H) ·r (precompose-lifts P f h)) ∙h
( triangle-precompose-lifts' P H h))
coherence-triangle-precompose-lifts-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
(f : A → B) → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P (htpy-refl' f)
coherence-triangle-precompose-lifts-htpy-refl P f h =
( htpy-eq (htpy-eq (compute-triangle-precompose-lifts P f) h)) ∙h
( ( ( htpy-inv htpy-right-unit) ∙h
( htpy-ap-concat
( λ h' → tr-eq-htpy-fam-lifts-htpy-refl P h f (λ a → h' (f a)))
( htpy-refl)
( triangle-precompose-lifts' P htpy-refl h)
( htpy-inv (compute-triangle-precompose-lifts' P f h)))) ∙h
( htpy-eq
( ap
( λ t →
( t ·r (precompose-lifts P f h)) ∙h
( triangle-precompose-lifts' P htpy-refl h))
( inv (compute-tr-eq-htpy-fam-lifts P h f)))))
abstract
coherence-triangle-precompose-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
{f g : A → B} (H : f ~ g) → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H
coherence-triangle-precompose-lifts P {f} =
ind-htpy f
( λ g H → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H)
( coherence-triangle-precompose-lifts-htpy-refl P f)
compute-coherence-triangle-precompose-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
(f : A → B) →
Id ( coherence-triangle-precompose-lifts P (htpy-refl' f))
( coherence-triangle-precompose-lifts-htpy-refl P f)
compute-coherence-triangle-precompose-lifts P f =
comp-htpy f
( λ g H → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H)
( coherence-triangle-precompose-lifts-htpy-refl P f)
total-lifts :
{l1 l2 l3 : Level} (A : UU l1) {X : UU l2} (P : X → UU l3) →
UU _
total-lifts A {X} P = type-choice-∞ {A = A} {B = λ a → X} (λ a → P)
precompose-total-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) → (A → B) →
total-lifts B P → total-lifts A P
precompose-total-lifts {A = A} P f =
toto
( λ h → (a : A) → P (h a))
( λ h → h ∘ f)
( precompose-lifts P f)
coherence-square-inv-choice-∞ :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) (f : A → B) →
coherence-square
( precompose-total-lifts P f)
( inv-choice-∞ {A = B} {B = λ x → X} {C = λ x y → P y})
( inv-choice-∞)
( λ h → h ∘ f)
coherence-square-inv-choice-∞ P f = htpy-refl
{- Our goal is now to produce a homotopy between (precompose-total-lifts P f)
and (precompose-total-lifts P g) for homotopic maps f and g, and a coherence
filling a cilinder. -}
HTPY-PRECOMPOSE-TOTAL-LIFTS :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(P : X → UU l4) {f g : A → B} (H : f ~ g) →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
HTPY-PRECOMPOSE-TOTAL-LIFTS P {f} {g} H =
(precompose-total-lifts P f) ~ (precompose-total-lifts P g)
htpy-precompose-total-lifts :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
{f g : A → B} (H : f ~ g) → HTPY-PRECOMPOSE-TOTAL-LIFTS P H
htpy-precompose-total-lifts {A = A} {B} P {f} {g} H =
htpy-toto
{ P = fam-lifts B P}
( fam-lifts A P)
( λ h → eq-htpy (h ·l H))
( precompose-lifts P f)
( triangle-precompose-lifts P H)
{- We show that when htpy-precompose-total-lifts is applied to htpy-refl, it
computes to htpy-refl. -}
tr-id-left-subst :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} {x y : A}
(p : Id x y) (b : B) → (q : Id (f x) b) →
Id (tr (λ (a : A) → Id (f a) b) p q) ((inv (ap f p)) ∙ q)
tr-id-left-subst refl b q = refl
compute-htpy-precompose-total-lifts :
{ l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
( f : A → B) →
( htpy-precompose-total-lifts P (htpy-refl' f)) ~
( htpy-refl' (toto (fam-lifts A P) (λ h → h ∘ f) (precompose-lifts P f)))
compute-htpy-precompose-total-lifts {A = A} P f (pair h h') =
let α = λ (t : Id (h ∘ f) (h ∘ f)) → tr (fam-lifts A P) t (λ a → h' (f a))
in
ap eq-pair'
( eq-pair
( eq-htpy-htpy-refl (h ∘ f))
( ( tr-id-left-subst
{ f = α}
( eq-htpy-htpy-refl (h ∘ f))
( λ a → h' (f a))
( triangle-precompose-lifts P htpy-refl h h')) ∙
( ( ap
( λ t → inv (ap α (eq-htpy-htpy-refl (λ a → h (f a)))) ∙ t)
( htpy-eq
( htpy-eq (compute-triangle-precompose-lifts P f) h) h')) ∙
( left-inv (triangle-precompose-lifts-htpy-refl P f h h')))))
COHERENCE-HTPY-INV-CHOICE-∞ :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
{f g : A → B} (H : f ~ g) → UU _
COHERENCE-HTPY-INV-CHOICE-∞ P {f} {g} H =
( ( coherence-square-inv-choice-∞ P f) ∙h
( inv-choice-∞ ·l ( htpy-precompose-total-lifts P H))) ~
( ( ( λ h → eq-htpy (h ·l H)) ·r inv-choice-∞) ∙h
( coherence-square-inv-choice-∞ P g))
coherence-htpy-inv-choice-∞-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
(f : A → B) → COHERENCE-HTPY-INV-CHOICE-∞ P (htpy-refl' f)
coherence-htpy-inv-choice-∞-htpy-refl {X = X} P f =
( htpy-ap-concat
( coherence-square-inv-choice-∞ P f)
( inv-choice-∞ ·l ( htpy-precompose-total-lifts P htpy-refl))
( htpy-refl)
( λ h →
ap (ap inv-choice-∞) (compute-htpy-precompose-total-lifts P f h))) ∙h
( htpy-inv
( htpy-ap-concat'
( ( htpy-precomp htpy-refl (Σ X P)) ·r inv-choice-∞)
( htpy-refl)
( htpy-refl)
( λ h → compute-htpy-precomp f (Σ X P) (inv-choice-∞ h))))
abstract
coherence-htpy-inv-choice-∞ :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4)
{f g : A → B} (H : f ~ g) → COHERENCE-HTPY-INV-CHOICE-∞ P H
coherence-htpy-inv-choice-∞ P {f} =
ind-htpy f
( λ g H → COHERENCE-HTPY-INV-CHOICE-∞ P H)
( coherence-htpy-inv-choice-∞-htpy-refl P f)
cone-family-dependent-pullback-property :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l) →
cone-family
( fam-lifts S P)
( precompose-lifts P f)
( precompose-lifts P g)
( cone-pullback-property-pushout f g c X)
( fam-lifts X P)
cone-family-dependent-pullback-property f g c P γ =
pair
( precompose-lifts P (pr1 c) γ)
( pair
( precompose-lifts P (pr1 (pr2 c)) γ)
( triangle-precompose-lifts P (pr2 (pr2 c)) γ))
is-pullback-cone-family-dependent-pullback-property :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) →
((l : Level) → pullback-property-pushout l f g c) →
{l : Level} (P : X → UU l) (γ : X → X) →
is-pullback
( ( tr (fam-lifts S P) (eq-htpy (γ ·l (pr2 (pr2 c))))) ∘
( precompose-lifts P f (γ ∘ (pr1 c))))
( precompose-lifts P g (γ ∘ (pr1 (pr2 c))))
( cone-family-dependent-pullback-property f g c P γ)
is-pullback-cone-family-dependent-pullback-property {S = S} {A} {B} {X}
f g (pair i (pair j H)) pb-c P =
let c = pair i (pair j H) in
is-pullback-family-is-pullback-tot
( fam-lifts S P)
( precompose-lifts P f)
( precompose-lifts P g)
( cone-pullback-property-pushout f g c X)
( cone-family-dependent-pullback-property f g c P)
( pb-c _ X)
( is-pullback-top-is-pullback-bottom-cube-is-equiv
( precomp i (Σ X P))
( precomp j (Σ X P))
( precomp f (Σ X P))
( precomp g (Σ X P))
( toto (fam-lifts A P) (precomp i X) (precompose-lifts P i))
( toto (fam-lifts B P) (precomp j X) (precompose-lifts P j))
( toto (fam-lifts S P) (precomp f X) (precompose-lifts P f))
( toto (fam-lifts S P) (precomp g X) (precompose-lifts P g))
( inv-choice-∞)
( inv-choice-∞)
( inv-choice-∞)
( inv-choice-∞)
( htpy-precompose-total-lifts P H)
( htpy-refl)
( htpy-refl)
( htpy-refl)
( htpy-refl)
( htpy-precomp H (Σ X P))
( coherence-htpy-inv-choice-∞ P H)
( is-equiv-inv-choice-∞)
( is-equiv-inv-choice-∞)
( is-equiv-inv-choice-∞)
( is-equiv-inv-choice-∞)
( pb-c _ (Σ X P)))
dependent-pullback-property-pullback-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) →
((l : Level) → pullback-property-pushout l f g c) →
((l : Level) → dependent-pullback-property-pushout l f g c)
dependent-pullback-property-pullback-property-pushout
{S = S} {A} {B} {X}
f g (pair i (pair j H)) pullback-c l P =
let c = pair i (pair j H) in
is-pullback-htpy'
( (tr (fam-lifts S P) (eq-htpy (id ·l H))) ∘ (precompose-lifts P f i))
( (tr-eq-htpy-fam-lifts P id H) ·r (precompose-lifts P f i))
( precompose-lifts P g j)
( htpy-refl)
( cone-family-dependent-pullback-property f g c P id)
{ c' = cone-dependent-pullback-property-pushout f g c P}
( pair htpy-refl
( pair htpy-refl
( htpy-right-unit ∙h (coherence-triangle-precompose-lifts P H id))))
( is-pullback-cone-family-dependent-pullback-property f g c pullback-c P id)
{- This concludes the proof of Theorem 18.1.4. -}
{- We give some further useful implications -}
dependent-universal-property-universal-property-pushout :
{ l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
( f : S → A) (g : S → B) (c : cocone f g X) →
( (l : Level) → universal-property-pushout l f g c) →
( (l : Level) → dependent-universal-property-pushout l f g c)
dependent-universal-property-universal-property-pushout f g c up-X =
dependent-universal-property-dependent-pullback-property-pushout f g c
( dependent-pullback-property-pullback-property-pushout f g c
( λ l → pullback-property-pushout-universal-property-pushout l f g c
( up-X l)))
-- Section 16.2 Families over pushouts
{- Definition 18.2.1 -}
Fam-pushout :
{l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ lsuc l)))
Fam-pushout l {S} {A} {B} f g =
Σ ( A → UU l)
( λ PA → Σ (B → UU l)
( λ PB → (s : S) → PA (f s) ≃ PB (g s)))
{- We characterize the identity type of Fam-pushout. -}
coherence-equiv-Fam-pushout :
{ l1 l2 l3 l l' : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{ f : S → A} {g : S → B}
( P : Fam-pushout l f g) (Q : Fam-pushout l' f g) →
( eA : (a : A) → (pr1 P a) ≃ (pr1 Q a))
( eB : (b : B) → (pr1 (pr2 P) b) ≃ (pr1 (pr2 Q) b)) →
UU (l1 ⊔ l ⊔ l')
coherence-equiv-Fam-pushout {S = S} {f = f} {g} P Q eA eB =
( s : S) →
( (map-equiv (eB (g s))) ∘ (map-equiv (pr2 (pr2 P) s))) ~
( (map-equiv (pr2 (pr2 Q) s)) ∘ (map-equiv (eA (f s))))
equiv-Fam-pushout :
{l1 l2 l3 l l' : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} →
Fam-pushout l f g → Fam-pushout l' f g → UU (l1 ⊔ l2 ⊔ l3 ⊔ l ⊔ l')
equiv-Fam-pushout {S = S} {A} {B} {f} {g} P Q =
Σ ( (a : A) → (pr1 P a) ≃ (pr1 Q a)) ( λ eA →
Σ ( (b : B) → (pr1 (pr2 P) b) ≃ (pr1 (pr2 Q) b))
( coherence-equiv-Fam-pushout P Q eA))
reflexive-equiv-Fam-pushout :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} (P : Fam-pushout l f g) →
equiv-Fam-pushout P P
reflexive-equiv-Fam-pushout (pair PA (pair PB PS)) =
pair (λ a → equiv-id (PA a))
( pair
( λ b → equiv-id (PB b))
( λ s → htpy-refl))
equiv-Fam-pushout-eq :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} {P Q : Fam-pushout l f g} →
Id P Q → equiv-Fam-pushout P Q
equiv-Fam-pushout-eq {P = P} {.P} refl =
reflexive-equiv-Fam-pushout P
is-contr-total-equiv-Fam-pushout :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} (P : Fam-pushout l f g) →
is-contr (Σ (Fam-pushout l f g) (equiv-Fam-pushout P))
is-contr-total-equiv-Fam-pushout {S = S} {A} {B} {f} {g} P =
is-contr-total-Eq-structure
( λ PA' t eA →
Σ ( (b : B) → (pr1 (pr2 P) b) ≃ (pr1 t b))
( coherence-equiv-Fam-pushout P (pair PA' t) eA))
( is-contr-total-Eq-Π
( λ a X → (pr1 P a) ≃ X)
( λ a → is-contr-total-equiv (pr1 P a))
( pr1 P))
( pair (pr1 P) (λ a → equiv-id (pr1 P a)))
( is-contr-total-Eq-structure
( λ PB' PS' eB →
coherence-equiv-Fam-pushout
P (pair (pr1 P) (pair PB' PS'))
(λ a → equiv-id (pr1 P a)) eB)
( is-contr-total-Eq-Π
( λ b Y → (pr1 (pr2 P) b) ≃ Y)
( λ b → is-contr-total-equiv (pr1 (pr2 P) b))
( pr1 (pr2 P)))
( pair (pr1 (pr2 P)) (λ b → equiv-id (pr1 (pr2 P) b)))
( is-contr-total-Eq-Π
( λ s e → (map-equiv (pr2 (pr2 P) s)) ~ (map-equiv e))
( λ s → is-contr-total-htpy-equiv (pr2 (pr2 P) s))
( pr2 (pr2 P))))
is-equiv-equiv-Fam-pushout-eq :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} (P Q : Fam-pushout l f g) →
is-equiv (equiv-Fam-pushout-eq {P = P} {Q})
is-equiv-equiv-Fam-pushout-eq P =
fundamental-theorem-id P
( reflexive-equiv-Fam-pushout P)
( is-contr-total-equiv-Fam-pushout P)
( λ Q → equiv-Fam-pushout-eq {P = P} {Q})
equiv-equiv-Fam-pushout :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} (P Q : Fam-pushout l f g) →
Id P Q ≃ equiv-Fam-pushout P Q
equiv-equiv-Fam-pushout P Q =
pair
( equiv-Fam-pushout-eq)
( is-equiv-equiv-Fam-pushout-eq P Q)
eq-equiv-Fam-pushout :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} {P Q : Fam-pushout l f g} →
(equiv-Fam-pushout P Q) → Id P Q
eq-equiv-Fam-pushout {P = P} {Q} =
inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q)
issec-eq-equiv-Fam-pushout :
{ l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{ f : S → A} {g : S → B} {P Q : Fam-pushout l f g} →
( ( equiv-Fam-pushout-eq {P = P} {Q}) ∘
( eq-equiv-Fam-pushout {P = P} {Q})) ~ id
issec-eq-equiv-Fam-pushout {P = P} {Q} =
issec-inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q)
isretr-eq-equiv-Fam-pushout :
{l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} {P Q : Fam-pushout l f g} →
( ( eq-equiv-Fam-pushout {P = P} {Q}) ∘
( equiv-Fam-pushout-eq {P = P} {Q})) ~ id
isretr-eq-equiv-Fam-pushout {P = P} {Q} =
isretr-inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q)
{- This concludes the characterization of the identity type of Fam-pushout. -}
{- Definition 18.2.2 -}
desc-fam :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
(P : X → UU l) → Fam-pushout l f g
desc-fam c P =
pair
( P ∘ (pr1 c))
( pair
( P ∘ (pr1 (pr2 c)))
( λ s → (pair (tr P (pr2 (pr2 c) s)) (is-equiv-tr P (pr2 (pr2 c) s)))))
{- Theorem 18.2.3 -}
Fam-pushout-cocone-UU :
{l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} → cocone f g (UU l) → Fam-pushout l f g
Fam-pushout-cocone-UU l =
tot (λ PA → (tot (λ PB H s → equiv-eq (H s))))
is-equiv-Fam-pushout-cocone-UU :
{l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
{f : S → A} {g : S → B} →
is-equiv (Fam-pushout-cocone-UU l {f = f} {g})
is-equiv-Fam-pushout-cocone-UU l {f = f} {g} =
is-equiv-tot-is-fiberwise-equiv
( λ PA → is-equiv-tot-is-fiberwise-equiv
( λ PB → is-equiv-postcomp-Π
( λ s → equiv-eq)
( λ s → univalence (PA (f s)) (PB (g s)))))
htpy-equiv-eq-ap-fam :
{l1 l2 : Level} {A : UU l1} (B : A → UU l2) {x y : A} (p : Id x y) →
htpy-equiv (equiv-tr B p) (equiv-eq (ap B p))
htpy-equiv-eq-ap-fam B {x} {.x} refl =
reflexive-htpy-equiv (equiv-id (B x))
triangle-desc-fam :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
( desc-fam {l = l} c) ~
( ( Fam-pushout-cocone-UU l {f = f} {g}) ∘ ( cocone-map f g {Y = UU l} c))
triangle-desc-fam {l = l} {S} {A} {B} {X} (pair i (pair j H)) P =
eq-equiv-Fam-pushout
( pair
( λ a → equiv-id (P (i a)))
( pair
( λ b → equiv-id (P (j b)))
( λ s → htpy-equiv-eq-ap-fam P (H s))))
is-equiv-desc-fam :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
((l' : Level) → universal-property-pushout l' f g c) →
is-equiv (desc-fam {l = l} {f = f} {g} c)
is-equiv-desc-fam {l = l} {f = f} {g} c up-c =
is-equiv-comp
( desc-fam c)
( Fam-pushout-cocone-UU l)
( cocone-map f g c)
( triangle-desc-fam c)
( up-c (lsuc l) (UU l))
( is-equiv-Fam-pushout-cocone-UU l)
equiv-desc-fam :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
((l' : Level) → universal-property-pushout l' f g c) →
(X → UU l) ≃ Fam-pushout l f g
equiv-desc-fam c up-c =
pair
( desc-fam c)
( is-equiv-desc-fam c up-c)
{- Corollary 18.2.4 -}
uniqueness-Fam-pushout :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) →
((l' : Level) → universal-property-pushout l' f g c) →
( P : Fam-pushout l f g) →
is-contr
( Σ (X → UU l) (λ Q →
equiv-Fam-pushout P (desc-fam c Q)))
uniqueness-Fam-pushout {l = l} f g c up-c P =
is-contr-equiv'
( fib (desc-fam c) P)
( equiv-tot (λ Q →
( equiv-equiv-Fam-pushout P (desc-fam c Q)) ∘e
( equiv-inv (desc-fam c Q) P)))
( is-contr-map-is-equiv (is-equiv-desc-fam c up-c) P)
fam-Fam-pushout :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
(up-X : (l' : Level) → universal-property-pushout l' f g c) →
Fam-pushout l f g → (X → UU l)
fam-Fam-pushout {f = f} {g} c up-X P =
pr1 (center (uniqueness-Fam-pushout f g c up-X P))
issec-fam-Fam-pushout :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{f : S → A} {g : S → B} (c : cocone f g X) →
(up-X : (l' : Level) → universal-property-pushout l' f g c) →
((desc-fam {l = l} c) ∘ (fam-Fam-pushout c up-X)) ~ id
issec-fam-Fam-pushout {f = f} {g} c up-X P =
inv (eq-equiv-Fam-pushout (pr2 (center (uniqueness-Fam-pushout f g c up-X P))))
comp-left-fam-Fam-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{ f : S → A} {g : S → B} (c : cocone f g X) →
( up-X : (l' : Level) → universal-property-pushout l' f g c) →
( P : Fam-pushout l f g) →
( a : A) → (pr1 P a) ≃ (fam-Fam-pushout c up-X P (pr1 c a))
comp-left-fam-Fam-pushout {f = f} {g} c up-X P =
pr1 (pr2 (center (uniqueness-Fam-pushout f g c up-X P)))
comp-right-fam-Fam-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{ f : S → A} {g : S → B} (c : cocone f g X) →
( up-X : (l' : Level) → universal-property-pushout l' f g c) →
( P : Fam-pushout l f g) →
( b : B) → (pr1 (pr2 P) b) ≃ (fam-Fam-pushout c up-X P (pr1 (pr2 c) b))
comp-right-fam-Fam-pushout {f = f} {g} c up-X P =
pr1 (pr2 (pr2 (center (uniqueness-Fam-pushout f g c up-X P))))
comp-path-fam-Fam-pushout :
{ l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
{ f : S → A} {g : S → B} (c : cocone f g X) →
( up-X : (l' : Level) → universal-property-pushout l' f g c) →
( P : Fam-pushout l f g) →
( s : S) →
( ( map-equiv (comp-right-fam-Fam-pushout c up-X P (g s))) ∘
( map-equiv (pr2 (pr2 P) s))) ~
( ( tr (fam-Fam-pushout c up-X P) (pr2 (pr2 c) s)) ∘
( map-equiv (comp-left-fam-Fam-pushout c up-X P (f s))))
comp-path-fam-Fam-pushout {f = f} {g} c up-X P =
pr2 (pr2 (pr2 (center (uniqueness-Fam-pushout f g c up-X P))))
{-
-- Section 18.3 The Flattening lemma for pushouts
{- Definition 18.3.1 -}
cocone-flattening-pushout :
{ l1 l2 l3 l4 l5 : Level}
{ S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
( f : S → A) (g : S → B) (c : cocone f g X)
( P : Fam-pushout l5 f g)
( Q : X → UU l5)
( e : equiv-Fam-pushout P (desc-fam f g c Q)) →
cocone
( toto (pr1 P) f (λ s → id))
( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s)))
( Σ X Q)
cocone-flattening-pushout f g c P Q e =
pair
( toto Q
( pr1 c)
( λ a → map-equiv (pr1 e a)))
( pair
( toto Q
( pr1 (pr2 c))
( λ b → map-equiv (pr1 (pr2 e) b)))
( htpy-toto Q
( pr2 (pr2 c))
( λ s → map-equiv (pr1 e (f s)))
( λ s → htpy-inv (pr2 (pr2 e) s))))
{- Theorem 18.3.2 The flattening lemma -}
coherence-bottom-flattening-lemma' :
{l1 l2 l3 : Level} {B : UU l1} {Q : B → UU l2} {T : UU l3}
{b b' : B} (α : Id b b') {y : Q b} {y' : Q b'} (β : Id (tr Q α y) y')
(h : (b : B) → Q b → T) → Id (h b y) (h b' y')
coherence-bottom-flattening-lemma' refl refl h = refl
coherence-bottom-flattening-lemma :
{l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {P : A → UU l3} {Q : B → UU l4} {T : UU l5}
{f f' : A → B} (H : f ~ f')
{g : (a : A) → P a → Q (f a)}
{g' : (a : A) → P a → Q (f' a)}
(K : (a : A) → ((tr Q (H a)) ∘ (g a)) ~ (g' a))
(h : (b : B) → Q b → T) → (a : A) (p : P a) →
Id (h (f a) (g a p)) (h (f' a) (g' a p))
coherence-bottom-flattening-lemma H K h a p =
coherence-bottom-flattening-lemma' (H a) (K a p) h
coherence-cube-flattening-lemma :
{l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {P : A → UU l3} {Q : B → UU l4} {T : UU l5}
{f f' : A → B} (H : f ~ f')
{g : (a : A) → P a → Q (f a)}
{g' : (a : A) → P a → Q (f' a)}
(K : (a : A) → ((tr Q (H a)) ∘ (g a)) ~ (g' a))
(h : Σ B Q → T) →
Id ( eq-htpy
( λ a → eq-htpy
( coherence-bottom-flattening-lemma H K (ev-pair h) a)))
( ap ev-pair
( htpy-precomp (htpy-toto Q H g K) T h))
coherence-cube-flattening-lemma {A = A} {B} {P} {Q} {T} {f = f} {f'} H {g} {g'} K = ind-htpy f
( λ f' H' →
(g : (a : A) → P a → Q (f a)) (g' : (a : A) → P a → Q (f' a))
(K : (a : A) → ((tr Q (H' a)) ∘ (g a)) ~ (g' a)) (h : Σ B Q → T) →
Id ( eq-htpy
( λ a → eq-htpy
( coherence-bottom-flattening-lemma H' K (ev-pair h) a)))
( ap ev-pair
( htpy-precomp (htpy-toto Q H' g K) T h)))
( λ g g' K h → {!ind-htpy g (λ g' K' → (h : Σ B Q → T) →
Id ( eq-htpy
( λ a → eq-htpy
( coherence-bottom-flattening-lemma htpy-refl (λ a → htpy-eq (K' a)) (ev-pair h) a)))
( ap ev-pair
( htpy-precomp (htpy-toto Q htpy-refl g (λ a → htpy-eq (K' a))) T h))) ? (λ a → eq-htpy (K a)) h!})
H g g' K
flattening-pushout' :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) →
( P : Fam-pushout l5 f g)
( Q : X → UU l5)
( e : equiv-Fam-pushout P (desc-fam f g c Q)) →
(l : Level) →
pullback-property-pushout l
( toto (pr1 P) f (λ s → id))
( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s)))
( cocone-flattening-pushout f g c P Q e)
flattening-pushout' f g c P Q e l T =
is-pullback-top-is-pullback-bottom-cube-is-equiv
( ( postcomp-Π (λ x → precomp-Π (map-equiv (pr1 e x)) (λ q → T))) ∘
( precomp-Π (pr1 c) (λ x → (Q x) → T)))
( ( postcomp-Π (λ x → precomp-Π (map-equiv (pr1 (pr2 e) x)) (λ q → T))) ∘
( precomp-Π (pr1 (pr2 c)) (λ x → (Q x) → T)))
( precomp-Π f (λ a → (pr1 P a) → T))
( ( postcomp-Π (λ s → precomp (map-equiv (pr2 (pr2 P) s)) T)) ∘
( precomp-Π g (λ b → (pr1 (pr2 P) b) → T)))
( precomp (toto Q (pr1 c) (λ a → map-equiv (pr1 e a))) T)
( precomp (toto Q (pr1 (pr2 c)) (λ b → map-equiv (pr1 (pr2 e) b))) T)
( precomp (toto (pr1 P) f (λ s → id)) T)
( precomp (toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) T)
ev-pair
ev-pair
ev-pair
ev-pair
( htpy-precomp
( htpy-toto Q
( pr2 (pr2 c))
( λ s → map-equiv (pr1 e (f s)))
( λ s → htpy-inv (pr2 (pr2 e) s)))
( T))
htpy-refl
htpy-refl
htpy-refl
htpy-refl
( λ h → eq-htpy (λ s → eq-htpy
( coherence-bottom-flattening-lemma
( pr2 (pr2 c))
( λ s → htpy-inv (pr2 (pr2 e) s))
( h)
( s))))
{!!}
is-equiv-ev-pair
is-equiv-ev-pair
is-equiv-ev-pair
is-equiv-ev-pair
{!!}
flattening-pushout :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4}
(f : S → A) (g : S → B) (c : cocone f g X) →
( P : Fam-pushout l5 f g)
( Q : X → UU l5)
( e : equiv-Fam-pushout P (desc-fam f g c Q)) →
(l : Level) →
universal-property-pushout l
( toto (pr1 P) f (λ s → id))
( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s)))
( cocone-flattening-pushout f g c P Q e)
flattening-pushout f g c P Q e l =
universal-property-pushout-pullback-property-pushout l
( toto (pr1 P) f (λ s → id))
( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s)))
( cocone-flattening-pushout f g c P Q e)
( flattening-pushout' f g c P Q e l)
-}
| 38.135484
| 110
| 0.528739
|
10497dbedce13a630521f9e8d3ed2b4ace62cad0
| 2,746
|
agda
|
Agda
|
BasicIS4/Syntax/HilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIS4/Syntax/HilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIS4/Syntax/HilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇.
-- Hilbert-style formalisation of syntax.
-- Sequences of terms.
module BasicIS4.Syntax.HilbertSequential where
open import BasicIS4.Syntax.Common public
-- Derivations.
infix 3 _⊦⊢_
data _⊦⊢_ (Γ : Cx Ty) : Cx Ty → Set where
nil : Γ ⊦⊢ ∅
var : ∀ {Ξ A} → A ∈ Γ → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A
mp : ∀ {Ξ A B} → A ▻ B ∈ Ξ → A ∈ Ξ → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , B
ci : ∀ {Ξ A} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A ▻ A
ck : ∀ {Ξ A B} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A ▻ B ▻ A
cs : ∀ {Ξ A B C} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
nec : ∀ {Ξ Ξ′ A} → ∅ ⊦⊢ Ξ′ , A → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , □ A
cdist : ∀ {Ξ A B} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , □ (A ▻ B) ▻ □ A ▻ □ B
cup : ∀ {Ξ A} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , □ A ▻ □ □ A
cdown : ∀ {Ξ A} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , □ A ▻ A
cpair : ∀ {Ξ A B} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A ▻ B ▻ A ∧ B
cfst : ∀ {Ξ A B} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A ∧ B ▻ A
csnd : ∀ {Ξ A B} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , A ∧ B ▻ B
unit : ∀ {Ξ} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ , ⊤
infix 3 _⊢_
_⊢_ : Cx Ty → Ty → Set
Γ ⊢ A = ∃ (λ Ξ → Γ ⊦⊢ Ξ , A)
-- Monotonicity with respect to context inclusion.
mono⊦⊢ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊦⊢ Ξ → Γ′ ⊦⊢ Ξ
mono⊦⊢ η nil = nil
mono⊦⊢ η (var i ts) = var (mono∈ η i) (mono⊦⊢ η ts)
mono⊦⊢ η (mp i j ts) = mp i j (mono⊦⊢ η ts)
mono⊦⊢ η (ci ts) = ci (mono⊦⊢ η ts)
mono⊦⊢ η (ck ts) = ck (mono⊦⊢ η ts)
mono⊦⊢ η (cs ts) = cs (mono⊦⊢ η ts)
mono⊦⊢ η (nec ss ts) = nec ss (mono⊦⊢ η ts)
mono⊦⊢ η (cdist ts) = cdist (mono⊦⊢ η ts)
mono⊦⊢ η (cup ts) = cup (mono⊦⊢ η ts)
mono⊦⊢ η (cdown ts) = cdown (mono⊦⊢ η ts)
mono⊦⊢ η (cpair ts) = cpair (mono⊦⊢ η ts)
mono⊦⊢ η (cfst ts) = cfst (mono⊦⊢ η ts)
mono⊦⊢ η (csnd ts) = csnd (mono⊦⊢ η ts)
mono⊦⊢ η (unit ts) = unit (mono⊦⊢ η ts)
mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A
mono⊢ η (Ξ , ts) = Ξ , mono⊦⊢ η ts
-- Concatenation of derivations.
_⧺⊦_ : ∀ {Γ Ξ Ξ′} → Γ ⊦⊢ Ξ → Γ ⊦⊢ Ξ′ → Γ ⊦⊢ Ξ ⧺ Ξ′
us ⧺⊦ nil = us
us ⧺⊦ var i ts = var i (us ⧺⊦ ts)
us ⧺⊦ mp i j ts = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (us ⧺⊦ ts)
us ⧺⊦ ci ts = ci (us ⧺⊦ ts)
us ⧺⊦ ck ts = ck (us ⧺⊦ ts)
us ⧺⊦ cs ts = cs (us ⧺⊦ ts)
us ⧺⊦ nec ss ts = nec ss (us ⧺⊦ ts)
us ⧺⊦ cdist ts = cdist (us ⧺⊦ ts)
us ⧺⊦ cup ts = cup (us ⧺⊦ ts)
us ⧺⊦ cdown ts = cdown (us ⧺⊦ ts)
us ⧺⊦ cpair ts = cpair (us ⧺⊦ ts)
us ⧺⊦ cfst ts = cfst (us ⧺⊦ ts)
us ⧺⊦ csnd ts = csnd (us ⧺⊦ ts)
us ⧺⊦ unit ts = unit (us ⧺⊦ ts)
-- Modus ponens and necessitation in expanded form.
app : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B
app {A} {B} (Ξ , ts) (Ξ′ , us) = Ξ″ , vs
where Ξ″ = (Ξ′ , A) ⧺ (Ξ , A ▻ B)
vs = mp top (mono∈ (weak⊆⧺₁ (Ξ , A ▻ B)) top) (us ⧺⊦ ts)
box : ∀ {A Γ} → ∅ ⊢ A → Γ ⊢ □ A
box (Ξ , ts) = ∅ , nec ts nil
| 32.690476
| 71
| 0.430444
|
0e7d98bad3c8f34707e803cb02a2986b6eab6bb1
| 48
|
agda
|
Agda
|
Task/Matrix-transposition/Agda/matrix-transposition-2.agda
|
mullikine/RosettaCodeData
|
4f0027c6ce83daa36118ee8b67915a13cd23ab67
|
[
"Info-ZIP"
] | 1
|
2018-11-09T22:08:38.000Z
|
2018-11-09T22:08:38.000Z
|
Task/Matrix-transposition/Agda/matrix-transposition-2.agda
|
mullikine/RosettaCodeData
|
4f0027c6ce83daa36118ee8b67915a13cd23ab67
|
[
"Info-ZIP"
] | null | null | null |
Task/Matrix-transposition/Agda/matrix-transposition-2.agda
|
mullikine/RosettaCodeData
|
4f0027c6ce83daa36118ee8b67915a13cd23ab67
|
[
"Info-ZIP"
] | 1
|
2018-11-09T22:08:40.000Z
|
2018-11-09T22:08:40.000Z
|
(1 ∷ 4 ∷ []) ∷ (2 ∷ 5 ∷ []) ∷ (3 ∷ 6 ∷ []) ∷ []
| 24
| 47
| 0.125
|
18bab93b5fde75c87bb04c90c5fafe79e40b25aa
| 1,288
|
agda
|
Agda
|
src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Well-founded induction on the relation LTC
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.List.WF-Relation.LT-Cons.Induction.Acc.WF-I where
open import FOTC.Base
open import FOTC.Data.List
open import FOTC.Data.List.WF-Relation.LT-Cons
open import FOTC.Data.List.WF-Relation.LT-Cons.PropertiesI
open import FOTC.Data.List.WF-Relation.LT-Length
open import FOTC.Data.List.WF-Relation.LT-Length.Induction.Acc.WF-I
open import FOTC.Induction.WF
-- Parametrized modules
open module S = FOTC.Induction.WF.Subrelation {List} {LTC} LTC→LTL
------------------------------------------------------------------------------
-- The relation LTL is well-founded (using the subrelation combinator).
LTC-wf : WellFounded LTC
LTC-wf Lxs = well-founded LTL-wf Lxs
-- Well-founded induction on the relation LTC.
LTC-wfind : (A : D → Set) →
(∀ {xs} → List xs → (∀ {ys} → List ys → LTC ys xs → A ys) → A xs) →
∀ {xs} → List xs → A xs
LTC-wfind A = WellFoundedInduction LTC-wf
| 39.030303
| 79
| 0.552019
|
df2464b9fb4275ed6a0ad252d4255dd40751af90
| 8,154
|
agda
|
Agda
|
Cubical/Experiments/ZCohomologyOld/KcompPrelims.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Experiments/ZCohomologyOld/KcompPrelims.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Experiments/ZCohomologyOld/KcompPrelims.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Experiments.ZCohomologyOld.KcompPrelims where
open import Cubical.ZCohomology.Base
open import Cubical.Homotopy.Connected
open import Cubical.HITs.Hopf
-- open import Cubical.Homotopy.Freudenthal hiding (encode)
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.HITs.Truncation renaming (elim to trElim ; rec to trRec ; map to trMap)
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.Int renaming (_+_ to +Int) hiding (_·_)
open import Cubical.Data.Nat hiding (_·_)
open import Cubical.Data.Unit
open import Cubical.HITs.Susp
open import Cubical.HITs.Nullification
open import Cubical.Data.Prod.Base
open import Cubical.Homotopy.Loopspace
open import Cubical.Data.Bool
open import Cubical.Data.Sum.Base
open import Cubical.Data.Sigma hiding (_×_)
open import Cubical.Foundations.Function
open import Cubical.Foundations.Pointed
open import Cubical.HITs.S3
private
variable
ℓ : Level
A : Type ℓ
{- We want to prove that Kn≃ΩKn+1. For this we use the map ϕ-}
-- Proof of Kₙ ≃ ∥ ΩSⁿ⁺¹ ∥ₙ for $n ≥ 2$
-- Entirely based on Cavallos proof of Freudenthal in Cubical.Homotopy.Freudenthal
module miniFreudenthal (n : HLevel) where
σ : S₊ (2 + n) → typ (Ω (S₊∙ (3 + n)))
σ a = merid a ∙ merid north ⁻¹
S2+n = S₊ (2 + n)
4n+2 = (2 + n) + (2 + n)
module WC-S (p : north ≡ north) where
P : (a b : S₊ (2 + n)) → Type₀
P a b = σ b ≡ p → hLevelTrunc 4n+2 (fiber (λ x → merid x ∙ merid a ⁻¹) p)
hLevelP : (a b : S₊ (2 + n)) → isOfHLevel 4n+2 (P a b)
hLevelP _ _ = isOfHLevelΠ 4n+2 λ _ → isOfHLevelTrunc 4n+2
leftFun : (a : S₊ (2 + n)) → P a north
leftFun a r = ∣ a , (rCancel' (merid a) ∙ rCancel' (merid north) ⁻¹) ∙ r ∣
rightFun : (b : S₊ (2 + n)) → P north b
rightFun b r = ∣ b , r ∣
funsAgree : leftFun north ≡ rightFun north
funsAgree =
funExt λ r → (λ i → ∣ north , rCancel' (rCancel' (merid north)) i ∙ r ∣)
∙ λ i → ∣ north , lUnit r (~ i) ∣
totalFun : (a b : S2+n) → P a b
totalFun = wedgeconFun (suc n) (suc n) hLevelP rightFun leftFun funsAgree
leftId : (λ x → totalFun x north) ≡ leftFun
leftId x i = wedgeconRight (suc n) (suc n) hLevelP rightFun leftFun funsAgree i x
fwd : (p : north ≡ north) (a : S2+n)
→ hLevelTrunc 4n+2 (fiber σ p)
→ hLevelTrunc 4n+2 (fiber (λ x → merid x ∙ merid a ⁻¹) p)
fwd p a = trRec (isOfHLevelTrunc 4n+2) (uncurry (WC-S.totalFun p a))
fwdnorth : (p : north ≡ north) → fwd p north ≡ idfun _
fwdnorth p = funExt (trElim (λ _ → isOfHLevelPath 4n+2 (isOfHLevelTrunc 4n+2) _ _)
λ p → refl)
isEquivFwd : (p : north ≡ north) (a : S2+n) → isEquiv (fwd p a)
isEquivFwd p =
suspToPropElim (ptSn (suc n))
(λ _ → isPropIsEquiv _)
helper
where
helper : isEquiv (fwd p north)
helper = subst isEquiv (sym (fwdnorth p)) (idIsEquiv _)
interpolate : (a : S2+n)
→ PathP (λ i → S2+n → north ≡ merid a i) (λ x → merid x ∙ merid a ⁻¹) merid
interpolate a i x j = compPath-filler (merid x) (merid a ⁻¹) (~ i) j
Code : (y : Susp S2+n) → north ≡ y → Type₀
Code north p = hLevelTrunc 4n+2 (fiber σ p)
Code south q = hLevelTrunc 4n+2 (fiber merid q)
Code (merid a i) p =
Glue
(hLevelTrunc 4n+2 (fiber (interpolate a i) p))
(λ
{ (i = i0) → _ , (fwd p a , isEquivFwd p a)
; (i = i1) → _ , idEquiv _
})
encodeS : (y : S₊ (3 + n)) (p : north ≡ y) → Code y p
encodeS y = J Code ∣ north , rCancel' (merid north) ∣
encodeMerid : (a : S2+n) → encodeS south (merid a) ≡ ∣ a , refl ∣
encodeMerid a =
cong (transport (λ i → gluePath i))
(funExt⁻ (funExt⁻ (WC-S.leftId refl) a) _ ∙ λ i → ∣ a , lem (rCancel' (merid a)) (rCancel' (merid north)) i ∣)
∙ transport (PathP≡Path gluePath _ _)
(λ i → ∣ a , (λ j k → rCancel-filler' (merid a) i j k) ∣)
where
gluePath : I → Type _
gluePath i = hLevelTrunc 4n+2 (fiber (interpolate a i) (λ j → merid a (i ∧ j)))
lem : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : z ≡ y) → (p ∙ q ⁻¹) ∙ q ≡ p
lem p q = assoc p (q ⁻¹) q ⁻¹ ∙ cong (p ∙_) (lCancel q) ∙ rUnit p ⁻¹
contractCodeSouth : (p : north ≡ south) (c : Code south p) → encodeS south p ≡ c
contractCodeSouth p =
trElim
(λ _ → isOfHLevelPath 4n+2 (isOfHLevelTrunc 4n+2) _ _)
(uncurry λ a →
J (λ p r → encodeS south p ≡ ∣ a , r ∣) (encodeMerid a))
isConnectedMerid : isConnectedFun 4n+2 (merid {A = S2+n})
isConnectedMerid p = encodeS south p , contractCodeSouth p
isConnectedσ : isConnectedFun 4n+2 σ
isConnectedσ =
transport (λ i → isConnectedFun 4n+2 (interpolate north (~ i))) isConnectedMerid
isConnectedσ-Sn : (n : ℕ) → isConnectedFun (4 + n) (miniFreudenthal.σ n)
isConnectedσ-Sn n =
isConnectedFunSubtr _ n _
(subst (λ x → isConnectedFun x (miniFreudenthal.σ n))
helper
(miniFreudenthal.isConnectedσ n))
where
helper : 2 + (n + (2 + n)) ≡ n + (4 + n)
helper = cong suc (sym (+-suc n _)) ∙ sym (+-suc n _)
stabSpheres-n≥2 : (n : ℕ) → Iso (hLevelTrunc (4 + n) (S₊ (2 + n)))
(hLevelTrunc (4 + n) (typ (Ω (S₊∙ (3 + n)))))
stabSpheres-n≥2 n = connectedTruncIso (4 + n) (miniFreudenthal.σ n) (isConnectedσ-Sn n)
--
ϕ : (pt a : A) → typ (Ω (Susp A , north))
ϕ pt a = (merid a) ∙ sym (merid pt)
private
Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n)))
Kn→ΩKn+1 zero x i = ∣ intLoop x i ∣
Kn→ΩKn+1 (suc zero) = trRec (isOfHLevelTrunc 4 ∣ north ∣ ∣ north ∣)
λ a i → ∣ ϕ base a i ∣
Kn→ΩKn+1 (suc (suc n)) = trRec (isOfHLevelTrunc (2 + (3 + n)) ∣ north ∣ ∣ north ∣)
λ a i → ∣ ϕ north a i ∣
d-map : typ (Ω ((Susp S¹) , north)) → S¹
d-map p = subst HopfSuspS¹ p base
d-mapId : (r : S¹) → d-map (ϕ base r) ≡ r
d-mapId r = substComposite HopfSuspS¹ (merid r) (sym (merid base)) base ∙
rotLemma r
where
rotLemma : (r : S¹) → r · base ≡ r
rotLemma base = refl
rotLemma (loop i) = refl
sphereConnectedSpecCase : isConnected 4 (Susp (Susp S¹))
sphereConnectedSpecCase = sphereConnected 3
d-mapComp : Iso (fiber d-map base) (Path (S₊ 3) north north)
d-mapComp = compIso (IsoΣPathTransportPathΣ {B = HopfSuspS¹} _ _)
(congIso (invIso IsoS³TotalHopf))
is1Connected-dmap : isConnectedFun 3 d-map
is1Connected-dmap = toPropElim (λ _ → isPropIsOfHLevel 0)
(isConnectedRetractFromIso 3 d-mapComp
(isOfHLevelRetractFromIso 0 (invIso (PathIdTruncIso 3))
contrHelper))
where
contrHelper : isContr (Path (∥ Susp (Susp S¹) ∥ 4) ∣ north ∣ ∣ north ∣)
fst contrHelper = refl
snd contrHelper = isOfHLevelPlus {n = 0} 2 (sphereConnected 3) ∣ north ∣ ∣ north ∣ refl
d-Iso : Iso (∥ Path (S₊ 2) north north ∥ 3) (coHomK 1)
d-Iso = connectedTruncIso _ d-map is1Connected-dmap
d-mapId2 : Iso.fun d-Iso ∘ trMap (ϕ base) ≡ idfun (coHomK 1)
d-mapId2 = funExt (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ a i → ∣ d-mapId a i ∣)
Iso∥ϕ₁∥ : Iso (coHomK 1) (∥ Path (S₊ 2) north north ∥ 3)
Iso∥ϕ₁∥ = composesToId→Iso d-Iso (trMap (ϕ base)) d-mapId2
Iso-Kn-ΩKn+1 : (n : HLevel) → Iso (coHomK n) (typ (Ω (coHomK-ptd (suc n))))
Iso-Kn-ΩKn+1 zero = invIso (compIso (congIso (truncIdempotentIso _ isGroupoidS¹)) ΩS¹Isoℤ)
Iso-Kn-ΩKn+1 (suc zero) = compIso Iso∥ϕ₁∥ (invIso (PathIdTruncIso 3))
Iso-Kn-ΩKn+1 (suc (suc n)) = compIso (stabSpheres-n≥2 n)
(invIso (PathIdTruncIso (4 + n)))
where
helper : n + (4 + n) ≡ 2 + (n + (2 + n))
helper = +-suc n (3 + n) ∙ (λ i → suc (+-suc n (2 + n) i))
| 38.28169
| 116
| 0.607555
|
39670e80ffc78217b40b010adbd152576e1c0eeb
| 11,306
|
agda
|
Agda
|
StructurallyRecursiveDescentParsing/Lib.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
StructurallyRecursiveDescentParsing/Lib.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
StructurallyRecursiveDescentParsing/Lib.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- A library of parser combinators
------------------------------------------------------------------------
-- This module also provides examples of parsers for which the indices
-- cannot be inferred.
module StructurallyRecursiveDescentParsing.Lib where
open import StructurallyRecursiveDescentParsing.Grammar
open import StructurallyRecursiveDescentParsing.Index
open import Data.Nat hiding (_≟_)
open import Data.Vec as Vec using (Vec; []; _∷_)
open import Data.List using (List; []; _∷_; foldr; foldl; reverse)
open import Data.Product
open import Data.Bool using (Bool; true; false; _∧_; _∨_)
open import Function
open import Data.Maybe
open import Data.Unit using (⊤)
import Data.Char as Char
open Char using (Char; _==_)
open import Coinduction
open import Algebra
import Data.Bool.Properties as Bool
private
module BCS = CommutativeSemiring Bool.commutativeSemiring-∨-∧
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
import Level
------------------------------------------------------------------------
-- Some important derived combinators
infixl 10 _>>=_
_>>=_ : ∀ {NT Tok e₁ c₁ i₂ R₁ R₂} → let i₁ = e₁ ◇ c₁ in
Parser NT Tok i₁ R₁ →
(R₁ → Parser NT Tok i₂ R₂) →
Parser NT Tok (i₁ · i₂) R₂
_>>=_ {e₁ = true } p₁ p₂ = p₁ ?>>= p₂
_>>=_ {e₁ = false} p₁ p₂ = p₁ !>>= λ x → ♯ p₂ x
cast : ∀ {NT Tok e₁ e₂ c₁ c₂ R} →
e₁ ≡ e₂ → c₁ ≡ c₂ →
Parser NT Tok (e₁ ◇ c₁) R → Parser NT Tok (e₂ ◇ c₂) R
cast refl refl p = p
------------------------------------------------------------------------
-- Applicative functor parsers
-- We could get these for free with better library support.
infixl 50 _⊛_ _⊛!_ _<⊛_ _⊛>_ _<$>_ _<$_ _⊗_ _⊗!_
_⊛_ : ∀ {NT Tok i₁ i₂ R₁ R₂} →
Parser NT Tok i₁ (R₁ → R₂) →
Parser NT Tok i₂ R₁ →
Parser NT Tok _ R₂
p₁ ⊛ p₂ = p₁ >>= λ f → p₂ >>= λ x → return (f x)
-- A variant: If the second parser does not accept the empty string,
-- then neither does the combination. (This is immediate for the first
-- parser, but for the second one a small lemma is needed, hence this
-- variant.)
_⊛!_ : ∀ {NT Tok i₁ c₂ R₁ R₂} →
Parser NT Tok i₁ (R₁ → R₂) →
Parser NT Tok (false ◇ c₂) R₁ →
Parser NT Tok (false ◇ _) R₂
_⊛!_ {i₁ = i₁} p₁ p₂ = cast (BCS.*-comm (empty i₁) false) refl
(p₁ ⊛ p₂)
_<$>_ : ∀ {NT Tok i R₁ R₂} →
(R₁ → R₂) →
Parser NT Tok i R₁ →
Parser NT Tok _ R₂
f <$> p = return f ⊛ p
_<⊛_ : ∀ {NT Tok i₁ i₂ R₁ R₂} →
Parser NT Tok i₁ R₁ →
Parser NT Tok i₂ R₂ →
Parser NT Tok _ R₁
p₁ <⊛ p₂ = const <$> p₁ ⊛ p₂
_⊛>_ : ∀ {NT Tok i₁ i₂ R₁ R₂} →
Parser NT Tok i₁ R₁ →
Parser NT Tok i₂ R₂ →
Parser NT Tok _ R₂
p₁ ⊛> p₂ = flip const <$> p₁ ⊛ p₂
_<$_ : ∀ {NT Tok i R₁ R₂} →
R₁ →
Parser NT Tok i R₂ →
Parser NT Tok _ R₁
x <$ p = const x <$> p
_⊗_ : ∀ {NT Tok i₁ i₂ R₁ R₂} →
Parser NT Tok i₁ R₁ → Parser NT Tok i₂ R₂ →
Parser NT Tok _ (R₁ × R₂)
p₁ ⊗ p₂ = (_,_) <$> p₁ ⊛ p₂
_⊗!_ : ∀ {NT Tok i₁ c₂ R₁ R₂} →
Parser NT Tok i₁ R₁ → Parser NT Tok (false ◇ c₂) R₂ →
Parser NT Tok (false ◇ _) (R₁ × R₂)
p₁ ⊗! p₂ = (_,_) <$> p₁ ⊛! p₂
------------------------------------------------------------------------
-- Parsing sequences
infix 55 _⋆ _+
-- Not accepted by the productivity checker:
-- mutual
-- _⋆ : ∀ {NT Tok R c} →
-- Parser NT Tok (false ◇ c) R →
-- Parser NT Tok _ (List R)
-- p ⋆ = return [] ∣ p +
-- _+ : ∀ {NT Tok R c} →
-- Parser NT Tok (false ◇ c) R →
-- Parser NT Tok _ (List R)
-- p + = _∷_ <$> p ⊛ p ⋆
-- In fact the code above risks leading to infinite loops in the
-- current version of Agda (Mar 2009), since it does not contain any
-- coinductive constructors. The following code is OK, though:
mutual
_⋆ : ∀ {NT Tok R c} →
Parser NT Tok (false ◇ c) R →
Parser NT Tok _ (List R)
p ⋆ = return [] ∣ p +
_+ : ∀ {NT Tok R c} →
Parser NT Tok (false ◇ c) R →
Parser NT Tok _ (List R)
p + = p !>>= λ x → ♯
(p ⋆ ?>>= λ xs →
return (x ∷ xs))
-- p sepBy⟨ ne ⟩ sep and p sepBy sep parse one or more ps separated by
-- seps.
_sepBy⟨_⟩_ : ∀ {NT Tok i i′ R R′} →
Parser NT Tok i R →
(empty i′ ∧ true) ∧ (empty i ∧ true) ≡ false →
Parser NT Tok i′ R′ →
Parser NT Tok _ (List R)
p sepBy⟨ non-empty ⟩ sep = _∷_ <$> p ⊛ cast₁ (sep ⊛> p) ⋆
where cast₁ = cast non-empty refl
-- _sepBy_ could be implemented by using _sepBy⟨_⟩_, but the following
-- definition is handled more efficiently by the current version of
-- Agda (Dec 2008).
_sepBy_ : ∀ {NT Tok i c R R′} →
Parser NT Tok i R → Parser NT Tok (false ◇ c) R′ →
Parser NT Tok _ (List R)
p sepBy sep = _∷_ <$> p ⊛ (sep ⊛> p) ⋆
mutual
-- Note that the index of atLeast is only partly inferred; the
-- recursive structure of atLeast-index is given manually.
atLeast-index : Corners → ℕ → Index
atLeast-index c zero = _
atLeast-index c (suc n) = _
-- At least n occurrences of p.
atLeast : ∀ {NT Tok c R} (n : ℕ) →
Parser NT Tok (false ◇ c) R →
Parser NT Tok (atLeast-index c n) (List R)
atLeast zero p = p ⋆
atLeast (suc n) p = _∷_ <$> p ⊛ atLeast n p
-- exactly n p parses n occurrences of p.
--
-- (Note that, unlike what is written in "Structurally Recursive
-- Descent Parsing", Agda as of 2012-03-16 can no longer infer
-- exactly-index's second right-hand side.)
exactly-index : Index → ℕ → Index
exactly-index i zero = 1I
exactly-index i (suc n) = (1I · i · 1I) · exactly-index i n · 1I
exactly : ∀ {NT Tok i R} n →
Parser NT Tok i R →
Parser NT Tok (exactly-index i n) (Vec R n)
exactly zero p = return []
exactly (suc n) p = _∷_ <$> p ⊛ exactly n p
-- A function with a similar type:
sequence : ∀ {NT Tok i R n} →
Vec (Parser NT Tok i R) n →
Parser NT Tok (exactly-index i n) (Vec R n)
sequence [] = return []
sequence (p ∷ ps) = _∷_ <$> p ⊛ sequence ps
mutual
-- p between ps parses p repeatedly, between the elements of ps:
-- ∙ between (x ∷ y ∷ z ∷ []) ≈ x ∙ y ∙ z.
between-corners : Corners → ℕ → Corners
between-corners c′ zero = _
between-corners c′ (suc n) = _
_between_ : ∀ {NT Tok i R c′ R′ n} →
Parser NT Tok i R →
Vec (Parser NT Tok (false ◇ c′) R′) (suc n) →
Parser NT Tok (false ◇ between-corners c′ n) (Vec R n)
p between (x ∷ []) = [] <$ x
p between (x ∷ y ∷ xs) = _∷_ <$> (x ⊛> p) ⊛ (p between (y ∷ xs))
------------------------------------------------------------------------
-- Chaining
-- Associativity. Used to specify how chain≥ should apply the parsed
-- operators: left or right associatively.
data Assoc : Set where
left : Assoc
right : Assoc
-- Application.
appʳ : {R : Set} → R × (R → R → R) → R → R
appʳ (x , _•_) y = x • y
appˡ : {R : Set} → R → (R → R → R) × R → R
appˡ x (_•_ , y) = x • y
-- Shifting. See Examples below for an illuminating example.
shiftʳ : {A B : Set} → A → List (B × A) → List (A × B) × A
shiftʳ x [] = ([] , x)
shiftʳ x₁ ((x₂ , x₃) ∷ xs₄) = ((x₁ , x₂) ∷ proj₁ xs₃x₄ , proj₂ xs₃x₄)
where xs₃x₄ = shiftʳ x₃ xs₄
-- Post-processing for the chain≥ parser.
chain≥-combine : {R : Set} → Assoc → R → List ((R → R → R) × R) → R
chain≥-combine left x ys = foldl appˡ x ys
chain≥-combine right x ys with shiftʳ x ys
... | (xs , y) = foldr appʳ y xs
-- Chains at least n occurrences of op, in an a-associative
-- manner. The ops are surrounded by ps.
chain≥ : ∀ {NT Tok c₁ i₂ R} (n : ℕ) →
Assoc →
Parser NT Tok (false ◇ c₁) R →
Parser NT Tok i₂ (R → R → R) →
Parser NT Tok _ R
chain≥ n a p op = chain≥-combine a <$> p ⊛ atLeast n (op ⊗! p)
private
module Examples {R S : Set}
(x y z : R)
(a b : S)
(_+_ _*_ : R → R → R)
where
ex : shiftʳ x ((a , y) ∷ (b , z) ∷ []) ≡ ((x , a) ∷ (y , b) ∷ [] , z)
ex = refl
exʳ : chain≥-combine right x ((_+_ , y) ∷ (_*_ , z) ∷ []) ≡
(x + (y * z))
exʳ = refl
exˡ : chain≥-combine left x ((_+_ , y) ∷ (_*_ , z) ∷ []) ≡
((x + y) * z)
exˡ = refl
------------------------------------------------------------------------
-- N-ary variants of _∣_
-- choice ps parses one of the elements in ps.
choice-corners : Corners → ℕ → Corners
choice-corners c zero = ε
choice-corners c (suc n) = c ∪ choice-corners c n
choice : ∀ {NT Tok c R n} →
Vec (Parser NT Tok (false ◇ c) R) n →
Parser NT Tok (false ◇ choice-corners c n) R
choice [] = fail
choice (p ∷ ps) = p ∣ choice ps
-- choiceMap f xs ≈ choice (map f xs), but avoids use of Vec and
-- fromList.
choiceMap-corners : {A : Set} → (A → Corners) → List A → Corners
choiceMap-corners c [] = ε
choiceMap-corners c (x ∷ xs) = c x ∪ choiceMap-corners c xs
choiceMap : ∀ {NT Tok R} {A : Set} {c : A → Corners} →
((x : A) → Parser NT Tok (false ◇ c x) R) →
(xs : List A) →
Parser NT Tok (false ◇ choiceMap-corners c xs) R
choiceMap f [] = fail
choiceMap f (x ∷ xs) = f x ∣ choiceMap f xs
------------------------------------------------------------------------
-- sat and friends
sat : ∀ {NT Tok R} → (Tok → Maybe R) → Parser NT Tok (0I · 1I) R
sat {NT} {Tok} {R} p = token !>>= λ c → ♯ ok (p c)
where
mutual
okIndex : Maybe R → Index
okIndex nothing = _
okIndex (just _) = _
ok : (x : Maybe R) → Parser NT Tok (okIndex x) R
ok nothing = fail
ok (just x) = return x
sat' : ∀ {NT Tok} → (Tok → Bool) → Parser NT Tok _ ⊤
sat' p = sat (boolToMaybe ∘ p)
any : ∀ {NT Tok} → Parser NT Tok _ Tok
any = sat just
------------------------------------------------------------------------
-- Token parsers
module Token (A : DecSetoid Level.zero Level.zero) where
open DecSetoid A using (_≟_) renaming (Carrier to Tok)
-- Parses a given token (or, really, a given equivalence class of
-- tokens).
tok : ∀ {NT} → Tok → Parser NT Tok _ Tok
tok tok = sat p
where
p : Tok → Maybe Tok
p tok′ with tok ≟ tok′
... | yes _ = just tok′
... | no _ = nothing
-- Parses a sequence of tokens.
theString : ∀ {NT n} → Vec Tok n → Parser NT Tok _ (Vec Tok n)
theString cs = sequence (Vec.map tok cs)
------------------------------------------------------------------------
-- Character parsers
digit : ∀ {NT} → Parser NT Char _ ℕ
digit = 0 <$ tok '0'
∣ 1 <$ tok '1'
∣ 2 <$ tok '2'
∣ 3 <$ tok '3'
∣ 4 <$ tok '4'
∣ 5 <$ tok '5'
∣ 6 <$ tok '6'
∣ 7 <$ tok '7'
∣ 8 <$ tok '8'
∣ 9 <$ tok '9'
where open Token Char.decSetoid
number : ∀ {NT} → Parser NT Char _ ℕ
number = toNum <$> digit +
where
toNum = foldr (λ n x → 10 * x + n) 0 ∘ reverse
-- whitespace recognises an incomplete but useful list of whitespace
-- characters.
whitespace : ∀ {NT} → Parser NT Char _ ⊤
whitespace = sat' isSpace
where
isSpace = λ c →
(c == ' ') ∨ (c == '\t') ∨ (c == '\n') ∨ (c == '\r')
| 29.366234
| 72
| 0.520609
|
cb4356a68f1524a6a0f21bba8f508cc61ce09453
| 1,698
|
agda
|
Agda
|
huffman/huffman-main.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
huffman/huffman-main.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
huffman/huffman-main.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module huffman-main where
import parse
open import lib
open import huffman-types
import huffman
module parsem = parse huffman.gratr2-nt ptr
open parsem
open parsem.pnoderiv huffman.rrs huffman.huffman-rtn
open import run ptr
open noderiv {- from run.agda -}
process-start : start → string
process-start s = ""
process : Run → string
process (ParseTree (parsed-start p) :: []) = process-start p
process r = "Parsing failure (run with -" ^ "-showParsed).\n"
putStrRunIf : 𝔹 → Run → IO ⊤
putStrRunIf tt r = putStr (Run-to-string r) >> putStr "\n"
putStrRunIf ff r = return triv
processArgs : (showRun : 𝔹) → (showParsed : 𝔹) → 𝕃 string → IO ⊤
processArgs showRun showParsed (input-filename :: []) = (readFiniteFile input-filename) >>= processText
where processText : string → IO ⊤
processText x with runRtn (string-to-𝕃char x)
processText x | s with s
processText x | s | inj₁ cs = putStr "Characters left before failure : " >> putStr (𝕃char-to-string cs) >> putStr "\nCannot proceed to parsing.\n"
processText x | s | inj₂ r with putStrRunIf showRun r | rewriteRun r
processText x | s | inj₂ r | sr | r' with putStrRunIf showParsed r'
processText x | s | inj₂ r | sr | r' | sr' = sr >> sr' >> putStr (process r')
processArgs showRun showParsed ("--showRun" :: xs) = processArgs tt showParsed xs
processArgs showRun showParsed ("--showParsed" :: xs) = processArgs showRun tt xs
processArgs showRun showParsed (x :: xs) = putStr ("Unknown option " ^ x ^ "\n")
processArgs showRun showParsed [] = putStr "Please run with the name of a file to process.\n"
main : IO ⊤
main = getArgs >>= processArgs ff ff
| 39.488372
| 154
| 0.671378
|
d07a0ac8c6c56a18cacd0af990dfbd2e6b05fb86
| 1,005
|
agda
|
Agda
|
out/Sum/Signature.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 39
|
2021-11-09T20:39:55.000Z
|
2022-03-19T17:33:12.000Z
|
out/Sum/Signature.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 1
|
2021-11-21T12:19:32.000Z
|
2021-11-21T12:19:32.000Z
|
out/Sum/Signature.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 4
|
2021-11-09T20:39:59.000Z
|
2022-01-24T12:49:17.000Z
|
{-
This second-order signature was created from the following second-order syntax description:
syntax Sum | S
type
_⊕_ : 2-ary | l30
term
inl : α -> α ⊕ β
inr : β -> α ⊕ β
case : α ⊕ β α.γ β.γ -> γ
theory
(lβ) a : α f : α.γ g : β.γ |> case (inl(a), x.f[x], y.g[y]) = f[a]
(rβ) b : β f : α.γ g : β.γ |> case (inr(b), x.f[x], y.g[y]) = g[b]
(cη) s : α ⊕ β c : (α ⊕ β).γ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s]
-}
module Sum.Signature where
open import SOAS.Context
-- Type declaration
data ST : Set where
_⊕_ : ST → ST → ST
infixl 30 _⊕_
open import SOAS.Syntax.Signature ST public
open import SOAS.Syntax.Build ST public
-- Operator symbols
data Sₒ : Set where
inlₒ inrₒ : {α β : ST} → Sₒ
caseₒ : {α β γ : ST} → Sₒ
-- Term signature
S:Sig : Signature Sₒ
S:Sig = sig λ
{ (inlₒ {α}{β}) → (⊢₀ α) ⟼₁ α ⊕ β
; (inrₒ {α}{β}) → (⊢₀ β) ⟼₁ α ⊕ β
; (caseₒ {α}{β}{γ}) → (⊢₀ α ⊕ β) , (α ⊢₁ γ) , (β ⊢₁ γ) ⟼₃ γ
}
open Signature S:Sig public
| 21.382979
| 91
| 0.527363
|
2344862cd0eed24a7ff2328669aa008c40600243
| 346
|
agda
|
Agda
|
test/Succeed/Issue152.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue152.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue152.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue152 where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
f : ℕ → ℕ
f 0 with zero
f 0 | n = n
f 1 with zero
f 1 | n = n
f n = n
g : ℕ → ℕ
g 0 with zero
g zero | n = n
g 1 with zero
g (suc zero) | n = n
g n = n
h : ℕ → ℕ
h zero with zero
h 0 | n = n
h (suc zero) with zero
h 1 | n = n
h n = n
| 11.16129
| 28
| 0.511561
|
395c53ec9815250dd53eae9c732124bbe7ea2400
| 396
|
agda
|
Agda
|
examples/instance-arguments/05-equality-std2.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
examples/instance-arguments/05-equality-std2.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/instance-arguments/05-equality-std2.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --universe-polymorphism #-}
-- {-# OPTIONS --verbose tc.rec:15 #-}
-- {-# OPTIONS --verbose tc.records.ifs:15 #-}
-- {-# OPTIONS --verbose tc.constr.findInScope:15 #-}
-- {-# OPTIONS --verbose tc.term.args.ifs:15 #-}
module 05-equality-std2 where
open import Relation.Binary
open import Data.Bool hiding (_≟_)
open DecSetoid {{...}}
test = isDecEquivalence
test2 = false ≟ false
| 24.75
| 53
| 0.664141
|
d0b05d7a4a3dc47a9ecd01af2f7313dc1cc9dc81
| 1,483
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyFun.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyFun.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyFun.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyFun where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+n_)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Sigma
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.GradedRing.DirectSumFun
private variable
ℓ : Level
module _
(ACommRing@(A , Astr) : CommRing ℓ)
where
open CommRingStr Astr
open RingTheory (CommRing→Ring ACommRing)
UnivariatePolyFun-CommRing : CommRing ℓ
UnivariatePolyFun-CommRing = ⊕FunGradedRing-CommRing
_+n_ (makeIsMonoid isSetℕ +-assoc +-zero λ _ → refl) (λ _ _ → refl)
(λ _ → A)
(λ _ → snd (Ring→AbGroup (CommRing→Ring ACommRing)))
1r _·_ 0LeftAnnihilates 0RightAnnihilates
(λ a b c → ΣPathP ((+-assoc _ _ _) , (·Assoc _ _ _)))
(λ a → ΣPathP ((+-zero _) , (·IdR _)))
(λ a → ΣPathP (refl , (·IdL _)))
·DistR+
·DistL+
λ x y → ΣPathP ((+-comm _ _) , (·Comm _ _))
nUnivariatePolyFun : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ
nUnivariatePolyFun A' zero = A'
nUnivariatePolyFun A' (suc n) = UnivariatePolyFun-CommRing (nUnivariatePolyFun A' n)
| 35.309524
| 86
| 0.634525
|
dc639fb4abbc7f08ee0c2cc64d6a6b60c0435dd1
| 10,783
|
agda
|
Agda
|
src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Braided.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Braided.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal/Braided.agda
|
o1lo01ol1o/agda-categories
|
5fc007768264a270b8ff319570225986773da601
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
-- Monoidal natural isomorphisms between lax and strong braided
-- monoidal functors.
--
-- NOTE. Braided monoidal natural isomorphisms are really just
-- monoidal natural isomorphisms that happen to go between braided
-- monoidal functors. No additional conditions are necessary.
-- Nevertheless, the definitions in this module are useful when one is
-- working in a braided monoidal setting. They also help Agda's type
-- checker by bundling the (braided monoidal) categories and functors
-- involved.
module Categories.NaturalTransformation.NaturalIsomorphism.Monoidal.Braided
where
open import Level
open import Relation.Binary using (IsEquivalence)
open import Categories.Category.Monoidal using (BraidedMonoidalCategory)
import Categories.Functor.Monoidal.Braided as BMF
open import Categories.Functor.Monoidal.Properties using () renaming
( idF-BraidedMonoidal to idFˡ ; idF-StrongBraidedMonoidal to idFˢ
; ∘-BraidedMonoidal to _∘Fˡ_ ; ∘-StrongBraidedMonoidal to _∘Fˢ_
)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI
using (NaturalIsomorphism)
import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal as MNI
module Lax where
open BMF.Lax using (BraidedMonoidalFunctor)
open MNI.Lax using (IsMonoidalNaturalIsomorphism)
open BraidedMonoidalFunctor using () renaming (F to UF; monoidalFunctor to MF)
private module U = MNI.Lax
module _ {o ℓ e o′ ℓ′ e′}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural isomorphisms between lax braided monoidal functors.
record BraidedMonoidalNaturalIsomorphism
(F G : BraidedMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalIsomorphism (UF F) (UF G)
F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism (MF F) (MF G) U
⌊_⌋ : U.MonoidalNaturalIsomorphism (MF F) (MF G)
⌊_⌋ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
open U.MonoidalNaturalIsomorphism ⌊_⌋ public hiding (U; F⇒G-isMonoidal)
infix 4 _≃_
_≃_ = BraidedMonoidalNaturalIsomorphism
-- "Strengthening"
⌈_⌉ : {F G : BraidedMonoidalFunctor C D} →
U.MonoidalNaturalIsomorphism (MF F) (MF G) → F ≃ G
⌈ α ⌉ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
where open U.MonoidalNaturalIsomorphism α
open BraidedMonoidalNaturalIsomorphism
-- Identity and compositions
infixr 9 _ⓘᵥ_
id : {F : BraidedMonoidalFunctor C D} → F ≃ F
id = ⌈ U.id ⌉
_ⓘᵥ_ : {F G H : BraidedMonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H
α ⓘᵥ β = ⌈ ⌊ α ⌋ U.ⓘᵥ ⌊ β ⌋ ⌉
isEquivalence : IsEquivalence _≃_
isEquivalence = record
{ refl = id
; sym = λ α → record
{ U = NI.sym (U α)
; F⇒G-isMonoidal = F⇐G-isMonoidal α
}
; trans = λ α β → β ⓘᵥ α
}
where
open BraidedMonoidalNaturalIsomorphism
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′}
{E : BraidedMonoidalCategory o″ ℓ″ e″} where
infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_
_ⓘₕ_ : {F G : BraidedMonoidalFunctor C D}
{H I : BraidedMonoidalFunctor D E} →
H ≃ I → F ≃ G → (H ∘Fˡ F) ≃ (I ∘Fˡ G)
-- NOTE: this definition is clearly equivalent to
--
-- α ⓘₕ β = ⌈ ⌊ α ⌋ U.ⓘₕ ⌊ β ⌋ ⌉
--
-- but the latter takes an unreasonably long time to typecheck,
-- while the unfolded version typechecks almost immediately.
α ⓘₕ β = record
{ U = C.U
; F⇒G-isMonoidal = record
{ ε-compat = C.ε-compat
; ⊗-homo-compat = C.⊗-homo-compat }
}
where module C = U.MonoidalNaturalIsomorphism (⌊ α ⌋ U.ⓘₕ ⌊ β ⌋)
_ⓘˡ_ : {F G : BraidedMonoidalFunctor C D}
(H : BraidedMonoidalFunctor D E) → F ≃ G → (H ∘Fˡ F) ≃ (H ∘Fˡ G)
H ⓘˡ α = id {F = H} ⓘₕ α
_ⓘʳ_ : {G H : BraidedMonoidalFunctor D E} →
G ≃ H → (F : BraidedMonoidalFunctor C D) → (G ∘Fˡ F) ≃ (H ∘Fˡ F)
α ⓘʳ F = α ⓘₕ id {F = F}
-- Left and right unitors.
module _ {o ℓ e o′ ℓ′ e′}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′}
{F : BraidedMonoidalFunctor C D} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
unitorˡ : idFˡ D ∘Fˡ F ≃ F
unitorˡ = record
{ U = LU.U
; F⇒G-isMonoidal = record
{ ε-compat = LU.ε-compat
; ⊗-homo-compat = LU.⊗-homo-compat
}
}
where module LU = U.MonoidalNaturalIsomorphism (U.unitorˡ {F = MF F})
unitorʳ : F ∘Fˡ idFˡ C ≃ F
unitorʳ = record
{ U = RU.U
; F⇒G-isMonoidal = record
{ ε-compat = RU.ε-compat
; ⊗-homo-compat = RU.⊗-homo-compat
}
}
where module RU = U.MonoidalNaturalIsomorphism (U.unitorʳ {F = MF F})
-- Associator.
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴}
{B : BraidedMonoidalCategory o ℓ e}
{C : BraidedMonoidalCategory o′ ℓ′ e′}
{D : BraidedMonoidalCategory o″ ℓ″ e″}
{E : BraidedMonoidalCategory o‴ ℓ‴ e‴}
{F : BraidedMonoidalFunctor B C} {G : BraidedMonoidalFunctor C D}
{H : BraidedMonoidalFunctor D E} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
associator : (H ∘Fˡ G) ∘Fˡ F ≃ H ∘Fˡ (G ∘Fˡ F)
associator = record
{ U = AU.U
; F⇒G-isMonoidal = record
{ ε-compat = AU.ε-compat
; ⊗-homo-compat = AU.⊗-homo-compat
}
}
where
module AU =
U.MonoidalNaturalIsomorphism (U.associator {F = MF F} {MF G} {MF H})
module Strong where
open BMF.Strong using (BraidedMonoidalFunctor)
open MNI.Strong using (IsMonoidalNaturalIsomorphism)
open BraidedMonoidalFunctor using () renaming
( F to UF
; monoidalFunctor to MF
; laxBraidedMonoidalFunctor to laxBMF
)
private module U = MNI.Strong
module _ {o ℓ e o′ ℓ′ e′}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′} where
-- Monoidal natural isomorphisms between strong braided monoidal functors.
record BraidedMonoidalNaturalIsomorphism
(F G : BraidedMonoidalFunctor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
field
U : NaturalIsomorphism (UF F) (UF G)
F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism (MF F) (MF G) U
⌊_⌋ : U.MonoidalNaturalIsomorphism (MF F) (MF G)
⌊_⌋ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
laxBNI : Lax.BraidedMonoidalNaturalIsomorphism (laxBMF F) (laxBMF G)
laxBNI = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
open Lax.BraidedMonoidalNaturalIsomorphism laxBNI public
hiding (U; F⇒G-isMonoidal; ⌊_⌋)
infix 4 _≃_
_≃_ = BraidedMonoidalNaturalIsomorphism
-- "Strengthening"
⌈_⌉ : {F G : BraidedMonoidalFunctor C D} →
U.MonoidalNaturalIsomorphism (MF F) (MF G) → F ≃ G
⌈ α ⌉ = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal }
where open U.MonoidalNaturalIsomorphism α
open BraidedMonoidalNaturalIsomorphism
-- Identity and compositions
infixr 9 _ⓘᵥ_
id : {F : BraidedMonoidalFunctor C D} → F ≃ F
id = ⌈ U.id ⌉
_ⓘᵥ_ : {F G H : BraidedMonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H
α ⓘᵥ β = ⌈ ⌊ α ⌋ U.ⓘᵥ ⌊ β ⌋ ⌉
isEquivalence : IsEquivalence _≃_
isEquivalence = record
{ refl = id
; sym = λ α → record
{ U = NI.sym (U α)
; F⇒G-isMonoidal = F⇐G-isMonoidal α
}
; trans = λ α β → β ⓘᵥ α
}
where
open BraidedMonoidalNaturalIsomorphism
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′}
{E : BraidedMonoidalCategory o″ ℓ″ e″} where
infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_
_ⓘₕ_ : {F G : BraidedMonoidalFunctor C D}
{H I : BraidedMonoidalFunctor D E} →
H ≃ I → F ≃ G → (H ∘Fˢ F) ≃ (I ∘Fˢ G)
-- NOTE: this definition is clearly equivalent to
--
-- α ⓘₕ β = ⌈ ⌊ α ⌋ U.ⓘₕ ⌊ β ⌋ ⌉
--
-- but the latter takes an unreasonably long time to typecheck,
-- while the unfolded version typechecks almost immediately.
α ⓘₕ β = record
{ U = C.U
; F⇒G-isMonoidal = record
{ ε-compat = C.ε-compat
; ⊗-homo-compat = C.⊗-homo-compat }
}
where module C = U.MonoidalNaturalIsomorphism (⌊ α ⌋ U.ⓘₕ ⌊ β ⌋)
_ⓘˡ_ : {F G : BraidedMonoidalFunctor C D}
(H : BraidedMonoidalFunctor D E) → F ≃ G → (H ∘Fˢ F) ≃ (H ∘Fˢ G)
H ⓘˡ α = id {F = H} ⓘₕ α
_ⓘʳ_ : {G H : BraidedMonoidalFunctor D E} →
G ≃ H → (F : BraidedMonoidalFunctor C D) → (G ∘Fˢ F) ≃ (H ∘Fˢ F)
α ⓘʳ F = α ⓘₕ id {F = F}
-- Left and right unitors.
module _ {o ℓ e o′ ℓ′ e′}
{C : BraidedMonoidalCategory o ℓ e}
{D : BraidedMonoidalCategory o′ ℓ′ e′}
{F : BraidedMonoidalFunctor C D} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
unitorˡ : idFˢ D ∘Fˢ F ≃ F
unitorˡ = record
{ U = LU.U
; F⇒G-isMonoidal = record
{ ε-compat = LU.ε-compat
; ⊗-homo-compat = LU.⊗-homo-compat
}
}
where module LU = U.MonoidalNaturalIsomorphism (U.unitorˡ {F = MF F})
unitorʳ : F ∘Fˢ idFˢ C ≃ F
unitorʳ = record
{ U = RU.U
; F⇒G-isMonoidal = record
{ ε-compat = RU.ε-compat
; ⊗-homo-compat = RU.⊗-homo-compat
}
}
where module RU = U.MonoidalNaturalIsomorphism (U.unitorʳ {F = MF F})
-- Associator.
module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴}
{B : BraidedMonoidalCategory o ℓ e}
{C : BraidedMonoidalCategory o′ ℓ′ e′}
{D : BraidedMonoidalCategory o″ ℓ″ e″}
{E : BraidedMonoidalCategory o‴ ℓ‴ e‴}
{F : BraidedMonoidalFunctor B C} {G : BraidedMonoidalFunctor C D}
{H : BraidedMonoidalFunctor D E} where
-- NOTE: Again, manual expansion seems necessary to type check in
-- reasonable time.
associator : (H ∘Fˢ G) ∘Fˢ F ≃ H ∘Fˢ (G ∘Fˢ F)
associator = record
{ U = AU.U
; F⇒G-isMonoidal = record
{ ε-compat = AU.ε-compat
; ⊗-homo-compat = AU.⊗-homo-compat
}
}
where
module AU =
U.MonoidalNaturalIsomorphism (U.associator {F = MF F} {MF G} {MF H})
| 32.577039
| 80
| 0.58008
|
c5856fe59e30c160bdfd614aa8657a2145049de3
| 2,656
|
agda
|
Agda
|
src/SecondOrder/VRelMonMorphism.agda
|
cilinder/formaltt
|
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
|
[
"MIT"
] | 21
|
2021-02-16T14:07:06.000Z
|
2021-11-19T15:50:08.000Z
|
src/SecondOrder/VRelMonMorphism.agda
|
cilinder/formaltt
|
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
|
[
"MIT"
] | 1
|
2021-04-30T14:18:25.000Z
|
2021-05-14T16:15:17.000Z
|
src/SecondOrder/VRelMonMorphism.agda
|
cilinder/formaltt
|
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
|
[
"MIT"
] | 6
|
2021-02-16T13:43:07.000Z
|
2021-05-24T02:51:43.000Z
|
open import Agda.Primitive using (lzero; lsuc; _⊔_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst; setoid)
open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap)
import Function.Equality
open import Relation.Binary using (Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
import Categories.Category
import Categories.Functor
import Categories.Category.Instance.Setoids
import Categories.Monad.Relative
import Categories.Category.Equivalence
import Categories.Category.Cocartesian
import Categories.Category.Construction.Functors
import Categories.Category.Product
import Categories.NaturalTransformation
import Categories.NaturalTransformation.NaturalIsomorphism
import SecondOrder.Arity
import SecondOrder.Signature
import SecondOrder.Metavariable
import SecondOrder.VRenaming
import SecondOrder.MRenaming
import SecondOrder.Term
import SecondOrder.Substitution
import SecondOrder.RelativeMonadMorphism
import SecondOrder.Instantiation
import SecondOrder.IndexedCategory
import SecondOrder.RelativeKleisli
import SecondOrder.Mslot
import SecondOrder.MRelativeMonad
import SecondOrder.VRelativeMonad
module SecondOrder.VRelMonMorphism
{ℓ}
{𝔸 : SecondOrder.Arity.Arity}
(Σ : SecondOrder.Signature.Signature ℓ 𝔸)
where
open SecondOrder.RelativeMonadMorphism
open SecondOrder.Metavariable Σ
open SecondOrder.VRelativeMonad Σ
open SecondOrder.Instantiation Σ
open SecondOrder.MRenaming Σ
open SecondOrder.VRenaming Σ
open SecondOrder.Term Σ
open SecondOrder.Substitution Σ
-- In this file, the goal is to show that given two variable relative monads
-- on different metacontexts, metarenaming from one of the metacontexts to the other
-- we can define a relative monad morphism between the two variable relative monads
Fⱽ : ∀ (Θ Θ′ : MContext) (μ : Θ ⇒ᵐ Θ′) → RMonadMorph (VMonad {Θ}) (VMonad {Θ′})
Fⱽ Θ Θ′ μ = record
{ morph = λ A →
record
{ _⟨$⟩_ = [ μ ]ᵐ_
; cong = λ s≈t → []ᵐ-resp-≈ s≈t
}
; law-unit = λ A x≡y → ≈-≡ (σ-resp-≡ {σ = tm-var} x≡y)
; law-extend = λ {Γ} {Δ} {k} A {s} {t} s≈t →
≈-trans
(≈-sym ([ᵐ∘ˢ] s))
(≈-trans
([]ˢ-resp-≈ˢ ([ μ ]ᵐ s) λ x → ≈-refl )
([]ˢ-resp-≈ (λ {B} x → [ μ ]ᵐ (k B Function.Equality.⟨$⟩ x)) ([]ᵐ-resp-≈ s≈t)))
}
| 38.492754
| 126
| 0.649849
|
dc05e6fd4b05274954c479ced93162f8b2818054
| 2,262
|
agda
|
Agda
|
examples/AIM6/Path/Span.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/AIM6/Path/Span.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/AIM6/Path/Span.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Span where
open import Prelude
open import Star
open import Modal
data SpanView {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool) :
EdgePred (Star R) where
oneFalse : {a b c d : A}(xs : Star R a b)(pxs : All (\x -> IsTrue (p x)) xs)
(x : R b c)(¬px : IsFalse (p x))(ys : Star R c d) ->
SpanView p (xs ++ x • ys)
allTrue : {a b : A}{xs : Star R a b}(ts : All (\x -> IsTrue (p x)) xs) ->
SpanView p xs
span : {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool){a b : A}
(xs : Star R a b) -> SpanView p xs
span p ε = allTrue ε
span p (x • xs) with inspect (p x)
span p (x • xs) | itsFalse ¬px = oneFalse ε ε x ¬px xs
span p (x • xs) | itsTrue px with span p xs
span p (x • .(xs ++ y • ys)) | itsTrue px
| oneFalse xs pxs y ¬py ys =
oneFalse (x • xs) (check px • pxs) y ¬py ys
span p (x • xs) | itsTrue px | allTrue pxs =
allTrue (check px • pxs)
_│_ : {A : Set}(R : Rel A)(P : EdgePred R) -> Rel A
(R │ P) a b = Σ (R a b) P
forget : {A : Set}{R : Rel A}{P : EdgePred R} -> Star (R │ P) =[ id ]=> Star R
forget = map id fst
data SpanView' {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool) :
EdgePred (Star R) where
oneFalse' : {a b c d : A}(xs : Star (R │ \{a b} x -> IsTrue (p x)) a b)
(x : R b c)(¬px : IsFalse (p x))(ys : Star R c d) ->
SpanView' p (forget xs ++ x • ys)
allTrue' : {a b : A}(xs : Star (R │ \{a b} x -> IsTrue (p x)) a b) ->
SpanView' p (forget xs)
span' : {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool){a b : A}
(xs : Star R a b) -> SpanView' p xs
span' p ε = allTrue' ε
span' p (x • xs) with inspect (p x)
span' p (x • xs) | itsFalse ¬px = oneFalse' ε x ¬px xs
span' p (x • xs) | itsTrue px with span' p xs
span' p (x • .(forget xs ++ y • ys)) | itsTrue px
| oneFalse' xs y ¬py ys = oneFalse' ((x ,, px) • xs) y ¬py ys
span' p (x • .(forget xs)) | itsTrue px
| allTrue' xs = allTrue' ((x ,, px) • xs)
-- Can't seem to define it as 'map Some.a (\x -> (_ ,, uncheck x))'
all│ : {A : Set}{R : Rel A}{P : EdgePred R}{a b : A}{xs : Star R a b} ->
All P xs -> Star (R │ P) a b
all│ (check p • pxs) = (_ ,, p) • all│ pxs
all│ ε = ε
| 39
| 78
| 0.486737
|
c5fe48d8d2c76906974f390c40b8e666838025bb
| 593
|
agda
|
Agda
|
test/fail/Issue512.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/Issue512.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue512.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module Issue512 where
postulate
Level : Set
{-# BUILTIN LEVEL Level #-}
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
{-# BUILTIN REFL refl #-}
data A : Set where
a b : A
proof : a ≡ a
proof = refl
f : A → A → A
f x y rewrite proof = ? -- gave error below (now complains about LEVELZERO instead of STRING)
{-
{-
No binding for builtin thing STRING, use {-# BUILTIN STRING name
#-} to bind it to 'name'
when checking that the type of the generated with function
(w : A) → _≡_ {"Max []"} {A} w w → (x y : A) → A is well-formed
-}
-}
| 18.53125
| 93
| 0.607083
|
4ae5066f215b86f79ea967bd0ee01c6a391ebb3d
| 8,225
|
agda
|
Agda
|
complexity-drafts/Preliminaries.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 2
|
2016-04-26T20:22:22.000Z
|
2019-08-08T12:27:18.000Z
|
complexity-drafts/Preliminaries.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 1
|
2020-03-23T08:39:04.000Z
|
2020-05-12T00:32:45.000Z
|
complexity-drafts/Preliminaries.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | null | null | null |
module Preliminaries where
open import Agda.Primitive using (Level) renaming (lzero to lZ; lsuc to lS; _⊔_ to lmax)
-- ----------------------------------------------------------------------
-- functions
_o_ : {A B C : Set} → (B → C) → (A → B) → A → C
g o f = \ x → g (f x)
infixr 10 _o_
-- ----------------------------------------------------------------------
-- identity type
data _==_ {l : Level} {A : Set l} (M : A) : A → Set l where
Refl : M == M
Id : {l : Level} {A : Set l} (M : A) → A → Set l
Id M N = M == N
{-# BUILTIN EQUALITY _==_ #-}
{-# BUILTIN REFL Refl #-}
transport : {l1 : Level} {l2 : Level} {A : Set l1} (B : A → Set l2)
{a1 a2 : A} → a1 == a2 → (B a1 → B a2)
transport B Refl = λ x → x
! : {l : Level} {A : Set l} {M N : A} → M == N → N == M
! Refl = Refl
_∘_ : {l : Level} {A : Set l} {M N P : A}
→ N == P → M == N → M == P
β ∘ Refl = β
ap : {l1 l2 : Level} {A : Set l1} {B : Set l2} {M N : A}
(f : A → B) → M == N → (f M) == (f N)
ap f Refl = Refl
ap2 : {l1 l2 l3 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {M N : A} {M' N' : B} (f : A -> B -> C) -> M == N -> M' == N' -> (f M M') == (f N N')
ap2 f Refl Refl = Refl
ap3 : {l1 l2 l3 l4 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} {M N : A} {M' N' : B} {M'' N'' : C}
(f : A → B → C → D) → M == N → M' == N' → M'' == N'' → (f M M' M'') == (f N N' N'')
ap3 f Refl Refl Refl = Refl
postulate
-- function extensionality
λ= : {l1 l2 : Level} {A : Set l1} {B : A -> Set l2} {f g : (x : A) -> B x} -> ((x : A) -> (f x) == (g x)) -> f == g
-- function extensionality for implicit functions
λ=i : {l1 l2 : Level} {A : Set l1} {B : A -> Set l2} {f g : {x : A} -> B x} -> ((x : A) -> (f {x}) == (g {x})) -> _==_ {_}{ {x : A} → B x } f g
private primitive primTrustMe : {l : Level} {A : Set l} {x y : A} -> x == y
infixr 9 _==_
infix 2 _∎
infixr 2 _=⟨_⟩_
_=⟨_⟩_ : {l : Level} {A : Set l} (x : A) {y z : A} → x == y → y == z → x == z
_ =⟨ p1 ⟩ p2 = (p2 ∘ p1)
_∎ : {l : Level} {A : Set l} (x : A) → x == x
_∎ _ = Refl
-- ----------------------------------------------------------------------
-- product types
record Unit : Set where
constructor <>
record Σ {l1 l2 : Level} {A : Set l1} (B : A -> Set l2) : Set (lmax l1 l2) where
constructor _,_
field
fst : A
snd : B fst
open Σ public
infixr 0 _,_
_×_ : {l1 l2 : Level} → Set l1 -> Set l2 -> Set (lmax l1 l2)
A × B = Σ (\ (_ : A) -> B)
infixr 10 _×_
-- ----------------------------------------------------------------------
-- booleans
data Bool : Set where
True : Bool
False : Bool
{-# COMPILED_DATA Bool Bool True False #-}
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE True #-}
{-# BUILTIN FALSE False #-}
-- ----------------------------------------------------------------------
-- order
data Order : Set where
Less : Order
Equal : Order
Greater : Order
-- ----------------------------------------------------------------------
-- sums
data Void : Set where
abort : {A : Set} → Void → A
abort ()
data Either (A B : Set) : Set where
Inl : A → Either A B
Inr : B → Either A B
DecEq : Set → Set
DecEq A = (x y : A) → Either (x == y) (x == y → Void)
-- ----------------------------------------------------------------------
-- natural numbers
module Nat where
data Nat : Set where
Z : Nat
S : Nat -> Nat
-- let's you use numerals for Nat
{-# BUILTIN NATURAL Nat #-}
_+_ : Nat → Nat → Nat
Z + n = n
(S m) + n = S (m + n)
max : Nat → Nat → Nat
max Z n = n
max m Z = m
max (S m) (S n) = S (max m n)
equal : Nat → Nat → Bool
equal Z Z = True
equal Z (S _) = False
equal (S _) Z = False
equal (S m) (S n) = equal m n
compare : Nat → Nat → Order
compare Z Z = Equal
compare Z (S m) = Less
compare (S n) Z = Greater
compare (S n) (S m) = compare n m
open Nat public using (Nat ; Z ; S)
-- ----------------------------------------------------------------------
-- monad
module Monad where
record Monad : Set1 where
field
T : Set → Set
return : ∀ {A} → A → T A
_>>=_ : ∀ {A B} → T A → (A → T B) -> T B
-- ----------------------------------------------------------------------
-- options
module Maybe where
data Maybe {l : Level} (A : Set l) : Set l where
Some : A → Maybe A
None : Maybe A
Monad : Monad.Monad
Monad = record { T = Maybe; return = Some; _>>=_ = (λ {None _ → None; (Some v) f → f v}) }
open Maybe public using (Maybe;Some;None)
-- ----------------------------------------------------------------------
-- lists
module List where
data List {l : Level} (A : Set l) : Set l where
[] : List A
_::_ : A -> List A -> List A
{-# COMPILED_DATA List [] [] (:) #-}
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _::_ #-}
infixr 99 _::_
_++_ : {A : Set} → List A → List A → List A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
infixr 10 _++_
map : {l1 l2 : Level} {A : Set l1} {B : Set l2} → (A → B) → List A → List B
map f [] = []
map f (x :: xs) = f x :: map f xs
map-id : {l : Level} {A : Set l} (l : List A) → map (\ (x : A) → x) l == l
map-id [] = Refl
map-id (x :: l) with map (\ x -> x) l | map-id l
... | ._ | Refl = Refl
++-assoc : ∀ {A} (l1 l2 l3 : List A) → (l1 ++ l2) ++ l3 == l1 ++ (l2 ++ l3)
++-assoc [] l2 l3 = Refl
++-assoc (x :: xs) l2 l3 = ap (_::_ x) (++-assoc xs l2 l3)
open List public using (List ; [] ; _::_)
-- ----------------------------------------------------------------------
-- characters
module Char where
postulate {- Agda Primitive -}
Char : Set
{-# BUILTIN CHAR Char #-}
{-# COMPILED_TYPE Char Char #-}
private
primitive
primCharToNat : Char → Nat
primCharEquality : Char → Char → Bool
toNat : Char → Nat
toNat = primCharToNat
equalb : Char -> Char -> Bool
equalb = primCharEquality
-- need to go outside the real language a little to give the primitives good types,
-- but from the outside this should be safe
equal : DecEq Char
equal x y with equalb x y
... | True = Inl primTrustMe
... | False = Inr canthappen where
postulate canthappen : _
open Char public using (Char)
-- ----------------------------------------------------------------------
-- vectors
module Vector where
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_::_ : ∀ {n} → A → Vec A n → Vec A (S n)
infixr 99 _::_
Vec-elim : {A : Set} (P : {n : Nat} → Vec A n → Set)
→ (P [])
→ ({n : Nat} (x : A) (xs : Vec A n) → P xs → P (x :: xs))
→ {n : Nat} (v : Vec A n) → P v
Vec-elim P n c [] = n
Vec-elim P n c (y :: ys) = c y ys (Vec-elim P n c ys)
fromList : {A : Set} → List A → Σ \n → Vec A n
fromList [] = _ , []
fromList (x :: xs) = _ , x :: snd (fromList xs)
toList : {A : Set} {n : Nat} → Vec A n → List A
toList [] = []
toList (x :: xs) = x :: (toList xs)
toList' : {A : Set} → (Σ \ n → Vec A n) → List A
toList' (._ , []) = []
toList' (._ , (x :: xs)) = x :: (toList' (_ , xs))
-- ----------------------------------------------------------------------
-- strings
module String where
postulate {- Agda Primitive -}
String : Set
{-# BUILTIN STRING String #-}
{-# COMPILED_TYPE String String #-}
private
primitive
primStringToList : String -> List Char
primStringFromList : List Char -> String
primStringAppend : String -> String -> String
primStringEquality : String -> String -> Bool
equal : String -> String -> Bool
equal = primStringEquality
toList = primStringToList
fromList = primStringFromList
append = primStringAppend
toVec : String -> Σ \ m → Vector.Vec Char m
toVec = Vector.fromList o toList
| 26.446945
| 151
| 0.42079
|
dc864e727832d05fa81fcda58808b3c5350429c8
| 3,313
|
agda
|
Agda
|
vendor/stdlib/src/Relation/Binary/Consequences.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Relation/Binary/Consequences.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Relation/Binary/Consequences.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Some properties imply others
------------------------------------------------------------------------
module Relation.Binary.Consequences where
open import Relation.Binary.Core hiding (refl)
open import Relation.Nullary.Core
open import Relation.Binary.PropositionalEquality.Core
open import Data.Function
open import Data.Sum
open import Data.Product
open import Data.Empty
-- Some of the definitions can be found in the following module:
open import Relation.Binary.Consequences.Core public
trans∧irr⟶asym :
∀ {a} → {≈ < : Rel a} →
Reflexive ≈ →
Transitive < → Irreflexive ≈ < → Asymmetric <
trans∧irr⟶asym refl trans irrefl = λ x<y y<x →
irrefl refl (trans x<y y<x)
irr∧antisym⟶asym :
∀ {a} → {≈ < : Rel a} →
Irreflexive ≈ < → Antisymmetric ≈ < → Asymmetric <
irr∧antisym⟶asym irrefl antisym = λ x<y y<x →
irrefl (antisym x<y y<x) x<y
asym⟶antisym :
∀ {a} → {≈ < : Rel a} →
Asymmetric < → Antisymmetric ≈ <
asym⟶antisym asym x<y y<x = ⊥-elim (asym x<y y<x)
asym⟶irr :
∀ {a} → {≈ < : Rel a} →
< Respects₂ ≈ → Symmetric ≈ →
Asymmetric < → Irreflexive ≈ <
asym⟶irr {< = _<_} resp sym asym {x} {y} x≈y x<y = asym x<y y<x
where
y<y : y < y
y<y = proj₂ resp x≈y x<y
y<x : y < x
y<x = proj₁ resp (sym x≈y) y<y
total⟶refl :
∀ {a} → {≈ ∼ : Rel a} →
∼ Respects₂ ≈ → Symmetric ≈ →
Total ∼ → ≈ ⇒ ∼
total⟶refl {≈ = ≈} {∼ = ∼} resp sym total = refl
where
refl : ≈ ⇒ ∼
refl {x} {y} x≈y with total x y
... | inj₁ x∼y = x∼y
... | inj₂ y∼x =
proj₁ resp x≈y (proj₂ resp (sym x≈y) y∼x)
total+dec⟶dec :
∀ {a} → {≈ ≤ : Rel a} →
≈ ⇒ ≤ → Antisymmetric ≈ ≤ →
Total ≤ → Decidable ≈ → Decidable ≤
total+dec⟶dec {≈ = ≈} {≤ = ≤} refl antisym total _≟_ = dec
where
dec : Decidable ≤
dec x y with total x y
... | inj₁ x≤y = yes x≤y
... | inj₂ y≤x with x ≟ y
... | yes x≈y = yes (refl x≈y)
... | no ¬x≈y = no (λ x≤y → ¬x≈y (antisym x≤y y≤x))
tri⟶asym :
∀ {a} → {≈ < : Rel a} →
Trichotomous ≈ < → Asymmetric <
tri⟶asym tri {x} {y} x<y x>y with tri x y
... | tri< _ _ x≯y = x≯y x>y
... | tri≈ _ _ x≯y = x≯y x>y
... | tri> x≮y _ _ = x≮y x<y
tri⟶irr :
∀ {a} → {≈ < : Rel a} →
< Respects₂ ≈ → Symmetric ≈ →
Trichotomous ≈ < → Irreflexive ≈ <
tri⟶irr resp sym tri = asym⟶irr resp sym (tri⟶asym tri)
tri⟶dec≈ :
∀ {a} → {≈ < : Rel a} →
Trichotomous ≈ < → Decidable ≈
tri⟶dec≈ compare x y with compare x y
... | tri< _ x≉y _ = no x≉y
... | tri≈ _ x≈y _ = yes x≈y
... | tri> _ x≉y _ = no x≉y
tri⟶dec< :
∀ {a} → {≈ < : Rel a} →
Trichotomous ≈ < → Decidable <
tri⟶dec< compare x y with compare x y
... | tri< x<y _ _ = yes x<y
... | tri≈ x≮y _ _ = no x≮y
... | tri> x≮y _ _ = no x≮y
subst⟶cong :
{≈ : ∀ {a} → Rel a} →
(∀ {a} → Reflexive {a} ≈) →
(∀ {a} → Substitutive {a} ≈) →
Congruential ≈
subst⟶cong {≈ = _≈_} refl subst f {x} x≈y =
subst (λ y → f x ≈ f y) x≈y refl
cong+trans⟶cong₂ :
{≈ : ∀ {a} → Rel a} →
Congruential ≈ → (∀ {a} → Transitive {a} ≈) →
Congruential₂ ≈
cong+trans⟶cong₂ cong trans f {x = x} {v = v} x≈y u≈v =
cong (f x) u≈v ⟨ trans ⟩ cong (flip f v) x≈y
map-NonEmpty : ∀ {I} {P Q : Rel I} →
P ⇒ Q → NonEmpty P → NonEmpty Q
map-NonEmpty f x = nonEmpty (f (NonEmpty.proof x))
| 27.380165
| 72
| 0.520374
|
1c6b9cd31933ad90cfa35ba7259e104213e20d1c
| 2,721
|
agda
|
Agda
|
lemmas-consistency.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
lemmas-consistency.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
lemmas-consistency.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
open import Prelude
open import dynamics-core
module lemmas-consistency where
-- type consistency is symmetric
~sym : {t1 t2 : htyp} → t1 ~ t2 → t2 ~ t1
~sym TCRefl = TCRefl
~sym TCHole1 = TCHole2
~sym TCHole2 = TCHole1
~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2)
~sym (TCSum p1 p2) = TCSum (~sym p1) (~sym p2)
~sym (TCProd p1 p2) = TCProd (~sym p1) (~sym p2)
-- type consistency isn't transitive
not-trans : ((t1 t2 t3 : htyp) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥
not-trans t with t (num ==> num) ⦇-⦈ num TCHole1 TCHole2
... | ()
-- every pair of types is either consistent or not consistent
~dec : (t1 t2 : htyp) → ((t1 ~ t2) + (t1 ~̸ t2))
-- this takes care of all hole cases, so we don't consider them below
~dec _ ⦇-⦈ = Inl TCHole1
~dec ⦇-⦈ _ = Inl TCHole2
~dec num num = Inl TCRefl
~dec num (t2 ==> t3) = Inr (λ ())
~dec num (t2 ⊕ t3) = Inr (λ ())
~dec (t1 ==> t3) num = Inr (λ ())
~dec (t1 ==> t3) (t2 ==> t4)
with ~dec t1 t2 | ~dec t3 t4
... | Inl x | Inl x₁ = Inl (TCArr x x₁)
... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCArr x₂ x₃) → x₁ x₃}
... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCArr x₁ x₂) → x x₁}
~dec (t1 ==> t3) (t2 ⊕ t4) = Inr (λ ())
~dec (t1 ⊕ t3) num = Inr (λ ())
~dec (t1 ⊕ t3) (t2 ==> t4) = Inr (λ ())
~dec (t1 ⊕ t3) (t2 ⊕ t4)
with ~dec t1 t2 | ~dec t3 t4
... | Inl x | Inl x₁ = Inl (TCSum x x₁)
... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCSum x₂ x₃) → x₁ x₃}
... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCSum x₁ x₂) → x x₁}
~dec num (t2 ⊠ t4) = Inr (λ ())
~dec (t1 ==> t3) (t2 ⊠ t4) = Inr (λ ())
~dec (t1 ⊕ t3) (t2 ⊠ t4) = Inr (λ ())
~dec (t1 ⊠ t3) num = Inr (λ ())
~dec (t1 ⊠ t3) (t2 ==> t4) = Inr (λ ())
~dec (t1 ⊠ t3) (t2 ⊕ t4) = Inr (λ ())
~dec (t1 ⊠ t3) (t2 ⊠ t4)
with ~dec t1 t2 | ~dec t3 t4
... | Inl x | Inl x₁ = Inl (TCProd x x₁)
... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCProd x₂ x₃) → x₁ x₃}
... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCProd x₁ x₂) → x x₁}
-- if arrows are consistent, their components are consistent
~arr : ∀{τ1 τ2 τ3 τ4} →
(τ1 ==> τ2) ~ (τ3 ==> τ4) →
(τ1 ~ τ3) × (τ2 ~ τ4)
~arr TCRefl = TCRefl , TCRefl
~arr (TCArr con con₁) = con , con₁
-- if sums are consistent, their components are consistent
~sum : ∀{τ1 τ2 τ3 τ4} →
(τ1 ⊕ τ2) ~ (τ3 ⊕ τ4) →
(τ1 ~ τ3) × (τ2 ~ τ4)
~sum TCRefl = TCRefl , TCRefl
~sum (TCSum con con₁) = con , con₁
-- if products are consistent, their components are consistent
~prod : ∀{τ1 τ2 τ3 τ4} →
(τ1 ⊠ τ2) ~ (τ3 ⊠ τ4) →
(τ1 ~ τ3) × (τ2 ~ τ4)
~prod TCRefl = TCRefl , TCRefl
~prod (TCProd con con₁) = con , con₁
| 37.273973
| 76
| 0.519294
|
df81469c4ebaf5ff47d733345f6b7d09f7d03506
| 3,862
|
agda
|
Agda
|
examples/examplesPaperJFP/BasicIO.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
examples/examplesPaperJFP/BasicIO.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
examples/examplesPaperJFP/BasicIO.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module examplesPaperJFP.BasicIO where
open import Data.Maybe hiding ( _>>=_ )
open import Data.Sum renaming (inj₁ to left; inj₂ to right; [_,_]′ to either)
open import Function
open import examplesPaperJFP.NativeIOSafe
open import examplesPaperJFP.triangleRightOperator
module _ where -- for indentation
record IOInterface : Set₁ where
field Command : Set
Response : (c : Command) → Set
open IOInterface public
module _ {C : Set} {R : C → Set} (let
I = record { Command = C; Response = R }
) where
module Postulated {I : IOInterface} (let C = Command I) (let R = Response I) where
postulate
IO : (I : IOInterface) (A : Set) → Set
exec : ∀{A} (c : C) (f : R c → IO I A) → IO I A
return : ∀{A} (a : A) → IO I A
_>>=_ : ∀{A B} (m : IO I A) (k : A → IO I B) → IO I B
mutual
record IO I A : Set where
coinductive
constructor delay
field force : IO′ I A
data IO′ I A : Set where
exec′ : (c : Command I) (f : Response I c → IO I A) → IO′ I A
return′ : (a : A) → IO′ I A
open IO public
delay′ : ∀{I A} → IO′ I A → IO I A
force (delay′ x) = x
module _ {I : IOInterface} (let C = Command I) (let R = Response I) where
-- module _ {I : IOInterface} (let record { Command = C; Response = R } = I) where
-- module _ {I : IOInterface} (let ioInterface C R = I) where
exec : ∀{A} (c : C) (f : R c → IO I A) → IO I A
force (exec c f) = exec′ c f
return : ∀{A} (a : A) → IO I A
force (return a) = return′ a
infixl 2 _>>=_
_>>=_ : ∀{A B} (m : IO I A) (k : A → IO I B) → IO I B
force (m >>= k) with force m
... | exec′ c f = exec′ c λ x → f x >>= k
... | return′ a = force (k a)
module _ {I : IOInterface} (let C = Command I) (let R = Response I)
where
{-# NON_TERMINATING #-}
translateIO : ∀ {A} (tr : (c : C) → NativeIO (R c)) → IO I A → NativeIO A
translateIO tr m = force m ▹ λ
{ (exec′ c f) → (tr c) native>>= λ r → translateIO tr (f r)
; (return′ a) → nativeReturn a
}
-- Recursion
-- trampoline provides a generic form of loop (generalizing while/repeat).
-- Starting at state s : S, step function f is iterated until it returns
-- a result in A.
module _ (I : IOInterface)(let C = Command I) (let R = Response I)
where
data IO+ (A : Set) : Set where
exec′ : (c : C) (f : R c → IO I A) → IO+ A
module _ {I : IOInterface}(let C = Command I) (let R = Response I)
where
fromIO+′ : ∀{A} → IO+ I A → IO′ I A
fromIO+′ (exec′ c f) = exec′ c f
fromIO+ : ∀{A} → IO+ I A → IO I A
force (fromIO+ (exec′ c f)) = exec′ c f
_>>=+′_ : ∀{A B} (m : IO+ I A) (k : A → IO I B) → IO′ I B
exec′ c f >>=+′ k = exec′ c λ x → f x >>= k
_>>=+_ : ∀{A B} (m : IO+ I A) (k : A → IO I B) → IO I B
force (m >>=+ k) = m >>=+′ k
mutual
_>>+_ : ∀{A B} (m : IO I (A ⊎ B)) (k : A → IO I B) → IO I B
force (m >>+ k) = force m >>+′ k
_>>+′_ : ∀{A B} (m : IO′ I (A ⊎ B)) (k : A → IO I B) → IO′ I B
exec′ c f >>+′ k = exec′ c λ x → f x >>+ k
return′ (left a) >>+′ k = force (k a)
return′ (right b) >>+′ k = return′ b
-- loop
{-# TERMINATING #-}
trampoline : ∀{A S} (f : S → IO+ I (S ⊎ A)) (s : S) → IO I A
force (trampoline f s) = case (f s) of
\ { (exec′ c k) → exec′ c λ r → k r >>+ trampoline f }
-- simple infinite loop
{-# TERMINATING #-}
forever : ∀{A B} → IO+ I A → IO I B
force (forever (exec′ c f)) = exec′ c λ r → f r >>= λ _ → forever (exec′ c f)
whenJust : {A : Set} → Maybe A → (A → IO I Unit) → IO I Unit
whenJust nothing k = return _
whenJust (just a) k = k a
main : NativeIO Unit
main = nativePutStrLn "Hello, world!"
| 30.171875
| 82
| 0.503884
|
39e3e950bcf0c59bb227ee8f23da272657f64490
| 245
|
agda
|
Agda
|
test/Fail/Issue5238.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue5238.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue5238.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
data ⊥ : Set where
postulate
T : Set
t0 : T
t1 : T
postulate
foo : ⊥ → t0 ≡ t1
{-# REWRITE foo #-}
test : t0 ≡ t1
test = refl
| 12.894737
| 41
| 0.628571
|
203aa9469741fbdf41b86000b9e5e81d000cef59
| 8,436
|
agda
|
Agda
|
theorems/homotopy/Cogroup.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/Cogroup.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/Cogroup.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.CoHSpace
module homotopy.Cogroup where
record CogroupStructure {i} (X : Ptd i) : Type i where
field
co-h-struct : CoHSpaceStructure X
⊙inv : X ⊙→ X
open CoHSpaceStructure co-h-struct public
inv : de⊙ X → de⊙ X
inv = fst ⊙inv
field
⊙inv-l : ⊙Wedge-rec ⊙inv (⊙idf X) ⊙∘ ⊙coμ ⊙∼ ⊙cst
⊙assoc : ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
⊙∼ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
{-
module _ {i j : ULevel} {X : Ptd i} (CGS : CogroupStructure X) where
open CogroupStructure CGS
private
lemma-inv : ⊙Wedge-rec (⊙Lift-fmap ⊙inv) (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j})
⊙∘ ⊙coμ
⊙∘ ⊙lower {j = j}
== ⊙cst
abstract
lemma-inv =
! (⊙λ= (⊙∘-assoc
(⊙Wedge-rec (⊙Lift-fmap ⊙inv) (⊙idf (⊙Lift {j = j} X)))
(⊙∨-fmap ⊙lift ⊙lift)
(⊙coμ ⊙∘ ⊙lower)))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (⊙λ= (⊙Wedge-rec-fmap (⊙Lift-fmap ⊙inv) (⊙idf _) ⊙lift ⊙lift))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (! (⊙λ= (⊙Wedge-rec-post∘ ⊙lift ⊙inv (⊙idf _))))
∙ ⊙λ= (⊙∘-assoc ⊙lift (⊙Wedge-rec ⊙inv (⊙idf X)) (⊙coμ ⊙∘ ⊙lower))
∙ ap ⊙Lift-fmap (⊙λ= ⊙inv-l)
private
⊙coμ' : ⊙Lift {j = j} X ⊙→ ⊙Lift {j = j} X ⊙∨ ⊙Lift {j = j} X
⊙coμ' = ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ ⊙∘ ⊙lower {j = j}
private
lemma-assoc' :
⊙–> (⊙∨-assoc (⊙Lift {j = j} X) (⊙Lift {j = j} X) (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ
== ⊙∨-fmap (⊙idf (⊙Lift {j = j} X)) ⊙coμ'
⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ
abstract
lemma-assoc' =
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙lift ⊙lift ⊙∘ ⊙coμ
=⟨ ! $ ap (⊙–> (⊙∨-assoc _ _ _) ⊙∘_) $ ⊙λ= $
⊙∘-assoc
(⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift X)))
(⊙∨-fmap ⊙lift ⊙lift)
⊙coμ ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ (⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift X)) ⊙∘ ⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙coμ
=⟨ ap (λ f → ⊙–> (⊙∨-assoc _ _ _ ) ⊙∘ f ⊙∘ ⊙coμ) $
! (⊙λ= $ ⊙∨-fmap-∘ ⊙coμ' ⊙lift (⊙idf (⊙Lift X)) ⊙lift)
∙ (⊙λ= $ ⊙∨-fmap-∘ (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ ⊙lift (⊙idf X)) ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ (⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X))
⊙∘ ⊙coμ
=⟨ ap (⊙–> (⊙∨-assoc _ _ _ ) ⊙∘_) $ ⊙λ= $
⊙∘-assoc
(⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
(⊙∨-fmap ⊙coμ (⊙idf X))
⊙coμ ⟩
⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X))
⊙∘ ⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $
⊙∘-assoc
(⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X)))
(⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
(⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
(⊙–> (⊙∨-assoc (⊙Lift X) (⊙Lift X) (⊙Lift X)) ⊙∘ ⊙∨-fmap (⊙∨-fmap ⊙lift ⊙lift) ⊙lift)
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) $
⊙λ= $ ⊙∨-assoc-nat ⊙lift ⊙lift ⊙lift ⟩
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift) ⊙∘ ⊙–> (⊙∨-assoc X X X))
⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift))
(⊙–> (⊙∨-assoc X X X))
(⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift) ⊙∘_) $ ⊙λ= ⊙assoc ⟩
⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $ ⊙∘-assoc
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift))
(⊙∨-fmap (⊙idf X) ⊙coμ)
⊙coμ ⟩
(⊙∨-fmap ⊙lift (⊙∨-fmap ⊙lift ⊙lift)
⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ)
⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) $
! (⊙λ= $ ⊙∨-fmap-∘ ⊙lift (⊙idf X) (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ)
∙ (⊙λ= $ ⊙∨-fmap-∘ (⊙idf (⊙Lift X)) ⊙lift ⊙coμ' ⊙lift) ⟩
(⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ' ⊙∘ ⊙∨-fmap ⊙lift ⊙lift) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ') (⊙∨-fmap ⊙lift ⊙lift) ⊙coμ ⟩
⊙∨-fmap (⊙idf (⊙Lift X)) ⊙coμ' ⊙∘ ⊙∨-fmap ⊙lift ⊙lift ⊙∘ ⊙coμ
=∎
private
lemma-assoc :
⊙–> (⊙∨-assoc (⊙Lift {j = j} X) (⊙Lift {j = j} X) (⊙Lift {j = j} X))
⊙∘ ⊙∨-fmap ⊙coμ' (⊙idf (⊙Lift {j = j} X)) ⊙∘ ⊙coμ'
== ⊙∨-fmap (⊙idf (⊙Lift {j = j} X)) ⊙coμ' ⊙∘ ⊙coμ'
abstract
lemma-assoc = ap (_⊙∘ ⊙lower) lemma-assoc'
Lift-cogroup-structure : CogroupStructure (⊙Lift {j = j} X)
Lift-cogroup-structure = record
{ co-h-struct = Lift-co-h-space-structure {j = j} co-h-struct
; ⊙inv = ⊙lift ⊙∘ ⊙inv ⊙∘ ⊙lower
; ⊙inv-l = ⊙app= lemma-inv
; ⊙assoc = ⊙app= lemma-assoc
}
-}
module _ {i j} {X : Ptd i} (cogroup-struct : CogroupStructure X) (Y : Ptd j) where
private
module CGS = CogroupStructure cogroup-struct
⊙coμ = CGS.⊙coμ
comp : (X ⊙→ Y) → (X ⊙→ Y) → (X ⊙→ Y)
comp f g = ⊙Wedge-rec f g ⊙∘ ⊙coμ
inv : (X ⊙→ Y) → (X ⊙→ Y)
inv = _⊙∘ CGS.⊙inv
abstract
unit-l : ∀ f → comp ⊙cst f == f
unit-l f =
⊙Wedge-rec ⊙cst f ⊙∘ ⊙coμ
=⟨ ap2 (λ f g → ⊙Wedge-rec f g ⊙∘ ⊙coμ) (! $ ⊙λ= (⊙∘-cst-r f)) (! $ ⊙λ= (⊙∘-unit-r f)) ⟩
⊙Wedge-rec (f ⊙∘ ⊙cst) (f ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) (! $ ⊙λ= $ ⊙Wedge-rec-post∘ f ⊙cst (⊙idf X)) ⟩
(f ⊙∘ ⊙Wedge-rec ⊙cst (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc f (⊙Wedge-rec ⊙cst (⊙idf X)) ⊙coμ ⟩
f ⊙∘ (⊙Wedge-rec ⊙cst (⊙idf X) ⊙∘ ⊙coμ)
=⟨ ap (f ⊙∘_) (⊙λ= CGS.⊙unit-l) ⟩
f ⊙∘ ⊙idf X
=⟨ ⊙λ= (⊙∘-unit-r f) ⟩
f
=∎
assoc : ∀ f g h → comp (comp f g) h == comp f (comp g h)
assoc f g h =
⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) h ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= (⊙∘-unit-r h) |in-ctx (λ h → ⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) h ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec (⊙Wedge-rec f g ⊙∘ ⊙coμ) (h ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= (⊙Wedge-rec-fmap (⊙Wedge-rec f g) h ⊙coμ (⊙idf X)) |in-ctx _⊙∘ ⊙coμ ⟩
(⊙Wedge-rec (⊙Wedge-rec f g) h ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec (⊙Wedge-rec f g) h) (⊙∨-fmap ⊙coμ (⊙idf X)) ⊙coμ ⟩
⊙Wedge-rec (⊙Wedge-rec f g) h ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙Wedge-rec-assoc f g h) |in-ctx _⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ ⟩
(⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙–> (⊙∨-assoc X X X)) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec f (⊙Wedge-rec g h)) (⊙–> (⊙∨-assoc X X X)) (⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙–> (⊙∨-assoc X X X) ⊙∘ ⊙∨-fmap ⊙coμ (⊙idf X) ⊙∘ ⊙coμ
=⟨ ⊙λ= CGS.⊙assoc |in-ctx ⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘_ ⟩
⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ ⊙∘ ⊙coμ
=⟨ ! $ ⊙λ= $ ⊙∘-assoc (⊙Wedge-rec f (⊙Wedge-rec g h)) (⊙∨-fmap (⊙idf X) ⊙coμ) ⊙coμ ⟩
(⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙∨-fmap (⊙idf X) ⊙coμ) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙Wedge-rec-fmap f (⊙Wedge-rec g h) (⊙idf X) ⊙coμ) |in-ctx _⊙∘ ⊙coμ ⟩
⊙Wedge-rec (f ⊙∘ ⊙idf X) (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ
=⟨ ⊙λ= (⊙∘-unit-r f) |in-ctx (λ f → ⊙Wedge-rec f (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ) ⟩
⊙Wedge-rec f (⊙Wedge-rec g h ⊙∘ ⊙coμ) ⊙∘ ⊙coμ
=∎
inv-l : ∀ f → comp (inv f) f == ⊙cst
inv-l f =
⊙Wedge-rec (f ⊙∘ CGS.⊙inv) f ⊙∘ ⊙coμ
=⟨ ap (λ g → ⊙Wedge-rec (f ⊙∘ CGS.⊙inv) g ⊙∘ ⊙coμ) (! $ ⊙λ= (⊙∘-unit-r f)) ⟩
⊙Wedge-rec (f ⊙∘ CGS.⊙inv) (f ⊙∘ ⊙idf X) ⊙∘ ⊙coμ
=⟨ ap (_⊙∘ ⊙coμ) (! $ ⊙λ= $ ⊙Wedge-rec-post∘ f CGS.⊙inv (⊙idf X)) ⟩
(f ⊙∘ ⊙Wedge-rec CGS.⊙inv (⊙idf X)) ⊙∘ ⊙coμ
=⟨ ⊙λ= $ ⊙∘-assoc f (⊙Wedge-rec CGS.⊙inv (⊙idf X)) ⊙coμ ⟩
f ⊙∘ (⊙Wedge-rec CGS.⊙inv (⊙idf X) ⊙∘ ⊙coμ)
=⟨ ap (f ⊙∘_) (⊙λ= CGS.⊙inv-l) ⟩
f ⊙∘ ⊙cst
=⟨ ⊙λ= (⊙∘-cst-r f) ⟩
⊙cst
=∎
cogroup⊙→-group-structure : GroupStructure (X ⊙→ Y)
cogroup⊙→-group-structure = record
{ ident = ⊙cst
; inv = inv
; comp = comp
; unit-l = unit-l
; assoc = assoc
; inv-l = inv-l
}
| 40.363636
| 116
| 0.411095
|
102791ab74cb8a13c7e30b0781353639f6bb5391
| 31,541
|
agda
|
Agda
|
Cubical/Homotopy/BlakersMassey.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:02.000Z
|
2022-02-05T01:25:02.000Z
|
Cubical/Homotopy/BlakersMassey.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/BlakersMassey.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-
A Cubical proof of Blakers-Massey Theorem (KANG Rongji, Oct. 2021)
Based on the previous type-theoretic proof described in
Kuen-Bang Hou (Favonia), Eric Finster, Dan Licata, Peter LeFanu Lumsdaine,
"A Mechanization of the Blakers–Massey Connectivity Theorem in Homotopy Type Theory"
(https://arxiv.org/abs/1605.03227)
Also the HoTT-Agda formalization by Favonia:
(https://github.com/HoTT/HoTT-Agda/blob/master/theorems/homotopy/BlakersMassey.agda)
Using cubes explicitly as much as possible.
-}
{-# OPTIONS --safe #-}
module Cubical.Homotopy.BlakersMassey where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.HITs.Truncation renaming (hLevelTrunc to Trunc)
open import Cubical.HITs.Pushout hiding (PushoutGenFib)
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.WedgeConnectivity
module BlakersMassey {ℓ₁ ℓ₂ ℓ₃ : Level}
(X : Type ℓ₁)(Y : Type ℓ₂)(Q : X → Y → Type ℓ₃)
{m : HLevel} (leftConn : (x : X) → isConnected (1 + m) (Σ[ y ∈ Y ] Q x y))
{n : HLevel} (rightConn : (y : Y) → isConnected (1 + n) (Σ[ x ∈ X ] Q x y))
where
ℓ : Level
ℓ = ℓ-max (ℓ-max ℓ₁ ℓ₂) ℓ₃
leftFiber : X → Type (ℓ-max ℓ₂ ℓ₃)
leftFiber x = Σ[ y ∈ Y ] Q x y
rightFiber : Y → Type (ℓ-max ℓ₁ ℓ₃)
rightFiber y = Σ[ x ∈ X ] Q x y
{- We use the alternative formulation of pushout with fewer parameters -}
PushoutQ = PushoutGen Q
{- Some preliminary definitions for convenience -}
fiberSquare :
{x₀ x₁ : X}{y₀ : Y}{p : PushoutQ}(q₀₀ : Q x₀ y₀)(q₁₀ : Q x₁ y₀)
→ inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
fiberSquare q₀₀ q₁₀ r' r = PathP (λ i → push q₀₀ (~ i) ≡ r' i) (sym (push q₁₀)) r
fiberSquarePush :
{x₀ x₁ : X}{y₀ y₁ : Y}(q₀₀ : Q x₀ y₀)(q₁₀ : Q x₁ y₀)(q₁₁ : Q x₁ y₁)
→ inl x₀ ≡ inr y₁ → Type ℓ
fiberSquarePush q₀₀ q₁₀ q₁₁ = fiberSquare q₀₀ q₁₀ (push q₁₁)
fiber' : {x₀ : X}{y₀ : Y}(q₀₀ : Q x₀ y₀){x₁ : X}{p : PushoutQ} → inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
fiber' {y₀ = y₀} q₀₀ {x₁ = x₁} r' r = Σ[ q₁₀ ∈ Q x₁ y₀ ] fiberSquare q₀₀ q₁₀ r' r
fiber'Push : {x₀ x₁ : X}{y₀ y₁ : Y}(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁) → inl x₀ ≡ inr y₁ → Type ℓ
fiber'Push q₀₀ q₁₁ = fiber' q₀₀ (push q₁₁)
leftCodeExtended :
{x₀ : X}{y₀ : Y}(q₀₀ : Q x₀ y₀)
→ (x₁ : X){p : PushoutQ} → inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
leftCodeExtended {y₀ = y₀} q₀₀ x₁ r' r = Trunc (m + n) (fiber' q₀₀ r' r)
rightCode : {x₀ : X}(y : Y) → Path PushoutQ (inl x₀) (inr y) → Type ℓ
rightCode y r = Trunc (m + n) (fiber push r)
{- Bunch of coherence data that will be used to construct Code -}
{- Definitions of fiber→ -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
fiber→[q₀₀=q₁₀]-filler : (i j k : I) → PushoutQ
fiber→[q₀₀=q₁₀]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₁₁ (j ∧ k)
; (i = i1) → p k j
; (j = i0) → push q₁₀ (i ∧ ~ k)
; (j = i1) → push q₁₁ k })
(inS (push q₁₀ (i ∧ ~ j))) k'
fiber→[q₀₀=q₁₀] : fiber push r
fiber→[q₀₀=q₁₀] .fst = q₁₁
fiber→[q₀₀=q₁₀] .snd i j = fiber→[q₀₀=q₁₀]-filler i j i1
∣fiber→[q₀₀=q₁₀]∣ : rightCode _ r
∣fiber→[q₀₀=q₁₀]∣ = ∣ fiber→[q₀₀=q₁₀] ∣ₕ
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
fiber→[q₁₁=q₁₀]-filler : (i j k : I) → PushoutQ
fiber→[q₁₁=q₁₀]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (j ∨ ~ k)
; (i = i1) → p k j
; (j = i0) → push q₀₀ (~ k)
; (j = i1) → push q₁₀ (~ i ∨ k) })
(inS (push q₁₀ (~ i ∨ ~ j))) k'
fiber→[q₁₁=q₁₀] : fiber push r
fiber→[q₁₁=q₁₀] .fst = q₀₀
fiber→[q₁₁=q₁₀] .snd i j = fiber→[q₁₁=q₁₀]-filler i j i1
∣fiber→[q₁₁=q₁₀]∣ : rightCode _ r
∣fiber→[q₁₁=q₁₀]∣ = ∣ fiber→[q₁₁=q₁₀] ∣ₕ
{- q₀₀ = q₁₁ = q₁₀ -}
fiber→[q₀₀=q₁₀=q₁₁]-filler :
(r : inl x₁ ≡ inr y₀)
→ (p : fiberSquarePush q₁₀ q₁₀ q₁₀ r)
→ (i j k l : I) → PushoutQ
fiber→[q₀₀=q₁₀=q₁₁]-filler r p i j k l' =
hfill (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₁₀ r p j k l
; (i = i1) → fiber→[q₁₁=q₁₀]-filler q₁₀ r p j k l
; (j = i0) → push q₁₀ ((i ∨ (k ∧ l)) ∧ (k ∨ (i ∧ ~ l)))
; (j = i1) → p l k
; (k = i0) → push q₁₀ ((i ∨ j) ∧ ~ l)
; (k = i1) → push q₁₀ ((i ∧ ~ j) ∨ l) })
(inS (push q₁₀ ((i ∨ (~ k ∧ j)) ∧ (~ k ∨ (i ∧ ~ j))))) l'
fiber→[q₀₀=q₁₀=q₁₁] : fiber→[q₀₀=q₁₀] q₁₀ ≡ fiber→[q₁₁=q₁₀] q₁₀
fiber→[q₀₀=q₁₀=q₁₁] i r p .fst = q₁₀
fiber→[q₀₀=q₁₀=q₁₁] i r p .snd j k = fiber→[q₀₀=q₁₀=q₁₁]-filler r p i j k i1
∣fiber→[q₀₀=q₁₀=q₁₁]∣ : ∣fiber→[q₀₀=q₁₀]∣ q₁₀ ≡ ∣fiber→[q₁₁=q₁₀]∣ q₁₀
∣fiber→[q₀₀=q₁₀=q₁₁]∣ i r p = ∣ fiber→[q₀₀=q₁₀=q₁₁] i r p ∣ₕ
{- Definitions of fiber← -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←[q₁₁=q₀₁]-filler : (i j k : I) → PushoutQ
fiber←[q₁₁=q₀₁]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (~ j ∧ k)
; (i = i1) → p k j
; (j = i0) → push q₀₀ (~ i ∧ k)
; (j = i1) → push q₀₁ i })
(inS (push q₀₁ (i ∧ j))) k'
fiber←[q₁₁=q₀₁] : fiber'Push q₀₀ q₀₁ r
fiber←[q₁₁=q₀₁] .fst = q₀₀
fiber←[q₁₁=q₀₁] .snd i j = fiber←[q₁₁=q₀₁]-filler i j i1
∣fiber←[q₁₁=q₀₁]∣ : leftCodeExtended q₀₀ _ (push q₀₁) r
∣fiber←[q₁₁=q₀₁]∣ = ∣ fiber←[q₁₁=q₀₁] ∣ₕ
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←[q₀₀=q₀₁]-filler : (i j k : I) → PushoutQ
fiber←[q₀₀=q₀₁]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₁₁ (~ j ∨ ~ k)
; (i = i1) → p k j
; (j = i0) → push q₀₁ (~ i)
; (j = i1) → push q₁₁ (i ∨ ~ k) })
(inS (push q₀₁ (~ i ∨ j))) k'
fiber←[q₀₀=q₀₁] : fiber'Push q₀₁ q₁₁ r
fiber←[q₀₀=q₀₁] .fst = q₁₁
fiber←[q₀₀=q₀₁] .snd i j = fiber←[q₀₀=q₀₁]-filler i j i1
∣fiber←[q₀₀=q₀₁]∣ : leftCodeExtended q₀₁ _ (push q₁₁) r
∣fiber←[q₀₀=q₀₁]∣ = ∣ fiber←[q₀₀=q₀₁] ∣ₕ
{- q₀₀ = q₀₁ = q₁₁ -}
fiber←[q₀₀=q₀₁=q₁₁]-filler :
(r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ (i j k l : I) → PushoutQ
fiber←[q₀₀=q₀₁=q₁₁]-filler r p i j k l' =
hfill (λ l → λ { (i = i0) → fiber←[q₁₁=q₀₁]-filler q₀₁ r p j k l
; (i = i1) → fiber←[q₀₀=q₀₁]-filler q₀₁ r p j k l
; (j = i0) → push q₀₁ ((i ∨ (~ k ∧ l)) ∧ (~ k ∨ (i ∧ ~ l)))
; (j = i1) → p l k
; (k = i0) → push q₀₁ ((i ∨ l) ∧ ~ j)
; (k = i1) → push q₀₁ ((i ∧ ~ l) ∨ j) })
(inS (push q₀₁ ((i ∨ (k ∧ j)) ∧ (k ∨ (i ∧ ~ j))))) l'
fiber←[q₀₀=q₀₁=q₁₁] : fiber←[q₁₁=q₀₁] q₀₁ ≡ fiber←[q₀₀=q₀₁] q₀₁
fiber←[q₀₀=q₀₁=q₁₁] i r p .fst = q₀₁
fiber←[q₀₀=q₀₁=q₁₁] i r p .snd j k = fiber←[q₀₀=q₀₁=q₁₁]-filler r p i j k i1
∣fiber←[q₀₀=q₀₁=q₁₁]∣ : ∣fiber←[q₁₁=q₀₁]∣ q₀₁ ≡ ∣fiber←[q₀₀=q₀₁]∣ q₀₁
∣fiber←[q₀₀=q₀₁=q₁₁]∣ i r p = ∣ fiber←[q₀₀=q₀₁=q₁₁] i r p ∣ₕ
{- Definitions of fiber→← -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
fiber→←[q₀₀=q₁₀]-filler : (i j k l : I) → PushoutQ
fiber→←[q₀₀=q₁₀]-filler i j k l' =
let p' = fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd in
hfill (λ l → λ { (i = i0) → fiber←[q₁₁=q₀₁]-filler q₁₁ q₁₀ r p' j k l
; (i = i1) → fiber→[q₀₀=q₁₀]-filler q₁₀ q₁₁ r p l k j
; (j = i0) → push q₁₀ (~ k ∧ l)
; (j = i1) → p' l k
; (k = i0) → push q₁₀ (~ j ∧ l)
; (k = i1) → push q₁₁ j })
(inS (push q₁₁ (j ∧ k))) l'
fiber→←[q₀₀=q₁₀] : fiber←[q₁₁=q₀₁] q₁₁ q₁₀ r (fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd) .snd ≡ p
fiber→←[q₀₀=q₁₀] i j k = fiber→←[q₀₀=q₁₀]-filler i j k i1
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
fiber→←[q₁₁=q₁₀]-filler : (i j k l : I) → PushoutQ
fiber→←[q₁₁=q₁₀]-filler i j k l' =
let p' = fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd in
hfill (λ l → λ { (i = i0) → fiber←[q₀₀=q₀₁]-filler q₀₀ q₁₀ r p' j k l
; (i = i1) → fiber→[q₁₁=q₁₀]-filler q₁₀ q₀₀ r p l k j
; (j = i0) → push q₁₀ (~ k ∨ ~ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₀ (~ j)
; (k = i1) → push q₁₀ (j ∨ ~ l) })
(inS (push q₀₀ (~ j ∨ k))) l'
fiber→←[q₁₁=q₁₀] : fiber←[q₀₀=q₀₁] q₀₀ q₁₀ r (fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd) .snd ≡ p
fiber→←[q₁₁=q₁₀] i j k = fiber→←[q₁₁=q₁₀]-filler i j k i1
{- q₀₀ = q₁₀ = q₁₁ -}
fiber→←hypercube :
(r : inl x₁ ≡ inr y₀)
→ (p : fiberSquarePush q₁₀ q₁₀ q₁₀ r)
→ PathP (λ i → fiber←[q₀₀=q₀₁=q₁₁] q₁₀ i r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd) .snd ≡ p)
(fiber→←[q₀₀=q₁₀] q₁₀ r p) (fiber→←[q₁₁=q₁₀] q₁₀ r p)
fiber→←hypercube r p i j u v =
hcomp (λ l → λ { (i = i0) → fiber→←[q₀₀=q₁₀]-filler q₁₀ r p j u v l
; (i = i1) → fiber→←[q₁₁=q₁₀]-filler q₁₀ r p j u v l
; (j = i0) → fiber←[q₀₀=q₀₁=q₁₁]-filler q₁₀ r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd) i u v l
; (j = i1) → fiber→[q₀₀=q₁₀=q₁₁]-filler q₁₀ r p i l v u
; (u = i0) → push q₁₀ ((i ∨ (~ v ∧ l)) ∧ (~ v ∨ (i ∧ ~ l)))
; (u = i1) → fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd l v
; (v = i0) → push q₁₀ ((i ∨ l) ∧ ~ u)
; (v = i1) → push q₁₀ ((i ∧ ~ l) ∨ u) })
(push q₁₀ ((i ∨ (v ∧ u)) ∧ (v ∨ (i ∧ ~ u))))
{- Definitions of fiber←→ -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←→[q₁₁=q₀₁]-filler : (i j k l : I) → PushoutQ
fiber←→[q₁₁=q₀₁]-filler i j k l' =
let p' = fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd in
hfill (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₀₀ q₀₁ r p' j k l
; (i = i1) → fiber←[q₁₁=q₀₁]-filler q₀₁ q₀₀ r p l k j
; (j = i0) → push q₀₁ (k ∧ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₀ (j ∧ ~ l)
; (k = i1) → push q₀₁ l })
(inS (push q₀₀ (j ∧ ~ k))) l'
fiber←→[q₁₁=q₀₁] : fiber→[q₀₀=q₁₀] q₀₀ q₀₁ r (fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd) .snd ≡ p
fiber←→[q₁₁=q₀₁] i j k = fiber←→[q₁₁=q₀₁]-filler i j k i1
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←→[q₀₀=q₀₁]-filler : (i j k l : I) → PushoutQ
fiber←→[q₀₀=q₀₁]-filler i j k l' =
let p' = fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd in
hfill (λ l → λ { (i = i0) → fiber→[q₁₁=q₁₀]-filler q₁₁ q₀₁ r p' j k l
; (i = i1) → fiber←[q₀₀=q₀₁]-filler q₀₁ q₁₁ r p l k j
; (j = i0) → push q₀₁ (k ∨ ~ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₁ (~ l)
; (k = i1) → push q₁₁ (~ j ∨ l) })
(inS (push q₁₁ (~ j ∨ ~ k))) l'
fiber←→[q₀₀=q₀₁] : fiber→[q₁₁=q₁₀] q₁₁ q₀₁ r (fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd) .snd ≡ p
fiber←→[q₀₀=q₀₁] i j k = fiber←→[q₀₀=q₀₁]-filler i j k i1
{- q₀₀ = q₀₁ = q₁₁ -}
fiber←→hypercube :
(r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ PathP (λ i → fiber→[q₀₀=q₁₀=q₁₁] q₀₁ i r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd) .snd ≡ p)
(fiber←→[q₁₁=q₀₁] q₀₁ r p) (fiber←→[q₀₀=q₀₁] q₀₁ r p)
fiber←→hypercube r p i j u v =
hcomp (λ l → λ { (i = i0) → fiber←→[q₁₁=q₀₁]-filler q₀₁ r p j u v l
; (i = i1) → fiber←→[q₀₀=q₀₁]-filler q₀₁ r p j u v l
; (j = i0) → fiber→[q₀₀=q₁₀=q₁₁]-filler q₀₁ r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd) i u v l
; (j = i1) → fiber←[q₀₀=q₀₁=q₁₁]-filler q₀₁ r p i l v u
; (u = i0) → push q₀₁ ((i ∨ (v ∧ l)) ∧ (v ∨ (i ∧ ~ l)))
; (u = i1) → fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd l v
; (v = i0) → push q₀₁ ((i ∨ u) ∧ ~ l)
; (v = i1) → push q₀₁ ((i ∧ ~ u) ∨ l) })
(push q₀₁ ((i ∨ (~ v ∧ u)) ∧ (~ v ∨ (i ∧ ~ u))))
module Fiber→
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) =
WedgeConnectivity m n
(leftFiber x₁ , (y₀ , q₁₀)) (leftConn x₁)
(rightFiber y₀ , (x₁ , q₁₀)) (rightConn y₀)
(λ (y₁ , q₁₁) (x₀ , q₀₀) →
(((r : inl x₀ ≡ inr y₁) → fiberSquarePush q₀₀ q₁₀ q₁₁ r → rightCode _ r)
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTrunc _)))
(λ (y₁ , q₁₁) → ∣fiber→[q₀₀=q₁₀]∣ q₁₀ q₁₁)
(λ (x₀ , q₀₀) → ∣fiber→[q₁₁=q₁₀]∣ q₁₀ q₀₀)
(∣fiber→[q₀₀=q₁₀=q₁₁]∣ q₁₀)
fiber→ :
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀)
→ {x₀ : X}(q₀₀ : Q x₀ y₀) → {y₁ : Y}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ fiberSquarePush q₀₀ q₁₀ q₁₁ r → rightCode _ r
fiber→ q₁₀ q₀₀ q₁₁ = Fiber→.extension q₁₀ (_ , q₁₁) (_ , q₀₀)
module Fiber←
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) =
WedgeConnectivity m n
(leftFiber x₀ , (y₁ , q₀₁)) (leftConn x₀)
(rightFiber y₁ , (x₀ , q₀₁)) (rightConn y₁)
(λ (y₀ , q₀₀) (x₁ , q₁₁) →
(((r : inl x₀ ≡ inr y₁) → push q₀₁ ≡ r → leftCodeExtended q₀₀ _ (push q₁₁) r)
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTrunc _)))
(λ (y₀ , q₀₀) → ∣fiber←[q₁₁=q₀₁]∣ q₀₁ q₀₀)
(λ (x₁ , q₁₁) → ∣fiber←[q₀₀=q₀₁]∣ q₀₁ q₁₁)
(∣fiber←[q₀₀=q₀₁=q₁₁]∣ q₀₁)
fiber← :
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁)
→ {y₀ : Y}(q₀₀ : Q x₀ y₀) → {x₁ : X}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ push q₀₁ ≡ r → leftCodeExtended q₀₀ _ (push q₁₁) r
fiber← q₀₁ q₀₀ q₁₁ = Fiber←.extension q₀₁ (_ , q₀₀) (_ , q₁₁)
module _
{x₀ x₁ : X}{y₀ y₁ : Y}
(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁) where
left→rightCodeExtended : leftCodeExtended q₀₀ _ (push q₁₁) r → rightCode _ r
left→rightCodeExtended =
rec (isOfHLevelTrunc _) (λ (q₁₀ , p) → fiber→ q₁₀ q₀₀ q₁₁ r p)
right→leftCodeExtended : rightCode _ r → leftCodeExtended q₀₀ _ (push q₁₁) r
right→leftCodeExtended =
rec (isOfHLevelTrunc _) (λ (q₀₁ , p) → fiber← q₀₁ q₀₀ q₁₁ r p)
{- Definition of one-side homotopy -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
∣fiber→←[q₀₀=q₁₀]∣ : right→leftCodeExtended q₁₀ q₁₁ r (fiber→ q₁₀ q₁₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ
∣fiber→←[q₀₀=q₁₀]∣ =
(λ i → right→leftCodeExtended q₁₀ q₁₁ r (Fiber→.left q₁₀ (_ , q₁₁) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber←.left q₁₁ (_ , q₁₀) i r (fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd))
∙ (λ i → ∣ q₁₀ , fiber→←[q₀₀=q₁₀] q₁₀ q₁₁ r p i ∣ₕ)
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
∣fiber→←[q₁₁=q₁₀]∣ : right→leftCodeExtended q₀₀ q₁₀ r (fiber→ q₁₀ q₀₀ q₁₀ r p) ≡ ∣ q₁₀ , p ∣ₕ
∣fiber→←[q₁₁=q₁₀]∣ =
(λ i → right→leftCodeExtended q₀₀ q₁₀ r (Fiber→.right q₁₀ (_ , q₀₀) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber←.right q₀₀ (_ , q₁₀) i r (fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd))
∙ (λ i → ∣ q₁₀ , fiber→←[q₁₁=q₁₀] q₁₀ q₀₀ r p i ∣ₕ)
{- q₀₀ = q₁₁ = q₁₀ -}
module _
(r : inl x₁ ≡ inr y₀)
(p : fiberSquarePush q₁₀ q₁₀ q₁₀ r) where
path→←Square =
(λ i j → right→leftCodeExtended q₁₀ q₁₀ r (Fiber→.homSquare q₁₀ i j r p))
∙₂ (λ i → recUniq {n = m + n} _ _ _)
∙₂ (λ i j → Fiber←.homSquare q₁₀ i j r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd))
∙₂ (λ i j → ∣ (q₁₀ , fiber→←hypercube q₁₀ r p i j) ∣ₕ)
∣fiber→←[q₀₀=q₁₀=q₁₁]∣ : ∣fiber→←[q₀₀=q₁₀]∣ q₁₀ ≡ ∣fiber→←[q₁₁=q₁₀]∣ q₁₀
∣fiber→←[q₀₀=q₁₀=q₁₁]∣ i r p = path→←Square r p i
fiber→← :
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀)
→ {x₀ : X}(q₀₀ : Q x₀ y₀) → {y₁ : Y}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ (p : fiberSquarePush q₀₀ q₁₀ q₁₁ r)
→ right→leftCodeExtended q₀₀ q₁₁ r (fiber→ q₁₀ q₀₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ
fiber→← {x₁ = x₁} {y₀ = y₀} q₁₀ q₀₀' q₁₁' =
WedgeConnectivity.extension m n
(leftFiber x₁ , (y₀ , q₁₀)) (leftConn x₁)
(rightFiber y₀ , (x₁ , q₁₀)) (rightConn y₀)
(λ (y₁ , q₁₁) (x₀ , q₀₀) →
(( (r : inl x₀ ≡ inr y₁) → (p : fiberSquarePush q₀₀ q₁₀ q₁₁ r)
→ right→leftCodeExtended q₀₀ q₁₁ r (fiber→ q₁₀ q₀₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ )
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTruncPath)))
(λ (y₁ , q₁₁) → ∣fiber→←[q₀₀=q₁₀]∣ q₁₀ q₁₁)
(λ (x₀ , q₀₀) → ∣fiber→←[q₁₁=q₁₀]∣ q₁₀ q₀₀)
(∣fiber→←[q₀₀=q₁₀=q₁₁]∣ q₁₀)
(_ , q₁₁') (_ , q₀₀')
{- Definition of the other side homotopy -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
∣fiber←→[q₁₁=q₀₁]∣ : left→rightCodeExtended q₀₀ q₀₁ r (fiber← q₀₁ q₀₀ q₀₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
∣fiber←→[q₁₁=q₀₁]∣ =
(λ i → left→rightCodeExtended q₀₀ q₀₁ r (Fiber←.left q₀₁ (_ , q₀₀) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber→.left q₀₀ (_ , q₀₁) i r (fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd))
∙ (λ i → ∣ q₀₁ , fiber←→[q₁₁=q₀₁] q₀₁ q₀₀ r p i ∣ₕ)
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
∣fiber←→[q₀₀=q₀₁]∣ : left→rightCodeExtended q₀₁ q₁₁ r (fiber← q₀₁ q₀₁ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
∣fiber←→[q₀₀=q₀₁]∣ =
(λ i → left→rightCodeExtended q₀₁ q₁₁ r (Fiber←.right q₀₁ (_ , q₁₁) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber→.right q₁₁ (_ , q₀₁) i r (fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd))
∙ (λ i → ∣ q₀₁ , fiber←→[q₀₀=q₀₁] q₀₁ q₁₁ r p i ∣ₕ)
{- q₀₀ = q₀₁ = q₁₁ -}
module _
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
path←→Square =
(λ i j → left→rightCodeExtended q₀₁ q₀₁ r (Fiber←.homSquare q₀₁ i j r p))
∙₂ (λ i → recUniq {n = m + n} _ _ _)
∙₂ (λ i j → Fiber→.homSquare q₀₁ i j r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd))
∙₂ (λ i j → ∣ q₀₁ , fiber←→hypercube q₀₁ r p i j ∣ₕ)
∣fiber←→[q₀₀=q₀₁=q₁₁]∣ : ∣fiber←→[q₁₁=q₀₁]∣ q₀₁ ≡ ∣fiber←→[q₀₀=q₀₁]∣ q₀₁
∣fiber←→[q₀₀=q₀₁=q₁₁]∣ i r p = path←→Square r p i
fiber←→ :
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁)
→ {y₀ : Y}(q₀₀ : Q x₀ y₀) → {x₁ : X}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (fiber← q₀₁ q₀₀ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
fiber←→ {x₀ = x₀} {y₁ = y₁} q₀₁ q₀₀' q₁₁' =
WedgeConnectivity.extension m n
(leftFiber x₀ , (y₁ , q₀₁)) (leftConn x₀)
(rightFiber y₁ , (x₀ , q₀₁)) (rightConn y₁)
(λ (y₀ , q₀₀) (x₁ , q₁₁) →
(( (r : inl x₀ ≡ inr y₁) → (p : push q₀₁ ≡ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (fiber← q₀₁ q₀₀ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ )
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTruncPath)))
(λ (y₀ , q₀₀) → ∣fiber←→[q₁₁=q₀₁]∣ q₀₁ q₀₀)
(λ (x₁ , q₁₁) → ∣fiber←→[q₀₀=q₀₁]∣ q₀₁ q₁₁)
(∣fiber←→[q₀₀=q₀₁=q₁₁]∣ q₀₁)
(_ , q₀₀') (_ , q₁₁')
module _
{x₀ x₁ : X}{y₀ y₁ : Y}
(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁) where
left→right→leftCodeExtended :
(a : leftCodeExtended q₀₀ _ (push q₁₁) r)
→ right→leftCodeExtended q₀₀ q₁₁ r (left→rightCodeExtended q₀₀ q₁₁ r a) ≡ a
left→right→leftCodeExtended a =
sym (∘rec _ _ _ (right→leftCodeExtended q₀₀ q₁₁ r) a) ∙
(λ i → recId _ (λ (q₁₀ , p) → fiber→← q₁₀ q₀₀ q₁₁ r p) i a)
right→left→rightCodeExtended :
(a : rightCode _ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (right→leftCodeExtended q₀₀ q₁₁ r a) ≡ a
right→left→rightCodeExtended a =
sym (∘rec _ _ _ (left→rightCodeExtended q₀₀ q₁₁ r) a) ∙
(λ i → recId _ (λ (q₀₁ , p) → fiber←→ q₀₁ q₀₀ q₁₁ r p) i a)
left≃rightCodeExtended : leftCodeExtended q₀₀ _ (push q₁₁) r ≃ rightCode y₁ r
left≃rightCodeExtended =
isoToEquiv (iso (left→rightCodeExtended _ _ _) (right→leftCodeExtended _ _ _)
right→left→rightCodeExtended left→right→leftCodeExtended)
{- Definition and properties of Code -}
module _ (x₀ : X)(y₀ : Y)(q₀₀ : Q x₀ y₀) where
leftCode' : (x : X){p : PushoutQ} → inl x ≡ p → inl x₀ ≡ p → Type ℓ
leftCode' x r' = leftCodeExtended q₀₀ x r'
leftCode : (x : X) → inl x₀ ≡ inl x → Type ℓ
leftCode x = leftCode' x refl
fiberPath : {x : X}{y : Y} → (q : Q x y) → leftCode' x (push q) ≡ rightCode y
fiberPath q i r = ua (left≃rightCodeExtended q₀₀ q r) i
pushCode :
{x : X}{y : Y} → (q : Q x y)
→ PathP (λ i → inl x₀ ≡ push q i → Type ℓ) (leftCode x) (rightCode y)
pushCode q i =
hcomp (λ j → λ { (i = i0) → leftCode _
; (i = i1) → fiberPath q j })
(leftCode' _ (λ j → push q (i ∧ j)))
Code : (p : PushoutQ) → inl x₀ ≡ p → Type ℓ
Code (inl x) = leftCode x
Code (inr y) = rightCode y
Code (push q i) = pushCode q i
{- Transportation rule of pushCode -}
transpLeftCode : (y : Y) → (q : Q x₀ y) → (q' : leftCodeExtended q₀₀ _ refl refl) → leftCode' _ (push q) (push q)
transpLeftCode y q q' =
transport (λ i → leftCode' _ (λ j → push q (i ∧ j)) (λ j → push q (i ∧ j))) q'
transpPushCodeβ' :
(y : Y) → (q : Q x₀ y) → (q' : leftCodeExtended q₀₀ _ refl refl)
→ transport (λ i → pushCode q i (λ j → push q (i ∧ j))) q' ≡ left→rightCodeExtended _ _ _ (transpLeftCode y q q')
transpPushCodeβ' y q q' i = transportRefl (left→rightCodeExtended _ _ _ (transpLeftCode y q (transportRefl q' i))) i
module _
{p : PushoutQ}(r : inl x₀ ≡ p) where
fiber-filler : I → Type ℓ
fiber-filler i = fiber' q₀₀ (λ j → r (i ∧ j)) (λ j → r (i ∧ j))
module _
(q : fiberSquare q₀₀ q₀₀ refl refl) where
transpLeftCode-filler : (i j k : I) → PushoutQ
transpLeftCode-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (~ j)
; (i = i1) → r (j ∧ k)
; (j = i0) → push q₀₀ (~ i)
; (j = i1) → r (i ∧ k) })
(inS (q i j)) k'
transpLeftCodeβ' :
{p : PushoutQ} → (r : inl x₀ ≡ p) → (q : fiberSquare q₀₀ q₀₀ refl refl)
→ transport (λ i → fiber-filler r i) (q₀₀ , q) ≡ (q₀₀ , λ i j → transpLeftCode-filler r q i j i1)
transpLeftCodeβ' r q =
J (λ p r → transport (λ i → fiber-filler r i) (q₀₀ , q) ≡ (q₀₀ , λ i j → transpLeftCode-filler r q i j i1))
(transportRefl _ ∙ (λ k → (q₀₀ , λ i j → transpLeftCode-filler refl q i j k))) r
transpLeftCodeβ :
(y : Y) → (q : Q x₀ y) → (q' : fiberSquare q₀₀ q₀₀ refl refl)
→ transpLeftCode y q ∣ q₀₀ , q' ∣ₕ ≡ ∣ q₀₀ , (λ i j → transpLeftCode-filler (push q) q' i j i1) ∣ₕ
transpLeftCodeβ y q q' = transportTrunc _ ∙ (λ i → ∣ transpLeftCodeβ' _ q' i ∣ₕ)
transpPushCodeβ :
(y : Y) → (q : Q x₀ y) → (q' : fiberSquare q₀₀ q₀₀ refl refl)
→ transport (λ i → pushCode q i (λ j → push q (i ∧ j))) ∣ q₀₀ , q' ∣ₕ
≡ ∣fiber→[q₀₀=q₁₀]∣ q₀₀ q (push q) (λ i j → transpLeftCode-filler (push q) q' i j i1)
transpPushCodeβ y q q' =
transpPushCodeβ' _ _ _
∙ (λ i → left→rightCodeExtended _ _ _ (transpLeftCodeβ _ _ q' i))
∙ recUniq {n = m + n} _ _ _
∙ (λ i' → Fiber→.left q₀₀ (_ , q) i' (push q) (λ i j → transpLeftCode-filler (push q) q' i j i1))
{- The contractibility of Code -}
centerCode : {p : PushoutQ} → (r : inl x₀ ≡ p) → Code p r
centerCode r =
transport (λ i → Code _ (λ j → r (i ∧ j))) ∣ q₀₀ , (λ i j → push q₀₀ (~ i ∧ ~ j)) ∣ₕ
module _
(y : Y)(q : Q x₀ y) where
transp-filler : (i j k : I) → PushoutQ
transp-filler = transpLeftCode-filler (push q) (λ i' j' → push q₀₀ (~ i' ∧ ~ j'))
transp-square : fiberSquare q₀₀ q₀₀ (push q) (push q)
transp-square i j = transp-filler i j i1
contractionCodeRefl' :
fiber→[q₀₀=q₁₀] q₀₀ q (push q) transp-square .snd ≡ refl
contractionCodeRefl' i j k =
hcomp (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₀₀ q (push q) transp-square j k l
; (i = i1) → transp-square (~ j ∨ l) k
; (j = i0) → push q (k ∧ (i ∨ l))
; (j = i1) → transp-square l k
; (k = i0) → push q₀₀ (j ∧ ~ l)
; (k = i1) → push q ((i ∧ ~ j) ∨ l) })
(transp-filler (~ j) k i)
contractionCodeRefl : centerCode (push q) ≡ ∣ q , refl ∣ₕ
contractionCodeRefl = transpPushCodeβ _ _ _ ∙ (λ i → ∣ q , contractionCodeRefl' i ∣ₕ)
module _
(y : Y)(r : inl x₀ ≡ inr y) where
contractionCode' : (a : fiber push r) → centerCode r ≡ ∣ a ∣ₕ
contractionCode' (q , p') = J (λ r' p → centerCode r' ≡ ∣ q , p ∣ₕ) (contractionCodeRefl _ q) p'
contractionCode : (a : Code _ r) → centerCode r ≡ a
contractionCode = elim (λ _ → isOfHLevelTruncPath) contractionCode'
isContrCode : isContr (Code _ r)
isContrCode = centerCode r , contractionCode
excision-helper :
(x : X) → Trunc (1 + m) (Σ[ y₀ ∈ Y ] Q x y₀)
→ (y : Y) → (r : inl x ≡ inr y) → isContr (Trunc (m + n) (fiber push r))
excision-helper x y' y r = rec (isProp→isOfHLevelSuc m isPropIsContr) (λ (y₀ , q₀₀) → isContrCode x y₀ q₀₀ y r ) y'
{- The Main Result : Blakers-Massey Homotopy Excision Theorem -}
Excision : (x : X)(y : Y) → isConnectedFun (m + n) (push {x = x} {y = y})
Excision x y = excision-helper x (leftConn x .fst) y
{-
We also give the following version of the theorem: Given a square
g
A --------------> B
|\ ↗ |
| \ ↗ |
| \ ↗ |
f | X | inr
| / |
| / |
| / |
v / v
B -----------> Pushout f g
inl
where X is the pullback of inl and inr
(X := Σ[ (b , c) ∈ B × C ] (inl b ≡ inr c)).
If f in n-connected and g in m-connected, then the diagonal map
A → X is (n+m)-connected
-}
private
shuffleFibIso₁ :
{ℓ ℓ' ℓ'' : Level} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (b : B)
→ Iso (Σ[ c ∈ C ] Σ[ a ∈ A ] (f a ≡ b) × (g a ≡ c))
(Σ[ a ∈ A ] ((Σ[ c ∈ C ] (g a ≡ c)) × (f a ≡ b)))
shuffleFibIso₁ f g b =
compIso (invIso Σ-assoc-Iso)
(compIso (Σ-cong-iso-fst Σ-swap-Iso)
(compIso
(Σ-cong-iso-snd (λ y → Σ-swap-Iso))
(compIso Σ-assoc-Iso
(Σ-cong-iso-snd λ a → invIso Σ-assoc-Iso))))
shuffleFibIso₂ : {ℓ ℓ' ℓ'' : Level} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (x : _)
→ Iso (Σ[ a ∈ A ] ((Σ[ c ∈ C ] (g a ≡ c)) × (f a ≡ x)))
(fiber f x)
shuffleFibIso₂ f g x = Σ-cong-iso-snd
λ a → compIso (Σ-cong-iso-fst
(isContr→Iso (isContrSingl (g a))
isContrUnit))
lUnit×Iso
module BlakersMassey□ {ℓ ℓ' ℓ'' : Level}
{A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (n m : ℕ)
(con-f : isConnectedFun (suc n) f)
(con-g : isConnectedFun (suc m) g) where
{- Some abbreviations and connectivity -}
private
fib = doubleFib f g
B-con : (x : B) → isConnected (suc n) (Σ[ c ∈ C ] (fib x c))
B-con x =
isConnectedRetractFromIso (suc n)
(compIso
(shuffleFibIso₁ f g x)
(shuffleFibIso₂ f g x))
(con-f x)
C-con : (c : C) → isConnected (suc m) (Σ[ b ∈ B ] (fib b c))
C-con c =
isConnectedRetractFromIso (suc m)
(compIso
(compIso (Σ-cong-iso-snd
(λ _ → Σ-cong-iso-snd λ _ → Σ-swap-Iso))
(shuffleFibIso₁ g f c))
(shuffleFibIso₂ g f c))
(con-g c)
open module BM-f-g = BlakersMassey B C fib {m = n} B-con {n = m} C-con
fib× : (B × C) → Type _
fib× (b , c) = fib b c
PushoutGenPath× : B × C → Type _
PushoutGenPath× (b , c) = Path (PushoutGen fib) (inl b) (inr c)
PushoutPath× : B × C → Type _
PushoutPath× (b , c) = Path (Pushout f g) (inl b) (inr c)
{- The function in question -}
toPullback : A → Σ (B × C) PushoutPath×
toPullback a = (f a , g a) , push a
{- We redescribe toPullback as a composition of three maps,
two of which are equivs and one of which is (n+m)-connected -}
Totalfib×→Total : Σ (B × C) fib× → Σ (B × C) PushoutGenPath×
Totalfib×→Total =
TotalFun {A = B × C} {B = fib×} {C = PushoutGenPath×} (λ a → push)
isConnectedTotalFun : isConnectedFun (n + m) Totalfib×→Total
isConnectedTotalFun =
FunConnected→TotalFunConnected (λ _ → push) (n + m) (uncurry BM-f-g.Excision)
TotalPathGen×Iso : Iso (Σ (B × C) PushoutGenPath×) (Σ (B × C) PushoutPath×)
TotalPathGen×Iso =
Σ-cong-iso-snd λ x
→ congIso (invIso (IsoPushoutPushoutGen f g))
Totalfib×Iso : Iso (Σ (B × C) fib×) A
fun Totalfib×Iso ((b , c) , a , p) = a
inv Totalfib×Iso a = (f a , g a) , a , refl , refl
rightInv Totalfib×Iso _ = refl
leftInv Totalfib×Iso ((b , c) , a , (p , q)) i =
((p i) , (q i)) , (a , ((λ j → p (i ∧ j)) , (λ j → q (i ∧ j))))
toPullback' : A → Σ (B × C) PushoutPath×
toPullback' =
(fun TotalPathGen×Iso ∘ Totalfib×→Total) ∘ inv Totalfib×Iso
toPullback'≡toPullback : toPullback' ≡ toPullback
toPullback'≡toPullback =
funExt λ x → ΣPathP (refl , (sym (rUnit (push x))))
isConnected-toPullback : isConnectedFun (n + m) toPullback
isConnected-toPullback =
subst (isConnectedFun (n + m)) toPullback'≡toPullback
(isConnectedComp
(fun TotalPathGen×Iso ∘ Totalfib×→Total)
(inv Totalfib×Iso) (n + m)
(isConnectedComp (fun TotalPathGen×Iso) Totalfib×→Total (n + m)
(isEquiv→isConnected _ (isoToIsEquiv TotalPathGen×Iso) (n + m))
isConnectedTotalFun)
(isEquiv→isConnected _ (isoToIsEquiv (invIso Totalfib×Iso)) (n + m)))
| 38.939506
| 120
| 0.502394
|
4ad3f66ced588ee98c6d0e9aafe26563ffd4df87
| 925
|
agda
|
Agda
|
theorems/homotopy/PathSetIsInitalCover.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/PathSetIsInitalCover.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/PathSetIsInitalCover.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.PathSetIsInitalCover {i} (X : Ptd i)
-- and an arbitrary covering
{k} (⊙cov : ⊙Cover X k) where
open Cover
private
univ-cover = path-set-cover X
module ⊙cov = ⊙Cover ⊙cov
-- Weak initiality by transport.
quotient-cover : CoverHom univ-cover ⊙cov.cov
quotient-cover _ p = cover-trace ⊙cov.cov ⊙cov.pt p
-- Strong initiality by path induction.
module Uniqueness
(cover-hom : CoverHom univ-cover ⊙cov.cov)
(pres-pt : cover-hom (pt X) idp₀ == ⊙cov.pt)
where
private
lemma₁ : ∀ a p → cover-hom a [ p ] == quotient-cover a [ p ]
lemma₁ ._ idp = pres-pt
lemma₂ : ∀ a p → cover-hom a p == quotient-cover a p
lemma₂ a = Trunc-elim
(λ p → =-preserves-set (⊙cov.Fiber-level a))
(lemma₁ a)
theorem : cover-hom == quotient-cover
theorem = λ= λ a → λ= $ lemma₂ a
| 25.694444
| 66
| 0.60973
|
df9190f8cd5e848276bd51406937d4cdb602de8c
| 7,369
|
agda
|
Agda
|
core/lib/groups/TensorProduct.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
core/lib/groups/TensorProduct.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
core/lib/groups/TensorProduct.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Group
open import lib.types.List
open import lib.types.Pi
open import lib.types.Sigma
open import lib.types.Word
open import lib.groups.Homomorphism
open import lib.groups.GeneratedGroup
open import lib.groups.GeneratedAbelianGroup
open import lib.groups.Isomorphism
module lib.groups.TensorProduct where
module TensorProduct₀ {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G = AbGroup G
module H = AbGroup H
⊗-pair : Type (lmax i j)
⊗-pair = G.El × H.El
data ⊗-rel : Word ⊗-pair → Word ⊗-pair → Type (lmax i j) where
linear-l : (g₁ g₂ : G.El) (h : H.El) →
⊗-rel (inl (G.comp g₁ g₂ , h) :: nil) (inl (g₁ , h) :: inl (g₂ , h) :: nil)
linear-r : (g : G.El) (h₁ h₂ : H.El) →
⊗-rel (inl (g , H.comp h₁ h₂) :: nil) (inl (g , h₁) :: inl (g , h₂) :: nil)
private
module Gen = GeneratedAbelianGroup ⊗-pair ⊗-rel
open Gen hiding (GenGroup; GenAbGroup; El) public
abstract
abgroup : AbGroup (lmax i j)
abgroup = Gen.GenAbGroup
open AbGroup abgroup public
abstract
infixr 80 _⊗_
_⊗_ : G.El → H.El → El
_⊗_ g h = insert (g , h)
⊗-lin-l : ∀ g₁ g₂ h → G.comp g₁ g₂ ⊗ h == comp (g₁ ⊗ h) (g₂ ⊗ h)
⊗-lin-l g₁ g₂ h = rel-holds (linear-l g₁ g₂ h)
⊗-lin-r : ∀ g h₁ h₂ → g ⊗ H.comp h₁ h₂ == comp (g ⊗ h₁) (g ⊗ h₂)
⊗-lin-r g h₁ h₂ = rel-holds (linear-r g h₁ h₂)
⊗-unit-l : ∀ h → G.ident ⊗ h == ident
⊗-unit-l h = cancel-l (G.ident ⊗ h) $
comp (G.ident ⊗ h) (G.ident ⊗ h)
=⟨ ! (⊗-lin-l G.ident G.ident h) ⟩
G.comp G.ident G.ident ⊗ h
=⟨ ap (_⊗ h) (G.unit-l G.ident) ⟩
G.ident ⊗ h
=⟨ ! (unit-r (G.ident ⊗ h)) ⟩
comp (G.ident ⊗ h) ident =∎
⊗-unit-r : ∀ g → g ⊗ H.ident == ident
⊗-unit-r g = cancel-r (g ⊗ H.ident) $
comp (g ⊗ H.ident) (g ⊗ H.ident)
=⟨ ! (⊗-lin-r g H.ident H.ident) ⟩
g ⊗ H.comp H.ident H.ident
=⟨ ap (g ⊗_) (H.unit-l H.ident) ⟩
g ⊗ H.ident
=⟨ ! (unit-r (g ⊗ H.ident)) ⟩
comp (g ⊗ H.ident) ident =∎
ins-l-hom : H.El → G.grp →ᴳ grp
ins-l-hom h = group-hom (_⊗ h) (λ g₁ g₂ → ⊗-lin-l g₁ g₂ h)
ins-r-hom : G.El → H.grp →ᴳ grp
ins-r-hom g = group-hom (g ⊗_) (⊗-lin-r g)
module BilinearMaps {k} (L : AbGroup k) where
private
module L = AbGroup L
module HE = Gen.HomomorphismEquiv L
is-linear-l : (G.El → H.El → L.El) → Type (lmax i (lmax j k))
is-linear-l b = ∀ g₁ g₂ h → b (G.comp g₁ g₂) h == L.comp (b g₁ h) (b g₂ h)
is-linear-l-is-prop : (b : G.El → H.El → L.El) → is-prop (is-linear-l b)
is-linear-l-is-prop b =
Π-level $ λ g₁ →
Π-level $ λ g₂ →
Π-level $ λ h →
has-level-apply L.El-level _ _
is-linear-r : (G.El → H.El → L.El) → Type (lmax i (lmax j k))
is-linear-r b = ∀ g h₁ h₂ → b g (H.comp h₁ h₂) == L.comp (b g h₁) (b g h₂)
is-linear-r-is-prop : (b : G.El → H.El → L.El) → is-prop (is-linear-r b)
is-linear-r-is-prop b =
Π-level $ λ g →
Π-level $ λ h₁ →
Π-level $ λ h₂ →
has-level-apply L.El-level _ _
record BilinearMap : Type (lmax i (lmax j k)) where
field
bmap : G.El → H.El → L.El
linearity-l : is-linear-l bmap
linearity-r : is-linear-r bmap
BilinearMap= : {b b' : BilinearMap}
→ BilinearMap.bmap b == BilinearMap.bmap b'
→ b == b'
BilinearMap= {b} {b'} idp =
ap2 mk-bilinear-map
(prop-path (is-linear-l-is-prop b.bmap) b.linearity-l b'.linearity-l)
(prop-path (is-linear-r-is-prop b.bmap) b.linearity-r b'.linearity-r)
where
module b = BilinearMap b
module b' = BilinearMap b'
mk-bilinear-map : is-linear-l b.bmap → is-linear-r b.bmap → BilinearMap
mk-bilinear-map lin-l lin-r =
record { bmap = b.bmap; linearity-l = lin-l; linearity-r = lin-r }
bilinear-to-legal-equiv : BilinearMap ≃ HE.RelationRespectingFunction
bilinear-to-legal-equiv =
equiv to from
(λ lf → HE.RelationRespectingFunction= idp)
(λ b → BilinearMap= idp)
where
to : BilinearMap → HE.RelationRespectingFunction
to b = HE.rel-res-fun f f-respects
where
module b = BilinearMap b
f : ⊗-pair → L.El
f (g , h) = b.bmap g h
f-respects : HE.respects-rel f
f-respects (linear-l g₁ g₂ h) = b.linearity-l g₁ g₂ h
f-respects (linear-r g h₁ h₂) = b.linearity-r g h₁ h₂
from : HE.RelationRespectingFunction → BilinearMap
from (HE.rel-res-fun f f-respects) =
record { bmap = bmap; linearity-l = linearity-l; linearity-r = linearity-r }
where
bmap : G.El → H.El → L.El
bmap g h = f (g , h)
linearity-l : is-linear-l bmap
linearity-l g₁ g₂ h = f-respects (linear-l g₁ g₂ h)
linearity-r : is-linear-r bmap
linearity-r g h₁ h₂ = f-respects (linear-r g h₁ h₂)
module UniversalProperty {k} (L : AbGroup k) where
open BilinearMaps L public
private
module HE = Gen.HomomorphismEquiv L
abstract
extend-equiv : BilinearMap ≃ (grp →ᴳ AbGroup.grp L)
extend-equiv =
HE.extend-equiv ∘e bilinear-to-legal-equiv
extend : BilinearMap → (grp →ᴳ AbGroup.grp L)
extend = –> extend-equiv
restrict : (grp →ᴳ AbGroup.grp L) → BilinearMap
restrict = <– extend-equiv
extend-β : ∀ b g h → GroupHom.f (extend b) (g ⊗ h) == BilinearMap.bmap b g h
extend-β b g h = idp
hom= : ∀ {ϕ ψ : grp →ᴳ AbGroup.grp L}
→ (∀ g h → GroupHom.f ϕ (g ⊗ h) == GroupHom.f ψ (g ⊗ h))
→ ϕ == ψ
hom= {ϕ} {ψ} e =
ϕ
=⟨ ! (<–-inv-r extend-equiv ϕ) ⟩
extend (restrict ϕ)
=⟨ ap extend (BilinearMap= (λ= (λ g → λ= (λ h → e g h)))) ⟩
extend (restrict ψ)
=⟨ <–-inv-r extend-equiv ψ ⟩
ψ =∎
module TensorProduct₁ {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G⊗H = TensorProduct₀ G H
module H⊗G = TensorProduct₀ H G
module F = G⊗H.UniversalProperty H⊗G.abgroup
b : F.BilinearMap
b =
record
{ bmap = λ g h → h H⊗G.⊗ g
; linearity-l = λ g₁ g₂ h → H⊗G.⊗-lin-r h g₁ g₂
; linearity-r = λ g h₁ h₂ → H⊗G.⊗-lin-l h₁ h₂ g
}
swap : (G⊗H.grp →ᴳ H⊗G.grp)
swap = F.extend b
swap-β : ∀ g h →
GroupHom.f swap (g G⊗H.⊗ h) == h H⊗G.⊗ g
swap-β g h = F.extend-β b g h
open G⊗H public
module TensorProduct₂ {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G⊗H = TensorProduct₁ G H
module H⊗G = TensorProduct₁ H G
swap-swap : ∀ s → GroupHom.f (H⊗G.swap ∘ᴳ G⊗H.swap) s == s
swap-swap s =
ap (λ ϕ → GroupHom.f ϕ s) $
G⊗H.UniversalProperty.hom= G⊗H.abgroup {ϕ = H⊗G.swap ∘ᴳ G⊗H.swap} {ψ = idhom _} $
λ g h → ap (GroupHom.f H⊗G.swap) (G⊗H.swap-β g h) ∙ H⊗G.swap-β h g
swap-swap-idhom : H⊗G.swap ∘ᴳ G⊗H.swap == idhom G⊗H.grp
swap-swap-idhom = group-hom= (λ= swap-swap)
open G⊗H public
module TensorProduct {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G⊗H = TensorProduct₂ G H
module H⊗G = TensorProduct₂ H G
swap-is-equiv : is-equiv (GroupHom.f G⊗H.swap)
swap-is-equiv = is-eq _ (GroupHom.f H⊗G.swap) H⊗G.swap-swap G⊗H.swap-swap
commutative : G⊗H.grp ≃ᴳ H⊗G.grp
commutative = G⊗H.swap , swap-is-equiv
open G⊗H public
| 31.224576
| 85
| 0.56032
|
dfb94dd87badab311fd37147053d85fde37ab24c
| 384
|
agda
|
Agda
|
test/Succeed/NonConjectures/Foo.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
test/Succeed/NonConjectures/Foo.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
test/Succeed/NonConjectures/Foo.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
------------------------------------------------------------------------------
-- Foo module
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Foo where
postulate foo : Set
| 29.538462
| 78
| 0.307292
|
dcb120169094163c31b226995e21346bf823fae2
| 12,801
|
agda
|
Agda
|
src/FOmegaInt/Undecidable/SK.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 12
|
2017-06-13T16:05:35.000Z
|
2021-09-27T05:53:06.000Z
|
src/FOmegaInt/Undecidable/SK.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 1
|
2021-05-14T08:09:40.000Z
|
2021-05-14T08:54:39.000Z
|
src/FOmegaInt/Undecidable/SK.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 2
|
2021-05-13T22:29:48.000Z
|
2021-05-14T10:25:05.000Z
|
------------------------------------------------------------------------
-- The untyped SKI combinator calculus
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Undecidable.SK where
open import Data.Bool
open import Data.Product as Prod using (_,_; ∃; _×_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- The untyped SK(I) combinator calculus
infixl 9 _·_
infixl 4 _≡SK_ _≤SK?_ _⇛[_]_ _⇛[_]*_ _⇛≤_ _⇛≤*_ _⇛≥_ _⇛≥*_ _⇛≤*≤⇚_
-- Terms of the SK combinator calculus.
data SKTerm : Set where
S : SKTerm
K : SKTerm
_·_ : SKTerm → SKTerm → SKTerm
-- Equality of SK terms.
data _≡SK_ : SKTerm → SKTerm → Set where
≡-refl : ∀ {t} → t ≡SK t
≡-trans : ∀ {s t u} → s ≡SK t → t ≡SK u → s ≡SK u
≡-sym : ∀ {s t} → s ≡SK t → t ≡SK s
≡-Sred : ∀ {s t u} → S · s · t · u ≡SK s · u · (t · u)
≡-Kred : ∀ {s t} → K · s · t ≡SK s
≡-· : ∀ {s₁ s₂ t₁ t₂} →
s₁ ≡SK s₂ → t₁ ≡SK t₂ → s₁ · t₁ ≡SK s₂ · t₂
-- A well-known encoding of the I combinator.
I : SKTerm
I = S · K · K
-- Some admissible equality rules.
≡-Ired : ∀ {t} → I · t ≡SK t
≡-Ired = ≡-trans ≡-Sred ≡-Kred
≡-Sexp : ∀ {s t u} → s · u · (t · u) ≡SK S · s · t · u
≡-Sexp = ≡-sym ≡-Sred
≡-Kexp : ∀ {s t} → s ≡SK K · s · t
≡-Kexp = ≡-sym ≡-Kred
≡-Iexp : ∀ {t} → t ≡SK I · t
≡-Iexp = ≡-sym ≡-Ired
------------------------------------------------------------------------
-- A variant of the untyped SK calculus with extra term formers
data SK?Term : Set where
⊥ : SK?Term -- degenerate term
⊤ : SK?Term -- degenerate term
S : SK?Term
K : SK?Term
_·_ : SK?Term → SK?Term → SK?Term
-- An SK? term is pure if it is an SK term.
data Pure : SK?Term → Set where
S : Pure S
K : Pure K
_·_ : ∀ {s t} → Pure s → Pure t → Pure (s · t)
-- A partial order on SK? terms that resembles subtyping.
data _≤SK?_ : SK?Term → SK?Term → Set where
≤?-refl : ∀ {t} → t ≤SK? t
≤?-trans : ∀ {s t u} → s ≤SK? t → t ≤SK? u → s ≤SK? u
≤?-⊥ : ∀ {t} → ⊥ ≤SK? t
≤?-⊤ : ∀ {t} → t ≤SK? ⊤
≤?-Sred : ∀ {s t u} → S · s · t · u ≤SK? s · u · (t · u)
≤?-Kred : ∀ {s t} → K · s · t ≤SK? s
≤?-Sexp : ∀ {s t u} → s · u · (t · u) ≤SK? S · s · t · u
≤?-Kexp : ∀ {s t} → s ≤SK? K · s · t
≤?-· : ∀ {s₁ s₂ t₁ t₂} →
s₁ ≤SK? s₂ → t₁ ≤SK? t₂ → s₁ · t₁ ≤SK? s₂ · t₂
-- Parallel one-step and multi-step reduction of SK? terms, possibly
-- containing instances of ⊥-elim and ⊤-intro.
--
-- The `i' index in `_⇛[ i ]_' indicates whether the relation is
-- increasing (true) or decreasing (false). The increasing
-- single/multi-step relations are (strict) subrelations of _≤SK?_,
-- while the decreasing ones are subrelations of _≥SK?_ (i.e. the
-- inverse of _≤SK?_).
data _⇛[_]_ : SK?Term → Bool → SK?Term → Set where
⇛-refl : ∀ {t i} → t ⇛[ i ] t
⇛-Sred : ∀ {s₁ s₂ t₁ t₂ u₁ u₂ i} →
s₁ ⇛[ i ] s₂ → t₁ ⇛[ i ] t₂ → u₁ ⇛[ i ] u₂ →
S · s₁ · t₁ · u₁ ⇛[ i ] s₂ · u₂ · (t₂ · u₂)
⇛-Kred : ∀ {s₁ s₂ t i} → s₁ ⇛[ i ] s₂ → K · s₁ · t ⇛[ i ] s₂
⇛-· : ∀ {s₁ s₂ t₁ t₂ i} →
s₁ ⇛[ i ] s₂ → t₁ ⇛[ i ] t₂ → s₁ · t₁ ⇛[ i ] s₂ · t₂
⇛-⊥ : ∀ {t} → ⊥ ⇛[ true ] t
⇛-⊤ : ∀ {t} → ⊤ ⇛[ false ] t
_⇛[_]*_ : SK?Term → Bool → SK?Term → Set
s ⇛[ i ]* t = (Star _⇛[ i ]_) s t
_⇛≤_ : SK?Term → SK?Term → Set
_⇛≤_ = _⇛[ true ]_
_⇛≤*_ : SK?Term → SK?Term → Set
_⇛≤*_ = _⇛[ true ]*_
_⇛≥_ : SK?Term → SK?Term → Set
_⇛≥_ = _⇛[ false ]_
_⇛≥*_ : SK?Term → SK?Term → Set
_⇛≥*_ = _⇛[ false ]*_
-- A combination of the two multi-step reductions that is equivalent
-- to _≤SK?_ modulo "squashing" of intermediate terms (see ≤SK?--⇛≤*≤⇚
-- below).
_⇛≤*≤⇚_ : SK?Term → SK?Term → Set
s ⇛≤*≤⇚ t = ∃ λ u → s ⇛≤* u × t ⇛≥* u
-- SK terms are SK? terms
inject : SKTerm → SK?Term
inject S = S
inject K = K
inject (s · t) = inject s · inject t
inject-Pure : ∀ t → Pure (inject t)
inject-Pure S = S
inject-Pure K = K
inject-Pure (s · t) = inject-Pure s · inject-Pure t
-- The inverse of inject on pure terms.
inject⁻¹ : ∀ {t} → Pure t → SKTerm
inject⁻¹ S = S
inject⁻¹ K = K
inject⁻¹ (p · q) = inject⁻¹ p · inject⁻¹ q
inject⁻¹-inject-Pure : ∀ t → inject⁻¹ (inject-Pure t) ≡ t
inject⁻¹-inject-Pure S = refl
inject⁻¹-inject-Pure K = refl
inject⁻¹-inject-Pure (s · t) =
cong₂ _·_ (inject⁻¹-inject-Pure s) (inject⁻¹-inject-Pure t)
inject⁻¹-unique : ∀ {t} → (p q : Pure t) → inject⁻¹ p ≡ inject⁻¹ q
inject⁻¹-unique S S = refl
inject⁻¹-unique K K = refl
inject⁻¹-unique (p₁ · p₂) (q₁ · q₂) =
cong₂ _·_ (inject⁻¹-unique p₁ q₁) (inject⁻¹-unique p₂ q₂)
-- Equality of SK terms is a subrelation of the SK? term order and its
-- inverse.
mutual
≡SK-≤SK? : ∀ {s t} → s ≡SK t → inject s ≤SK? inject t
≡SK-≤SK? ≡-refl = ≤?-refl
≡SK-≤SK? (≡-trans s≡t t≡u) = ≤?-trans (≡SK-≤SK? s≡t) (≡SK-≤SK? t≡u)
≡SK-≤SK? (≡-sym s≡t) = ≡SK-≥SK? s≡t
≡SK-≤SK? ≡-Sred = ≤?-Sred
≡SK-≤SK? ≡-Kred = ≤?-Kred
≡SK-≤SK? (≡-· s₁≡t₁ s₂≡t₂) = ≤?-· (≡SK-≤SK? s₁≡t₁) (≡SK-≤SK? s₂≡t₂)
≡SK-≥SK? : ∀ {s t} → s ≡SK t → inject t ≤SK? inject s
≡SK-≥SK? ≡-refl = ≤?-refl
≡SK-≥SK? (≡-trans s≡t t≡u) = ≤?-trans (≡SK-≥SK? t≡u) (≡SK-≥SK? s≡t)
≡SK-≥SK? (≡-sym s≡t) = ≡SK-≤SK? s≡t
≡SK-≥SK? ≡-Sred = ≤?-Sexp
≡SK-≥SK? ≡-Kred = ≤?-Kexp
≡SK-≥SK? (≡-· s₁≡t₁ s₂≡t₂) = ≤?-· (≡SK-≥SK? s₁≡t₁) (≡SK-≥SK? s₂≡t₂)
-- Admissible constructors for multi-step reduction
⇛*-· : ∀ {ab s₁ s₂ t₁ t₂} →
s₁ ⇛[ ab ]* s₂ → t₁ ⇛[ ab ]* t₂ → s₁ · t₁ ⇛[ ab ]* s₂ · t₂
⇛*-· ε ε = ε
⇛*-· ε (t₁⇛t₂ ◅ t₂⇛*t₃) = (⇛-· ⇛-refl t₁⇛t₂) ◅ (⇛*-· ε t₂⇛*t₃)
⇛*-· (s₁⇛s₂ ◅ s₂⇛*s₃) ε = (⇛-· s₁⇛s₂ ⇛-refl) ◅ (⇛*-· s₂⇛*s₃ ε)
⇛*-· (s₁⇛s₂ ◅ s₂⇛*s₃) (t₁⇛t₂ ◅ t₂⇛*t₃) = (⇛-· s₁⇛s₂ t₁⇛t₂) ◅ (⇛*-· s₂⇛*s₃ t₂⇛*t₃)
-- A Church-Rosser theorem for SK? reductions.
⇛-CR : ∀ {s t₁ t₂} → s ⇛≤ t₁ → s ⇛≥ t₂ → ∃ λ u → t₁ ⇛≥ u × t₂ ⇛≤ u
⇛-CR ⇛-refl s⇛t₂ = _ , s⇛t₂ , ⇛-refl
⇛-CR (⇛-Sred s₁⇛t₁₁ s₂⇛t₂₁ s₃⇛t₃₁) (⇛-Sred s₁⇛t₁₂ s₂⇛t₂₂ s₃⇛t₃₂) =
let u₁ , t₁₁⇛u₁ , t₁₂⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₁₂
u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in u₁ · u₃ · (u₂ · u₃) ,
⇛-· (⇛-· t₁₁⇛u₁ t₃₁⇛u₃) (⇛-· t₂₁⇛u₂ t₃₁⇛u₃) ,
⇛-· (⇛-· t₁₂⇛u₁ t₃₂⇛u₃) (⇛-· t₂₂⇛u₂ t₃₂⇛u₃)
⇛-CR (⇛-Sred s₁⇛t₁₁ s₂⇛t₂₁ s₃⇛t₃₁) (⇛-· ⇛-refl s₃⇛t₃₂) =
let u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in _ · u₃ · (_ · u₃) ,
⇛-· (⇛-· ⇛-refl t₃₁⇛u₃) (⇛-· ⇛-refl t₃₁⇛u₃) ,
⇛-Sred s₁⇛t₁₁ s₂⇛t₂₁ t₃₂⇛u₃
⇛-CR (⇛-Sred s₁⇛t₁₁ s₂⇛t₂₁ s₃⇛t₃₁) (⇛-· (⇛-· ⇛-refl s₂⇛t₂₂) s₃⇛t₃₂) =
let u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in _ · u₃ · (u₂ · u₃) ,
⇛-· (⇛-· ⇛-refl t₃₁⇛u₃) (⇛-· t₂₁⇛u₂ t₃₁⇛u₃) ,
⇛-Sred s₁⇛t₁₁ t₂₂⇛u₂ t₃₂⇛u₃
⇛-CR (⇛-Sred s₁⇛t₁₁ s₂⇛t₂₁ s₃⇛t₃₁)
(⇛-· (⇛-· (⇛-· ⇛-refl s₁⇛t₁₂) s₂⇛t₂₂) s₃⇛t₃₂) =
let u₁ , t₁₁⇛u₁ , t₁₂⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₁₂
u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in u₁ · u₃ · (u₂ · u₃) ,
⇛-· (⇛-· t₁₁⇛u₁ t₃₁⇛u₃) (⇛-· t₂₁⇛u₂ t₃₁⇛u₃) ,
⇛-Sred t₁₂⇛u₁ t₂₂⇛u₂ t₃₂⇛u₃
⇛-CR (⇛-Kred s⇛t₁) (⇛-Kred s⇛t₂) =
let u , t₁⇛u , t₂⇛u = ⇛-CR s⇛t₁ s⇛t₂
in u , t₁⇛u , t₂⇛u
⇛-CR (⇛-Kred s₁⇛t₁₁) (⇛-· ⇛-refl _) = _ , ⇛-refl , ⇛-Kred s₁⇛t₁₁
⇛-CR (⇛-Kred s₁⇛t₁₁) (⇛-· (⇛-· ⇛-refl s₁⇛t₂₁) _) =
let u₁ , t₁₁⇛u₁ , t₂₁⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₂₁
in u₁ , t₁₁⇛u₁ , ⇛-Kred t₂₁⇛u₁
⇛-CR (⇛-· ⇛-refl s₃⇛t₃₁) (⇛-Sred s₁⇛t₁₂ s₂⇛t₂₂ s₃⇛t₃₂) =
let u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in _ · u₃ · (_ · u₃) ,
⇛-Sred s₁⇛t₁₂ s₂⇛t₂₂ t₃₁⇛u₃ ,
⇛-· (⇛-· ⇛-refl t₃₂⇛u₃) (⇛-· ⇛-refl t₃₂⇛u₃)
⇛-CR (⇛-· (⇛-· ⇛-refl s₂⇛t₂₁) s₃⇛t₃₁) (⇛-Sred s₁⇛t₁₂ s₂⇛t₂₂ s₃⇛t₃₂) =
let u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in _ · u₃ · (u₂ · u₃) ,
⇛-Sred s₁⇛t₁₂ t₂₁⇛u₂ t₃₁⇛u₃ ,
⇛-· (⇛-· ⇛-refl t₃₂⇛u₃) (⇛-· t₂₂⇛u₂ t₃₂⇛u₃)
⇛-CR (⇛-· (⇛-· (⇛-· ⇛-refl s₁⇛t₁₁) s₂⇛t₂₁) s₃⇛t₃₁)
(⇛-Sred s₁⇛t₁₂ s₂⇛t₂₂ s₃⇛t₃₂) =
let u₁ , t₁₁⇛u₁ , t₁₂⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₁₂
u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
u₃ , t₃₁⇛u₃ , t₃₂⇛u₃ = ⇛-CR s₃⇛t₃₁ s₃⇛t₃₂
in u₁ · u₃ · (u₂ · u₃) ,
⇛-Sred t₁₁⇛u₁ t₂₁⇛u₂ t₃₁⇛u₃ ,
⇛-· (⇛-· t₁₂⇛u₁ t₃₂⇛u₃) (⇛-· t₂₂⇛u₂ t₃₂⇛u₃)
⇛-CR (⇛-· ⇛-refl _) (⇛-Kred s₁⇛t₂₁) =
_ , ⇛-Kred s₁⇛t₂₁ , ⇛-refl
⇛-CR (⇛-· (⇛-· ⇛-refl s₁⇛t₁₁) _) (⇛-Kred s₁⇛t₂₁) =
let u₁ , t₁₁⇛u₁ , t₂₁⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₂₁
in u₁ , ⇛-Kred t₁₁⇛u₁ , t₂₁⇛u₁
{-# CATCHALL #-}
⇛-CR (⇛-· s₁⇛t₁₁ s₂⇛t₂₁) (⇛-· s₁⇛t₁₂ s₂⇛t₂₂) =
let u₁ , t₁₁⇛u₁ , t₁₂⇛u₁ = ⇛-CR s₁⇛t₁₁ s₁⇛t₁₂
u₂ , t₂₁⇛u₂ , t₂₂⇛u₂ = ⇛-CR s₂⇛t₂₁ s₂⇛t₂₂
in u₁ · u₂ , ⇛-· t₁₁⇛u₁ t₂₁⇛u₂ , ⇛-· t₁₂⇛u₁ t₂₂⇛u₂
{-# CATCHALL #-}
⇛-CR s⇛t₁ ⇛-refl = _ , ⇛-refl , s⇛t₁
⇛-⇛*-CR : ∀ {s t₁ t₂} → s ⇛≤ t₁ → s ⇛≥* t₂ → ∃ λ u → t₁ ⇛≥* u × t₂ ⇛≤ u
⇛-⇛*-CR s⇛≤t ε = _ , ε , s⇛≤t
⇛-⇛*-CR s⇛≤u₁ (s⇛≥t₁ ◅ t₁⇛≥*t₂) =
let u₂ , u₁⇛≥u₂ , t₁⇛≤u₂ = ⇛-CR s⇛≤u₁ s⇛≥t₁
u₃ , u₂⇛≥*u₃ , t₂⇛≤u₃ = ⇛-⇛*-CR t₁⇛≤u₂ t₁⇛≥*t₂
in u₃ , u₁⇛≥u₂ ◅ u₂⇛≥*u₃ , t₂⇛≤u₃
⇛*-CR : ∀ {s t₁ t₂} → s ⇛≤* t₁ → s ⇛≥* t₂ → ∃ λ u → t₁ ⇛≥* u × t₂ ⇛≤* u
⇛*-CR ε s⇛≥*t = _ , s⇛≥*t , ε
⇛*-CR (s⇛≤t₁ ◅ t₁⇛≤*t₂) s⇛≥*u₁ =
let u₂ , t₁⇛≥*u₂ , u₁⇛≤u₂ = ⇛-⇛*-CR s⇛≤t₁ s⇛≥*u₁
u₃ , t₂⇛≥*u₃ , u₂⇛≤*u₃ = ⇛*-CR t₁⇛≤*t₂ t₁⇛≥*u₂
in u₃ , t₂⇛≥*u₃ , u₁⇛≤u₂ ◅ u₂⇛≤*u₃
-- Thanks to Church-Rosser, thee combined multi-step reduction is
-- transitive.
⇛≤*≤⇚-trans : ∀ {s t u} → s ⇛≤*≤⇚ t → t ⇛≤*≤⇚ u → s ⇛≤*≤⇚ u
⇛≤*≤⇚-trans (v , s⇛≤*v , t⇛≥*v) (w , t⇛≤*w , u⇛≥*w) =
let u′ , w⇛≥*u′ , v⇛≤*u′ = ⇛*-CR t⇛≤*w t⇛≥*v
in u′ , (s⇛≤*v ◅◅ v⇛≤*u′ , u⇛≥*w ◅◅ w⇛≥*u′)
-- The order on SK? terms is a subrelation of the combined multi-step
-- reduction (modulo squashing).
--
-- The two orders are in fact equivalent, but we don't need that
-- result here, so we omit its proof. Instead we will establish that
-- the two relations are both equivalent to _≡SK_ on pure SK terms
-- (see inject-⇛≤*≤⇚-≡SK below).
≤SK?--⇛≤*≤⇚ : ∀ {s t} → s ≤SK? t → s ⇛≤*≤⇚ t
≤SK?--⇛≤*≤⇚ ≤?-refl = (_ , ε , ε)
≤SK?--⇛≤*≤⇚ (≤?-trans s≤t t≤u) =
⇛≤*≤⇚-trans (≤SK?--⇛≤*≤⇚ s≤t) (≤SK?--⇛≤*≤⇚ t≤u)
≤SK?--⇛≤*≤⇚ ≤?-⊥ = (_ , ⇛-⊥ ◅ ε , ε)
≤SK?--⇛≤*≤⇚ ≤?-⊤ = (_ , ε , ⇛-⊤ ◅ ε)
≤SK?--⇛≤*≤⇚ ≤?-Sred = _ , ⇛-Sred ⇛-refl ⇛-refl ⇛-refl ◅ ε , ε
≤SK?--⇛≤*≤⇚ ≤?-Kred = _ , ⇛-Kred ⇛-refl ◅ ε , ε
≤SK?--⇛≤*≤⇚ ≤?-Sexp = _ , ε , ⇛-Sred ⇛-refl ⇛-refl ⇛-refl ◅ ε
≤SK?--⇛≤*≤⇚ ≤?-Kexp = _ , ε , ⇛-Kred ⇛-refl ◅ ε
≤SK?--⇛≤*≤⇚ (≤?-· s₁≤t₁ s₂≤t₂) =
let u₁ , s₁⇛u₁ , t₁⇛u₁ = ≤SK?--⇛≤*≤⇚ s₁≤t₁
u₂ , s₂⇛u₂ , t₂⇛u₂ = ≤SK?--⇛≤*≤⇚ s₂≤t₂
in u₁ · u₂ , ⇛*-· s₁⇛u₁ s₂⇛u₂ , ⇛*-· t₁⇛u₁ t₂⇛u₂
-- Reduction preserves pure terms.
⇛-Pure : ∀ {ab s t} (ps : Pure s) → s ⇛[ ab ] t →
∃ λ pt → inject⁻¹ ps ≡SK inject⁻¹ {t} pt
⇛-Pure p ⇛-refl = p , ≡-refl
⇛-Pure (S · ps₁ · pt₁ · pu₁) (⇛-Sred s₁⇛s₂ t₁⇛t₂ u₁⇛u₂) =
let ps₂ , s₁≡s₂ = ⇛-Pure ps₁ s₁⇛s₂
pt₂ , t₁≡t₂ = ⇛-Pure pt₁ t₁⇛t₂
pu₂ , u₁≡u₂ = ⇛-Pure pu₁ u₁⇛u₂
in ps₂ · pu₂ · (pt₂ · pu₂) ,
≡-trans (≡-· (≡-· (≡-· ≡-refl s₁≡s₂) t₁≡t₂) u₁≡u₂) ≡-Sred
⇛-Pure (K · ps₁ · _) (⇛-Kred s₁⇛s₂) =
let ps₂ , s₁≡s₂ = ⇛-Pure ps₁ s₁⇛s₂
in ps₂ , ≡-trans ≡-Kred s₁≡s₂
⇛-Pure (ps · pt) (⇛-· s₁⇛s₂ t₁⇛t₂) =
Prod.zip _·_ ≡-· (⇛-Pure ps s₁⇛s₂) (⇛-Pure pt t₁⇛t₂)
⇛*-Pure : ∀ {ab s t} (ps : Pure s) → s ⇛[ ab ]* t →
∃ λ pt → inject⁻¹ ps ≡SK inject⁻¹ {t} pt
⇛*-Pure p ε = p , ≡-refl
⇛*-Pure ps (s⇛t ◅ t⇛*u) =
let pt , s≡t = ⇛-Pure ps s⇛t
pu , t≡u = ⇛*-Pure pt t⇛*u
in pu , ≡-trans s≡t t≡u
-- The combined multi-step reduction is a subrelation of ≡SK on pure terms.
inject-⇛≤*≤⇚-≡SK : ∀ {s t} → inject s ⇛≤*≤⇚ inject t → s ≡SK t
inject-⇛≤*≤⇚-≡SK {s} {t} (u , s⇛≤*u , t⇛≥*u) =
let pu , s≡u = ⇛*-Pure (inject-Pure s) s⇛≤*u
pu′ , t≡u = ⇛*-Pure (inject-Pure t) t⇛≥*u
in ≡-trans (subst (_≡SK (inject⁻¹ pu)) (inject⁻¹-inject-Pure s) s≡u)
(subst₂ (_≡SK_) (inject⁻¹-unique pu′ pu) (inject⁻¹-inject-Pure t)
(≡-sym t≡u))
-- The order on SK? terms is a subrelation of the equality on pure SK
-- terms.
--
-- NOTE. This establishes a circular equivalence between the three
-- relations _≡SK_, _⇛≤*≤⇚_ and _≤SK?_ when restricted to pure SK
-- terms:
--
-- _≡SK_ ⊆ _≤SK?_ ⊆ _⇛≤*≤⇚_ ⊆ _≡SK_
--
-- This equivalence will allow us to encode/extract equivalence proofs
-- on (pure) SK terms from typing derivations.
inject-≤SK?-≡SK : ∀ {s t} → inject s ≤SK? inject t → s ≡SK t
inject-≤SK?-≡SK {s} {t} s≤t = inject-⇛≤*≤⇚-≡SK (≤SK?--⇛≤*≤⇚ s≤t)
| 35.857143
| 81
| 0.470588
|
3995c525e88e6de9e3abb8acffe3a2fba707a220
| 404
|
agda
|
Agda
|
Cubical/HITs/Truncation/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Truncation/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Truncation/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Truncation.Base where
open import Cubical.Data.NatMinusOne
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.HITs.Sn
data ∥_∥_ {ℓ} (A : Type ℓ) (n : ℕ₋₁) : Type ℓ where
∣_∣ : A → ∥ A ∥ n
hub : (f : S (1+ n) → ∥ A ∥ n) → ∥ A ∥ n
spoke : (f : S (1+ n) → ∥ A ∥ n) (x : S (1+ n)) → hub f ≡ f x
| 28.857143
| 63
| 0.596535
|
18c46be68d78cbf01303c446f74c94f8832c8148
| 384
|
agda
|
Agda
|
Cubical/Data/NatMinusTwo/Properties.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Data/NatMinusTwo/Properties.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/Data/NatMinusTwo/Properties.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Data.NatMinusTwo.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.Data.NatMinusOne using (ℕ₋₁)
open import Cubical.Data.NatMinusTwo.Base
-2+Path : ℕ ≡ ℕ₋₂
-2+Path = isoToPath (iso -2+_ 2+_ (λ _ → refl) (λ _ → refl))
| 32
| 60
| 0.747396
|
2361a0c96969340cb498a86dbc385c823a478277
| 316
|
agda
|
Agda
|
src/SizedIO/ConsoleObject.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
src/SizedIO/ConsoleObject.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
src/SizedIO/ConsoleObject.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module SizedIO.ConsoleObject where
open import Size
open import SizedIO.Console
open import SizedIO.Object
open import SizedIO.IOObject
-- A console object is an IO object for the IO interface of console
ConsoleObject : (i : Size) → (iface : Interface) → Set
ConsoleObject i iface = IOObject consoleI iface i
| 22.571429
| 68
| 0.775316
|
cb987957c6a6f310a18aebe2450a5bf498d659cc
| 28,991
|
agda
|
Agda
|
Cubical/Data/Int/Properties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
Cubical/Data/Int/Properties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
Cubical/Data/Int/Properties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
{-
This file defines
sucPred : ∀ (i : Int) → sucInt (predInt i) ≡ i
predSuc : ∀ (i : Int) → predInt (sucInt i) ≡ i
discreteInt : discrete Int
isSetInt : isSet Int
addition of Int is defined _+_ : Int → Int → Int
as well as its commutativity and associativity
+-comm : ∀ (m n : Int) → m + n ≡ n + m
+-assoc : ∀ (m n o : Int) → m + (n + o) ≡ (m + n) + o
An alternate definition of _+_ is defined via ua,
namely _+'_, which helps us to easily prove
isEquivAddInt : (m : Int) → isEquiv (λ n → n + m)
-}
module Cubical.Data.Int.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit renaming (Unit to ⊤)
open import Cubical.Data.Nat as ℕ using (ℕ; zero; suc; discreteℕ) renaming
( _·_ to _·ⁿ_
; _+_ to _+ⁿ_
; _⊓_ to _⊓ⁿ_
; _⊔_ to _⊔ⁿ_
)
open import Cubical.Data.Nat.Order as ℕᵒ using () renaming ( _<_ to _<ⁿ_ )
open import Cubical.Data.Bool hiding (_≟_)
open import Cubical.Data.Sum
open import Cubical.Data.Int.Base
open import Cubical.Functions.Logic using (pathTo⇒; ⊔-comm)
open import Cubical.HITs.PropositionalTruncation as PropTrunc using (propTruncIsProp)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Reflection.Base using (_$_) -- TODO: add this to Foundation.Function
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
abs : Int → ℕ
abs (pos n) = n
abs (negsuc n) = suc n
Sign : Type₀
Sign = Bool
pattern spos = Bool.false
pattern sneg = Bool.true
_·ˢ_ : Sign → Sign → Sign
_·ˢ_ = _⊕_
sgn : Int → Bool
sgn (pos n) = spos
sgn (negsuc n) = sneg
signed : Sign → ℕ → Int
signed spos x = pos x
signed sneg zero = pos 0
signed sneg (suc x) = neg (suc x)
sgn-signed : ∀ s n → sgn (signed s (suc n)) ≡ s
sgn-signed spos n = refl
sgn-signed sneg n = refl
abs-signed : ∀ s n → abs (signed s n) ≡ n
abs-signed spos n = refl
abs-signed sneg zero = refl
abs-signed sneg (suc n) = refl
signed-inv : ∀ a → signed (sgn a) (abs a) ≡ a
signed-inv (pos n) = refl
signed-inv (negsuc n) = refl
signed-zero : ∀ s → signed s 0 ≡ 0
signed-zero spos = refl
signed-zero sneg = refl
signed-reflects-sgn : ∀ s₁ s₂ n m → signed s₁ (suc n) ≡ signed s₂ (suc m) → s₁ ≡ s₂
signed-reflects-sgn s₁ s₂ n m p = sym (sgn-signed s₁ n) ∙ (λ i → sgn (p i)) ∙ sgn-signed s₂ m
signed-reflects-abs : ∀ s₁ s₂ n m → signed s₁ n ≡ signed s₂ m → n ≡ m
signed-reflects-abs s₁ s₂ n m p = sym (abs-signed s₁ n) ∙ (λ i → abs (p i)) ∙ abs-signed s₂ m
sign-abs-≡ : ∀ a b → sgn a ≡ sgn b → abs a ≡ abs b → a ≡ b
sign-abs-≡ a b p q = transport (λ i → signed-inv a i ≡ signed-inv b i) λ i → signed (p i) (q i)
sucPred : ∀ i → sucInt (predInt i) ≡ i
sucPred (pos zero) = refl
sucPred (pos (suc n)) = refl
sucPred (negsuc n) = refl
predSuc : ∀ i → predInt (sucInt i) ≡ i
predSuc (pos n) = refl
predSuc (negsuc zero) = refl
predSuc (negsuc (suc n)) = refl
predInt-inj : ∀ a b → predInt a ≡ predInt b → a ≡ b
predInt-inj a b p = sym (sucPred a) ∙ cong sucInt p ∙ sucPred b
injPos : ∀ {a b : ℕ} → pos a ≡ pos b → a ≡ b
injPos {a} h = subst T h refl
where
T : Int → Type₀
T (pos x) = a ≡ x
T (negsuc _) = ⊥
injNegsuc : ∀ {a b : ℕ} → negsuc a ≡ negsuc b → a ≡ b
injNegsuc {a} h = subst T h refl
where
T : Int → Type₀
T (pos _) = ⊥
T (negsuc x) = a ≡ x
posNotnegsuc : ∀ (a b : ℕ) → ¬ (pos a ≡ negsuc b)
posNotnegsuc a b h = subst T h 0
where
T : Int → Type₀
T (pos _) = ℕ
T (negsuc _) = ⊥
negsucNotpos : ∀ (a b : ℕ) → ¬ (negsuc a ≡ pos b)
negsucNotpos a b h = subst T h 0
where
T : Int → Type₀
T (pos _) = ⊥
T (negsuc _) = ℕ
discreteInt : Discrete Int
discreteInt (pos n) (pos m) with discreteℕ n m
... | yes p = yes (cong pos p)
... | no p = no (λ x → p (injPos x))
discreteInt (pos n) (negsuc m) = no (posNotnegsuc n m)
discreteInt (negsuc n) (pos m) = no (negsucNotpos n m)
discreteInt (negsuc n) (negsuc m) with discreteℕ n m
... | yes p = yes (cong negsuc p)
... | no p = no (λ x → p (injNegsuc x))
isSetInt : isSet Int
isSetInt = Discrete→isSet discreteInt
_ℕ-_ : ℕ → ℕ → Int
a ℕ- 0 = pos a
0 ℕ- suc b = negsuc b
suc a ℕ- suc b = a ℕ- b
_+pos_ : Int → ℕ → Int
z +pos 0 = z
z +pos (suc n) = sucInt (z +pos n)
_+negsuc_ : Int → ℕ → Int
z +negsuc 0 = predInt z
z +negsuc (suc n) = predInt (z +negsuc n)
infix 8 -_
infixl 7 _·_ _⊓_
infixl 6 _+_ _-_ _⊔_
infix 4 _<_ -- _≤_
_+_ : Int → Int → Int
m + pos n = m +pos n
m + negsuc n = m +negsuc n
-- TODO: in `Cubical.Papers.RepresentationIndependence` we have
-- -_ : ℤ → ℤ
-- - x = 0 - x
-- there might be an advantage of defining -_ by _-_ and not the other way around
-- e.g. in Cubical.HITs.QuoInt we have
-- -_ : ℤ → ℤ
-- - signed s n = signed (not s) n
-- - posneg i = posneg (~ i)
-_ : Int → Int
- pos zero = pos zero
- pos (suc n) = negsuc n
- negsuc n = pos (suc n)
_-_ : Int → Int → Int
m - n = m + (- n)
_·_ : Int → Int → Int
x · y = signed (sgn x ⊕ sgn y) (abs x ·ⁿ abs y)
_<_ : ∀(x y : Int) → Type₀
pos x < pos y = x <ⁿ y
pos x < negsuc y = ⊥
negsuc x < pos y = ⊤
negsuc x < negsuc y = y <ⁿ x
_⊓_ : Int → Int → Int
(pos x) ⊓ (pos y) = pos (x ⊓ⁿ y)
(pos x) ⊓ (negsuc y) = negsuc y
(negsuc x) ⊓ (pos y) = negsuc x
(negsuc x) ⊓ (negsuc y) = negsuc (x ⊔ⁿ y)
_⊔_ : Int → Int → Int
(pos x) ⊔ (pos y) = pos (x ⊔ⁿ y)
(pos x) ⊔ (negsuc y) = pos x
(negsuc x) ⊔ (pos y) = pos y
(negsuc x) ⊔ (negsuc y) = negsuc (x ⊓ⁿ y)
neg-involutive : ∀ n → - - n ≡ n
neg-involutive (pos zero ) = refl
neg-involutive (pos (suc n)) = refl
neg-involutive (negsuc n ) = refl
neg-signed-not : ∀ s n → - signed s n ≡ signed (not s) n
neg-signed-not spos zero = refl
neg-signed-not sneg zero = refl
neg-signed-not spos (suc n) = refl
neg-signed-not sneg (suc n) = refl
neg-abs : ∀ a → abs (- a) ≡ abs a
neg-abs (pos zero) = refl
neg-abs (pos (suc n)) = refl
neg-abs (negsuc n) = refl
neg-reflects-≡ : ∀ a b → - a ≡ - b → a ≡ b
neg-reflects-≡ a b p = sym (neg-involutive a) ∙ (λ i → - p i) ∙ neg-involutive b
abs-preserves-· : ∀ a b → abs (a · b) ≡ abs a ℕ.· abs b
abs-preserves-· a b = abs-signed (sgn a ⊕ sgn b) _
sucInt+pos : ∀ n m → sucInt (m +pos n) ≡ (sucInt m) +pos n
sucInt+pos zero m = refl
sucInt+pos (suc n) m = cong sucInt (sucInt+pos n m)
predInt+negsuc : ∀ n m → predInt (m +negsuc n) ≡ (predInt m) +negsuc n
predInt+negsuc zero m = refl
predInt+negsuc (suc n) m = cong predInt (predInt+negsuc n m)
sucInt+negsuc : ∀ n m → sucInt (m +negsuc n) ≡ (sucInt m) +negsuc n
sucInt+negsuc zero m = (sucPred _) ∙ (sym (predSuc _))
sucInt+negsuc (suc n) m = _ ≡⟨ sucPred _ ⟩
m +negsuc n ≡[ i ]⟨ predSuc m (~ i) +negsuc n ⟩
(predInt (sucInt m)) +negsuc n ≡⟨ sym (predInt+negsuc n (sucInt m)) ⟩
predInt (sucInt m +negsuc n) ∎
predInt+pos : ∀ n m → predInt (m +pos n) ≡ (predInt m) +pos n
predInt+pos zero m = refl
predInt+pos (suc n) m = _ ≡⟨ predSuc _ ⟩
m +pos n ≡[ i ]⟨ sucPred m (~ i) + pos n ⟩
(sucInt (predInt m)) +pos n ≡⟨ sym (sucInt+pos n (predInt m))⟩
(predInt m) +pos (suc n) ∎
predInt+ : ∀ m n → predInt (m + n) ≡ (predInt m) + n
predInt+ m (pos n) = predInt+pos n m
predInt+ m (negsuc n) = predInt+negsuc n m
+predInt : ∀ m n → predInt (m + n) ≡ m + (predInt n)
+predInt m (pos zero) = refl
+predInt m (pos (suc n)) = (predSuc (m + pos n)) ∙ (cong (_+_ m) (sym (predSuc (pos n))))
+predInt m (negsuc n) = refl
sucInt+ : ∀ m n → sucInt (m + n) ≡ (sucInt m) + n
sucInt+ m (pos n) = sucInt+pos n m
sucInt+ m (negsuc n) = sucInt+negsuc n m
+sucInt : ∀ m n → sucInt (m + n) ≡ m + (sucInt n)
+sucInt m (pos n) = refl
+sucInt m (negsuc zero) = sucPred _
+sucInt m (negsuc (suc n)) = (sucPred (m +negsuc n)) ∙ (cong (_+_ m) (sym (sucPred (negsuc n))))
pos0+ : ∀ z → z ≡ pos 0 + z
pos0+ (pos zero) = refl
pos0+ (pos (suc n)) = cong sucInt (pos0+ (pos n))
pos0+ (negsuc zero) = refl
pos0+ (negsuc (suc n)) = cong predInt (pos0+ (negsuc n))
negsuc0+ : ∀ z → predInt z ≡ negsuc 0 + z
negsuc0+ (pos zero) = refl
negsuc0+ (pos (suc n)) = (sym (sucPred (pos n))) ∙ (cong sucInt (negsuc0+ _))
negsuc0+ (negsuc zero) = refl
negsuc0+ (negsuc (suc n)) = cong predInt (negsuc0+ (negsuc n))
ind-comm : {A : Type₀} (_∙_ : A → A → A) (f : ℕ → A) (g : A → A)
(p : ∀ {n} → f (suc n) ≡ g (f n))
(g∙ : ∀ a b → g (a ∙ b) ≡ g a ∙ b)
(∙g : ∀ a b → g (a ∙ b) ≡ a ∙ g b)
(base : ∀ z → z ∙ f 0 ≡ f 0 ∙ z)
→ ∀ z n → z ∙ f n ≡ f n ∙ z
ind-comm _∙_ f g p g∙ ∙g base z 0 = base z
ind-comm _∙_ f g p g∙ ∙g base z (suc n) =
z ∙ f (suc n) ≡[ i ]⟨ z ∙ p {n} i ⟩
z ∙ g (f n) ≡⟨ sym ( ∙g z (f n)) ⟩
g (z ∙ f n) ≡⟨ cong g IH ⟩
g (f n ∙ z) ≡⟨ g∙ (f n) z ⟩
g (f n) ∙ z ≡[ i ]⟨ p {n} (~ i) ∙ z ⟩
f (suc n) ∙ z ∎
where
IH = ind-comm _∙_ f g p g∙ ∙g base z n
ind-assoc : {A : Type₀} (_·_ : A → A → A) (f : ℕ → A)
(g : A → A) (p : ∀ a b → g (a · b) ≡ a · (g b))
(q : ∀ {c} → f (suc c) ≡ g (f c))
(base : ∀ m n → (m · n) · (f 0) ≡ m · (n · (f 0)))
(m n : A) (o : ℕ)
→ m · (n · (f o)) ≡ (m · n) · (f o)
ind-assoc _·_ f g p q base m n 0 = sym (base m n)
ind-assoc _·_ f g p q base m n (suc o) =
m · (n · (f (suc o))) ≡[ i ]⟨ m · (n · q {o} i) ⟩
m · (n · (g (f o))) ≡[ i ]⟨ m · (p n (f o) (~ i)) ⟩
m · (g (n · (f o))) ≡⟨ sym (p m (n · (f o)))⟩
g (m · (n · (f o))) ≡⟨ cong g IH ⟩
g ((m · n) · (f o)) ≡⟨ p (m · n) (f o) ⟩
(m · n) · (g (f o)) ≡[ i ]⟨ (m · n) · q {o} (~ i) ⟩
(m · n) · (f (suc o)) ∎
where
IH = ind-assoc _·_ f g p q base m n o
+-comm : ∀ m n → m + n ≡ n + m
+-comm m (pos n) = ind-comm _+_ pos sucInt refl sucInt+ +sucInt pos0+ m n
+-comm m (negsuc n) = ind-comm _+_ negsuc predInt refl predInt+ +predInt negsuc0+ m n
+-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o
+-assoc m n (pos o) = ind-assoc _+_ pos sucInt +sucInt refl (λ _ _ → refl) m n o
+-assoc m n (negsuc o) = ind-assoc _+_ negsuc predInt +predInt refl +predInt m n o
·-nullifiesʳ : ∀ x → x · 0 ≡ 0
·-nullifiesʳ (pos n) i = signed spos (ℕ.·-nullifiesʳ n i)
·-nullifiesʳ (negsuc n) i = signed sneg (ℕ.·-nullifiesʳ n i)
·-nullifiesˡ : ∀ x → 0 · x ≡ 0
·-nullifiesˡ (pos n) i = pos (ℕ.·-nullifiesˡ n i)
·-nullifiesˡ (negsuc n) = refl
+-identityʳ : ∀ x → x + 0 ≡ x
+-identityʳ x = refl
+-identityˡ : ∀ x → 0 + x ≡ x
+-identityˡ x = +-comm 0 x
·-identityʳ : ∀ x → x · 1 ≡ x
·-identityʳ x = cong₂ signed (⊕-comm (sgn x) spos) (ℕ.·-identityʳ (abs x)) ∙ signed-inv x
·-identityˡ : ∀ x → 1 · x ≡ x
·-identityˡ x = (λ i → signed (sgn x) (ℕ.+-comm (abs x) 0 i)) ∙ signed-inv x
·-comm : ∀ m n → m · n ≡ n · m
·-comm (pos m) n = cong₂ signed (⊕-comm spos (sgn n)) (ℕ.·-comm m (abs n))
·-comm (negsuc m) n = cong₂ signed (⊕-comm sneg (sgn n)) (ℕ.·-comm (suc m) (abs n))
predInt-neg : ∀ a → predInt (- a) ≡ - (sucInt a)
predInt-neg (pos zero ) = refl
predInt-neg (pos (suc n)) = refl
predInt-neg (negsuc zero ) = refl
predInt-neg (negsuc (suc n)) = refl
sucInt-neg : ∀ a → sucInt (- a) ≡ - (predInt a)
sucInt-neg (pos zero ) = refl
sucInt-neg (pos (suc zero) ) = refl
sucInt-neg (pos (suc (suc n))) = refl
sucInt-neg (negsuc zero ) = refl
sucInt-neg (negsuc (suc n) ) = refl
private
lem : ∀ n → -(0 + n) ≡ 0 - n
lem n i = +-identityˡ (- +-identityˡ n i) (~ i)
negate-+ : ∀ m n → - (m + n) ≡ (- m) + (- n)
negate-+ (pos zero) = lem
negate-+ (pos (suc m)) n = (λ i → - sucInt+ (pos m) n (~ i)) ∙ sym (predInt-neg (pos m + n)) ∙ (λ i → predInt (negate-+ (pos m) n i)) ∙ predInt+ (- pos m) (- n) ∙ λ i → predInt-neg (pos m) i + - n
negate-+ (negsuc zero) n = predInt-inj (- (negsuc zero + n)) (pos 1 + - n) $ predInt-neg (negsuc 0 + n) ∙ (λ i → - sucInt+ (negsuc 0) n i) ∙ lem n ∙ sym (predInt+ (pos 1) (- n))
negate-+ (negsuc (suc m)) n = (λ i → - predInt+ (negsuc m) n (~ i)) ∙ sym (sucInt-neg (negsuc m + n)) ∙ (λ i → sucInt (negate-+ (negsuc m) n i)) ∙ sucInt+ (pos (suc m)) (- n)
negate-·ˡ : ∀ a b → -(a · b) ≡ (- a) · b
negate-·ˡ (pos zero) b = neg-signed-not (sgn b) 0 ∙ signed-zero (not (sgn b)) ∙ sym (signed-zero (sgn b))
negate-·ˡ (pos (suc n)) b = neg-signed-not (sgn b) _
negate-·ˡ (negsuc n) b = neg-signed-not (not (sgn b)) _ ∙ cong₂ signed (notnot (sgn b)) refl
negate-·ʳ : ∀ a b → -(a · b) ≡ a · (- b)
negate-·ʳ a b = (λ i → - ·-comm a b i) ∙ negate-·ˡ b a ∙ ·-comm (- b) a
negsuc+negsuc : ∀ a x → (negsuc a +negsuc x) ≡ negsuc (suc (a +ⁿ x))
negsuc+negsuc a zero = λ i → negsuc $ suc $ ℕ.+-comm 0 a i
negsuc+negsuc a (suc x) = let r = negsuc+negsuc a x in
predInt (negsuc a +negsuc x) ≡⟨ (λ i → predInt (r i)) ⟩
predInt (negsuc (suc (a +ⁿ x))) ≡⟨ refl ⟩
negsuc (suc (suc (a +ⁿ x))) ≡⟨ (λ i → negsuc $ suc $ ℕ.+-suc a x (~ i)) ⟩
negsuc (suc (a +ⁿ suc x)) ∎
signed-distrib : ∀ s m n → signed s (m +ⁿ n) ≡ signed s m + signed s n
signed-distrib s zero n = (sym $ +-identityˡ (signed s n)) ∙ λ i → signed-zero s (~ i) + signed s n
signed-distrib spos (suc m) n = cong sucInt (signed-distrib spos m n) ∙ sucInt+pos n (pos m)
signed-distrib sneg (suc m) zero i = negsuc (ℕ.+-comm m 0 i)
signed-distrib sneg (suc m) (suc n) = (λ i → negsuc (ℕ.+-suc m n i)) ∙ sym (negsuc+negsuc m n)
·-pos-suc : ∀ m n → pos (suc m) · n ≡ n + pos m · n
·-pos-suc m n = signed-distrib (sgn n) (abs n) (m ℕ.· abs n) ∙ λ i → signed-inv n i + signed (sgn n) (m ·ⁿ abs n)
·-negsuc-suc : ∀ m n → negsuc (suc m) · n ≡ - n + negsuc m · n
·-negsuc-suc m n = signed-distrib (not (sgn n)) (abs n) (suc m ℕ.· abs n) ∙ λ i → γ i + negsuc m · n
where γ = sym (neg-signed-not (sgn n) (abs n)) ∙ cong -_ (signed-inv n)
-- this is a similar proof to the one in Cubical.HITs.QuoInt.Properties
-- but we have less definitional equalities
-- ·-assoc : ∀ m n o → m · (n · o) ≡ m · n · o
-- ·-assoc m n o with abs m | signed-inv m
-- ... | zero | pm = {! !}
-- ... | suc mⁿ | pm with abs n | signed-inv n
-- ... | zero | pn = (λ i → signed s₁ (γ₁ i)) ∙ signed-zero s₁ ∙ sym (signed-zero s₂) ∙ (λ i → signed s₂ (γ₂ i)) where
-- s₁ = sgn m ⊕ sgn (signed (sgn n ⊕ sgn o) 0)
-- s₂ = sgn (signed (sgn m ⊕ sgn n) (mⁿ ·ⁿ 0)) ⊕ sgn o
-- γ₁ = suc mⁿ ·ⁿ abs (signed (sgn n ⊕ sgn o) 0) ≡⟨ {! !} ⟩
-- suc mⁿ ·ⁿ 0 ≡⟨ {! !} ⟩
-- 0 ∎
-- γ₂ = 0 ≡⟨ {! !} ⟩
-- 0 ·ⁿ abs o ≡⟨ {! !} ⟩
-- (mⁿ ·ⁿ 0) ·ⁿ abs o ≡⟨ {! !} ⟩
-- abs (signed (sgn m ⊕ sgn n) (mⁿ ·ⁿ 0)) ·ⁿ abs o ∎
-- ... | suc nⁿ | pn with abs o | signed-inv o
-- ... | zero | po = (λ i → signed s₁ (γ₁ i)) ∙ signed-zero s₁ ∙ sym (signed-zero s₂) ∙ (λ i → signed s₂ (γ₂ i)) where
-- s₁ = sgn m ⊕ sgn (signed (sgn n ⊕ sgn o) (nⁿ ·ⁿ zero))
-- s₂ = sgn (signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ)) ⊕ sgn o
-- γ₁ = suc mⁿ ·ⁿ abs (signed (sgn n ⊕ sgn o) (nⁿ ·ⁿ 0)) ≡[ i ]⟨ suc mⁿ ·ⁿ abs-signed (sgn n ⊕ sgn o) (nⁿ ·ⁿ 0) i ⟩
-- suc mⁿ ·ⁿ (nⁿ ·ⁿ 0) ≡[ i ]⟨ suc mⁿ ·ⁿ (ℕ.·-nullifiesʳ nⁿ i) ⟩
-- suc mⁿ ·ⁿ 0 ≡⟨ ℕ.·-nullifiesʳ (suc mⁿ) ⟩
-- 0 ∎
-- γ₂ = 0 ≡⟨ sym $ ℕ.·-nullifiesʳ (abs (signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ))) ⟩
-- abs (signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ)) ·ⁿ 0 ∎
-- ... | suc oⁿ | po = cong₂ signed γ₁ γ₂ where
-- γ₁ = sgn m ⊕ sgn (signed (sgn n ⊕ sgn o) (suc nⁿ ·ⁿ suc oⁿ)) ≡[ i ]⟨ sgn m ⊕ sgn-signed (sgn n ⊕ sgn o) (oⁿ +ⁿ nⁿ ·ⁿ suc oⁿ) i ⟩
-- sgn m ⊕ (sgn n ⊕ sgn o) ≡⟨ ⊕-assoc (sgn m) (sgn n) (sgn o) ⟩
-- (sgn m ⊕ sgn n) ⊕ sgn o ≡[ i ]⟨ sgn-signed (sgn m ⊕ sgn n) (nⁿ +ⁿ mⁿ ·ⁿ suc nⁿ) (~ i) ⊕ sgn o ⟩
-- sgn (signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ)) ⊕ sgn o ∎
-- γ₂ = suc mⁿ ·ⁿ abs (signed (sgn n ⊕ sgn o) (suc nⁿ ·ⁿ suc oⁿ)) ≡[ i ]⟨ suc mⁿ ·ⁿ abs-signed (sgn n ⊕ sgn o) (suc nⁿ ·ⁿ suc oⁿ) i ⟩
-- suc mⁿ ·ⁿ (suc nⁿ ·ⁿ suc oⁿ) ≡⟨ ℕ.·-assoc (suc mⁿ) (suc nⁿ) (suc oⁿ) ⟩
-- (suc mⁿ ·ⁿ suc nⁿ) ·ⁿ suc oⁿ ≡[ i ]⟨ abs-signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ) (~ i) ·ⁿ suc oⁿ ⟩
-- abs (signed (sgn m ⊕ sgn n) (suc mⁿ ·ⁿ suc nⁿ)) ·ⁿ suc oⁿ ∎
private
lemma2 : ∀ a b c → c +ⁿ (b +ⁿ a ·ⁿ suc b) ·ⁿ suc c
≡ (c +ⁿ b ·ⁿ suc c) +ⁿ a ·ⁿ suc (c +ⁿ b ·ⁿ suc c)
lemma2 a b c =
c +ⁿ (b +ⁿ a ·ⁿ suc b) ·ⁿ suc c ≡⟨ (λ i → c +ⁿ ℕ.·-distribʳ b (a ·ⁿ suc b) (suc c) (~ i)) ⟩
c +ⁿ (b ·ⁿ suc c +ⁿ (a ·ⁿ suc b) ·ⁿ suc c) ≡⟨ ℕ.+-assoc c _ _ ⟩
(c +ⁿ b ·ⁿ suc c) +ⁿ (a ·ⁿ suc b) ·ⁿ suc c ≡⟨ (λ i → (c +ⁿ b ·ⁿ suc c) +ⁿ ℕ.·-assoc a (suc b) (suc c) (~ i)) ⟩
(c +ⁿ b ·ⁿ suc c) +ⁿ a ·ⁿ (suc b ·ⁿ suc c) ≡⟨ refl ⟩
(c +ⁿ b ·ⁿ suc c) +ⁿ a ·ⁿ suc (c +ⁿ b ·ⁿ suc c) ∎
-- this is a proof ported from the non-cubical standard library
·-assoc : ∀ x y z → (x · y) · z ≡ x · (y · z)
·-assoc (pos 0) y z = (λ i → ·-nullifiesˡ y i · z) ∙ ·-nullifiesˡ z ∙ sym (·-nullifiesˡ (y · z))
·-assoc x (pos 0) z = (λ i → ·-nullifiesʳ x i · z) ∙ ·-nullifiesˡ z ∙ sym (·-nullifiesʳ x) ∙ (λ i → x · ·-nullifiesˡ z (~ i))
·-assoc x y (pos 0) = ·-nullifiesʳ (x · y) ∙ sym (·-nullifiesʳ x) ∙ (λ i → x · ·-nullifiesʳ y (~ i))
·-assoc (negsuc a ) (negsuc b ) (pos (suc c)) i = (pos (suc (lemma2 a b c i)))
·-assoc (negsuc a ) (pos (suc b)) (negsuc c ) i = (pos (suc (lemma2 a b c i)))
·-assoc (pos (suc a)) (pos (suc b)) (pos (suc c)) i = (pos (suc (lemma2 a b c i)))
·-assoc (pos (suc a)) (negsuc b ) (negsuc c ) i = (pos (suc (lemma2 a b c i)))
·-assoc (negsuc a ) (negsuc b ) (negsuc c ) i = (negsuc (lemma2 a b c i) )
·-assoc (negsuc a ) (pos (suc b)) (pos (suc c)) i = (negsuc (lemma2 a b c i) )
·-assoc (pos (suc a)) (negsuc b ) (pos (suc c)) i = (negsuc (lemma2 a b c i) )
·-assoc (pos (suc a)) (pos (suc b)) (negsuc c ) i = (negsuc (lemma2 a b c i) )
-- this is a similar proof to the one in Cubical.HITs.QuoInt.Properties
·-distribˡ-pos : ∀ o m n → (pos o · m) + (pos o · n) ≡ pos o · (m + n)
·-distribˡ-pos zero m n = (λ i → ·-nullifiesˡ m i + ·-nullifiesˡ n i) ∙ sym (·-nullifiesˡ (m + n))
·-distribˡ-pos (suc o) m n =
pos (suc o) · m + pos (suc o) · n ≡[ i ]⟨ ·-pos-suc o m i + ·-pos-suc o n i ⟩
m + pos o · m + (n + pos o · n) ≡⟨ +-assoc (m + pos o · m) n (pos o · n) ⟩
m + pos o · m + n + pos o · n ≡[ i ]⟨ +-assoc m (pos o · m) n (~ i) + pos o · n ⟩
m + (pos o · m + n) + pos o · n ≡[ i ]⟨ m + +-comm (pos o · m) n i + pos o · n ⟩
m + (n + pos o · m) + pos o · n ≡[ i ]⟨ +-assoc m n (pos o · m) i + pos o · n ⟩
m + n + pos o · m + pos o · n ≡⟨ sym (+-assoc (m + n) (pos o · m) (pos o · n)) ⟩
m + n + (pos o · m + pos o · n) ≡⟨ cong ((m + n) +_) (·-distribˡ-pos o m n) ⟩
m + n + pos o · (m + n) ≡⟨ sym (·-pos-suc o (m + n)) ⟩
pos (suc o) · (m + n) ∎
neg-pos-neg : ∀ x → - pos x ≡ neg x
neg-pos-neg zero = refl
neg-pos-neg (suc x) = refl
·-distribˡ-neg : ∀ o m n → (neg o · m) + (neg o · n) ≡ neg o · (m + n)
·-distribˡ-neg o m n =
neg o · m + neg o · n ≡[ i ]⟨ neg-pos-neg o (~ i) · m + neg-pos-neg o (~ i) · n ⟩
- pos o · m + - pos o · n ≡[ i ]⟨ negate-·ˡ (pos o) m (~ i) + negate-·ˡ (pos o) n (~ i) ⟩
- (pos o · m) + - (pos o · n) ≡⟨ sym (negate-+ (pos o · m) (pos o · n)) ⟩
- (pos o · m + pos o · n) ≡⟨ cong -_ (·-distribˡ-pos o m n) ⟩
- (pos o · (m + n)) ≡⟨ negate-·ˡ (pos o) (m + n) ⟩
- pos o · (m + n) ≡[ i ]⟨ neg-pos-neg o i · (m + n) ⟩
neg o · (m + n) ∎
·-distribˡ : ∀ o m n → (o · m) + (o · n) ≡ o · (m + n)
·-distribˡ (pos o) m n = ·-distribˡ-pos o m n
·-distribˡ (negsuc o) m n = ·-distribˡ-neg (suc o) m n
·-distribʳ : ∀ m n o → (m · o) + (n · o) ≡ (m + n) · o
·-distribʳ m n o = (λ i → ·-comm m o i + ·-comm n o i) ∙ ·-distribˡ o m n ∙ ·-comm o (m + n)
·-neg1 : ∀ x → -1 · x ≡ - x
·-neg1 x = sym (neg-signed-not (sgn x) (abs x +ⁿ 0)) ∙ (λ i → - signed (sgn x) (ℕ.+-comm (abs x) 0 i)) ∙ cong -_ (signed-inv x)
private
possuc+negsuc≡0 : ∀ n → (pos (suc n) +negsuc n) ≡ pos 0
possuc+negsuc≡0 zero = refl
possuc+negsuc≡0 (suc n) = sym ind ∙ possuc+negsuc≡0 n where
ind = pos (suc n) +negsuc n ≡⟨ refl ⟩
predInt (pos (suc (suc n))) +negsuc n ≡⟨ sym $ predInt+negsuc n (pos (suc (suc n))) ⟩
predInt (pos (suc (suc n)) +negsuc n) ∎
sucInt[negsuc+pos]≡0 : ∀ n → sucInt (negsuc n +pos n) ≡ pos 0
sucInt[negsuc+pos]≡0 zero = refl
sucInt[negsuc+pos]≡0 (suc n) = let r = sucInt[negsuc+pos]≡0 n in sym ind ∙ r where
ind = sucInt ( negsuc n +pos n ) ≡⟨ refl ⟩
sucInt (sucInt (negsuc (suc n)) +pos n ) ≡⟨ (λ i → sucInt $ sucInt+pos n (negsuc (suc n)) (~ i)) ⟩
sucInt (sucInt (negsuc (suc n) +pos n)) ∎
+-inverseʳ : ∀ a → a + (- a) ≡ 0
+-inverseʳ (pos zero ) = refl
+-inverseʳ (pos (suc n)) = possuc+negsuc≡0 n
+-inverseʳ (negsuc n ) = sucInt[negsuc+pos]≡0 n
+-inverseˡ : ∀ a → (- a) + a ≡ 0
+-inverseˡ a = +-comm (- a) a ∙ +-inverseʳ a
-- Compose sucPathInt with itself n times. Transporting along this
-- will be addition, transporting with it backwards will be subtraction.
-- Use this to define _+'_ for which is easier to prove
-- isEquiv (λ n → n +' m) since _+'_ is defined by transport
sucPathInt : Int ≡ Int
sucPathInt = ua (sucInt , isoToIsEquiv (iso sucInt predInt sucPred predSuc))
addEq : ℕ → Int ≡ Int
addEq zero = refl
addEq (suc n) = (addEq n) ∙ sucPathInt
predPathInt : Int ≡ Int
predPathInt = ua (predInt , isoToIsEquiv (iso predInt sucInt predSuc sucPred))
subEq : ℕ → Int ≡ Int
subEq zero = refl
subEq (suc n) = (subEq n) ∙ predPathInt
_+'_ : Int → Int → Int
m +' pos n = transport (addEq n) m
m +' negsuc n = transport (subEq (suc n)) m
+'≡+ : _+'_ ≡ _+_
+'≡+ i m (pos zero) = m
+'≡+ i m (pos (suc n)) = sucInt (+'≡+ i m (pos n))
+'≡+ i m (negsuc zero) = predInt m
+'≡+ i m (negsuc (suc n)) = predInt (+'≡+ i m (negsuc n)) --
-- compPath (λ i → (+'≡+ i (predInt m) (negsuc n))) (sym (predInt+negsuc n m)) i
isEquivAddInt' : (m : Int) → isEquiv (λ n → n +' m)
isEquivAddInt' (pos n) = isEquivTransport (addEq n)
isEquivAddInt' (negsuc n) = isEquivTransport (subEq (suc n))
isEquivAddInt : (m : Int) → isEquiv (λ n → n + m)
isEquivAddInt = subst (λ add → (m : Int) → isEquiv (λ n → add n m)) +'≡+ isEquivAddInt'
-- below is an alternate proof of isEquivAddInt for comparison
-- We also have two useful lemma here.
minusPlus : ∀ m n → (n - m) + m ≡ n
minusPlus (pos zero) n = refl
minusPlus (pos 1) = sucPred
minusPlus (pos (suc (suc m))) n =
sucInt ((n +negsuc (suc m)) +pos (suc m)) ≡⟨ sucInt+pos (suc m) _ ⟩
sucInt (n +negsuc (suc m)) +pos (suc m) ≡[ i ]⟨ sucPred (n +negsuc m) i +pos (suc m) ⟩
(n - pos (suc m)) +pos (suc m) ≡⟨ minusPlus (pos (suc m)) n ⟩
n ∎
minusPlus (negsuc zero) = predSuc
minusPlus (negsuc (suc m)) n =
predInt (sucInt (sucInt (n +pos m)) +negsuc m) ≡⟨ predInt+negsuc m _ ⟩
predInt (sucInt (sucInt (n +pos m))) +negsuc m ≡[ i ]⟨ predSuc (sucInt (n +pos m)) i +negsuc m ⟩
sucInt (n +pos m) +negsuc m ≡⟨ minusPlus (negsuc m) n ⟩
n ∎
plusMinus : ∀ m n → (n + m) - m ≡ n
plusMinus (pos zero) n = refl
plusMinus (pos (suc m)) = minusPlus (negsuc m)
plusMinus (negsuc m) = minusPlus (pos (suc m))
private
alternateProof : (m : Int) → isEquiv (λ n → n + m)
alternateProof m = isoToIsEquiv (iso (λ n → n + m)
(λ n → n - m)
(minusPlus m)
(plusMinus m))
<-irrefl : ∀ a → ¬ (a < a)
<-irrefl (pos zero ) = ℕᵒ.<-irrefl 0
<-irrefl (pos (suc n)) = ℕᵒ.<-irrefl (suc n)
<-irrefl (negsuc n ) = ℕᵒ.<-irrefl n
<-trans : ∀ a b c → a < b → b < c → a < c
<-trans (pos a) (pos b) (pos c) a<b b<c = ℕᵒ.<-trans a<b b<c
<-trans (negsuc a) (pos b) (pos c) a<b b<c = tt
<-trans (negsuc a) (negsuc b) (pos c) a<b b<c = tt
<-trans (negsuc a) (negsuc b) (negsuc c) a<b b<c = ℕᵒ.<-trans b<c a<b
<-asym : ∀ a b → a < b → ¬(b < a)
<-asym a b p q = <-irrefl _ (<-trans _ _ _ p q)
private
swap-∥⊎∥ : ∀{ℓ ℓ'} (a : Type ℓ) (b : Type ℓ') → ∥ a ⊎ b ∥ → ∥ b ⊎ a ∥
swap-∥⊎∥ a b = PropTrunc.elim (λ _ → propTruncIsProp) λ{ (inl p) → ∣ inr p ∣ ; (inr p) → ∣ inl p ∣ }
<-cotrans : ∀ a b x → a < b → ∥ (a < x) ⊎ (x < b) ∥
<-cotrans (pos a) (pos b) (pos x) a<b = ℕᵒ.<-cotrans _ _ x a<b
<-cotrans (pos a) (pos b) (negsuc x) a<b = ∣ inr tt ∣
<-cotrans (negsuc a) (pos b) (pos x) a<b = ∣ inl tt ∣
<-cotrans (negsuc a) (pos b) (negsuc x) a<b = ∣ inr tt ∣
<-cotrans (negsuc a) (negsuc b) (pos x) a<b = ∣ inl tt ∣
<-cotrans (negsuc a) (negsuc b) (negsuc x) a<b = swap-∥⊎∥ _ _ (ℕᵒ.<-cotrans _ _ x a<b)
data Trichotomy (m n : Int) : Type₀ where
lt : m < n → Trichotomy m n
eq : m ≡ n → Trichotomy m n
gt : n < m → Trichotomy m n
_≟_ : ∀ m n → Trichotomy m n
pos a ≟ pos b with a ℕᵒ.≟ b
... | ℕᵒ.lt p = lt p
... | ℕᵒ.eq p = eq λ i → pos (p i)
... | ℕᵒ.gt p = gt p
pos a ≟ negsuc b = gt tt
negsuc a ≟ pos b = lt tt
negsuc a ≟ negsuc b with a ℕᵒ.≟ b
... | ℕᵒ.lt p = gt p
... | ℕᵒ.eq p = eq λ i → negsuc (p i)
... | ℕᵒ.gt p = lt p
sucInt-reflects-< : ∀ x y → sucInt x < sucInt y → x < y
sucInt-reflects-< (pos x ) (pos y ) p = ℕᵒ.suc-reflects-< x y p
sucInt-reflects-< (pos x ) (negsuc zero ) p = ℕᵒ.¬-<-zero p
sucInt-reflects-< (negsuc x ) (pos y ) p = tt
sucInt-reflects-< (negsuc zero ) (negsuc zero ) p = p
sucInt-reflects-< (negsuc (suc x)) (negsuc zero ) p = ℕᵒ.zero-<-suc x
sucInt-reflects-< (negsuc (suc x)) (negsuc (suc y)) p = ℕᵒ.suc-preserves-< y x p
predInt-reflects-< : ∀ x y → predInt x < predInt y → x < y
predInt-reflects-< (pos zero ) (pos zero ) p = p
predInt-reflects-< (pos zero ) (pos (suc y)) p = ℕᵒ.zero-<-suc y
predInt-reflects-< (pos (suc x)) (pos (suc y)) p = ℕᵒ.suc-preserves-< x y p
predInt-reflects-< (pos zero ) (negsuc y ) p = ℕᵒ.¬-<-zero p
predInt-reflects-< (negsuc x ) (pos y ) p = tt
predInt-reflects-< (negsuc x ) (negsuc y ) p = ℕᵒ.suc-reflects-< y x p
sucInt-preserves-< : ∀ x y → x < y → sucInt x < sucInt y
sucInt-preserves-< (pos x ) (pos y ) p = ℕᵒ.suc-preserves-< x y p
sucInt-preserves-< (negsuc zero ) (pos y ) p = ℕᵒ.zero-<-suc y
sucInt-preserves-< (negsuc (suc x)) (pos y ) p = tt
sucInt-preserves-< (negsuc zero ) (negsuc zero ) p = p
sucInt-preserves-< (negsuc zero ) (negsuc (suc y)) p = ℕᵒ.¬-<-zero p
sucInt-preserves-< (negsuc (suc x)) (negsuc zero ) p = tt
sucInt-preserves-< (negsuc (suc x)) (negsuc (suc y)) p = ℕᵒ.suc-reflects-< y x p
predInt-preserves-< : ∀ x y → x < y → predInt x < predInt y
predInt-preserves-< (pos zero ) (pos zero ) p = p
predInt-preserves-< (pos zero ) (pos (suc y)) p = tt
predInt-preserves-< (pos (suc x)) (pos zero ) p = ℕᵒ.¬-<-zero p
predInt-preserves-< (pos (suc x)) (pos (suc y)) p = ℕᵒ.suc-reflects-< x y p
predInt-preserves-< (negsuc x ) (pos zero ) p = ℕᵒ.zero-<-suc x
predInt-preserves-< (negsuc x ) (pos (suc y)) p = tt
predInt-preserves-< (negsuc x ) (negsuc y ) p = ℕᵒ.suc-preserves-< y x p
+-preserves-<ʳ : ∀ a b x → a < b → (a + x) < (b + x)
+-preserves-<ʳ a b (pos zero ) a<b = a<b
+-preserves-<ʳ a b (pos (suc n)) a<b = sucInt-preserves-< (a +pos n) (b +pos n) (+-preserves-<ʳ a b (pos n) a<b)
+-preserves-<ʳ a b (negsuc zero ) a<b = predInt-preserves-< a b a<b
+-preserves-<ʳ a b (negsuc (suc n)) a<b = predInt-preserves-< (a +negsuc n) (b +negsuc n) (+-preserves-<ʳ a b (negsuc n) a<b)
+-reflects-<ʳ : ∀ a b x → (a + x) < (b + x) → a < b
+-reflects-<ʳ a b x =
a + x < b + x →⟨ +-preserves-<ʳ (a + x) (b + x) (- x) ⟩
a + x - x < b + x - x →⟨ transp (λ i → +-assoc a x (- x) (~ i) < +-assoc b x (- x) (~ i)) i0 ⟩
a + (x - x) < b + (x - x) →⟨ transp (λ i → (a + +-inverseʳ x i) < (b + +-inverseʳ x i)) i0 ⟩
a + 0 < b + 0 →⟨⟩
a < b ◼
+-reflects-<ˡ : ∀ a b x → (x + a) < (x + b) → a < b
+-reflects-<ˡ a b x p = +-reflects-<ʳ a b x (transport (λ i → +-comm x a i < +-comm x b i) p)
+-<-extensional : ∀ w x y z → (w + x) < (y + z) → ∥ (w < y) ⊎ (x < z) ∥
+-<-extensional w x y z r with w ≟ y | x ≟ z
... | lt w<y | q = ∣ inl w<y ∣
... | eq w≡y | q = ∣ inr $ +-reflects-<ˡ x z y (transport (λ i → (w≡y i + x) < (y + z)) r) ∣
... | gt y<w | q = PropTrunc.elim (λ _ → propTruncIsProp) γ (<-cotrans (w + x) (y + z) (y + x) r)
where γ : _ ⊎ _ → _
γ (inl p) = ∣ inr (⊥.elim {A = λ _ → x < z} (<-asym y w y<w (+-reflects-<ʳ w y x p))) ∣
γ (inr p) = ∣ inr (+-reflects-<ˡ x z y p) ∣
| 41.238976
| 196
| 0.522921
|
3914361e87d13bd7aa5e1f021ac1d752e92f4007
| 7,242
|
agda
|
Agda
|
StructurallyRecursiveDescentParsing/Simplified/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
StructurallyRecursiveDescentParsing/Simplified/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
StructurallyRecursiveDescentParsing/Simplified/Semantics.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Semantics of the simplified parsers
------------------------------------------------------------------------
module StructurallyRecursiveDescentParsing.Simplified.Semantics where
open import Algebra
open import Coinduction
open import Data.Bool
open import Data.List
import Data.List.Properties
private
module LM {Tok : Set} = Monoid (Data.List.Properties.++-monoid Tok)
open import Data.Product as Prod
open import Function
open import Data.Empty
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import StructurallyRecursiveDescentParsing.Simplified
open import TotalParserCombinators.Parser using (○; ◌)
open import TotalParserCombinators.Semantics as Semantics
using ([_-_]_>>=_) renaming (_∈_·_ to _∈′_·_)
open Semantics._∈_·_
------------------------------------------------------------------------
-- Semantics
-- The semantics of the parsers. x ∈ p · s means that x can be the
-- result of applying the parser p to the string s. Note that the
-- semantics is defined inductively.
infixl 10 _?>>=_ _!>>=_
infix 4 _∈_·_
data _∈_·_ {Tok} : ∀ {R e} → R → Parser Tok e R → List Tok → Set1 where
return : ∀ {R} {x : R} → x ∈ return x · []
token : ∀ {x} → x ∈ token · [ x ]
∣ˡ : ∀ {R x e₁ e₂ s} {p₁ : Parser Tok e₁ R} {p₂ : Parser Tok e₂ R}
(x∈p₁ : x ∈ p₁ · s) → x ∈ p₁ ∣ p₂ · s
∣ʳ : ∀ {R x e₂ s} e₁ {p₁ : Parser Tok e₁ R} {p₂ : Parser Tok e₂ R}
(x∈p₂ : x ∈ p₂ · s) → x ∈ p₁ ∣ p₂ · s
_?>>=_ : ∀ {R₁ R₂ x y e₂ s₁ s₂}
{p₁ : Parser Tok true R₁} {p₂ : R₁ → Parser Tok e₂ R₂}
(x∈p₁ : x ∈ p₁ · s₁) (y∈p₂x : y ∈ p₂ x · s₂) →
y ∈ p₁ ?>>= p₂ · s₁ ++ s₂
_!>>=_ : ∀ {R₁ R₂ x y} {e₂ : R₁ → Bool} {s₁ s₂}
{p₁ : Parser Tok false R₁}
{p₂ : (x : R₁) → ∞ (Parser Tok (e₂ x) R₂)}
(x∈p₁ : x ∈ p₁ · s₁) (y∈p₂x : y ∈ ♭ (p₂ x) · s₂) →
y ∈ p₁ !>>= p₂ · s₁ ++ s₂
------------------------------------------------------------------------
-- _∈_·_ is correct with respect to _∈′_·_
sound : ∀ {Tok e R} {p : Parser Tok e R} {x s} →
x ∈ p · s → x ∈′ ⟦ p ⟧ · s
sound return = return
sound token = token
sound (∣ˡ x∈p₁) = cast (∣-left (sound x∈p₁))
sound (∣ʳ _ {p₁} x∈p₂) = cast (∣-right (initial p₁) (sound x∈p₂))
sound (_?>>=_ {p₂ = p₂}
x∈p₁ y∈p₂x) = cast ([_-_]_>>=_ ○ ○ {p₂ = λ x → ⟦ p₂ x ⟧}
(sound x∈p₁) (sound y∈p₂x))
sound (x∈p₁ !>>= y∈p₂x) = [ ○ - ◌ ] sound x∈p₁ >>= sound y∈p₂x
complete : ∀ {Tok e R} (p : Parser Tok e R) {x s} →
x ∈′ ⟦ p ⟧ · s → x ∈ p · s
complete (return x) return = return
complete fail ()
complete token token = token
complete (p₁ ∣ p₂) (cast (∣-left x∈p₁)) = ∣ˡ (complete p₁ x∈p₁)
complete (_∣_ {e₁} p₁ p₂) (cast (∣-right ._ x∈p₂)) = ∣ʳ e₁ (complete p₂ x∈p₂)
complete (p₁ ?>>= p₂) (cast (x∈p₁ >>= y∈p₂x)) = complete p₁ x∈p₁ ?>>= complete (p₂ _) y∈p₂x
complete (p₁ !>>= p₂) (x∈p₁ >>= y∈p₂x) = complete p₁ x∈p₁ !>>= complete (♭ (p₂ _)) y∈p₂x
------------------------------------------------------------------------
-- A lemma
-- A simple cast lemma.
cast∈ : ∀ {Tok e R} {p p′ : Parser Tok e R} {x x′ s s′} →
x ≡ x′ → p ≡ p′ → s ≡ s′ → x ∈ p · s → x′ ∈ p′ · s′
cast∈ P.refl P.refl P.refl x∈ = x∈
------------------------------------------------------------------------
-- A variant of the semantics
-- The statement x ⊕ s₂ ∈ p · s means that there is some s₁ such that
-- s ≡ s₁ ++ s₂ and x ∈ p · s₁. This variant of the semantics is
-- perhaps harder to understand, but sometimes easier to work with
-- (and it is proved equivalent to the semantics above).
infix 4 _⊕_∈_·_
data _⊕_∈_·_ {Tok} : ∀ {R e} → R → List Tok →
Parser Tok e R → List Tok → Set1 where
return : ∀ {R} {x : R} {s} → x ⊕ s ∈ return x · s
token : ∀ {x s} → x ⊕ s ∈ token · x ∷ s
∣ˡ : ∀ {R x e₁ e₂ s s₁}
{p₁ : Parser Tok e₁ R} {p₂ : Parser Tok e₂ R}
(x∈p₁ : x ⊕ s₁ ∈ p₁ · s) → x ⊕ s₁ ∈ p₁ ∣ p₂ · s
∣ʳ : ∀ {R x e₂ s s₁} e₁
{p₁ : Parser Tok e₁ R} {p₂ : Parser Tok e₂ R}
(x∈p₂ : x ⊕ s₁ ∈ p₂ · s) → x ⊕ s₁ ∈ p₁ ∣ p₂ · s
_?>>=_ : ∀ {R₁ R₂ x y e₂ s s₁ s₂}
{p₁ : Parser Tok true R₁} {p₂ : R₁ → Parser Tok e₂ R₂}
(x∈p₁ : x ⊕ s₁ ∈ p₁ · s) (y∈p₂x : y ⊕ s₂ ∈ p₂ x · s₁) →
y ⊕ s₂ ∈ p₁ ?>>= p₂ · s
_!>>=_ : ∀ {R₁ R₂ x y} {e₂ : R₁ → Bool} {s s₁ s₂}
{p₁ : Parser Tok false R₁}
{p₂ : (x : R₁) → ∞ (Parser Tok (e₂ x) R₂)}
(x∈p₁ : x ⊕ s₁ ∈ p₁ · s) (y∈p₂x : y ⊕ s₂ ∈ ♭ (p₂ x) · s₁) →
y ⊕ s₂ ∈ p₁ !>>= p₂ · s
-- The definition is sound and complete with respect to the one above.
⊕-sound′ : ∀ {Tok R e x s₂ s} {p : Parser Tok e R} →
x ⊕ s₂ ∈ p · s → ∃ λ s₁ → (s ≡ s₁ ++ s₂) × (x ∈ p · s₁)
⊕-sound′ return = ([] , P.refl , return)
⊕-sound′ {x = x} token = ([ x ] , P.refl , token)
⊕-sound′ (∣ˡ x∈p₁) with ⊕-sound′ x∈p₁
⊕-sound′ (∣ˡ x∈p₁) | (s₁ , P.refl , x∈p₁′) = (s₁ , P.refl , ∣ˡ x∈p₁′)
⊕-sound′ (∣ʳ e₁ x∈p₁) with ⊕-sound′ x∈p₁
⊕-sound′ (∣ʳ e₁ x∈p₁) | (s₁ , P.refl , x∈p₁′) = (s₁ , P.refl , ∣ʳ e₁ x∈p₁′)
⊕-sound′ (x∈p₁ ?>>= y∈p₂x) with ⊕-sound′ x∈p₁ | ⊕-sound′ y∈p₂x
⊕-sound′ (x∈p₁ ?>>= y∈p₂x) | (s₁ , P.refl , x∈p₁′) | (s₂ , P.refl , y∈p₂x′) =
(s₁ ++ s₂ , P.sym (LM.assoc s₁ s₂ _)
, x∈p₁′ ?>>= y∈p₂x′)
⊕-sound′ (x∈p₁ !>>= y∈p₂x) with ⊕-sound′ x∈p₁ | ⊕-sound′ y∈p₂x
⊕-sound′ (x∈p₁ !>>= y∈p₂x) | (s₁ , P.refl , x∈p₁′) | (s₂ , P.refl , y∈p₂x′) =
(s₁ ++ s₂ , P.sym (LM.assoc s₁ s₂ _)
, x∈p₁′ !>>= y∈p₂x′)
⊕-sound : ∀ {Tok R e x s} {p : Parser Tok e R} →
x ⊕ [] ∈ p · s → x ∈ p · s
⊕-sound x∈p with ⊕-sound′ x∈p
⊕-sound x∈p | (s , P.refl , x∈p′) with s ++ [] | proj₂ LM.identity s
⊕-sound x∈p | (s , P.refl , x∈p′) | .s | P.refl = x∈p′
extend : ∀ {Tok R e x s s′ s″} {p : Parser Tok e R} →
x ⊕ s′ ∈ p · s → x ⊕ s′ ++ s″ ∈ p · s ++ s″
extend return = return
extend token = token
extend (∣ˡ x∈p₁) = ∣ˡ (extend x∈p₁)
extend (∣ʳ e₁ x∈p₂) = ∣ʳ e₁ (extend x∈p₂)
extend (x∈p₁ ?>>= y∈p₂x) = extend x∈p₁ ?>>= extend y∈p₂x
extend (x∈p₁ !>>= y∈p₂x) = extend x∈p₁ !>>= extend y∈p₂x
⊕-complete : ∀ {Tok R e x s} {p : Parser Tok e R} →
x ∈ p · s → x ⊕ [] ∈ p · s
⊕-complete return = return
⊕-complete token = token
⊕-complete (∣ˡ x∈p₁) = ∣ˡ (⊕-complete x∈p₁)
⊕-complete (∣ʳ e₁ x∈p₂) = ∣ʳ e₁ (⊕-complete x∈p₂)
⊕-complete (x∈p₁ ?>>= y∈p₂x) = extend (⊕-complete x∈p₁) ?>>=
⊕-complete y∈p₂x
⊕-complete (x∈p₁ !>>= y∈p₂x) = extend (⊕-complete x∈p₁) !>>=
⊕-complete y∈p₂x
⊕-complete′ : ∀ {Tok R e x s₂ s} {p : Parser Tok e R} →
(∃ λ s₁ → s ≡ s₁ ++ s₂ × x ∈ p · s₁) →
x ⊕ s₂ ∈ p · s
⊕-complete′ (s₁ , P.refl , x∈p) = extend (⊕-complete x∈p)
| 44.158537
| 100
| 0.443386
|
18bcf3edd1216e277401e7a87d224ba333d98f8d
| 14,744
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Ideal.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:41.000Z
|
2022-03-05T00:29:41.000Z
|
Cubical/Algebra/CommRing/Ideal.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Ideal.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-
This is mostly for convenience, when working with ideals
(which are defined for general rings) in a commutative ring.
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Ideal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset renaming ( _∈_ to _∈p_ ; _⊆_ to _⊆p_
; subst-∈ to subst-∈p )
open import Cubical.Functions.Logic
open import Cubical.Data.Nat using (ℕ ; zero ; suc ; tt)
renaming ( --zero to ℕzero ; suc to ℕsuc
_+_ to _+ℕ_ ; _·_ to _·ℕ_
; +-assoc to +ℕ-assoc ; +-comm to +ℕ-comm
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)
open import Cubical.Data.FinData hiding (rec ; elim)
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Ring.Ideal renaming (IdealsIn to IdealsInRing)
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.RingSolver.Reflection
private
variable
ℓ : Level
IdealsIn : (R : CommRing ℓ) → Type _
IdealsIn R = IdealsInRing (CommRing→Ring R)
module _ (Ring@(R , str) : CommRing ℓ) where
open CommRingStr str
makeIdeal : (I : R → hProp ℓ)
→ (+-closed : {x y : R} → x ∈p I → y ∈p I → (x + y) ∈p I)
→ (0r-closed : 0r ∈p I)
→ (·-closedLeft : {x : R} → (r : R) → x ∈p I → r · x ∈p I)
→ IdealsIn (R , str)
makeIdeal I +-closed 0r-closed ·-closedLeft = I ,
(record
{ +-closed = +-closed
; -closed = λ x∈pI → subst-∈p I (useSolver _)
(·-closedLeft (- 1r) x∈pI)
; 0r-closed = 0r-closed
; ·-closedLeft = ·-closedLeft
; ·-closedRight = λ r x∈pI →
subst-∈p I
(·Comm r _)
(·-closedLeft r x∈pI)
})
where useSolver : (x : R) → - 1r · x ≡ - x
useSolver = solve Ring
-- better?
module CommIdeal (R' : CommRing ℓ) where
private R = fst R'
open CommRingStr (snd R')
open Sum (CommRing→Ring R')
open CommRingTheory R'
open RingTheory (CommRing→Ring R')
record isCommIdeal (I : ℙ R) : Type ℓ where
constructor
makeIsCommIdeal
field
+Closed : ∀ {x y : R} → x ∈p I → y ∈p I → (x + y) ∈p I
contains0 : 0r ∈p I
·Closed : ∀ {x : R} (r : R) → x ∈p I → r · x ∈p I
·RClosed : ∀ {x : R} (r : R) → x ∈p I → x · r ∈p I
·RClosed r x∈pI = subst-∈p I (·Comm _ _) (·Closed r x∈pI)
open isCommIdeal
isPropIsCommIdeal : (I : ℙ R) → isProp (isCommIdeal I)
+Closed (isPropIsCommIdeal I ici₁ ici₂ i) x∈pI y∈pI =
I _ .snd (ici₁ .+Closed x∈pI y∈pI) (ici₂ .+Closed x∈pI y∈pI) i
contains0 (isPropIsCommIdeal I ici₁ ici₂ i) = I 0r .snd (ici₁ .contains0) (ici₂ .contains0) i
·Closed (isPropIsCommIdeal I ici₁ ici₂ i) r x∈pI =
I _ .snd (ici₁ .·Closed r x∈pI) (ici₂ .·Closed r x∈pI) i
CommIdeal : Type (ℓ-suc ℓ)
CommIdeal = Σ[ I ∈ ℙ R ] isCommIdeal I
isSetCommIdeal : isSet CommIdeal
isSetCommIdeal = isSetΣSndProp isSetℙ isPropIsCommIdeal
--inclusion and containment of ideals
_⊆_ : CommIdeal → CommIdeal → Type ℓ
I ⊆ J = I .fst ⊆p J .fst
infix 5 _∈_
_∈_ : R → CommIdeal → Type ℓ
x ∈ I = x ∈p I .fst
subst-∈ : (I : CommIdeal) {x y : R} → x ≡ y → x ∈ I → y ∈ I
subst-∈ I = subst-∈p (I .fst)
CommIdeal≡Char : {I J : CommIdeal} → I ⊆ J → J ⊆ I → I ≡ J
CommIdeal≡Char I⊆J J⊆I = Σ≡Prop isPropIsCommIdeal (⊆-extensionality _ _ (I⊆J , J⊆I))
∑Closed : (I : CommIdeal) {n : ℕ} (V : FinVec R n)
→ (∀ i → V i ∈ I) → ∑ V ∈ I
∑Closed I {n = zero} _ _ = I .snd .contains0
∑Closed I {n = suc n} V h = I .snd .+Closed (h zero) (∑Closed I (V ∘ suc) (h ∘ suc))
0Ideal : CommIdeal
fst 0Ideal x = (x ≡ 0r) , is-set _ _
+Closed (snd 0Ideal) x≡0 y≡0 = cong₂ (_+_) x≡0 y≡0 ∙ +Rid _
contains0 (snd 0Ideal) = refl
·Closed (snd 0Ideal) r x≡0 = cong (r ·_) x≡0 ∙ 0RightAnnihilates _
1Ideal : CommIdeal
fst 1Ideal x = ⊤
+Closed (snd 1Ideal) _ _ = lift tt
contains0 (snd 1Ideal) = lift tt
·Closed (snd 1Ideal) _ _ = lift tt
contains1Is1 : (I : CommIdeal) → 1r ∈ I → I ≡ 1Ideal
contains1Is1 I 1∈I = CommIdeal≡Char (λ _ _ → lift tt)
λ x _ → subst-∈ I (·Rid _) (I .snd .·Closed x 1∈I) -- x≡x·1 ∈ I
_+i_ : CommIdeal → CommIdeal → CommIdeal
fst (I +i J) x =
(∃[ (y , z) ∈ (R × R) ] ((y ∈ I) × (z ∈ J) × (x ≡ y + z))) --have a record for this?
, isPropPropTrunc
+Closed (snd (I +i J)) {x = x₁} {y = x₂} = map2 +ClosedΣ
where
+ClosedΣ : Σ[ (y₁ , z₁) ∈ (R × R) ] ((y₁ ∈ I) × (z₁ ∈ J) × (x₁ ≡ y₁ + z₁))
→ Σ[ (y₂ , z₂) ∈ (R × R) ] ((y₂ ∈ I) × (z₂ ∈ J) × (x₂ ≡ y₂ + z₂))
→ Σ[ (y₃ , z₃) ∈ (R × R) ] ((y₃ ∈ I) × (z₃ ∈ J) × (x₁ + x₂ ≡ y₃ + z₃))
+ClosedΣ ((y₁ , z₁) , y₁∈I , z₁∈J , x₁≡y₁+z₁) ((y₂ , z₂) , y₂∈I , z₂∈J , x₂≡y₂+z₂) =
(y₁ + y₂ , z₁ + z₂) , +Closed (snd I) y₁∈I y₂∈I , +Closed (snd J) z₁∈J z₂∈J
, cong₂ (_+_) x₁≡y₁+z₁ x₂≡y₂+z₂ ∙ +ShufflePairs _ _ _ _
contains0 (snd (I +i J)) = ∣ (0r , 0r) , contains0 (snd I) , contains0 (snd J) , sym (+Rid _) ∣
·Closed (snd (I +i J)) {x = x} r = map ·ClosedΣ
where
·ClosedΣ : Σ[ (y₁ , z₁) ∈ (R × R) ] ((y₁ ∈ I) × (z₁ ∈ J) × (x ≡ y₁ + z₁))
→ Σ[ (y₂ , z₂) ∈ (R × R) ] ((y₂ ∈ I) × (z₂ ∈ J) × (r · x ≡ y₂ + z₂))
·ClosedΣ ((y₁ , z₁) , y₁∈I , z₁∈J , x≡y₁+z₁) =
(r · y₁ , r · z₁) , ·Closed (snd I) r y₁∈I , ·Closed (snd J) r z₁∈J
, cong (r ·_) x≡y₁+z₁ ∙ ·Rdist+ _ _ _
infixl 6 _+i_
+iComm⊆ : ∀ (I J : CommIdeal) → (I +i J) ⊆ (J +i I)
+iComm⊆ I J x = map λ ((y , z) , y∈I , z∈J , x≡y+z) → (z , y) , z∈J , y∈I , x≡y+z ∙ +Comm _ _
+iComm : ∀ (I J : CommIdeal) → I +i J ≡ J +i I
+iComm I J = CommIdeal≡Char (+iComm⊆ I J) (+iComm⊆ J I)
+iLidLIncl : ∀ (I : CommIdeal) → (0Ideal +i I) ⊆ I
+iLidLIncl I x = rec (I .fst x .snd) λ ((y , z) , y≡0 , z∈I , x≡y+z)
→ subst-∈ I (sym (x≡y+z ∙∙ cong (_+ z) y≡0 ∙∙ +Lid z)) z∈I
+iLidRIncl : ∀ (I : CommIdeal) → I ⊆ (0Ideal +i I)
+iLidRIncl I x x∈I = ∣ (0r , x) , refl , x∈I , sym (+Lid _) ∣
+iLid : ∀ (I : CommIdeal) → 0Ideal +i I ≡ I
+iLid I = CommIdeal≡Char (+iLidLIncl I) (+iLidRIncl I)
+iLincl : ∀ (I J : CommIdeal) → I ⊆ (I +i J)
+iLincl I J x x∈I = ∣ (x , 0r) , x∈I , J .snd .contains0 , sym (+Rid x) ∣
+iRincl : ∀ (I J : CommIdeal) → J ⊆ (I +i J)
+iRincl I J x x∈J = ∣ (0r , x) , I .snd .contains0 , x∈J , sym (+Lid x) ∣
+iRespLincl : ∀ (I J K : CommIdeal) → I ⊆ J → (I +i K) ⊆ (J +i K)
+iRespLincl I J K I⊆J x = map λ ((y , z) , y∈I , z∈K , x≡y+z) → ((y , z) , I⊆J y y∈I , z∈K , x≡y+z)
+iAssocLIncl : ∀ (I J K : CommIdeal) → (I +i (J +i K)) ⊆ ((I +i J) +i K)
+iAssocLIncl I J K x = elim (λ _ → ((I +i J) +i K) .fst x .snd) (uncurry3
λ (y , z) y∈I → elim (λ _ → isPropΠ λ _ → ((I +i J) +i K) .fst x .snd)
λ ((u , v) , u∈J , v∈K , z≡u+v) x≡y+z
→ ∣ (y + u , v) , ∣ _ , y∈I , u∈J , refl ∣ , v∈K
, x≡y+z ∙∙ cong (y +_) z≡u+v ∙∙ +Assoc _ _ _ ∣)
+iAssocRIncl : ∀ (I J K : CommIdeal) → ((I +i J) +i K) ⊆ (I +i (J +i K))
+iAssocRIncl I J K x = elim (λ _ → (I +i (J +i K)) .fst x .snd) (uncurry3
λ (y , z) → elim (λ _ → isPropΠ2 λ _ _ → (I +i (J +i K)) .fst x .snd)
λ ((u , v) , u∈I , v∈J , y≡u+v) z∈K x≡y+z
→ ∣ (u , v + z) , u∈I , ∣ _ , v∈J , z∈K , refl ∣
, x≡y+z ∙∙ cong (_+ z) y≡u+v ∙∙ sym (+Assoc _ _ _) ∣)
+iAssoc : ∀ (I J K : CommIdeal) → I +i (J +i K) ≡ (I +i J) +i K
+iAssoc I J K = CommIdeal≡Char (+iAssocLIncl I J K) (+iAssocRIncl I J K)
+iIdemLIncl : ∀ (I : CommIdeal) → (I +i I) ⊆ I
+iIdemLIncl I x = rec (I .fst x .snd) λ ((y , z) , y∈I , z∈I , x≡y+z)
→ subst-∈ I (sym x≡y+z) (I .snd .+Closed y∈I z∈I)
+iIdemRIncl : ∀ (I : CommIdeal) → I ⊆ (I +i I)
+iIdemRIncl I x x∈I = ∣ (0r , x) , I .snd .contains0 , x∈I , sym (+Lid _) ∣
+iIdem : ∀ (I : CommIdeal) → I +i I ≡ I
+iIdem I = CommIdeal≡Char (+iIdemLIncl I) (+iIdemRIncl I)
-- where to put this?
mul++dist : ∀ {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) (j : Fin (n +ℕ m))
→ ((λ i → α i · U i) ++Fin (λ i → β i · V i)) j ≡ (α ++Fin β) j · (U ++Fin V) j
mul++dist {n = zero} α U β V j = refl
mul++dist {n = suc n} α U β V zero = refl
mul++dist {n = suc n} α U β V (suc j) = mul++dist (α ∘ suc) (U ∘ suc) β V j
-- define multiplication of ideals
_·i_ : CommIdeal → CommIdeal → CommIdeal
fst (I ·i J) x = (∃[ n ∈ ℕ ] Σ[ (α , β) ∈ (FinVec R n × FinVec R n) ]
(∀ i → α i ∈ I) × (∀ i → β i ∈ J) × (x ≡ ∑ λ i → α i · β i))
, isPropPropTrunc
+Closed (snd (I ·i J)) = map2
λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ) (m , (γ , δ) , ∀γi∈I , ∀δi∈J , y≡∑γδ)
→ n +ℕ m , (α ++Fin γ , β ++Fin δ) , ++FinPres∈ (I .fst) ∀αi∈I ∀γi∈I
, ++FinPres∈ (J .fst) ∀βi∈J ∀δi∈J
, cong₂ (_+_) x≡∑αβ y≡∑γδ ∙∙ sym (∑Split++ (λ i → α i · β i) (λ i → γ i · δ i))
∙∙ ∑Ext (mul++dist α β γ δ)
contains0 (snd (I ·i J)) = ∣ 0 , ((λ ()) , (λ ())) , (λ ()) , (λ ()) , refl ∣
·Closed (snd (I ·i J)) r = map
λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ)
→ n , ((λ i → r · α i) , β) , (λ i → I .snd .·Closed r (∀αi∈I i)) , ∀βi∈J
, cong (r ·_) x≡∑αβ ∙ ∑Mulrdist r (λ i → α i · β i) ∙ ∑Ext λ i → ·Assoc r (α i) (β i)
infixl 7 _·i_
prodInProd : ∀ (I J : CommIdeal) (x y : R) → x ∈ I → y ∈ J → (x · y) ∈ (I ·i J)
prodInProd _ _ x y x∈I y∈J =
∣ 1 , ((λ _ → x) , λ _ → y) , (λ _ → x∈I) , (λ _ → y∈J) , sym (+Rid _) ∣
·iLincl : ∀ (I J : CommIdeal) → (I ·i J) ⊆ I
·iLincl I J x = elim (λ _ → I .fst x .snd)
λ (_ , (α , β) , α∈I , _ , x≡∑αβ) → subst-∈ I (sym x≡∑αβ)
(∑Closed I (λ i → α i · β i) λ i → ·RClosed (I .snd) _ (α∈I i))
·iComm⊆ : ∀ (I J : CommIdeal) → (I ·i J) ⊆ (J ·i I)
·iComm⊆ I J x = map λ (n , (α , β) , ∀αi∈I , ∀βi∈J , x≡∑αβ)
→ (n , (β , α) , ∀βi∈J , ∀αi∈I , x≡∑αβ ∙ ∑Ext (λ i → ·Comm (α i) (β i)))
·iComm : ∀ (I J : CommIdeal) → I ·i J ≡ J ·i I
·iComm I J = CommIdeal≡Char (·iComm⊆ I J) (·iComm⊆ J I)
I⊆I1 : ∀ (I : CommIdeal) → I ⊆ (I ·i 1Ideal)
I⊆I1 I x x∈I = ∣ 1 , ((λ _ → x) , λ _ → 1r) , (λ _ → x∈I) , (λ _ → lift tt) , useSolver x ∣
where
useSolver : ∀ x → x ≡ x · 1r + 0r
useSolver = solve R'
·iRid : ∀ (I : CommIdeal) → I ·i 1Ideal ≡ I
·iRid I = CommIdeal≡Char (·iLincl I 1Ideal) (I⊆I1 I)
-- a useful corollary
·iRContains1id : ∀ (I J : CommIdeal) → 1r ∈ J → I ·i J ≡ I
·iRContains1id I J 1∈J = cong (I ·i_) (contains1Is1 J 1∈J) ∙ ·iRid I
·iAssocLIncl : ∀ (I J K : CommIdeal) → (I ·i (J ·i K)) ⊆ ((I ·i J) ·i K)
·iAssocLIncl I J K x = rec isPropPropTrunc
λ (_ , (α , β) , α∈I , β∈JK , x≡∑αβ)
→ subst-∈ ((I ·i J) ·i K) (sym x≡∑αβ)
(∑Closed ((I ·i J) ·i K) (λ i → α i · β i)
λ i → rec isPropPropTrunc
(λ (_ , (γ , δ) , γ∈J , δ∈K , βi≡∑γδ)
→ subst-∈ ((I ·i J) ·i K) -- each αᵢβᵢ ≡...≡ ∑αᵢγⱼδⱼ ∈IJK
(sym (cong (α i ·_) βi≡∑γδ ∙∙ ∑Mulrdist (α i) (λ j → γ j · δ j)
∙∙ ∑Ext (λ j → ·Assoc (α i) (γ j) (δ j))))
(∑Closed ((I ·i J) ·i K) (λ j → α i · γ j · δ j) -- each αᵢγⱼδⱼ∈IJK
λ j → prodInProd (I ·i J) K _ _
(prodInProd I J _ _ (α∈I i) (γ∈J j)) (δ∈K j)))
(β∈JK i))
·iAssocRIncl : ∀ (I J K : CommIdeal) → ((I ·i J) ·i K) ⊆ (I ·i (J ·i K))
·iAssocRIncl I J K x = rec isPropPropTrunc
λ (_ , (α , β) , α∈IJ , β∈K , x≡∑αβ)
→ subst-∈ (I ·i (J ·i K)) (sym x≡∑αβ)
(∑Closed (I ·i (J ·i K)) (λ i → α i · β i)
λ i → rec isPropPropTrunc
(λ (_ , (γ , δ) , γ∈I , δ∈J , αi≡∑γδ)
→ subst-∈ (I ·i (J ·i K))
(sym (cong (_· β i) αi≡∑γδ ∙∙ ∑Mulldist (β i) (λ j → γ j · δ j)
∙∙ ∑Ext (λ j → sym (·Assoc (γ j) (δ j) (β i)))))
(∑Closed (I ·i (J ·i K)) (λ j → γ j · (δ j · β i))
λ j → prodInProd I (J ·i K) _ _ (γ∈I j)
(prodInProd J K _ _ (δ∈J j) (β∈K i))))
(α∈IJ i))
·iAssoc : ∀ (I J K : CommIdeal) → I ·i (J ·i K) ≡ (I ·i J) ·i K
·iAssoc I J K = CommIdeal≡Char (·iAssocLIncl I J K) (·iAssocRIncl I J K)
·iRdist+iLIncl : ∀ (I J K : CommIdeal) → (I ·i (J +i K)) ⊆ (I ·i J +i I ·i K)
·iRdist+iLIncl I J K x = rec isPropPropTrunc
λ (n , (α , β) , α∈I , β∈J+K , x≡∑αβ) → subst-∈ ((I ·i J) +i (I ·i K)) (sym x≡∑αβ)
(∑Closed ((I ·i J) +i (I ·i K)) (λ i → α i · β i) -- each αi·βi ∈ IJ+IK
λ i → rec isPropPropTrunc
(λ ((γi , δi) , γi∈J , δi∈K , βi≡γi+δi) →
∣ (α i · γi , α i · δi) , prodInProd I J _ _ (α∈I i) γi∈J
, prodInProd I K _ _ (α∈I i) δi∈K
, cong (α i ·_) βi≡γi+δi ∙ ·Rdist+ _ _ _ ∣)
(β∈J+K i))
·iRdist+iRIncl : ∀ (I J K : CommIdeal) → ((I ·i J) +i (I ·i K)) ⊆ (I ·i (J +i K))
·iRdist+iRIncl I J K x = rec isPropPropTrunc λ ((y , z) , y∈IJ , z∈IK , x≡y+z)
→ subst-∈ (I ·i (J +i K)) (sym x≡y+z)
((I ·i (J +i K)) .snd .+Closed (inclHelperLeft _ y∈IJ) (inclHelperRight _ z∈IK))
where
inclHelperLeft : (I ·i J) ⊆ (I ·i (J +i K))
inclHelperLeft x' = map (λ (n , (α , β) , α∈I , β∈J , x'≡∑αβ)
→ n , (α , β) , α∈I , (λ i → +iLincl J K _ (β∈J i)) , x'≡∑αβ)
inclHelperRight : (I ·i K) ⊆ (I ·i (J +i K))
inclHelperRight x' = map (λ (n , (α , β) , α∈I , β∈K , x'≡∑αβ)
→ n , (α , β) , α∈I , (λ i → +iRincl J K _ (β∈K i)) , x'≡∑αβ)
·iRdist+i : ∀ (I J K : CommIdeal) → I ·i (J +i K) ≡ I ·i J +i I ·i K
·iRdist+i I J K = CommIdeal≡Char (·iRdist+iLIncl I J K) (·iRdist+iRIncl I J K)
-- only one absorption law, i.e. CommIdeal , +i , ·i does not form a dist. lattice
·iAbsorb+iLIncl : ∀ (I J : CommIdeal) → (I +i (I ·i J)) ⊆ I
·iAbsorb+iLIncl I J x = rec (I .fst x .snd) λ ((y , z) , y∈I , z∈IJ , x≡y+z)
→ subst-∈ I (sym x≡y+z) (I .snd .+Closed y∈I (·iLincl I J _ z∈IJ))
·iAbsorb+iRIncl : ∀ (I J : CommIdeal) → I ⊆ (I +i (I ·i J))
·iAbsorb+iRIncl I J = +iLincl I (I ·i J)
·iAbsorb+i : ∀ (I J : CommIdeal) → I +i (I ·i J) ≡ I
·iAbsorb+i I J = CommIdeal≡Char (·iAbsorb+iLIncl I J) (·iAbsorb+iRIncl I J)
| 44.409639
| 100
| 0.46134
|
1c2557630e16713cfd25cafd018df3bd630d35bd
| 2,847
|
agda
|
Agda
|
test/interaction/Highlighting.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2021-06-14T11:08:59.000Z
|
2021-06-14T11:08:59.000Z
|
test/interaction/Highlighting.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2020-05-29T19:45:38.000Z
|
2020-05-29T19:45:38.000Z
|
test/interaction/Highlighting.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2021-06-14T11:07:38.000Z
|
2021-06-14T11:07:38.000Z
|
module Highlighting where
Set-one : Set₂
Set-one = Set₁
record R (A : Set) : Set-one where
constructor con
field X : Set
F : Set → Set → Set
F A B = B
field P : F A X → Set
-- highlighting of non-terminating definition
Q : F A X → Set
Q = Q
postulate P : _
open import Highlighting.M using (ℕ) renaming
( _+_ to infixl 5 _⊕_
; _*_ to infixl 7 _⊗_
)
data D (A : Set) : Set-one where
d : let X = D in X A
postulate _+_ _×_ : Set → Set → Set
infixl 4 _×_ _+_
-- Issue #2140: the operators should be highlighted also in the
-- fixity declaration.
-- Issue #3120, jump-to-definition for record field tags
-- in record expressions and patterns.
anR : ∀ A → R A
anR A = record { X = A ; P = λ _ → A }
idR : ∀ A → R A → R A
idR A r@record { X = X; P = P } = record r { X = X }
record S (A : Set) : Set where
field
X : A
idR' : ∀ A → R A → R A
idR' A r@record { X = X; P = P } = record r { X = X }
open S
bla : ∀{A} → A → S A
bla x .X = x
-- Issue #3825: highlighting of unsolved metas in record{M} expressions
record R₂ (A : Set) : Set where
field
impl : {a : A} → A
module M {A : Set} where
impl : {a : A} → A -- yellow should not be here
impl {a} = a
r₂ : ∀{A} → R₂ A
r₂ = record {M} -- just because there is an unsolved meta here
-- End issue #3825
-- Issue #3855: highlighting of quantity attributes.
-- @0 and @erased should be highlighted as symbols.
idPoly0 : {@0 A : Set} → A → A
idPoly0 x = x
idPolyE : {@erased A : Set} → A → A
idPolyE x = x
-- Issue #3989: Shadowed repeated variables in telescopes should by
-- default /not/ be highlighted.
Issue-3989 : (A A : Set) → Set
Issue-3989 _ A = A
-- Issue #4356.
open import Agda.Builtin.Sigma
Issue-4356₁ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set)
Issue-4356₁ = λ P@(A , B) → P
Issue-4356₂ : Σ Set (λ _ → Set) → Set
Issue-4356₂ = λ (A , B) → A
Issue-4356₃ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set)
Issue-4356₃ P = let Q@(A , B) = P in Q
Issue-4356₄ : Σ Set (λ _ → Set) → Set
Issue-4356₄ P = let (A , B) = P in B
Issue-4356₅ : Σ Set (λ _ → Set) → Σ Set (λ _ → Set)
Issue-4356₅ P@(A , B) = P
Issue-4356₆ : Σ Set (λ _ → Set) → Set
Issue-4356₆ (A , B) = B
-- Issue #4361: Highlighting builtins.
data Nat : Set where
zero : Nat
suc : Nat → Nat
{-# BUILTIN NATURAL Nat #-} -- NATURAL should be highlighted as keyword.
module Issue3432 where
pattern con′ x y = con x y
pattern d′ = d
open Issue3432 using (con′; d′)
-- These pattern synonyms should be highlighted
-- in inductive constructor color.
module Issue4604 where
record RR : Set₁ where
field
A : Set
postulate
rr : RR
open RR rr
rr₁ : RR
rr₁ = record { A = A } -- Second A should /not/ be highlighted as projection.
rr₂ : RR
rr₂ = record { A = RR.A rr } -- All other As should have field/projection color.
| 20.049296
| 83
| 0.60274
|
182592552899978b9473244fda99c811a34f13de
| 800
|
agda
|
Agda
|
test/Succeed/RewriteExt.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/RewriteExt.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/RewriteExt.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --rewriting #-}
-- Let us assume that extensionality of functions cannot be proved
-- inside "plain" Agda. In that case the code below shows that the
-- REWRITE functionality is not a conservative extension, even if we
-- only use propositional equality as the rewriting relation, and do
-- not use any postulates.
module RewriteExt where
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
data Unit : Set where
unit : Unit
module _ {a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x}
(f≡g : ∀ x → f x ≡ g x) where
private
id : Unit → (x : A) → B x → B x
id unit _ x = x
f≡g′ : ∀ u x → id u x (f x) ≡ g x
f≡g′ unit = f≡g
{-# REWRITE f≡g′ #-}
ext′ : ∀ u → (λ x → id u x (f x)) ≡ g
ext′ u = refl
ext : f ≡ g
ext = ext′ unit
| 22.222222
| 68
| 0.58
|
dfac09952cde29acbeeda4165ead2fa1142bab6d
| 1,746
|
agda
|
Agda
|
src/Categories/Category/Construction/LT-Models.agda
|
yourboynico/agda-categories
|
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Category/Construction/LT-Models.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Category/Construction/LT-Models.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Construction.LT-Models where
-- Given a fixed Lawvere Theory LT and a fixed category C,
-- the Functors [LT , C] form a category.
-- The proof is basically the same as that of Functors.
open import Level
open import Categories.Category.Core using (Category)
open import Categories.Category.Cartesian.Bundle using (CartesianCategory)
open import Categories.Category.Monoidal.Instance.Setoids using (Setoids-CartesianCategory)
open import Categories.NaturalTransformation
using (NaturalTransformation; _∘ᵥ_) renaming (id to idN)
open import Categories.NaturalTransformation.Equivalence using (_≃_; ≃-isEquivalence)
open import Categories.Theory.Lawvere using (LawvereTheory; ModelsOf_In_)
private
variable
o ℓ e o′ ℓ′ e′ : Level
-- The reason the proofs below are so easy is that _∘ᵥ_ 'computes' all the way down into
-- expressions in C, from which the properties follow.
LT-Models : LawvereTheory ℓ e → CartesianCategory o′ ℓ′ e′ → Category (ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) (ℓ ⊔ ℓ′ ⊔ e′) e′
LT-Models LT C = record
{ Obj = ModelsOf LT In C
; _⇒_ = λ m₁ m₂ → NaturalTransformation (ModelsOf_In_.mod m₁) (ModelsOf_In_.mod m₂)
; _≈_ = _≃_
; id = idN
; _∘_ = _∘ᵥ_
; assoc = assoc
; sym-assoc = sym-assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identity²
; equiv = ≃-isEquivalence
; ∘-resp-≈ = λ eq eq′ → ∘-resp-≈ eq eq′
}
where
module C = CartesianCategory C using (U)
open Category C.U
LT-SetoidsModels : {ℓ′ e′ : Level} → LawvereTheory ℓ e → Category (ℓ ⊔ e ⊔ suc (ℓ′ ⊔ e′)) (ℓ ⊔ ℓ′ ⊔ e′) (ℓ′ ⊔ e′)
LT-SetoidsModels {ℓ′ = ℓ′} {e′} LT = LT-Models LT (Setoids-CartesianCategory ℓ′ e′)
| 37.956522
| 113
| 0.67984
|
0ed9f8f71aa031d23e01cf143fe8f6c055fa21d0
| 700
|
agda
|
Agda
|
test/fail/Test2.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
test/fail/Test2.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
test/fail/Test2.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Base
module test.fail.Test2 where
module _ where
private
data #I : Type₀ where
#zero : #I
#one : #I
I : Type₀
I = #I
zero : I
zero = #zero
one : I
one = #one
postulate
seg : zero == one
I-elim : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ]) → Π I P
I-elim {i} {P} zero* one* seg* = I-elim-aux phantom where
I-elim-aux : Phantom seg* → Π I P
I-elim-aux phantom #zero = zero*
I-elim-aux phantom #one = one*
postulate
P : I → Type₀
z : P zero
o : P one
s s' : z == o [ P ↓ seg ]
absurd : I-elim z o s == I-elim z o s'
absurd = idp
| 16.666667
| 65
| 0.518571
|
4ae6881b739baafb17439590a32112ce22cc232e
| 439
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Plus.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Plus.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Plus.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Transitive closures
--
-- This module is DEPRECATED. Please use the
-- Relation.Binary.Construct.Closure.Transitive module directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Plus where
open import Relation.Binary.Construct.Closure.Transitive public
| 29.266667
| 72
| 0.505695
|
d0b7c977bc49c33c943f6c86e87586eb5133e9c2
| 1,969
|
agda
|
Agda
|
src/prototyping/term/examples/Nested.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
src/prototyping/term/examples/Nested.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
src/prototyping/term/examples/Nested.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
{-# OPTIONS --type-in-type #-}
module Nested where
open import Prelude
record Sigma1 (A : Set)(B : A -> Set) : Set
record Sigma1 A B where
constructor pair
field
fst : A
snd : B fst
open Sigma1
record Sigma (A : Set)(B : A -> Set) : Set
record Sigma A B where
constructor inn
field
out : Sigma1 A B
open Sigma
data Unit : Set
data Unit where
tt : Unit
Cat : Set
Cat =
Sigma Set (\ Obj ->
Sigma (Obj -> Obj -> Set) (\ Hom ->
Sigma ((X : _) -> Hom X X) (\ id ->
Sigma ((X Y Z : _) -> Hom Y Z -> Hom X Y -> Hom X Z) (\ comp ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ (id Y) f == f) (\ idl ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ f (id X) == f) (\ idr ->
Sigma ((W X Y Z : _)
(f : Hom W X)(g : Hom X Y)(h : Hom Y Z) ->
comp _ _ _ (comp _ _ _ h g) f ==
comp _ _ _ h (comp _ _ _ g f)) (\ assoc ->
Unit)))))))
Obj : (C : Cat) -> Set
Obj C = fst (out C)
Hom : (C : Cat) -> Obj C -> Obj C -> Set
Hom C = fst (out (snd (out C)))
id : (C : Cat) -> (X : _) -> Hom C X X
id C = fst (out (snd (out (snd (out C)))))
comp : (C : Cat) -> (X Y Z : _) -> Hom C Y Z -> Hom C X Y -> Hom C X Z
comp C = fst (out (snd (out (snd (out (snd (out C)))))))
idl : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ (id C Y) f == f
idl C = fst (out (snd (out (snd (out (snd (out (snd (out C)))))))))
idr : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ f (id C X) == f
idr C = fst (out (snd (out (snd (out (snd (out
(snd (out (snd (out C)))))))))))
assoc : (C : Cat) ->
(W X Y Z : _) (f : Hom C W X)(g : Hom C X Y)(h : Hom C Y Z) ->
comp C _ _ _ (comp C _ _ _ h g) f ==
comp C _ _ _ h (comp C _ _ _ g f)
assoc C = fst (out (snd (out (snd (out (snd (out
(snd (out (snd (out (snd (out C)))))))))))))
| 28.955882
| 72
| 0.439309
|
cbbff044d27e518a5bb6861e7bcb56cf776b3706
| 9,294
|
agda
|
Agda
|
agda/book/Programming_Language_Foundations_in_Agda/x05-747Isomorphism.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 36
|
2015-01-29T14:37:15.000Z
|
2021-07-30T06:55:03.000Z
|
agda/book/Programming_Language_Foundations_in_Agda/x05-747Isomorphism.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | null | null | null |
agda/book/Programming_Language_Foundations_in_Agda/x05-747Isomorphism.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 8
|
2015-04-13T21:40:15.000Z
|
2021-09-21T15:58:10.000Z
|
module 747Isomorphism where
-- Library
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; cong-app; sym) -- added last
open Eq.≡-Reasoning
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties using (+-comm; +-suc; +-identityʳ) -- added last
-- Function composition.
_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)
(g ∘ f) x = g (f x)
_∘′_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)
g ∘′ f = λ x → g (f x)
postulate
extensionality : ∀ {A B : Set} {f g : A → B}
→ (∀ (x : A) → f x ≡ g x)
-----------------------
→ f ≡ g
-- Another definition of addition.
_+′_ : ℕ → ℕ → ℕ -- split on n instead, get different code
m +′ n = {!!}
same-app : ∀ (m n : ℕ) → m +′ n ≡ m + n
same-app m n = {!!}
same : _+′_ ≡ _+_ -- this requires extensionality
same = {!!}
-- Isomorphism.
infix 0 _≃_
record _≃_ (A B : Set) : Set where
constructor mk-≃ -- This has been added, not in PLFA
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
to∘from : ∀ (y : B) → to (from y) ≡ y
open _≃_
-- Equivalent to the following:
data _≃′_ (A B : Set): Set where
mk-≃′ : ∀ (to : A → B) →
∀ (from : B → A) →
∀ (from∘to : (∀ (x : A) → from (to x) ≡ x)) →
∀ (to∘from : (∀ (y : B) → to (from y) ≡ y)) →
A ≃′ B
to′ : ∀ {A B : Set} → (A ≃′ B) → (A → B)
to′ (mk-≃′ f g g∘f f∘g) = f
from′ : ∀ {A B : Set} → (A ≃′ B) → (B → A)
from′ (mk-≃′ f g g∘f f∘g) = g
from∘to′ : ∀ {A B : Set} → (A≃B : A ≃′ B)
→ (∀ (x : A)
→ from′ A≃B (to′ A≃B x) ≡ x)
from∘to′ (mk-≃′ f g g∘f f∘g) = g∘f
to∘from′ : ∀ {A B : Set} → (A≃B : A ≃′ B)
→ (∀ (y : B)
→ to′ A≃B (from′ A≃B y) ≡ y)
to∘from′ (mk-≃′ f g g∘f f∘g) = f∘g
-- End of equivalent formulation (records are faster!)
-- Properties of isomorphism.
-- Reflexivity.
≃-refl : ∀ {A : Set}
-----
→ A ≃ A
-- in empty hole, split on result, get copatterns (not in PLFA)
≃-refl = {!!}
-- Symmetry.
≃-sym : ∀ {A B : Set}
→ A ≃ B
-----
→ B ≃ A
≃-sym A≃B = {!!}
-- Transitivity.
≃-trans : ∀ {A B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
≃-trans A≃B B≃C = {!!}
-- Isomorphism is an equivalence relation.
-- We can create syntax for equational reasoning.
module ≃-Reasoning where
infix 1 ≃-begin_
infixr 2 _≃⟨_⟩_
infix 3 _≃-∎
≃-begin_ : ∀ {A B : Set}
→ A ≃ B
-----
→ A ≃ B
≃-begin A≃B = A≃B
_≃⟨_⟩_ : ∀ (A : Set) {B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C
_≃-∎ : ∀ (A : Set)
-----
→ A ≃ A
A ≃-∎ = ≃-refl
open ≃-Reasoning
-- Embedding (weaker than isomorphism)
infix 0 _≲_
record _≲_ (A B : Set) : Set where
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
open _≲_
≲-refl : ∀ {A : Set} → A ≲ A
≲-refl = {!!}
≲-trans : ∀ {A B C : Set} → A ≲ B → B ≲ C → A ≲ C
≲-trans A≲B B≲C = {!!}
≲-antisym : ∀ {A B : Set}
→ (A≲B : A ≲ B)
→ (B≲A : B ≲ A)
→ (to A≲B ≡ from B≲A)
→ (from A≲B ≡ to B≲A)
-------------------
→ A ≃ B
≲-antisym A≲B B≲A to≡from from≡to = {!!}
-- Tabular reasoning for embedding.
module ≲-Reasoning where
infix 1 ≲-begin_
infixr 2 _≲⟨_⟩_
infix 3 _≲-∎
≲-begin_ : ∀ {A B : Set}
→ A ≲ B
-----
→ A ≲ B
≲-begin A≲B = A≲B
_≲⟨_⟩_ : ∀ (A : Set) {B C : Set}
→ A ≲ B
→ B ≲ C
-----
→ A ≲ C
A ≲⟨ A≲B ⟩ B≲C = ≲-trans A≲B B≲C
_≲-∎ : ∀ (A : Set)
-----
→ A ≲ A
A ≲-∎ = ≲-refl
open ≲-Reasoning
-- PLFA exercise: Isomorphism implies embedding.
≃-implies-≲ : ∀ {A B : Set}
→ A ≃ B
-----
→ A ≲ B
≃-implies-≲ a≃b = {!!}
-- PLFA exercise: propositional equivalence (weaker than embedding).
record _⇔_ (A B : Set) : Set where
field
to : A → B
from : B → A
open _⇔_ -- added
-- This is also an equivalence relation.
⇔-refl : ∀ {A : Set}
-----
→ A ⇔ A
⇔-refl = {!!}
⇔-sym : ∀ {A B : Set}
→ A ⇔ B
-----
→ B ⇔ A
⇔-sym A⇔B = {!!}
⇔-trans : ∀ {A B C : Set}
→ A ⇔ B
→ B ⇔ C
-----
→ A ⇔ C
⇔-trans A⇔B B⇔C = {!!}
-- 747/PLFA extended exercise: Canonical bitstrings.
-- Modified and extended from Bin-predicates exercise in PLFA Relations.
-- Copied from 747Naturals.
data Bin-ℕ : Set where
bits : Bin-ℕ
_x0 : Bin-ℕ → Bin-ℕ
_x1 : Bin-ℕ → Bin-ℕ
dbl : ℕ → ℕ
dbl zero = zero
dbl (suc n) = suc (suc (dbl n))
-- Copy your versions of 'inc', 'tob', and 'fromb' over from earlier files.
-- You may choose to change the definitions here to make proofs easier.
-- But make sure to test them if you do!
-- You may also copy over any theorems that prove useful.
inc : Bin-ℕ → Bin-ℕ
inc n = {!!}
tob : ℕ → Bin-ℕ
tob n = {!!}
dblb : Bin-ℕ → Bin-ℕ
dblb n = {!!}
fromb : Bin-ℕ → ℕ
fromb n = {!!}
-- The reason that we couldn't prove ∀ {n : Bin-ℕ} → tob (fromb n) ≡ n
-- is because of the possibility of leading zeroes in a Bin-ℕ value.
-- 'bits x0 x0 x1' is such a value that gives a counterexample.
-- However, the theorem is true is true for n without leading zeroes.
-- We define a predicate to be able to state this in a theorem.
-- A value of type One n is evidence that n has a leading one.
data One : Bin-ℕ → Set where
[bitsx1] : One (bits x1)
_[x0] : ∀ {n : Bin-ℕ} → One n → One (n x0)
_[x1] : ∀ {n : Bin-ℕ} → One n → One (n x1)
-- Here's a proof that 'bits x1 x0 x0' has a leading one.
_ : One (bits x1 x0 x0)
_ = [bitsx1] [x0] [x0]
-- There is no value of type One (bits x0 x0 x1).
-- But we can't state and prove this yet, because we don't know
-- how to express negation. That comes in the Connectives chapter.
-- A canonical binary representation is either zero or has a leading one.
data Can : Bin-ℕ → Set where
[zero] : Can bits
[pos] : ∀ {n : Bin-ℕ} → One n → Can n
-- Some obvious examples:
_ : Can bits
_ = [zero]
_ : Can (bits x1 x0)
_ = [pos] ([bitsx1] [x0])
-- The Bin-predicates exercise in PLFA Relations gives three properties of canonicity.
-- The first is that the increment of a canonical number is canonical.
-- Most of the work is done in the following lemma.
-- 747/PLFA exercise: IncCanOne (2 points)
-- The increment of a canonical number has a leading one.
one-inc : ∀ {n : Bin-ℕ} → Can n → One (inc n)
one-inc cn = {!!}
-- The first canonicity property is now an easy corollary.
-- 747/PLFA exercise: OneInc (1 point)
can-inc : ∀ {n : Bin-ℕ} → Can n → Can (inc n)
can-inc cn = {!!}
-- The second canonicity property is that converting a unary number
-- to binary produces a canonical number.
-- 747/PLFA exercise: CanToB (1 point)
to-can : ∀ (n : ℕ) → Can (tob n)
to-can n = {!!}
-- The third canonicity property is that converting a canonical number
-- from binary and back to unary produces the same number.
-- This takes more work, and some helper lemmas from 747Induction.
-- You will need to discover which ones.
-- 747/PLFA exercise: OneDblbX0 (1 point)
-- This helper function relates binary double to the x0 constructor,
-- for numbers with a leading one.
dblb-x0 : ∀ {n : Bin-ℕ} → One n → dblb n ≡ n x0
dblb-x0 on = {!!}
-- We can now prove the third property for numbers with a leading one.
-- 747/PLFA exercise: OneToFrom (3 points)
one-to∘from : ∀ {n : Bin-ℕ} → One n → tob (fromb n) ≡ n
one-to∘from on = {!!}
-- The third property is now an easy corollary.
-- 747/PLFA exercise: CanToFrom (1 point)
can-to∘from : ∀ {n : Bin-ℕ} → Can n → tob (fromb n) ≡ n
can-to∘from cn = {!!}
-- 747/PLFA exercise: OneUnique (2 points)
-- Proofs of positivity are unique.
one-unique : ∀ {n : Bin-ℕ} → (x y : One n) → x ≡ y
one-unique x y = {!!}
-- 747/PLFA exercise: CanUnique (1 point)
-- Proofs of canonicity are unique.
can-unique : ∀ {n : Bin-ℕ} → (x y : Can n) → x ≡ y
can-unique x y = {!!}
-- Do we have an isomorphism between ℕ (unary) and canonical binary representations?
-- Can is not a set, but a family of sets, so it doesn't quite fit
-- into our framework for isomorphism.
-- But we can roll all the values into one set which is isomorphic to ℕ.
-- A CanR value wraps up a Bin-ℕ and proof it has a canonical representation.
data CanR : Set where
wrap : ∀ (n : Bin-ℕ) → Can n → CanR
-- We can show that there is an isomorphism between ℕ and CanR.
-- 747/PLFA exercise: IsoNCanR (3 points)
iso-ℕ-CanR : ℕ ≃ CanR
iso-ℕ-CanR = {!!}
-- Can we get an isomorphism between ℕ and some binary encoding,
-- without the awkwardness of non-canonical values?
-- Yes: we use digits 1 and 2, instead of 0 and 1 (multiplier/base is still 2).
-- This is known as bijective binary numbering.
-- The counting sequence goes <empty>, 1, 2, 11, 12, 21, 22, 111...
data Bij-ℕ : Set where
bits : Bij-ℕ
_x1 : Bij-ℕ → Bij-ℕ
_x2 : Bij-ℕ → Bij-ℕ
-- There is an isomorphism between ℕ and Bij-ℕ.
-- The proof largely follows the outline of what we did above,
-- and is left as an optional exercise.
-- See PLFA for remarks on standard library definitions similar to those here.
-- Unicode introduced in this chapter:
{-
∘ U+2218 RING OPERATOR (\o, \circ, \comp)
λ U+03BB GREEK SMALL LETTER LAMBDA (\lambda, \Gl)
≃ U+2243 ASYMPTOTICALLY EQUAL TO (\~-)
≲ U+2272 LESS-THAN OR EQUIVALENT TO (\<~)
⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\<=>)
-}
| 22.891626
| 87
| 0.561222
|
1c3cacb01ebe3bf43f85d17a1489ceae3d9a62b1
| 2,689
|
agda
|
Agda
|
src/Pf/Ip.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | 26
|
2015-08-31T09:49:52.000Z
|
2021-11-13T12:37:44.000Z
|
src/Pf/Ip.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
src/Pf/Ip.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
-- Intuitionistic propositional logic, PHOAS approach, final encoding
module Pf.Ip where
-- Types
infixl 2 _&&_
infixl 1 _||_
infixr 0 _=>_
data Ty : Set where
UNIT : Ty
_=>_ : Ty -> Ty -> Ty
_&&_ : Ty -> Ty -> Ty
_||_ : Ty -> Ty -> Ty
FALSE : Ty
infixr 0 _<=>_
_<=>_ : Ty -> Ty -> Ty
a <=> b = (a => b) && (b => a)
NOT : Ty -> Ty
NOT a = a => FALSE
TRUE : Ty
TRUE = FALSE => FALSE
-- Context and truth judgement
Cx : Set1
Cx = Ty -> Set
isTrue : Ty -> Cx -> Set
isTrue a tc = tc a
-- Terms
TmRepr : Set1
TmRepr = Cx -> Ty -> Set
module ArrMp where
record Tm (tr : TmRepr) : Set1 where
infixl 1 _$_
field
var : forall {tc a} -> isTrue a tc -> tr tc a
lam' : forall {tc a b} -> (isTrue a tc -> tr tc b) -> tr tc (a => b)
_$_ : forall {tc a b} -> tr tc (a => b) -> tr tc a -> tr tc b
lam'' : forall {tc a b} -> (tr tc a -> tr tc b) -> tr tc (a => b)
lam'' f = lam' \x -> f (var x)
syntax lam'' (\a -> b) = lam a => b
open Tm {{...}} public
module Mp where
record Tm (tr : TmRepr) : Set1 where
field
pair' : forall {tc a b} -> tr tc a -> tr tc b -> tr tc (a && b)
fst : forall {tc a b} -> tr tc (a && b) -> tr tc a
snd : forall {tc a b} -> tr tc (a && b) -> tr tc b
left : forall {tc a b} -> tr tc a -> tr tc (a || b)
right : forall {tc a b} -> tr tc b -> tr tc (a || b)
case' : forall {tc a b c} -> tr tc (a || b) -> (isTrue a tc -> tr tc c) -> (isTrue b tc -> tr tc c) -> tr tc c
isArrMp : ArrMp.Tm tr
open ArrMp.Tm isArrMp public
case'' : forall {tc a b c} -> tr tc (a || b) -> (tr tc a -> tr tc c) -> (tr tc b -> tr tc c) -> tr tc c
case'' xy f g = case' xy (\x -> f (var x)) (\y -> g (var y))
syntax pair' x y = [ x , y ]
syntax case'' xy (\x -> z1) (\y -> z2) = case xy of x => z1 or y => z2
open Tm {{...}} public
module Ip where
record Tm (tr : TmRepr) : Set1 where
field
abort : forall {tc a} -> tr tc FALSE -> tr tc a
isMp : Mp.Tm tr
open Mp.Tm isMp public
open Tm {{...}} public
Thm : Ty -> Set1
Thm a = forall {tr tc} {{_ : Tm tr}} -> tr tc a
open Ip public
-- Example theorems
t1 : forall {a b} -> Thm (a => NOT a => b)
t1 =
lam x =>
lam f => abort (f $ x)
t2 : forall {a b} -> Thm (NOT a => a => b)
t2 =
lam f =>
lam x => abort (f $ x)
t3 : forall {a} -> Thm (a => NOT (NOT a))
t3 =
lam x =>
lam f => f $ x
t4 : forall {a} -> Thm (NOT a <=> NOT (NOT (NOT a)))
t4 =
[ lam f =>
lam g => g $ f
, lam g =>
lam x => g $ (lam f => f $ x)
]
| 23.382609
| 116
| 0.462626
|
2360614957271cf794edfcef3809bcbca96c8e77
| 1,501
|
agda
|
Agda
|
test/Succeed/FlexibleFunArity.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/FlexibleFunArity.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/FlexibleFunArity.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS -v tc.lhs:40 #-}
module FlexibleFunArity where
open import Common.Equality
open import Common.Prelude
Case : {A : Set} → Maybe A → Set → Set → Set
Case nothing B C = B
Case (just _) B C = C
sample : {A : Set} (m : Maybe A) → Case m Bool (Maybe A → Bool)
sample (just a) (just b) = true
sample (just a) nothing = false
sample nothing = true
g : Bool -> Bool -> Bool
g false true = false
g true = \ x -> true
g false false = true
-- g true false = false -- Unreachable clause
testg1 : ∀ {x} → g true x ≡ true
testg1 = refl
testg2 : g false true ≡ false
testg2 = refl
testg3 : g false false ≡ true
testg3 = refl
T : Bool -> Set
T true = Bool
T false = Bool -> Bool
f : (b : Bool) -> T b
f false true = false
f false false = true
f true = true
testf1 : f true ≡ true
testf1 = refl
testf2 : f false true ≡ false
testf2 = refl
testf3 : f false false ≡ true
testf3 = refl
{- checking clause
f false true
starts with
f (b : Bool) : T b
splits on b
f true -- no match, discard
f false -- matches
instantiate type
f false : T false = Bool -> Bool
extend clause
f false (y : Bool) : Bool
split on y
f false true -- matches
f false false -- no match, discard
done
-}
{- coverage check starts with
f (x : Bool)
splits on x
f true -- finds clause 1
f false
NEW: remaing clauses have bigger arity, so expands to
f false (y : Bool)
splits on y
f false true -- finds clause 2
f false false -- finds clause 3
done
-}
| 14.861386
| 63
| 0.62958
|
4a7750658ab26edf112dd926f681e5e30ed0f828
| 1,589
|
agda
|
Agda
|
Setoids/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Setoids/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Setoids/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Sets.EquivalenceRelations
open import LogicalFormulae
open import Orders.Total.Definition
open import Orders.Partial.Definition
open import Setoids.Setoids
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Setoids.Orders.Partial.Definition where
record SetoidPartialOrder {a b c : _} {A : Set a} (S : Setoid {a} {b} A) (_<_ : Rel {a} {c} A) : Set (a ⊔ b ⊔ c) where
open Setoid S
field
<WellDefined : {a b c d : A} → (a ∼ b) → (c ∼ d) → a < c → b < d
irreflexive : {x : A} → (x < x) → False
<Transitive : {a b c : A} → (a < b) → (b < c) → (a < c)
_<=_ : Rel {a} {b ⊔ c} A
a <= b = (a < b) || (a ∼ b)
<=Transitive : {a b c : A} → (a <= b) → (b <= c) → (a <= c)
<=Transitive (inl a<b) (inl b<c) = inl (<Transitive a<b b<c)
<=Transitive (inl a<b) (inr b=c) = inl (<WellDefined (Equivalence.reflexive eq) b=c a<b)
<=Transitive (inr a=b) (inl b<c) = inl (<WellDefined (Equivalence.symmetric eq a=b) (Equivalence.reflexive eq) b<c)
<=Transitive (inr a=b) (inr b=c) = inr (Equivalence.transitive eq a=b b=c)
partialOrderToSetoidPartialOrder : {a b : _} {A : Set a} (P : PartialOrder {a} A {b}) → SetoidPartialOrder (reflSetoid A) (PartialOrder._<_ P)
SetoidPartialOrder.<WellDefined (partialOrderToSetoidPartialOrder P) a=b c=d a<c rewrite a=b | c=d = a<c
SetoidPartialOrder.irreflexive (partialOrderToSetoidPartialOrder P) = PartialOrder.irreflexive P
SetoidPartialOrder.<Transitive (partialOrderToSetoidPartialOrder P) = PartialOrder.<Transitive P
| 49.65625
| 142
| 0.660164
|
20ac5003c7b2da29153235a8dd73c7d08b6f39ca
| 44
|
agda
|
Agda
|
test/Succeed/Imports/A.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Imports/A.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Imports/A.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Imports.A where
postulate A : Set
| 7.333333
| 22
| 0.727273
|
1cce8fbcfcd7886656ecbfaeb3542f4d79abdaf8
| 11,560
|
agda
|
Agda
|
src/Container/List.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Container/List.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Container/List.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The list container
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Container.List
{c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where
open Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_; module _⇔_)
open import Prelude as P hiding (List; []; _∷_; id; _∘_)
open import Bag-equivalence eq
using () renaming (_≈-bag_ to _≈-bagL_; _∈_ to _∈L_; Any to AnyL)
open import Bijection eq using (_↔_; module _↔_; Σ-≡,≡↔≡)
open import Container eq
open import Fin eq
open import Function-universe eq
open import H-level.Closure eq
import List eq as L
open import Surjection eq using (_↠_)
------------------------------------------------------------------------
-- The type
-- Lists.
List : Container lzero
List = ℕ ▷ Fin
------------------------------------------------------------------------
-- The definitions of lists and bag equivalence for lists given in
-- Container/Container.List and in Prelude/Bag-equivalence are closely
-- related
-- There is a split surjection from ⟦ List ⟧ A to P.List A.
List↠List : {A : Type} → ⟦ List ⟧ A ↠ P.List A
List↠List {A} = record
{ logical-equivalence = record
{ to = uncurry to
; from = from
}
; right-inverse-of = to∘from
}
where
to : (n : ℕ) → (Fin n → A) → P.List A
to zero f = P.[]
to (suc n) f = P._∷_ (f fzero) (to n (f ∘ fsuc))
from = λ xs → (L.length xs , L.index xs)
to∘from : ∀ xs → uncurry to (from xs) ≡ xs
to∘from P.[] = refl _
to∘from (P._∷_ x xs) = cong (P._∷_ x) (to∘from xs)
-- If we assume that equality of functions is extensional, then we can
-- also prove that the two definitions are isomorphic.
List↔List : Extensionality lzero lzero →
{A : Type} → ⟦ List ⟧ A ↔ P.List A
List↔List ext {A} = record
{ surjection = List↠List
; left-inverse-of = uncurry from∘to
}
where
open _↠_ List↠List
from∘to : ∀ n f → from (to (n , f)) ≡ (n , f)
from∘to zero f = cong (_,_ _) (apply-ext ext λ ())
from∘to (suc n) f =
(suc (L.length (to xs)) , L.index (P._∷_ x (to xs))) ≡⟨ elim¹ (λ {ys} _ → _≡_ {A = ⟦ List ⟧ A}
(suc (L.length (to xs)) , L.index (P._∷_ x (to xs)))
(suc (proj₁ ys) , [ (λ _ → x) , proj₂ ys ]))
(cong (suc (L.length (to xs)) ,_) $ apply-ext ext
[ (λ _ → refl _) , (λ _ → refl _) ])
(from∘to n (f ∘ inj₂)) ⟩
(suc n , [ (λ _ → x) , f ∘ inj₂ ]) ≡⟨ cong (_,_ _) (apply-ext ext [ (λ _ → refl _) , (λ _ → refl _) ]) ⟩∎
(suc n , f) ∎
where
x = f (inj₁ tt)
xs = (n , f ∘ inj₂)
-- The two definitions of Any are isomorphic (both via "to" and
-- "from").
Any↔Any-to : {A : Type} (P : A → Type) (xs : ⟦ List ⟧ A) →
Any P xs ↔ AnyL P (_↠_.to List↠List xs)
Any↔Any-to {A} P = uncurry Any↔Any-to′
where
Any↔Any-to′ : (n : ℕ) (lkup : Fin n → A) →
Any {C = List} P (n , lkup) ↔
AnyL P (_↠_.to List↠List (n , lkup))
Any↔Any-to′ zero lkup =
(∃ λ (p : Fin zero) → P (lkup p)) ↔⟨ ∃-Fin-zero _ ⟩
⊥ □
Any↔Any-to′ (suc n) lkup =
(∃ λ (p : Fin (suc n)) → P (lkup p)) ↔⟨ ∃-Fin-suc _ ⟩
P (lkup fzero) ⊎ Any {C = List} P (n , lkup ∘ fsuc) ↔⟨ id ⊎-cong Any↔Any-to′ n (lkup ∘ fsuc) ⟩
P (lkup fzero) ⊎ AnyL P (_↠_.to List↠List (n , lkup ∘ fsuc)) □
Any-from↔Any : {A : Type} (P : A → Type) (xs : P.List A) →
Any P (_↠_.from List↠List xs) ↔ AnyL P xs
Any-from↔Any P P.[] =
(∃ λ (p : Fin zero) → P (L.index P.[] p)) ↔⟨ ∃-Fin-zero _ ⟩
⊥ □
Any-from↔Any P (P._∷_ x xs) =
(∃ λ (p : Fin (suc (L.length xs))) → P (L.index (P._∷_ x xs) p)) ↔⟨ ∃-Fin-suc _ ⟩
P x ⊎ Any {C = List} P (_↠_.from List↠List xs) ↔⟨ id ⊎-cong Any-from↔Any P xs ⟩
P x ⊎ AnyL P xs □
-- The definition of bag equivalence in Bag-equivalence and the one in
-- Container, instantiated with the List container, are logically
-- equivalent (both via "to" and "from").
≈-⇔-to-≈-to :
{A : Type} {xs ys : ⟦ List ⟧ A} →
xs ≈-bag ys ⇔ _↠_.to List↠List xs ≈-bagL _↠_.to List↠List ys
≈-⇔-to-≈-to {xs = xs} {ys} = record
{ to = λ xs≈ys z →
z ∈L (_↠_.to List↠List xs) ↔⟨ inverse $ Any↔Any-to _ xs ⟩
z ∈ xs ↔⟨ xs≈ys z ⟩
z ∈ ys ↔⟨ Any↔Any-to _ ys ⟩
z ∈L (_↠_.to List↠List ys) □
; from = λ xs≈ys z →
z ∈ xs ↔⟨ Any↔Any-to _ xs ⟩
z ∈L (_↠_.to List↠List xs) ↔⟨ xs≈ys z ⟩
z ∈L (_↠_.to List↠List ys) ↔⟨ inverse $ Any↔Any-to _ ys ⟩
z ∈ ys □
}
≈-⇔-from-≈-from :
{A : Type} {xs ys : P.List A} →
xs ≈-bagL ys ⇔ _↠_.from List↠List xs ≈-bag _↠_.from List↠List ys
≈-⇔-from-≈-from {xs = xs} {ys} = record
{ to = λ xs≈ys z →
z ∈ (_↠_.from List↠List xs) ↔⟨ Any-from↔Any _ xs ⟩
z ∈L xs ↔⟨ xs≈ys z ⟩
z ∈L ys ↔⟨ inverse $ Any-from↔Any _ ys ⟩
z ∈ (_↠_.from List↠List ys) □
; from = λ xs≈ys z →
z ∈L xs ↔⟨ inverse $ Any-from↔Any _ xs ⟩
z ∈ (_↠_.from List↠List xs) ↔⟨ xs≈ys z ⟩
z ∈ (_↠_.from List↠List ys) ↔⟨ Any-from↔Any _ ys ⟩
z ∈L ys □
}
------------------------------------------------------------------------
-- Constructors
[] : {A : Type} → ⟦ List ⟧ A
[] = (zero , λ ())
infixr 5 _∷_
_∷_ : {A : Type} → A → ⟦ List ⟧ A → ⟦ List ⟧ A
x ∷ (n , lkup) = (suc n , [ (λ _ → x) , lkup ])
-- Even if we don't assume extensionality we can prove that
-- intensionally distinct implementations of the constructors are bag
-- equivalent.
[]≈ : {A : Type} {lkup : _ → A} →
_≈-bag_ {C₂ = List} [] (zero , lkup)
[]≈ _ = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (() , _) }
; from = λ { (() , _) }
}
; right-inverse-of = λ { (() , _) }
}
; left-inverse-of = λ { (() , _) }
}
∷≈ : ∀ {A : Type} {n} {lkup : _ → A} →
_≈-bag_ {C₂ = List}
(lkup (inj₁ tt) ∷ (n , lkup ∘ inj₂))
(suc n , lkup)
∷≈ _ = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (inj₁ tt , eq) → (inj₁ tt , eq)
; (inj₂ s , eq) → (inj₂ s , eq)
}
; from = λ { (inj₁ tt , eq) → (inj₁ tt , eq)
; (inj₂ s , eq) → (inj₂ s , eq)
}
}
; right-inverse-of = λ { (inj₁ tt , eq) → refl _
; (inj₂ s , eq) → refl _
}
}
; left-inverse-of = λ { (inj₁ tt , eq) → refl _
; (inj₂ s , eq) → refl _
}
}
-- Any lemmas for the constructors.
Any-[] : {A : Type} (P : A → Type) →
Any P [] ↔ ⊥₀
Any-[] _ = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (() , _) }
; from = λ ()
}
; right-inverse-of = λ ()
}
; left-inverse-of = λ { (() , _) }
}
Any-∷ : ∀ {A : Type} (P : A → Type) {x xs} →
Any P (x ∷ xs) ↔ P x ⊎ Any P xs
Any-∷ _ = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (inj₁ tt , eq) → inj₁ eq
; (inj₂ s , eq) → inj₂ (s , eq)
}
; from = λ { (inj₁ eq) → (inj₁ tt , eq)
; (inj₂ (s , eq)) → (inj₂ s , eq)
}
}
; right-inverse-of = λ { (inj₁ eq) → refl _
; (inj₂ (s , eq)) → refl _
}
}
; left-inverse-of = λ { (inj₁ tt , eq) → refl _
; (inj₂ s , eq) → refl _
}
}
------------------------------------------------------------------------
-- More functions
-- A fold for lists. (Well, this is not a catamorphism, it is a
-- paramorphism.)
fold : {A B : Type} → B → (A → ⟦ List ⟧ A → B → B) → ⟦ List ⟧ A → B
fold {A} {B} nl cns = uncurry fold′
where
fold′ : (n : ℕ) → (Fin n → A) → B
fold′ zero lkup = nl
fold′ (suc n) lkup =
cns (lkup fzero) (n , lkup ∘ fsuc) (fold′ n (lkup ∘ fsuc))
-- A lemma which can be used to prove properties about fold.
--
-- The "respects bag equivalence" argument could be omitted if
-- equality of functions were extensional.
fold-lemma : ∀ {A B : Type} {nl : B} {cns : A → ⟦ List ⟧ A → B → B}
(P : ⟦ List ⟧ A → B → Type) →
(∀ xs ys → xs ≈-bag ys → ∀ b → P xs b → P ys b) →
P [] nl →
(∀ x xs b → P xs b → P (x ∷ xs) (cns x xs b)) →
∀ xs → P xs (fold nl cns xs)
fold-lemma {A} {nl = nl} {cns} P resp P-nl P-cns = uncurry fold′-lemma
where
fold′-lemma : ∀ n (lkup : Fin n → A) →
P (n , lkup) (fold nl cns (n , lkup))
fold′-lemma zero lkup = resp _ _ []≈ _ P-nl
fold′-lemma (suc n) lkup = resp _ _ ∷≈ _ $
P-cns _ _ _ $ fold′-lemma n (lkup ∘ fsuc)
-- Why have I included both fold and fold-lemma rather than simply a
-- dependent eliminator? I tried this, and could easily define the
-- functions I wanted to define. However, the functions were defined
-- together with (partial) correctness proofs, and were unnecessarily
-- hard to read. I wanted to be able to define functions which were
-- easy to read, like the _++_ function below, and then have the
-- option to prove properties about them, like Any-++.
--
-- Unfortunately this turned out to be harder than expected. When
-- proving the Any-++ lemma it seemed as if I had to prove that _++_
-- preserves bag equivalence in its first argument in order to
-- instantiate the "respects bag equivalence" argument. However, my
-- preferred proof of this property uses Any-++…
--
-- An alternative could be to assume that equality of functions is
-- extensional, in which case the "respects bag equivalence" argument
-- could be removed. Another option would be to listen to Conor
-- McBride and avoid higher-order representations of first-order data.
-- Append.
infixr 5 _++_
_++_ : {A : Type} → ⟦ List ⟧ A → ⟦ List ⟧ A → ⟦ List ⟧ A
xs ++ ys = fold ys (λ z _ zs → z ∷ zs) xs
-- An Any lemma for append.
Any-++ : ∀ {A : Type} (P : A → Type) xs ys →
Any P (xs ++ ys) ↔ Any P xs ⊎ Any P ys
Any-++ P xs ys = fold-lemma
(λ xs xs++ys → Any P xs++ys ↔ Any P xs ⊎ Any P ys)
(λ us vs us≈vs us++ys hyp →
Any P us++ys ↔⟨ hyp ⟩
Any P us ⊎ Any P ys ↔⟨ _⇔_.to (∼⇔∼″ us vs) us≈vs P ⊎-cong id ⟩
Any P vs ⊎ Any P ys □)
(Any P ys ↔⟨ inverse ⊎-left-identity ⟩
⊥ ⊎ Any P ys ↔⟨ inverse (Any-[] P) ⊎-cong id ⟩
Any P [] ⊎ Any P ys □)
(λ x xs xs++ys ih →
Any P (x ∷ xs++ys) ↔⟨ Any-∷ P ⟩
P x ⊎ Any P xs++ys ↔⟨ id ⊎-cong ih ⟩
P x ⊎ Any P xs ⊎ Any P ys ↔⟨ ⊎-assoc ⟩
(P x ⊎ Any P xs) ⊎ Any P ys ↔⟨ inverse (Any-∷ P) ⊎-cong id ⟩
Any P (x ∷ xs) ⊎ Any P ys □)
xs
| 35.900621
| 135
| 0.455882
|
0e1f9dfb331e8140010a7fa11b30235421adef7b
| 1,316
|
agda
|
Agda
|
src/fot/LTC-PCF/Program/GCD/Partial/GreatestAnyCommonDivisor.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/LTC-PCF/Program/GCD/Partial/GreatestAnyCommonDivisor.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/LTC-PCF/Program/GCD/Partial/GreatestAnyCommonDivisor.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
---------------------------------------------------------------------------
-- The gcd is greatest that any common divisor
---------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat.Divisibility.NotBy0
open import LTC-PCF.Data.Nat.Inequalities
open import LTC-PCF.Data.Nat.Type
module LTC-PCF.Program.GCD.Partial.GreatestAnyCommonDivisor
(x∣Sy→x≤Sy : ∀ {m n} → N m → N n → m ∣ (succ₁ n) → m ≤ succ₁ n)
(0∤x : ∀ {n} → ¬ (zero ∣ n))
where
open import LTC-PCF.Program.GCD.Partial.Definitions
---------------------------------------------------------------------------
-- Knowing that gcd is a common divisor of m and n and that any other
-- common divisor of m and n divides it, we can prove that gcd is the
-- largest common divisor.
-- It requires the totality of gcd, ie. N gcd.
gcdGACD : ∀ {m n gcd} → N gcd → CD m n gcd → Divisible m n gcd → GACD m n gcd
gcdGACD nzero (0∣m , _) = ⊥-elim (0∤x 0∣m)
gcdGACD (nsucc {gcd} Ngcd) _ =
λ Divisible-mnSgcd c Nc CDmnc → x∣Sy→x≤Sy Nc Ngcd
(Divisible-mnSgcd c Nc CDmnc)
| 39.878788
| 77
| 0.515198
|
dcc5fcdaec5f5250c89050cb93ae6ea9c3b95453
| 2,225
|
agda
|
Agda
|
src/Tactic/Reflection/Free.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | 111
|
2015-01-05T11:28:15.000Z
|
2022-02-12T23:29:26.000Z
|
src/Tactic/Reflection/Free.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | 59
|
2016-02-09T05:36:44.000Z
|
2022-01-14T07:32:36.000Z
|
src/Tactic/Reflection/Free.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | 24
|
2015-03-12T18:03:45.000Z
|
2021-04-22T06:10:41.000Z
|
module Tactic.Reflection.Free where
open import Prelude
open import Prelude.Variables
open import Builtin.Reflection
open import Tactic.Reflection.DeBruijn
VarSet = List Nat -- ordered
private
_∪_ : VarSet → VarSet → VarSet
[] ∪ ys = ys
xs ∪ [] = xs
(x ∷ xs) ∪ (y ∷ ys) =
case-cmp compare x y
less _ => x ∷ (xs ∪ (y ∷ ys))
equal _ => x ∷ (xs ∪ ys)
greater _ => y ∷ ((x ∷ xs) ∪ ys)
∅ : VarSet
∅ = []
record FreeVars {a} (A : Set a) : Set a where
field freeVars : A → VarSet
open FreeVars {{...}} public
-- Instances --
private
freeTerm : Nat → Term → VarSet
freeSort : Nat → Sort → VarSet
freeArgTerm : Nat → Arg Term → VarSet
freeArgs : Nat → List (Arg Term) → VarSet
freeClauses : Nat → List Clause → VarSet
freeClause : Nat → Clause → VarSet
freeTerm n (var x args) = freeArgs n args ∪
(case compare (suc x) n of
λ { (greater (diff k _)) → [ k ]
; _ → ∅
})
freeTerm n (con c args) = freeArgs n args
freeTerm n (def f args) = freeArgs n args
freeTerm n (meta x args) = freeArgs n args
freeTerm n (lam _ (abs _ v)) = freeTerm (suc n) v
freeTerm n (pat-lam cs args) = freeClauses n cs ∪ freeArgs n args
freeTerm n (pi a (abs _ b)) = freeArgTerm n a ∪ freeTerm (suc n) b
freeTerm n (agda-sort s) = freeSort n s
freeTerm n (lit l) = ∅
freeTerm n unknown = ∅
freeSort n (set t) = freeTerm n t
freeSort _ (lit n) = ∅
freeSort n (prop t) = freeTerm n t
freeSort _ (propLit n) = ∅
freeSort _ (inf n) = ∅
freeSort _ unknown = ∅
freeArgTerm n (arg i x) = freeTerm n x
freeArgs n [] = ∅
freeArgs n (a ∷ as) = freeArgTerm n a ∪ freeArgs n as
freeClauses n [] = ∅
freeClauses n (c ∷ cs) = freeClause n c ∪ freeClauses n cs
freeClause n (clause tel ps b) = freeTerm (length tel + n) b
freeClause n (absurd-clause tel _) = ∅
instance
FreeTerm : FreeVars Term
freeVars {{FreeTerm}} = freeTerm 0
FreeSort : FreeVars Sort
freeVars {{FreeSort}} = freeSort 0
FreeArg : {{_ : FreeVars A}} → FreeVars (Arg A)
freeVars {{FreeArg}} (arg _ x) = freeVars x
FreeList : {{_ : FreeVars A}} → FreeVars (List A)
freeVars {{FreeList}} = foldr (λ x → freeVars x ∪_) ∅
| 26.807229
| 69
| 0.603596
|
df3bb1cd5118a062009d37a02c874f119fdd5ae2
| 2,761
|
agda
|
Agda
|
src/Impure/STLCRef/Eval.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Impure/STLCRef/Eval.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Impure/STLCRef/Eval.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
module Impure.STLCRef.Eval where
open import Prelude
open import Data.Product
open import Data.List
open import Data.List.Reverse
open import Data.Nat
open import Data.Fin hiding (_<_)
open import Extensions.List as L
open import Impure.STLCRef.Syntax
open import Impure.STLCRef.Welltyped
_!!_ : ∀ {n i} → (μ : Store n) → i < length μ → ∃ (Val {n})
_!!_ {i = i} [] ()
_!!_ {i = zero} (x ∷ μ) (s≤s p) = x
_!!_ {i = suc i} (x ∷ μ) (s≤s p) = μ !! p
Config : (n : ℕ) → Set
Config n = Exp n × Store n
infixl 1 _≻_
data _≻_ : ∀ {n} → Config n → Config n → Set where
---------------------------------------
-- Reduction rules
---------------------------------------
-- β
AppAbs : ∀ {n} {A x} {e : Exp (suc n)} {μ : Store n} →
---------------------------------
(ƛ A e) · x , μ ≻ e / (sub x) , μ
-- new
RefVal : ∀ {n e} {μ : Store n} →
(v : Val e) →
--------------------------------------------
(ref e , μ) ≻ (loc (length μ) , μ ∷ʳ (, v))
-- load
DerefLoc : ∀ {n i} {μ : Store n} →
(p : i < length μ) →
---------------------------------------------------
(! (loc i) , μ) ≻ (proj₁ (μ !! p) , μ)
-- store
Assign : ∀ {i n e} {μ : Store n} →
(p : i < length μ) →
(v : Val e) →
----------------------------------------------
loc i ≔ e , μ ≻ unit , (μ L.[ fromℕ≤ p ]≔ (, v))
---------------------------------------
-- contextual closure
---------------------------------------
Ref : ∀ {n e'} {e : Exp n} {μ μ'} →
(e , μ) ≻ (e' , μ') →
---------------------------------------
(ref e) , μ ≻ (ref e') , μ'
Appₗ : ∀ {n f' e} {f : Exp n} {μ μ'} →
(f , μ) ≻ (f' , μ') →
---------------------------------------
(f · e) , μ ≻ (f' · e) , μ'
Appᵣ : ∀ {n e' e} {f : Exp n} {μ μ'} →
(e , μ) ≻ (e' , μ') →
---------------------------------------
(f · e) , μ ≻ (f · e') , μ'
Deref : ∀ {n} {e : Exp n} {e'} {μ μ'} →
e , μ ≻ e' , μ' →
---------------------------------------
! e , μ ≻ ! e' , μ'
Assign₁ : ∀ {n} {e₁ : Exp n} {e₁' e₂} {μ μ'} →
e₁ , μ ≻ e₁' , μ' →
---------------------------------------
e₁ ≔ e₂ , μ ≻ e₁' ≔ e₂ , μ'
Assign₂ : ∀ {n} {e₁ : Exp n} {e₂' e₂} {μ μ'} →
e₂ , μ ≻ e₂' , μ' →
---------------------------------------
e₁ ≔ e₂ , μ ≻ e₁ ≔ e₂' , μ'
------------------------------------------------
-- Reflexive-transitive closure of step relation
------------------------------------------------
open import Data.Star
infixl 1 _≻*_
_≻*_ : ∀ {n} → Config n → Config n → Set
c ≻* c' = Star _≻_ c c'
| 28.463918
| 64
| 0.300254
|
1817b7cfa784dbe71d462476fb3d99089fa681db
| 2,115
|
agda
|
Agda
|
src/Tactic/Reflection/Free.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Free.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Free.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | null | null | null |
module Tactic.Reflection.Free where
open import Prelude
open import Prelude.Variables
open import Builtin.Reflection
open import Tactic.Reflection.DeBruijn
VarSet = List Nat -- ordered
private
_∪_ : VarSet → VarSet → VarSet
[] ∪ ys = ys
xs ∪ [] = xs
(x ∷ xs) ∪ (y ∷ ys) =
case-cmp compare x y
less _ => x ∷ (xs ∪ (y ∷ ys))
equal _ => x ∷ (xs ∪ ys)
greater _ => y ∷ ((x ∷ xs) ∪ ys)
∅ : VarSet
∅ = []
record FreeVars {a} (A : Set a) : Set a where
field freeVars : A → VarSet
open FreeVars {{...}} public
-- Instances --
private
freeTerm : Nat → Term → VarSet
freeSort : Nat → Sort → VarSet
freeArgTerm : Nat → Arg Term → VarSet
freeArgs : Nat → List (Arg Term) → VarSet
freeClauses : Nat → List Clause → VarSet
freeClause : Nat → Clause → VarSet
freeTerm n (var x args) = freeArgs n args ∪
(case compare (suc x) n of
λ { (greater (diff k _)) → [ k ]
; _ → ∅
})
freeTerm n (con c args) = freeArgs n args
freeTerm n (def f args) = freeArgs n args
freeTerm n (meta x args) = freeArgs n args
freeTerm n (lam _ (abs _ v)) = freeTerm (suc n) v
freeTerm n (pat-lam cs args) = freeClauses n cs ∪ freeArgs n args
freeTerm n (pi a (abs _ b)) = freeArgTerm n a ∪ freeTerm (suc n) b
freeTerm n (agda-sort s) = freeSort n s
freeTerm n (lit l) = ∅
freeTerm n unknown = ∅
freeSort n (set t) = freeTerm n t
freeSort _ (lit n) = ∅
freeSort _ unknown = ∅
freeArgTerm n (arg i x) = freeTerm n x
freeArgs n [] = ∅
freeArgs n (a ∷ as) = freeArgTerm n a ∪ freeArgs n as
freeClauses n [] = ∅
freeClauses n (c ∷ cs) = freeClause n c ∪ freeClauses n cs
freeClause n (clause tel ps b) = freeTerm (length tel + n) b
freeClause n (absurd-clause tel _) = ∅
instance
FreeTerm : FreeVars Term
freeVars {{FreeTerm}} = freeTerm 0
FreeSort : FreeVars Sort
freeVars {{FreeSort}} = freeSort 0
FreeArg : {{_ : FreeVars A}} → FreeVars (Arg A)
freeVars {{FreeArg}} (arg _ x) = freeVars x
FreeList : {{_ : FreeVars A}} → FreeVars (List A)
freeVars {{FreeList}} = foldr (λ x → freeVars x ∪_) ∅
| 26.4375
| 69
| 0.609456
|
23e52eace7bc4a5a21fb4859fd5931bdddb59d6f
| 4,734
|
agda
|
Agda
|
Cubical/Relation/Binary/Base.agda
|
dan-iel-lee/cubical
|
fd8059ec3eed03f8280b4233753d00ad123ffce8
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Base.agda
|
dan-iel-lee/cubical
|
fd8059ec3eed03f8280b4233753d00ad123ffce8
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Base.agda
|
dan-iel-lee/cubical
|
fd8059ec3eed03f8280b4233753d00ad123ffce8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Fiberwise
open import Cubical.Data.Sigma
open import Cubical.HITs.SetQuotients.Base
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓA ℓ≅A ℓA' ℓ≅A' : Level
Rel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
Rel A B ℓ' = A → B → Type ℓ'
PropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
PropRel A B ℓ' = Σ[ R ∈ Rel A B ℓ' ] ∀ a b → isProp (R a b)
idPropRel : ∀ {ℓ} (A : Type ℓ) → PropRel A A ℓ
idPropRel A .fst a a' = ∥ a ≡ a' ∥
idPropRel A .snd _ _ = squash
invPropRel : ∀ {ℓ ℓ'} {A B : Type ℓ}
→ PropRel A B ℓ' → PropRel B A ℓ'
invPropRel R .fst b a = R .fst a b
invPropRel R .snd b a = R .snd a b
compPropRel : ∀ {ℓ ℓ' ℓ''} {A B C : Type ℓ}
→ PropRel A B ℓ' → PropRel B C ℓ'' → PropRel A C (ℓ-max ℓ (ℓ-max ℓ' ℓ''))
compPropRel R S .fst a c = ∥ Σ[ b ∈ _ ] (R .fst a b × S .fst b c) ∥
compPropRel R S .snd _ _ = squash
graphRel : ∀ {ℓ} {A B : Type ℓ} → (A → B) → Rel A B ℓ
graphRel f a b = f a ≡ b
module BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') where
isRefl : Type (ℓ-max ℓ ℓ')
isRefl = (a : A) → R a a
isSym : Type (ℓ-max ℓ ℓ')
isSym = (a b : A) → R a b → R b a
isTrans : Type (ℓ-max ℓ ℓ')
isTrans = (a b c : A) → R a b → R b c → R a c
record isEquivRel : Type (ℓ-max ℓ ℓ') where
constructor equivRel
field
reflexive : isRefl
symmetric : isSym
transitive : isTrans
isPropValued : Type (ℓ-max ℓ ℓ')
isPropValued = (a b : A) → isProp (R a b)
isEffective : Type (ℓ-max ℓ ℓ')
isEffective =
(a b : A) → isEquiv (eq/ {R = R} a b)
impliesIdentity : Type _
impliesIdentity = {a a' : A} → (R a a') → (a ≡ a')
-- the total space corresponding to the binary relation w.r.t. a
relSinglAt : (a : A) → Type (ℓ-max ℓ ℓ')
relSinglAt a = Σ[ a' ∈ A ] (R a a')
-- the statement that the total space is contractible at any a
contrRelSingl : Type (ℓ-max ℓ ℓ')
contrRelSingl = (a : A) → isContr (relSinglAt a)
isUnivalent : Type (ℓ-max ℓ ℓ')
isUnivalent = (a a' : A) → (R a a') ≃ (a ≡ a')
contrRelSingl→isUnivalent : isRefl → contrRelSingl → isUnivalent
contrRelSingl→isUnivalent ρ c a a' = isoToEquiv i
where
h : isProp (relSinglAt a)
h = isContr→isProp (c a)
aρa : relSinglAt a
aρa = a , ρ a
Q : (y : A) → a ≡ y → _
Q y _ = R a y
i : Iso (R a a') (a ≡ a')
Iso.fun i r = cong fst (h aρa (a' , r))
Iso.inv i = J Q (ρ a)
Iso.rightInv i = J (λ y p → cong fst (h aρa (y , J Q (ρ a) p)) ≡ p)
(J (λ q _ → cong fst (h aρa (a , q)) ≡ refl)
(J (λ α _ → cong fst α ≡ refl) refl
(isContr→isProp (isProp→isContrPath h aρa aρa) refl (h aρa aρa)))
(sym (JRefl Q (ρ a))))
Iso.leftInv i r = J (λ w β → J Q (ρ a) (cong fst β) ≡ snd w)
(JRefl Q (ρ a)) (h aρa (a' , r))
isUnivalent→contrRelSingl : isUnivalent → contrRelSingl
isUnivalent→contrRelSingl u a = q
where
abstract
f : (x : A) → a ≡ x → R a x
f x p = invEq (u a x) p
t : singl a → relSinglAt a
t (x , p) = x , f x p
q = isOfHLevelRespectEquiv 0 (t , totalEquiv _ _ f λ x → invEquiv (u a x) .snd)
(isContrSingl a)
EquivRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivRel A ℓ' = Σ[ R ∈ Rel A A ℓ' ] BinaryRelation.isEquivRel R
EquivPropRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivPropRel A ℓ' = Σ[ R ∈ PropRel A A ℓ' ] BinaryRelation.isEquivRel (R .fst)
record RelIso {A : Type ℓA} (_≅_ : Rel A A ℓ≅A)
{A' : Type ℓA'} (_≅'_ : Rel A' A' ℓ≅A') : Type (ℓ-max (ℓ-max ℓA ℓA') (ℓ-max ℓ≅A ℓ≅A')) where
constructor reliso
field
fun : A → A'
inv : A' → A
rightInv : (a' : A') → fun (inv a') ≅' a'
leftInv : (a : A) → inv (fun a) ≅ a
open BinaryRelation
RelIso→Iso : {A : Type ℓA} {A' : Type ℓA'}
(_≅_ : Rel A A ℓ≅A) (_≅'_ : Rel A' A' ℓ≅A')
(uni : impliesIdentity _≅_) (uni' : impliesIdentity _≅'_)
(f : RelIso _≅_ _≅'_)
→ Iso A A'
Iso.fun (RelIso→Iso _ _ _ _ f) = RelIso.fun f
Iso.inv (RelIso→Iso _ _ _ _ f) = RelIso.inv f
Iso.rightInv (RelIso→Iso _ _ uni uni' f) a'
= uni' (RelIso.rightInv f a')
Iso.leftInv (RelIso→Iso _ _ uni uni' f) a
= uni (RelIso.leftInv f a)
| 33.814286
| 106
| 0.55112
|
df46b10637ea05aaea3039714179a9a28d7cc912
| 1,084
|
agda
|
Agda
|
test/Succeed/ImproveInertRHS.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/ImproveInertRHS.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/ImproveInertRHS.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
data Nat : Set where
zero : Nat
suc : Nat → Nat
data Id (A : Set) : Set where
mkId : A → Id A
data Monad (M : Set → Set) : Set where
postulate
return : ∀ {M} {{Mon : Monad M}} {A} → A → M A
_>>=_ : ∀ {M} {{Mon : Monad M}} {A B} → M A → (A → M B) → M B
State : (S A : Set) → Set
instance
MonadState : ∀ {S} → Monad (State S)
MonadId : Monad Id
-- Yields
-- _M Nat == State Nat Nat,
-- which inert improvement solves by
-- _M x := State (_S x) (_A x)
-- with _S Nat == Nat
-- _A Nat == Nat
-- This allows instance search to pick the right instance.
rz : State Nat Nat
rz = return zero
postulate
StateT : (S : Set) (M : Set → Set) (A : Set) → Set
instance
MonadStateT : ∀ {S M} {{_ : Monad M}} → Monad (StateT S M)
stateT₁ : ∀ {M} {{Mon : Monad M}} → StateT Nat M Nat
stateT₁ = return zero
stateT₂ : ∀ {M} {{Mon : Monad M}} → StateT Nat M Nat
stateT₂ = return zero >>= λ n → return (suc n)
postulate
_<$_ : ∀ {A B M} {{Mon : Monad M}} → A → M B → M A
record ⊤ : Set where
constructor tt
foo : Id ⊤
foo = _ <$ return zero
| 21.68
| 64
| 0.551661
|
0efc88077473e2e573a86d9ded19a3b0b02297a0
| 321
|
agda
|
Agda
|
src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda
|
bennn/agda
|
f77b563d328513138d6c88bf0a3e350a9b91f8ed
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda
|
bennn/agda
|
f77b563d328513138d6c88bf0a3e350a9b91f8ed
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda
|
bennn/agda
|
f77b563d328513138d6c88bf0a3e350a9b91f8ed
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --cubical #-}
module Agda.Builtin.Cubical.Sub where
open import Agda.Primitive.Cubical
{-# BUILTIN SUB Sub #-}
postulate
inc : ∀ {ℓ} {A : Set ℓ} {φ} (x : A) → Sub A φ (λ _ → x)
{-# BUILTIN SUBIN inc #-}
primitive
primSubOut : ∀ {ℓ} {A : Set ℓ} {φ : I} {u : Partial φ A} → Sub _ φ u → A
| 21.4
| 76
| 0.551402
|
18a83aaca243a5165f4043cd961ce5df2ec2e057
| 191
|
agda
|
Agda
|
test/fail/Issue328.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/fail/Issue328.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue328.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module Issue328 where
mutual
postulate D : Set
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Concrete/Definitions.hs:398
| 21.222222
| 74
| 0.759162
|
10c98468dd70135bd5ff3ec0f98284cf4d934782
| 2,726
|
agda
|
Agda
|
src/Sessions/Semantics/Expr.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | 34
|
2019-12-20T13:57:50.000Z
|
2021-02-03T15:22:33.000Z
|
src/Sessions/Semantics/Expr.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | null | null | null |
src/Sessions/Semantics/Expr.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | 2
|
2020-01-30T14:15:14.000Z
|
2020-05-23T00:34:36.000Z
|
module Sessions.Semantics.Expr where
open import Prelude
open import Data.Fin
open import Relation.Unary.PredicateTransformer hiding (_⊔_)
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Monad.Reader
open import Sessions.Syntax.Types
open import Sessions.Syntax.Values
open import Sessions.Syntax.Expr
open import Sessions.Semantics.Commands
open import Sessions.Semantics.Runtime
open import Relation.Ternary.Separation.Construct.List Type
open import Relation.Ternary.Separation.Monad.Free Cmd δ
hiding (⟪_⟫)
open import Relation.Ternary.Separation.Monad.Error
open ErrorTrans Free {{monad = free-monad}} public
open ReaderTransformer id-morph Val (ErrorT Free) {{error-monad}}
renaming (Reader to M)
public
open Monads using (Monad; str; _&_)
open Monad reader-monad
mutual
eval⊸ : ∀ {Γ} → ℕ → Exp (a ⊸ b) Γ → ∀[ Val a ⇒ⱼ M Γ [] (Val b) ]
eval⊸ n e v = do
(clos e env) ×⟨ σ₂ ⟩ v ← ►eval n e & v
empty ← append (cons (v ×⟨ ⊎-comm σ₂ ⟩ env))
►eval n e
►eval : ℕ → Exp a Γ → ε[ M Γ [] (Val a) ]
app (►eval zero e) _ _ = partial (pure (inj₁ err))
►eval (suc n) e = eval n e
⟪_⟫ : ∀ {Γ Φ} → (c : Cmd Φ) → M Γ Γ (δ c) Φ
app (⟪_⟫ c) (inj E) σ =
partial (impure (c ×⟨ σ ⟩
wand λ r σ' → pure (inj₂ (r ×⟨ ⊎-comm σ' ⟩ E))))
eval : ℕ → Exp a Γ → ε[ M Γ [] (Val a) ]
eval n unit = do
return tt
eval n (var refl) = do
(v :⟨ σ ⟩: nil) ← ask
case ⊎-id⁻ʳ σ of λ where
refl → return v
eval n (lam a e) = do
env ← ask
return (clos e env)
eval n (ap (f ×⟨ Γ≺ ⟩ e)) = do
v ← frame (⊎-comm Γ≺) (►eval n e)
eval⊸ n f v
eval n (pairs (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
v₁ ← frame Γ≺ (►eval n e₁)
v₂⋆v₂ ← ►eval n e₂ & v₁
return (pairs (✴-swap v₂⋆v₂))
eval n (letunit (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
tt ← frame Γ≺ (►eval n e₁)
►eval n e₂
eval n (letpair (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
pairs (v₁ ×⟨ σ ⟩ v₂) ← frame Γ≺ (►eval n e₁)
empty ← prepend (cons (v₁ ×⟨ σ ⟩ singleton v₂))
►eval n e₂
eval n (send (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
v₁ ← frame Γ≺ (►eval n e₁)
cref φ ×⟨ σ ⟩ v₁ ← ►eval n e₂ & v₁
φ' ← ⟪ send (φ ×⟨ σ ⟩ v₁) ⟫
return (cref φ')
eval n (recv e) = do
cref φ ← ►eval n e
v ×⟨ σ ⟩ φ' ← ⟪ receive φ ⟫
return (pairs (cref φ' ×⟨ ⊎-comm σ ⟩ v))
eval n (mkchan α) = do
φₗ ×⟨ σ ⟩ φᵣ ← ⟪ mkchan α ⟫
return (pairs (cref φₗ ×⟨ σ ⟩ cref φᵣ))
eval n (fork e) = do
clos body env ← ►eval n e
empty ←
⟪ fork (app (runReader (cons (tt ×⟨ ⊎-idˡ ⟩ env))) (►eval n body) ⊎-idʳ) ⟫
return tt
eval n (terminate e) = do
cref φ ← ►eval n e
empty ← ⟪ close φ ⟫
return tt
| 26.72549
| 80
| 0.573734
|
10e42b4931be0c9da9c844afe1a70fbdd39e98e3
| 3,060
|
agda
|
Agda
|
src/Categories/Category/Core.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Core.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Core.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Core where
open import Level
open import Function.Base using (flip)
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
-- Basic definition of a |Category| with a Hom setoid.
-- Also comes with some reasoning combinators (see HomReasoning)
record Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
eta-equality
infix 4 _≈_ _⇒_
infixr 9 _∘_
field
Obj : Set o
_⇒_ : Rel Obj ℓ
_≈_ : ∀ {A B} → Rel (A ⇒ B) e
id : ∀ {A} → (A ⇒ A)
_∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
field
assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)
-- We add a symmetric proof of associativity so that the opposite category of the
-- opposite category is definitionally equal to the original category. See how
-- `op` is implemented.
sym-assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → h ∘ (g ∘ f) ≈ (h ∘ g) ∘ f
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
-- We add a proof of "neutral" identity proof, in order to ensure the opposite of
-- constant functor is definitionally equal to itself.
identity² : ∀ {A} → id ∘ id {A} ≈ id {A}
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
module Equiv {A B : Obj} = IsEquivalence (equiv {A} {B})
open Equiv
∘-resp-≈ˡ : ∀ {A B C} {f h : B ⇒ C} {g : A ⇒ B} → f ≈ h → f ∘ g ≈ h ∘ g
∘-resp-≈ˡ pf = ∘-resp-≈ pf refl
∘-resp-≈ʳ : ∀ {A B C} {f h : A ⇒ B} {g : B ⇒ C} → f ≈ h → g ∘ f ≈ g ∘ h
∘-resp-≈ʳ pf = ∘-resp-≈ refl pf
hom-setoid : ∀ {A B} → Setoid _ _
hom-setoid {A} {B} = record
{ Carrier = A ⇒ B
; _≈_ = _≈_
; isEquivalence = equiv
}
-- Reasoning combinators. _≈⟨_⟩_ and _≈˘⟨_⟩_ from SetoidR.
-- Also some useful combinators for doing reasoning on _∘_ chains
module HomReasoning {A B : Obj} where
open SetoidR (hom-setoid {A} {B}) public
-- open Equiv {A = A} {B = B} public
infixr 4 _⟩∘⟨_ refl⟩∘⟨_
infixl 5 _⟩∘⟨refl
_⟩∘⟨_ : ∀ {M} {f h : M ⇒ B} {g i : A ⇒ M} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
_⟩∘⟨_ = ∘-resp-≈
refl⟩∘⟨_ : ∀ {M} {f : M ⇒ B} {g i : A ⇒ M} → g ≈ i → f ∘ g ≈ f ∘ i
refl⟩∘⟨_ = Equiv.refl ⟩∘⟨_
_⟩∘⟨refl : ∀ {M} {f h : M ⇒ B} {g : A ⇒ M} → f ≈ h → f ∘ g ≈ h ∘ g
_⟩∘⟨refl = _⟩∘⟨ Equiv.refl
-- convenient inline versions
infix 2 ⟺
infixr 3 _○_
⟺ : {f g : A ⇒ B} → f ≈ g → g ≈ f
⟺ = Equiv.sym
_○_ : {f g h : A ⇒ B} → f ≈ g → g ≈ h → f ≈ h
_○_ = Equiv.trans
op : Category o ℓ e
op = record
{ Obj = Obj
; _⇒_ = flip _⇒_
; _≈_ = _≈_
; _∘_ = flip _∘_
; id = id
; assoc = sym-assoc
; sym-assoc = assoc
; identityˡ = identityʳ
; identityʳ = identityˡ
; identity² = identity²
; equiv = equiv
; ∘-resp-≈ = flip ∘-resp-≈
}
| 31.875
| 91
| 0.493791
|
4a4423f17d49d7de62a12b074cb1ecb7fd1dd595
| 3,582
|
agda
|
Agda
|
src/Pi/I.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | 26
|
2015-08-31T09:49:52.000Z
|
2021-11-13T12:37:44.000Z
|
src/Pi/I.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
src/Pi/I.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
-- Intuitionistic logic, PHOAS approach, initial encoding
module Pi.I (Indiv : Set) where
-- Types
data Ty : Set
Pred : Set
Pred = Indiv -> Ty
infixl 2 _&&_
infixl 1 _||_
infixr 0 _=>_
data Ty where
UNIT : Ty
_=>_ : Ty -> Ty -> Ty
_&&_ : Ty -> Ty -> Ty
_||_ : Ty -> Ty -> Ty
FALSE : Ty
FORALL : Pred -> Ty
EXISTS : Pred -> Ty
infixr 0 _<=>_
_<=>_ : Ty -> Ty -> Ty
a <=> b = (a => b) && (b => a)
NOT : Ty -> Ty
NOT a = a => FALSE
TRUE : Ty
TRUE = FALSE => FALSE
-- Context and truth/individual judgement
data El : Set where
mkTrue : Ty -> El
mkIndiv : Indiv -> El
Cx : Set1
Cx = El -> Set
isTrue : Ty -> Cx -> Set
isTrue a tc = tc (mkTrue a)
isIndiv : Indiv -> Cx -> Set
isIndiv x tc = tc (mkIndiv x)
-- Terms
module I where
infixl 2 _$$_
infixl 1 _$_
data Tm (tc : Cx) : Ty -> Set where
var : forall {a} -> isTrue a tc -> Tm tc a
lam' : forall {a b} -> (isTrue a tc -> Tm tc b) -> Tm tc (a => b)
_$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b
pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b)
fst : forall {a b} -> Tm tc (a && b) -> Tm tc a
snd : forall {a b} -> Tm tc (a && b) -> Tm tc b
left : forall {a b} -> Tm tc a -> Tm tc (a || b)
right : forall {a b} -> Tm tc b -> Tm tc (a || b)
case' : forall {a b c} -> Tm tc (a || b) -> (isTrue a tc -> Tm tc c) -> (isTrue b tc -> Tm tc c) -> Tm tc c
pi' : forall {p} -> (forall {x} -> isIndiv x tc -> Tm tc (p x)) -> Tm tc (FORALL p)
_$$_ : forall {p x} -> Tm tc (FORALL p) -> isIndiv x tc -> Tm tc (p x)
sig' : forall {p x} -> isIndiv x tc -> Tm tc (p x) -> Tm tc (EXISTS p)
split' : forall {p x a} -> Tm tc (EXISTS p) -> (isTrue (p x) tc -> Tm tc a) -> Tm tc a
abort : forall {a} -> Tm tc FALSE -> Tm tc a
lam'' : forall {tc a b} -> (Tm tc a -> Tm tc b) -> Tm tc (a => b)
lam'' f = lam' \x -> f (var x)
case'' : forall {tc a b c} -> Tm tc (a || b) -> (Tm tc a -> Tm tc c) -> (Tm tc b -> Tm tc c) -> Tm tc c
case'' xy f g = case' xy (\x -> f (var x)) (\y -> g (var y))
split'' : forall {tc p x a} -> Tm tc (EXISTS p) -> (Tm tc (p x) -> Tm tc a) -> Tm tc a
split'' x f = split' x \y -> f (var y)
syntax lam'' (\a -> b) = lam a => b
syntax pair' x y = [ x , y ]
syntax case'' xy (\x -> z1) (\y -> z2) = case xy of x => z1 or y => z2
syntax pi' (\x -> px) = pi x => px
syntax sig' x px = [ x ,, px ]
syntax split'' x (\y -> z) = split x as y => z
Thm : Ty -> Set1
Thm a = forall {tc} -> Tm tc a
open I public
-- Example theorems
t214 : forall {p q : Pred} -> Thm (
FORALL (\x -> p x || NOT (p x)) && FORALL (\x -> p x => EXISTS (\y -> q y)) =>
FORALL (\x -> EXISTS (\y -> p x => q y)))
t214 =
lam fg =>
pi x =>
case fst fg $$ x
of px =>
split snd fg $$ x $ px
as qy =>
[ x ,, lam _ => qy ]
or npx =>
[ x ,, lam px => abort (npx $ px) ]
l5 : forall {a} -> Thm (a && FALSE <=> FALSE)
l5 =
[ lam xnt => snd xnt
, lam nt => abort nt
]
l10 : forall {a} -> Thm (a || FALSE <=> a)
l10 =
[ lam xnt =>
case xnt
of x => x
or nt => abort nt
, lam x => left x
]
l20 : forall {a} -> Thm ((FALSE => a) <=> TRUE)
l20 =
[ lam _ => lam nt => nt
, lam _ => lam nt => abort nt
]
| 27.553846
| 114
| 0.434953
|
1c3088415d4db04bb71cccceabd8041240a41015
| 1,214
|
agda
|
Agda
|
Syntax/List.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Syntax/List.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Syntax/List.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
-- Opening this module allows lists to be written using "list notation".
-- Examples:
-- [] = ∅
-- [ a ] = a ⊰ ∅
-- [ a , b ] = a ⊰ b ⊰ ∅
-- [ a , b , c ] = a ⊰ b ⊰ c ⊰ ∅
module Syntax.List where
open import Data.List
{-
infixl 1 [_
infixr 1000 _,_
infixl 100000 _]
pattern [] = ∅
pattern [_ l = l
pattern _,_ x l = x ⊰ l
pattern _] x = x ⊰ ∅
-}
pattern [] = ∅
pattern [_] x₁ = x₁ ⊰ ∅
pattern [_,_] x₁ x₂ = x₁ ⊰ x₂ ⊰ ∅
pattern [_,_,_] x₁ x₂ x₃ = x₁ ⊰ x₂ ⊰ x₃ ⊰ ∅
pattern [_,_,_,_] x₁ x₂ x₃ x₄ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ ∅
pattern [_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ ∅
pattern [_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ ∅
pattern [_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ ∅
pattern [_,_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ x₈ ⊰ ∅
pattern [_,_,_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ x₈ ⊰ x₉ ⊰ ∅
| 37.9375
| 103
| 0.397858
|
1c2f39bd02752ad5115c4e1d41b89aa2bf6c9c0b
| 351
|
agda
|
Agda
|
Categories/Terminal.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 21
|
2015-07-30T01:25:12.000Z
|
2021-02-13T18:02:18.000Z
|
Categories/Terminal.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 3
|
2019-01-13T13:12:33.000Z
|
2019-05-29T09:50:26.000Z
|
Categories/Terminal.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 1
|
2019-11-04T21:33:13.000Z
|
2019-11-04T21:33:13.000Z
|
module Categories.Terminal where
open import Library
open import Categories
open import Categories.Sets
open Cat
record Term {a b} (C : Cat {a}{b})(T : Obj C) : Set (a ⊔ b) where
constructor term
field t : ∀{X} → Hom C X T
law : ∀{X}{f : Hom C X T} → t {X} ≅ f
OneSet : Term Sets ⊤
OneSet = record {t = λ _ → _; law = ext (λ _ → refl)}
| 23.4
| 65
| 0.609687
|
cb260a46db03f960209d8b5747026cbb8a41487f
| 10,743
|
agda
|
Agda
|
Formalization/PredicateLogic/Constructive/SequentCalculus.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Formalization/PredicateLogic/Constructive/SequentCalculus.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Formalization/PredicateLogic/Constructive/SequentCalculus.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
open import Formalization.PredicateLogic.Signature
module Formalization.PredicateLogic.Constructive.SequentCalculus (𝔏 : Signature) where
open Signature(𝔏)
open import Data.Option
open import Data.List
open import Data.List.Functions using (map) renaming (singleton to · ; _++_ to _∪_)
open import Data.List.Relation.Permutation
import Data.ListSized as S
open import Formalization.PredicateLogic.Syntax(𝔏)
open import Formalization.PredicateLogic.Syntax.Substitution(𝔏)
open import Functional as Fn using ()
import Lvl
open import Numeral.Natural
open import Type
private variable ℓ : Lvl.Level
private variable args n vars vars₁ vars₂ : ℕ
private variable Γ Γ₁ Γ₂ Γ₃ : List(Formula(vars))
private variable Δ Δ₁ Δ₂ Δ₃ : Option(Formula(vars))
private variable φ φ₁ φ₂ ψ A B C : Formula(vars)
private variable p : Prop(n)
private variable f : Prop(args)
private variable x : S.List(Term(vars))(args)
_∪·_ : ∀{T : Type{ℓ}} → List(T) → T → List(T)
_∪·_ = Fn.swap(_⊰_)
infixl 1000 _∪·_
module Variant1 where
data _⇒_ : List(Formula(vars)) → Option(Formula(vars)) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ)} where
axiom : ((· φ) ⇒ Some(φ))
weakenₗ : (Γ ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
permuteₗ : (Γ₁ permutes Γ₂) → (Γ₁ ⇒ Δ) → (Γ₂ ⇒ Δ)
contractₗ : ((Γ ∪· A ∪· A) ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
⊥ₗ : (Γ ∪· ⊥) ⇒ None
∧ₗₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∧ₗᵣ : ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∨ₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∨ B)) ⇒ Δ)
⟶ₗ : (Γ ⇒ Some(A)) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ⟶ B)) ⇒ Δ)
Ɐₗ : ∀{t} → ((Γ ∪· (substitute0 t A)) ⇒ Δ) → ((Γ ∪· (Ɐ A)) ⇒ Δ)
∃ₗ : ∀{v}{n} → ((Γ ∪· (substituteN n (var v) A)) ⇒ Δ) → ((Γ ∪· (∃ A)) ⇒ Δ)
weakenᵣ : (Γ ⇒ None) → (Γ ⇒ Some(A))
⊤ᵣ : ∅ ⇒ Some(⊤ {vars})
∧ᵣ : (Γ ⇒ Some(A)) → (Γ ⇒ Some(B)) → (Γ ⇒ Some(A ∧ B))
∨ᵣₗ : (Γ ⇒ Some(A)) → (Γ ⇒ Some(A ∨ B))
∨ᵣᵣ : (Γ ⇒ Some(B)) → (Γ ⇒ Some(A ∨ B))
⟶ᵣ : ((Γ ∪· A) ⇒ Some(B)) → (Γ ⇒ Some(A ⟶ B))
Ɐᵣ : ∀{v}{n} → (Γ ⇒ Some((substituteN n (var v) A))) → (Γ ⇒ Some(Ɐ A))
∃ᵣ : ∀{t} → (Γ ⇒ Some((substitute0 t A))) → (Γ ⇒ Some(∃ A))
import Logic.Propositional as Meta
no-empty-refl : Meta.¬(∅ ⇒ None{T = Formula vars})
no-empty-refl (permuteₗ perm p) rewrite Proofs.permutes-on-empty perm = no-empty-refl p
{-
no-callCC : Meta.¬(∅ ⇒ Some(((A ⟶ B) ⟶ A) ⟶ A))
no-callCC (permuteₗ perm p) rewrite permutes-on-empty perm = no-callCC p
no-callCC (weakenᵣ (permuteₗ perm p)) rewrite permutes-on-empty perm = no-empty-refl p
no-callCC (⟶ᵣ p) = no-callCC {!!}
{-no-callCC (⟶ᵣ (weakenₗ p)) = {!!}
no-callCC (⟶ᵣ (permuteₗ x p)) = {!!}
no-callCC (⟶ᵣ (contractₗ p)) = {!!}
no-callCC (⟶ᵣ (⟶ₗ p p₁)) = {!!}
no-callCC (⟶ᵣ (weakenᵣ p)) = {!!}
no-callCC (⟶ᵣ (∧ᵣ p p₁)) = {!!}
no-callCC (⟶ᵣ (∨ᵣₗ p)) = {!!}
no-callCC (⟶ᵣ (∨ᵣᵣ p)) = {!!}
no-callCC (⟶ᵣ (⟶ᵣ p)) = {!!}
no-callCC (⟶ᵣ (Ɐᵣ p)) = {!!}
no-callCC (⟶ᵣ (∃ᵣ p)) = {!!}
-}
-}
module Variant3 where
-- Note: Because this formalization is non-standard, a problem arises for Formula(𝟎): It it missing some of the quantification rules because it has no variables.
data _⇒_ : List(Formula(vars)) → Formula(vars) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ)} where
axiom : ((Γ ∪· (f $ x)) ⇒ (f $ x))
permuteₗ : (Γ₁ permutes Γ₂) → (Γ₁ ⇒ C) → (Γ₂ ⇒ C)
⊥ₗ : (Γ ∪· ⊥) ⇒ A
∧ₗ : ((Γ ∪· A ∪· B) ⇒ C) → ((Γ ∪· (A ∧ B)) ⇒ C)
∨ₗ : ((Γ ∪· A) ⇒ C) → ((Γ ∪· B) ⇒ C) → ((Γ ∪· (A ∨ B)) ⇒ C)
⟶ₗ : ((Γ ∪· (A ⟶ B)) ⇒ A) → ((Γ ∪· B) ⇒ C) → ((Γ ∪· (A ⟶ B)) ⇒ C)
Ɐₗ : ∀{t} → ((Γ ∪· (substitute0 t A) ∪· (Ɐ A)) ⇒ C) → ((Γ ∪· (Ɐ A)) ⇒ C)
∃ₗ : ∀{n}{v} → ((Γ ∪· (substituteN n (var v) A)) ⇒ C) → ((Γ ∪· (∃ A)) ⇒ C)
⊤ᵣ : Γ ⇒ (⊤ {vars})
∧ᵣ : (Γ ⇒ A) → (Γ ⇒ B) → (Γ ⇒ (A ∧ B))
∨ᵣₗ : (Γ ⇒ A) → (Γ ⇒ (A ∨ B))
∨ᵣᵣ : (Γ ⇒ B) → (Γ ⇒ (A ∨ B))
⟶ᵣ : ((Γ ∪· A) ⇒ B) → (Γ ⇒ (A ⟶ B))
Ɐᵣ : ∀{n}{v} → (Γ ⇒ (substituteN n (var v) A)) → (Γ ⇒ (Ɐ A))
∃ᵣ : ∀{t} → (Γ ⇒ (substitute0 t A)) → (Γ ⇒ (∃ A))
import Logic.Propositional as Meta
open import Numeral.Finite
open import Type.Properties.Inhabited
weakenₗ : (Γ ⇒ ψ) → ((Γ ∪· φ) ⇒ ψ)
weakenₗ axiom = permuteₗ swap axiom
weakenₗ (permuteₗ x p) = permuteₗ (prepend x) (weakenₗ p)
weakenₗ ⊥ₗ = permuteₗ swap ⊥ₗ
weakenₗ (∧ₗ p) = permuteₗ swap (∧ₗ(permuteₗ (trans swap (prepend swap)) (weakenₗ p)))
weakenₗ (∨ₗ p q) = permuteₗ swap (∨ₗ (permuteₗ swap (weakenₗ p)) (permuteₗ swap (weakenₗ q)))
weakenₗ (⟶ₗ p q) = permuteₗ swap (⟶ₗ (permuteₗ swap (weakenₗ p)) (permuteₗ swap (weakenₗ q)))
weakenₗ (Ɐₗ p) = permuteₗ swap (Ɐₗ (permuteₗ (trans swap (prepend swap)) (weakenₗ p)))
weakenₗ (∃ₗ{n = n} p) = permuteₗ swap (∃ₗ{n = n} (permuteₗ swap (weakenₗ p)))
weakenₗ ⊤ᵣ = ⊤ᵣ
weakenₗ (∧ᵣ p q) = ∧ᵣ (weakenₗ p) (weakenₗ q)
weakenₗ (∨ᵣₗ p) = ∨ᵣₗ (weakenₗ p)
weakenₗ (∨ᵣᵣ p) = ∨ᵣᵣ (weakenₗ p)
weakenₗ (⟶ᵣ p) = ⟶ᵣ (permuteₗ swap (weakenₗ p))
weakenₗ (Ɐᵣ{n = n} p) = Ɐᵣ{n = n} (weakenₗ p)
weakenₗ (∃ᵣ p) = ∃ᵣ (weakenₗ p)
weaken-union : (Γ₂ ⇒ φ) → ((Γ₁ ∪ Γ₂) ⇒ φ)
weaken-union {Γ₁ = ∅} p = p
weaken-union {Γ₁ = φ ⊰ Γ₁} p = weakenₗ (weaken-union {Γ₁ = Γ₁} p)
open import Formalization.PredicateLogic.Syntax.Tree(𝔏)
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Function
open import Structure.Relator.Properties
open import Syntax.Function
direct₊ : ∀{φ : Formula(𝐒(vars))} → ((Γ ∪· φ) ⇒ φ)
direct₊{Γ = Γ}{φ = φ} = induction-on-height(P) (\{vars}{φ} → proof{vars}{φ}) \() where
P = \{vars} (φ : Formula(vars)) → (vars ≢ 𝟎) → ∀{Γ} → (Γ ∪· φ) ⇒ φ
proof : ∀{φ : Formula(vars)} → (∀{vars}{ψ : Formula(vars)} → (height ψ < height φ) → P(ψ)) → P(φ)
proof {𝟎} _ nz with () ← nz [≡]-intro
proof {𝐒 _} {φ = f $ x} prev _ = axiom
proof {𝐒 _} {φ = ⊤} prev _ = weakenₗ ⊤ᵣ
proof {𝐒 _} {φ = ⊥} prev _ = ⊥ₗ
proof {𝐒 _} {φ = φ ∧ ψ} prev nz = ∧ᵣ (∧ₗ (permuteₗ swap (prev (∧-height-orderₗ{φ = φ}{ψ = ψ}) nz))) (∧ₗ (prev (∧-height-orderᵣ{ψ = ψ}{φ = φ}) nz))
proof {𝐒 _} {φ = φ ∨ ψ} prev nz = ∨ₗ (∨ᵣₗ (prev (∨-height-orderₗ{φ = φ}{ψ = ψ}) nz)) (∨ᵣᵣ (prev (∨-height-orderᵣ{ψ = ψ}{φ = φ}) nz))
proof {𝐒 _} {φ = φ ⟶ ψ} prev nz = ⟶ᵣ (permuteₗ swap (⟶ₗ (permuteₗ swap (prev (⟶-height-orderₗ{φ = φ}{ψ = ψ}) nz)) (prev (⟶-height-orderᵣ{ψ = ψ}{φ = φ}) nz)))
proof {𝐒 v} {φ = Ɐ φ} prev nz = Ɐᵣ{n = 𝟎}{v = 𝟎} (Ɐₗ{t = var 𝟎} (weakenₗ (prev (subtransitivityₗ(_≤_)(_≡_) (congruence₁(𝐒) (substitute-height{φ = φ})) (Ɐ-height-order{φ = φ})) nz)))
proof {𝐒 v} {φ = ∃ φ} prev nz = ∃ᵣ{t = var 𝟎} (∃ₗ{n = 𝟎}{v = 𝟎} (prev (subtransitivityₗ(_≤_)(_≡_) (congruence₁(𝐒) (substitute-height{φ = φ})) (Ɐ-height-order{φ = φ})) nz))
no-empty-refl : Meta.¬(∅ ⇒ (⊥ {vars}))
no-empty-refl (permuteₗ perm p) rewrite Proofs.permutes-on-empty perm = no-empty-refl p
no-empty-axiomₗ : Meta.¬(·(p $ x) ⇒ ⊥)
no-empty-axiomₗ (permuteₗ perm p) rewrite Proofs.permutes-on-singleton perm = no-empty-axiomₗ p
no-empty-axiomᵣ : Meta.¬(∅ ⇒ (p $ x))
no-empty-axiomᵣ (permuteₗ perm p) rewrite Proofs.permutes-on-empty perm = no-empty-axiomᵣ p
no-negated-axiomᵣ : Meta.¬(∅ ⇒ (¬(p $ x)))
no-negated-axiomᵣ (permuteₗ perm p) rewrite Proofs.permutes-on-empty perm = no-negated-axiomᵣ p
no-negated-axiomᵣ (⟶ᵣ p) = no-empty-axiomₗ p
-- 3.5.2
substitute-proof : ∀{t : 𝕟(vars₁) → Term(vars₂)} → (Γ ⇒ φ) → ((map(substitute t) Γ) ⇒ (substitute t φ))
substitute-proof p = {!!}
module _ ⦃ pos-prop : ◊(Prop(0)) ⦄ where
no-excludedMiddle : Meta.¬(∀{A : Formula(vars)} → (∅ ⇒ (A ∨ (¬ A))))
no-excludedMiddle as = proof(as{[◊]-existence $ S.∅}) where
proof : Meta.¬(∅ ⇒ ((p $ x) ∨ ¬(p $ x)))
proof (permuteₗ perm q) rewrite Proofs.permutes-on-empty perm = proof q
proof (∨ᵣₗ (permuteₗ perm q)) rewrite Proofs.permutes-on-empty perm = no-empty-axiomᵣ q
proof (∨ᵣᵣ (permuteₗ perm q)) rewrite Proofs.permutes-on-empty perm = no-negated-axiomᵣ q
proof (∨ᵣᵣ (permuteₗ perm (⟶ᵣ q))) rewrite Proofs.permutes-on-empty perm = no-empty-axiomₗ q
proof (∨ᵣᵣ (⟶ᵣ (permuteₗ perm q))) rewrite Proofs.permutes-on-singleton perm = no-empty-axiomₗ q
no-doubleNegation : Meta.¬(∀{A : Formula(vars)} → (∅ ⇒ ((¬ ¬ A) ⟶ A)))
no-doubleNegation as = proof(as{[◊]-existence $ S.∅}) where
proof : Meta.¬(∅ ⇒ ((¬ ¬(p $ x)) ⟶ (p $ x)))
proof (permuteₗ perm q) rewrite Proofs.permutes-on-empty perm = proof q
proof (⟶ᵣ (permuteₗ perm q)) = {!!}
proof (⟶ᵣ (⟶ₗ q (permuteₗ perm q₁))) = {!!}
proof (⟶ᵣ (⟶ₗ (permuteₗ perm q) ⊥ₗ)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ₗ q q₁) ⊥ₗ)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ᵣ q) ⊥ₗ)) = {!!}
test : ∀{T : Type{ℓ}} → (Γ₁ permutes Γ₂) → ((Γ₁ ⇒ φ) → T) → ((Γ₂ ⇒ φ) → T)
test perm p1 p2 = p1 (permuteₗ (symmetry(_permutes_) perm) p2)
{-# INLINE test #-}
no-callCC : Meta.¬(∀{A B : Formula(vars)} → (∅ ⇒ ((A ⟶ B) ⟶ A) ⟶ A))
no-callCC as = proof(as{[◊]-existence $ S.∅}{⊥}) where
proof2 : Meta.¬((∅ ∪· ((p $ x ⟶ ⊥) ⟶ p $ x) ∪· p $ x) ⇒ ⊥)
proof2 (permuteₗ x t) = {!t!}
proof3 : Meta.¬((∅ ∪· p $ x ∪· ((p $ x ⟶ ⊥) ⟶ p $ x)) ⇒ ⊥)
proof3 (permuteₗ perm p) = {!!}
proof3 (⟶ₗ p q) = {!!}
proof : Meta.¬(∅ ⇒ (((p $ x) ⟶ ⊥) ⟶ (p $ x)) ⟶ (p $ x))
proof (permuteₗ perm q) rewrite Proofs.permutes-on-empty perm = proof q
proof (⟶ᵣ (permuteₗ perm q)) rewrite Proofs.permutes-on-singleton perm = {!!}
proof (⟶ᵣ (⟶ₗ (permuteₗ perm q) q₁)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ₗ q (permuteₗ x r)) s)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ₗ q (⟶ᵣ r)) s)) = no-empty-axiomₗ (contract-axiom-bottom r) where
contract-axiom-bottom : ((·(p $ x) ∪· (p $ x)) ⇒ ⊥) → (·(p $ x) ⇒ ⊥)
contract-axiom-bottom (permuteₗ x p) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ perm q)) r)) = proof2 (permuteₗ perm q)
-- proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ perm q)) r)) = test (trans swap (symmetry(_permutes_) perm)) (proof ↦ {!⟶ᵣ proof!}) q
{-proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ perm q)) r)) = test (symmetry(_permutes_) perm) proof2 q where
proof2 : Meta.¬((∅ ∪· ((p $ x ⟶ ⊥) ⟶ p $ x) ∪· p $ x) ⇒ ⊥)
proof2 (permuteₗ perm p) = test (symmetry(_permutes_) perm) proof2 p-}
{-proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ (prepend perm) q)) r)) rewrite permutes-on-singleton perm = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ swap (permuteₗ perm q))) r)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ swap (⟶ₗ q₁ (permuteₗ perm q₂)))) r)) = {!!}
proof (⟶ᵣ (⟶ₗ (⟶ᵣ (permuteₗ (trans perm₁ perm₂) q)) r)) = {!!}-}
--⟶ₗ : ((Γ ∪· (A ⟶ B)) ⇒ A) → ((Γ ∪· B) ⇒ A) → ((Γ ∪· (A ⟶ B)) ⇒ A)
| 48.61086
| 187
| 0.528344
|
1028a561a94590a76c4c79c6a7b0aa39848b5d21
| 337
|
agda
|
Agda
|
agda/BHeap/Order.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | 6
|
2015-05-21T12:50:35.000Z
|
2021-08-24T22:11:15.000Z
|
agda/BHeap/Order.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
agda/BHeap/Order.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
module BHeap.Order {A : Set}(_≤_ : A → A → Set) where
open import BHeap _≤_
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Data.Nat
_≺_ : {b b' : Bound} → BHeap b → BHeap b' → Set
h ≺ h' = # h <′ # h'
data Acc {b' : Bound}(h' : BHeap b') : Set where
acc : (∀ {b} h → (_≺_ {b} {b'} h h') → Acc h) → Acc h'
| 24.071429
| 56
| 0.560831
|
d0922624bf2304a946c23bab21f382eab02e79c7
| 512
|
agda
|
Agda
|
test/Fail/IdiomBracketsImplicit.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/IdiomBracketsImplicit.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/IdiomBracketsImplicit.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ where
open import Agda.Builtin.Nat
postulate
F : Set → Set
pure : ∀ {A} → A → F A
_<*>_ : ∀ {A B} → F (A → B) → F A → F B
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
ok : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n))
ok n a as = (| a ∷ as |)
ok₂ : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n))
ok₂ n a as = (| (_∷_ {n = n}) a as |)
fail : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n))
fail n a as = (| _∷_ {n = n} a as |)
| 22.26087
| 56
| 0.462891
|
10931b7314d8dc41b12d1f56b7726357c9e8a332
| 168
|
agda
|
Agda
|
test/Fail/NoTerminationCheck2.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/NoTerminationCheck2.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/NoTerminationCheck2.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
-- 2012-03-08 Andreas
module NoTerminationCheck2 where
{-# NON_TERMINATING #-}
data D : Set where
lam : (D -> D) -> D
-- error: works only for function definitions
| 18.666667
| 45
| 0.684524
|
20bffa998f42584346e9a9aea0a76f580bcac2dc
| 6,593
|
agda
|
Agda
|
test/Succeed/Issue906EtAl.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2021-06-14T11:08:59.000Z
|
2021-06-14T11:08:59.000Z
|
test/Succeed/Issue906EtAl.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T15:49:15.000Z
|
2015-09-15T15:49:15.000Z
|
test/Succeed/Issue906EtAl.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2020-02-06, issue #906, and #942 #2068 #3136 #3431 #4391 #4418
--
-- Termination checker now tries to reduce calls away
-- using non-recursive clauses.
--
-- This fixes the problem that for dependent copattern definitions
-- the earlier, non-recursive clauses get into non-guarded positions
-- in later clauses via Agda's constraint solver, and there confuse
-- the termination checker.
module Issue906EtAl where
module Issue906 where
{- Globular types as a coinductive record -}
record Glob : Set1 where
coinductive
field
Ob : Set
Hom : (a b : Ob) → Glob
open Glob
record Unit : Set where
data _==_ {A : Set} (a : A) : A → Set where
refl : a == a
{- The terminal globular type -}
Unit-glob : Glob
Ob Unit-glob = Unit
Hom Unit-glob _ _ = Unit-glob
{- The tower of identity types -}
Id-glob : (A : Set) → Glob
Ob (Id-glob A) = A
Hom (Id-glob A) a b = Id-glob (a == b)
module Issue907 where
data _==_ {A : Set} (a : A) : A → Set where
idp : a == a
-- Coinductive equivalences
record CoEq (A B : Set) : Set where
coinductive
constructor coEq
field to : A → B
from : B → A
eq : (a : A) (b : B) → CoEq (a == from b) (to a == b)
open CoEq public
id-CoEq : (A : Set) → CoEq A A
to (id-CoEq A) a = a
from (id-CoEq A) b = b
eq (id-CoEq A) a b = id-CoEq _ -- Keep underscore!
-- Solution: (a == from (id-CoEq A) b)
-- contains recursive call
module Issue942 where
record Sigma (A : Set)(P : A → Set) : Set where
constructor _,_
field
fst : A
snd : P fst
open Sigma
postulate
A : Set
x : A
P Q : A → Set
Px : P x
f : ∀ {x} → P x → Q x
ex : Sigma A Q
ex = record
{ fst = x
; snd = f Px -- goal: P x
}
ex' : Sigma A Q
ex' = x , f Px -- goal: P x
ex'' : Sigma A Q
fst ex'' = x
snd ex'' = f Px -- goal: P (fst ex'')
module Issue2068-OP where
data _==_ {A : Set} : A → A → Set where
refl : {a : A} → a == a
data Bool : Set where
tt : Bool
ff : Bool
record TwoEqualFunctions : Set₁ where
field
A : Set
B : Set
f : A → B
g : A → B
p : f == g
postulate
funext : {A B : Set} {f g : A → B} → ((a : A) → f a == g a) → f == g
identities : TwoEqualFunctions
TwoEqualFunctions.A identities = Bool
TwoEqualFunctions.B identities = Bool
TwoEqualFunctions.f identities x = x
TwoEqualFunctions.g identities = λ{tt → tt ; ff → ff}
TwoEqualFunctions.p identities = funext (λ{tt → refl ; ff → refl})
module Issue2068b where
data _==_ {A : Set} : (a : A) → A → Set where
refl : (a : A) → a == a
data Unit : Set where
unit : Unit
record R : Set₁ where
field
f : Unit → Unit
p : f == λ x → x
postulate
extId : (f : Unit → Unit) → (∀ a → f a == a) → f == λ x → x
test : R
R.f test = λ{ unit → unit }
R.p test = extId _ λ{ unit → refl _ }
-- R.p test = extId {! R.f test !} λ{unit → refl {! R.f test unit !}}
module Issue2068c where
record _×_ (A B : Set) : Set where
field fst : A
snd : B
open _×_
test : ∀{A} (a : A) → (A → A) × (A → A)
fst (test a) x = a
snd (test a) x = fst (test a) (snd (test a) x)
module Issue3136 (A : Set) where
-- Andreas, 2018-07-22, issue #3136
-- WAS: Internal error when printing termination errors
postulate
any : {X : Set} → X
x : A
P : A → Set
record C : Set where
field
a : A
b : P a
c : C
c = λ where
.C.a → x
.C.b → λ where
→ any
-- NOW: succeeds
module Issue3413 where
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
postulate
A : Set
P : ∀{X : Set} → X → Set
record Bob : Set₁ where
field
RE : Set
resp : RE → Set
open Bob
bob : Bob
bob .RE = A
bob .resp e = Σ (P e) λ {x → A}
module Issue4391 where
record GlobSet : Set₁ where
coinductive
field
cells : Set
morphisms : cells → cells → GlobSet
open GlobSet public
record GlobSetMorphism (G H : GlobSet) : Set where
coinductive
field
func : cells G → cells H
funcMorphisms : (x y : cells G)
→ GlobSetMorphism (morphisms G x y)
(morphisms H (func x) (func y))
open GlobSetMorphism public
gComp : {G H I : GlobSet} → GlobSetMorphism H I → GlobSetMorphism G H → GlobSetMorphism G I
func (gComp ϕ ψ) x = func ϕ (func ψ x)
funcMorphisms (gComp ϕ ψ) x y = gComp (funcMorphisms ϕ (func ψ x) (func ψ y)) (funcMorphisms ψ x y)
module Issue4391Nisse where
record GlobSet : Set₁ where
coinductive
field
cells : Set
morphisms : cells → cells → GlobSet
open GlobSet public
mutual
record GlobSetMorphism (G H : GlobSet) : Set where
inductive
field
func : cells G → cells H
funcMorphisms : (x y : cells G) →
GlobSetMorphism′
(morphisms G x y)
(morphisms H (func x) (func y))
record GlobSetMorphism′ (G H : GlobSet) : Set where
coinductive
field
force : GlobSetMorphism G H
open GlobSetMorphism public
open GlobSetMorphism′ public
works fails :
{G H I : GlobSet} →
GlobSetMorphism H I → GlobSetMorphism G H → GlobSetMorphism G I
works ϕ ψ = record
{ func = λ x → func ϕ (func ψ x)
; funcMorphisms = λ { x y .force →
works (funcMorphisms ϕ (func ψ x) (func ψ y) .force)
(funcMorphisms ψ x y .force) }
}
fails ϕ ψ .func = λ x → func ϕ (func ψ x)
fails ϕ ψ .funcMorphisms = λ { x y .force →
fails (funcMorphisms ϕ (func ψ x) (func ψ y) .force)
(funcMorphisms ψ x y .force) }
module Issue4418 {l}
(Index : Set l)
(Shape : Index → Set l)
(Position : (i : Index) → Shape i → Set l)
(index : (i : Index) → (s : Shape i) → Position i s → Index) where
record M (i : Index) : Set l where
coinductive
field shape : Shape i
field children : (p : Position i shape) → M (index i shape p)
open M
record MBase (Rec : Index → Set l) (i : Index) : Set l where
coinductive
field shapeB : Shape i
field childrenB : (p : Position i shapeB) → Rec (index i shapeB p)
open MBase
module _ (S : Index → Set l) (u : ∀ {i} → S i → MBase S i) where
unroll : ∀ i → S i → M i
unroll i s .shape = u s .shapeB
unroll i s .children p = unroll _ (u s .childrenB p)
-- Underscore solved as: index i (u s .shapeB) p
| 22.892361
| 101
| 0.559381
|
cba18ad0c2195c0a1b7fa3e0d38c62844e91fa93
| 248
|
agda
|
Agda
|
cohesion/david_jaz_261/Axiom/C1.agda
|
glangmead/formalization
|
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
|
[
"CC0-1.0"
] | 6
|
2021-10-06T17:39:22.000Z
|
2022-02-13T05:51:12.000Z
|
cohesion/david_jaz_261/Axiom/C1.agda
|
glangmead/formalization
|
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
|
[
"CC0-1.0"
] | null | null | null |
cohesion/david_jaz_261/Axiom/C1.agda
|
glangmead/formalization
|
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
|
[
"CC0-1.0"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import Basics
open import lib.Basics
open import Flat
module Axiom.C1 {@♭ i j : ULevel} (@♭ I : Type i) (@♭ R : I → Type j) where
open import Axiom.C0 I R
postulate C1 : (index : I) → R index
| 22.545455
| 75
| 0.620968
|
0e3e8265200a5b4def54f58a7667f0a8c7078c3d
| 7,106
|
agda
|
Agda
|
src/LinearLogic.agda
|
wenkokke/msla2014
|
b880cf25ed8e81b9a965ea9aad18377008d68a9f
|
[
"MIT"
] | 5
|
2018-11-17T23:04:39.000Z
|
2020-10-29T09:07:45.000Z
|
src/LinearLogic.agda
|
wenkokke/msla2014
|
b880cf25ed8e81b9a965ea9aad18377008d68a9f
|
[
"MIT"
] | null | null | null |
src/LinearLogic.agda
|
wenkokke/msla2014
|
b880cf25ed8e81b9a965ea9aad18377008d68a9f
|
[
"MIT"
] | null | null | null |
open import Function using (case_of_; _∘_)
open import Data.List using (List; _++_; map) renaming (_∷_ to _,_; _∷ʳ_ to _,′_; [] to ∅)
open import Data.List.Properties using (map-++-commute)
open import Data.Product using () renaming (_×_ to _x'_)
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl; sym; cong)
module LinearLogic (U : Set) (R : U) (⟦_⟧ᵁ : U → Set) where
infixr 40 ¬_
infix 30 _⊗_
infixr 20 _⊸_
infix 4 _⊢_
data Type : Set where
el : (A : U) → Type
⊥ : Type
_⊗_ : Type → Type → Type
_⊸_ : Type → Type → Type
data _⊢_ : ∀ (X : List Type) (A : Type) → Set where
var : ∀ {A} → A , ∅ ⊢ A
abs : ∀ {X A B} → A , X ⊢ B → X ⊢ A ⊸ B
app : ∀ {X Y A B} → X ⊢ A ⊸ B → Y ⊢ A → X ++ Y ⊢ B
pair : ∀ {X Y A B} → X ⊢ A → Y ⊢ B → X ++ Y ⊢ A ⊗ B
case : ∀ {X Y A B C } → X ⊢ A ⊗ B → A , B , Y ⊢ C → X ++ Y ⊢ C
exch : ∀ {X Y Z W A} → (X ++ Z) ++ (Y ++ W) ⊢ A
→ (X ++ Y) ++ (Z ++ W) ⊢ A
¬_ : Type → Type
¬ A = A ⊸ ⊥
exch₀ : ∀ {A B C X} → A , B , X ⊢ C → B , A , X ⊢ C
exch₀ {A} {B} {X = X} t = exch {∅} {B , ∅} {A , ∅} {X} t
swap : ∀ {A B} → ∅ ⊢ A ⊗ B ⊸ B ⊗ A
swap {A} {B} = abs (case var (exch₀ (pair var var)))
raise : ∀ {A B X} → X ⊢ A → X ⊢ (A ⊸ B) ⊸ B
raise t = abs (app var t)
++-assoc : ∀ {a} {A : Set a} (X Y Z : List A) → X ++ (Y ++ Z) ≡ (X ++ Y) ++ Z
++-assoc ∅ Y Z = refl
++-assoc (x , X) Y Z = cong (_,_ x) (++-assoc X Y Z)
xs++[]=xs : ∀ {a} {A : Set a} (xs : List A) → xs ++ ∅ ≡ xs
xs++[]=xs ∅ = refl
xs++[]=xs (x , xs) = cong (_,_ x) (xs++[]=xs xs)
to-front : ∀ {X A B} → A , X ⊢ B → X ,′ A ⊢ B
to-front {X} {A} {B} t = lem1 lem2
where
lem1 : A , (X ++ ∅) ⊢ B → X ,′ A ⊢ B
lem1 = exch {∅} {X} {A , ∅} {∅}
lem2 : A , (X ++ ∅) ⊢ B
lem2 rewrite xs++[]=xs X = t
to-back : ∀ {X A B} → X ,′ A ⊢ B → A , X ⊢ B
to-back {X} {A} {B} t = lem2
where
lem1 : A , X ++ ∅ ⊢ B
lem1 = exch {∅} {A , ∅} {X} {∅} t
lem2 : A , X ⊢ B
lem2 rewrite sym (xs++[]=xs (A , X)) = lem1
YX↝XY : ∀ {A} X Y → Y ++ X ⊢ A → X ++ Y ⊢ A
YX↝XY {A} X Y t = lem₃
where
lem₁ : Y ++ X ++ ∅ ⊢ A
lem₁ rewrite xs++[]=xs X = t
lem₂ : X ++ Y ++ ∅ ⊢ A
lem₂ = exch {∅} {X} {Y} {∅} lem₁
lem₃ : X ++ Y ⊢ A
lem₃ = PropEq.subst (λ Y → X ++ Y ⊢ A) (xs++[]=xs Y) lem₂
Y[XZ]↝X[YZ] : ∀ {A} X Y Z → Y ++ (X ++ Z) ⊢ A → X ++ (Y ++ Z) ⊢ A
Y[XZ]↝X[YZ] {A} X Y Z t = exch {∅} {X} {Y} {Z} t
[YX]Z↝[XY]Z : ∀ {A} X Y Z → (Y ++ X) ++ Z ⊢ A → (X ++ Y) ++ Z ⊢ A
[YX]Z↝[XY]Z {A} X Y Z t = lem₃
where
lem₁ : Y ++ (X ++ Z) ⊢ A
lem₁ rewrite ++-assoc Y X Z = t
lem₂ : X ++ (Y ++ Z) ⊢ A
lem₂ = Y[XZ]↝X[YZ] X Y Z lem₁
lem₃ : (X ++ Y) ++ Z ⊢ A
lem₃ rewrite sym (++-assoc X Y Z) = lem₂
[XZ]Y↝[XY]Z : ∀ {A} X Y Z → (X ++ Z) ++ Y ⊢ A → (X ++ Y) ++ Z ⊢ A
[XZ]Y↝[XY]Z {A} X Y Z t = lem₃
where
lem₁ : (X ++ Z) ++ Y ++ ∅ ⊢ A
lem₁ rewrite xs++[]=xs Y = t
lem₂ : (X ++ Y) ++ Z ++ ∅ ⊢ A
lem₂ = exch {X} {Y} {Z} {∅} lem₁
lem₃ : (X ++ Y) ++ Z ⊢ A
lem₃ = PropEq.subst (λ Z → (X ++ Y) ++ Z ⊢ A) (xs++[]=xs Z) lem₂
X[ZY]↝X[YZ] : ∀ {A} X Y Z → X ++ (Z ++ Y) ⊢ A → X ++ (Y ++ Z) ⊢ A
X[ZY]↝X[YZ] {A} X Y Z t = lem₃
where
lem₁ : (X ++ Z) ++ Y ⊢ A
lem₁ rewrite sym (++-assoc X Z Y) = t
lem₂ : (X ++ Y) ++ Z ⊢ A
lem₂ = [XZ]Y↝[XY]Z X Y Z lem₁
lem₃ : X ++ Y ++ Z ⊢ A
lem₃ rewrite ++-assoc X Y Z = lem₂
XYZW↝XWZY : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (X ++ W) ++ (Z ++ Y) ⊢ A
XYZW↝XWZY {A} X Y Z W t = lem₃
where
lem₁ : (X ++ Y) ++ (W ++ Z) ⊢ A
lem₁ = X[ZY]↝X[YZ] (X ++ Y) W Z t
lem₂ : (X ++ W) ++ (Y ++ Z) ⊢ A
lem₂ = exch {X} {W} {Y} {Z} lem₁
lem₃ : (X ++ W) ++ (Z ++ Y) ⊢ A
lem₃ = X[ZY]↝X[YZ] (X ++ W) Z Y lem₂
XYZW↝YWXZ : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Y ++ W) ++ (X ++ Z) ⊢ A
XYZW↝YWXZ {A} X Y Z W t = lem₃
where
lem₁ : (Y ++ X) ++ (Z ++ W) ⊢ A
lem₁ = [YX]Z↝[XY]Z Y X (Z ++ W) t
lem₂ : (Y ++ X) ++ (W ++ Z) ⊢ A
lem₂ = X[ZY]↝X[YZ] (Y ++ X) W Z lem₁
lem₃ : (Y ++ W) ++ (X ++ Z) ⊢ A
lem₃ = exch {Y} {W} {X} {Z} lem₂
XYZW↝ZXWY : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Z ++ X) ++ (W ++ Y) ⊢ A
XYZW↝ZXWY {A} X Y Z W t = lem₃
where
lem₁ : (X ++ Z) ++ (Y ++ W) ⊢ A
lem₁ = exch {X} {Z} {Y} {W} t
lem₂ : (Z ++ X) ++ (Y ++ W) ⊢ A
lem₂ = [YX]Z↝[XY]Z Z X (Y ++ W) lem₁
lem₃ : (Z ++ X) ++ (W ++ Y) ⊢ A
lem₃ = X[ZY]↝X[YZ] (Z ++ X) W Y lem₂
XYZW↝ZYXW : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Z ++ Y) ++ (X ++ W) ⊢ A
XYZW↝ZYXW {A} X Y Z W t = lem₃
where
lem₁ : (Y ++ X) ++ (Z ++ W) ⊢ A
lem₁ = [YX]Z↝[XY]Z Y X (Z ++ W) t
lem₂ : (Y ++ Z) ++ (X ++ W) ⊢ A
lem₂ = exch {Y} {Z} {X} {W} lem₁
lem₃ : (Z ++ Y) ++ (X ++ W) ⊢ A
lem₃ = [YX]Z↝[XY]Z Z Y (X ++ W) lem₂
pair-left : ∀ {X A B C} → A , B , X ⊢ C → A ⊗ B , X ⊢ C
pair-left t = case var t
pair-left′ : ∀ {X A B C} → X ++ (A , B , ∅) ⊢ C → X ,′ A ⊗ B ⊢ C
pair-left′ {X} {A} {B} {C} = lem₃
where
lem₁ : X ,′ A ,′ B ⊢ C → X ,′ A ⊗ B ⊢ C
lem₁ t = to-front (pair-left (to-back {B , X} {A} (to-back {X ,′ A} {B} t)))
lem₂ : ∀ {a} {A : Set a} xs (y z : A) → xs ,′ y ,′ z ≡ xs ++ (y , z , ∅)
lem₂ ∅ y z = refl
lem₂ (x , xs) y z = cong (_,_ x) (lem₂ xs y z)
lem₃ : X ++ (A , B , ∅) ⊢ C → X ,′ A ⊗ B ⊢ C
lem₃ rewrite sym (lem₂ X A B) = lem₁
open import IntuitionisticLogic U ⟦_⟧ᵁ as IL renaming (Type to TypeIL; _⊗_ to _×_)
open IL.Explicit
hiding (swap; swap′)
renaming (_⊢_ to _⊢IL_; ReifyType to ReifyTypeIL; ReifyCtxt to ReiftCtxtIL; [_] to reifyIL)
instance
ReifyType : Reify Type TypeIL
ReifyType = record { ⟦_⟧ = ⟦_⟧ }
where
⟦_⟧ : Type → TypeIL
⟦ ⊥ ⟧ = el R
⟦ el A ⟧ = el A
⟦ A ⊗ B ⟧ = ⟦ A ⟧ × ⟦ B ⟧
⟦ A ⊸ B ⟧ = ⟦ A ⟧ ⇒ ⟦ B ⟧
open Reify {{...}} using (⟦_⟧)
instance
ReifyCtxt : Reify (List Type) (List TypeIL)
ReifyCtxt = record { ⟦_⟧ = map ⟦_⟧ }
⟦X++Y⟧=⟦X⟧++⟦Y⟧ : (X Y : List Type) → ⟦ X ++ Y ⟧ ≡ ⟦ X ⟧ ++ ⟦ Y ⟧
⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = map-++-commute ⟦_⟧ X Y
toIL : ∀ {X A} → X ⊢ A → ⟦ X ⟧ ⊢IL ⟦ A ⟧
toIL var = var
toIL (abs t) = abs (toIL t)
toIL (app {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = app (toIL s) (toIL t)
toIL (pair {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = pair (toIL s) (toIL t)
toIL (case {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = case (toIL s) (toIL t)
toIL (exch {X} {Y} {Z} {W} {A} t) = lem4
where
lem1 : ⟦ (X ++ Z) ++ (Y ++ W) ⟧ ⊢IL ⟦ A ⟧
lem1 = toIL t
lem2 : (⟦ X ⟧ ++ ⟦ Z ⟧) ++ (⟦ Y ⟧ ++ ⟦ W ⟧) ⊢IL ⟦ A ⟧
lem2 rewrite sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Z)
| sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ Y W)
| sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ (X ++ Z) (Y ++ W)) = lem1
lem3 : (⟦ X ⟧ ++ ⟦ Y ⟧) ++ (⟦ Z ⟧ ++ ⟦ W ⟧) ⊢IL ⟦ A ⟧
lem3 = exch {⟦ X ⟧} {⟦ Y ⟧} {⟦ Z ⟧} {⟦ W ⟧} lem2
lem4 : ⟦ (X ++ Y) ++ (Z ++ W) ⟧ ⊢IL ⟦ A ⟧
lem4 rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ (X ++ Y) (Z ++ W)
| ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y
| ⟦X++Y⟧=⟦X⟧++⟦Y⟧ Z W = lem3
[_] : {A : Type} {X : List Type} → X ⊢ A → (Ctxt ⟦ ⟦ X ⟧ ⟧ → ⟦ ⟦ A ⟧ ⟧)
[_] = reifyIL ∘ toIL
swap′ : {A B : Type} → ⟦ ⟦ A ⟧ ⟧ x' ⟦ ⟦ B ⟧ ⟧ → ⟦ ⟦ B ⟧ ⟧ x' ⟦ ⟦ A ⟧ ⟧
swap′ {A} {B} = [ swap {A} {B} ] ∅
| 33.205607
| 93
| 0.40121
|
c5a4983c8a50f4eb6104aab757e103b74f2a6539
| 10,863
|
agda
|
Agda
|
Cubical/HITs/PropositionalTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/HITs/PropositionalTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/HITs/PropositionalTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Eliminator for propositional truncation
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.PropositionalTruncation.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓ : Level
A B C : Type ℓ
rec : ∀ {P : Type ℓ} → isProp P → (A → P) → ∥ A ∥ → P
rec Pprop f ∣ x ∣ = f x
rec Pprop f (squash x y i) = Pprop (rec Pprop f x) (rec Pprop f y) i
rec2 : ∀ {P : Type ℓ} → isProp P → (A → A → P) → ∥ A ∥ → ∥ A ∥ → P
rec2 Pprop f = rec (isPropΠ (λ _ → Pprop))
(λ a → rec Pprop (f a))
elim : ∀ {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a))
→ ((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a
elim Pprop f ∣ x ∣ = f x
elim Pprop f (squash x y i) =
isOfHLevel→isOfHLevelDep 1 Pprop
(elim Pprop f x) (elim Pprop f y) (squash x y) i
elim2 : {P : ∥ A ∥ → ∥ A ∥ → Type ℓ}
(Bset : ((x y : ∥ A ∥) → isProp (P x y)))
(g : (a b : A) → P ∣ a ∣ ∣ b ∣)
(x y : ∥ A ∥) → P x y
elim2 Pprop g = elim (λ _ → isPropΠ (λ _ → Pprop _ _))
(λ a → elim (λ _ → Pprop _ _) (g a))
elim3 : {P : ∥ A ∥ → ∥ A ∥ → ∥ A ∥ → Type ℓ}
(Bset : ((x y z : ∥ A ∥) → isProp (P x y z)))
(g : (a b c : A) → P (∣ a ∣) ∣ b ∣ ∣ c ∣)
(x y z : ∥ A ∥) → P x y z
elim3 Pprop g = elim2 (λ _ _ → isPropΠ (λ _ → Pprop _ _ _))
(λ a b → elim (λ _ → Pprop _ _ _) (g a b))
propTruncIsProp : isProp ∥ A ∥
propTruncIsProp x y = squash x y
propTruncIdempotent≃ : isProp A → ∥ A ∥ ≃ A
propTruncIdempotent≃ {A = A} hA = isoToEquiv f
where
f : Iso ∥ A ∥ A
Iso.fun f = rec hA (idfun A)
Iso.inv f x = ∣ x ∣
Iso.rightInv f _ = refl
Iso.leftInv f = elim (λ _ → isProp→isSet propTruncIsProp _ _) (λ _ → refl)
propTruncIdempotent : isProp A → ∥ A ∥ ≡ A
propTruncIdempotent hA = ua (propTruncIdempotent≃ hA)
-- We could also define the eliminator using the recursor
elim' : ∀ {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a)) →
((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a
elim' {P = P} Pprop f a =
rec (Pprop a) (λ x → transp (λ i → P (squash ∣ x ∣ a i)) i0 (f x)) a
map : (A → B) → (∥ A ∥ → ∥ B ∥)
map f = rec squash (∣_∣ ∘ f)
map2 : (A → B → C) → (∥ A ∥ → ∥ B ∥ → ∥ C ∥)
map2 f = rec (isPropΠ λ _ → squash) (map ∘ f)
-- The propositional truncation can be eliminated into non-propositional
-- types as long as the function used in the eliminator is 'coherently
-- constant.' The details of this can be found in the following paper:
--
-- https://arxiv.org/pdf/1411.2682.pdf
module SetElim (Bset : isSet B) where
Bset' : isSet' B
Bset' = isSet→isSet' Bset
rec→Set : (f : A → B) (kf : 2-Constant f) → ∥ A ∥ → B
helper : (f : A → B) (kf : 2-Constant f) → (t u : ∥ A ∥)
→ rec→Set f kf t ≡ rec→Set f kf u
rec→Set f kf ∣ x ∣ = f x
rec→Set f kf (squash t u i) = helper f kf t u i
helper f kf ∣ x ∣ ∣ y ∣ = kf x y
helper f kf (squash t u i) v
= Bset' (helper f kf t v) (helper f kf u v) (helper f kf t u) refl i
helper f kf t (squash u v i)
= Bset' (helper f kf t u) (helper f kf t v) refl (helper f kf u v) i
kcomp : ∀(f : ∥ A ∥ → B) → 2-Constant (f ∘ ∣_∣)
kcomp f x y = cong f (squash ∣ x ∣ ∣ y ∣)
Fset : isSet (A → B)
Fset = isSetΠ (const Bset)
Kset : (f : A → B) → isSet (2-Constant f)
Kset f = isSetΠ (λ _ → isSetΠ (λ _ → isProp→isSet (Bset _ _)))
setRecLemma
: (f : ∥ A ∥ → B)
→ rec→Set (f ∘ ∣_∣) (kcomp f) ≡ f
setRecLemma f i t
= elim {P = λ t → rec→Set (f ∘ ∣_∣) (kcomp f) t ≡ f t}
(λ t → Bset _ _) (λ x → refl) t i
mkKmap : (∥ A ∥ → B) → Σ (A → B) 2-Constant
mkKmap f = f ∘ ∣_∣ , kcomp f
fib : (g : Σ (A → B) 2-Constant) → fiber mkKmap g
fib (g , kg) = rec→Set g kg , refl
eqv : (g : Σ (A → B) 2-Constant)
→ ∀ fi → fib g ≡ fi
eqv g (f , p) =
ΣProp≡ (λ f → isOfHLevelΣ 2 Fset Kset _ _)
(cong (uncurry rec→Set) (sym p) ∙ setRecLemma f)
trunc→Set≃ : (∥ A ∥ → B) ≃ (Σ (A → B) 2-Constant)
trunc→Set≃ .fst = mkKmap
trunc→Set≃ .snd .equiv-proof g = fib g , eqv g
-- The strategy of this equivalence proof follows the paper more closely.
-- It is used further down for the groupoid version, because the above
-- strategy does not generalize so easily.
e : B → Σ (A → B) 2-Constant
e b = const b , λ _ _ → refl
eval : A → (γ : Σ (A → B) 2-Constant) → B
eval a₀ (g , _) = g a₀
e-eval : ∀ (a₀ : A) γ → e (eval a₀ γ) ≡ γ
e-eval a₀ (g , kg) i .fst a₁ = kg a₀ a₁ i
e-eval a₀ (g , kg) i .snd a₁ a₂ = Bset' refl (kg a₁ a₂) (kg a₀ a₁) (kg a₀ a₂) i
e-isEquiv : A → isEquiv (e {A = A})
e-isEquiv a₀ = isoToIsEquiv (iso e (eval a₀) (e-eval a₀) λ _ → refl)
preEquiv₁ : ∥ A ∥ → B ≃ Σ (A → B) 2-Constant
preEquiv₁ t = e , rec (isPropIsEquiv e) e-isEquiv t
preEquiv₂ : (∥ A ∥ → Σ (A → B) 2-Constant) ≃ Σ (A → B) 2-Constant
preEquiv₂ = isoToEquiv (iso to const (λ _ → refl) retr)
where
to : (∥ A ∥ → Σ (A → B) 2-Constant) → Σ (A → B) 2-Constant
to f .fst x = f ∣ x ∣ .fst x
to f .snd x y i = f (squash ∣ x ∣ ∣ y ∣ i) .snd x y i
retr : retract to const
retr f i t .fst x = f (squash ∣ x ∣ t i) .fst x
retr f i t .snd x y
= Bset'
(λ j → f (squash ∣ x ∣ ∣ y ∣ j) .snd x y j)
(f t .snd x y)
(λ j → f (squash ∣ x ∣ t j) .fst x)
(λ j → f (squash ∣ y ∣ t j) .fst y)
i
trunc→Set≃₂ : (∥ A ∥ → B) ≃ Σ (A → B) 2-Constant
trunc→Set≃₂ = compEquiv (equivPi preEquiv₁) preEquiv₂
open SetElim public using (rec→Set; trunc→Set≃)
elim→Set
: {P : ∥ A ∥ → Set ℓ}
→ (∀ t → isSet (P t))
→ (f : (x : A) → P ∣ x ∣)
→ (kf : ∀ x y → PathP (λ i → P (squash ∣ x ∣ ∣ y ∣ i)) (f x) (f y))
→ (t : ∥ A ∥) → P t
elim→Set {A = A} {P = P} Pset f kf t
= rec→Set (Pset t) g gk t
where
g : A → P t
g x = transp (λ i → P (squash ∣ x ∣ t i)) i0 (f x)
gk : 2-Constant g
gk x y i = transp (λ j → P (squash (squash ∣ x ∣ ∣ y ∣ i) t j)) i0 (kf x y i)
RecHProp : (P : A → hProp ℓ) (kP : ∀ x y → P x ≡ P y) → ∥ A ∥ → hProp ℓ
RecHProp P kP = rec→Set isSetHProp P kP
module GpdElim (Bgpd : isGroupoid B) where
Bgpd' : isGroupoid' B
Bgpd' = isGroupoid→isGroupoid' Bgpd
module _ (f : A → B) (3kf : 3-Constant f) where
open 3-Constant 3kf
rec→Gpd : ∥ A ∥ → B
pathHelper : (t u : ∥ A ∥) → rec→Gpd t ≡ rec→Gpd u
triHelper₁
: (t u v : ∥ A ∥)
→ Square (pathHelper t u) (pathHelper t v) refl (pathHelper u v)
triHelper₂
: (t u v : ∥ A ∥)
→ Square (pathHelper t v) (pathHelper u v) (pathHelper t u) refl
rec→Gpd ∣ x ∣ = f x
rec→Gpd (squash t u i) = pathHelper t u i
pathHelper ∣ x ∣ ∣ y ∣ = link x y
pathHelper (squash t u j) v = triHelper₂ t u v j
pathHelper ∣ x ∣ (squash u v j) = triHelper₁ ∣ x ∣ u v j
triHelper₁ ∣ x ∣ ∣ y ∣ ∣ z ∣ = coh₁ x y z
triHelper₁ (squash s t i) u v
= Bgpd'
(triHelper₁ s u v)
(triHelper₁ t u v)
(triHelper₂ s t u)
(triHelper₂ s t v)
(λ i → refl)
(λ i → pathHelper u v)
i
triHelper₁ ∣ x ∣ (squash t u i) v
= Bgpd'
(triHelper₁ ∣ x ∣ t v)
(triHelper₁ ∣ x ∣ u v)
(triHelper₁ ∣ x ∣ t u)
(λ i → pathHelper ∣ x ∣ v)
(λ i → refl)
(triHelper₂ t u v)
i
triHelper₁ ∣ x ∣ ∣ y ∣ (squash u v i)
= Bgpd'
(triHelper₁ ∣ x ∣ ∣ y ∣ u)
(triHelper₁ ∣ x ∣ ∣ y ∣ v)
(λ i → link x y)
(triHelper₁ ∣ x ∣ u v)
(λ i → refl)
(triHelper₁ ∣ y ∣ u v)
i
triHelper₂ ∣ x ∣ ∣ y ∣ ∣ z ∣ = coh₂ x y z
triHelper₂ (squash s t i) u v
= Bgpd'
(triHelper₂ s u v)
(triHelper₂ t u v)
(triHelper₂ s t v)
(λ i → pathHelper u v)
(triHelper₂ s t u)
(λ i → refl)
i
triHelper₂ ∣ x ∣ (squash t u i) v
= Bgpd'
(triHelper₂ ∣ x ∣ t v)
(triHelper₂ ∣ x ∣ u v)
(λ i → pathHelper ∣ x ∣ v)
(triHelper₂ t u v)
(triHelper₁ ∣ x ∣ t u)
(λ i → refl)
i
triHelper₂ ∣ x ∣ ∣ y ∣ (squash u v i)
= Bgpd'
(triHelper₂ ∣ x ∣ ∣ y ∣ u)
(triHelper₂ ∣ x ∣ ∣ y ∣ v)
(triHelper₁ ∣ x ∣ u v)
(triHelper₁ ∣ y ∣ u v)
(λ i → link x y)
(λ i → refl)
i
preEquiv₁ : (∥ A ∥ → Σ (A → B) 3-Constant) ≃ Σ (A → B) 3-Constant
preEquiv₁ = isoToEquiv (iso fn const (λ _ → refl) retr)
where
open 3-Constant
fn : (∥ A ∥ → Σ (A → B) 3-Constant) → Σ (A → B) 3-Constant
fn f .fst x = f ∣ x ∣ .fst x
fn f .snd .link x y i = f (squash ∣ x ∣ ∣ y ∣ i) .snd .link x y i
fn f .snd .coh₁ x y z i j
= f (squash ∣ x ∣ (squash ∣ y ∣ ∣ z ∣ i) j) .snd .coh₁ x y z i j
retr : retract fn const
retr f i t .fst x = f (squash ∣ x ∣ t i) .fst x
retr f i t .snd .link x y j
= f (squash (squash ∣ x ∣ ∣ y ∣ j) t i) .snd .link x y j
retr f i t .snd .coh₁ x y z
= Bgpd'
(λ k j → f (cb k j i0) .snd .coh₁ x y z k j )
(λ k j → f (cb k j i1) .snd .coh₁ x y z k j)
(λ k j → f (cb i0 j k) .snd .link x y j)
(λ k j → f (cb i1 j k) .snd .link x z j)
(λ _ → refl)
(λ k j → f (cb j i1 k) .snd .link y z j)
i
where
cb : I → I → I → ∥ _ ∥
cb i j k = squash (squash ∣ x ∣ (squash ∣ y ∣ ∣ z ∣ i) j) t k
e : B → Σ (A → B) 3-Constant
e b .fst _ = b
e b .snd = record
{ link = λ _ _ _ → b
; coh₁ = λ _ _ _ _ _ → b
}
eval : A → Σ (A → B) 3-Constant → B
eval a₀ (g , _) = g a₀
module _ where
open 3-Constant
e-eval : ∀(a₀ : A) γ → e (eval a₀ γ) ≡ γ
e-eval a₀ (g , 3kg) i .fst x = 3kg .link a₀ x i
e-eval a₀ (g , 3kg) i .snd .link x y = λ j → 3kg .coh₁ a₀ x y j i
e-eval a₀ (g , 3kg) i .snd .coh₁ x y z
= Bgpd'
(λ _ _ → g a₀)
(3kg .coh₁ x y z)
(λ k j → 3kg .coh₁ a₀ x y j k)
(λ k j → 3kg .coh₁ a₀ x z j k)
(λ _ → refl)
(λ k j → 3kg .coh₁ a₀ y z j k)
i
e-isEquiv : A → isEquiv (e {A = A})
e-isEquiv a₀ = isoToIsEquiv (iso e (eval a₀) (e-eval a₀) λ _ → refl)
preEquiv₂ : ∥ A ∥ → B ≃ Σ (A → B) 3-Constant
preEquiv₂ t = e , rec (isPropIsEquiv e) e-isEquiv t
trunc→Gpd≃ : (∥ A ∥ → B) ≃ Σ (A → B) 3-Constant
trunc→Gpd≃ = compEquiv (equivPi preEquiv₂) preEquiv₁
open GpdElim using (rec→Gpd; trunc→Gpd≃) public
RecHSet : (P : A → HLevel ℓ 2) → 3-Constant P → ∥ A ∥ → HLevel ℓ 2
RecHSet P 3kP = rec→Gpd (isOfHLevelHLevel 2) P 3kP
| 31.486957
| 81
| 0.499862
|
2386f724726d26053dad8dcedd8326775b6f25d4
| 659
|
agda
|
Agda
|
extra/extra/DecidableFixed.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 1,003
|
2018-07-05T18:15:14.000Z
|
2022-03-27T07:03:28.000Z
|
extra/extra/DecidableFixed.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 323
|
2018-07-05T22:34:34.000Z
|
2022-03-30T07:42:57.000Z
|
extra/extra/DecidableFixed.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 304
|
2018-07-16T18:24:59.000Z
|
2022-03-28T11:35:02.000Z
|
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open import Data.Nat using (ℕ; zero; suc)
open import Relation.Nullary using (¬_; Dec; yes; no)
data _≤_ : ℕ → ℕ → Set where
z≤n : ∀ {n : ℕ} → zero ≤ n
s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n
¬s≤z : ∀ {m : ℕ} → ¬ (suc m ≤ zero)
¬s≤z ()
¬s≤s : ∀ {m n : ℕ} → ¬ (m ≤ n) → ¬ (suc m ≤ suc n)
¬s≤s ¬m≤n (s≤s m≤n) = ¬m≤n m≤n
_≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n)
zero ≤? n = yes z≤n
suc m ≤? zero = no ¬s≤z
suc m ≤? suc n with m ≤? n
... | yes m≤n = yes (s≤s m≤n)
... | no ¬m≤n = no (¬s≤s ¬m≤n)
_ : 2 ≤? 4 ≡ yes (s≤s (s≤s z≤n))
_ = refl
_ : 4 ≤? 2 ≡ no (¬s≤s (¬s≤s ¬s≤z))
_ = refl
| 22.724138
| 53
| 0.474962
|
23bf6900e23f426a0841a665861d5f2ebfc69779
| 3,345
|
agda
|
Agda
|
WeakArrows.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 21
|
2015-07-30T01:25:12.000Z
|
2021-02-13T18:02:18.000Z
|
WeakArrows.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 3
|
2019-01-13T13:12:33.000Z
|
2019-05-29T09:50:26.000Z
|
WeakArrows.agda
|
jmchapman/Relative-Monads
|
74707d3538bf494f4bd30263d2f5515a84733865
|
[
"MIT"
] | 1
|
2019-11-04T21:33:13.000Z
|
2019-11-04T21:33:13.000Z
|
module WeakArrows where
open import Library
open import Categories
record Arrow {l m}(J : Cat {l}{m}) : Set (lsuc (l ⊔ m)) where
constructor arrow
open Cat J
field R : Obj → Obj → Set m
pure : ∀{X Y} -> Hom X Y -> R X Y
_<<<_ : ∀{X Y Z} → R Y Z -> R X Y -> R X Z
alaw1 : ∀{X Y Z}(g : Hom Y Z)(f : Hom X Y) ->
pure (comp g f) ≅ pure g <<< pure f
alaw2 : ∀{X Y}(s : R X Y) -> s <<< pure iden ≅ s
alaw3 : ∀{X Y}(r : R X Y) -> pure iden <<< r ≅ r
alaw4 : ∀{W X Y Z}(t : R Y Z)(s : R X Y)(r : R W X) ->
t <<< (s <<< r) ≅ (t <<< s) <<< r
open import Functors
open import Naturals
open import Categories.Sets
open import YonedaLemma
open import RMonads
module Arrow2RMonad {l m}(C : Cat {l}{m})(A : Arrow C) where
open Cat C
open Arrow A
T : Cat.Obj C -> Fun (C Op) (Sets {m})
T X = functor
(λ Y -> R Y X)
(λ f s -> s <<< pure f)
(ext alaw2)
(ext (λ s -> trans (cong (s <<<_) (alaw1 _ _)) (alaw4 _ _ _)))
η : {X : Obj} -> NatT HomF[-, X ] (T X)
η = natural pure (ext λ _ -> sym (alaw1 _ _))
bind : {X Y : Obj} ->
NatT HomF[-, X ] (T Y) -> NatT (T X) (T Y)
bind α = natural (λ s -> cmp iden <<< s) (ext λ _ -> sym (alaw4 _ _ _))
where open NatT α
-- cmp iden is one direction of the yoneda lemma
law1 : {X : Obj} → bind (η {X}) ≅ idNat {F = T X}
law1 = NatTEq (iext (\ _ -> ext alaw3))
law2 : {X Y : Obj}{f : NatT HomF[-, X ] (T Y)} →
compNat (bind f) η ≅ f
law2 {f = f} = NatTEq
(iext \ _ -> ext \ s -> trans (fcong iden (nat {f = s})) (cong cmp idl))
where open NatT f
law3 : {X Y Z : Obj}
{f : NatT HomF[-, X ] (T Y)} →
{g : NatT HomF[-, Y ] (T Z)} →
bind (compNat (bind g) f) ≅ compNat (bind g) (bind f)
law3 = NatTEq (iext \ W -> ext (\ s -> sym (alaw4 _ _ s)))
ArrowRMonad : RMonad (y C)
ArrowRMonad = rmonad
T
η
bind
law1
law2
(λ {_ _ _ f g} -> law3 {f = f}{g = g})
module RMonad2Arrow {l m}(C : Cat {l}{m})(M : RMonad (y C)) where
open Cat C
open RMonad M
open Fun
open NatT
R : Obj → Obj → Set m
R X Y = OMap (T Y) X
pure : {X Y : Obj} → Hom X Y → R X Y
pure f = cmp η f
_<<<_ : ∀{X Y Z} → R Y Z → R X Y → R X Z
s <<< t = cmp (bind (ylem C (T _) _ s)) t
alaw1 : ∀{X Y Z}(g : Hom Y Z)(f : Hom X Y) →
pure (comp g f) ≅ (pure g <<< pure f)
alaw1 g f = trans
(sym (fcong g (nat η)))
(sym (fcong f (ifcong _ (cong cmp law2))))
alaw2 : ∀{X Y} -> (s : R X Y) → (s <<< pure iden) ≅ s
alaw2 s = trans
(fcong iden (ifcong _ (cong cmp law2)))
(fcong s (fid (T _)))
alaw3 : ∀{X Y}(r : R X Y) → (pure iden <<< r) ≅ r
alaw3 r = trans
(cong (\ α -> cmp (bind α) r)
(NatTEq (iext \ Z -> ext \ f -> trans
(fcong iden (nat η))
(cong (cmp η) idl))))
(fcong r (ifcong _ (cong cmp law1)))
alaw4 : ∀{W X Y Z}(t : R Y Z)(s : R X Y)(r : R W X) →
(t <<< (s <<< r)) ≅ ((t <<< s) <<< r)
alaw4 t s r = trans
(sym (fcong r (ifcong _ (cong cmp law3))))
(cong (\ α -> cmp (bind α) r)
(NatTEq (iext \ _ -> ext \ _ ->
sym (fcong s (nat (bind (ylem C (T _) _ t)))))))
RMonadArrow : Arrow C
RMonadArrow = arrow
R
pure
_<<<_
alaw1
alaw2
alaw3
alaw4
| 27.875
| 76
| 0.472646
|
18297f0de5b28fb73a771ff60edb13d63a914171
| 10,532
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Localisation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/CommRing/Localisation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Localisation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
-- We define the localisation of a commutative ring
-- at a multiplicatively closed subset and show that it
-- has a commutative ring structure.
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.CommRing.Localisation.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset
open import Cubical.Foundations.Transport
open import Cubical.Functions.FunExtEquiv
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_
; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)
open import Cubical.Data.Vec
open import Cubical.Data.Sigma.Base
open import Cubical.Data.Sigma.Properties
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRingSolver.Reflection
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
open Iso
private
variable
ℓ ℓ' : Level
A : Type ℓ
-- A multiplicatively closed subset is assumed to contain 1
record isMultClosedSubset (R' : CommRing ℓ) (S' : ℙ (fst R')) : Type ℓ where
constructor
multclosedsubset
field
containsOne : (R' .snd .CommRingStr.1r) ∈ S'
multClosed : ∀ {s t} → s ∈ S' → t ∈ S' → ((snd R') .CommRingStr._·_ s t) ∈ S'
module Loc (R' : CommRing ℓ) (S' : ℙ (fst R')) (SMultClosedSubset : isMultClosedSubset R' S') where
open isMultClosedSubset
private R = fst R'
open CommRingStr (snd R')
open RingTheory (CommRing→Ring R')
open CommRingTheory R'
S = Σ[ s ∈ R ] (s ∈ S')
-- We define the localisation of R by S by quotienting by the following relation:
_≈_ : R × S → R × S → Type ℓ
(r₁ , s₁) ≈ (r₂ , s₂) = Σ[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁)
S⁻¹R = (R × S) / _≈_
-- now define addition for S⁻¹R
open BinaryRelation
locRefl : isRefl _≈_
locRefl _ = (1r , SMultClosedSubset .containsOne) , refl
locSym : isSym _≈_
locSym (r , s , s∈S') (r' , s' , s'∈S') (u , p) = u , sym p
locTrans : isTrans _≈_
locTrans (r , s , s∈S') (r' , s' , s'∈S') (r'' , s'' , s''∈S') ((u , u∈S') , p) ((v , v∈S') , q) =
((u · v · s') , SMultClosedSubset .multClosed (SMultClosedSubset .multClosed u∈S' v∈S') s'∈S')
, path
where
eq1 : (r s r' s' r'' s'' u v : R) → u · v · s' · r · s'' ≡ u · r · s' · v · s''
eq1 = solve R'
eq2 : (r s r' s' r'' s'' u v : R) → u · r' · s · v · s'' ≡ u · s · (v · r' · s'')
eq2 = solve R'
eq3 : (r s r' s' r'' s'' u v : R) → u · s · (v · r'' · s') ≡ u · v · s' · r'' · s
eq3 = solve R'
path : u · v · s' · r · s'' ≡ u · v · s' · r'' · s
path = u · v · s' · r · s'' ≡⟨ eq1 r s r' s' r'' s'' u v ⟩ -- not just ≡⟨ solve R' ⟩
u · r · s' · v · s'' ≡⟨ cong (λ x → x · v · s'') p ⟩
u · r' · s · v · s'' ≡⟨ eq2 r s r' s' r'' s'' u v ⟩
u · s · (v · r' · s'') ≡⟨ cong (u · s ·_) q ⟩
u · s · (v · r'' · s') ≡⟨ eq3 r s r' s' r'' s'' u v ⟩
u · v · s' · r'' · s ∎
locIsEquivRel : isEquivRel _≈_
isEquivRel.reflexive locIsEquivRel = locRefl
isEquivRel.symmetric locIsEquivRel = locSym
isEquivRel.transitive locIsEquivRel = locTrans
_+ₗ_ : S⁻¹R → S⁻¹R → S⁻¹R
_+ₗ_ = setQuotSymmBinOp locRefl locTrans _+ₚ_
(λ a b → subst (λ x → (a +ₚ b) ≈ x) (+ₚ-symm a b) (locRefl (a +ₚ b))) θ
where
_+ₚ_ : R × S → R × S → R × S
(r₁ , s₁ , s₁∈S) +ₚ (r₂ , s₂ , s₂∈S) =
(r₁ · s₂ + r₂ · s₁) , (s₁ · s₂) , SMultClosedSubset .multClosed s₁∈S s₂∈S
+ₚ-symm : (a b : R × S) → (a +ₚ b) ≡ (b +ₚ a)
+ₚ-symm (r₁ , s₁ , s₁∈S) (r₂ , s₂ , s₂∈S) =
ΣPathP (+Comm _ _ , Σ≡Prop (λ x → S' x .snd) (·Comm _ _))
θ : (a a' b : R × S) → a ≈ a' → (a +ₚ b) ≈ (a' +ₚ b)
θ (r₁ , s₁ , s₁∈S) (r'₁ , s'₁ , s'₁∈S) (r₂ , s₂ , s₂∈S) ((s , s∈S) , p) = (s , s∈S) , path
where
eq1 : (r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s : R)
→ s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂) ≡ s · r₁ · s'₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂
eq1 = solve R'
eq2 : (r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s : R)
→ s · r'₁ · s₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂ ≡ s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂)
eq2 = solve R'
path : s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂) ≡ s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂)
path = s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂)
≡⟨ eq1 r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s ⟩
s · r₁ · s'₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂
≡⟨ cong (λ x → x · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂) p ⟩
s · r'₁ · s₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂
≡⟨ eq2 r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s ⟩
s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂) ∎
-- check group-laws for addition
+ₗ-assoc : (x y z : S⁻¹R) → x +ₗ (y +ₗ z) ≡ (x +ₗ y) +ₗ z
+ₗ-assoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) +ₗ-assoc[]
where
+ₗ-assoc[] : (a b c : R × S) → [ a ] +ₗ ([ b ] +ₗ [ c ]) ≡ ([ a ] +ₗ [ b ]) +ₗ [ c ]
+ₗ-assoc[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) =
cong [_] (ΣPathP ((path r s r' s' r'' s'') , Σ≡Prop (λ x → ∈-isProp S' x) (·Assoc _ _ _)))
where
path : (r s r' s' r'' s'' : R)
→ r · (s' · s'') + (r' · s'' + r'' · s') · s ≡ (r · s' + r' · s) · s'' + r'' · (s · s')
path = solve R'
0ₗ : S⁻¹R
0ₗ = [ 0r , 1r , SMultClosedSubset .containsOne ]
+ₗ-rid : (x : S⁻¹R) → x +ₗ 0ₗ ≡ x
+ₗ-rid = SQ.elimProp (λ _ → squash/ _ _) +ₗ-rid[]
where
+ₗ-rid[] : (a : R × S) → [ a ] +ₗ 0ₗ ≡ [ a ]
+ₗ-rid[] (r , s , s∈S) = path
where
eq1 : (r s : R) → r · 1r + 0r · s ≡ r
eq1 = solve R'
path : [ r · 1r + 0r · s , s · 1r , SMultClosedSubset .multClosed s∈S
(SMultClosedSubset .containsOne) ]
≡ [ r , s , s∈S ]
path = cong [_] (ΣPathP (eq1 r s , Σ≡Prop (λ x → ∈-isProp S' x) (·Rid _)))
-ₗ_ : S⁻¹R → S⁻¹R
-ₗ_ = SQ.rec squash/ -ₗ[] -ₗWellDef
where
-ₗ[] : R × S → S⁻¹R
-ₗ[] (r , s) = [ - r , s ]
-ₗWellDef : (a b : R × S) → a ≈ b → -ₗ[] a ≡ -ₗ[] b
-ₗWellDef (r , s , _) (r' , s' , _) ((u , u∈S) , p) = eq/ _ _ ((u , u∈S) , path)
where
eq1 : (u r s' : R) → u · - r · s' ≡ - (u · r · s')
eq1 = solve R'
eq2 : (u r' s : R) → - (u · r' · s) ≡ u · - r' · s
eq2 = solve R'
path : u · - r · s' ≡ u · - r' · s
path = eq1 u r s' ∙∙ cong -_ p ∙∙ eq2 u r' s
+ₗ-rinv : (x : S⁻¹R) → x +ₗ (-ₗ x) ≡ 0ₗ
+ₗ-rinv = SQ.elimProp (λ _ → squash/ _ _) +ₗ-rinv[]
where
+ₗ-rinv[] : (a : R × S) → ([ a ] +ₗ (-ₗ [ a ])) ≡ 0ₗ
+ₗ-rinv[] (r , s , s∈S) = eq/ _ _ ((1r , SMultClosedSubset .containsOne) , path r s)
where
path : (r s : R) → 1r · (r · s + - r · s) · 1r ≡ 1r · 0r · (s · s)
path = solve R'
+ₗ-comm : (x y : S⁻¹R) → x +ₗ y ≡ y +ₗ x
+ₗ-comm = SQ.elimProp2 (λ _ _ → squash/ _ _) +ₗ-comm[]
where
+ₗ-comm[] : (a b : R × S) → ([ a ] +ₗ [ b ]) ≡ ([ b ] +ₗ [ a ])
+ₗ-comm[] (r , s , s∈S) (r' , s' , s'∈S) =
cong [_] (ΣPathP ((+Comm _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Comm _ _)))
-- Now for multiplication
_·ₗ_ : S⁻¹R → S⁻¹R → S⁻¹R
_·ₗ_ = setQuotSymmBinOp locRefl locTrans _·ₚ_
(λ a b → subst (λ x → (a ·ₚ b) ≈ x) (·ₚ-symm a b) (locRefl (a ·ₚ b))) θ
where
_·ₚ_ : R × S → R × S → R × S
(r₁ , s₁ , s₁∈S) ·ₚ (r₂ , s₂ , s₂∈S) =
(r₁ · r₂) , ((s₁ · s₂) , SMultClosedSubset .multClosed s₁∈S s₂∈S)
·ₚ-symm : (a b : R × S) → (a ·ₚ b) ≡ (b ·ₚ a)
·ₚ-symm (r₁ , s₁ , s₁∈S) (r₂ , s₂ , s₂∈S) =
ΣPathP (·Comm _ _ , Σ≡Prop (λ x → S' x .snd) (·Comm _ _))
θ : (a a' b : R × S) → a ≈ a' → (a ·ₚ b) ≈ (a' ·ₚ b)
θ (r₁ , s₁ , s₁∈S) (r'₁ , s'₁ , s'₁∈S) (r₂ , s₂ , s₂∈S) ((s , s∈S) , p) = (s , s∈S) , path
where
eq1 : (r₁ s₁ r'₁ s'₁ r₂ s₂ s : R)
→ s · (r₁ · r₂) · (s'₁ · s₂) ≡ s · r₁ · s'₁ · r₂ · s₂
eq1 = solve R'
eq2 : (r₁ s₁ r'₁ s'₁ r₂ s₂ s : R)
→ s · r'₁ · s₁ · r₂ · s₂ ≡ s · (r'₁ · r₂) · (s₁ · s₂)
eq2 = solve R'
path : s · (r₁ · r₂) · (s'₁ · s₂) ≡ s · (r'₁ · r₂) · (s₁ · s₂)
path = eq1 r₁ s₁ r'₁ s'₁ r₂ s₂ s ∙∙ cong (λ x → x · r₂ · s₂) p ∙∙ eq2 r₁ s₁ r'₁ s'₁ r₂ s₂ s
-- checking laws for multiplication
1ₗ : S⁻¹R
1ₗ = [ 1r , 1r , SMultClosedSubset .containsOne ]
·ₗ-assoc : (x y z : S⁻¹R) → x ·ₗ (y ·ₗ z) ≡ (x ·ₗ y) ·ₗ z
·ₗ-assoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) ·ₗ-assoc[]
where
·ₗ-assoc[] : (a b c : R × S) → [ a ] ·ₗ ([ b ] ·ₗ [ c ]) ≡ ([ a ] ·ₗ [ b ]) ·ₗ [ c ]
·ₗ-assoc[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) =
cong [_] (ΣPathP ((·Assoc _ _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Assoc _ _ _)))
·ₗ-rid : (x : S⁻¹R) → x ·ₗ 1ₗ ≡ x
·ₗ-rid = SQ.elimProp (λ _ → squash/ _ _) ·ₗ-rid[]
where
·ₗ-rid[] : (a : R × S) → ([ a ] ·ₗ 1ₗ) ≡ [ a ]
·ₗ-rid[] (r , s , s∈S) = cong [_] (ΣPathP ((·Rid _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Rid _)))
·ₗ-rdist-+ₗ : (x y z : S⁻¹R) → x ·ₗ (y +ₗ z) ≡ (x ·ₗ y) +ₗ (x ·ₗ z)
·ₗ-rdist-+ₗ = SQ.elimProp3 (λ _ _ _ → squash/ _ _) ·ₗ-rdist-+ₗ[]
where
·ₗ-rdist-+ₗ[] : (a b c : R × S) → [ a ] ·ₗ ([ b ] +ₗ [ c ]) ≡ ([ a ] ·ₗ [ b ]) +ₗ ([ a ] ·ₗ [ c ])
·ₗ-rdist-+ₗ[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) =
eq/ _ _ ((1r , (SMultClosedSubset .containsOne)) , path r s r' s' r'' s'')
where
-- could be shortened even further
path : (r s r' s' r'' s'' : R)
→ 1r · (r · (r' · s'' + r'' · s')) · (s · s' · (s · s''))
≡ 1r · (r · r' · (s · s'') + r · r'' · (s · s')) · (s · (s' · s''))
path = solve R'
·ₗ-comm : (x y : S⁻¹R) → x ·ₗ y ≡ y ·ₗ x
·ₗ-comm = SQ.elimProp2 (λ _ _ → squash/ _ _) ·ₗ-comm[]
where
·ₗ-comm[] : (a b : R × S) → [ a ] ·ₗ [ b ] ≡ [ b ] ·ₗ [ a ]
·ₗ-comm[] (r , s , s∈S) (r' , s' , s'∈S) =
cong [_] (ΣPathP ((·Comm _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Comm _ _)))
-- Commutative ring structure on S⁻¹R
S⁻¹RAsCommRing : CommRing ℓ
S⁻¹RAsCommRing = S⁻¹R , S⁻¹RCommRingStr
where
open CommRingStr
S⁻¹RCommRingStr : CommRingStr S⁻¹R
0r S⁻¹RCommRingStr = 0ₗ
1r S⁻¹RCommRingStr = 1ₗ
_+_ S⁻¹RCommRingStr = _+ₗ_
_·_ S⁻¹RCommRingStr = _·ₗ_
- S⁻¹RCommRingStr = -ₗ_
isCommRing S⁻¹RCommRingStr = makeIsCommRing squash/ +ₗ-assoc +ₗ-rid +ₗ-rinv +ₗ-comm
·ₗ-assoc ·ₗ-rid ·ₗ-rdist-+ₗ ·ₗ-comm
| 36.442907
| 101
| 0.476738
|
180ca8484684ee5226c5f2d92646f50268782a40
| 1,096
|
agda
|
Agda
|
Cubical/WithK.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/WithK.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/WithK.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{- Cubical Agda with K
This file demonstrates the incompatibility of the --cubical
and --with-K flags, relying on the well-known incosistency of K with
univalence.
The --safe flag can be used to prevent accidentally mixing such
incompatible flags.
-}
{-# OPTIONS --cubical --no-import-sorts --with-K #-}
module Cubical.WithK where
open import Cubical.Data.Equality
open import Cubical.Data.Bool
open import Cubical.Data.Empty
private
variable
ℓ : Level
A : Type ℓ
x y : A
uip : (prf : x ≡p x) → prf ≡c reflp
uip reflp i = reflp
transport-uip : (prf : A ≡p A) → transport (ptoc prf) x ≡c x
transport-uip {x = x} prf =
cong (λ m → transport (ptoc m) x) (uip prf) ∙ transportRefl x
transport-not : transport (ptoc (ctop notEq)) true ≡c false
transport-not = cong (λ a → transport a true) (ptoc-ctop notEq)
false-true : false ≡c true
false-true = sym transport-not ∙ transport-uip (ctop notEq)
absurd : (X : Type) → X
absurd X = transport (cong sel false-true) true
where
sel : Bool → Type
sel false = Bool
sel true = X
inconsistency : ⊥
inconsistency = absurd ⊥
| 22.367347
| 68
| 0.691606
|
1c784558a6fe9352bc4444ee45edc81b84b59aca
| 312
|
agda
|
Agda
|
test/js/TestHarness.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/js/TestHarness.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/js/TestHarness.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
open import Common.Prelude
module TestHarness where
record ⊤ : Set where
data ⊥ : Set where
T : Bool → Set
T true = ⊤
T false = ⊥
infixr 4 _,_
data Asserts : Set where
ε : Asserts
_,_ : Asserts → Asserts → Asserts
assert : (b : Bool) → {b✓ : T b} → String → Asserts
Tests : Set
Tests = ⊤ → Asserts
| 14.181818
| 53
| 0.628205
|
105c7164becd4b6826627277e8c8f55e33ac35ac
| 159
|
agda
|
Agda
|
test/Fail/Issue2833.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue2833.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue2833.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Nat
record R : Set where
field
r₁ : Nat
r₂ : Nat
open R
h : (n : Nat) → R
r₁ (h zero) = {!!}
r₂ (h zero) = {!!}
h = {!!}
| 11.357143
| 28
| 0.503145
|
0ef76df24f9f99e53508ec9ff8a902fcad67b186
| 1,780
|
agda
|
Agda
|
agda-stdlib/src/Data/These/Categorical/Right/Base.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/These/Categorical/Right/Base.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/These/Categorical/Right/Base.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Base definitions for the right-biased universe-sensitive functor and
-- monad instances for These.
--
-- To minimize the universe level of the RawFunctor, we require that
-- elements of B are "lifted" to a copy of B at a higher universe level
-- (a ⊔ b).
-- See the Data.Product.Categorical.Examples for how this is done in a
-- Product-based similar setting.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Level
module Data.These.Categorical.Right.Base (a : Level) {b} (B : Set b) where
open import Data.These.Base
open import Category.Functor
open import Category.Applicative
open import Category.Monad
open import Function
Theseᵣ : Set (a ⊔ b) → Set (a ⊔ b)
Theseᵣ A = These A B
functor : RawFunctor Theseᵣ
functor = record { _<$>_ = map₁ }
------------------------------------------------------------------------
-- Get access to other monadic functions
module _ {F} (App : RawApplicative {a ⊔ b} F) where
open RawApplicative App
sequenceA : ∀ {A} → Theseᵣ (F A) → F (Theseᵣ A)
sequenceA (this a) = this <$> a
sequenceA (that b) = pure (that b)
sequenceA (these a b) = flip these b <$> a
mapA : ∀ {A B} → (A → F B) → Theseᵣ A → F (Theseᵣ B)
mapA f = sequenceA ∘ map₁ f
forA : ∀ {A B} → Theseᵣ A → (A → F B) → F (Theseᵣ B)
forA = flip mapA
module _ {M} (Mon : RawMonad {a ⊔ b} M) where
private App = RawMonad.rawIApplicative Mon
sequenceM : ∀ {A} → Theseᵣ (M A) → M (Theseᵣ A)
sequenceM = sequenceA App
mapM : ∀ {A B} → (A → M B) → Theseᵣ A → M (Theseᵣ B)
mapM = mapA App
forM : ∀ {A B} → Theseᵣ A → (A → M B) → M (Theseᵣ B)
forM = forA App
| 28.709677
| 74
| 0.566292
|
cbd8139fa8f8ca34d2bbd498ec148b47f3eae425
| 21,304
|
agda
|
Agda
|
prototyping/Properties/TypeNormalization.agda
|
Libertus-Lab/luau
|
f1b46f4b967f11fabe666da1de0e71b225368260
|
[
"MIT"
] | 1
|
2021-11-06T08:03:00.000Z
|
2021-11-06T08:03:00.000Z
|
prototyping/Properties/TypeNormalization.agda
|
sthagen/Roblox-luau
|
39fbd2146a379fb0878369b48764cd7e8772c0fb
|
[
"MIT"
] | null | null | null |
prototyping/Properties/TypeNormalization.agda
|
sthagen/Roblox-luau
|
39fbd2146a379fb0878369b48764cd7e8772c0fb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --rewriting #-}
module Properties.TypeNormalization where
open import Luau.Type using (Type; Scalar; nil; number; string; boolean; never; unknown; _⇒_; _∪_; _∩_)
open import Luau.Subtyping using (Tree; Language; ¬Language; function; scalar; unknown; left; right; function-ok₁; function-ok₂; function-err; function-tgt; scalar-function; scalar-function-ok; scalar-function-err; scalar-function-tgt; function-scalar; _,_)
open import Luau.TypeNormalization using (_∪ⁿ_; _∩ⁿ_; _∪ᶠ_; _∪ⁿˢ_; _∩ⁿˢ_; normalize)
open import Luau.Subtyping using (_<:_; _≮:_; witness; never)
open import Properties.Subtyping using (<:-trans; <:-refl; <:-unknown; <:-never; <:-∪-left; <:-∪-right; <:-∪-lub; <:-∩-left; <:-∩-right; <:-∩-glb; <:-∩-symm; <:-function; <:-function-∪-∩; <:-function-∩-∪; <:-function-∪; <:-everything; <:-union; <:-∪-assocl; <:-∪-assocr; <:-∪-symm; <:-intersect; ∪-distl-∩-<:; ∪-distr-∩-<:; <:-∪-distr-∩; <:-∪-distl-∩; ∩-distl-∪-<:; <:-∩-distl-∪; <:-∩-distr-∪; scalar-∩-function-<:-never; scalar-≢-∩-<:-never)
-- Normal forms for types
data FunType : Type → Set
data Normal : Type → Set
data FunType where
_⇒_ : ∀ {S T} → Normal S → Normal T → FunType (S ⇒ T)
_∩_ : ∀ {F G} → FunType F → FunType G → FunType (F ∩ G)
data Normal where
_⇒_ : ∀ {S T} → Normal S → Normal T → Normal (S ⇒ T)
_∩_ : ∀ {F G} → FunType F → FunType G → Normal (F ∩ G)
_∪_ : ∀ {S T} → Normal S → Scalar T → Normal (S ∪ T)
never : Normal never
unknown : Normal unknown
data OptScalar : Type → Set where
never : OptScalar never
number : OptScalar number
boolean : OptScalar boolean
string : OptScalar string
nil : OptScalar nil
-- Top function type
fun-top : ∀ {F} → (FunType F) → (F <: (never ⇒ unknown))
fun-top (S ⇒ T) = <:-function <:-never <:-unknown
fun-top (F ∩ G) = <:-trans <:-∩-left (fun-top F)
-- function types are inhabited
fun-function : ∀ {F} → FunType F → Language F function
fun-function (S ⇒ T) = function
fun-function (F ∩ G) = (fun-function F , fun-function G)
fun-≮:-never : ∀ {F} → FunType F → (F ≮: never)
fun-≮:-never F = witness function (fun-function F) never
-- function types aren't scalars
fun-¬scalar : ∀ {F S t} → (s : Scalar S) → FunType F → Language F t → ¬Language S t
fun-¬scalar s (S ⇒ T) function = scalar-function s
fun-¬scalar s (S ⇒ T) (function-ok₁ p) = scalar-function-ok s
fun-¬scalar s (S ⇒ T) (function-ok₂ p) = scalar-function-ok s
fun-¬scalar s (S ⇒ T) (function-err p) = scalar-function-err s
fun-¬scalar s (S ⇒ T) (function-tgt p) = scalar-function-tgt s
fun-¬scalar s (F ∩ G) (p₁ , p₂) = fun-¬scalar s G p₂
¬scalar-fun : ∀ {F S} → FunType F → (s : Scalar S) → ¬Language F (scalar s)
¬scalar-fun (S ⇒ T) s = function-scalar s
¬scalar-fun (F ∩ G) s = left (¬scalar-fun F s)
scalar-≮:-fun : ∀ {F S} → FunType F → Scalar S → S ≮: F
scalar-≮:-fun F s = witness (scalar s) (scalar s) (¬scalar-fun F s)
unknown-≮:-fun : ∀ {F} → FunType F → unknown ≮: F
unknown-≮:-fun F = witness (scalar nil) unknown (¬scalar-fun F nil)
-- Normalization produces normal types
normal : ∀ T → Normal (normalize T)
normalᶠ : ∀ {F} → FunType F → Normal F
normal-∪ⁿ : ∀ {S T} → Normal S → Normal T → Normal (S ∪ⁿ T)
normal-∩ⁿ : ∀ {S T} → Normal S → Normal T → Normal (S ∩ⁿ T)
normal-∪ⁿˢ : ∀ {S T} → Normal S → OptScalar T → Normal (S ∪ⁿˢ T)
normal-∩ⁿˢ : ∀ {S T} → Normal S → Scalar T → OptScalar (S ∩ⁿˢ T)
normal-∪ᶠ : ∀ {F G} → FunType F → FunType G → FunType (F ∪ᶠ G)
normal nil = never ∪ nil
normal (S ⇒ T) = (normal S) ⇒ (normal T)
normal never = never
normal unknown = unknown
normal boolean = never ∪ boolean
normal number = never ∪ number
normal string = never ∪ string
normal (S ∪ T) = normal-∪ⁿ (normal S) (normal T)
normal (S ∩ T) = normal-∩ⁿ (normal S) (normal T)
normalᶠ (S ⇒ T) = S ⇒ T
normalᶠ (F ∩ G) = F ∩ G
normal-∪ⁿ S (T₁ ∪ T₂) = (normal-∪ⁿ S T₁) ∪ T₂
normal-∪ⁿ S never = S
normal-∪ⁿ S unknown = unknown
normal-∪ⁿ never (T ⇒ U) = T ⇒ U
normal-∪ⁿ never (G₁ ∩ G₂) = G₁ ∩ G₂
normal-∪ⁿ unknown (T ⇒ U) = unknown
normal-∪ⁿ unknown (G₁ ∩ G₂) = unknown
normal-∪ⁿ (R ⇒ S) (T ⇒ U) = normalᶠ (normal-∪ᶠ (R ⇒ S) (T ⇒ U))
normal-∪ⁿ (R ⇒ S) (G₁ ∩ G₂) = normalᶠ (normal-∪ᶠ (R ⇒ S) (G₁ ∩ G₂))
normal-∪ⁿ (F₁ ∩ F₂) (T ⇒ U) = normalᶠ (normal-∪ᶠ (F₁ ∩ F₂) (T ⇒ U))
normal-∪ⁿ (F₁ ∩ F₂) (G₁ ∩ G₂) = normalᶠ (normal-∪ᶠ (F₁ ∩ F₂) (G₁ ∩ G₂))
normal-∪ⁿ (S₁ ∪ S₂) (T₁ ⇒ T₂) = normal-∪ⁿ S₁ (T₁ ⇒ T₂) ∪ S₂
normal-∪ⁿ (S₁ ∪ S₂) (G₁ ∩ G₂) = normal-∪ⁿ S₁ (G₁ ∩ G₂) ∪ S₂
normal-∩ⁿ S never = never
normal-∩ⁿ S unknown = S
normal-∩ⁿ S (T ∪ U) = normal-∪ⁿˢ (normal-∩ⁿ S T) (normal-∩ⁿˢ S U )
normal-∩ⁿ never (T ⇒ U) = never
normal-∩ⁿ unknown (T ⇒ U) = T ⇒ U
normal-∩ⁿ (R ⇒ S) (T ⇒ U) = (R ⇒ S) ∩ (T ⇒ U)
normal-∩ⁿ (R ∩ S) (T ⇒ U) = (R ∩ S) ∩ (T ⇒ U)
normal-∩ⁿ (R ∪ S) (T ⇒ U) = normal-∩ⁿ R (T ⇒ U)
normal-∩ⁿ never (T ∩ U) = never
normal-∩ⁿ unknown (T ∩ U) = T ∩ U
normal-∩ⁿ (R ⇒ S) (T ∩ U) = (R ⇒ S) ∩ (T ∩ U)
normal-∩ⁿ (R ∩ S) (T ∩ U) = (R ∩ S) ∩ (T ∩ U)
normal-∩ⁿ (R ∪ S) (T ∩ U) = normal-∩ⁿ R (T ∩ U)
normal-∪ⁿˢ S never = S
normal-∪ⁿˢ never number = never ∪ number
normal-∪ⁿˢ unknown number = unknown
normal-∪ⁿˢ (R ⇒ S) number = (R ⇒ S) ∪ number
normal-∪ⁿˢ (R ∩ S) number = (R ∩ S) ∪ number
normal-∪ⁿˢ (R ∪ number) number = R ∪ number
normal-∪ⁿˢ (R ∪ boolean) number = normal-∪ⁿˢ R number ∪ boolean
normal-∪ⁿˢ (R ∪ string) number = normal-∪ⁿˢ R number ∪ string
normal-∪ⁿˢ (R ∪ nil) number = normal-∪ⁿˢ R number ∪ nil
normal-∪ⁿˢ never boolean = never ∪ boolean
normal-∪ⁿˢ unknown boolean = unknown
normal-∪ⁿˢ (R ⇒ S) boolean = (R ⇒ S) ∪ boolean
normal-∪ⁿˢ (R ∩ S) boolean = (R ∩ S) ∪ boolean
normal-∪ⁿˢ (R ∪ number) boolean = normal-∪ⁿˢ R boolean ∪ number
normal-∪ⁿˢ (R ∪ boolean) boolean = R ∪ boolean
normal-∪ⁿˢ (R ∪ string) boolean = normal-∪ⁿˢ R boolean ∪ string
normal-∪ⁿˢ (R ∪ nil) boolean = normal-∪ⁿˢ R boolean ∪ nil
normal-∪ⁿˢ never string = never ∪ string
normal-∪ⁿˢ unknown string = unknown
normal-∪ⁿˢ (R ⇒ S) string = (R ⇒ S) ∪ string
normal-∪ⁿˢ (R ∩ S) string = (R ∩ S) ∪ string
normal-∪ⁿˢ (R ∪ number) string = normal-∪ⁿˢ R string ∪ number
normal-∪ⁿˢ (R ∪ boolean) string = normal-∪ⁿˢ R string ∪ boolean
normal-∪ⁿˢ (R ∪ string) string = R ∪ string
normal-∪ⁿˢ (R ∪ nil) string = normal-∪ⁿˢ R string ∪ nil
normal-∪ⁿˢ never nil = never ∪ nil
normal-∪ⁿˢ unknown nil = unknown
normal-∪ⁿˢ (R ⇒ S) nil = (R ⇒ S) ∪ nil
normal-∪ⁿˢ (R ∩ S) nil = (R ∩ S) ∪ nil
normal-∪ⁿˢ (R ∪ number) nil = normal-∪ⁿˢ R nil ∪ number
normal-∪ⁿˢ (R ∪ boolean) nil = normal-∪ⁿˢ R nil ∪ boolean
normal-∪ⁿˢ (R ∪ string) nil = normal-∪ⁿˢ R nil ∪ string
normal-∪ⁿˢ (R ∪ nil) nil = R ∪ nil
normal-∩ⁿˢ never number = never
normal-∩ⁿˢ never boolean = never
normal-∩ⁿˢ never string = never
normal-∩ⁿˢ never nil = never
normal-∩ⁿˢ unknown number = number
normal-∩ⁿˢ unknown boolean = boolean
normal-∩ⁿˢ unknown string = string
normal-∩ⁿˢ unknown nil = nil
normal-∩ⁿˢ (R ⇒ S) number = never
normal-∩ⁿˢ (R ⇒ S) boolean = never
normal-∩ⁿˢ (R ⇒ S) string = never
normal-∩ⁿˢ (R ⇒ S) nil = never
normal-∩ⁿˢ (R ∩ S) number = never
normal-∩ⁿˢ (R ∩ S) boolean = never
normal-∩ⁿˢ (R ∩ S) string = never
normal-∩ⁿˢ (R ∩ S) nil = never
normal-∩ⁿˢ (R ∪ number) number = number
normal-∩ⁿˢ (R ∪ boolean) number = normal-∩ⁿˢ R number
normal-∩ⁿˢ (R ∪ string) number = normal-∩ⁿˢ R number
normal-∩ⁿˢ (R ∪ nil) number = normal-∩ⁿˢ R number
normal-∩ⁿˢ (R ∪ number) boolean = normal-∩ⁿˢ R boolean
normal-∩ⁿˢ (R ∪ boolean) boolean = boolean
normal-∩ⁿˢ (R ∪ string) boolean = normal-∩ⁿˢ R boolean
normal-∩ⁿˢ (R ∪ nil) boolean = normal-∩ⁿˢ R boolean
normal-∩ⁿˢ (R ∪ number) string = normal-∩ⁿˢ R string
normal-∩ⁿˢ (R ∪ boolean) string = normal-∩ⁿˢ R string
normal-∩ⁿˢ (R ∪ string) string = string
normal-∩ⁿˢ (R ∪ nil) string = normal-∩ⁿˢ R string
normal-∩ⁿˢ (R ∪ number) nil = normal-∩ⁿˢ R nil
normal-∩ⁿˢ (R ∪ boolean) nil = normal-∩ⁿˢ R nil
normal-∩ⁿˢ (R ∪ string) nil = normal-∩ⁿˢ R nil
normal-∩ⁿˢ (R ∪ nil) nil = nil
normal-∪ᶠ (R ⇒ S) (T ⇒ U) = (normal-∩ⁿ R T) ⇒ (normal-∪ⁿ S U)
normal-∪ᶠ (R ⇒ S) (G ∩ H) = normal-∪ᶠ (R ⇒ S) G ∩ normal-∪ᶠ (R ⇒ S) H
normal-∪ᶠ (E ∩ F) G = normal-∪ᶠ E G ∩ normal-∪ᶠ F G
scalar-∩-fun-<:-never : ∀ {F S} → FunType F → Scalar S → (F ∩ S) <: never
scalar-∩-fun-<:-never (T ⇒ U) S = scalar-∩-function-<:-never S
scalar-∩-fun-<:-never (F ∩ G) S = <:-trans (<:-intersect <:-∩-left <:-refl) (scalar-∩-fun-<:-never F S)
flipper : ∀ {S T U} → ((S ∪ T) ∪ U) <: ((S ∪ U) ∪ T)
flipper = <:-trans <:-∪-assocr (<:-trans (<:-union <:-refl <:-∪-symm) <:-∪-assocl)
∩-<:-∩ⁿ : ∀ {S T} → Normal S → Normal T → (S ∩ T) <: (S ∩ⁿ T)
∩ⁿ-<:-∩ : ∀ {S T} → Normal S → Normal T → (S ∩ⁿ T) <: (S ∩ T)
∩-<:-∩ⁿˢ : ∀ {S T} → Normal S → Scalar T → (S ∩ T) <: (S ∩ⁿˢ T)
∩ⁿˢ-<:-∩ : ∀ {S T} → Normal S → Scalar T → (S ∩ⁿˢ T) <: (S ∩ T)
∪ᶠ-<:-∪ : ∀ {F G} → FunType F → FunType G → (F ∪ᶠ G) <: (F ∪ G)
∪ⁿ-<:-∪ : ∀ {S T} → Normal S → Normal T → (S ∪ⁿ T) <: (S ∪ T)
∪-<:-∪ⁿ : ∀ {S T} → Normal S → Normal T → (S ∪ T) <: (S ∪ⁿ T)
∪ⁿˢ-<:-∪ : ∀ {S T} → Normal S → OptScalar T → (S ∪ⁿˢ T) <: (S ∪ T)
∪-<:-∪ⁿˢ : ∀ {S T} → Normal S → OptScalar T → (S ∪ T) <: (S ∪ⁿˢ T)
∩-<:-∩ⁿ S never = <:-∩-right
∩-<:-∩ⁿ S unknown = <:-∩-left
∩-<:-∩ⁿ S (T ∪ U) = <:-trans <:-∩-distl-∪ (<:-trans (<:-union (∩-<:-∩ⁿ S T) (∩-<:-∩ⁿˢ S U)) (∪-<:-∪ⁿˢ (normal-∩ⁿ S T) (normal-∩ⁿˢ S U)) )
∩-<:-∩ⁿ never (T ⇒ U) = <:-∩-left
∩-<:-∩ⁿ unknown (T ⇒ U) = <:-∩-right
∩-<:-∩ⁿ (R ⇒ S) (T ⇒ U) = <:-refl
∩-<:-∩ⁿ (R ∩ S) (T ⇒ U) = <:-refl
∩-<:-∩ⁿ (R ∪ S) (T ⇒ U) = <:-trans <:-∩-distr-∪ (<:-trans (<:-union (∩-<:-∩ⁿ R (T ⇒ U)) (<:-trans <:-∩-symm (∩-<:-∩ⁿˢ (T ⇒ U) S))) (<:-∪-lub <:-refl <:-never))
∩-<:-∩ⁿ never (T ∩ U) = <:-∩-left
∩-<:-∩ⁿ unknown (T ∩ U) = <:-∩-right
∩-<:-∩ⁿ (R ⇒ S) (T ∩ U) = <:-refl
∩-<:-∩ⁿ (R ∩ S) (T ∩ U) = <:-refl
∩-<:-∩ⁿ (R ∪ S) (T ∩ U) = <:-trans <:-∩-distr-∪ (<:-trans (<:-union (∩-<:-∩ⁿ R (T ∩ U)) (<:-trans <:-∩-symm (∩-<:-∩ⁿˢ (T ∩ U) S))) (<:-∪-lub <:-refl <:-never))
∩ⁿ-<:-∩ S never = <:-never
∩ⁿ-<:-∩ S unknown = <:-∩-glb <:-refl <:-unknown
∩ⁿ-<:-∩ S (T ∪ U) = <:-trans (∪ⁿˢ-<:-∪ (normal-∩ⁿ S T) (normal-∩ⁿˢ S U)) (<:-trans (<:-union (∩ⁿ-<:-∩ S T) (∩ⁿˢ-<:-∩ S U)) ∩-distl-∪-<:)
∩ⁿ-<:-∩ never (T ⇒ U) = <:-never
∩ⁿ-<:-∩ unknown (T ⇒ U) = <:-∩-glb <:-unknown <:-refl
∩ⁿ-<:-∩ (R ⇒ S) (T ⇒ U) = <:-refl
∩ⁿ-<:-∩ (R ∩ S) (T ⇒ U) = <:-refl
∩ⁿ-<:-∩ (R ∪ S) (T ⇒ U) = <:-trans (∩ⁿ-<:-∩ R (T ⇒ U)) (<:-∩-glb (<:-trans <:-∩-left <:-∪-left) <:-∩-right)
∩ⁿ-<:-∩ never (T ∩ U) = <:-never
∩ⁿ-<:-∩ unknown (T ∩ U) = <:-∩-glb <:-unknown <:-refl
∩ⁿ-<:-∩ (R ⇒ S) (T ∩ U) = <:-refl
∩ⁿ-<:-∩ (R ∩ S) (T ∩ U) = <:-refl
∩ⁿ-<:-∩ (R ∪ S) (T ∩ U) = <:-trans (∩ⁿ-<:-∩ R (T ∩ U)) (<:-∩-glb (<:-trans <:-∩-left <:-∪-left) <:-∩-right)
∩-<:-∩ⁿˢ never number = <:-∩-left
∩-<:-∩ⁿˢ never boolean = <:-∩-left
∩-<:-∩ⁿˢ never string = <:-∩-left
∩-<:-∩ⁿˢ never nil = <:-∩-left
∩-<:-∩ⁿˢ unknown T = <:-∩-right
∩-<:-∩ⁿˢ (R ⇒ S) T = scalar-∩-fun-<:-never (R ⇒ S) T
∩-<:-∩ⁿˢ (F ∩ G) T = scalar-∩-fun-<:-never (F ∩ G) T
∩-<:-∩ⁿˢ (R ∪ number) number = <:-∩-right
∩-<:-∩ⁿˢ (R ∪ boolean) number = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R number) (scalar-≢-∩-<:-never boolean number (λ ())))
∩-<:-∩ⁿˢ (R ∪ string) number = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R number) (scalar-≢-∩-<:-never string number (λ ())))
∩-<:-∩ⁿˢ (R ∪ nil) number = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R number) (scalar-≢-∩-<:-never nil number (λ ())))
∩-<:-∩ⁿˢ (R ∪ number) boolean = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R boolean) (scalar-≢-∩-<:-never number boolean (λ ())))
∩-<:-∩ⁿˢ (R ∪ boolean) boolean = <:-∩-right
∩-<:-∩ⁿˢ (R ∪ string) boolean = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R boolean) (scalar-≢-∩-<:-never string boolean (λ ())))
∩-<:-∩ⁿˢ (R ∪ nil) boolean = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R boolean) (scalar-≢-∩-<:-never nil boolean (λ ())))
∩-<:-∩ⁿˢ (R ∪ number) string = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R string) (scalar-≢-∩-<:-never number string (λ ())))
∩-<:-∩ⁿˢ (R ∪ boolean) string = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R string) (scalar-≢-∩-<:-never boolean string (λ ())))
∩-<:-∩ⁿˢ (R ∪ string) string = <:-∩-right
∩-<:-∩ⁿˢ (R ∪ nil) string = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R string) (scalar-≢-∩-<:-never nil string (λ ())))
∩-<:-∩ⁿˢ (R ∪ number) nil = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R nil) (scalar-≢-∩-<:-never number nil (λ ())))
∩-<:-∩ⁿˢ (R ∪ boolean) nil = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R nil) (scalar-≢-∩-<:-never boolean nil (λ ())))
∩-<:-∩ⁿˢ (R ∪ string) nil = <:-trans <:-∩-distr-∪ (<:-∪-lub (∩-<:-∩ⁿˢ R nil) (scalar-≢-∩-<:-never string nil (λ ())))
∩-<:-∩ⁿˢ (R ∪ nil) nil = <:-∩-right
∩ⁿˢ-<:-∩ never T = <:-never
∩ⁿˢ-<:-∩ unknown T = <:-∩-glb <:-unknown <:-refl
∩ⁿˢ-<:-∩ (R ⇒ S) T = <:-never
∩ⁿˢ-<:-∩ (F ∩ G) T = <:-never
∩ⁿˢ-<:-∩ (R ∪ number) number = <:-∩-glb <:-∪-right <:-refl
∩ⁿˢ-<:-∩ (R ∪ boolean) number = <:-trans (∩ⁿˢ-<:-∩ R number) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ string) number = <:-trans (∩ⁿˢ-<:-∩ R number) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ nil) number = <:-trans (∩ⁿˢ-<:-∩ R number) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ number) boolean = <:-trans (∩ⁿˢ-<:-∩ R boolean) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ boolean) boolean = <:-∩-glb <:-∪-right <:-refl
∩ⁿˢ-<:-∩ (R ∪ string) boolean = <:-trans (∩ⁿˢ-<:-∩ R boolean) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ nil) boolean = <:-trans (∩ⁿˢ-<:-∩ R boolean) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ number) string = <:-trans (∩ⁿˢ-<:-∩ R string) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ boolean) string = <:-trans (∩ⁿˢ-<:-∩ R string) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ string) string = <:-∩-glb <:-∪-right <:-refl
∩ⁿˢ-<:-∩ (R ∪ nil) string = <:-trans (∩ⁿˢ-<:-∩ R string) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ number) nil = <:-trans (∩ⁿˢ-<:-∩ R nil) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ boolean) nil = <:-trans (∩ⁿˢ-<:-∩ R nil) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ string) nil = <:-trans (∩ⁿˢ-<:-∩ R nil) (<:-intersect <:-∪-left <:-refl)
∩ⁿˢ-<:-∩ (R ∪ nil) nil = <:-∩-glb <:-∪-right <:-refl
∪ᶠ-<:-∪ (R ⇒ S) (T ⇒ U) = <:-trans (<:-function (∩-<:-∩ⁿ R T) (∪ⁿ-<:-∪ S U)) <:-function-∪-∩
∪ᶠ-<:-∪ (R ⇒ S) (G ∩ H) = <:-trans (<:-intersect (∪ᶠ-<:-∪ (R ⇒ S) G) (∪ᶠ-<:-∪ (R ⇒ S) H)) ∪-distl-∩-<:
∪ᶠ-<:-∪ (E ∩ F) G = <:-trans (<:-intersect (∪ᶠ-<:-∪ E G) (∪ᶠ-<:-∪ F G)) ∪-distr-∩-<:
∪-<:-∪ᶠ : ∀ {F G} → FunType F → FunType G → (F ∪ G) <: (F ∪ᶠ G)
∪-<:-∪ᶠ (R ⇒ S) (T ⇒ U) = <:-trans <:-function-∪ (<:-function (∩ⁿ-<:-∩ R T) (∪-<:-∪ⁿ S U))
∪-<:-∪ᶠ (R ⇒ S) (G ∩ H) = <:-trans <:-∪-distl-∩ (<:-intersect (∪-<:-∪ᶠ (R ⇒ S) G) (∪-<:-∪ᶠ (R ⇒ S) H))
∪-<:-∪ᶠ (E ∩ F) G = <:-trans <:-∪-distr-∩ (<:-intersect (∪-<:-∪ᶠ E G) (∪-<:-∪ᶠ F G))
∪ⁿˢ-<:-∪ S never = <:-∪-left
∪ⁿˢ-<:-∪ never number = <:-refl
∪ⁿˢ-<:-∪ never boolean = <:-refl
∪ⁿˢ-<:-∪ never string = <:-refl
∪ⁿˢ-<:-∪ never nil = <:-refl
∪ⁿˢ-<:-∪ unknown number = <:-∪-left
∪ⁿˢ-<:-∪ unknown boolean = <:-∪-left
∪ⁿˢ-<:-∪ unknown string = <:-∪-left
∪ⁿˢ-<:-∪ unknown nil = <:-∪-left
∪ⁿˢ-<:-∪ (R ⇒ S) number = <:-refl
∪ⁿˢ-<:-∪ (R ⇒ S) boolean = <:-refl
∪ⁿˢ-<:-∪ (R ⇒ S) string = <:-refl
∪ⁿˢ-<:-∪ (R ⇒ S) nil = <:-refl
∪ⁿˢ-<:-∪ (R ∩ S) number = <:-refl
∪ⁿˢ-<:-∪ (R ∩ S) boolean = <:-refl
∪ⁿˢ-<:-∪ (R ∩ S) string = <:-refl
∪ⁿˢ-<:-∪ (R ∩ S) nil = <:-refl
∪ⁿˢ-<:-∪ (R ∪ number) number = <:-union <:-∪-left <:-refl
∪ⁿˢ-<:-∪ (R ∪ boolean) number = <:-trans (<:-union (∪ⁿˢ-<:-∪ R number) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ string) number = <:-trans (<:-union (∪ⁿˢ-<:-∪ R number) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ nil) number = <:-trans (<:-union (∪ⁿˢ-<:-∪ R number) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ number) boolean = <:-trans (<:-union (∪ⁿˢ-<:-∪ R boolean) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ boolean) boolean = <:-union <:-∪-left <:-refl
∪ⁿˢ-<:-∪ (R ∪ string) boolean = <:-trans (<:-union (∪ⁿˢ-<:-∪ R boolean) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ nil) boolean = <:-trans (<:-union (∪ⁿˢ-<:-∪ R boolean) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ number) string = <:-trans (<:-union (∪ⁿˢ-<:-∪ R string) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ boolean) string = <:-trans (<:-union (∪ⁿˢ-<:-∪ R string) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ string) string = <:-union <:-∪-left <:-refl
∪ⁿˢ-<:-∪ (R ∪ nil) string = <:-trans (<:-union (∪ⁿˢ-<:-∪ R string) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ number) nil = <:-trans (<:-union (∪ⁿˢ-<:-∪ R nil) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ boolean) nil = <:-trans (<:-union (∪ⁿˢ-<:-∪ R nil) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ string) nil = <:-trans (<:-union (∪ⁿˢ-<:-∪ R nil) <:-refl) flipper
∪ⁿˢ-<:-∪ (R ∪ nil) nil = <:-union <:-∪-left <:-refl
∪-<:-∪ⁿˢ T never = <:-∪-lub <:-refl <:-never
∪-<:-∪ⁿˢ never number = <:-refl
∪-<:-∪ⁿˢ never boolean = <:-refl
∪-<:-∪ⁿˢ never string = <:-refl
∪-<:-∪ⁿˢ never nil = <:-refl
∪-<:-∪ⁿˢ unknown number = <:-unknown
∪-<:-∪ⁿˢ unknown boolean = <:-unknown
∪-<:-∪ⁿˢ unknown string = <:-unknown
∪-<:-∪ⁿˢ unknown nil = <:-unknown
∪-<:-∪ⁿˢ (R ⇒ S) number = <:-refl
∪-<:-∪ⁿˢ (R ⇒ S) boolean = <:-refl
∪-<:-∪ⁿˢ (R ⇒ S) string = <:-refl
∪-<:-∪ⁿˢ (R ⇒ S) nil = <:-refl
∪-<:-∪ⁿˢ (R ∩ S) number = <:-refl
∪-<:-∪ⁿˢ (R ∩ S) boolean = <:-refl
∪-<:-∪ⁿˢ (R ∩ S) string = <:-refl
∪-<:-∪ⁿˢ (R ∩ S) nil = <:-refl
∪-<:-∪ⁿˢ (R ∪ number) number = <:-∪-lub <:-refl <:-∪-right
∪-<:-∪ⁿˢ (R ∪ boolean) number = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R number) <:-refl)
∪-<:-∪ⁿˢ (R ∪ string) number = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R number) <:-refl)
∪-<:-∪ⁿˢ (R ∪ nil) number = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R number) <:-refl)
∪-<:-∪ⁿˢ (R ∪ number) boolean = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R boolean) <:-refl)
∪-<:-∪ⁿˢ (R ∪ boolean) boolean = <:-∪-lub <:-refl <:-∪-right
∪-<:-∪ⁿˢ (R ∪ string) boolean = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R boolean) <:-refl)
∪-<:-∪ⁿˢ (R ∪ nil) boolean = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R boolean) <:-refl)
∪-<:-∪ⁿˢ (R ∪ number) string = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R string) <:-refl)
∪-<:-∪ⁿˢ (R ∪ boolean) string = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R string) <:-refl)
∪-<:-∪ⁿˢ (R ∪ string) string = <:-∪-lub <:-refl <:-∪-right
∪-<:-∪ⁿˢ (R ∪ nil) string = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R string) <:-refl)
∪-<:-∪ⁿˢ (R ∪ number) nil = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R nil) <:-refl)
∪-<:-∪ⁿˢ (R ∪ boolean) nil = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R nil) <:-refl)
∪-<:-∪ⁿˢ (R ∪ string) nil = <:-trans flipper (<:-union (∪-<:-∪ⁿˢ R nil) <:-refl)
∪-<:-∪ⁿˢ (R ∪ nil) nil = <:-∪-lub <:-refl <:-∪-right
∪ⁿ-<:-∪ S never = <:-∪-left
∪ⁿ-<:-∪ S unknown = <:-∪-right
∪ⁿ-<:-∪ never (T ⇒ U) = <:-∪-right
∪ⁿ-<:-∪ unknown (T ⇒ U) = <:-∪-left
∪ⁿ-<:-∪ (R ⇒ S) (T ⇒ U) = ∪ᶠ-<:-∪ (R ⇒ S) (T ⇒ U)
∪ⁿ-<:-∪ (R ∩ S) (T ⇒ U) = ∪ᶠ-<:-∪ (R ∩ S) (T ⇒ U)
∪ⁿ-<:-∪ (R ∪ S) (T ⇒ U) = <:-trans (<:-union (∪ⁿ-<:-∪ R (T ⇒ U)) <:-refl) (<:-∪-lub (<:-∪-lub (<:-trans <:-∪-left <:-∪-left) <:-∪-right) (<:-trans <:-∪-right <:-∪-left))
∪ⁿ-<:-∪ never (T ∩ U) = <:-∪-right
∪ⁿ-<:-∪ unknown (T ∩ U) = <:-∪-left
∪ⁿ-<:-∪ (R ⇒ S) (T ∩ U) = ∪ᶠ-<:-∪ (R ⇒ S) (T ∩ U)
∪ⁿ-<:-∪ (R ∩ S) (T ∩ U) = ∪ᶠ-<:-∪ (R ∩ S) (T ∩ U)
∪ⁿ-<:-∪ (R ∪ S) (T ∩ U) = <:-trans (<:-union (∪ⁿ-<:-∪ R (T ∩ U)) <:-refl) (<:-∪-lub (<:-∪-lub (<:-trans <:-∪-left <:-∪-left) <:-∪-right) (<:-trans <:-∪-right <:-∪-left))
∪ⁿ-<:-∪ S (T ∪ U) = <:-∪-lub (<:-trans (∪ⁿ-<:-∪ S T) (<:-union <:-refl <:-∪-left)) (<:-trans <:-∪-right <:-∪-right)
∪-<:-∪ⁿ S never = <:-∪-lub <:-refl <:-never
∪-<:-∪ⁿ S unknown = <:-unknown
∪-<:-∪ⁿ never (T ⇒ U) = <:-∪-lub <:-never <:-refl
∪-<:-∪ⁿ unknown (T ⇒ U) = <:-unknown
∪-<:-∪ⁿ (R ⇒ S) (T ⇒ U) = ∪-<:-∪ᶠ (R ⇒ S) (T ⇒ U)
∪-<:-∪ⁿ (R ∩ S) (T ⇒ U) = ∪-<:-∪ᶠ (R ∩ S) (T ⇒ U)
∪-<:-∪ⁿ (R ∪ S) (T ⇒ U) = <:-trans <:-∪-assocr (<:-trans (<:-union <:-refl <:-∪-symm) (<:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ R (T ⇒ U)) <:-refl)))
∪-<:-∪ⁿ never (T ∩ U) = <:-∪-lub <:-never <:-refl
∪-<:-∪ⁿ unknown (T ∩ U) = <:-unknown
∪-<:-∪ⁿ (R ⇒ S) (T ∩ U) = ∪-<:-∪ᶠ (R ⇒ S) (T ∩ U)
∪-<:-∪ⁿ (R ∩ S) (T ∩ U) = ∪-<:-∪ᶠ (R ∩ S) (T ∩ U)
∪-<:-∪ⁿ (R ∪ S) (T ∩ U) = <:-trans <:-∪-assocr (<:-trans (<:-union <:-refl <:-∪-symm) (<:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ R (T ∩ U)) <:-refl)))
∪-<:-∪ⁿ never (T ∪ U) = <:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ never T) <:-refl)
∪-<:-∪ⁿ unknown (T ∪ U) = <:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ unknown T) <:-refl)
∪-<:-∪ⁿ (R ⇒ S) (T ∪ U) = <:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ (R ⇒ S) T) <:-refl)
∪-<:-∪ⁿ (R ∩ S) (T ∪ U) = <:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ (R ∩ S) T) <:-refl)
∪-<:-∪ⁿ (R ∪ S) (T ∪ U) = <:-trans <:-∪-assocl (<:-union (∪-<:-∪ⁿ (R ∪ S) T) <:-refl)
normalize-<: : ∀ T → normalize T <: T
<:-normalize : ∀ T → T <: normalize T
<:-normalize nil = <:-∪-right
<:-normalize (S ⇒ T) = <:-function (normalize-<: S) (<:-normalize T)
<:-normalize never = <:-refl
<:-normalize unknown = <:-refl
<:-normalize boolean = <:-∪-right
<:-normalize number = <:-∪-right
<:-normalize string = <:-∪-right
<:-normalize (S ∪ T) = <:-trans (<:-union (<:-normalize S) (<:-normalize T)) (∪-<:-∪ⁿ (normal S) (normal T))
<:-normalize (S ∩ T) = <:-trans (<:-intersect (<:-normalize S) (<:-normalize T)) (∩-<:-∩ⁿ (normal S) (normal T))
normalize-<: nil = <:-∪-lub <:-never <:-refl
normalize-<: (S ⇒ T) = <:-function (<:-normalize S) (normalize-<: T)
normalize-<: never = <:-refl
normalize-<: unknown = <:-refl
normalize-<: boolean = <:-∪-lub <:-never <:-refl
normalize-<: number = <:-∪-lub <:-never <:-refl
normalize-<: string = <:-∪-lub <:-never <:-refl
normalize-<: (S ∪ T) = <:-trans (∪ⁿ-<:-∪ (normal S) (normal T)) (<:-union (normalize-<: S) (normalize-<: T))
normalize-<: (S ∩ T) = <:-trans (∩ⁿ-<:-∩ (normal S) (normal T)) (<:-intersect (normalize-<: S) (normalize-<: T))
| 52.08802
| 443
| 0.505492
|
2056c72923f35045e758c4b46d613608c209cc9e
| 410
|
agda
|
Agda
|
test/Succeed/UnquoteWithArgs.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/UnquoteWithArgs.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/UnquoteWithArgs.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ where
open import Common.Prelude
open import Common.Reflection
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x _ = x
id : ∀ {a} {A : Set a} → A → A
id x = x
first : Tactic
first = give (def (quote const) [])
second : Tactic
second = give (def (quote const) (vArg (def (quote id) []) ∷ []))
number : Nat
number = unquote first 6 false
boolean : Bool
boolean = unquote second 5 true
| 17.083333
| 65
| 0.619512
|
fb2eeb0535466434b913d3ba7d796f8360cc86bc
| 523
|
agda
|
Agda
|
LibraBFT/Impl/Base/Types.agda
|
haroldcarr/bft-consensus-agda
|
34e4627855fb198665d0c98f377403a906ba75d7
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Impl/Base/Types.agda
|
haroldcarr/bft-consensus-agda
|
34e4627855fb198665d0c98f377403a906ba75d7
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Impl/Base/Types.agda
|
haroldcarr/bft-consensus-agda
|
34e4627855fb198665d0c98f377403a906ba75d7
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
module LibraBFT.Impl.Base.Types where
open import LibraBFT.Prelude
open import LibraBFT.Hash
NodeId : Set
NodeId = ℕ
_≟NodeId_ : (n1 n2 : NodeId) → Dec (n1 ≡ n2)
_≟NodeId_ = _≟ℕ_
UID : Set
UID = Hash
_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁)
_≟UID_ = _≟Hash_
| 23.772727
| 111
| 0.686424
|
20020918d95cfb5153353a96d255d339ec473410
| 4,617
|
agda
|
Agda
|
src/Categories/Category/CartesianClosed/Canonical.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/CartesianClosed/Canonical.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/CartesianClosed/Canonical.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
-- A "canonical" presentation of cartesian closed categories.
--
-- This presentation is equivalent to the one in
-- Categories.Category.CartesianClosed but it is easier to work with
-- in some circumstances.
--
-- Here, exponentials are not defined in terms of arbitrary products,
-- but in terms of a family of "canonical" products. Since products
-- are defined only up to isomorphism the choice of product does not
-- matter for the property of being cartesian closed, but working with
-- a fixed choice of representatives simplifies the constructions of
-- some instances of CCCs (e.g. Cats).
module Categories.Category.CartesianClosed.Canonical {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level using (levelOfTerm)
open import Function using (flip)
open import Categories.Category.Cartesian 𝒞 using (Cartesian)
import Categories.Category.CartesianClosed 𝒞 as 𝒞-CC
open import Categories.Object.Exponential 𝒞 using (Exponential)
open import Categories.Object.Product 𝒞
open import Categories.Object.Terminal 𝒞 using (Terminal)
open import Categories.Morphism.Reasoning 𝒞
private
open Category 𝒞
open HomReasoning
variable
A B C : Obj
f g h : A ⇒ B
-- A (canonical) cartesian closed category is a category with all
-- (canonical) products and exponentials
--
-- This presentation is equivalent to the one in
-- Categories.Category.CartesianClosed.CartesianClosed.
record CartesianClosed : Set (levelOfTerm 𝒞) where
infixr 7 _×_
infixr 9 _^_
infix 10 ⟨_,_⟩
field
-- Canonical products
⊤ : Obj
_×_ : Obj → Obj → Obj
! : A ⇒ ⊤
π₁ : A × B ⇒ A
π₂ : A × B ⇒ B
⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ A × B
!-unique : (f : A ⇒ ⊤) → ! ≈ f
π₁-comp : π₁ ∘ ⟨ f , g ⟩ ≈ f
π₂-comp : π₂ ∘ ⟨ f , g ⟩ ≈ g
⟨,⟩-unique : ∀ {f g} {h : C ⇒ A × B} →
π₁ ∘ h ≈ f → π₂ ∘ h ≈ g → ⟨ f , g ⟩ ≈ h
-- The above defines canonical finite products, making 𝒞 cartesian.
⊤-terminal : Terminal
⊤-terminal = record { !-unique = !-unique }
×-product : ∀ {A B} → Product A B
×-product {A} {B} =
record { project₁ = π₁-comp; project₂ = π₂-comp; unique = ⟨,⟩-unique }
isCartesian : Cartesian
isCartesian = record
{ terminal = ⊤-terminal
; products = record { product = ×-product }
}
open Cartesian isCartesian public
hiding (_×_; π₁; π₂; ⟨_,_⟩)
renaming (⟨⟩-cong₂ to ⟨,⟩-resp-≈)
field
-- Canonical exponentials (w.r.t. the canonical products)
_^_ : Obj → Obj → Obj
eval : B ^ A × A ⇒ B
curry : C × A ⇒ B → C ⇒ B ^ A
eval-comp : eval ∘ (curry f ⁂ id) ≈ f
curry-resp-≈ : f ≈ g → curry f ≈ curry g
curry-unique : eval ∘ (f ⁂ id) ≈ g → f ≈ curry g
-- The above defines canonical exponentials, making 𝒞 cartesian closed.
--
-- NOTE: below we use "⊗" to indicate "non-canonical" products.
^-exponential : ∀ {A B} → Exponential A B
^-exponential {A} {B} = record
{ B^A = B ^ A
; product = ×-product
; eval = eval
; λg = λ C⊗A f → curry (f ∘ repack ×-product C⊗A)
; β = λ {C} C⊗A {g} →
begin
eval ∘ [ C⊗A ⇒ ×-product ] curry (g ∘ repack ×-product C⊗A) ×id
≈˘⟨ pullʳ [ ×-product ⇒ ×-product ]×∘⟨⟩ ⟩
(eval ∘ (curry (g ∘ repack ×-product C⊗A) ⁂ id)) ∘ repack C⊗A ×-product
≈⟨ eval-comp ⟩∘⟨refl ⟩
(g ∘ repack ×-product C⊗A) ∘ repack C⊗A ×-product
≈⟨ cancelʳ (repack∘repack≈id ×-product C⊗A) ⟩
g
∎
; λ-unique = λ {C} C⊗A {g} {f} hyp →
curry-unique (begin
eval ∘ (f ⁂ id)
≈˘⟨ pullʳ [ C⊗A ⇒ ×-product ]×∘⟨⟩ ⟩
(eval ∘ [ C⊗A ⇒ ×-product ] f ×id) ∘ repack ×-product C⊗A
≈⟨ hyp ⟩∘⟨refl ⟩
g ∘ repack ×-product C⊗A
∎)
}
module Equivalence where
open 𝒞-CC using () renaming (CartesianClosed to CartesianClosed′)
-- The two presentations of CCCs are equivalent
fromCanonical : CartesianClosed → CartesianClosed′
fromCanonical cc = record
{ cartesian = CartesianClosed.isCartesian cc
; exp = CartesianClosed.^-exponential cc
}
toCanonical : CartesianClosed′ → CartesianClosed
toCanonical cc = record
{ ⊤ = ⊤
; _×_ = _×_
; ! = !
; π₁ = π₁
; π₂ = π₂
; ⟨_,_⟩ = ⟨_,_⟩
; !-unique = !-unique
; π₁-comp = project₁
; π₂-comp = project₂
; ⟨,⟩-unique = unique
; _^_ = _^_
; eval = eval′
; curry = λg
; eval-comp = β′
; curry-resp-≈ = λ-cong
; curry-unique = λ-unique′
}
where open CartesianClosed′ cc
| 28.85625
| 87
| 0.591726
|
dcc3a5f2104d29a2a2174d1569cbdd9d5f17d566
| 222
|
agda
|
Agda
|
vendor/stdlib/src/Data/Unit1.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Data/Unit1.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Data/Unit1.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- The unit type (in Set₁)
------------------------------------------------------------------------
module Data.Unit1 where
record ⊤₁ : Set₁ where
| 27.75
| 72
| 0.238739
|
4ad3bef4a1cfdd9fd68ea3cdb4162d1bdc99dfb2
| 169
|
agda
|
Agda
|
test/Succeed/Issue3361.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3361.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3361.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2018-11-03, issue #3361
--
-- Empty variable blocks should trigger warning rather than parse error.
variable
-- Expected warning:
-- Empty variable block.
| 18.777778
| 72
| 0.733728
|
cb04edf53b0fd2baf06b20321ebdbcb40b7a6e98
| 576
|
agda
|
Agda
|
test/Succeed/Issue679.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue679.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/Issue679.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2012-07-31 no eager introduction of hidden abstractions
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.conv.coerce:100 #-}
-- {-# OPTIONS -v tc.with:100 #-}
module Issue679 where
data Unit : Set where
unit : Unit
-- works also now:
test : {u : Unit} → Unit
test = λ {u} → u
T : Unit → Set
T unit = {u : Unit} → Unit
works : (u : Unit) → T u
works unit = λ {u} → u
fails : (u : Unit) → T u
fails unit with unit
... | _ = λ {u} → u
-- Error was:
-- {u : _14 _} → _16 _ !=< Unit of type Set
-- when checking that the expression λ {u} → u has type Unit
| 20.571429
| 67
| 0.590278
|
1063e053cfb047cd0ccb797d94ec6486b4afeb4f
| 15,868
|
agda
|
Agda
|
lib/Explore/Old/Sum/sum-properties.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 2
|
2016-06-05T09:25:32.000Z
|
2017-06-28T19:19:29.000Z
|
lib/Explore/Old/Sum/sum-properties.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 1
|
2019-03-16T14:24:04.000Z
|
2019-03-16T14:24:04.000Z
|
lib/Explore/Old/Sum/sum-properties.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
module sum-properties where
open import Type
import Level as L
open L using (Lift)
open import Data.Zero using (𝟘)
open import Data.Bool.NP
open Data.Bool.NP.Indexed
open import Data.Nat.NP
open import Data.Nat.Properties
open import Data.Product renaming (map to pmap)
open import Data.Sum
open import Relation.Binary.Product.Pointwise
open import Data.Maybe
open import Data.One using (𝟙)
open import Function.NP
import Function.Inverse as Inv
open Inv using (_↔_)
open import Function.Related
open import Function.Related.TypeIsomorphisms.NP
open import Function.Equality using (_⟨$⟩_)
--open import sum
open import Search.Type
open import Search.Sum
open import Search.Derived using (sum-swap)
open import Search.Searchable renaming (Searchable to SumProp)
open import Search.Searchable.Fin
open import Search.Searchable.Product
open import Search.Searchable.Sum
open import Relation.Binary.Sum
import Relation.Binary.PropositionalEquality.NP as ≡
open ≡ using (_≡_ ; _≗_ ; _≗₂_)
module _M2 {A : ★} (μA : SumProp A) (f g : A → Bool) where
sum-ext₂ : ∀ {A B}{f g : A → B → ℕ}(μA : SumProp A)(μB : SumProp B) → f ≗₂ g → sum μA (sum μB ∘ f) ≡ sum μA (sum μB ∘ g)
sum-ext₂ μA μB f≗g = sum-ext μA (sum-ext μB ∘ f≗g)
CountStableUnderInjection : ∀ {A} → SumProp A → Set
CountStableUnderInjection μ = ∀ p → Injective p → CountStableUnder (count μ) p
#-StableUnderInjection : ∀ {A}{μ : SumProp A} → SumStableUnderInjection (sum μ) → CountStableUnderInjection μ
#-StableUnderInjection sui p p-inj f = sui p p-inj (toℕ ∘ f)
𝟙SUI : SumStableUnderInjection (sum μ𝟙)
𝟙SUI f p x = ≡.refl
{-
stableMaybe : ∀ {A} (μA : SumProp A) → StableUnderInjection μA
→ StableUnderInjection (μMaybe μA)
stableMaybe {A} μA suiA f p p-inj with p nothing | ≡.inspect p nothing
... | nothing | ≡.[ eq ] = {!!}
where h : ∀ x → p (just x) ≡ just {!!}
h = {!!}
p' : A → A
p' x = {!p (just x)!}
p'-inj : Injective p'
p'-inj = {!!}
... | just pn | ≡.[ eq ] = ≡.trans (≡.cong (λ x → f nothing + x) (suiA (f ∘ just) p' p'-inj)) {!!}
where p' : A → A
p' x = maybe id pn (p (just x))
p'-inj : Injective p'
p'-inj = {!!}
SumsOk : ∀ {A B} → SumProp A → SumProp B → A ↔ B → ★
SumsOk μA μB iso = ∀ f → sum μA f ≡ sum μB (f ∘ from)
where from = _⟨$⟩_ (Inv.Inverse.from iso)
module StableIso {A B}(μA : SumProp A)(μB : SumProp B)(iso : A ↔ B)
(sums-ok : SumsOk μA μB iso)
(suiB : StableUnderInjection μB) where
to : A → B
to x = Inv.Inverse.to iso ⟨$⟩ x
from : B → A
from x = Inv.Inverse.from iso ⟨$⟩ x
from-inj : Injective from
from-inj = Inv.Inverse.injective (Inv.sym iso)
to-inj : Injective to
to-inj = Inv.Inverse.injective iso
left-inv : from ∘ to ≗ id
left-inv = Inv.Inverse.left-inverse-of iso
stable : StableUnderInjection μA
stable f p p-inj
= sum μA f
≡⟨ sums-ok f ⟩
sum μB (f ∘ from)
≡⟨ suiB (f ∘ from) (to ∘ p ∘ from) (from-inj ∘ p-inj ∘ to-inj) ⟩
sum μB (f ∘ from ∘ to ∘ p ∘ from)
≡⟨ sum-ext μB (λ x → ≡.cong f (left-inv (p (from x)))) ⟩
sum μB (f ∘ p ∘ from)
≡⟨ ≡.sym (sums-ok (f ∘ p)) ⟩
sum μA (f ∘ p)
∎
where open ≡.≡-Reasoning
record Iso1+ {A : Set}(μA : SumProp A) : ★₁ where
constructor mk
field
B : ★
μB : SumProp B
iso : A ↔ Maybe B
toMaybe : A → Maybe B
toMaybe x = Inv.Inverse.to iso ⟨$⟩ x
fromMaybe : Maybe B → A
fromMaybe x = Inv.Inverse.from iso ⟨$⟩ x
field
sums-ok : ∀ f → sum μA f ≡ sum (μMaybe μB) (f ∘ fromMaybe)
from-inj : Injective fromMaybe
from-inj = Inv.Inverse.injective (Inv.sym iso)
to-inj : Injective toMaybe
to-inj = Inv.Inverse.injective iso
left-inv : fromMaybe ∘ toMaybe ≗ id
left-inv = Inv.Inverse.left-inverse-of iso
stable : StableUnderInjection (μMaybe μB) → StableUnderInjection μA
stable suiMB = StableIso.stable μA (μMaybe μB) iso sums-ok suiMB
-- iso1+𝟙 : Iso1+ μ𝟙
-- iso1+𝟙 = {!mk !}
iso1+Maybe : ∀ {A} (μA : SumProp A) → Iso1+ μA → Iso1+ (μMaybe μA)
iso1+Maybe {A} μA A≅1+ = mk A μA Inv.id (λ f → ≡.refl)
iso1+FinSuc : ∀ n → Iso1+ (μFinSuc (suc n))
iso1+FinSuc n = mk (Fin (suc n)) (μFinSuc n) Fin∘suc↔Maybe∘Fin (λ f → ≡.refl)
-}
infix 4 _≈_
record _≈_ {A B} (μA : SumProp A)(μB : SumProp B) : Set where
constructor mk
field
iso : A ↔ B
from : B → A
from x = Inv.Inverse.from iso ⟨$⟩ x
to : A → B
to x = Inv.Inverse.to iso ⟨$⟩ x
from-inj : Injective from
from-inj = Inv.Inverse.injective (Inv.sym iso)
to-inj : Injective to
to-inj = Inv.Inverse.injective iso
field
sums-ok : ∀ f → sum μA f ≡ sum μB (f ∘ from)
sums-ok' : ∀ f → sum μB f ≡ sum μA (f ∘ to)
sums-ok' f = sum μB f
≡⟨ sum-ext μB (≡.cong f ∘ ≡.sym ∘ Inv.Inverse.right-inverse-of iso) ⟩
sum μB (f ∘ to ∘ from)
≡⟨ ≡.sym (sums-ok (f ∘ to)) ⟩
sum μA (f ∘ to)
∎
where open ≡.≡-Reasoning
StableUnder≈ : SumStableUnderInjection (sum μA) → SumStableUnderInjection (sum μB)
StableUnder≈ μA-SUI p p-inj f
= sum μB f
≡⟨ sums-ok' f ⟩
sum μA (f ∘ to)
≡⟨ μA-SUI (from ∘ p ∘ to) (to-inj ∘ p-inj ∘ from-inj) (f ∘ to) ⟩
sum μA (f ∘ to ∘ from ∘ p ∘ to)
≡⟨ ≡.sym (sums-ok' (f ∘ to ∘ from ∘ p)) ⟩
sum μB (f ∘ to ∘ from ∘ p)
≡⟨ sum-ext μB (≡.cong f ∘ Inv.Inverse.right-inverse-of iso ∘ p) ⟩
sum μB (f ∘ p)
∎
where open ≡.≡-Reasoning
≈-refl : ∀ {A} (μA : SumProp A) → μA ≈ μA
≈-refl μA = mk Inv.id (λ f → ≡.refl)
≈-id : ∀ {A} {μA : SumProp A} → μA ≈ μA
≈-id = ≈-refl _
≈-sym : ∀ {A B}{μA : SumProp A}{μB : SumProp B} → μA ≈ μB → μB ≈ μA
≈-sym A≈B = mk (Inv.sym iso) sums-ok'
where open _≈_ A≈B
≈-trans : ∀ {A B C}{μA : SumProp A}{μB : SumProp B}{μC : SumProp C} → μA ≈ μB → μB ≈ μC → μA ≈ μC
≈-trans A≈B B≈C = mk (iso B≈C Inv.∘ iso A≈B) (λ f → ≡.trans (sums-ok A≈B f) (sums-ok B≈C (f ∘ from A≈B)))
where open _≈_
infix 2 _≈∎
infixr 2 _≈⟨_⟩_
_≈∎ : ∀ {A} (μA : SumProp A) → μA ≈ μA
_≈∎ = ≈-refl
_≈⟨_⟩_ : ∀ {A B C} (μA : SumProp A){μB : SumProp B}{μC : SumProp C} → μA ≈ μB → μB ≈ μC → μA ≈ μC
_ ≈⟨ A≈B ⟩ B≈C = ≈-trans A≈B B≈C
{-
Fin1≈𝟙 : μFin 1 ≈ μ𝟙
Fin1≈𝟙 = mk iso sums-ok where
open import Relation.Binary.Sum
iso : _
iso = (A⊎𝟘↔A Inv.∘ Inv.id ⊎-cong Fin0↔𝟘) Inv.∘ Fin∘suc↔𝟙⊎Fin
sums-ok : (_ : _) → _
sums-ok f = ≡.refl
-}
𝟙+Fin : ∀ {n pf} → μ𝟙 ⊎-μ μFinSuc n ≈ μFinSuc (suc n)
𝟙+Fin {zero} {()}
𝟙+Fin {suc n} = mk iso sums-ok where
iso : _
iso = Inv.sym Fin∘suc↔𝟙⊎Fin
sums-ok : (_ : _) → _
sums-ok f = ≡.refl
𝟙×A≈A : ∀ {A}{μA : SumProp A} → μ𝟙 ×-μ μA ≈ μA
𝟙×A≈A = mk iso sums-ok where
iso : _
iso = 𝟙×A↔A
sums-ok : (_ : _) → _
sums-ok f = ≡.refl
μFinSucPres : ∀ {m n} → m ≡ n → μFinSuc m ≈ μFinSuc n
μFinSucPres eq rewrite eq = ≈-refl _
μFinPres : ∀ {m n pfm pfn} → m ≡ n → μFinSuc m {pfm} ≈ μFinSuc n {pfn}
μFinPres eq rewrite eq = ≈-refl _
{-
Maybe-Finable : ∀ {A} (μA : SumProp A) → Finable μA → Finable (μMaybe μA)
Maybe-Finable {A} μA finA = mk card iso sums-ok where
module FinA = Finable finA
card = suc FinA.FinCard
|A| : ℕ
|A| = suc (Finable.FinCard finA)
iso : _
iso = (𝟙 ⊎ A) ↔⟨ Inv.id ⊎-cong FinA.iso ⟩
(𝟙 ⊎ Fin |A|) ↔⟨ sym Fin∘suc↔𝟙⊎Fin ⟩
Fin (suc |A|) ∎
where open EquationalReasoning
sums-ok : (_ : _) → _
sums-ok f = ≡.cong (λ x → f (inj₁ _) + x) (FinA.sums-ok _)
-}
_+μ-cong_ : ∀ {A B C D}{μA : SumProp A}{μB : SumProp B}{μC : SumProp C}{μD : SumProp D}
→ μA ≈ μC → μB ≈ μD → μA ⊎-μ μB ≈ μC ⊎-μ μD
A≈C +μ-cong B≈D = mk iso sums-ok where
open import Relation.Binary.Sum
iso : _
iso = (_≈_.iso A≈C) ⊎-cong (_≈_.iso B≈D)
sums-ok : (_ : _) → _
sums-ok f = ≡.cong₂ _+_ (_≈_.sums-ok A≈C (f ∘ inj₁)) (_≈_.sums-ok B≈D (f ∘ inj₂))
+μ-assoc : ∀ {A B C}(μA : SumProp A)(μB : SumProp B)(μC : SumProp C)
→ (μA ⊎-μ μB) ⊎-μ μC ≈ μA ⊎-μ (μB ⊎-μ μC)
+μ-assoc μA μB μC = mk iso sums-ok where
iso : _
iso = ⊎-CMon.assoc _ _ _
sums-ok : (_ : _) → _
sums-ok f = ℕ°.+-assoc (sum μA (f ∘ inj₁ ∘ inj₁)) (sum μB (f ∘ inj₁ ∘ inj₂)) (sum μC (f ∘ inj₂))
+μ-comm : ∀ {A B}(μA : SumProp A)(μB : SumProp B)
→ μA ⊎-μ μB ≈ μB ⊎-μ μA
+μ-comm μA μB = mk iso sums-ok where
iso : _
iso = ⊎-CMon.comm _ _
sums-ok : (_ : _) → _
sums-ok f = ℕ°.+-comm (sum μA (f ∘ inj₁)) (sum μB (f ∘ inj₂))
_×μ-cong_ : ∀ {A B C D}{μA : SumProp A}{μB : SumProp B}{μC : SumProp C}{μD : SumProp D}
→ μA ≈ μC → μB ≈ μD → μA ×-μ μB ≈ μC ×-μ μD
_×μ-cong_ {μA = μA}{μD = μD} A≈C B≈D = mk iso sums-ok where
open import Relation.Binary.Product.Pointwise
iso : _
iso = _≈_.iso A≈C ×-cong _≈_.iso B≈D
sums-ok : (_ : _) → _
sums-ok f = ≡.trans (sum-ext μA (_≈_.sums-ok B≈D ∘ curry f))
(_≈_.sums-ok A≈C (λ a → sum μD (curry f a ∘ (_≈_.from B≈D))))
×μ-assoc : ∀ {A B C}(μA : SumProp A)(μB : SumProp B)(μC : SumProp C)
→ (μA ×-μ μB) ×-μ μC ≈ μA ×-μ (μB ×-μ μC)
×μ-assoc μA μB μC = mk iso sums-ok where
iso : _
iso = ×-CMon.assoc _ _ _
sums-ok : (_ : _) → _
sums-ok f = ≡.refl
×μ-comm : ∀ {A B}(μA : SumProp A)(μB : SumProp B)
→ μA ×-μ μB ≈ μB ×-μ μA
×μ-comm μA μB = mk iso sums-ok where
iso : _
iso = ×-CMon.comm _ _
sums-ok : (_ : _) → _
sums-ok f = sum-swap μA μB (curry f)
×+-distrib : ∀ {A B C}(μA : SumProp A)(μB : SumProp B)(μC : SumProp C)
→ (μA ⊎-μ μB) ×-μ μC ≈ (μA ×-μ μC) ⊎-μ (μB ×-μ μC)
×+-distrib μA μB μC = mk iso sums-ok where
iso : _
iso = ×⊎°.distribʳ _ _ _
sums-ok : (_ : _) → _
sums-ok f = ≡.refl
{-
_Suc-+_ : ∀ {m} → Suc m → ∀ n → Suc (m + n)
_Suc-+_ {zero} () _
_Suc-+_ {suc m} _ _ = _
+-≈ : ∀ m n {pfm pfn} → (μFin m {pfm}) +μ (μFin n {pfn}) ≈ μFin (m + n) {pfm Suc-+ n}
+-≈ zero _ {()}
+-≈ _ zero {_} {()}
+-≈ (suc m) (suc n) = μFin (suc m) +μ μFin (suc n)
≈⟨ {!!} ⟩
μFin (suc m + suc n)
≈∎
-}
{-
+-≈ (suc zero) (suc n) = μFin 1 +μ μFin (suc n)
≈⟨ Fin1≈𝟙 +μ-cong ≈-refl (μFin (suc n)) ⟩
μ𝟙 +μ μFinSuc n
≈⟨ 𝟙+Fin ⟩
μFinSuc (suc n)
≈∎
+-≈ (suc (suc m)) (suc n) = μFinSuc (suc m) +μ μFinSuc n
≈⟨ ≈-sym 𝟙+Fin +μ-cong ≈-refl (μFinSuc n) ⟩
(μ𝟙 +μ μFinSuc m) +μ μFinSuc n
≈⟨ +μ-assoc μ𝟙 (μFinSuc m) (μFinSuc n) ⟩
μ𝟙 +μ (μFinSuc m +μ μFinSuc n)
≈⟨ ≈-refl μ𝟙 +μ-cong +-≈ (suc m) (suc n) ⟩
μ𝟙 +μ μFinSuc (m + suc n)
≈⟨ 𝟙+Fin ⟩
μFinSuc (suc m + suc n)
≈∎
-}
{-
+-≈ : ∀ m n → (μFinSuc m) +μ (μFinSuc n) ≈ μFinSuc (m + suc n)
+-≈ zero n = μFinSuc zero +μ μFinSuc n
≈⟨ Fin1≈𝟙 +μ-cong ≈-refl (μFinSuc n) ⟩
μ𝟙 +μ μFinSuc n
≈⟨ 𝟙+Fin ⟩
μFinSuc (suc n)
≈∎
+-≈ (suc m) n = μFinSuc (suc m) +μ μFinSuc n
≈⟨ ≈-sym 𝟙+Fin +μ-cong ≈-refl (μFinSuc n) ⟩
(μ𝟙 +μ μFinSuc m) +μ μFinSuc n
≈⟨ +μ-assoc μ𝟙 (μFinSuc m) (μFinSuc n) ⟩
μ𝟙 +μ (μFinSuc m +μ μFinSuc n)
≈⟨ ≈-refl μ𝟙 +μ-cong +-≈ m n ⟩
μ𝟙 +μ μFinSuc (m + suc n)
≈⟨ 𝟙+Fin ⟩
μFinSuc (suc m + suc n)
≈∎
×-≈ : ∀ m n → μFinSuc m ×μ μFinSuc n ≈ μFinSuc (n + m * suc n)
×-≈ zero n = μFinSuc 0 ×μ μFinSuc n
≈⟨ Fin1≈𝟙 ×μ-cong (≈-refl (μFinSuc n)) ⟩
μ𝟙 ×μ μFinSuc n
≈⟨ 𝟙×A≈A ⟩
μFinSuc n
≈⟨ μFinSucPres (ℕ°.+-comm 0 n) ⟩
μFinSuc (n + 0)
≈∎
×-≈ (suc m) n = μFinSuc (suc m) ×μ μFinSuc n
≈⟨ ≈-sym 𝟙+Fin ×μ-cong ≈-refl (μFinSuc n) ⟩
(μ𝟙 +μ μFinSuc m) ×μ μFinSuc n
≈⟨ ×+-distrib μ𝟙 (μFinSuc m) (μFinSuc n) ⟩
(μ𝟙 ×μ μFinSuc n) +μ (μFinSuc m ×μ μFinSuc n)
≈⟨ 𝟙×A≈A {μA = μFinSuc n} +μ-cong ×-≈ m n ⟩
μFinSuc n +μ μFinSuc (n + m * suc n)
≈⟨ +-≈ n (n + m * suc n) ⟩
μFinSuc (n + suc m * suc n)
≈∎
-- μA→B ≈ μFinSuc (m ^ n)
-- μB ≈ μFinSuc m
-- μMaybe→ μA→B μB ≈ μFinSuc (m * m ^ n)
open import Data.Fin using (Fin ; zero ; suc)
Finable : ∀ {A} → SumProp A → Set
Finable μA = Σ ℕ λ FinCard → μA ≈ μFinSuc FinCard
𝟙-Finable : Finable μ𝟙
𝟙-Finable = 0 , ≈-sym Fin1≈𝟙
Fin-Finable : ∀ {n} → Finable (μFinSuc n)
Fin-Finable {n} = n , ≈-refl (μFinSuc n)
+-Finable : ∀ {A B}(μA : SumProp A)(μB : SumProp B) → Finable μA → Finable μB → Finable (μA +μ μB)
+-Finable μA μB (|A| , A≈) (|B| , B≈) = (|A| + suc |B|) ,
( μA +μ μB
≈⟨ A≈ +μ-cong B≈ ⟩
μFinSuc |A| +μ μFinSuc |B|
≈⟨ +-≈ |A| |B| ⟩
μFinSuc (|A| + suc |B|) ≈∎)
×-Finable : ∀ {A B}(μA : SumProp A)(μB : SumProp B) → Finable μA → Finable μB → Finable (μA ×μ μB)
×-Finable μA μB (|A| , A≈) (|B| , B≈) = (|B| + |A| * suc |B|) ,
( μA ×μ μB
≈⟨ A≈ ×μ-cong B≈ ⟩
μFinSuc |A| ×μ μFinSuc |B|
≈⟨ ×-≈ |A| |B| ⟩
μFinSuc (|B| + |A| * suc |B|)
≈∎)
module _M3 where
open import bijection-fin
open import Data.Fin using (Fin; zero; suc)
open import Data.Vec.NP renaming (sum to vsum)
sumFin : ∀ n → Sum (Fin n)
sumFin n f = vsum (tabulate f)
sumFin-spec : ∀ n → sumFin (suc n) ≗ sum (μFinSuc n)
sumFin-spec zero f = ℕ°.+-comm (f zero) 0
sumFin-spec (suc n) f = ≡.cong (_+_ (f zero)) (sumFin-spec n (f ∘ suc))
sumFinSUI : ∀ n f p → Injective p → sumFin n f ≡ sumFin n (f ∘ p)
sumFinSUI n f p p-inj = count-perm f p (λ _ _ → p-inj)
μFinSUI : ∀ {n} → StableUnderInjection (μFinSuc n)
μFinSUI {n} p p-inj f rewrite ≡.sym (sumFin-spec n f)
| ≡.sym (sumFin-spec n (f ∘ p))
= sumFinSUI (suc n) f p p-inj
open _M3 public
StableIfFinable : ∀ {A} (μA : SumProp A) → Finable μA → StableUnderInjection μA
StableIfFinable μA (_ , A≈Fin)
= _≈_.StableUnder≈ (≈-sym A≈Fin) μFinSUI
Decomposable : ★ → ★₁
Decomposable A = (A ↔ 𝟙) ⊎ (∃ λ (B : ★) → A ↔ Maybe B)
open EquationalReasoning
dec-iso : ∀ {A B} → (A ↔ B) → Decomposable A → Decomposable B
dec-iso A↔B (inj₁ A↔𝟙) = inj₁ (A↔𝟙 Inv.∘ sym A↔B)
dec-iso A↔B (inj₂ (C , A↔MaybeC)) = inj₂ (C , A↔MaybeC Inv.∘ sym A↔B)
Maybe×⊎ : ∀ {A B : ★} → (Maybe A × B) ↔ (B ⊎ (A × B))
Maybe×⊎ {A} {B} = (Maybe A × B) ↔⟨ Maybe↔𝟙⊎ ×-cong Inv.id ⟩
((𝟙 ⊎ A) × B) ↔⟨ ×⊎°.distribʳ B 𝟙 A ⟩
(𝟙 × B ⊎ A × B) ↔⟨ 𝟙×A↔A ⊎-cong Inv.id ⟩
(B ⊎ (A × B)) ∎
dec× : ∀ {A B} → Decomposable A → Decomposable B → Decomposable (A × B)
dec× {A} {B} (inj₁ A↔𝟙) dB = dec-iso (B ↔⟨ sym 𝟙×A↔A ⟩
(𝟙 × B) ↔⟨ sym A↔𝟙 ×-cong Inv.id ⟩
(A × B) ∎) dB
dec× {A} {B} dA (inj₁ B↔𝟙) = dec-iso (A ↔⟨ sym A×𝟙↔A ⟩
(A × 𝟙) ↔⟨ Inv.id ×-cong sym B↔𝟙 ⟩
(A × B) ∎) dA
dec× {A} {B} (inj₂ (C , A↔1+C)) (inj₂ (D , B↔1+D))
= inj₂ (_ , Maybe-⊎ Inv.∘ Maybe×⊎ Inv.∘ A↔1+C ×-cong B↔1+D)
dec+ : ∀ {A B} → Decomposable A → Decomposable B → Decomposable (A ⊎ B)
dec+ {A} {B} (inj₁ A↔𝟙) dB = inj₂ (B , sym Maybe↔𝟙⊎ Inv.∘ A↔𝟙 ⊎-cong Inv.id)
dec+ {A} {B} (inj₂ (C , A↔1+C)) dB = inj₂ ((C ⊎ B) , sym Maybe↔𝟙⊎
Inv.∘ ⊎-CMon.assoc 𝟙 C B
Inv.∘ (Maybe↔𝟙⊎ Inv.∘ A↔1+C) ⊎-cong Inv.id)
{-
dB = dec-iso {!!} dB
where dec : Decomposable (A × B)
{-
-- B + C×B
-- 1×B + C×B
-- (1+C) × B
-- A × B
-}
Stable× : ∀ {A} (μA : SumProp A) {B} (μB : SumProp B)
(suiA : StableUnderInjection μA)
(suiB : StableUnderInjection μB)
→ StableUnderInjection (μA ×μ μB)
Stable× μA μB suiA suiB = {!!}
-- -}
-- -}
-- -}
-- -}
| 31.29783
| 120
| 0.509201
|
399b223705ba7d86dea1dcabd99d0ce14e3391d8
| 14,271
|
agda
|
Agda
|
Cubical/Foundations/Path.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:02.000Z
|
2022-02-05T01:25:02.000Z
|
Cubical/Foundations/Path.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Foundations.Path where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Reflection.StrictEquiv
private
variable
ℓ ℓ' : Level
A : Type ℓ
-- Less polymorphic version of `cong`, to avoid some unresolved metas
cong′ : ∀ {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y)
→ Path B (f x) (f y)
cong′ f = cong f
{-# INLINE cong′ #-}
PathP≡Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≡ Path (P i1) (transport (λ i → P i) p) q
PathP≡Path P p q i = PathP (λ j → P (i ∨ j)) (transport-filler (λ j → P j) p i) q
PathP≡Path⁻ : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≡ Path (P i0) p (transport⁻ (λ i → P i) q)
PathP≡Path⁻ P p q i = PathP (λ j → P (~ i ∧ j)) p (transport⁻-filler (λ j → P j) q i)
PathPIsoPath : ∀ (A : I → Type ℓ) (x : A i0) (y : A i1) → Iso (PathP A x y) (transport (λ i → A i) x ≡ y)
PathPIsoPath A x y .Iso.fun = fromPathP
PathPIsoPath A x y .Iso.inv = toPathP
PathPIsoPath A x y .Iso.rightInv q k i =
hcomp
(λ j → λ
{ (i = i0) → slide (j ∨ ~ k)
; (i = i1) → q j
; (k = i0) → transp (λ l → A (i ∨ l)) i (fromPathPFiller j)
; (k = i1) → ∧∨Square i j
})
(transp (λ l → A (i ∨ ~ k ∨ l)) (i ∨ ~ k)
(transp (λ l → (A (i ∨ (~ k ∧ l)))) (k ∨ i)
(transp (λ l → A (i ∧ l)) (~ i)
x)))
where
fromPathPFiller : _
fromPathPFiller =
hfill
(λ j → λ
{ (i = i0) → x
; (i = i1) → q j })
(inS (transp (λ j → A (i ∧ j)) (~ i) x))
slide : I → _
slide i = transp (λ l → A (i ∨ l)) i (transp (λ l → A (i ∧ l)) (~ i) x)
∧∨Square : I → I → _
∧∨Square i j =
hcomp
(λ l → λ
{ (i = i0) → slide j
; (i = i1) → q (j ∧ l)
; (j = i0) → slide i
; (j = i1) → q (i ∧ l)
})
(slide (i ∨ j))
PathPIsoPath A x y .Iso.leftInv q k i =
outS
(hcomp-unique
(λ j → λ
{ (i = i0) → x
; (i = i1) → transp (λ l → A (j ∨ l)) j (q j)
})
(inS (transp (λ l → A (i ∧ l)) (~ i) x))
(λ j → inS (transp (λ l → A (i ∧ (j ∨ l))) (~ i ∨ j) (q (i ∧ j)))))
k
PathP≃Path : (A : I → Type ℓ) (x : A i0) (y : A i1) →
PathP A x y ≃ (transport (λ i → A i) x ≡ y)
PathP≃Path A x y = isoToEquiv (PathPIsoPath A x y)
PathP≡compPath : ∀ {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) (r : x ≡ z)
→ (PathP (λ i → x ≡ q i) p r) ≡ (p ∙ q ≡ r)
PathP≡compPath p q r k = PathP (λ i → p i0 ≡ q (i ∨ k)) (λ j → compPath-filler p q k j) r
-- a quick corollary for 3-constant functions
3-ConstantCompChar : {A : Type ℓ} {B : Type ℓ'} (f : A → B) (link : 2-Constant f)
→ (∀ x y z → link x y ∙ link y z ≡ link x z)
→ 3-Constant f
3-Constant.link (3-ConstantCompChar f link coh₂) = link
3-Constant.coh₁ (3-ConstantCompChar f link coh₂) _ _ _ =
transport⁻ (PathP≡compPath _ _ _) (coh₂ _ _ _)
PathP≡doubleCompPathˡ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (p ⁻¹ ∙∙ q ∙∙ s ≡ r)
PathP≡doubleCompPathˡ p q r s k = PathP (λ i → p (i ∨ k) ≡ s (i ∨ k))
(λ j → doubleCompPath-filler (p ⁻¹) q s k j) r
PathP≡doubleCompPathʳ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (q ≡ p ∙∙ r ∙∙ s ⁻¹)
PathP≡doubleCompPathʳ p q r s k = PathP (λ i → p (i ∧ (~ k)) ≡ s (i ∧ (~ k)))
q (λ j → doubleCompPath-filler p r (s ⁻¹) k j)
compPathl-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : x ≡ z) → p ∙ (sym p ∙ q) ≡ q
compPathl-cancel p q = p ∙ (sym p ∙ q) ≡⟨ assoc p (sym p) q ⟩
(p ∙ sym p) ∙ q ≡⟨ cong (_∙ q) (rCancel p) ⟩
refl ∙ q ≡⟨ sym (lUnit q) ⟩
q ∎
compPathr-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : z ≡ y) (q : x ≡ y) → (q ∙ sym p) ∙ p ≡ q
compPathr-cancel {x = x} p q i j =
hcomp-equivFiller (doubleComp-faces (λ _ → x) (sym p) j) (inS (q j)) (~ i)
compPathl-isEquiv : {x y z : A} (p : x ≡ y) → isEquiv (λ (q : y ≡ z) → p ∙ q)
compPathl-isEquiv p = isoToIsEquiv (iso (p ∙_) (sym p ∙_) (compPathl-cancel p) (compPathl-cancel (sym p)))
compPathlEquiv : {x y z : A} (p : x ≡ y) → (y ≡ z) ≃ (x ≡ z)
compPathlEquiv p = (p ∙_) , compPathl-isEquiv p
compPathr-isEquiv : {x y z : A} (p : y ≡ z) → isEquiv (λ (q : x ≡ y) → q ∙ p)
compPathr-isEquiv p = isoToIsEquiv (iso (_∙ p) (_∙ sym p) (compPathr-cancel p) (compPathr-cancel (sym p)))
compPathrEquiv : {x y z : A} (p : y ≡ z) → (x ≡ y) ≃ (x ≡ z)
compPathrEquiv p = (_∙ p) , compPathr-isEquiv p
-- Variations of isProp→isSet for PathP
isProp→SquareP : ∀ {B : I → I → Type ℓ} → ((i j : I) → isProp (B i j))
→ {a : B i0 i0} {b : B i0 i1} {c : B i1 i0} {d : B i1 i1}
→ (r : PathP (λ j → B j i0) a c) (s : PathP (λ j → B j i1) b d)
→ (t : PathP (λ j → B i0 j) a b) (u : PathP (λ j → B i1 j) c d)
→ SquareP B t u r s
isProp→SquareP {B = B} isPropB {a = a} r s t u i j =
hcomp (λ { k (i = i0) → isPropB i0 j (base i0 j) (t j) k
; k (i = i1) → isPropB i1 j (base i1 j) (u j) k
; k (j = i0) → isPropB i i0 (base i i0) (r i) k
; k (j = i1) → isPropB i i1 (base i i1) (s i) k
}) (base i j) where
base : (i j : I) → B i j
base i j = transport (λ k → B (i ∧ k) (j ∧ k)) a
isProp→isPropPathP : ∀ {ℓ} {B : I → Type ℓ} → ((i : I) → isProp (B i))
→ (b0 : B i0) (b1 : B i1)
→ isProp (PathP (λ i → B i) b0 b1)
isProp→isPropPathP {B = B} hB b0 b1 = isProp→SquareP (λ _ → hB) refl refl
isProp→isContrPathP : {A : I → Type ℓ} → (∀ i → isProp (A i))
→ (x : A i0) (y : A i1)
→ isContr (PathP A x y)
isProp→isContrPathP h x y = isProp→PathP h x y , isProp→isPropPathP h x y _
-- Flipping a square along its diagonal
flipSquare : {a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁ → Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquare sq i j = sq j i
module _ {a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁} {a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
where
flipSquareEquiv : Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ Square a₋₀ a₋₁ a₀₋ a₁₋
unquoteDef flipSquareEquiv = defStrictEquiv flipSquareEquiv flipSquare flipSquare
flipSquarePath : Square a₀₋ a₁₋ a₋₀ a₋₁ ≡ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquarePath = ua flipSquareEquiv
module _ {a₀₀ a₁₁ : A} {a₋ : a₀₀ ≡ a₁₁}
{a₁₀ : A} {a₁₋ : a₁₀ ≡ a₁₁} {a₋₀ : a₀₀ ≡ a₁₀} where
slideSquareFaces : (i j k : I) → Partial (i ∨ ~ i ∨ j ∨ ~ j) A
slideSquareFaces i j k (i = i0) = a₋ (j ∧ ~ k)
slideSquareFaces i j k (i = i1) = a₁₋ j
slideSquareFaces i j k (j = i0) = a₋₀ i
slideSquareFaces i j k (j = i1) = a₋ (i ∨ ~ k)
slideSquare : Square a₋ a₁₋ a₋₀ refl → Square refl a₁₋ a₋₀ a₋
slideSquare sq i j = hcomp (slideSquareFaces i j) (sq i j)
slideSquareEquiv : (Square a₋ a₁₋ a₋₀ refl) ≃ (Square refl a₁₋ a₋₀ a₋)
slideSquareEquiv = isoToEquiv (iso slideSquare slideSquareInv fillerTo fillerFrom) where
slideSquareInv : Square refl a₁₋ a₋₀ a₋ → Square a₋ a₁₋ a₋₀ refl
slideSquareInv sq i j = hcomp (λ k → slideSquareFaces i j (~ k)) (sq i j)
fillerTo : ∀ p → slideSquare (slideSquareInv p) ≡ p
fillerTo p k i j = hcomp-equivFiller (λ k → slideSquareFaces i j (~ k)) (inS (p i j)) (~ k)
fillerFrom : ∀ p → slideSquareInv (slideSquare p) ≡ p
fillerFrom p k i j = hcomp-equivFiller (slideSquareFaces i j) (inS (p i j)) (~ k)
-- The type of fillers of a square is equivalent to the double composition identites
Square≃doubleComp : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(a₀₋ : a₀₀ ≡ a₀₁) (a₁₋ : a₁₀ ≡ a₁₁)
(a₋₀ : a₀₀ ≡ a₁₀) (a₋₁ : a₀₁ ≡ a₁₁)
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ (a₋₀ ⁻¹ ∙∙ a₀₋ ∙∙ a₋₁ ≡ a₁₋)
Square≃doubleComp a₀₋ a₁₋ a₋₀ a₋₁ = transportEquiv (PathP≡doubleCompPathˡ a₋₀ a₀₋ a₁₋ a₋₁)
-- Flipping a square in Ω²A is the same as inverting it
sym≡flipSquare : {x : A} (P : Square (refl {x = x}) refl refl refl)
→ sym P ≡ flipSquare P
sym≡flipSquare {x = x} P = sym (main refl P)
where
B : (q : x ≡ x) → I → Type _
B q i = PathP (λ j → x ≡ q (i ∨ j)) (λ k → q (i ∧ k)) refl
main : (q : x ≡ x) (p : refl ≡ q) → PathP (λ i → B q i) (λ i j → p j i) (sym p)
main q = J (λ q p → PathP (λ i → B q i) (λ i j → p j i) (sym p)) refl
-- Inverting both interval arguments of a square in Ω²A is the same as doing nothing
sym-cong-sym≡id : {x : A} (P : Square (refl {x = x}) refl refl refl)
→ P ≡ λ i j → P (~ i) (~ j)
sym-cong-sym≡id {x = x} P = sym (main refl P)
where
B : (q : x ≡ x) → I → Type _
B q i = Path (x ≡ q i) (λ j → q (i ∨ ~ j)) λ j → q (i ∧ j)
main : (q : x ≡ x) (p : refl ≡ q) → PathP (λ i → B q i) (λ i j → p (~ i) (~ j)) p
main q = J (λ q p → PathP (λ i → B q i) (λ i j → p (~ i) (~ j)) p) refl
-- Applying cong sym is the same as flipping a square in Ω²A
flipSquare≡cong-sym : ∀ {ℓ} {A : Type ℓ} {x : A} (P : Square (refl {x = x}) refl refl refl)
→ flipSquare P ≡ λ i j → P i (~ j)
flipSquare≡cong-sym P = sym (sym≡flipSquare P) ∙ sym (sym-cong-sym≡id (cong sym P))
-- Applying cong sym is the same as inverting a square in Ω²A
sym≡cong-sym : ∀ {ℓ} {A : Type ℓ} {x : A} (P : Square (refl {x = x}) refl refl refl)
→ sym P ≡ cong sym P
sym≡cong-sym P = sym-cong-sym≡id (sym P)
-- sym induces an equivalence on identity types of paths
symIso : {a b : A} (p q : a ≡ b) → Iso (p ≡ q) (q ≡ p)
symIso p q = iso sym sym (λ _ → refl) λ _ → refl
-- J is an equivalence
Jequiv : {x : A} (P : ∀ y → x ≡ y → Type ℓ') → P x refl ≃ (∀ {y} (p : x ≡ y) → P y p)
Jequiv P = isoToEquiv isom
where
isom : Iso _ _
Iso.fun isom = J P
Iso.inv isom f = f refl
Iso.rightInv isom f =
implicitFunExt λ {_} →
funExt λ t →
J (λ _ t → J P (f refl) t ≡ f t) (JRefl P (f refl)) t
Iso.leftInv isom = JRefl P
-- Action of PathP on equivalences (without relying on univalence)
congPathIso : ∀ {ℓ ℓ'} {A : I → Type ℓ} {B : I → Type ℓ'}
(e : ∀ i → A i ≃ B i) {a₀ : A i0} {a₁ : A i1}
→ Iso (PathP A a₀ a₁) (PathP B (e i0 .fst a₀) (e i1 .fst a₁))
congPathIso {A = A} {B} e {a₀} {a₁} .Iso.fun p i = e i .fst (p i)
congPathIso {A = A} {B} e {a₀} {a₁} .Iso.inv q i =
hcomp
(λ j → λ
{ (i = i0) → retEq (e i0) a₀ j
; (i = i1) → retEq (e i1) a₁ j
})
(invEq (e i) (q i))
congPathIso {A = A} {B} e {a₀} {a₁} .Iso.rightInv q k i =
hcomp
(λ j → λ
{ (i = i0) → commSqIsEq (e i0 .snd) a₀ j k
; (i = i1) → commSqIsEq (e i1 .snd) a₁ j k
; (k = i0) →
e i .fst
(hfill
(λ j → λ
{ (i = i0) → retEq (e i0) a₀ j
; (i = i1) → retEq (e i1) a₁ j
})
(inS (invEq (e i) (q i)))
j)
; (k = i1) → q i
})
(secEq (e i) (q i) k)
where b = commSqIsEq
congPathIso {A = A} {B} e {a₀} {a₁} .Iso.leftInv p k i =
hcomp
(λ j → λ
{ (i = i0) → retEq (e i0) a₀ (j ∨ k)
; (i = i1) → retEq (e i1) a₁ (j ∨ k)
; (k = i1) → p i
})
(retEq (e i) (p i) k)
congPathEquiv : ∀ {ℓ ℓ'} {A : I → Type ℓ} {B : I → Type ℓ'}
(e : ∀ i → A i ≃ B i) {a₀ : A i0} {a₁ : A i1}
→ PathP A a₀ a₁ ≃ PathP B (e i0 .fst a₀) (e i1 .fst a₁)
congPathEquiv e = isoToEquiv (congPathIso e)
-- Characterizations of dependent paths in path types
doubleCompPath-filler∙ : {a b c d : A} (p : a ≡ b) (q : b ≡ c) (r : c ≡ d)
→ PathP (λ i → p i ≡ r (~ i)) (p ∙ q ∙ r) q
doubleCompPath-filler∙ {A = A} {b = b} p q r j i =
hcomp (λ k → λ { (i = i0) → p j
; (i = i1) → side j k
; (j = i1) → q (i ∧ k)})
(p (j ∨ i))
where
side : I → I → A
side i j =
hcomp (λ k → λ { (i = i1) → q j
; (j = i0) → b
; (j = i1) → r (~ i ∧ k)})
(q j)
PathP→compPathL : {a b c d : A} {p : a ≡ c} {q : b ≡ d} {r : a ≡ b} {s : c ≡ d}
→ PathP (λ i → p i ≡ q i) r s
→ sym p ∙ r ∙ q ≡ s
PathP→compPathL {p = p} {q = q} {r = r} {s = s} P j i =
hcomp (λ k → λ { (i = i0) → p (j ∨ k)
; (i = i1) → q (j ∨ k)
; (j = i0) → doubleCompPath-filler∙ (sym p) r q (~ k) i
; (j = i1) → s i })
(P j i)
PathP→compPathR : {a b c d : A} {p : a ≡ c} {q : b ≡ d} {r : a ≡ b} {s : c ≡ d}
→ PathP (λ i → p i ≡ q i) r s
→ r ≡ p ∙ s ∙ sym q
PathP→compPathR {p = p} {q = q} {r = r} {s = s} P j i =
hcomp (λ k → λ { (i = i0) → p (j ∧ (~ k))
; (i = i1) → q (j ∧ (~ k))
; (j = i0) → r i
; (j = i1) → doubleCompPath-filler∙ p s (sym q) (~ k) i})
(P j i)
-- Other direction
compPathL→PathP : {a b c d : A} {p : a ≡ c} {q : b ≡ d} {r : a ≡ b} {s : c ≡ d}
→ sym p ∙ r ∙ q ≡ s
→ PathP (λ i → p i ≡ q i) r s
compPathL→PathP {p = p} {q = q} {r = r} {s = s} P j i =
hcomp (λ k → λ { (i = i0) → p (~ k ∨ j)
; (i = i1) → q (~ k ∨ j)
; (j = i0) → doubleCompPath-filler∙ (sym p) r q k i
; (j = i1) → s i})
(P j i)
compPathR→PathP : {a b c d : A} {p : a ≡ c} {q : b ≡ d} {r : a ≡ b} {s : c ≡ d}
→ r ≡ p ∙ s ∙ sym q
→ PathP (λ i → p i ≡ q i) r s
compPathR→PathP {p = p} {q = q} {r = r} {s = s} P j i =
hcomp (λ k → λ { (i = i0) → p (k ∧ j)
; (i = i1) → q (k ∧ j)
; (j = i0) → r i
; (j = i1) → doubleCompPath-filler∙ p s (sym q) k i})
(P j i)
compPathR→PathP∙∙ : {a b c d : A} {p : a ≡ c} {q : b ≡ d} {r : a ≡ b} {s : c ≡ d}
→ r ≡ p ∙∙ s ∙∙ sym q
→ PathP (λ i → p i ≡ q i) r s
compPathR→PathP∙∙ {p = p} {q = q} {r = r} {s = s} P j i =
hcomp (λ k → λ { (i = i0) → p (k ∧ j)
; (i = i1) → q (k ∧ j)
; (j = i0) → r i
; (j = i1) → doubleCompPath-filler p s (sym q) (~ k) i})
(P j i)
| 39.31405
| 106
| 0.474879
|
d07511ba5696cc5ba7b2cd5a9ff365c898d073f7
| 8,342
|
agda
|
Agda
|
src/OPair.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | 5
|
2019-10-02T13:46:23.000Z
|
2021-01-10T13:27:48.000Z
|
src/OPair.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | null | null | null |
src/OPair.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --allow-unsolved-metas #-}
open import Level
open import Ordinals
module OPair {n : Level } (O : Ordinals {n}) where
open import zf
open import logic
import OD
import ODUtil
import OrdUtil
open import Relation.Nullary
open import Relation.Binary
open import Data.Empty
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
open OD O
open OD.OD
open OD.HOD
open ODAxiom odAxiom
open Ordinals.Ordinals O
open Ordinals.IsOrdinals isOrdinal
open Ordinals.IsNext isNext
open OrdUtil O
open ODUtil O
open _∧_
open _∨_
open Bool
open _==_
<_,_> : (x y : HOD) → HOD
< x , y > = (x , x ) , (x , y )
exg-pair : { x y : HOD } → (x , y ) =h= ( y , x )
exg-pair {x} {y} = record { eq→ = left ; eq← = right } where
left : {z : Ordinal} → odef (x , y) z → odef (y , x) z
left (case1 t) = case2 t
left (case2 t) = case1 t
right : {z : Ordinal} → odef (y , x) z → odef (x , y) z
right (case1 t) = case2 t
right (case2 t) = case1 t
ord≡→≡ : { x y : HOD } → & x ≡ & y → x ≡ y
ord≡→≡ eq = subst₂ (λ j k → j ≡ k ) *iso *iso ( cong ( λ k → * k ) eq )
od≡→≡ : { x y : Ordinal } → * x ≡ * y → x ≡ y
od≡→≡ eq = subst₂ (λ j k → j ≡ k ) &iso &iso ( cong ( λ k → & k ) eq )
eq-prod : { x x' y y' : HOD } → x ≡ x' → y ≡ y' → < x , y > ≡ < x' , y' >
eq-prod refl refl = refl
xx=zy→x=y : {x y z : HOD } → ( x , x ) =h= ( z , y ) → x ≡ y
xx=zy→x=y {x} {y} eq with trio< (& x) (& y)
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c with eq← eq {& y} (case2 refl)
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c | case1 s = ⊥-elim ( o<¬≡ (sym s) a )
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c | case2 s = ⊥-elim ( o<¬≡ (sym s) a )
xx=zy→x=y {x} {y} eq | tri≈ ¬a b ¬c = ord≡→≡ b
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c with eq← eq {& y} (case2 refl)
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c | case1 s = ⊥-elim ( o<¬≡ s c )
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c | case2 s = ⊥-elim ( o<¬≡ s c )
prod-eq : { x x' y y' : HOD } → < x , y > =h= < x' , y' > → (x ≡ x' ) ∧ ( y ≡ y' )
prod-eq {x} {x'} {y} {y'} eq = ⟪ lemmax , lemmay ⟫ where
lemma2 : {x y z : HOD } → ( x , x ) =h= ( z , y ) → z ≡ y
lemma2 {x} {y} {z} eq = trans (sym (xx=zy→x=y lemma3 )) ( xx=zy→x=y eq ) where
lemma3 : ( x , x ) =h= ( y , z )
lemma3 = ==-trans eq exg-pair
lemma1 : {x y : HOD } → ( x , x ) =h= ( y , y ) → x ≡ y
lemma1 {x} {y} eq with eq← eq {& y} (case2 refl)
lemma1 {x} {y} eq | case1 s = ord≡→≡ (sym s)
lemma1 {x} {y} eq | case2 s = ord≡→≡ (sym s)
lemma4 : {x y z : HOD } → ( x , y ) =h= ( x , z ) → y ≡ z
lemma4 {x} {y} {z} eq with eq← eq {& z} (case2 refl)
lemma4 {x} {y} {z} eq | case1 s with ord≡→≡ s -- x ≡ z
... | refl with lemma2 (==-sym eq )
... | refl = refl
lemma4 {x} {y} {z} eq | case2 s = ord≡→≡ (sym s) -- y ≡ z
lemmax : x ≡ x'
lemmax with eq→ eq {& (x , x)} (case1 refl)
lemmax | case1 s = lemma1 (ord→== s ) -- (x,x)≡(x',x')
lemmax | case2 s with lemma2 (ord→== s ) -- (x,x)≡(x',y') with x'≡y'
... | refl = lemma1 (ord→== s )
lemmay : y ≡ y'
lemmay with lemmax
... | refl with lemma4 eq -- with (x,y)≡(x,y')
... | eq1 = lemma4 (ord→== (cong (λ k → & k ) eq1 ))
--
-- unlike ordered pair, ZFProduct is not a HOD
data ord-pair : (p : Ordinal) → Set n where
pair : (x y : Ordinal ) → ord-pair ( & ( < * x , * y > ) )
ZFProduct : OD
ZFProduct = record { def = λ x → ord-pair x }
-- open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ )
-- eq-pair : { x x' y y' : Ordinal } → x ≡ x' → y ≡ y' → pair x y ≅ pair x' y'
-- eq-pair refl refl = HE.refl
pi1 : { p : Ordinal } → ord-pair p → Ordinal
pi1 ( pair x y) = x
π1 : { p : HOD } → def ZFProduct (& p) → HOD
π1 lt = * (pi1 lt )
pi2 : { p : Ordinal } → ord-pair p → Ordinal
pi2 ( pair x y ) = y
π2 : { p : HOD } → def ZFProduct (& p) → HOD
π2 lt = * (pi2 lt )
op-cons : { ox oy : Ordinal } → def ZFProduct (& ( < * ox , * oy > ))
op-cons {ox} {oy} = pair ox oy
def-subst : {Z : OD } {X : Ordinal }{z : OD } {x : Ordinal }→ def Z X → Z ≡ z → X ≡ x → def z x
def-subst df refl refl = df
p-cons : ( x y : HOD ) → def ZFProduct (& ( < x , y >))
p-cons x y = def-subst {_} {_} {ZFProduct} {& (< x , y >)} (pair (& x) ( & y )) refl (
let open ≡-Reasoning in begin
& < * (& x) , * (& y) >
≡⟨ cong₂ (λ j k → & < j , k >) *iso *iso ⟩
& < x , y >
∎ )
op-iso : { op : Ordinal } → (q : ord-pair op ) → & < * (pi1 q) , * (pi2 q) > ≡ op
op-iso (pair ox oy) = refl
p-iso : { x : HOD } → (p : def ZFProduct (& x) ) → < π1 p , π2 p > ≡ x
p-iso {x} p = ord≡→≡ (op-iso p)
p-pi1 : { x y : HOD } → (p : def ZFProduct (& < x , y >) ) → π1 p ≡ x
p-pi1 {x} {y} p = proj1 ( prod-eq ( ord→== (op-iso p) ))
p-pi2 : { x y : HOD } → (p : def ZFProduct (& < x , y >) ) → π2 p ≡ y
p-pi2 {x} {y} p = proj2 ( prod-eq ( ord→== (op-iso p)))
ω-pair : {x y : HOD} → {m : Ordinal} → & x o< next m → & y o< next m → & (x , y) o< next m
ω-pair lx ly = next< (omax<nx lx ly ) ho<
ω-opair : {x y : HOD} → {m : Ordinal} → & x o< next m → & y o< next m → & < x , y > o< next m
ω-opair {x} {y} {m} lx ly = lemma0 where
lemma0 : & < x , y > o< next m
lemma0 = osucprev (begin
osuc (& < x , y >)
<⟨ osuc<nx ho< ⟩
next (omax (& (x , x)) (& (x , y)))
≡⟨ cong (λ k → next k) (sym ( omax≤ _ _ pair-xx<xy )) ⟩
next (osuc (& (x , y)))
≡⟨ sym (nexto≡) ⟩
next (& (x , y))
≤⟨ x<ny→≤next (ω-pair lx ly) ⟩
next m
∎ ) where
open o≤-Reasoning O
_⊗_ : (A B : HOD) → HOD
A ⊗ B = Union ( Replace B (λ b → Replace A (λ a → < a , b > ) ))
product→ : {A B a b : HOD} → A ∋ a → B ∋ b → ( A ⊗ B ) ∋ < a , b >
product→ {A} {B} {a} {b} A∋a B∋b = λ t → t (& (Replace A (λ a → < a , b >)))
⟪ lemma1 , subst (λ k → odef k (& < a , b >)) (sym *iso) lemma2 ⟫ where
lemma1 : odef (Replace B (λ b₁ → Replace A (λ a₁ → < a₁ , b₁ >))) (& (Replace A (λ a₁ → < a₁ , b >)))
lemma1 = replacement← B b B∋b
lemma2 : odef (Replace A (λ a₁ → < a₁ , b >)) (& < a , b >)
lemma2 = replacement← A a A∋a
x<nextA : {A x : HOD} → A ∋ x → & x o< next (odmax A)
x<nextA {A} {x} A∋x = ordtrans (c<→o< {x} {A} A∋x) ho<
A<Bnext : {A B x : HOD} → & A o< & B → A ∋ x → & x o< next (odmax B)
A<Bnext {A} {B} {x} lt A∋x = osucprev (begin
osuc (& x)
<⟨ osucc (c<→o< A∋x) ⟩
osuc (& A)
<⟨ osucc lt ⟩
osuc (& B)
<⟨ osuc<nx ho< ⟩
next (odmax B)
∎ ) where open o≤-Reasoning O
ZFP : (A B : HOD) → HOD
ZFP A B = record { od = record { def = λ x → ord-pair x ∧ ((p : ord-pair x ) → odef A (pi1 p) ∧ odef B (pi2 p) )} ;
odmax = omax (next (odmax A)) (next (odmax B)) ; <odmax = λ {y} px → lemma y px }
where
lemma : (y : Ordinal) → ( ord-pair y ∧ ((p : ord-pair y) → odef A (pi1 p) ∧ odef B (pi2 p))) → y o< omax (next (odmax A)) (next (odmax B))
lemma y lt with proj1 lt
lemma p lt | pair x y with trio< (& A) (& B)
lemma p lt | pair x y | tri< a ¬b ¬c = ordtrans (ω-opair (A<Bnext a (subst (λ k → odef A k ) (sym &iso)
(proj1 (proj2 lt (pair x y))))) (lemma1 (proj2 (proj2 lt (pair x y))))) (omax-y _ _ ) where
lemma1 : odef B y → & (* y) o< next (HOD.odmax B)
lemma1 lt = x<nextA {B} (d→∋ B lt)
lemma p lt | pair x y | tri≈ ¬a b ¬c = ordtrans (ω-opair (x<nextA {A} (d→∋ A ((proj1 (proj2 lt (pair x y)))))) lemma2 ) (omax-x _ _ ) where
lemma2 : & (* y) o< next (HOD.odmax A)
lemma2 = ordtrans ( subst (λ k → & (* y) o< k ) (sym b) (c<→o< (d→∋ B ((proj2 (proj2 lt (pair x y))))))) ho<
lemma p lt | pair x y | tri> ¬a ¬b c = ordtrans (ω-opair (x<nextA {A} (d→∋ A ((proj1 (proj2 lt (pair x y))))))
(A<Bnext c (subst (λ k → odef B k ) (sym &iso) (proj2 (proj2 lt (pair x y)))))) (omax-x _ _ )
ZFP⊆⊗ : {A B : HOD} {x : Ordinal} → odef (ZFP A B) x → odef (A ⊗ B) x
ZFP⊆⊗ {A} {B} {px} ⟪ (pair x y) , p2 ⟫ = product→ (d→∋ A (proj1 (p2 (pair x y) ))) (d→∋ B (proj2 (p2 (pair x y) )))
-- axiom of choice required
-- ⊗⊆ZFP : {A B x : HOD} → ( A ⊗ B ) ∋ x → def ZFProduct (& x)
-- ⊗⊆ZFP {A} {B} {x} lt = subst (λ k → ord-pair (& k )) {!!} op-cons
| 38.981308
| 146
| 0.474706
|
1077065d9c430a8b22e67e5e8c48345f8b2a6239
| 2,414
|
agda
|
Agda
|
Data/FixedTree/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Data/FixedTree/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Data/FixedTree/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Data.FixedTree.Properties where
import Lvl
open import Data using (Unit ; <>)
open import Data.Boolean
open import Data.FixedTree
open import Data.Tuple.Raise
import Data.Tuple.Raiseᵣ.Functions as Raise
open import Functional as Fn
open import Logic.Propositional
open import Numeral.Finite
open import Numeral.Finite.Oper.Comparisons
open import Numeral.Natural
open import Type
private variable ℓ ℓᵢ ℓₗ ℓₙ ℓₒ : Lvl.Level
private variable n : ℕ
private variable N N₁ N₂ L T A B : Type{ℓ}
-- A tree is full when every node has no or all children.
data Full {L : Type{ℓₗ}}{N : Type{ℓₙ}}{n} : FixedTree(n) L N → Type{ℓₗ Lvl.⊔ ℓₙ} where
leaf : ∀{l} → Full(Leaf l)
single : ∀{a}{l} → Full(Node a (Raise.repeat(n) (Leaf l))) -- TODO: All the leaves should not be forced to all have the same data
step : ∀{a : N}{ca : N ^ n}{cc : ((FixedTree(n) L N) ^ n) ^ n} → (∀{i : 𝕟(n)} → Full(Node (Raise.index i ca) (Raise.index i cc))) → Full(Node a (Raise.map₂{n} Node ca cc))
-- step : ∀{a : T}{ca : T ^ n}{cc : (FixedTree(n)(T) ^ n) ^ n} → Raise.reduceOrᵣ{n}(_⨯_) Unit (Raise.map₂(Full ∘₂ Node) ca cc) → Full(Node a (Raise.map₂{n} Node ca cc))
-- A tree is perfect at depth `n` when all leaves are at height `n`.
-- In other words, a tree is perfect when all leaves are at the same height.
data Perfect {L : Type{ℓₗ}}{N : Type{ℓₙ}}{n} : FixedTree(n) L N → ℕ → Type{ℓₗ Lvl.⊔ ℓₙ} where
leaf : ∀{l} → Perfect(Leaf l)(𝟎)
step : ∀{a}{c}{h} → (∀{i : 𝕟(n)} → Perfect(Raise.index i c)(h)) → Perfect(Node a c)(𝐒(h))
data Complete {L : Type{ℓₗ}}{N : Type{ℓₙ}}{n} : FixedTree(n) L N → ℕ → Bool → Type{ℓₗ Lvl.⊔ ℓₙ} where
perfect-leaf : ∀{l} → Complete(Leaf l)(𝟎)(𝑇)
imperfect-leaf : ∀{l} → Complete(Leaf l)(𝐒(𝟎))(𝐹)
step : ∀{a}{c}{h}{t : 𝕟(n)} → (∀{i : 𝕟(n)} → Complete(Raise.index i c)(h)(i ≤? t)) → Complete(Node a c)(𝐒(h))(t ≤? maximum{n})
data DepthOrdered {L : Type{ℓₗ}}{N : Type{ℓₙ}} (_≤_ : N → N → Type{ℓₒ}) {n} : FixedTree(n) L N → Type{ℓₗ Lvl.⊔ ℓₙ Lvl.⊔ ℓₒ} where
leaf : ∀{l} → DepthOrdered(_≤_)(Leaf l)
step : ∀{p}{c : (FixedTree(n) L N) ^ n} → (∀{i : 𝕟(n)} → (\{(Leaf _) → Unit ; (Node a c) → (p ≤ a) ∧ DepthOrdered(_≤_)(Node a c)}) $ (Raise.index i c)) → DepthOrdered(_≤_)(Node p c)
Heap : ∀{L : Type{ℓₗ}}{N : Type{ℓₙ}} → (N → N → Type{ℓₒ}) → ∀{n} → FixedTree(n) L N → ℕ → Bool → Type
Heap(_≤_) tree height perfect = DepthOrdered(_≤_)(tree) ∧ Complete(tree)(height)(perfect)
| 54.863636
| 183
| 0.613919
|
dc2928fee3f2c57256a46b24f9eb4fc51a369d01
| 2,055
|
agda
|
Agda
|
src/Bi/BoxMp.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | 26
|
2015-08-31T09:49:52.000Z
|
2021-11-13T12:37:44.000Z
|
src/Bi/BoxMp.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
src/Bi/BoxMp.agda
|
mietek/formal-logic
|
2dd761bfa96ccda089888e8defa6814776fa2922
|
[
"X11"
] | null | null | null |
-- Minimal implicational modal logic, de Bruijn approach, initial encoding
module Bi.BoxMp where
open import Lib using (List; []; _,_; LMem; lzero; lsuc)
-- Types
infixr 0 _=>_
data Ty : Set where
UNIT : Ty
_=>_ : Ty -> Ty -> Ty
BOX : Ty -> Ty
-- Context and truth/validity judgements
Cx : Set
Cx = List Ty
isTrue : Ty -> Cx -> Set
isTrue a tc = LMem a tc
isValid : Ty -> Cx -> Set
isValid a vc = LMem a vc
-- Terms
module BoxMp where
infixl 1 _$_
infixr 0 lam=>_
data Tm (vc tc : Cx) : Ty -> Set where
var : forall {a} -> isTrue a tc -> Tm vc tc a
lam=>_ : forall {a b} -> Tm vc (tc , a) b -> Tm vc tc (a => b)
_$_ : forall {a b} -> Tm vc tc (a => b) -> Tm vc tc a -> Tm vc tc b
var# : forall {a} -> isValid a vc -> Tm vc tc a
box : forall {a} -> Tm vc [] a -> Tm vc tc (BOX a)
unbox' : forall {a b} -> Tm vc tc (BOX a) -> Tm (vc , a) tc b -> Tm vc tc b
syntax unbox' x' x = unbox x' => x
v0 : forall {vc tc a} -> Tm vc (tc , a) a
v0 = var lzero
v1 : forall {vc tc a b} -> Tm vc (tc , a , b) a
v1 = var (lsuc lzero)
v2 : forall {vc tc a b c} -> Tm vc (tc , a , b , c) a
v2 = var (lsuc (lsuc lzero))
v0# : forall {vc tc a} -> Tm (vc , a) tc a
v0# = var# lzero
v1# : forall {vc tc a b} -> Tm (vc , a , b) tc a
v1# = var# (lsuc lzero)
v2# : forall {vc tc a b c} -> Tm (vc , a , b , c) tc a
v2# = var# (lsuc (lsuc lzero))
Thm : Ty -> Set
Thm a = forall {vc tc} -> Tm vc tc a
open BoxMp public
-- Example theorems
rNec : forall {a} -> Thm a -> Thm (BOX a)
rNec x =
box x
aK : forall {a b} -> Thm (BOX (a => b) => BOX a => BOX b)
aK =
lam=>
lam=>
(unbox v1 =>
unbox v0 =>
box (v1# $ v0#))
aT : forall {a} -> Thm (BOX a => a)
aT =
lam=>
(unbox v0 => v0#)
a4 : forall {a} -> Thm (BOX a => BOX (BOX a))
a4 =
lam=>
(unbox v0 => box (box v0#))
t1 : forall {a} -> Thm (a => BOX (a => a))
t1 =
lam=> box (lam=> v0)
| 21.861702
| 81
| 0.487591
|
d01d8f32909e72df3ea23d1c33933750c88f0926
| 4,507
|
agda
|
Agda
|
Groups/FirstIsomorphismTheorem.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/FirstIsomorphismTheorem.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/FirstIsomorphismTheorem.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Setoids
open import LogicalFormulae
open import Sets.EquivalenceRelations
open import Groups.Homomorphisms.Definition
open import Groups.Homomorphisms.Lemmas
open import Groups.Isomorphisms.Definition
open import Groups.Subgroups.Definition
open import Groups.Lemmas
module Groups.FirstIsomorphismTheorem {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+G_ : A → A → A} {_+H_ : B → B → B} {G : Group S _+G_} {H : Group T _+H_} {f : A → B} (fHom : GroupHom G H f) where
open import Groups.Homomorphisms.Image fHom
open import Groups.Homomorphisms.Kernel fHom
open import Groups.Cosets G groupKernelIsSubgroup
open import Groups.QuotientGroup.Definition G fHom
open Setoid T
open Equivalence eq
open import Setoids.Subset T
groupFirstIsomorphismTheoremWellDefined : {x y : A} → groupKernelPred (Group.inverse G y +G x) → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive))
groupFirstIsomorphismTheoremWellDefined {x} {y} pr = transitive (symmetric (invTwice H _)) (transitive (symmetric u) (invTwice H _))
where
t : Setoid._∼_ T (Group.inverse H (f y) +H (f x)) (Group.0G H)
t = transitive (transitive (Group.+WellDefined H (symmetric (homRespectsInverse fHom)) reflexive) (symmetric (GroupHom.groupHom fHom))) pr
u : Setoid._∼_ T (Group.inverse H (Group.inverse H (f y))) (Group.inverse H (Group.inverse H (f x)))
u = inverseWellDefined H (transferToRight' H t)
groupFirstIsomorphismTheorem : GroupsIsomorphic (cosetGroup groupKernelIsNormalSubgroup) (subgroupIsGroup H imageGroupSubgroup)
GroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem x = f x , (x , reflexive)
GroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = GroupHom.groupHom fHom
GroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = groupFirstIsomorphismTheoremWellDefined {x} {y}
SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined
SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive fx=fy) (transitive (symmetric (GroupHom.groupHom fHom)) (transitive (GroupHom.wellDefined fHom (Group.invLeft G)) (imageOfIdentityIsIdentity fHom))))
SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) {b , (a , fa=b)} = a , fa=b
groupFirstIsomorphismTheoremWellDefined' : {x y : A} → f (x +G (Group.inverse G y)) ∼ Group.0G H → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive))
groupFirstIsomorphismTheoremWellDefined' {x} {y} pr = transferToRight H (transitive (symmetric (transitive (GroupHom.groupHom fHom) (Group.+WellDefined H reflexive (homRespectsInverse fHom)))) pr)
groupFirstIsomorphismTheorem' : GroupsIsomorphic (quotientGroupByHom) (subgroupIsGroup H imageGroupSubgroup)
GroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem' a = f a , (a , reflexive)
GroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = GroupHom.groupHom fHom
GroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = groupFirstIsomorphismTheoremWellDefined'
SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined' {x} {y}
SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive (homRespectsInverse fHom)) (transferToRight'' H fx=fy))
SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined'
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {b , (a , fa=b)} = a , fa=b
| 86.673077
| 354
| 0.786554
|
dfd228d98359e63e65f85540a38690c6aef9398d
| 4,721
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The lifting of a strict order to incorporate a new supremum
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Supremum
open import Relation.Binary
module Relation.Binary.Construct.Add.Supremum.Strict
{a r} {A : Set a} (_<_ : Rel A r) where
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
import Relation.Binary.PropositionalEquality as P
open import Relation.Nullary.Construct.Add.Supremum
import Relation.Binary.Construct.Add.Supremum.Equality as Equality
import Relation.Binary.Construct.Add.Supremum.NonStrict as NonStrict
------------------------------------------------------------------------
-- Definition
infix 4 _<⁺_
data _<⁺_ : Rel (A ⁺) (a ⊔ r) where
[_] : {k l : A} → k < l → [ k ] <⁺ [ l ]
[_]<⊤⁺ : (k : A) → [ k ] <⁺ ⊤⁺
------------------------------------------------------------------------
-- Relational properties
[<]-injective : ∀ {k l} → [ k ] <⁺ [ l ] → k < l
[<]-injective [ p ] = p
<⁺-asym : Asymmetric _<_ → Asymmetric _<⁺_
<⁺-asym <-asym [ p ] [ q ] = <-asym p q
<⁺-asym <-asym [ k ]<⊤⁺ ()
<⁺-trans : Transitive _<_ → Transitive _<⁺_
<⁺-trans <-trans [ p ] [ q ] = [ <-trans p q ]
<⁺-trans <-trans [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-dec : Decidable _<_ → Decidable _<⁺_
<⁺-dec _<?_ [ k ] [ l ] = Dec.map′ [_] [<]-injective (k <? l)
<⁺-dec _<?_ [ k ] ⊤⁺ = yes [ k ]<⊤⁺
<⁺-dec _<?_ ⊤⁺ [ l ] = no (λ ())
<⁺-dec _<?_ ⊤⁺ ⊤⁺ = no (λ ())
<⁺-irrelevant : Irrelevant _<_ → Irrelevant _<⁺_
<⁺-irrelevant <-irr [ p ] [ q ] = P.cong _ (<-irr p q)
<⁺-irrelevant <-irr [ k ]<⊤⁺ [ k ]<⊤⁺ = P.refl
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-cmp : Trichotomous _≈_ _<_ → Trichotomous _≈⁺_ _<⁺_
<⁺-cmp <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) ⊤⁺≈⊤⁺ (λ ())
<⁺-cmp <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺
<⁺-cmp <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ())
<⁺-cmp <-cmp [ k ] [ l ] with <-cmp k l
... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ [≈]-injective) (¬c ∘ [<]-injective)
... | tri≈ ¬a b ¬c = tri≈ (¬a ∘ [<]-injective) [ b ] (¬c ∘ [<]-injective)
... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ [≈]-injective) [ c ]
<⁺-irrefl : Irreflexive _≈_ _<_ → Irreflexive _≈⁺_ _<⁺_
<⁺-irrefl <-irrefl [ p ] [ q ] = <-irrefl p q
<⁺-irrefl <-irrefl ⊤⁺≈⊤⁺ ()
<⁺-respˡ-≈⁺ : _<_ Respectsˡ _≈_ → _<⁺_ Respectsˡ _≈⁺_
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] [ q ] = [ <-respˡ-≈ p q ]
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] ([ l ]<⊤⁺) = [ _ ]<⊤⁺
<⁺-respˡ-≈⁺ <-respˡ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-respʳ-≈⁺ : _<_ Respectsʳ _≈_ → _<⁺_ Respectsʳ _≈⁺_
<⁺-respʳ-≈⁺ <-respʳ-≈ [ p ] [ q ] = [ <-respʳ-≈ p q ]
<⁺-respʳ-≈⁺ <-respʳ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-resp-≈⁺ : _<_ Respects₂ _≈_ → _<⁺_ Respects₂ _≈⁺_
<⁺-resp-≈⁺ = map <⁺-respʳ-≈⁺ <⁺-respˡ-≈⁺
module _ {r} {_≤_ : Rel A r} where
open NonStrict _≤_
<⁺-transʳ : Trans _≤_ _<_ _<_ → Trans _≤⁺_ _<⁺_ _<⁺_
<⁺-transʳ <-transʳ [ p ] [ q ] = [ <-transʳ p q ]
<⁺-transʳ <-transʳ [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-transˡ : Trans _<_ _≤_ _<_ → Trans _<⁺_ _≤⁺_ _<⁺_
<⁺-transˡ <-transˡ [ p ] [ q ] = [ <-transˡ p q ]
<⁺-transˡ <-transˡ [ p ] ([ _ ] ≤⊤⁺) = [ _ ]<⊤⁺
<⁺-transˡ <-transˡ [ k ]<⊤⁺ (⊤⁺ ≤⊤⁺) = [ k ]<⊤⁺
------------------------------------------------------------------------
-- Structures
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ →
IsStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isStrictPartialOrder strict = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; irrefl = <⁺-irrefl irrefl
; trans = <⁺-trans trans
; <-resp-≈ = <⁺-resp-≈⁺ <-resp-≈
} where open IsStrictPartialOrder strict
<⁺-isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ →
IsDecStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isDecStrictPartialOrder dectot = record
{ isStrictPartialOrder = <⁺-isStrictPartialOrder isStrictPartialOrder
; _≟_ = ≈⁺-dec _≟_
; _<?_ = <⁺-dec _<?_
} where open IsDecStrictPartialOrder dectot
<⁺-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ →
IsStrictTotalOrder _≈⁺_ _<⁺_
<⁺-isStrictTotalOrder strictot = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; trans = <⁺-trans trans
; compare = <⁺-cmp compare
} where open IsStrictTotalOrder strictot
| 35.496241
| 75
| 0.481042
|
20312437129636aaf746bd044c7c4e354bbead92
| 1,051
|
agda
|
Agda
|
src/Categories/Category/Exact.agda
|
Trebor-Huang/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 5
|
2019-05-21T17:07:19.000Z
|
2019-05-22T03:54:24.000Z
|
src/Categories/Category/Exact.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Exact.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
-- Exact category (https://ncatlab.org/nlab/show/exact+category)
-- is a regular category
-- in which every internal equivalence is a kernel pair
module Categories.Category.Exact where
open import Level
open import Categories.Category.Core
open import Categories.Diagram.Pullback
open import Categories.Category.Cocartesian
open import Categories.Object.Coproduct
open import Categories.Morphism
open import Categories.Diagram.Coequalizer
open import Categories.Diagram.KernelPair
open import Categories.Category.Regular
open import Categories.Morphism.Regular
open import Categories.Object.InternalRelation
record Exact {o ℓ e : Level} (𝒞 : Category o ℓ e) : Set (suc (o ⊔ ℓ ⊔ e)) where
open Category 𝒞
open Pullback
open Coequalizer
open Equivalence
field
regular : Regular 𝒞
quotient : ∀ {X : Obj} (E : Equivalence 𝒞 X) → Coequalizer 𝒞 (R.p₁ E) (R.p₂ E)
effective : ∀ {X : Obj} (E : Equivalence 𝒞 X) → IsPullback 𝒞 (R.p₁ E) (R.p₂ E)
(arr (quotient E)) (arr (quotient E))
| 30.028571
| 84
| 0.733587
|
0eeb700e339592853af4c1c387fd6ae464451274
| 222
|
agda
|
Agda
|
test/Fail/MultipleFrontEnds.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/MultipleFrontEnds.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/MultipleFrontEnds.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2020-12-15, re PR #5020
-- Test error message "Must not specify multiple frontends"
-- See respective .flags file
-- Expected error:
-- Must not specify multiple frontends (--interaction, --interaction-json)
| 27.75
| 74
| 0.72973
|
df85c29c5187ddd884cb638d816e4787448442fc
| 5,325
|
agda
|
Agda
|
Definition/Conversion/Weakening.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Weakening.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Weakening.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Weakening where
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Typed.Consequences.Syntactic
open import Definition.Conversion
open import Definition.Conversion.Soundness
import Tools.PropositionalEquality as PE
open import Tools.Product
mutual
-- Weakening of algorithmic equality of neutrals.
wk~↑ : ∀ {ρ t u A Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ t ~ u ↑ A
→ Δ ⊢ U.wk ρ t ~ U.wk ρ u ↑ U.wk ρ A
wk~↑ {ρ} [ρ] ⊢Δ (var-refl x₁ x≡y) = var-refl (wkTerm [ρ] ⊢Δ x₁) (PE.cong (wkVar ρ) x≡y)
wk~↑ ρ ⊢Δ (app-cong {G = G} t~u x) =
PE.subst (λ x → _ ⊢ _ ~ _ ↑ x) (PE.sym (wk-β G))
(app-cong (wk~↓ ρ ⊢Δ t~u) (wkConv↑Term ρ ⊢Δ x))
wk~↑ ρ ⊢Δ (fst-cong p~r) =
fst-cong (wk~↓ ρ ⊢Δ p~r)
wk~↑ ρ ⊢Δ (snd-cong {G = G} p~r) =
PE.subst (λ x → _ ⊢ _ ~ _ ↑ x)
(PE.sym (wk-β G))
(snd-cong (wk~↓ ρ ⊢Δ p~r))
wk~↑ {ρ} {Δ = Δ} [ρ] ⊢Δ (natrec-cong {k} {l} {h} {g} {a₀} {b₀} {F} {G} x x₁ x₂ t~u) =
PE.subst (λ x → _ ⊢ U.wk ρ (natrec F a₀ h k) ~ _ ↑ x) (PE.sym (wk-β F))
(natrec-cong (wkConv↑ (lift [ρ]) (⊢Δ ∙ ℕⱼ ⊢Δ) x)
(PE.subst (λ x → _ ⊢ _ [conv↑] _ ∷ x) (wk-β F)
(wkConv↑Term [ρ] ⊢Δ x₁))
(PE.subst (λ x → Δ ⊢ U.wk ρ h [conv↑] U.wk ρ g ∷ x)
(wk-β-natrec _ F) (wkConv↑Term [ρ] ⊢Δ x₂))
(wk~↓ [ρ] ⊢Δ t~u))
wk~↑ {ρ} {Δ = Δ} [ρ] ⊢Δ (Emptyrec-cong {k} {l} {F} {G} x t~u) =
Emptyrec-cong (wkConv↑ [ρ] ⊢Δ x) (wk~↓ [ρ] ⊢Δ t~u)
-- Weakening of algorithmic equality of neutrals in WHNF.
wk~↓ : ∀ {ρ t u A Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ t ~ u ↓ A
→ Δ ⊢ U.wk ρ t ~ U.wk ρ u ↓ U.wk ρ A
wk~↓ {ρ} [ρ] ⊢Δ ([~] A₁ D whnfA k~l) =
[~] (U.wk ρ A₁) (wkRed* [ρ] ⊢Δ D) (wkWhnf ρ whnfA) (wk~↑ [ρ] ⊢Δ k~l)
-- Weakening of algorithmic equality of types.
wkConv↑ : ∀ {ρ A B Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ A [conv↑] B
→ Δ ⊢ U.wk ρ A [conv↑] U.wk ρ B
wkConv↑ {ρ} [ρ] ⊢Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) =
[↑] (U.wk ρ A′) (U.wk ρ B′) (wkRed* [ρ] ⊢Δ D) (wkRed* [ρ] ⊢Δ D′)
(wkWhnf ρ whnfA′) (wkWhnf ρ whnfB′) (wkConv↓ [ρ] ⊢Δ A′<>B′)
-- Weakening of algorithmic equality of types in WHNF.
wkConv↓ : ∀ {ρ A B Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ A [conv↓] B
→ Δ ⊢ U.wk ρ A [conv↓] U.wk ρ B
wkConv↓ ρ ⊢Δ (U-refl x) = U-refl ⊢Δ
wkConv↓ ρ ⊢Δ (ℕ-refl x) = ℕ-refl ⊢Δ
wkConv↓ ρ ⊢Δ (Empty-refl x) = Empty-refl ⊢Δ
wkConv↓ ρ ⊢Δ (Unit-refl x) = Unit-refl ⊢Δ
wkConv↓ ρ ⊢Δ (ne x) = ne (wk~↓ ρ ⊢Δ x)
wkConv↓ ρ ⊢Δ (Π-cong x A<>B A<>B₁) =
let ⊢ρF = wk ρ ⊢Δ x
in Π-cong ⊢ρF (wkConv↑ ρ ⊢Δ A<>B) (wkConv↑ (lift ρ) (⊢Δ ∙ ⊢ρF) A<>B₁)
wkConv↓ ρ ⊢Δ (Σ-cong x A<>B A<>B₁) =
let ⊢ρF = wk ρ ⊢Δ x
in Σ-cong ⊢ρF (wkConv↑ ρ ⊢Δ A<>B) (wkConv↑ (lift ρ) (⊢Δ ∙ ⊢ρF) A<>B₁)
-- Weakening of algorithmic equality of terms.
wkConv↑Term : ∀ {ρ t u A Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ t [conv↑] u ∷ A
→ Δ ⊢ U.wk ρ t [conv↑] U.wk ρ u ∷ U.wk ρ A
wkConv↑Term {ρ} [ρ] ⊢Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) =
[↑]ₜ (U.wk ρ B) (U.wk ρ t′) (U.wk ρ u′)
(wkRed* [ρ] ⊢Δ D) (wkRed*Term [ρ] ⊢Δ d) (wkRed*Term [ρ] ⊢Δ d′)
(wkWhnf ρ whnfB) (wkWhnf ρ whnft′) (wkWhnf ρ whnfu′)
(wkConv↓Term [ρ] ⊢Δ t<>u)
-- Weakening of algorithmic equality of terms in WHNF.
wkConv↓Term : ∀ {ρ t u A Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ
→ Γ ⊢ t [conv↓] u ∷ A
→ Δ ⊢ U.wk ρ t [conv↓] U.wk ρ u ∷ U.wk ρ A
wkConv↓Term ρ ⊢Δ (ℕ-ins x) =
ℕ-ins (wk~↓ ρ ⊢Δ x)
wkConv↓Term ρ ⊢Δ (Empty-ins x) =
Empty-ins (wk~↓ ρ ⊢Δ x)
wkConv↓Term ρ ⊢Δ (Unit-ins x) =
Unit-ins (wk~↓ ρ ⊢Δ x)
wkConv↓Term {ρ} [ρ] ⊢Δ (ne-ins t u x x₁) =
ne-ins (wkTerm [ρ] ⊢Δ t) (wkTerm [ρ] ⊢Δ u) (wkNeutral ρ x) (wk~↓ [ρ] ⊢Δ x₁)
wkConv↓Term ρ ⊢Δ (univ x x₁ x₂) =
univ (wkTerm ρ ⊢Δ x) (wkTerm ρ ⊢Δ x₁) (wkConv↓ ρ ⊢Δ x₂)
wkConv↓Term ρ ⊢Δ (zero-refl x) = zero-refl ⊢Δ
wkConv↓Term ρ ⊢Δ (suc-cong t<>u) = suc-cong (wkConv↑Term ρ ⊢Δ t<>u)
wkConv↓Term {ρ} {Δ = Δ} [ρ] ⊢Δ (η-eq {F = F} {G = G} x₁ x₂ y y₁ t<>u) =
let ⊢F , _ = syntacticΠ (syntacticTerm x₁)
⊢ρF = wk [ρ] ⊢Δ ⊢F
in η-eq (wkTerm [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂)
(wkFunction ρ y) (wkFunction ρ y₁)
(PE.subst₃ (λ x y z → Δ ∙ U.wk ρ F ⊢ x [conv↑] y ∷ z)
(PE.cong₂ _∘_ (PE.sym (wk1-wk≡lift-wk1 _ _)) PE.refl)
(PE.cong₂ _∘_ (PE.sym (wk1-wk≡lift-wk1 _ _)) PE.refl)
PE.refl
(wkConv↑Term (lift [ρ]) (⊢Δ ∙ ⊢ρF) t<>u))
wkConv↓Term {ρ} [ρ] ⊢Δ (Σ-η {G = G} ⊢p ⊢r pProd rProd fstConv sndConv) =
Σ-η (wkTerm [ρ] ⊢Δ ⊢p)
(wkTerm [ρ] ⊢Δ ⊢r)
(wkProduct ρ pProd)
(wkProduct ρ rProd)
(wkConv↑Term [ρ] ⊢Δ fstConv)
(PE.subst (λ x → _ ⊢ _ [conv↑] _ ∷ x)
(wk-β G)
(wkConv↑Term [ρ] ⊢Δ sndConv))
wkConv↓Term {ρ} [ρ] ⊢Δ (η-unit [t] [u] tWhnf uWhnf) =
η-unit (wkTerm [ρ] ⊢Δ [t]) (wkTerm [ρ] ⊢Δ [u])
(wkWhnf ρ tWhnf) (wkWhnf ρ uWhnf)
| 44.008264
| 89
| 0.477183
|
3962c9998a7498c086f6f5eb260a88b09f310a3b
| 9,707
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Categorical.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Categorical.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Categorical.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- A categorical view of List
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Categorical where
open import Category.Functor
open import Category.Applicative
open import Category.Monad
open import Data.Bool.Base using (false; true)
open import Data.List.Base
open import Data.List.Properties
open import Function
open import Relation.Binary.PropositionalEquality as P
using (_≡_; _≢_; _≗_; refl)
open P.≡-Reasoning
------------------------------------------------------------------------
-- List applicative functor
functor : ∀ {ℓ} → RawFunctor {ℓ} List
functor = record { _<$>_ = map }
applicative : ∀ {ℓ} → RawApplicative {ℓ} List
applicative = record
{ pure = [_]
; _⊛_ = λ fs as → concatMap (λ f → map f as) fs
}
applicativeZero : ∀ {ℓ} → RawApplicativeZero {ℓ} List
applicativeZero = record
{ applicative = applicative
; ∅ = []
}
alternative : ∀ {ℓ} → RawAlternative {ℓ} List
alternative = record
{ applicativeZero = applicativeZero
; _∣_ = _++_
}
------------------------------------------------------------------------
-- List monad
monad : ∀ {ℓ} → RawMonad {ℓ} List
monad = record
{ return = [_]
; _>>=_ = flip concatMap
}
monadZero : ∀ {ℓ} → RawMonadZero {ℓ} List
monadZero = record
{ monad = monad
; applicativeZero = applicativeZero
}
monadPlus : ∀ {ℓ} → RawMonadPlus {ℓ} List
monadPlus = record
{ monad = monad
; alternative = alternative
}
------------------------------------------------------------------------
-- Get access to other monadic functions
module TraversableA {f F} (App : RawApplicative {f} F) where
open RawApplicative App
sequenceA : ∀ {A} → List (F A) → F (List A)
sequenceA [] = pure []
sequenceA (x ∷ xs) = _∷_ <$> x ⊛ sequenceA xs
mapA : ∀ {a} {A : Set a} {B} → (A → F B) → List A → F (List B)
mapA f = sequenceA ∘ map f
forA : ∀ {a} {A : Set a} {B} → List A → (A → F B) → F (List B)
forA = flip mapA
module TraversableM {m M} (Mon : RawMonad {m} M) where
open RawMonad Mon
open TraversableA rawIApplicative public
renaming
( sequenceA to sequenceM
; mapA to mapM
; forA to forM
)
------------------------------------------------------------------------
-- List monad transformer
monadT : ∀ {ℓ} → RawMonadT {ℓ} (_∘′ List)
monadT M = record
{ return = pure ∘′ [_]
; _>>=_ = λ mas f → mas >>= λ as → concat <$> mapM f as
} where open RawMonad M; open TraversableM M
------------------------------------------------------------------------
-- The list monad.
private
open module LMP {ℓ} = RawMonadPlus (monadPlus {ℓ = ℓ})
module MonadProperties where
left-identity : ∀ {ℓ} {A B : Set ℓ} (x : A) (f : A → List B) →
(return x >>= f) ≡ f x
left-identity x f = ++-identityʳ (f x)
right-identity : ∀ {ℓ} {A : Set ℓ} (xs : List A) →
(xs >>= return) ≡ xs
right-identity [] = refl
right-identity (x ∷ xs) = P.cong (x ∷_) (right-identity xs)
left-zero : ∀ {ℓ} {A B : Set ℓ} (f : A → List B) → (∅ >>= f) ≡ ∅
left-zero f = refl
right-zero : ∀ {ℓ} {A B : Set ℓ} (xs : List A) →
(xs >>= const ∅) ≡ ∅ {A = B}
right-zero [] = refl
right-zero (x ∷ xs) = right-zero xs
private
not-left-distributive :
let xs = true ∷ false ∷ []; f = return; g = return in
(xs >>= λ x → f x ∣ g x) ≢ ((xs >>= f) ∣ (xs >>= g))
not-left-distributive ()
right-distributive : ∀ {ℓ} {A B : Set ℓ}
(xs ys : List A) (f : A → List B) →
(xs ∣ ys >>= f) ≡ ((xs >>= f) ∣ (ys >>= f))
right-distributive [] ys f = refl
right-distributive (x ∷ xs) ys f = begin
f x ∣ (xs ∣ ys >>= f) ≡⟨ P.cong (f x ∣_) $ right-distributive xs ys f ⟩
f x ∣ ((xs >>= f) ∣ (ys >>= f)) ≡⟨ P.sym $ ++-assoc (f x) _ _ ⟩
((f x ∣ (xs >>= f)) ∣ (ys >>= f)) ∎
associative : ∀ {ℓ} {A B C : Set ℓ}
(xs : List A) (f : A → List B) (g : B → List C) →
(xs >>= λ x → f x >>= g) ≡ (xs >>= f >>= g)
associative [] f g = refl
associative (x ∷ xs) f g = begin
(f x >>= g) ∣ (xs >>= λ x → f x >>= g) ≡⟨ P.cong ((f x >>= g) ∣_) $ associative xs f g ⟩
(f x >>= g) ∣ (xs >>= f >>= g) ≡⟨ P.sym $ right-distributive (f x) (xs >>= f) g ⟩
(f x ∣ (xs >>= f) >>= g) ∎
cong : ∀ {ℓ} {A B : Set ℓ} {xs₁ xs₂} {f₁ f₂ : A → List B} →
xs₁ ≡ xs₂ → f₁ ≗ f₂ → (xs₁ >>= f₁) ≡ (xs₂ >>= f₂)
cong {xs₁ = xs} refl f₁≗f₂ = P.cong concat (map-cong f₁≗f₂ xs)
------------------------------------------------------------------------
-- The applicative functor derived from the list monad.
-- Note that these proofs (almost) show that RawIMonad.rawIApplicative
-- is correctly defined. The proofs can be reused if proof components
-- are ever added to RawIMonad and RawIApplicative.
module Applicative where
private
module MP = MonadProperties
-- A variant of flip map.
pam : ∀ {ℓ} {A B : Set ℓ} → List A → (A → B) → List B
pam xs f = xs >>= return ∘ f
-- ∅ is a left zero for _⊛_.
left-zero : ∀ {ℓ} {A B : Set ℓ} (xs : List A) → (∅ ⊛ xs) ≡ ∅ {A = B}
left-zero xs = begin
∅ ⊛ xs ≡⟨⟩
(∅ >>= pam xs) ≡⟨ MonadProperties.left-zero (pam xs) ⟩
∅ ∎
-- ∅ is a right zero for _⊛_.
right-zero : ∀ {ℓ} {A B : Set ℓ} (fs : List (A → B)) → (fs ⊛ ∅) ≡ ∅
right-zero {ℓ} fs = begin
fs ⊛ ∅ ≡⟨⟩
(fs >>= pam ∅) ≡⟨ (MP.cong (refl {x = fs}) λ f →
MP.left-zero (return ∘ f)) ⟩
(fs >>= λ _ → ∅) ≡⟨ MP.right-zero fs ⟩
∅ ∎
-- _⊛_ distributes over _∣_ from the right.
right-distributive : ∀ {ℓ} {A B : Set ℓ} (fs₁ fs₂ : List (A → B)) xs →
((fs₁ ∣ fs₂) ⊛ xs) ≡ (fs₁ ⊛ xs ∣ fs₂ ⊛ xs)
right-distributive fs₁ fs₂ xs = begin
(fs₁ ∣ fs₂) ⊛ xs ≡⟨⟩
(fs₁ ∣ fs₂ >>= pam xs) ≡⟨ MonadProperties.right-distributive fs₁ fs₂ (pam xs) ⟩
(fs₁ >>= pam xs) ∣ (fs₂ >>= pam xs) ≡⟨⟩
(fs₁ ⊛ xs ∣ fs₂ ⊛ xs) ∎
-- _⊛_ does not distribute over _∣_ from the left.
private
not-left-distributive :
let fs = id ∷ id ∷ []; xs₁ = true ∷ []; xs₂ = true ∷ false ∷ [] in
(fs ⊛ (xs₁ ∣ xs₂)) ≢ (fs ⊛ xs₁ ∣ fs ⊛ xs₂)
not-left-distributive ()
-- Applicative functor laws.
identity : ∀ {a} {A : Set a} (xs : List A) → (return id ⊛ xs) ≡ xs
identity xs = begin
return id ⊛ xs ≡⟨⟩
(return id >>= pam xs) ≡⟨ MonadProperties.left-identity id (pam xs) ⟩
(xs >>= return) ≡⟨ MonadProperties.right-identity xs ⟩
xs ∎
private
pam-lemma : ∀ {ℓ} {A B C : Set ℓ}
(xs : List A) (f : A → B) (fs : B → List C) →
(pam xs f >>= fs) ≡ (xs >>= λ x → fs (f x))
pam-lemma xs f fs = begin
(pam xs f >>= fs) ≡⟨ P.sym $ MP.associative xs (return ∘ f) fs ⟩
(xs >>= λ x → return (f x) >>= fs) ≡⟨ MP.cong (refl {x = xs}) (λ x → MP.left-identity (f x) fs) ⟩
(xs >>= λ x → fs (f x)) ∎
composition : ∀ {ℓ} {A B C : Set ℓ}
(fs : List (B → C)) (gs : List (A → B)) xs →
(return _∘′_ ⊛ fs ⊛ gs ⊛ xs) ≡ (fs ⊛ (gs ⊛ xs))
composition {ℓ} fs gs xs = begin
return _∘′_ ⊛ fs ⊛ gs ⊛ xs ≡⟨⟩
(return _∘′_ >>= pam fs >>= pam gs >>= pam xs) ≡⟨ MP.cong (MP.cong (MP.left-identity _∘′_ (pam fs))
(λ f → refl {x = pam gs f}))
(λ fg → refl {x = pam xs fg}) ⟩
(pam fs _∘′_ >>= pam gs >>= pam xs) ≡⟨ MP.cong (pam-lemma fs _∘′_ (pam gs)) (λ _ → refl) ⟩
((fs >>= λ f → pam gs (f ∘′_)) >>= pam xs) ≡⟨ P.sym $ MP.associative fs (λ f → pam gs (_∘′_ f)) (pam xs) ⟩
(fs >>= λ f → pam gs (f ∘′_) >>= pam xs) ≡⟨ (MP.cong (refl {x = fs}) λ f →
pam-lemma gs (f ∘′_) (pam xs)) ⟩
(fs >>= λ f → gs >>= λ g → pam xs (f ∘′ g)) ≡⟨ (MP.cong (refl {x = fs}) λ f →
MP.cong (refl {x = gs}) λ g →
P.sym $ pam-lemma xs g (return ∘ f)) ⟩
(fs >>= λ f → gs >>= λ g → pam (pam xs g) f) ≡⟨ (MP.cong (refl {x = fs}) λ f →
MP.associative gs (pam xs) (return ∘ f)) ⟩
(fs >>= pam (gs >>= pam xs)) ≡⟨⟩
fs ⊛ (gs ⊛ xs) ∎
homomorphism : ∀ {ℓ} {A B : Set ℓ} (f : A → B) x →
(return f ⊛ return x) ≡ return (f x)
homomorphism f x = begin
return f ⊛ return x ≡⟨⟩
(return f >>= pam (return x)) ≡⟨ MP.left-identity f (pam (return x)) ⟩
pam (return x) f ≡⟨ MP.left-identity x (return ∘ f) ⟩
return (f x) ∎
interchange : ∀ {ℓ} {A B : Set ℓ} (fs : List (A → B)) {x} →
(fs ⊛ return x) ≡ (return (λ f → f x) ⊛ fs)
interchange fs {x} = begin
fs ⊛ return x ≡⟨⟩
(fs >>= pam (return x)) ≡⟨ (MP.cong (refl {x = fs}) λ f →
MP.left-identity x (return ∘ f)) ⟩
(fs >>= λ f → return (f x)) ≡⟨⟩
(pam fs (λ f → f x)) ≡⟨ P.sym $ MP.left-identity (λ f → f x) (pam fs) ⟩
(return (λ f → f x) >>= pam fs) ≡⟨⟩
return (λ f → f x) ⊛ fs ∎
| 35.951852
| 115
| 0.435974
|
18592afb355e366aded400b98ebf16b5bf5e8b24
| 122
|
agda
|
Agda
|
04-cubical-type-theory/material/ExerciseSession3.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
04-cubical-type-theory/material/ExerciseSession3.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
04-cubical-type-theory/material/ExerciseSession3.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
module Exercises where
open import Part2
open import Part3
open import Part4
open import Part5
| 15.25
| 25
| 0.770492
|
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.