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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1800372abcfb45f42dfad6634f50b46407ab05e1
| 1,207
|
agda
|
Agda
|
test/Succeed/Issue3176.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3176.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3176.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2018-08-14, issue #3176, reported by identicalsnowflake
--
-- Absurd lambdas should be equal.
-- In this case, they were only considered equal during give, but not upon reload.
-- {-# OPTIONS -v tc.meta.occurs:35 #-}
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Builtin.Equality
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
∃ : ∀ {A : Set} → (A → Set) → Set
∃ = Σ _
_×_ : ∀ _ _ → _
_×_ a b = ∃ λ (_ : a) → b
record Fin (n : ℕ) : Set where
field
m : ℕ
.p : ∃ λ k → (ℕ.suc k + m) ≡ n
module _ (n : ℕ) where
data S : Set where
V : S
K : Fin n → S
_X_ : S → S → S
[_] : ∀ {n} → S n → (Fin n → Set) → Set → Set
[ V ] k A = A
[ K i ] k _ = k i
[ s₁ X s₂ ] k A = [ s₁ ] k A × [ s₂ ] k A
postulate
ANY : ∀ {A : Set} → A
_<*>_ : ∀ {s : S 0} {A₁ A₂}
→ [ s ] (λ ()) (A₁ → A₂)
→ [ s ] (λ ()) A₁
→ [ s ] (λ ()) A₂
_<*>_ {s₁ X s₂} {A₁} {A₂} (f , _) (x , _) =
let v : [ s₁ ] (λ ()) A₂
v = _<*>_ {s = s₁} {A₁ = A₁} {A₂ = A₂} f x
in
ANY -- {A = [ s₁ ] (λ ()) A₂ × [ s₂ ] (λ ()) A₂}
_<*>_ {s = s} f x = ANY -- {A = [ s ] (λ ()) _ }
-- Should succeed.
| 21.175439
| 82
| 0.46976
|
d0ef874b65a37ec73bb7395508fbed4762b9c004
| 609
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Relation/Subset/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Relation/Subset/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Relation/Subset/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Subset.Setoid.Properties directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Subset.Setoid.Properties where
open import Data.List.Relation.Binary.Subset.Setoid.Properties public
{-# WARNING_ON_IMPORT
"Data.List.Relation.Subset.Setoid.Properties was deprecated in v1.0.
Use Data.List.Relation.Binary.Subset.Setoid.Properties instead."
#-}
| 33.833333
| 72
| 0.591133
|
cbc568e0dc48a1a4c67220165c6e4b77e5d5ceab
| 38,750
|
agda
|
Agda
|
archive/agda-1/MGU.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-1/MGU.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-1/MGU.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module MGU where
--open import Agda.Builtin.Nat using () renaming (Nat to ℕ)
open import Agda.Primitive
open import Agda.Builtin.Equality
open import Prelude.Product using (Σ; _,_; fst; snd; _×_; curry; uncurry)
open import Prelude.Equality using (_≡_; eqReasoningStep; _∎; sym; trans; cong)
open import Prelude.Function using (_∘_)
open import Prelude.Empty using (⊥)
open import Prelude.Sum using () renaming (Either to _⊎_)
open import Prelude.Maybe using (Maybe; just; nothing)
∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b)
∃ = Σ _
open import Prelude using (_$_)
open import Relation.Binary
open import Algebra
open import Category.Applicative.Predicate
open import Prolegomenon
--record IsTermSubstitution {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
record IsSetoid {c} {ℓ} {Carrier : Set c} (_≈_ : Rel Carrier ℓ) : Set (c ⊔ ℓ) where
field
isEquivalence : IsEquivalence _≈_
setoid : Setoid c ℓ
setoid = record { Carrier = Carrier ; _≈_ = _≈_ ; isEquivalence = isEquivalence }
open Setoid setoid public
open IsSetoid ⦃ … ⦄
open import Algebra.Structures
--open IsMonoid ⦃ … ⦄
record IsTermSubstitution {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
(Term : Setoid ℓᵗ ℓ⁼ᵗ)
(Substitution : Monoid ℓˢ ℓ⁼ˢ)
: Set (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ) where
open Setoid Term public using () renaming
(Carrier to T
;_≈_ to _=ᵗ_)
open Monoid Substitution public using () renaming
(Carrier to S
;_≈_ to _=ˢ_
;_∙_ to _∙_
;ε to ∅)
infixl 6 _▹_
field
_▹_ : T → S → T
▹-=ˢ-to-ᵗ : ∀ {s s′} → s =ˢ s′ → (t : T) → (t ▹ s) =ᵗ (t ▹ s′)
▹-=ᵗ-to-=ˢ : ∀ {s s′} → ((t : T) → t ▹ s =ᵗ t ▹ s′) → s =ˢ s′
▹-extracts-∙ : (t : T) (s₁ s₂ : S) → t ▹ s₁ ∙ s₂ =ᵗ t ▹ s₁ ▹ s₂
open IsTermSubstitution ⦃ … ⦄
record TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
field
Term : Setoid ℓᵗ ℓ⁼ᵗ
Substitution : Monoid ℓˢ ℓ⁼ˢ
isTermSubstitution : IsTermSubstitution Term Substitution
open IsTermSubstitution isTermSubstitution public
open import Relation.Unary
import Relation.Binary.Indexed as I
open import Relation.Nullary
record 𝓩ero (A : Set) : Set where
field
𝓩 : A
open 𝓩ero ⦃ … ⦄
instance 𝓩eroLevel : 𝓩ero Level
𝓩ero.𝓩 𝓩eroLevel = lzero
open import Agda.Builtin.Nat
instance 𝓩eroNat : 𝓩ero Nat
𝓩ero.𝓩 𝓩eroNat = zero
record IsSeparableInto {sx s x} (SX : Set sx) (S : Set s) (X : Set x) : Set (s ⊔ x ⊔ sx) where
field
break : SX → S × X
combine : S → X → SX
iso : ∀ sx → uncurry combine (break sx) ≡ sx
record Separableoid sx s x : Set (lsuc (sx ⊔ s ⊔ x)) where
field
SX : Set sx
S : Set s
X : Set x
separable : IsSeparableInto SX S X
_AND_ = _×_
NOT_ = ¬_
_NAND_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_NAND_ A B = (NOT A) × (NOT B)
_OR_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_OR_ A B = NOT (A NAND B)
_XOR_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_XOR_ A B = (A OR B) AND (NOT (A AND B))
asdf : (A B : Set) → Dec A → A XOR B → Prelude.Either A (¬ ¬ B)
asdf A B x (¬[¬A׬B] , ¬[A×B]) with x
asdf A B x (¬[¬A׬B] , ¬[A×B]) | yes p = _⊎_.left p
asdf A B x (¬[¬A׬B] , ¬[A×B]) | no ¬p = _⊎_.right (λ {x₁ → ¬[¬A׬B] (¬p , x₁)})
import Data.Empty
frf : Dec Data.Empty.⊥
frf = no (λ x → x)
{-
record LAW (A : Set) (B : Set) (E : EITHER A B) : Set where
open import Data.Empty
open EITHER E
¬A→B : ¬ A → ¬ ¬ B
¬A→B ¬a ¬b with e
... | ei = ei (λ {(a , ¬b) → ¬a a})
-}
record FiniteMembership : Set where
open import Data.List
module _ {ℓ} {A : Set ℓ} where
listMembers : List A → Pred A ℓ
listMembers [] x₁ = Prelude.⊥′
listMembers (x ∷ xs) y = (y ≡ x) OR (listMembers xs y)
_∈L_ : A → List A → Set ℓ
x ∈L xs = x ∈ listMembers xs
data _inL_ (y : A) : List A → Set where
[] : ∀ {xs} → y inL (y ∷ xs)
_∷_ : ∀ {x xs} → (ys : y inL xs) → y inL (x ∷ xs)
ListMembers : List A → Pred A lzero
ListMembers xs = _inL xs
_∈LL_ : A → List A → Set
x ∈LL xs = x ∈ ListMembers xs
toLL : (y : A) (xs : List A) → y ∈L xs → y ∈LL xs
toLL y [] x = Prelude.⊥′-elim x
toLL y (x ∷ xs) y∈Lxxs = {!!} -- toLL y xs x₁
record Boolean (True : Set) (False : Set) : Set where
field
bool : True XOR False
{-
record L {ℓ} (A : Set ℓ) : Set ℓ where
inductive
field
EMPTY : Set
empty : L A
head : A XOR ⊥
tail : {!!}
-}
{-
head : A XOR Prelude.⊥
tail :
empty : Prelude.⊥′
list : EITHER Prelude.⊥′ (L A)
-}
record FreeVariableoid ℓᵛ∈ᵗ ℓᵛ∈ˢ⁺ ℓᵛ∈ˢ⁻ ℓᵛ ℓ⁼ᵛ ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵛ∈ᵗ ⊔ ℓᵛ∈ˢ⁺ ⊔ ℓᵛ∈ˢ⁻ ⊔ ℓᵛ ⊔ ℓ⁼ᵛ ⊔ ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
field
Variable : Setoid ℓᵛ ℓ⁼ᵛ
TermStructure : Set
open Setoid Variable public using () renaming
(Carrier to V
;_≈_ to _=ᵛ_)
field
termVariables : T → Pred V ℓᵛ∈ᵗ
termStructure : T → Set
substitutionSourceVariables : S → Pred V ℓᵛ∈ˢ⁺
substitutionTargetVariables : S → Pred V ℓᵛ∈ˢ⁻
_ᵛ∈ᵗ_ : V → T → Set ℓᵛ∈ᵗ
_ᵛ∈ᵗ_ v t = v ∈ termVariables t
field
termNumberOfVariables : (t : T) → ∃ λ (vs : List V) → (∀ v → (v ∈L vs → v ᵛ∈ᵗ t) × (v ᵛ∈ᵗ t → v ∈L vs))
elementsDefineVariables : (t : T) → V
_ᵛ∈ˢ⁺_ : V → S → Set ℓᵛ∈ˢ⁺
_ᵛ∈ˢ⁺_ v s = v ∈ substitutionSourceVariables s
_ᵛ∈ˢ⁻_ : V → S → Set ℓᵛ∈ˢ⁻
_ᵛ∈ˢ⁻_ v s = v ∈ substitutionTargetVariables s
field
foo : ∀ {v t s} → v ᵛ∈ᵗ t → ¬ v ᵛ∈ˢ⁺ s → v ᵛ∈ᵗ (t ▹ s)
isSep : IsSeparableInto T TermStructure V
record CorrectTermSubstitution ℓᵛ∈ᵗ ℓᵛ∈ˢ⁺ ℓᵛ∈ˢ⁻ ℓᵛ ℓ⁼ᵛ ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵛ∈ᵗ ⊔ ℓᵛ∈ˢ⁺ ⊔ ℓᵛ∈ˢ⁻ ⊔ ℓᵛ ⊔ ℓ⁼ᵛ ⊔ ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
field
Variable : Setoid ℓᵛ ℓ⁼ᵛ
open Setoid Variable public using () renaming
(Carrier to V
;_≈_ to _=ᵛ_)
field
termVariables : T → Pred V ℓᵛ∈ᵗ
substitutionSourceVariables : S → Pred V ℓᵛ∈ˢ⁺
substitutionTargetVariables : S → Pred V ℓᵛ∈ˢ⁻
_ᵛ∈ᵗ_ : V → T → Set ℓᵛ∈ᵗ
_ᵛ∈ᵗ_ v t = v ∈ termVariables t
_ᵛ∈ˢ⁺_ : V → S → Set ℓᵛ∈ˢ⁺
_ᵛ∈ˢ⁺_ v s = v ∈ substitutionSourceVariables s
_ᵛ∈ˢ⁻_ : V → S → Set ℓᵛ∈ˢ⁻
_ᵛ∈ˢ⁻_ v s = v ∈ substitutionTargetVariables s
field
foo : ∀ {v t s} → v ᵛ∈ᵗ t → ¬ v ᵛ∈ˢ⁺ s → v ᵛ∈ᵗ (t ▹ s)
data D : Set where
data IsRight {a b} {A : Set a} {B : Set b} (e : _⊎_ A B) : Set (a ⊔ b) where
right : B → IsRight e
module MostGeneralMGU where
record Unificationoid {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
Property {ℓ} = S → Set ℓ
Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
Nothing P = ∀ s → P s → ⊥
IsUnifier : (t₁ t₂ : T) → Property
IsUnifier t₁ t₂ s = t₁ ▹ s =ᵗ t₂ ▹ s
field
unify : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (IsUnifier t₁ t₂)
unifier : (t₁ t₂ : T) → Maybe S
unifier t₁ t₂ with unify t₁ t₂
unifier t₁ t₂ | _⊎_.left x = nothing
unifier t₁ t₂ | _⊎_.right (x , _) = just x
unifier-is-correct : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) → unifier t₁ t₂ ≡ nothing
unifier-is-correct = {!!}
record IsMostGeneralUnification ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
(unificationoid : Unificationoid ⦃ termSubstitution ⦄)
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
--open TermSubstitution termSubstitution
open Unificationoid unificationoid
_≤_ : (s₋ : S) (s₊ : S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
_≤_ s₋ s₊ = ∃ λ s → s ∙ s₊ =ˢ s₋
MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
MostGenerally P s₊ = ∀ s₋ → P s₋ → s₋ ≤ s₊
field
isMguIfUnifier : (t₁ t₂ : T) → (ru : IsRight (unify t₁ t₂)) →
Prelude.case ru of λ {((right (u , _))) → MostGenerally (IsUnifier t₁ t₂) u}
--mgu : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally $ IsUnifier t₁ t₂)
mgu : (t₁ t₂ : T) → Maybe S
mgu = unifier
record MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
Property {ℓ} = S → Set ℓ
Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
Nothing P = ∀ s → P s → ⊥
IsUnifier : (t₁ t₂ : T) → Property
IsUnifier t₁ t₂ s = t₁ ▹ s =ᵗ t₂ ▹ s
_≤_ : (s₋ : S) (s₊ : S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
_≤_ s₋ s₊ = ∃ λ s → s ∙ s₊ =ˢ s₋
MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
MostGenerally P s₊ = P s₊ × ∀ s₋ → P s₋ → s₋ ≤ s₊
field
mgu : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally $ IsUnifier t₁ t₂)
-- record PairUnification ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
-- ⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
-- : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- --open TermSubstitution termSubstitution
-- Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
-- Property {ℓ} = S × S → Set ℓ
-- Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
-- Nothing P = ∀ u → P u → ⊥
-- IsUnifier : (t₁ t₂ : T) → Property
-- IsUnifier t₁ t₂ u = let (s₁ , s₂) = u in t₁ ▹ s₁ =ᵗ t₂ ▹ s₂
-- infix 4 _≤_
-- _≤_ : (s₋ : S × S) (s₊ : S × S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
-- _≤_ u₋ u₊ =
-- let s₋₁ , s₋₂ = u₋
-- s₊₁ , s₊₂ = u₊ in
-- ∃ λ s → s ∙ s₊₁ =ˢ s₋₁ × s ∙ s₊₂ =ˢ s₋₂
-- MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
-- MostGenerally P u₊ = P u₊ × ∀ u₋ → P u₋ → u₋ ≤ u₊
-- {-
-- mgu f(x,y) f(y,x)
-- x → w , y → z || x → z , y → w
-- mgu f(x,y) f(g(y),x)
-- x → g(z) || y → z , x → y
-- mgu f(x,y) f(y,z)
-- x → y , y → z || ∅ ≥₂
-- x → w , y → z || y → w ≥₂
-- x → w , y → v || y → w , z → v ≥₂
-- y → v || y → x , z → v ≥₂
-- ∅ || y → x , z → y
-- x → w , y → v , z → v || y → w , z → v
-- x → y , y → f(z) || z → f(z)
-- f(x , g(x,y) ,w)
-- x → g(z)
-- w →? v
-- f(g(z), g(g(z),y) ,v)
-- v →? w
-- possible unifers:
-- x → g(z) , w → v ||
-- x → g(h(a)) , w → v || z → h(a)
-- x → g(z) || z → h(y) , v → w
-- -}
-- field
-- mgu : (t₁ t₂ : T)
-- → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally (IsUnifier t₁ t₂))
-- -- record Something ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- -- field
-- -- Terminus : Setoid ℓᵗ ℓ⁼ᵗ
-- -- Simplex : Monoid ℓˢ ℓ⁼ˢ
-- -- open Setoid Terminus public using () renaming
-- -- (Carrier to T
-- -- ;_≈_ to _=T=_)
-- -- open Monoid Simplex public using () renaming
-- -- (Carrier to S
-- -- ;_≈_ to _=S=_
-- -- ;_∙_ to _∙_
-- -- ;ε to ∅)
-- -- infixl 6 _▹_
-- -- field
-- -- _▹_ : T → S → T
-- -- -- equivalence of S implies substitutivity in (T,▹)
-- -- ▹-=S=-to-=T= : ∀ {s s′} → s =S= s′ → (t : T) → t ▹ s =T= t ▹ s′
-- -- -- applications of simplexi are equivalent across all termini only when the simplexi are equivalent
-- -- -- that is, equivalence of S is as compact is it can be while still respecting equivalence in (T,▹)
-- -- ▹-=T=-to-=S= : ∀ {s s′} → ((t : T) → t ▹ s =T= t ▹ s′) → s =S= s′
-- -- -- S extracts to ▹ in (T,∙)
-- -- ▹-∙-compositional : (t : T) (s₁ s₂ : S) → t ▹ s₁ ∙ s₂ =T= t ▹ s₁ ▹ s₂
-- -- -- module NotIndexed where
-- -- -- record MGU ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- -- -- infixr 8 _◃_
-- -- -- --infixr 9 _◇_
-- -- -- field
-- -- -- 𝓣erm : Setoid ℓᵗ ℓ⁼ᵗ
-- -- -- open Setoid 𝓣erm public using () renaming (Carrier to 𝓣; _≈_ to _=ᵗ_)
-- -- -- field
-- -- -- 𝓢ubstition : Semigroup ℓˢ ℓ⁼ˢ -- TODO Monoid?
-- -- -- open Semigroup 𝓢ubstition public using () renaming
-- -- -- (Carrier to 𝓢
-- -- -- ;_≈_ to _=ˢ_
-- -- -- ; _∙_ to _◇_)
-- -- -- --field
-- -- -- -- 𝓼ubstitute : RawPApplicative (λ x x₁ → {!!})
-- -- -- _◃'_ : 𝓢 → 𝓣 → 𝓣
-- -- -- _◃'_ = {!!}
-- -- -- field
-- -- -- _◃_ : 𝓢 → 𝓣 → 𝓣
-- -- -- ◃-=ˢ-to-=ᵗ : ∀ {𝒮 𝒮′} → 𝒮 =ˢ 𝒮′ → (𝒯 : 𝓣) → 𝒮 ◃ 𝒯 =ᵗ 𝒮′ ◃ 𝒯
-- -- -- ◃-=ᵗ-to-=ˢ : ∀ {𝒮 𝒮′} → ((𝒯 : 𝓣) → 𝒮 ◃ 𝒯 =ᵗ 𝒮′ ◃ 𝒯) → 𝒮 =ˢ 𝒮′
-- -- -- field
-- -- -- --_◇_ : 𝓢 → 𝓢 → 𝓢
-- -- -- ◇-compositional : (𝒯 : 𝓣) (𝒮₁ 𝒮₂ : 𝓢) → (𝒮₂ ◇ 𝒮₁) ◃ 𝒯 =ᵗ 𝒮₂ ◃ 𝒮₁ ◃ 𝒯
-- -- -- ◇-associative : (𝒮₁ 𝒮₂ 𝒮₃ : 𝓢) → 𝒮₃ ◇ (𝒮₂ ◇ 𝒮₁) =ˢ (𝒮₃ ◇ 𝒮₂) ◇ 𝒮₁
-- -- -- ◇-associative 𝒮₁ 𝒮₂ 𝒮₃ = {!!}
-- -- -- Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
-- -- -- Property {ℓ} = 𝓢 → Set ℓ
-- -- -- Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
-- -- -- Nothing P = ∀ 𝒮 → P 𝒮 → ⊥
-- -- -- Unifies : (𝒯₁ 𝒯₂ : 𝓣) → Property
-- -- -- Unifies 𝒯₁ 𝒯₂ 𝒮 = 𝒮 ◃ 𝒯₁ ≡ 𝒮 ◃ 𝒯₂
-- -- -- _≤_ : (σ₋ : 𝓢) (σ₊ : 𝓢) → Set (ℓˢ ⊔ ℓ⁼ˢ)
-- -- -- _≤_ σ₋ σ₊ = ∃ λ σ → σ ◇ σ₊ =ˢ σ₋
-- -- -- Max : ∀ {ℓ} (P : Property {ℓ}) → Property
-- -- -- Max P σ₊ = P σ₊ × ∀ σ₋ → P σ₋ → σ₋ ≤ σ₊
-- -- -- field
-- -- -- mgu : (𝒯₁ 𝒯₂ : 𝓣) → Nothing (Unifies 𝒯₁ 𝒯₂) ⊎ ∃ λ (σ : 𝓢) → Max (Unifies 𝒯₁ 𝒯₂) σ
-- -- -- -- module Indexed where
-- -- -- -- record MGU ℓⁱ ℓᵛ ℓᵗ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓᵛ ⊔ ℓᵗ ⊔ ℓˢ)) where
-- -- -- -- field
-- -- -- -- 𝓲 : Set ℓⁱ
-- -- -- -- 𝓥 : 𝓲 → Set ℓᵛ
-- -- -- -- 𝓣 : 𝓲 → Set ℓᵗ
-- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓᵛ ⊔ ℓᵗ)
-- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- infix 14 _≐_
-- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓᵛ ⊔ ℓᵗ)
-- -- -- -- _≐_ σ σ′ = ∀ x → σ x ≡ σ′ x
-- -- -- -- field
-- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- ≐-◃-identity : {!!}
-- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (σ₂ : s ↦ t) (σ₁ : r ↦ s) → r ↦ t
-- -- -- -- _◇_ σ₂ σ₁ = (σ₂ ◃_) ∘ σ₁
-- -- -- -- field
-- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- Property {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- Nothing P = ∀ {n} f → P {n} f → ⊥
-- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- Unifies t₁ t₂ f = f ◃ t₁ ≡ f ◃ t₂
-- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- Max P = (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- field
-- -- -- -- -- mgu : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- Nothing (Unifies t₁ t₂) ⊎ (∃ λ n → ∃ λ (σ : 𝓢 m n) → (Max (Unifies t₁ t₂)) (sub σ))
-- -- -- -- -- -- -- -- open import Prelude.Function
-- -- -- -- -- -- -- -- open import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_ ; ≅-to-≡)
-- -- -- -- -- -- -- -- open import Prelude.Equality
-- -- -- -- -- -- -- -- record MGU-addIndex-to-noIndex* {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- 𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ)
-- -- -- -- -- -- -- -- 𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- 𝓼ᵢ : Set (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- to∃𝓥 : 𝓥ᵢ → ∃ 𝓥
-- -- -- -- -- -- -- -- to∃𝓣 : 𝓣ᵢ → ∃ 𝓣
-- -- -- -- -- -- -- -- to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ
-- -- -- -- -- -- -- -- to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ
-- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥 a ≡ 𝓥 b → a ≡ b
-- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣 a ≡ 𝓣 b → a ≡ b
-- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- to∃𝓣𝓣 : 𝓣ᵢ → 𝓣ᵢ → ∃ λ i → 𝓣 i × 𝓣 i
-- -- -- -- -- -- -- -- max𝓣ᵢ : ∀ {m} n → (tm : 𝓣 m) → (((𝓣 n → 𝓣 m) × (𝓥 n → 𝓥 m)) ⊎ 𝓣 n)
-- -- -- -- -- -- -- -- max𝓲 : ∀ m n → ((𝓣 n → 𝓣 m) × (𝓥 n → 𝓥 m)) ⊎ ((𝓣 m → 𝓣 n) × (𝓥 m → 𝓥 n))
-- -- -- -- -- -- -- -- apply𝓼 : 𝓣ᵢ → (𝓥ᵢ → 𝓣ᵢ) → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × 𝓣 s
-- -- -- -- -- -- -- -- to𝓼 : 𝓼ᵢ → ∃ λ s → ∃ λ t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- to𝓼' : 𝓼ᵢ → 𝓣ᵢ → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × 𝓣 s
-- -- -- -- -- -- -- -- to◇ : 𝓼ᵢ → 𝓼ᵢ → ∃ λ r → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × (𝓥 r → 𝓣 s)
-- -- -- -- -- -- -- -- to= : 𝓼ᵢ → 𝓼ᵢ → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × (𝓥 s → 𝓣 t)
-- -- -- -- -- -- -- -- to𝓼ᵢ : ∀ {r t} → (𝓥 r → 𝓣 t) → 𝓼ᵢ
-- -- -- -- -- -- -- -- {{ eqi }} : Eq 𝓲
-- -- -- -- -- -- -- -- to-noIndex : MGU-noIndex* (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) (ℓⁱ ⊔ ℓˢ)
-- -- -- -- -- -- -- -- to-noIndex = go where
-- -- -- -- -- -- -- -- go : MGU-noIndex* _ _ _
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓼 go = 𝓼ᵢ -- ∃ λ s → ∃ λ t → s ↦ t
-- -- -- -- -- -- -- -- MGU-noIndex*._≐_ go s1 s2 with to= s1 s2
-- -- -- -- -- -- -- -- ... | (s , t , vstt1 , vstt2) = {!_≐_ vstt1 vstt2!}
-- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go f x with to𝓼' f x
-- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go _ _ | (s , t , f , term) = to𝓣ᵢ $ _ , f ◃ term
-- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go s1 s2 with to◇ s1 s2
-- -- -- -- -- -- -- -- ... | (r , s , t , vstt , vrts) = to𝓼ᵢ $ vstt ◇ vrts
-- -- -- -- -- -- -- -- MGU-noIndex*.mgu go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓥 go = {!𝓥ᵢ!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓼 go = {!!} -- ∃ λ s → ∃ λ t → s ↦ t -- ∃ λ s → ∃ λ t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- MGU-noIndex*._≐_ go (s₁ , t₁ , f₁) (s₂ , t₂ , f₂) = {!!} -- ∃ λ (s-refl : s₁ ≡ s₂) → ∃ λ (t-refl : t₁ ≡ t₂) → (∀ x → f₁ x ≡ (Prelude.transport (λ i → 𝓥 s₂ → 𝓣 i) (sym t-refl) f₂) (Prelude.transport _ s-refl x))
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 = {!_◃_ f!}
-- -- -- -- -- -- -- -- -- ∀ s t → 𝓣ᵢ → (𝓣 s → 𝓣 t) → 𝓣 s
-- -- -- -- -- -- -- -- -- ∀ s t → 𝓣ᵢ → (𝓣 s → 𝓣 t) → 𝓣ᵢ
-- -- -- -- -- -- -- -- -- 𝓣 s
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 with to∃𝓣 𝒯
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 | (s2 , ttt) with s == s2
-- -- -- -- -- -- -- -- -- (go MGU-noIndex*.◃ (.s , t , f)) 𝒯 | s , 𝒯s | (Prelude.yes refl) = to𝓣ᵢ (_ , _◃_ {s} {t} f 𝒯s)
-- -- -- -- -- -- -- -- -- (go MGU-noIndex*.◃ (s , t , f)) 𝒯 | s2 , ttt | (Prelude.no x) = 𝒯
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) with max𝓲 r s
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) | _⊎_.left (T , V) = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) | _⊎_.right (T , V) = _ , _ , f ◇ (T ∘ g) -- f ◃_ ∘ (T ∘ g)
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- = _ , _ , f ◃_ ∘ (λ x → {!max𝓣ᵢ s₁ (g x)!}) -- _ , _ , f ◃_ ∘ (λ x → {!g x!})
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) with t₂ == s₁
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) | (Prelude.yes refl) = s₂ , t₁ , f ◃_ ∘ g
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) | (Prelude.no x) = s₂ , t₂ , g
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- = s₂ , t₁ , {!(f ◃_)!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ with to∃𝓣𝓣 t₁ t₂
-- -- -- -- -- -- -- -- -- … | i , tt₁ , tt₂ with mgu tt₁ tt₂
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.left x) = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.right (i₂ , σ , subσ-refl , ff)) with to∃𝓣 t₁ | to∃𝓣 t₂
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.right (i₂ , σ , subσ-refl , ff)) | (fst₁ , snd₁) | (fst₂ , snd₂) = _⊎_.right ((_ , _ , sub σ) , {!!} , {!!}) -- _⊎_.right ((i , i₂ , sub σ) , {!subσ-refl!} , {!!})
-- -- -- -- -- -- -- -- -- record MGU-noIndex-to-addIndex {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- -- (m : MGU-noIndex ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- -- open MGU-noIndex m
-- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- 𝓲 : Set ℓⁱ
-- -- -- -- -- -- -- -- -- 𝓥ᵢ : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- 𝓣ᵢ : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- to𝓥 : ∃ 𝓥ᵢ → 𝓥
-- -- -- -- -- -- -- -- -- to𝓣 : ∃ 𝓣ᵢ → 𝓣
-- -- -- -- -- -- -- -- -- to∃𝓥ᵢ : 𝓥 → ∃ 𝓥ᵢ
-- -- -- -- -- -- -- -- -- to∃𝓣ᵢ : 𝓣 → ∃ 𝓣ᵢ
-- -- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥ᵢ a ≡ 𝓥ᵢ b → a ≡ b
-- -- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣ᵢ a ≡ 𝓣ᵢ b → a ≡ b
-- -- -- -- -- -- -- -- -- mag : ∀ {s t} → (𝓥ᵢ s → 𝓣ᵢ t) → 𝓥 → 𝓣
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- to-addIndex : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ
-- -- -- -- -- -- -- -- -- to-addIndex = go where
-- -- -- -- -- -- -- -- -- go : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓲 go = 𝓲
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-addIndex._◃_ go {s} {t} f x = Prelude.transport 𝓣ᵢ {!!} $ snd ∘ to∃𝓣ᵢ $ _◃_ (λ v → to𝓣 (t , f (Prelude.transport 𝓥ᵢ (inj𝓥 {_} {_} {!!}) (snd $ to∃𝓥ᵢ v)))) (to𝓣 (s , x)) -- let Ti , Tit = to∃𝓣ᵢ $ _◃_ (λ v → to𝓣 (t , f {!!})) (to𝓣 (s , x)) in {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.sub go = {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- record MGU-addIndex-to-noIndex {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- 𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ)
-- -- -- -- -- -- -- -- -- 𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- to∃𝓥 : 𝓥ᵢ → ∃ 𝓥
-- -- -- -- -- -- -- -- -- to∃𝓣 : 𝓣ᵢ → ∃ 𝓣
-- -- -- -- -- -- -- -- -- to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ
-- -- -- -- -- -- -- -- -- to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥 a ≡ 𝓥 b → a ≡ b
-- -- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣 a ≡ 𝓣 b → a ≡ b
-- -- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- to-noIndex : MGU-noIndex (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) ℓˢ
-- -- -- -- -- -- -- -- -- to-noIndex = go where
-- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ go 𝓈 𝒯ᵢ with to∃𝓣 𝒯ᵢ | Prelude.graphAt to∃𝓣 𝒯ᵢ | (Prelude.curry $ snd ∘ to∃𝓣 ∘ 𝓈 ∘ to𝓥ᵢ) (fst $ to∃𝓣 𝒯ᵢ) | Prelude.graphAt (Prelude.curry $ snd ∘ to∃𝓣 ∘ 𝓈 ∘ to𝓥ᵢ) (fst $ to∃𝓣 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | s , 𝒯s | Prelude.ingraph eq | 𝓈' | Prelude.ingraph refl with cong fst eq
-- -- -- -- -- -- -- -- -- (go MGU-noIndex.◃ 𝓈) 𝒯ᵢ | .(fst (to∃𝓣 𝒯ᵢ)) , 𝒯s | (Prelude.ingraph eq) | _ | (Prelude.ingraph refl) | refl with cong fst eq
-- -- -- -- -- -- -- -- -- (go MGU-noIndex.◃ 𝓈) 𝒯ᵢ | .(fst (to∃𝓣 _ 𝒯ᵢ)) , 𝒯s | (Prelude.ingraph eq) | 𝓈' | (Prelude.ingraph refl) | refl | refl rewrite Prelude.sym eq with _◃_ {_} {{!!}} (λ v → 𝓈' (Prelude.transport 𝓥 (cong fst (sym eq)) {!!})) (snd ∘ to∃𝓣 $ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | dfsf = to𝓣ᵢ (_ , dfsf)
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- … | s , 𝒯s | Prelude.ingraph eq | 𝓈' | Prelude.ingraph refl with _◃_ {fst (to∃𝓣 𝒯ᵢ)} {s} (λ v → Prelude.transport 𝓣 {!!} (𝓈' (Prelude.transport 𝓥 (cong fst eq) v))) (snd ∘ to∃𝓣 $ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | dd = to𝓣ᵢ (_ , dd)
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex.sub go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- -- MGU-addIndex-to-noIndex : ∀ {ℓⁱ ℓⱽ ℓᵀ ℓˢ} →
-- -- -- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ)
-- -- -- -- -- -- -- -- -- -- (open MGU-addIndex m)
-- -- -- -- -- -- -- -- -- -- (𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ))
-- -- -- -- -- -- -- -- -- -- (𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ))
-- -- -- -- -- -- -- -- -- -- (to∃𝓥 : 𝓥ᵢ → ∃ 𝓥)
-- -- -- -- -- -- -- -- -- -- (to∃𝓣 : 𝓣ᵢ → ∃ 𝓣)
-- -- -- -- -- -- -- -- -- -- (to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ)
-- -- -- -- -- -- -- -- -- -- (to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ)
-- -- -- -- -- -- -- -- -- -- (iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱)
-- -- -- -- -- -- -- -- -- -- (iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ)
-- -- -- -- -- -- -- -- -- -- (iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯)
-- -- -- -- -- -- -- -- -- -- (iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- -- → MGU-noIndex (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) ℓˢ
-- -- -- -- -- -- -- -- -- -- MGU-addIndex-to-noIndex {ℓⁱ} {ℓⱽ} {ℓᵀ} {ℓˢ} m = go where
-- -- -- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- -- go = {!!}
-- -- -- -- -- -- -- -- -- -- -- open import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_ ; ≅-to-≡)
-- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- 𝓼 = ∃ 𝓥 → ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- _∶_↦_ : 𝓼 → 𝓲 → 𝓲 → Set (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- _∶_↦_ 𝓈 s t = ((𝒱ₛ : 𝓥 s) → ∃ λ (𝒯ₜ : 𝓣 t) → 𝓈 (s , 𝒱ₛ) ≡ (t , 𝒯ₜ))
-- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 go = ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 go = ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ go f g = (𝒾 : 𝓲) (𝒱 : 𝓥 𝒾) → f (𝒾 , 𝒱) ≡ g (𝒾 , 𝒱)
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ go 𝓈 (𝒾 , 𝒯) = 𝒾 , _◃_ {𝒾} {𝒾} (λ v → (Prelude.transport _ (≅-to-≡ $ snd (mag (fst (𝓈 (𝒾 , v))) (( (𝒾 ))) (snd (𝓈 (𝒾 , v))))) $
-- -- -- -- -- -- -- -- -- -- -- snd (𝓈 (𝒾 , v)))
-- -- -- -- -- -- -- -- -- -- -- {!!}) {!!}
-- -- -- -- -- -- -- -- -- -- -- -- (snd ∘ (λ (𝒱 : 𝓥 𝒾) → 𝓈 (𝒾 , 𝒱)))
-- -- -- -- -- -- -- -- -- -- -- -- fst (𝓈 (s , {!!})) , _◃_ {s} {fst (𝓈 (s , _))} (λ v → {!𝓈 (s , v)!}) {!𝒯ₛ!}
-- -- -- -- -- -- -- -- -- -- -- -- Have: {s t : 𝓲} → (𝓥 s → 𝓣 t) → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- λ (𝒱 : 𝓥 𝒾) → 𝓈 (𝒾 , 𝒱)
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub go = {!sub {s} {t}!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 (MGU-addIndex-to-noIndex m) = let open MGU-addIndex m in ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 (MGU-addIndex-to-noIndex m) = let open MGU-addIndex m in ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ (MGU-addIndex-to-noIndex m) f g = {!let open MGU-addIndex m in ∀ (s t : 𝓲) → (𝒯ₜ : 𝓣 fst (f (s , 𝓥 s)) ≡ t → ≡ g → Set !} -- ∀ {s t} → (f g : s ↦ t) → f ≐ g
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ (MGU-addIndex-to-noIndex m) = {!let open MGU-addIndex m in _◃_!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ (MGU-addIndex-to-noIndex m@(record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu })) f g = {!!} -- (i : 𝓲) → MGU-addIndex._≐_ m (λ v → {!snd $ f (i , v)!}) (λ v → {!!})
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- record MGU⋆ ℓⁱ ℓⱽ ℓᵀ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ ⊔ ℓˢ)) where
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓲
-- -- -- -- -- -- -- -- -- -- -- : Set ℓⁱ
-- -- -- -- -- -- -- -- -- -- -- 𝓥 -- variables
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- -- -- 𝓣 -- terms
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- -- -- -- substitution
-- -- -- -- -- -- -- -- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- infix 14 _≐_
-- -- -- -- -- -- -- -- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≐_ f g = ∀ x → f x ≡ g x
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- -- substitution applied to a term
-- -- -- -- -- -- -- -- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- applying extentionally-equal subsitutions preserves equality of terms
-- -- -- -- -- -- -- -- -- -- -- ◃ext : ∀ {s t} {f g : s ↦ t} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (f : s ↦ t) (g : r ↦ s) → r ↦ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ f g = (f ◃_) ∘ g
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- -- -- -- -- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- -- -- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Nothing P = ∀ {n} f → P {n} f → ⊥
-- -- -- -- -- -- -- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- -- -- -- -- -- -- Unifies t₁ t₂ f = f ◃ t₁ ≡ f ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- -- -- -- -- -- -- Max P = (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- mgu : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- Nothing (Unifies t₁ t₂) ⊎ (∃ λ n → ∃ λ (σ : 𝓢 m n) → (Max (Unifies t₁ t₂)) (sub σ))
-- -- -- -- -- -- -- -- -- -- -- record MGU ℓⁱ ℓⱽ ℓᵀ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ ⊔ ℓˢ)) where
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓲
-- -- -- -- -- -- -- -- -- -- -- : Set ℓⁱ
-- -- -- -- -- -- -- -- -- -- -- 𝓥 -- variables
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- -- -- 𝓣 -- terms
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- -- -- -- substitution
-- -- -- -- -- -- -- -- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- infix 14 _≐_
-- -- -- -- -- -- -- -- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≐_ f g = ∀ x → f x ≡ g x
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- -- substitution applied to a term
-- -- -- -- -- -- -- -- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- applying extentionally-equal subsitutions preserves equality of terms
-- -- -- -- -- -- -- -- -- -- -- ◃ext : ∀ {s t} {f g : s ↦ t} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (f : s ↦ t) (g : r ↦ s) → r ↦ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ f g = (f ◃_) ∘ g
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- -- -- -- -- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- mgu : ∀ {m} → (s t : 𝓣 m) → Maybe (∃ (𝓢 m))
-- -- -- -- -- -- -- -- -- -- -- Property⋆ : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property⋆ {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- -- -- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property {ℓ} s = Σ (Property⋆ {ℓ} s) λ P → ∀ {s f g} → f ≐ g → P {s} f → P g
-- -- -- -- -- -- -- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Nothing P = ∀ {n} f → fst P {n} f → ⊥
-- -- -- -- -- -- -- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- -- -- -- -- -- -- Unifies t₁ t₂ = (λ {_} f → f ◃ t₁ ≡ f ◃ t₂) , λ {_} {f} {g} f≐g f◃t₁=f◃t₂ →
-- -- -- -- -- -- -- -- -- -- -- g ◃ t₁
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ sym (◃ext f≐g t₁) ⟩
-- -- -- -- -- -- -- -- -- -- -- f ◃ t₁
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ f◃t₁=f◃t₂ ⟩
-- -- -- -- -- -- -- -- -- -- -- f ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ ◃ext f≐g t₂ ⟩
-- -- -- -- -- -- -- -- -- -- -- g ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- ∎
-- -- -- -- -- -- -- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- -- -- -- -- -- -- Max P' =
-- -- -- -- -- -- -- -- -- -- -- let open Σ P' using () renaming (fst to P; snd to Peq) in
-- -- -- -- -- -- -- -- -- -- -- let lemma1 : {m : 𝓲} {f : _ ↦ m} {g : _ ↦ m} →
-- -- -- -- -- -- -- -- -- -- -- f ≐ g →
-- -- -- -- -- -- -- -- -- -- -- P f × ({n : 𝓲} (f' : _ ↦ n) → P f' → f' ≤ f) →
-- -- -- -- -- -- -- -- -- -- -- P g × ({n : 𝓲} (f' : _ ↦ n) → P f' → f' ≤ g)
-- -- -- -- -- -- -- -- -- -- -- lemma1 {_} {_} {g} f≐g = λ { (Pf , MaxPf) →
-- -- -- -- -- -- -- -- -- -- -- Peq f≐g Pf , λ {_} →
-- -- -- -- -- -- -- -- -- -- -- let lemma2 : ∀ {n} f' → P {n} f' → ∃ λ f0 → f' ≐ (f0 ◇ g)
-- -- -- -- -- -- -- -- -- -- -- lemma2 f' Pf' =
-- -- -- -- -- -- -- -- -- -- -- let f0 = fst (MaxPf f' Pf')
-- -- -- -- -- -- -- -- -- -- -- f'≐f0◇f = snd (MaxPf f' Pf') in
-- -- -- -- -- -- -- -- -- -- -- f0 , λ x → trans (f'≐f0◇f x) (cong (f0 ◃_) (f≐g x)) in
-- -- -- -- -- -- -- -- -- -- -- lemma2 } in
-- -- -- -- -- -- -- -- -- -- -- --(λ {_} f → P f × (∀ {n} f' → P {n} f' → f' ≤ f)) , λ {_} {_} {_} → lemma1
-- -- -- -- -- -- -- -- -- -- -- (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f)) , lemma1
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property⋆ m
-- -- -- -- -- -- -- -- -- -- -- Max P' =
-- -- -- -- -- -- -- -- -- -- -- let open Σ P' using () renaming (fst to P) in
-- -- -- -- -- -- -- -- -- -- -- (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- mgu-c : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → fst (Max (Unifies t₁ t₂)) (sub σ) × mgu t₁ t₂ ≡ just (n , σ))
-- -- -- -- -- -- -- -- -- -- -- ⊎ (Nothing (Unifies t₁ t₂) × mgu t₁ t₂ ≡ nothing)
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- mgu-c : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → (Max (Unifies t₁ t₂)) (sub σ) × mgu t₁ t₂ ≡ just (n , σ))
-- -- -- -- -- -- -- -- -- -- -- ⊎ (Nothing (Unifies t₁ t₂) × mgu t₁ t₂ ≡ nothing)
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- -- trivial substitution
-- -- -- -- -- -- -- -- -- -- -- -- ▹ : ∀ {s t} → (𝓥 s → 𝓥 t) → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- ≐-cong : ∀ {m n o} {f : m ↦ n} {g} (h : _ ↦ o) → f ≐ g → (h ◇ f) ≐ (h ◇ g)
-- -- -- -- -- -- -- -- -- -- -- ≐-cong h f≐g t = cong (h ◃_) (f≐g t)
-- -- -- -- -- -- -- -- -- -- -- ≐-sym : ∀ {m n} {f : m ↦ n} {g} → f ≐ g → g ≐ f
-- -- -- -- -- -- -- -- -- -- -- ≐-sym f≐g = sym ∘ f≐g
-- -- -- -- -- -- -- -- -- -- -- -}
| 44.134396
| 280
| 0.347329
|
105594610232acfb4f78bdbab5b1842643bcf146
| 421
|
agda
|
Agda
|
test/fail/Issue334.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/Issue334.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue334.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- 2010-10-04
-- termination checker no longer counts stripping off a record constructor
-- as decrease
module Issue334 where
data Unit : Set where
unit : Unit
record E : Set where
constructor mkE
field
fromE : E
spam : Unit
f : E -> Set
f (mkE e unit) = f e
-- the record pattern translation does not apply to f
-- still, should not termination check, because
-- f (mkE e u) = f e
-- also does not!
| 19.136364
| 74
| 0.67696
|
39dc0ce27cad3f60eb441c1dc187d82f27a55275
| 1,218
|
agda
|
Agda
|
src/NTypes/Id.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
src/NTypes/Id.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
src/NTypes/Id.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
module NTypes.Id where
open import GroupoidStructure
open import NTypes
open import PathOperations
open import Transport
open import Types
-- This should also be derivable from hLevel-suc from
-- HomotopyTypes.HLevel module.
Id-isSet : ∀ {a} {A : Set a} {x y : A} →
isSet A → isSet (x ≡ y)
Id-isSet {x = x} {y = y} A-set _ _ pp qq
= path pp ⁻¹ · path qq
where
split-path : {p q : x ≡ y} (pp : p ≡ q) →
A-set _ _ p q ≡ pp · A-set _ _ q q
split-path pp = J
(λ p q pp → A-set _ _ p q ≡ pp · A-set _ _ q q)
(λ _ → refl) _ _ pp
path : {p q : x ≡ y} (pp : p ≡ q) →
A-set _ _ p q ≡ pp
path pp = J
(λ p q pp → A-set _ _ p q ≡ pp)
(λ p → split-path (A-set _ _ p p ⁻¹) · p⁻¹·p (A-set _ _ p p))
_ _ pp
-- From the lectures.
Id-isSet-alt : ∀ {a} {A : Set a} {u v : A} →
isSet A → isSet (u ≡ v)
Id-isSet-alt {u = u} {v = v} H r s α β
= id·p α ⁻¹
· ap (λ z → z · α)
(p⁻¹·p (H′ r)) ⁻¹
· p·q·r (H′ r ⁻¹) (H′ r) α ⁻¹
· ap (λ z → H′ r ⁻¹ · z)
( tr-post r α (H′ r) ⁻¹
· apd H′ α
· apd H′ β ⁻¹
· tr-post r β (H′ r)
)
· p·q·r (H′ r ⁻¹) (H′ r) β
· ap (λ z → z · β)
(p⁻¹·p (H′ r))
· id·p β
where
H′ = λ q → H u v r q
| 24.36
| 65
| 0.49179
|
a11265ecda977d52e778f2e5299321a35daa7fc6
| 17,897
|
agda
|
Agda
|
agda/DsubDef.agda
|
HuStmpHrrr/popl20-artifact
|
48214a55ebb484fd06307df4320813d4a002535b
|
[
"MIT"
] | 1
|
2021-09-23T08:40:28.000Z
|
2021-09-23T08:40:28.000Z
|
agda/DsubDef.agda
|
HuStmpHrrr/popl20-artifact
|
48214a55ebb484fd06307df4320813d4a002535b
|
[
"MIT"
] | null | null | null |
agda/DsubDef.agda
|
HuStmpHrrr/popl20-artifact
|
48214a55ebb484fd06307df4320813d4a002535b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
-- In this module, we define the syntax of D<:
module DsubDef where
open import Data.List as List
open import Data.List.All
open import Data.Nat as ℕ
open import Data.Maybe as Maybe
open import Data.Product
open import Data.Sum
open import Data.Empty renaming (⊥ to False)
open import Function
open import Data.Nat.Properties as ℕₚ
open import Data.Maybe.Properties as Maybeₚ
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Utils
infix 8 _∙A
infix 6 Π_∙_ ⟨A:_⋯_⟩
-- Types
--
-- Notations in Agda should be more readable than in Coq.
-- * ⊤ is a supertype of all types.
-- * ⊥ is a subtype of all types.
-- * (x ∙A) represents a path dependent type (x.A).
-- * (Π S ∙ U) represents a dependent function type (∀(x : S)U).
-- * (⟨A: S ⋯ U ⟩) represents a type declaration ({A : S .. U}).
data Typ : Set where
⊤ : Typ
⊥ : Typ
_∙A : (n : ℕ) → Typ
Π_∙_ : (S U : Typ) → Typ
⟨A:_⋯_⟩ : (S U : Typ) → Typ
-- typing context
Env : Set
Env = List Typ
-- shifting operation of de Bruijn indices
infixl 7 _↑_
_↑_ : Typ → ℕ → Typ
⊤ ↑ n = ⊤
⊥ ↑ n = ⊥
(x ∙A) ↑ n with n ≤? x
... | yes n≤x = suc x ∙A
... | no n>x = x ∙A
(Π S ∙ U) ↑ n = Π S ↑ n ∙ U ↑ suc n
⟨A: S ⋯ U ⟩ ↑ n = ⟨A: S ↑ n ⋯ U ↑ n ⟩
-- The remaining are technical setup.
infix 4 _↦_∈_
data _↦_∈_ : ℕ → Typ → Env → Set where
hd : ∀ {T Γ} → 0 ↦ T ↑ 0 ∈ T ∷ Γ
tl : ∀ {n T T′ Γ} → n ↦ T ∈ Γ → suc n ↦ T ↑ 0 ∈ T′ ∷ Γ
env-lookup : Env → ℕ → Maybe Typ
env-lookup Γ n = Maybe.map (repeat (suc n) (_↑ 0)) (lookupOpt Γ n)
↦∈⇒lookup : ∀ {x T Γ} → x ↦ T ∈ Γ → env-lookup Γ x ≡ just T
↦∈⇒lookup hd = refl
↦∈⇒lookup {x} {_} {Γ} (tl T∈Γ) with lookupOpt Γ x | ↦∈⇒lookup T∈Γ
... | just T′ | eq = cong (just ∘ (_↑ zero)) (just-injective eq)
... | nothing | ()
lookup⇒↦∈ : ∀ {x T Γ} → env-lookup Γ x ≡ just T → x ↦ T ∈ Γ
lookup⇒↦∈ {x} {_} {[]} ()
lookup⇒↦∈ {zero} {_} {T ∷ Γ} refl = hd
lookup⇒↦∈ {suc x} {_} {T ∷ Γ} eq with lookupOpt Γ x | λ {T} → lookup⇒↦∈ {x} {T} {Γ}
lookup⇒↦∈ refl | just T′ | rec = tl $ rec refl
lookup⇒↦∈ () | nothing | _
⟨A:⟩-injective : ∀ {S U S′ U′} → ⟨A: S ⋯ U ⟩ ≡ ⟨A: S′ ⋯ U′ ⟩ → S ≡ S′ × U ≡ U′
⟨A:⟩-injective refl = refl , refl
↑-idx : ℕ → ℕ → ℕ
↑-idx x n with n ≤? x
... | yes p = suc x
... | no ¬p = x
↑-var : ∀ x n → x ∙A ↑ n ≡ ↑-idx x n ∙A
↑-var x n with n ≤? x
... | yes p = refl
... | no ¬p = refl
↑-↑-comm : ∀ T m n → m ≤ n → T ↑ m ↑ suc n ≡ T ↑ n ↑ m
↑-↑-comm ⊤ m n m≤n = refl
↑-↑-comm ⊥ m n m≤n = refl
↑-↑-comm (x ∙A) m n m≤n with n ≤? x
... | yes n≤x
rewrite ≤?-yes (≤-trans m≤n n≤x)
| ≤?-yes n≤x
| ≤?-yes (≤-step (≤-trans m≤n n≤x)) = refl
... | no n>x with m ≤? x
... | yes m≤x rewrite proj₂ $ ≤?-no n>x = refl
... | no m>x with suc n ≤? x
... | yes 1+n≤x = ⊥-elim (m>x (≤-trans (≤-step m≤n) 1+n≤x))
... | no 1+n>x = refl
↑-↑-comm (Π S ∙ U) m n m≤n
rewrite ↑-↑-comm S m n m≤n
| ↑-↑-comm U (suc m) (suc n) (s≤s m≤n) = refl
↑-↑-comm ⟨A: S ⋯ U ⟩ m n m≤n
rewrite ↑-↑-comm S m n m≤n | ↑-↑-comm U m n m≤n = refl
-- These two judgments are about to capture the characteristics of the image of
-- interpretation functions from F<:⁻ to D<:.
--
-- Covar quantifies the types in D<: which appears in the covariant positions in the
-- image of the interpretation function.
data Covar : Typ → Set where
cv⊤ : Covar ⊤
cv∙A : ∀ n → Covar (n ∙A)
cvΠ : ∀ {S U} → Covar S → Covar U → Covar (Π ⟨A: ⊥ ⋯ S ⟩ ∙ U)
-- Contra quantifies the types in D<: which appears in the contravariant positions in
-- the image of the interpretation function.
data Contra : Typ → Set where
ctt : ∀ {T} → Covar T → Contra ⟨A: ⊥ ⋯ T ⟩
ContraEnv : Env → Set
ContraEnv = All Contra
↑-Covar : ∀ {T} n → Covar T → Covar (T ↑ n)
↑-Covar n cv⊤ = cv⊤
↑-Covar n (cv∙A x)
rewrite ↑-var x n = cv∙A _
↑-Covar n (cvΠ S U) = cvΠ (↑-Covar n S) (↑-Covar (suc n) U)
↑-Contra : ∀ {T} n → Contra T → Contra (T ↑ n)
↑-Contra n (ctt T) = ctt (↑-Covar n T)
↑-injective : ∀ {S U n} → S ↑ n ≡ U ↑ n → S ≡ U
↑-injective {⊤} {⊤} {n} eq = refl
↑-injective {⊤} {⊥} {n} ()
↑-injective {⊤} {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {⊤} {Π S ∙ U} {n} ()
↑-injective {⊤} {⟨A: S ⋯ U ⟩} {n} ()
↑-injective {⊥} {⊤} {n} ()
↑-injective {⊥} {⊥} {n} eq = refl
↑-injective {⊥} {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {⊥} {Π S ∙ U} {n} ()
↑-injective {⊥} {⟨A: S ⋯ U ⟩} {n} ()
↑-injective {x ∙A} {⊤} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {x ∙A} {⊥} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {x ∙A} {y ∙A} {n} eq
with n ≤? x | n ≤? y
↑-injective {x ∙A} {y ∙A} {n} refl
| yes n≤x | yes n≤y = refl
↑-injective {x ∙A} {y ∙A} {n} refl
| yes n≤x | no n>y = ⊥-elim (n>y (≤-step n≤x))
↑-injective {x ∙A} {y ∙A} {n} refl
| no n>x | yes n≤y = ⊥-elim (n>x (≤-step n≤y))
↑-injective {x ∙A} {y ∙A} {n} refl
| no n>x | no n>y = refl
↑-injective {x ∙A} {Π S ∙ U} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {x ∙A} {⟨A: S ⋯ U ⟩} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {Π S ∙ U} {⊤} {n} ()
↑-injective {Π S ∙ U} {⊥} {n} ()
↑-injective {Π S ∙ U} {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {Π S ∙ U} {Π S′ ∙ U′} {n} eq
with S ↑ n | U ↑ suc n | S′ ↑ n | U′ ↑ suc n
| ↑-injective {S} {S′} {n} | ↑-injective {U} {U′} {suc n}
... | _ | _ | _ | _ | rec₁ | rec₂
with eq
... | refl = cong₂ Π_∙_ (rec₁ refl) (rec₂ refl)
↑-injective {Π S ∙ U} {⟨A: _ ⋯ _ ⟩} {n} ()
↑-injective {⟨A: S ⋯ U ⟩} {⊤} {n} ()
↑-injective {⟨A: S ⋯ U ⟩} {⊥} {n} ()
↑-injective {⟨A: S ⋯ U ⟩} {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-injective {⟨A: S ⋯ U ⟩} {Π _ ∙ _} {n} ()
↑-injective {⟨A: S ⋯ U ⟩} {⟨A: S′ ⋯ U′ ⟩} {n} eq
with S ↑ n | U ↑ n | S′ ↑ n | U′ ↑ n
| ↑-injective {S} {S′} {n} | ↑-injective {U} {U′} {n}
... | _ | _ | _ | _ | rec₁ | rec₂
with eq
... | refl = cong₂ ⟨A:_⋯_⟩ (rec₁ refl) (rec₂ refl)
↑-⊥-inv : ∀ {S n} → S ↑ n ≡ ⊥ → S ≡ ⊥
↑-⊥-inv {⊤} {n} ()
↑-⊥-inv {⊥} {n} refl = refl
↑-⊥-inv {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
↑-⊥-inv {Π _ ∙ _} {n} ()
↑-⊥-inv {⟨A: _ ⋯ _ ⟩} {n} ()
⟨A:⟩-↑-inv : ∀ {T n S U} → ⟨A: S ⋯ U ⟩ ≡ T ↑ n → ∃₂ λ S′ U′ → T ≡ ⟨A: S′ ⋯ U′ ⟩ × S ≡ S′ ↑ n × U ≡ U′ ↑ n
⟨A:⟩-↑-inv {⊤} ()
⟨A:⟩-↑-inv {⊥} ()
⟨A:⟩-↑-inv {x ∙A} {n} eq
rewrite ↑-var x n = case eq of λ ()
⟨A:⟩-↑-inv {Π _ ∙ _} ()
⟨A:⟩-↑-inv {⟨A: S′ ⋯ U′ ⟩} refl = S′ , U′ , refl , refl , refl
↦∈ContraEnv : ∀ {Γ n T} → n ↦ T ∈ Γ → ContraEnv Γ → Contra T
↦∈ContraEnv hd (T ∷ cT) = ↑-Contra 0 T
↦∈ContraEnv (tl T∈Γ) (_ ∷ cT) = ↑-Contra 0 (↦∈ContraEnv T∈Γ cT)
lookupContraEnv : ∀ {Γ n T} → env-lookup Γ n ≡ just T → ContraEnv Γ → Contra T
lookupContraEnv lk cT = ↦∈ContraEnv (lookup⇒↦∈ lk) cT
lookupContraBot : ∀ {Γ n} → ContraEnv Γ → ¬ env-lookup Γ n ≡ just ⊥
lookupContraBot all eq with lookupContraEnv eq all
... | ()
lookupContraBndBot : ∀ {Γ n S} → ContraEnv Γ → ¬ env-lookup Γ n ≡ just ⟨A: S ⋯ ⊥ ⟩
lookupContraBndBot all eq with lookupContraEnv eq all
... | ctt ()
lookupContraBndBnd : ∀ {Γ n T S U} → ContraEnv Γ →
¬ env-lookup Γ n ≡ just ⟨A: T ⋯ ⟨A: S ⋯ U ⟩ ⟩
lookupContraBndBnd all eq with lookupContraEnv eq all
... | ctt ()
lookupContra⊥Lb : ∀ {Γ n S U} → ContraEnv Γ →
env-lookup Γ n ≡ just ⟨A: S ⋯ U ⟩ → S ≡ ⊥
lookupContra⊥Lb all eq with lookupContraEnv eq all
... | ctt _ = refl
Typ-measure : Typ → ℕ
Typ-measure ⊤ = 1
Typ-measure ⊥ = 1
Typ-measure (_ ∙A) = 2
Typ-measure (Π S ∙ U) = 1 + Typ-measure S + Typ-measure U
Typ-measure ⟨A: S ⋯ U ⟩ = 1 + Typ-measure S + Typ-measure U
Typ-measure-↑ : ∀ T n → Typ-measure (T ↑ n) ≡ Typ-measure T
Typ-measure-↑ ⊤ n = refl
Typ-measure-↑ ⊥ n = refl
Typ-measure-↑ (x ∙A) n
rewrite ↑-var x n = refl
Typ-measure-↑ (Π S ∙ U) n
rewrite Typ-measure-↑ S n
| Typ-measure-↑ U (suc n) = refl
Typ-measure-↑ ⟨A: S ⋯ U ⟩ n
rewrite Typ-measure-↑ S n
| Typ-measure-↑ U n = refl
-- Definition of Invertible Contexts
--
-- As per Definition 9, we define a predicate for invertible contexts.
record InvertibleEnv (P : Env → Set) : Set where
field
no-⊥ : ∀ {Γ n} → P Γ → ¬ env-lookup Γ n ≡ just ⊥
no-bnd-⊥ : ∀ {Γ n S} → P Γ → ¬ env-lookup Γ n ≡ just ⟨A: S ⋯ ⊥ ⟩
no-bnd-bnd : ∀ {Γ n T S U} → P Γ → ¬ env-lookup Γ n ≡ just ⟨A: T ⋯ ⟨A: S ⋯ U ⟩ ⟩
⊥-lb : ∀ {Γ n S U} → P Γ → env-lookup Γ n ≡ just ⟨A: S ⋯ U ⟩ → S ≡ ⊥
contraInvertible : InvertibleEnv ContraEnv
contraInvertible = record
{ no-⊥ = lookupContraBot
; no-bnd-⊥ = lookupContraBndBot
; no-bnd-bnd = lookupContraBndBnd
; ⊥-lb = lookupContra⊥Lb
}
-- Properties of Invertible Contexts
--
-- Just by knowing the contexts being invertible, we can already derive many
-- properties of D<:. In the following module, we show that in invertible contexts,
-- inversion properties are recovered. For technical reasons, we leave the subtyping
-- judgment open in order to accomodate multiple definition of subtyping in D<:.
--
-- These properties are discussed in Section 4.4.
module InvertibleProperties {P : Env → Set}
(invertible : InvertibleEnv P)
(_⊢_<:_ : Env → Typ → Typ → Set) where
open InvertibleEnv invertible public
-- We define <:ᵢ to describe a fragment of <: under the restriction of invertible contexts.
infix 4 _⊢ᵢ_<:_
data _⊢ᵢ_<:_ : Env → Typ → Typ → Set where
ditop : ∀ {Γ T} → Γ ⊢ᵢ T <: ⊤
dibot : ∀ {Γ T} → Γ ⊢ᵢ ⊥ <: T
direfl : ∀ {Γ T} → Γ ⊢ᵢ T <: T
ditrans : ∀ {Γ S U} T →
(S<:T : Γ ⊢ᵢ S <: T) →
(T<:U : Γ ⊢ᵢ T <: U) →
Γ ⊢ᵢ S <: U
dibnd : ∀ {Γ S U S′ U′} →
(S′<:S : Γ ⊢ᵢ S′ <: S) →
(U<:U′ : Γ ⊢ᵢ U <: U′) →
Γ ⊢ᵢ ⟨A: S ⋯ U ⟩ <: ⟨A: S′ ⋯ U′ ⟩
diall : ∀ {Γ S U S′ U′} →
(S′<:S : Γ ⊢ᵢ S′ <: S) →
(U<:U′ : (Γ ‣ S′ !) ⊢ U <: U′) →
Γ ⊢ᵢ Π S ∙ U <: Π S′ ∙ U′
disel : ∀ {Γ n U} →
(T∈Γ : env-lookup Γ n ≡ just ⟨A: ⊥ ⋯ U ⟩) →
Γ ⊢ᵢ n ∙A <: U
module _ where
⊤<: : ∀ {Γ T} → Γ ⊢ᵢ ⊤ <: T → T ≡ ⊤
⊤<: ditop = refl
⊤<: direfl = refl
⊤<: (ditrans T S<:T T<:U) with ⊤<: S<:T
... | refl = ⊤<: T<:U
<:⊥ : ∀ {Γ T} → Γ ⊢ᵢ T <: ⊥ → P Γ → T ≡ ⊥
<:⊥ dibot pΓ = refl
<:⊥ direfl pΓ = refl
<:⊥ (ditrans T S<:T T<:U) pΓ with <:⊥ T<:U pΓ
... | refl = <:⊥ S<:T pΓ
<:⊥ (disel T∈Γ) pΓ = ⊥-elim (no-bnd-⊥ pΓ T∈Γ)
⟨A:⟩<: : ∀ {Γ T S U} → Γ ⊢ᵢ ⟨A: S ⋯ U ⟩ <: T → T ≡ ⊤ ⊎ ∃₂ (λ S′ U′ → T ≡ ⟨A: S′ ⋯ U′ ⟩)
⟨A:⟩<: ditop = inj₁ refl
⟨A:⟩<: direfl = inj₂ (-, -, refl)
⟨A:⟩<: (ditrans T S<:T T<:U) with ⟨A:⟩<: S<:T
... | inj₁ refl = inj₁ (⊤<: T<:U)
... | inj₂ (_ , _ , refl) with ⟨A:⟩<: T<:U
... | inj₁ eq = inj₁ eq
... | inj₂ (_ , _ , eq) = inj₂ (-, -, eq)
⟨A:⟩<: (dibnd D₁ D₂) = inj₂ (-, -, refl)
<:⟨A:⟩ : ∀ {Γ T S U} → Γ ⊢ᵢ T <: ⟨A: S ⋯ U ⟩ → P Γ →
T ≡ ⊥ ⊎ ∃₂ (λ S′ U′ → T ≡ ⟨A: S′ ⋯ U′ ⟩)
<:⟨A:⟩ dibot pΓ = inj₁ refl
<:⟨A:⟩ direfl pΓ = inj₂ (-, -, refl)
<:⟨A:⟩ (ditrans T S<:T T<:U) pΓ with <:⟨A:⟩ T<:U pΓ
... | inj₁ refl = inj₁ (<:⊥ S<:T pΓ)
... | inj₂ (S′ , U′ , refl) with <:⟨A:⟩ S<:T pΓ
... | inj₁ eq = inj₁ eq
... | inj₂ (S″ , U″ , eq) = inj₂ (S″ , U″ , eq)
<:⟨A:⟩ (dibnd D₁ D₂) pΓ = inj₂ (-, -, refl)
<:⟨A:⟩ (disel T∈Γ) pΓ = ⊥-elim (no-bnd-bnd pΓ T∈Γ)
⟨A:⟩<:⟨A:⟩ : ∀ {Γ S S′ U U′} → Γ ⊢ᵢ ⟨A: S ⋯ U ⟩ <: ⟨A: S′ ⋯ U′ ⟩ → P Γ →
Γ ⊢ᵢ S′ <: S × Γ ⊢ᵢ U <: U′
⟨A:⟩<:⟨A:⟩ direfl pΓ = direfl , direfl
⟨A:⟩<:⟨A:⟩ (ditrans T S<:T T<:U) pΓ with ⟨A:⟩<: S<:T
... | inj₁ refl with ⊤<: T<:U
... | ()
⟨A:⟩<:⟨A:⟩ (ditrans T S<:T T<:U) pΓ | inj₂ (_ , _ , refl)
with ⟨A:⟩<:⟨A:⟩ S<:T pΓ | ⟨A:⟩<:⟨A:⟩ T<:U pΓ
... | S″<:S , U<:U″ | S′<:S″ , U″<:U′ = ditrans _ S′<:S″ S″<:S , ditrans _ U<:U″ U″<:U′
⟨A:⟩<:⟨A:⟩ (dibnd D₁ D₂) pΓ = D₁ , D₂
infix 4 _reach_from_
data _reach_from_ : Env → Typ → ℕ → Set where
/_/ : ∀ {Γ n T} →
env-lookup Γ n ≡ just ⟨A: ⊥ ⋯ T ⟩ →
Γ reach T from n
_∷_ : ∀ {Γ n m T} →
env-lookup Γ n ≡ just ⟨A: ⊥ ⋯ m ∙A ⟩ →
Γ reach T from m →
Γ reach T from n
rf-concat : ∀ {Γ T m n} → Γ reach T from m → Γ reach m ∙A from n → Γ reach T from n
rf-concat m↝T / B∈Γ / = B∈Γ ∷ m↝T
rf-concat m↝T (B∈Γ ∷ n↝m∙A) = B∈Γ ∷ rf-concat m↝T n↝m∙A
∙A<: : ∀ {Γ n T} → Γ ⊢ᵢ n ∙A <: T →
T ≡ ⊤ ⊎ T ≡ n ∙A ⊎ ∃ λ T′ → Γ reach T′ from n × Γ ⊢ᵢ T′ <: T
∙A<: ditop = inj₁ refl
∙A<: direfl = inj₂ (inj₁ refl)
∙A<: (ditrans T S<:T T<:U) with ∙A<: S<:T
... | inj₁ refl = inj₁ (⊤<: T<:U)
... | inj₂ (inj₁ refl) = ∙A<: T<:U
... | inj₂ (inj₂ (T′ , n↝T′ , T′<:T)) = inj₂ (inj₂ (T′ , n↝T′ , ditrans _ T′<:T T<:U))
∙A<: (disel T∈Γ) = inj₂ (inj₂ (-, / T∈Γ / , direfl))
<:∙A : ∀ {Γ n T} → Γ ⊢ᵢ T <: n ∙A → P Γ →
T ≡ ⊥ ⊎
T ≡ n ∙A ⊎
∃ (λ m → T ≡ m ∙A × Γ reach n ∙A from m)
<:∙A dibot pΓ = inj₁ refl
<:∙A direfl pΓ = inj₂ (inj₁ refl)
<:∙A (ditrans T S<:T T<:U) pΓ with <:∙A T<:U pΓ
... | inj₁ refl = inj₁ (<:⊥ S<:T pΓ)
... | inj₂ (inj₁ refl) = <:∙A S<:T pΓ
... | inj₂ (inj₂ (m , refl , m↝n∙A))
with <:∙A S<:T pΓ
... | inj₁ refl = inj₁ refl
... | inj₂ (inj₁ refl) = inj₂ (inj₂ (-, refl , m↝n∙A))
... | inj₂ (inj₂ (m′ , refl , m′↝m∙A)) = inj₂ (inj₂ (-, refl , rf-concat m↝n∙A m′↝m∙A))
<:∙A (disel T∈Γ) pΓ = inj₂ (inj₂ (-, refl , / T∈Γ /))
Π<: : ∀ {Γ S U T} → Γ ⊢ᵢ Π S ∙ U <: T →
T ≡ ⊤ ⊎ ∃₂ (λ S′ U′ → T ≡ Π S′ ∙ U′)
Π<: ditop = inj₁ refl
Π<: direfl = inj₂ (-, -, refl)
Π<: (ditrans T S<:T T<:U) with Π<: S<:T
... | inj₁ refl = inj₁ (⊤<: T<:U)
... | inj₂ (_ , _ , refl) = Π<: T<:U
Π<: (diall D₁ D₂) = inj₂ (-, -, refl)
<:Π : ∀ {Γ S U T} → Γ ⊢ᵢ T <: Π S ∙ U → P Γ →
T ≡ ⊥ ⊎
∃ (λ n → T ≡ n ∙A) ⊎
∃₂ (λ S′ U′ → T ≡ Π S′ ∙ U′)
<:Π dibot pΓ = inj₁ refl
<:Π direfl pΓ = inj₂ (inj₂ (-, -, refl))
<:Π (ditrans T S<:T T<:U) pΓ with <:Π T<:U pΓ
... | inj₁ refl = inj₁ (<:⊥ S<:T pΓ)
... | inj₂ (inj₁ (_ , refl)) with <:∙A S<:T pΓ
... | inj₁ eq = inj₁ eq
... | inj₂ (inj₁ eq) = inj₂ (inj₁ (-, eq))
... | inj₂ (inj₂ (_ , eq , _)) = inj₂ (inj₁ (-, eq))
<:Π (ditrans T S<:T T<:U) pΓ | inj₂ (inj₂ (_ , _ , refl))
= <:Π S<:T pΓ
<:Π (diall D₁ D₂) pΓ = inj₂ (inj₂ (-, -, refl))
<:Π (disel T∈Γ) pΓ = inj₂ (inj₁ (-, refl))
-- Terms and Values
infix 6 var_ val_
infix 6 ⟨A=_⟩ _$$_
infixr 7 lt_inn_
infixr 6 Λ_∙_
mutual
-- Values
--
-- * (⟨A= T ⟩) represents a type tag ({A = T}).
-- * (Λ T ∙ t) represents a lambda expression (λ(x : T)t)
data Val : Set where
⟨A=_⟩ : (T : Typ) → Val
Λ_∙_ : (T : Typ) → (t : Trm) → Val
-- Terms
--
-- * (var x) represents a variable.
-- * (val v) represents a value as a term.
-- * (x $$ y) is an application of two variables.
-- * (lt t inn u) represents let binding (let x = t in u).
data Trm : Set where
var_ : ℕ → Trm
val_ : (v : Val) → Trm
_$$_ : (x y : ℕ) → Trm
lt_inn_ : Trm → Trm → Trm
-- substitution operation
record Subst (T : Set) : Set where
infixl 5 _[_/_]
field
_[_/_] : T → ℕ → ℕ → T
open Subst {{...}} public
infixl 5 _[_/_]ᵥ _[_/_]ₜ _[_/_]T
ℕsubst : ℕ → ℕ → ℕ → ℕ
ℕsubst x n m with x ≟ m
... | yes x≡m = n
... | no x≢m = x
instance
substℕ : Subst ℕ
substℕ = record { _[_/_] = ℕsubst }
_[_/_]T : Typ → ℕ → ℕ → Typ
⊤ [ n / m ]T = ⊤
⊥ [ n / m ]T = ⊥
x ∙A [ n / m ]T = (x [ n / m ]) ∙A
Π S ∙ U [ n / m ]T = Π S [ n / m ]T ∙ (U [ suc n / suc m ]T)
⟨A: S ⋯ U ⟩ [ n / m ]T = ⟨A: S [ n / m ]T ⋯ U [ n / m ]T ⟩
instance
substTyp : Subst Typ
substTyp = record { _[_/_] = _[_/_]T }
mutual
_[_/_]ᵥ : Val → ℕ → ℕ → Val
⟨A= T ⟩ [ n / m ]ᵥ = ⟨A= T [ n / m ] ⟩
Λ T ∙ t [ n / m ]ᵥ = Λ T [ n / m ] ∙ (t [ suc n / suc m ]ₜ)
_[_/_]ₜ : Trm → ℕ → ℕ → Trm
var x [ n / m ]ₜ = var (x [ n / m ])
val v [ n / m ]ₜ = val (v [ n / m ]ᵥ)
x $$ y [ n / m ]ₜ = (x [ n / m ]) $$ (y [ n / m ])
lt t inn u [ n / m ]ₜ = lt (t [ n / m ]ₜ) inn (u [ suc n / suc m ]ₜ)
instance
substVal : Subst Val
substVal = record { _[_/_] = _[_/_]ᵥ }
substTrm : Subst Trm
substTrm = record { _[_/_] = _[_/_]ₜ }
data Closed : ℕ → Typ → Set where
cl-⊤ : ∀ {n} → Closed n ⊤
cl-⊥ : ∀ {n} → Closed n ⊥
cl-∙A : ∀ {n m} (m≥n : m ≥ n) → Closed n (m ∙A)
cl-Π : ∀ {n S U} → Closed n S → Closed (suc n) U → Closed n (Π S ∙ U)
cl-⟨A⟩ : ∀ {n S U} → Closed n S → Closed n U → Closed n ⟨A: S ⋯ U ⟩
infix 7 _↓
_↓ : ∀ {n T} → Closed (suc n) T → Typ
cl-⊤ ↓ = ⊤
cl-⊥ ↓ = ⊥
cl-∙A {_} {m} m≥n ↓ = pred m ∙A
cl-Π S U ↓ = Π S ↓ ∙ (U ↓)
cl-⟨A⟩ S U ↓ = ⟨A: S ↓ ⋯ U ↓ ⟩
| 35.369565
| 105
| 0.43823
|
1c0144b77602d34e5ebaae47bd7a1cb2abb2312f
| 738
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Code related to vector equality over propositional equality that
-- makes use of heterogeneous equality
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Vec.Relation.Binary.Equality.Propositional.WithK
{a} {A : Set a} where
open import Data.Vec
open import Data.Vec.Relation.Binary.Equality.Propositional {A = A}
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality as H using (_≅_)
≋⇒≅ : ∀ {m n} {xs : Vec A m} {ys : Vec A n} →
xs ≋ ys → xs ≅ ys
≋⇒≅ p with length-equal p
... | refl = H.≡-to-≅ (≋⇒≡ p)
| 33.545455
| 72
| 0.554201
|
4a5f1ae1cf52e292b1920f6c8db6249724fdfb13
| 902
|
agda
|
Agda
|
src/Categories/Category/Construction/Wedges.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Category/Construction/Wedges.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Category/Construction/Wedges.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
open import Categories.Functor.Bifunctor using (Bifunctor)
module Categories.Category.Construction.Wedges {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
open import Level
open import Categories.Category.Core using (Category)
open import Categories.Diagram.Wedge F
Wedges : Category (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) e′
Wedges = record
{ Obj = Wedge
; _⇒_ = Wedge-Morphism
; _≈_ = λ M N → u M ≈ u N
; id = Wedge-id
; _∘_ = Wedge-Morphism-∘
; assoc = assoc
; sym-assoc = sym-assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identity²
; equiv = record { refl = Equiv.refl ; sym = Equiv.sym ; trans = Equiv.trans }
; ∘-resp-≈ = ∘-resp-≈
}
where
open Wedge-Morphism
open Category D
| 28.1875
| 108
| 0.637472
|
12dfae697ed40200283864f7df443ce14b65e156
| 323
|
agda
|
Agda
|
test/interaction/Issue5700.agda
|
thiagofelicissimo/agda
|
a0b3eea0c19c47ffbe2be525316311f5795d760d
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue5700.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue5700.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.List
open import Agda.Builtin.Nat
open import Agda.Builtin.Unit
open import Agda.Builtin.Reflection
pattern vArg x = arg (arg-info visible (modality relevant quantity-ω)) x
macro
macaroo : Term → TC ⊤
macaroo hole = unify hole (con (quote suc) (vArg unknown ∷ []))
test : Nat
test = macaroo
| 23.071429
| 72
| 0.736842
|
4db555d4c26d6033f3e007608576d6660cc52f5d
| 57
|
agda
|
Agda
|
test/Fail/Unsolved-meta-in-postulate.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Unsolved-meta-in-postulate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Unsolved-meta-in-postulate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Unsolved-meta-in-postulate where
postulate P : _
| 14.25
| 39
| 0.789474
|
12acfb527cbd86c9aa451e0dc5cc4f51aa52347e
| 947
|
agda
|
Agda
|
src/fot/LTC-PCF/Data/Nat.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/LTC-PCF/Data/Nat.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/LTC-PCF/Data/Nat.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Natural numbers (PCF version)
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LTC-PCF.Data.Nat where
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat.Rec
open import LTC-PCF.Data.Nat.Type public
infixl 7 _*_
infixl 6 _+_ _∸_
------------------------------------------------------------------------------
-- Addition with recursion on the first argument.
_+_ : D → D → D
m + n = rec m n (lam (λ _ → lam succ₁))
-- Subtraction with recursion on the second argument.
_∸_ : D → D → D
m ∸ n = rec n m (lam (λ _ → lam pred₁))
-- Multiplication with recursion on the first argument.
_*_ : D → D → D
m * n = rec m zero (lam (λ _ → lam (λ x → n + x)))
| 30.548387
| 78
| 0.455121
|
dc76b1d957c5e12daeaf369056f7bebebbae288c
| 3,477
|
agda
|
Agda
|
test/Succeed/ReflectTC.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/ReflectTC.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/ReflectTC.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | null | null | null |
-- Building some simple tactics using the reflected type checking monad.
module _ where
open import Common.Reflection
open import Common.Prelude hiding (_>>=_)
open import Common.Equality
open import Agda.Builtin.Sigma
-- Some helpers --
quotegoal : (Type → Tactic) → Tactic
quotegoal tac hole =
inferType hole >>= λ goal →
reduce goal >>= λ goal →
tac goal hole
case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B
case x of f = f x
replicateTC : {A : Set} → Nat → TC A → TC (List A)
replicateTC zero m = returnTC []
replicateTC (suc n) m = m >>= λ x → replicateTC n m >>= λ xs → returnTC (x ∷ xs)
mapTC! : ∀ {A : Set} → (A → TC ⊤) → List A → TC ⊤
mapTC! f [] = returnTC _
mapTC! f (x ∷ xs) = f x >>= λ _ → mapTC! f xs
mapTC!r : ∀ {A} → (A → TC ⊤) → List A → TC ⊤
mapTC!r f [] = returnTC _
mapTC!r f (x ∷ xs) = mapTC! f xs >>= λ _ → f x
visibleArity : QName → TC Nat
visibleArity q = getType q >>= λ t → returnTC (typeArity t)
where
typeArity : Type → Nat
typeArity (pi (arg (argInfo visible _) _) (abs _ b)) = suc (typeArity b)
typeArity (pi _ (abs _ b)) = typeArity b
typeArity _ = 0
newMeta! : TC Term
newMeta! = newMeta unknown
absurdLam : Term
absurdLam = extLam (absurdClause
(("()" , arg (argInfo visible relevant) unknown) ∷ [])
(arg (argInfo visible relevant) absurd ∷ [])
∷ []) []
-- Simple assumption tactic --
assumption-tac : Nat → Nat → Tactic
assumption-tac x 0 _ = typeError (strErr "No assumption matched" ∷ [])
assumption-tac x (suc n) hole =
catchTC (unify hole (var x []))
(assumption-tac (suc x) n hole)
macro
assumption : Tactic
assumption hole = getContext >>= λ Γ → assumption-tac 0 (length Γ) hole
test-assumption : ∀ {A B : Set} → A → B → A
test-assumption x y = assumption
test-assumption₂ : ∀ {A B : Set} → A → B → _
test-assumption₂ x y = assumption -- will pick y
-- Solving a goal using only constructors --
tryConstructors : Nat → List QName → Tactic
constructors-tac : Nat → Type → Tactic
constructors-tac zero _ _ = typeError (strErr "Search depth exhausted" ∷ [])
constructors-tac (suc n) (def d vs) hole =
getDefinition d >>= λ def →
case def of λ
{ (dataDef _ cs) → tryConstructors n cs hole
; _ → returnTC _ }
constructors-tac _ (pi a b) hole = give absurdLam hole
constructors-tac _ _ hole = returnTC _
tryConstructors n [] hole = typeError (strErr "No matching constructor term" ∷ [])
tryConstructors n (c ∷ cs) hole =
visibleArity c >>= λ ar →
catchTC (replicateTC ar newMeta! >>= λ vs →
unify hole (con c (map (arg (argInfo visible relevant)) vs)) >>= λ _ →
mapTC!r (quotegoal (constructors-tac n)) vs)
(tryConstructors n cs hole)
macro
constructors : Tactic
constructors = quotegoal (constructors-tac 10)
data Any {A : Set} (P : A → Set) : List A → Set where
zero : ∀ {x xs} → P x → Any P (x ∷ xs)
suc : ∀ {x xs} → Any P xs → Any P (x ∷ xs)
infix 1 _∈_
_∈_ : ∀ {A : Set} → A → List A → Set
x ∈ xs = Any (x ≡_) xs
data Dec (A : Set) : Set where
yes : A → Dec A
no : (A → ⊥) → Dec A
test₁ : 3 ∈ 1 ∷ 2 ∷ 3 ∷ []
test₁ = constructors
test₂ : Dec (2 + 3 ≡ 5)
test₂ = constructors
test₃ : Dec (2 + 2 ≡ 5)
test₃ = constructors
data Singleton (n : Nat) : Set where
it : (m : Nat) → m ≡ n → Singleton n
test₄ : Singleton 5
test₄ = constructors -- this works because we solve goals right to left (picking refl before m)
| 29.218487
| 95
| 0.609146
|
4a3061ba8d64e1a1795e270532392032405d5bf6
| 2,650
|
agda
|
Agda
|
prototyping/Luau/Syntax/ToString.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
prototyping/Luau/Syntax/ToString.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
prototyping/Luau/Syntax/ToString.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
module Luau.Syntax.ToString where
open import Agda.Builtin.Float using (primShowFloat)
open import Luau.Syntax using (Block; Stat; Expr; VarDec; FunDec; nil; var; var_∈_; addr; _$_; function_is_end; return; local_←_; _∙_; done; block_is_end; _⟨_⟩; _⟨_⟩∈_; number; BinaryOperator; +; -; *; /; binexp)
open import FFI.Data.String using (String; _++_)
open import Luau.Addr.ToString using (addrToString)
open import Luau.Type.ToString using (typeToString)
open import Luau.Var.ToString using (varToString)
varDecToString : ∀ {a} → VarDec a → String
varDecToString (var x) = varToString x
varDecToString (var x ∈ T) = varToString x ++ " : " ++ typeToString T
funDecToString : ∀ {a} → FunDec a → String
funDecToString ("" ⟨ x ⟩∈ T) = "function(" ++ varDecToString x ++ "): " ++ typeToString T
funDecToString ("" ⟨ x ⟩) = "function(" ++ varDecToString x ++ ")"
funDecToString (f ⟨ x ⟩∈ T) = "function " ++ varToString f ++ "(" ++ varDecToString x ++ "): " ++ typeToString T
funDecToString (f ⟨ x ⟩) = "function " ++ varToString f ++ "(" ++ varDecToString x ++ ")"
binOpToString : BinaryOperator → String
binOpToString + = "+"
binOpToString - = "-"
binOpToString * = "*"
binOpToString / = "/"
exprToString′ : ∀ {a} → String → Expr a → String
statToString′ : ∀ {a} → String → Stat a → String
blockToString′ : ∀ {a} → String → Block a → String
exprToString′ lb nil =
"nil"
exprToString′ lb (addr a) =
addrToString(a)
exprToString′ lb (var x) =
varToString(x)
exprToString′ lb (M $ N) =
(exprToString′ lb M) ++ "(" ++ (exprToString′ lb N) ++ ")"
exprToString′ lb (function F is B end) =
funDecToString F ++ lb ++
" " ++ (blockToString′ (lb ++ " ") B) ++ lb ++
"end"
exprToString′ lb (block b is B end) =
"(" ++ b ++ "()" ++ lb ++
" " ++ (blockToString′ (lb ++ " ") B) ++ lb ++
"end)()"
exprToString′ lb (number x) = primShowFloat x
exprToString′ lb (binexp x op y) = exprToString′ lb x ++ " " ++ binOpToString op ++ " " ++ exprToString′ lb y
statToString′ lb (function F is B end) =
"local " ++ funDecToString F ++ lb ++
" " ++ (blockToString′ (lb ++ " ") B) ++ lb ++
"end"
statToString′ lb (local x ← M) =
"local " ++ varDecToString x ++ " = " ++ (exprToString′ lb M)
statToString′ lb (return M) =
"return " ++ (exprToString′ lb M)
blockToString′ lb (S ∙ done) = statToString′ lb S
blockToString′ lb (S ∙ B) = statToString′ lb S ++ lb ++ blockToString′ lb B
blockToString′ lb (done) = ""
exprToString : ∀ {a} → Expr a → String
exprToString = exprToString′ "\n"
statToString : ∀ {a} → Stat a → String
statToString = statToString′ "\n"
blockToString : ∀ {a} → Block a → String
blockToString = blockToString′ "\n"
| 37.857143
| 212
| 0.629057
|
50c327ac52fdef87e03cb1ac027f1b4bea1963bb
| 276
|
agda
|
Agda
|
cruft/int-tests.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
cruft/int-tests.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
cruft/int-tests.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module int-tests where
open import int
open import eq
open import product
three : ℤ
three = , next next unit{pos}
-two : ℤ
-two = , next unit{neg}
one = -two +ℤ three
one-lem : one ≡ ,_ { a = nonzero pos } unit
one-lem = refl
six = three +ℤ three
-four = -two +ℤ -two
| 12.545455
| 43
| 0.641304
|
23eab2a3262d9a65b242eabef28b2b667eeea423
| 6,760
|
agda
|
Agda
|
src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 9
|
2015-09-13T17:46:41.000Z
|
2020-03-14T14:21:08.000Z
|
src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 4
|
2018-11-14T02:32:28.000Z
|
2021-01-04T20:57:19.000Z
|
src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 3
|
2017-12-03T14:52:09.000Z
|
2022-03-12T11:40:03.000Z
|
open import Data.Product using ( proj₁ ; proj₂ )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( refl )
open import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind ; _*_ )
open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ )
open import Web.Semantic.DL.ABox.Model using
( _⊨a_ ; on-bnode ; bnodes ; _,_ ; ⊨a-resp-≲ )
open import Web.Semantic.DL.Category.Composition using ( _∙_ )
open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using
( compose-left ; compose-right ; compose-resp-⊨a )
open import Web.Semantic.DL.Category.Properties.Tensor.Lemmas using
( tensor-up ; tensor-down ; tensor-resp-⊨a )
open import Web.Semantic.DL.Category.Object using ( Object ; IN ; fin )
open import Web.Semantic.DL.Category.Morphism using
( _⇒_ ; BN ; impl ; _⊑_ ; _≣_ ; _,_ )
open import Web.Semantic.DL.Category.Tensor using ( _⊗_ ; _⟨⊗⟩_ )
open import Web.Semantic.DL.Category.Unit using ( I )
open import Web.Semantic.DL.Category.Wiring using
( wires-≈ ; wires-≈⁻¹ ; assoc )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using ( TBox )
open import Web.Semantic.DL.TBox.Interp using
( Δ ; _⊨_≈_ ; ≈-refl ; ≈-refl′ ; ≈-sym )
open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl )
open import Web.Semantic.Util using
( _∘_ ; False ; ⊎-assoc ; ⊎-assoc⁻¹
; _⊕_⊕_ ; inode ; bnode ; enode ; left ; right ; up ; down )
module Web.Semantic.DL.Category.Properties.Tensor.AssocNatural
{Σ : Signature} {S T : TBox Σ} where
assoc-natural : ∀ {A₁ A₂ A₃ B₁ B₂ B₃ : Object S T}
(F₁ : A₁ ⇒ B₁) (F₂ : A₂ ⇒ B₂) (F₃ : A₃ ⇒ B₃) →
(((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃ ≣
assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)))
assoc-natural {A₁} {A₂} {A₃} {B₁} {B₂} {B₃} F₁ F₂ F₃ = (LHS⊑RHS , RHS⊑LHS) where
LHS⊑RHS : ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃ ⊑
assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃))
LHS⊑RHS J J⊨STA J⊨LHS = (f , J⊨RHS) where
f : (False ⊕ (IN A₁ ⊎ (IN A₂ ⊎ IN A₃)) ⊕ (BN F₁ ⊎ (BN F₂ ⊎ BN F₃))) → Δ ⌊ J ⌋
f (inode ())
f (bnode x) = ind J (inode (⊎-assoc⁻¹ x))
f (enode v) = ind J (bnode (inode (⊎-assoc⁻¹ v)))
lemma₁ : ∀ x →
⌊ J ⌋ ⊨ ind J (left (up (up x))) ≈
on-bnode f (ind J) (right (up x))
lemma₁ (inode x) = ≈-refl ⌊ J ⌋
lemma₁ (bnode v) = ≈-refl ⌊ J ⌋
lemma₁ (enode y) = wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₁ y))
(compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)
lemma₂ : ∀ x →
⌊ J ⌋ ⊨ ind J (left (up (down x))) ≈
on-bnode f (ind J) (right (down (up x)))
lemma₂ (inode x) = ≈-refl ⌊ J ⌋
lemma₂ (bnode v) = ≈-refl ⌊ J ⌋
lemma₂ (enode y) = wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₂ (inj₁ y)))
(compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)
lemma₃ : ∀ x →
⌊ J ⌋ ⊨ ind J (left (down x)) ≈
on-bnode f (ind J) (right (down (down x)))
lemma₃ (inode x) = ≈-refl ⌊ J ⌋
lemma₃ (bnode v) = ≈-refl ⌊ J ⌋
lemma₃ (enode y) = wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₂ (inj₂ y)))
(compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)
J⊨RHS : bnodes J f ⊨a impl (assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)))
J⊨RHS = compose-resp-⊨a (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) (bnodes J f)
(wires-≈⁻¹ ⊎-assoc⁻¹ (λ x → ≈-refl ⌊ J ⌋) (proj₁ (fin (A₁ ⊗ (A₂ ⊗ A₃)))))
(tensor-resp-⊨a F₁ (F₂ ⟨⊗⟩ F₃) (right * bnodes J f)
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁)
(tensor-up F₁ F₂ (up * left * J)
(tensor-up (F₁ ⟨⊗⟩ F₂) F₃ (left * J)
(compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS))))
(tensor-resp-⊨a F₂ F₃ (down * right * bnodes J f)
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂)
(tensor-down F₁ F₂ (up * left * J)
(tensor-up (F₁ ⟨⊗⟩ F₂) F₃ (left * J)
(compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS))))
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₃) (impl F₃)
(tensor-down (F₁ ⟨⊗⟩ F₂) F₃ (left * J)
(compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)))))
RHS⊑LHS : assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) ⊑
((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃
RHS⊑LHS J J⊨STA J⊨RHS = (f , J⊨LHS) where
f : (((BN F₁ ⊎ BN F₂) ⊎ BN F₃) ⊕ ((IN B₁ ⊎ IN B₂) ⊎ IN B₃) ⊕ False) → Δ ⌊ J ⌋
f (inode v) = ind J (bnode (enode (⊎-assoc v)))
f (bnode y) = ind J (enode (⊎-assoc y))
f (enode ())
lemma₀ : ∀ x →
⌊ J ⌋ ⊨ ind J (enode (⊎-assoc (⊎-assoc⁻¹ x))) ≈ ind J (enode x)
lemma₀ (inj₁ x) = ≈-refl ⌊ J ⌋
lemma₀ (inj₂ (inj₁ x)) = ≈-refl ⌊ J ⌋
lemma₀ (inj₂ (inj₂ y)) = ≈-refl ⌊ J ⌋
lemma₁ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (up x)) ≈
on-bnode f (ind J) (left (up (up x)))
lemma₁ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₁ x))
(compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))
lemma₁ (bnode v) = ≈-refl ⌊ J ⌋
lemma₁ (enode y) = ≈-refl ⌊ J ⌋
lemma₂ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (down (up x))) ≈
on-bnode f (ind J) (left (up (down x)))
lemma₂ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₂ (inj₁ x)))
(compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))
lemma₂ (bnode v) = ≈-refl ⌊ J ⌋
lemma₂ (enode y) = ≈-refl ⌊ J ⌋
lemma₃ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (down (down x))) ≈
on-bnode f (ind J) (left (down x))
lemma₃ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹
(proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₂ (inj₂ x)))
(compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))
lemma₃ (bnode v) = ≈-refl ⌊ J ⌋
lemma₃ (enode y) = ≈-refl ⌊ J ⌋
J⊨LHS : bnodes J f ⊨a impl (((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃)
J⊨LHS = compose-resp-⊨a ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) (bnodes J f)
(tensor-resp-⊨a (F₁ ⟨⊗⟩ F₂) F₃ (left * bnodes J f)
(tensor-resp-⊨a F₁ F₂ (up * left * bnodes J f)
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁)
(tensor-up F₁ (F₂ ⟨⊗⟩ F₃) (right * J)
(compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)))
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂)
(tensor-up F₂ F₃ (down * right * J)
(tensor-down F₁ (F₂ ⟨⊗⟩ F₃) (right * J)
(compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)))))
(⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₃) (impl F₃)
(tensor-down F₂ F₃ (down * right * J)
(tensor-down F₁ (F₂ ⟨⊗⟩ F₃) (right * J)
(compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)))))
(wires-≈⁻¹ ⊎-assoc⁻¹ lemma₀ (proj₁ (fin (B₁ ⊗ (B₂ ⊗ B₃)))))
| 46.30137
| 82
| 0.513462
|
a1dc82bed38362aa973f43a5acc0ac4f71f44dab
| 2,183
|
agda
|
Agda
|
src/even.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
src/even.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
src/even.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
module even where
open import Data.Nat
open import Data.Nat.Properties
open import Data.Empty
open import Data.Unit using (⊤ ; tt)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Definitions
open import nat
open import logic
even : (n : ℕ ) → Set
even zero = ⊤
even (suc zero) = ⊥
even (suc (suc n)) = even n
even? : (n : ℕ ) → Dec ( even n )
even? zero = yes tt
even? (suc zero) = no (λ ())
even? (suc (suc n)) = even? n
n+even : {n m : ℕ } → even n → even m → even ( n + m )
n+even {zero} {zero} tt tt = tt
n+even {zero} {suc m} tt em = em
n+even {suc (suc n)} {m} en em = n+even {n} {m} en em
n*even : {m n : ℕ } → even n → even ( m * n )
n*even {zero} {n} en = tt
n*even {suc m} {n} en = n+even {n} {m * n} en (n*even {m} {n} en)
even*n : {n m : ℕ } → even n → even ( n * m )
even*n {n} {m} en = subst even (*-comm m n) (n*even {m} {n} en)
record Even (i : ℕ) : Set where
field
j : ℕ
is-twice : i ≡ 2 * j
e2 : (i : ℕ) → even i → Even i
e2 zero en = record { j = 0 ; is-twice = refl }
e2 (suc (suc i)) en = record { j = suc (Even.j (e2 i en )) ; is-twice = e21 } where
e21 : suc (suc i) ≡ 2 * suc (Even.j (e2 i en))
e21 = begin
suc (suc i) ≡⟨ cong (λ k → suc (suc k)) (Even.is-twice (e2 i en)) ⟩
suc (suc (2 * Even.j (e2 i en))) ≡⟨ sym (*-distribˡ-+ 2 1 _) ⟩
2 * suc (Even.j (e2 i en)) ∎ where open ≡-Reasoning
record Odd (i : ℕ) : Set where
field
j : ℕ
is-twice : i ≡ suc (2 * j )
odd2 : (i : ℕ) → ¬ even i → even (suc i)
odd2 zero ne = ⊥-elim ( ne tt )
odd2 (suc zero) ne = tt
odd2 (suc (suc i)) ne = odd2 i ne
odd3 : (i : ℕ) → ¬ even i → Odd i
odd3 zero ne = ⊥-elim ( ne tt )
odd3 (suc zero) ne = record { j = 0 ; is-twice = refl }
odd3 (suc (suc i)) ne = record { j = Even.j (e2 (suc i) (odd2 i ne)) ; is-twice = odd31 } where
odd31 : suc (suc i) ≡ suc (2 * Even.j (e2 (suc i) (odd2 i ne)))
odd31 = begin
suc (suc i) ≡⟨ cong suc (Even.is-twice (e2 (suc i) (odd2 i ne))) ⟩
suc (2 * (Even.j (e2 (suc i) (odd2 i ne)))) ∎ where open ≡-Reasoning
odd4 : (i : ℕ) → even i → ¬ even ( suc i )
odd4 (suc (suc i)) en en1 = odd4 i en en1
| 30.319444
| 96
| 0.54787
|
dc97001b86c6b4f57f2db9216b285a9d91c5c66b
| 2,968
|
agda
|
Agda
|
proglangs-learning/Agda/sv20/exam1.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
proglangs-learning/Agda/sv20/exam1.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | 4
|
2020-03-10T19:20:21.000Z
|
2021-06-07T15:39:48.000Z
|
proglangs-learning/Agda/sv20/exam1.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
module sv20.exam1 where
open import Data.Product using (∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Function.Base using (_∘_)
record _⇔_ (A B : Set) : Set where
field
to : A → B
from : B → A
-- An idiom that makes things slightly more readable (sometimes)
case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B
case x of f = f x
-- Exam starts from here:
-- 1.
first : ∀ {Object : Set} {P Q : Object → Set}
→ (∃[ x ] (P x ⊎ Q x)) ⇔ (∃[ x ] (P x) ⊎ ∃[ x ] (Q x))
-- We prove each side separately of the bijection separately. If we are able to
-- prove both ways, we will have proved the bijection
first =
record { to = to ; from = from }
where
-- First, we prove that (∃[ x ] (P x ⊎ Q x)) → (∃[ x ] (P x) ⊎ ∃[ x ] (Q x))
to : ∀ {Object : Set} {P Q : Object → Set}
→ (∃[ x ] (P x ⊎ Q x)) → (∃[ x ] (P x) ⊎ ∃[ x ] (Q x))
-- Proof
--to ⟨ x , inj₁ px ⟩ = inj₁ ⟨ x , px ⟩
--to ⟨ x , inj₂ qx ⟩ = inj₂ ⟨ x , qx ⟩
--
-- Proof explained:
to ∃x-px⊎qx =
let
⟨ x , px⊎qx ⟩ = ∃x-px⊎qx -- From ∃[ x ] (P x ⊎ Q x) we find an element x that fullfills (P x ⊎ Q x)
in case px⊎qx of -- P x ⊎ Q x indicates two possible cases, either
λ { (inj₁ px) → inj₁ ⟨ x , px ⟩ -- P x is true, and so ∃[ x ] (P x)
; (inj₂ qx) → inj₂ ⟨ x , qx ⟩ -- or, Q x is true, and so ∃[ x ] (Q x)
}
-- Now, we prove the inverse (∃[ x ] (P x) ⊎ ∃[ x ] (Q x)) → (∃[ x ] (P x ⊎ Q x))
from : ∀ {Object : Set} {P Q : Object → Set}
→ (∃[ x ] (P x) ⊎ ∃[ x ] (Q x)) → (∃[ x ] (P x ⊎ Q x))
-- Proof
--from (inj₁ ⟨ x , px ⟩) = ⟨ x , inj₁ px ⟩
--from (inj₂ ⟨ x , qx ⟩) = ⟨ x , inj₂ qx ⟩
--
-- Proof explained:
-- There are two possible properties that get fulfilled, either
from (inj₁ ⟨ x , px ⟩) = ⟨ x , inj₁ px ⟩ -- ∃[ x ] (P x) gets fulfilled
from (inj₂ ⟨ x , qx ⟩) = ⟨ x , inj₂ qx ⟩ -- or, ∃[ x ] (Q x) gets fulfilled
-- 2.
second : ∀ {Object : Set} {P Q : Object → Set} {_R_ : Object → Object → Set}
→ ∃[ x ] (P x)
→ ∃[ x ] (Q x)
→ (∀ x → P x → ∀ y → Q y → x R y)
---------------------------------
→ ∃[ x ] ∃[ y ] (x R y)
--Proof:
--second ⟨ x₁ , px₁ ⟩ ⟨ x₂ , qx₂ ⟩ ∀x→px→∀y→qy→xry = ⟨ x₁ , ⟨ x₂ , ∀x→px→∀y→qy→xry x₁ px₁ x₂ qx₂ ⟩ ⟩
--
--Proof explained:
second ∃x-px ∃x-qx ∀x→px→∀y→qy→xry =
let
⟨ x₁ , px₁ ⟩ = ∃x-px -- If we have a value from ∃[ x ] (P x), we can get an x₁ that fulfills P
⟨ x₂ , qx₂ ⟩ = ∃x-qx -- and there is a value x₂ that fulfills Q
px→∀y→qy→xry = ∀x→px→∀y→qy→xry x₁ -- For all x it is true that (P x → ∀ y → Q y → x R y), including x₁
∀y→qy→xry = px→∀y→qy→xry px₁ -- P is fulfilled by x₁
xry = ∀y→qy→xry x₂ qx₂ -- In a similar way, x₂ is a value that fulfills Qy, so we can instanciate (∀ y → Q y → x₁ R y) into (x₁ R x₂)
in ⟨ x₁ , ⟨ x₂ , xry ⟩ ⟩ -- So, we know there is an element x₁ and an element x₂ for which x₁ R x₂ is true
| 39.573333
| 150
| 0.488208
|
239c394f3c17122d99d2f8ffa68c72e3e36e3fd7
| 1,187
|
agda
|
Agda
|
LibraBFT/Impl/Consensus/Network/Properties.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 4
|
2020-12-16T19:43:41.000Z
|
2021-12-18T19:24:05.000Z
|
LibraBFT/Impl/Consensus/Network/Properties.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 72
|
2021-02-04T05:04:33.000Z
|
2022-03-25T05:36:11.000Z
|
LibraBFT/Impl/Consensus/Network/Properties.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 6
|
2020-12-16T19:43:52.000Z
|
2022-02-18T01:04:32.000Z
|
{- 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
-}
open import LibraBFT.Base.Types
open import LibraBFT.Concrete.Records
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.NetworkMsg
open import LibraBFT.ImplShared.Util.Util
open import LibraBFT.Impl.Consensus.Network
open import LibraBFT.Impl.Properties.Util
open import LibraBFT.Prelude
open import Optics.All
module LibraBFT.Impl.Consensus.Network.Properties where
open Invariants
module processProposalSpec (proposal : ProposalMsg) (myEpoch : Epoch) (vv : ValidatorVerifier) where
postulate -- TODO-2: Refine contract
-- We also need to know that the the proposal message was successfully
-- checked by `ProposalMsg.verify`
contract
: case (processProposal proposal myEpoch vv) of λ where
(Left _) → Unit
(Right _) → proposal ^∙ pmProposal ∙ bEpoch ≡ myEpoch
× BlockId-correct (proposal ^∙ pmProposal)
| 37.09375
| 111
| 0.757372
|
a1f2716d64f2f68dbe698ccd3bb08d11010a6b5d
| 2,849
|
agda
|
Agda
|
Cubical/Functions/Surjection.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Functions/Surjection.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Functions/Surjection.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Functions.Surjection where
open import Cubical.Core.Everything
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Functions.Embedding
open import Cubical.HITs.PropositionalTruncation as PropTrunc
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : Type ℓ'
f : A → B
isSurjection : (A → B) → Type _
isSurjection f = ∀ b → ∥ fiber f b ∥
_↠_ : Type ℓ → Type ℓ' → Type (ℓ-max ℓ ℓ')
A ↠ B = Σ[ f ∈ (A → B) ] isSurjection f
section→isSurjection : {g : B → A} → section f g → isSurjection f
section→isSurjection {g = g} s b = ∣ g b , s b ∣
isSurjectionIsProp : isProp (isSurjection f)
isSurjectionIsProp = isPropΠ λ _ → squash
isEquiv→isSurjection : isEquiv f → isSurjection f
isEquiv→isSurjection e b = ∣ fst (equiv-proof e b) ∣
isEquiv→isEmbedding×isSurjection : isEquiv f → isEmbedding f × isSurjection f
isEquiv→isEmbedding×isSurjection e = isEquiv→isEmbedding e , isEquiv→isSurjection e
isEmbedding×isSurjection→isEquiv : isEmbedding f × isSurjection f → isEquiv f
equiv-proof (isEmbedding×isSurjection→isEquiv {f = f} (emb , sur)) b =
inhProp→isContr (PropTrunc.rec fib' (λ x → x) fib) fib'
where
hpf : hasPropFibers f
hpf = isEmbedding→hasPropFibers emb
fib : ∥ fiber f b ∥
fib = sur b
fib' : isProp (fiber f b)
fib' = hpf b
isEquiv≃isEmbedding×isSurjection : isEquiv f ≃ isEmbedding f × isSurjection f
isEquiv≃isEmbedding×isSurjection = isoToEquiv (iso
isEquiv→isEmbedding×isSurjection
isEmbedding×isSurjection→isEquiv
(λ _ → isOfHLevelΣ 1 isEmbeddingIsProp (\ _ → isSurjectionIsProp) _ _)
(λ _ → isPropIsEquiv _ _ _))
isPropIsSurjection : isProp (isSurjection f)
isPropIsSurjection = isPropΠ λ _ → propTruncIsProp
-- obs: for epi⇒surjective to go through we require a stronger
-- hypothesis that one would expect:
-- f must cancel functions from a higher universe.
rightCancellable : (f : A → B) → Type _
rightCancellable {ℓ} {A} {ℓ'} {B} f = ∀ {C : Type (ℓ-suc (ℓ-max ℓ ℓ'))}
→ ∀ (g g' : B → C) → (∀ x → g (f x) ≡ g' (f x)) → ∀ y → g y ≡ g' y
-- This statement is in Mac Lane & Moerdijk (page 143, corollary 5).
epi⇒surjective : (f : A → B) → rightCancellable f → isSurjection f
epi⇒surjective f rc y = transport (fact₂ y) tt*
where hasPreimage : (A → B) → B → _
hasPreimage f y = ∥ fiber f y ∥
fact₁ : ∀ x → Unit* ≡ hasPreimage f (f x)
fact₁ x = hPropExt isPropUnit*
propTruncIsProp
(λ _ → ∣ (x , refl) ∣)
(λ _ → tt*)
fact₂ : ∀ y → Unit* ≡ hasPreimage f y
fact₂ = rc _ _ fact₁
| 33.916667
| 83
| 0.665497
|
df4660256a50e711c9f5de5f729a1b3f5b5f956e
| 11,095
|
agda
|
Agda
|
Fields/CauchyCompletion/Group.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Fields/CauchyCompletion/Group.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Fields/CauchyCompletion/Group.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Groups.Definition
open import Groups.Lemmas
open import Groups.Homomorphisms.Definition
open import Fields.Fields
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
module Fields.CauchyCompletion.Group {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where
open Setoid S
open SetoidTotalOrder (TotallyOrderedRing.total order)
open SetoidPartialOrder pOrder
open Equivalence eq
open TotallyOrderedRing order
open Field F
open Group (Ring.additiveGroup R)
open Ring R
open import Rings.Orders.Total.Lemmas order
open import Rings.Orders.Total.AbsoluteValue order
open import Fields.CauchyCompletion.Definition order F
open import Fields.CauchyCompletion.Addition order F
open import Fields.CauchyCompletion.Setoid order F
abstract
+CCommutative : (a b : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid (a +C b) (b +C a)
+CCommutative a b ε 0<e = 0 , ans
where
foo : {x y : A} → (x + y) + inverse (y + x) ∼ 0G
foo = Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) (inverseWellDefined additiveGroup groupIsAbelian)) invRight
ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (a +C b)) (map inverse (CauchyCompletion.elts (b +C a)))) m) < ε
ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (a +C b)) (map inverse (CauchyCompletion.elts (b +C a))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _+_ {m} | equalityCommutative (mapAndIndex (apply _+_ (CauchyCompletion.elts b) (CauchyCompletion.elts a)) inverse m) | indexAndApply (CauchyCompletion.elts b) (CauchyCompletion.elts a) _+_ {m} = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ foo) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
private
abstract
additionWellDefinedLeft : (a b c : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid a b → Setoid._∼_ cauchyCompletionSetoid (a +C c) (b +C c)
additionWellDefinedLeft record { elts = a ; converges = aConv } record { elts = b ; converges = bConv } record { elts = c ; converges = cConv } a=b ε 0<e with a=b ε 0<e
... | Na-b , prA-b = Na-b , ans
where
ans : {m : ℕ} → Na-b <N m → abs (index (apply _+_ (apply _+_ a c) (map inverse (apply _+_ b c))) m) < ε
ans {m} mBig with prA-b {m} mBig
... | bl rewrite indexAndApply (apply _+_ a c) (map inverse (apply _+_ b c)) _+_ {m} | indexAndApply a c _+_ {m} | equalityCommutative (mapAndIndex (apply _+_ b c) inverse m) | indexAndApply b c _+_ {m} = <WellDefined (absWellDefined _ _ t) (Equivalence.reflexive eq) bl
where
t : index (apply _+_ a (map inverse b)) m ∼ ((index a m + index c m) + inverse (index b m + index c m))
t rewrite indexAndApply a (map inverse b) _+_ {m} | equalityCommutative (mapAndIndex b inverse m) = Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.symmetric eq identLeft) (+WellDefined (Equivalence.symmetric eq invRight) (Equivalence.reflexive eq))) (Equivalence.symmetric eq +Associative)) (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (invContravariant additiveGroup))))) (+Associative {index a m})
additionPreservedLeft : {a b : A} {c : CauchyCompletion} → (a ∼ b) → Setoid._∼_ cauchyCompletionSetoid (injection a +C c) (injection b +C c)
additionPreservedLeft {a} {b} {c} a=b = additionWellDefinedLeft (injection a) (injection b) c (injectionPreservesSetoid a b a=b)
additionPreservedRight : {a b : A} {c : CauchyCompletion} → (a ∼ b) → Setoid._∼_ cauchyCompletionSetoid (c +C injection a) (c +C injection b)
additionPreservedRight {a} {b} {c} a=b = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {c +C injection a} {injection a +C c} {c +C injection b} (+CCommutative c (injection a)) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {injection a +C c} {injection b +C c} {c +C injection b} (additionPreservedLeft {a} {b} {c} a=b) (+CCommutative (injection b) c))
additionPreserved : {a b c d : A} → (a ∼ b) → (c ∼ d) → Setoid._∼_ cauchyCompletionSetoid (injection a +C injection c) (injection b +C injection d)
additionPreserved {a} {b} {c} {d} a=b c=d = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {injection a +C injection c} {injection a +C injection d} {injection b +C injection d} (additionPreservedRight {c} {d} {injection a} c=d) (additionPreservedLeft {a} {b} {injection d} a=b)
additionWellDefinedRight : (a b c : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid b c → Setoid._∼_ cauchyCompletionSetoid (a +C b) (a +C c)
additionWellDefinedRight a b c b=c = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {a +C b} {b +C a} {a +C c} (+CCommutative a b) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {b +C a} {c +C a} {a +C c} (additionWellDefinedLeft b c a b=c) (+CCommutative c a))
additionWellDefined : {a b c d : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid a b → Setoid._∼_ cauchyCompletionSetoid c d → Setoid._∼_ cauchyCompletionSetoid (a +C c) (b +C d)
additionWellDefined {a} {b} {c} {d} a=b c=d = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {a +C c} {a +C d} {b +C d} (additionWellDefinedRight a c d c=d) (additionWellDefinedLeft a b d a=b)
additionHom : (x y : A) → Setoid._∼_ cauchyCompletionSetoid (injection (x + y)) (injection x +C injection y)
additionHom x y ε 0<e = 0 , ans
where
ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (injection (x + y))) (map inverse (CauchyCompletion.elts (injection x +C injection y)))) m) < ε
ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (injection (x + y))) (map inverse (CauchyCompletion.elts (injection x +C injection y))) _+_ {m} | equalityCommutative (mapAndIndex (apply _+_ (constSequence x) (constSequence y)) inverse m) | indexAndConst (x + y) m | indexAndApply (constSequence x) (constSequence y) _+_ {m} | indexAndConst x m | indexAndConst y m = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ invRight) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
Cassoc : {a b c : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a +C (b +C c)) ((a +C b) +C c)
Cassoc {a} {b} {c} ε 0<e = 0 , ans
where
ans : {m : ℕ} → 0 <N m → abs (index (CauchyCompletion.elts ((a +C (b +C c)) +C (-C ((a +C b) +C c)))) m) < ε
ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (a +C (b +C c))) (map inverse (CauchyCompletion.elts ((a +C b) +C c))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (apply _+_ (CauchyCompletion.elts b) (CauchyCompletion.elts c)) _+_ {m} | equalityCommutative (mapAndIndex (apply _+_ (apply _+_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (CauchyCompletion.elts c)) inverse m) | indexAndApply (CauchyCompletion.elts b) (CauchyCompletion.elts c) _+_ {m} | indexAndApply (apply _+_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (CauchyCompletion.elts c) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _+_ {m} = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (transferToRight'' (Ring.additiveGroup R) +Associative)) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
CidentRight : {a : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a +C injection 0G) a
CidentRight {a} ε 0<e = 0 , ans
where
ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (a +C injection 0G)) (map inverse (CauchyCompletion.elts a))) m) < ε
ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (a +C injection 0G)) (map inverse (CauchyCompletion.elts a)) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (constSequence 0G) _+_ {m} | equalityCommutative (mapAndIndex (CauchyCompletion.elts a) inverse m) | indexAndConst 0G m = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.transitive eq (+WellDefined (identRight) (Equivalence.reflexive eq)) (invRight))) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
CidentLeft : {a : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (injection 0G +C a) a
CidentLeft {a} = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {injection 0G +C a} {a +C injection 0G} {a} (+CCommutative (injection 0G) a) (CidentRight {a})
CinvRight : {a : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a +C (-C a)) (injection 0G)
CinvRight {a} ε 0<e = 0 , ans
where
ans : {m : ℕ} → (0 <N m) → abs (index (apply _+_ (CauchyCompletion.elts (a +C (-C a))) (map inverse (CauchyCompletion.elts (injection 0G)))) m) < ε
ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (a +C (-C a))) (map inverse (CauchyCompletion.elts (injection 0G))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (map inverse (CauchyCompletion.elts a)) _+_ {m} | equalityCommutative (mapAndIndex (CauchyCompletion.elts a) inverse m) | equalityCommutative (mapAndIndex (constSequence 0G) inverse m) | indexAndConst 0G m = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.transitive eq (+WellDefined invRight (invIdent (Ring.additiveGroup R))) identRight)) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e
CGroup : Group cauchyCompletionSetoid _+C_
Group.+WellDefined CGroup {a} {b} {c} {d} x y = additionWellDefined {a} {c} {b} {d} x y
Group.0G CGroup = injection 0G
Group.inverse CGroup = -C_
Group.+Associative CGroup {a} {b} {c} = Cassoc {a} {b} {c}
Group.identRight CGroup {a} = CidentRight {a}
Group.identLeft CGroup {a} = CidentLeft {a}
Group.invLeft CGroup {a} = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {(-C a) +C a} {a +C (-C a)} {injection 0G} (+CCommutative (-C a) a) (CinvRight {a})
Group.invRight CGroup {a} = CinvRight {a}
CInjectionGroupHom : GroupHom (Ring.additiveGroup R) CGroup injection
GroupHom.groupHom CInjectionGroupHom {x} {y} = additionHom x y
GroupHom.wellDefined CInjectionGroupHom {x} {y} x=y = SetoidInjection.wellDefined CInjection {x} {y} x=y
| 97.324561
| 920
| 0.713925
|
50c5f5a44f651409534c15273aee3cfccaca6bef
| 10,612
|
agda
|
Agda
|
Cubical/Data/Nat/Order.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:26.000Z
|
2022-02-05T01:25:26.000Z
|
Cubical/Data/Nat/Order.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/Order.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Data.Nat.Order where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sigma
open import Cubical.Data.Sum as ⊎
open import Cubical.Data.Nat.Base
open import Cubical.Data.Nat.Properties
open import Cubical.Induction.WellFounded
open import Cubical.Relation.Nullary
infix 4 _≤_ _<_
_≤_ : ℕ → ℕ → Type₀
m ≤ n = Σ[ k ∈ ℕ ] k + m ≡ n
_<_ : ℕ → ℕ → Type₀
m < n = suc m ≤ n
data Trichotomy (m n : ℕ) : Type₀ where
lt : m < n → Trichotomy m n
eq : m ≡ n → Trichotomy m n
gt : n < m → Trichotomy m n
private
variable
k l m n : ℕ
private
witness-prop : ∀ j → isProp (j + m ≡ n)
witness-prop {m} {n} j = isSetℕ (j + m) n
m≤n-isProp : isProp (m ≤ n)
m≤n-isProp {m} {n} (k , p) (l , q)
= Σ≡Prop witness-prop lemma
where
lemma : k ≡ l
lemma = inj-+m (p ∙ (sym q))
zero-≤ : 0 ≤ n
zero-≤ {n} = n , +-zero n
suc-≤-suc : m ≤ n → suc m ≤ suc n
suc-≤-suc (k , p) = k , (+-suc k _) ∙ (cong suc p)
≤-+k : m ≤ n → m + k ≤ n + k
≤-+k {m} {k = k} (i , p)
= i , +-assoc i m k ∙ cong (_+ k) p
≤-k+ : m ≤ n → k + m ≤ k + n
≤-k+ {m} {n} {k}
= subst (_≤ k + n) (+-comm m k)
∘ subst (m + k ≤_) (+-comm n k)
∘ ≤-+k
pred-≤-pred : suc m ≤ suc n → m ≤ n
pred-≤-pred (k , p) = k , injSuc ((sym (+-suc k _)) ∙ p)
≤-refl : m ≤ m
≤-refl = 0 , refl
≤-suc : m ≤ n → m ≤ suc n
≤-suc (k , p) = suc k , cong suc p
≤-predℕ : predℕ n ≤ n
≤-predℕ {zero} = ≤-refl
≤-predℕ {suc n} = ≤-suc ≤-refl
≤-trans : k ≤ m → m ≤ n → k ≤ n
≤-trans {k} {m} {n} (i , p) (j , q) = i + j , l2 ∙ (l1 ∙ q)
where
l1 : j + i + k ≡ j + m
l1 = (sym (+-assoc j i k)) ∙ (cong (j +_) p)
l2 : i + j + k ≡ j + i + k
l2 = cong (_+ k) (+-comm i j)
≤-antisym : m ≤ n → n ≤ m → m ≡ n
≤-antisym {m} (i , p) (j , q) = (cong (_+ m) l3) ∙ p
where
l1 : j + i + m ≡ m
l1 = (sym (+-assoc j i m)) ∙ ((cong (j +_) p) ∙ q)
l2 : j + i ≡ 0
l2 = m+n≡n→m≡0 l1
l3 : 0 ≡ i
l3 = sym (snd (m+n≡0→m≡0×n≡0 l2))
≤-k+-cancel : k + m ≤ k + n → m ≤ n
≤-k+-cancel {k} {m} (l , p) = l , inj-m+ (sub k m ∙ p)
where
sub : ∀ k m → k + (l + m) ≡ l + (k + m)
sub k m = +-assoc k l m ∙ cong (_+ m) (+-comm k l) ∙ sym (+-assoc l k m)
≤-+k-cancel : m + k ≤ n + k → m ≤ n
≤-+k-cancel {m} {k} {n} (l , p) = l , cancelled
where
cancelled : l + m ≡ n
cancelled = inj-+m (sym (+-assoc l m k) ∙ p)
≤-·k : m ≤ n → m · k ≤ n · k
≤-·k {m} {n} {k} (d , r) = d · k , reason where
reason : d · k + m · k ≡ n · k
reason = d · k + m · k ≡⟨ ·-distribʳ d m k ⟩
(d + m) · k ≡⟨ cong (_· k) r ⟩
n · k ∎
<-k+-cancel : k + m < k + n → m < n
<-k+-cancel {k} {m} {n} = ≤-k+-cancel ∘ subst (_≤ k + n) (sym (+-suc k m))
¬-<-zero : ¬ m < 0
¬-<-zero (k , p) = snotz ((sym (+-suc k _)) ∙ p)
¬m<m : ¬ m < m
¬m<m {m} = ¬-<-zero ∘ ≤-+k-cancel {k = m}
≤0→≡0 : n ≤ 0 → n ≡ 0
≤0→≡0 {zero} ineq = refl
≤0→≡0 {suc n} ineq = ⊥.rec (¬-<-zero ineq)
predℕ-≤-predℕ : m ≤ n → (predℕ m) ≤ (predℕ n)
predℕ-≤-predℕ {zero} {zero} ineq = ≤-refl
predℕ-≤-predℕ {zero} {suc n} ineq = zero-≤
predℕ-≤-predℕ {suc m} {zero} ineq = ⊥.rec (¬-<-zero ineq)
predℕ-≤-predℕ {suc m} {suc n} ineq = pred-≤-pred ineq
¬m+n<m : ¬ m + n < m
¬m+n<m {m} {n} = ¬-<-zero ∘ <-k+-cancel ∘ subst (m + n <_) (sym (+-zero m))
<-weaken : m < n → m ≤ n
<-weaken (k , p) = suc k , sym (+-suc k _) ∙ p
≤<-trans : l ≤ m → m < n → l < n
≤<-trans p = ≤-trans (suc-≤-suc p)
<≤-trans : l < m → m ≤ n → l < n
<≤-trans = ≤-trans
<-trans : l < m → m < n → l < n
<-trans p = ≤<-trans (<-weaken p)
<-asym : m < n → ¬ n ≤ m
<-asym m<n = ¬m<m ∘ <≤-trans m<n
<-+k : m < n → m + k < n + k
<-+k p = ≤-+k p
<-k+ : m < n → k + m < k + n
<-k+ {m} {n} {k} p = subst (λ km → km ≤ k + n) (+-suc k m) (≤-k+ p)
+-<-+ : m < n → k < l → m + k < n + l
+-<-+ m<n k<l = <-trans (<-+k m<n) (<-k+ k<l)
<-·sk : m < n → m · suc k < n · suc k
<-·sk {m} {n} {k} (d , r) = (d · suc k + k) , reason where
reason : (d · suc k + k) + suc (m · suc k) ≡ n · suc k
reason = (d · suc k + k) + suc (m · suc k) ≡⟨ sym (+-assoc (d · suc k) k _) ⟩
d · suc k + (k + suc (m · suc k)) ≡[ i ]⟨ d · suc k + +-suc k (m · suc k) i ⟩
d · suc k + suc m · suc k ≡⟨ ·-distribʳ d (suc m) (suc k) ⟩
(d + suc m) · suc k ≡⟨ cong (_· suc k) r ⟩
n · suc k ∎
∸-≤ : ∀ m n → m ∸ n ≤ m
∸-≤ m zero = ≤-refl
∸-≤ zero (suc n) = ≤-refl
∸-≤ (suc m) (suc n) = ≤-trans (∸-≤ m n) (1 , refl)
≤-∸-+-cancel : m ≤ n → (n ∸ m) + m ≡ n
≤-∸-+-cancel {zero} {n} _ = +-zero _
≤-∸-+-cancel {suc m} {zero} m≤n = ⊥.rec (¬-<-zero m≤n)
≤-∸-+-cancel {suc m} {suc n} m+1≤n+1 = +-suc _ _ ∙ cong suc (≤-∸-+-cancel (pred-≤-pred m+1≤n+1))
≤-∸-suc : m ≤ n → suc (n ∸ m) ≡ suc n ∸ m
≤-∸-suc {zero} {n} m≤n = refl
≤-∸-suc {suc m} {zero} m≤n = ⊥.rec (¬-<-zero m≤n)
≤-∸-suc {suc m} {suc n} m+1≤n+1 = ≤-∸-suc (pred-≤-pred m+1≤n+1)
left-≤-max : m ≤ max m n
left-≤-max {zero} {n} = zero-≤
left-≤-max {suc m} {zero} = ≤-refl
left-≤-max {suc m} {suc n} = suc-≤-suc left-≤-max
right-≤-max : n ≤ max m n
right-≤-max {zero} {m} = zero-≤
right-≤-max {suc n} {zero} = ≤-refl
right-≤-max {suc n} {suc m} = suc-≤-suc right-≤-max
min-≤-left : min m n ≤ m
min-≤-left {zero} {n} = ≤-refl
min-≤-left {suc m} {zero} = zero-≤
min-≤-left {suc m} {suc n} = suc-≤-suc min-≤-left
min-≤-right : min m n ≤ n
min-≤-right {zero} {n} = zero-≤
min-≤-right {suc m} {zero} = ≤-refl
min-≤-right {suc m} {suc n} = suc-≤-suc min-≤-right
≤Dec : ∀ m n → Dec (m ≤ n)
≤Dec zero n = yes (n , +-zero _)
≤Dec (suc m) zero = no ¬-<-zero
≤Dec (suc m) (suc n) with ≤Dec m n
... | yes m≤n = yes (suc-≤-suc m≤n)
... | no m≰n = no λ m+1≤n+1 → m≰n (pred-≤-pred m+1≤n+1 )
<Dec : ∀ m n → Dec (m < n)
<Dec m n = ≤Dec (suc m) n
Trichotomy-suc : Trichotomy m n → Trichotomy (suc m) (suc n)
Trichotomy-suc (lt m<n) = lt (suc-≤-suc m<n)
Trichotomy-suc (eq m=n) = eq (cong suc m=n)
Trichotomy-suc (gt n<m) = gt (suc-≤-suc n<m)
_≟_ : ∀ m n → Trichotomy m n
zero ≟ zero = eq refl
zero ≟ suc n = lt (n , +-comm n 1)
suc m ≟ zero = gt (m , +-comm m 1)
suc m ≟ suc n = Trichotomy-suc (m ≟ n)
<-split : m < suc n → (m < n) ⊎ (m ≡ n)
<-split {n = zero} = inr ∘ snd ∘ m+n≡0→m≡0×n≡0 ∘ snd ∘ pred-≤-pred
<-split {zero} {suc n} = λ _ → inl (suc-≤-suc zero-≤)
<-split {suc m} {suc n} = ⊎.map suc-≤-suc (cong suc) ∘ <-split ∘ pred-≤-pred
≤-+-split : ∀ n m k → k ≤ n + m → (n ≤ k) ⊎ (m ≤ (n + m) ∸ k)
≤-+-split n m k k≤n+m with n ≟ k
... | eq p = inl (0 , p)
... | lt n<k = inl (<-weaken n<k)
... | gt k<n with m ≟ ((n + m) ∸ k)
... | eq p = inr (0 , p)
... | lt m<n+m∸k = inr (<-weaken m<n+m∸k)
... | gt n+m∸k<m =
⊥.rec (¬m<m (transport (λ i → ≤-∸-+-cancel k≤n+m i < +-comm m n i) (+-<-+ n+m∸k<m k<n)))
private
acc-suc : Acc _<_ n → Acc _<_ (suc n)
acc-suc a
= acc λ y y<sn
→ case <-split y<sn of λ
{ (inl y<n) → access a y y<n
; (inr y≡n) → subst _ (sym y≡n) a
}
<-wellfounded : WellFounded _<_
<-wellfounded zero = acc λ _ → ⊥.rec ∘ ¬-<-zero
<-wellfounded (suc n) = acc-suc (<-wellfounded n)
<→≢ : n < m → ¬ n ≡ m
<→≢ {n} {m} p q = ¬m<m (subst (_< m) q p)
module _
(b₀ : ℕ)
(P : ℕ → Type₀)
(base : ∀ n → n < suc b₀ → P n)
(step : ∀ n → P n → P (suc b₀ + n))
where
open WFI (<-wellfounded)
private
dichotomy : ∀ b n → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m)
dichotomy b n
= case n ≟ b return (λ _ → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m)) of λ
{ (lt o) → inl o
; (eq p) → inr (0 , p ∙ sym (+-zero b))
; (gt (m , p)) → inr (suc m , sym p ∙ +-suc m b ∙ +-comm (suc m) b)
}
dichotomy<≡ : ∀ b n → (n<b : n < b) → dichotomy b n ≡ inl n<b
dichotomy<≡ b n n<b
= case dichotomy b n return (λ d → d ≡ inl n<b) of λ
{ (inl x) → cong inl (m≤n-isProp x n<b)
; (inr (m , p)) → ⊥.rec (<-asym n<b (m , sym (p ∙ +-comm b m)))
}
dichotomy+≡ : ∀ b m n → (p : n ≡ b + m) → dichotomy b n ≡ inr (m , p)
dichotomy+≡ b m n p
= case dichotomy b n return (λ d → d ≡ inr (m , p)) of λ
{ (inl n<b) → ⊥.rec (<-asym n<b (m , +-comm m b ∙ sym p))
; (inr (m' , q))
→ cong inr (Σ≡Prop (λ x → isSetℕ n (b + x)) (inj-m+ {m = b} (sym q ∙ p)))
}
b = suc b₀
lemma₁ : ∀{x y z} → x ≡ suc z + y → y < x
lemma₁ {y = y} {z} p = z , +-suc z y ∙ sym p
subStep : (n : ℕ) → (∀ m → m < n → P m) → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m) → P n
subStep n _ (inl l) = base n l
subStep n rec (inr (m , p))
= transport (cong P (sym p)) (step m (rec m (lemma₁ p)))
wfStep : (n : ℕ) → (∀ m → m < n → P m) → P n
wfStep n rec = subStep n rec (dichotomy b n)
wfStepLemma₀ : ∀ n (n<b : n < b) rec → wfStep n rec ≡ base n n<b
wfStepLemma₀ n n<b rec = cong (subStep n rec) (dichotomy<≡ b n n<b)
wfStepLemma₁ : ∀ n rec → wfStep (b + n) rec ≡ step n (rec n (lemma₁ refl))
wfStepLemma₁ n rec
= cong (subStep (b + n) rec) (dichotomy+≡ b n (b + n) refl)
∙ transportRefl _
+induction : ∀ n → P n
+induction = induction wfStep
+inductionBase : ∀ n → (l : n < b) → +induction n ≡ base n l
+inductionBase n l = induction-compute wfStep n ∙ wfStepLemma₀ n l _
+inductionStep : ∀ n → +induction (b + n) ≡ step n (+induction n)
+inductionStep n = induction-compute wfStep (b + n) ∙ wfStepLemma₁ n _
module <-Reasoning where
-- TODO: would it be better to mirror the way it is done in the agda-stdlib?
infixr 2 _<⟨_⟩_ _≤<⟨_⟩_ _≤⟨_⟩_ _<≤⟨_⟩_ _≡<⟨_⟩_ _≡≤⟨_⟩_ _<≡⟨_⟩_ _≤≡⟨_⟩_
_<⟨_⟩_ : ∀ k → k < n → n < m → k < m
_ <⟨ p ⟩ q = <-trans p q
_≤<⟨_⟩_ : ∀ k → k ≤ n → n < m → k < m
_ ≤<⟨ p ⟩ q = ≤<-trans p q
_≤⟨_⟩_ : ∀ k → k ≤ n → n ≤ m → k ≤ m
_ ≤⟨ p ⟩ q = ≤-trans p q
_<≤⟨_⟩_ : ∀ k → k < n → n ≤ m → k < m
_ <≤⟨ p ⟩ q = <≤-trans p q
_≡≤⟨_⟩_ : ∀ k → k ≡ l → l ≤ m → k ≤ m
_ ≡≤⟨ p ⟩ q = subst (λ k → k ≤ _) (sym p) q
_≡<⟨_⟩_ : ∀ k → k ≡ l → l < m → k < m
_ ≡<⟨ p ⟩ q = _ ≡≤⟨ cong suc p ⟩ q
_≤≡⟨_⟩_ : ∀ k → k ≤ l → l ≡ m → k ≤ m
_ ≤≡⟨ p ⟩ q = subst (λ l → _ ≤ l) q p
_<≡⟨_⟩_ : ∀ k → k < l → l ≡ m → k < m
_ <≡⟨ p ⟩ q = _ ≤≡⟨ p ⟩ q
-- Some lemmas about ∸
suc∸-fst : (n m : ℕ) → m < n → suc (n ∸ m) ≡ (suc n) ∸ m
suc∸-fst zero zero p = refl
suc∸-fst zero (suc m) p = ⊥.rec (¬-<-zero p)
suc∸-fst (suc n) zero p = refl
suc∸-fst (suc n) (suc m) p = (suc∸-fst n m (pred-≤-pred p))
n∸m≡0 : (n m : ℕ) → n < m → (n ∸ m) ≡ 0
n∸m≡0 zero zero p = refl
n∸m≡0 (suc n) zero p = ⊥.rec (¬-<-zero p)
n∸m≡0 zero (suc m) p = refl
n∸m≡0 (suc n) (suc m) p = n∸m≡0 n m (pred-≤-pred p)
n∸n≡0 : (n : ℕ) → n ∸ n ≡ 0
n∸n≡0 zero = refl
n∸n≡0 (suc n) = n∸n≡0 n
| 29.23416
| 96
| 0.46127
|
394e2db5441f0949210c19f84c81268cdb42dfc1
| 366
|
agda
|
Agda
|
examples/SummerSchool07/Lecture/Nat.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
examples/SummerSchool07/Lecture/Nat.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/SummerSchool07/Lecture/Nat.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module Nat where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
infixl 60 _+_
infixl 70 _*_
_+_ : Nat -> Nat -> Nat
n + zero = n
n + suc m = suc (n + m)
_*_ : Nat -> Nat -> Nat
n * zero = zero
n * suc m = n * m + n
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN NATPLUS _+_ #-}
{-# BUILTIN NATTIMES _*_ #-}
| 14.64
| 28
| 0.540984
|
12b1dc851cf3f92526bcb2c3f8f480f3818ca605
| 1,795
|
agda
|
Agda
|
Globular-TT/Typed-Syntax.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | 2
|
2020-05-01T08:26:53.000Z
|
2020-05-20T00:41:09.000Z
|
Globular-TT/Typed-Syntax.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
Globular-TT/Typed-Syntax.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Agda.Primitive
open import Prelude
import GSeTT.Typed-Syntax
import Globular-TT.Syntax
{- Type theory for globular sets -}
module Globular-TT.Typed-Syntax {l}
(index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index)) (eqdec-index : eqdec index) where
open import Globular-TT.Syntax index
open import Globular-TT.Rules index rule
open import Globular-TT.Eqdec-syntax index eqdec-index
open import Globular-TT.Uniqueness-Derivations index rule eqdec-index
Ctx : Set (lsuc l)
Ctx = Σ Pre-Ctx (λ Γ → Γ ⊢C)
Ty : Ctx → Set (lsuc l)
Ty (Γ , _) = Σ Pre-Ty (λ A → Γ ⊢T A)
Tm : ∀ (Γ : Ctx) → Ty Γ → Set (lsuc l)
Tm (Γ , _) (A , _) = Σ Pre-Tm (λ t → Γ ⊢t t # A)
Sub : ∀ (Δ : Ctx) (Γ : Ctx) → Set (lsuc l)
Sub (Δ , _) (Γ , _) = Σ Pre-Sub (λ γ → Δ ⊢S γ > Γ)
eqC : ∀ (Γ Δ : Ctx) → fst Γ == fst Δ → Γ == Δ
eqC (Γ , Γ⊢) (.Γ , Γ⊢') idp = Σ= idp (has-all-paths-⊢C _ _)
eqT : ∀ {Γ} (A B : Ty Γ) → fst A == fst B → A == B
eqT (A , Γ⊢A) (.A , Γ⊢'A) idp = Σ= idp (has-all-paths-⊢T _ _)
eqt : ∀ {Γ A} (t u : Tm Γ A) → fst t == fst u → t == u
eqt (t , Γ⊢t:A) (.t , Γ⊢':A) idp = Σ= idp (has-all-paths-⊢t _ _)
eqS : ∀ {Γ Δ} (γ δ : Sub Γ Δ) → fst γ == fst δ → γ == δ
eqS (γ , Γ⊢γ:Δ) (.γ , Γ⊢'γ:Δ) idp = Σ= idp (has-all-paths-⊢S _ _)
trS : ∀ {Γ Δ Θ : Ctx} → (p : Δ == Θ) → {γ : Sub Γ Δ} → {δ : Sub Γ Θ} → fst γ == fst δ → transport p γ == δ
trS {Γ} {Δ} {Θ} idp {γ} {δ} x = eqS {Γ} {Θ} γ δ x
private
eqdec-typedTy : ∀ Γ → eqdec (Ty Γ)
eqdec-typedTy Γ (A , Γ⊢A) (B , Γ⊢B) with eqdec-Ty A B
... | inl idp = inl (eqT {Γ} (A , Γ⊢A) (B , Γ⊢B) idp)
... | inr A≠B = inr λ p → A≠B (fst-is-inj p)
is-set-Ty : ∀ Γ → is-set (Ty Γ)
is-set-Ty Γ = eqdec-is-set (eqdec-typedTy Γ)
| 33.240741
| 128
| 0.530919
|
dcb88a8e20831786dd471aef0ee72dd2780ad75c
| 9,357
|
agda
|
Agda
|
Cubical/Experiments/EscardoSIP.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Experiments/EscardoSIP.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/EscardoSIP.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-
This is a rather literal translation of Martin Hötzel-Escardó's structure identity principle into cubical Agda. See
https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns
All the needed preliminary results from the lecture notes are stated and proven in this file.
It would be interesting to compare the proves with the one in Cubical.Foundations.SIP
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.Experiments.EscardoSIP where
open import Cubical.Core.Everything
open import Cubical.Foundations.Everything
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.Sigma.Properties
private
variable
ℓ ℓ' ℓ'' : Level
S : Type ℓ → Type ℓ'
-- We prove several useful equalities and equivalences between Σ-types all the proofs are taken from
-- Martin Hötzel-Escardó's lecture notes.
-- The next result is just a reformulation of pathSigma≡sigmaPath from Sigma.Properties.
Σ-≡-≃ : {X : Type ℓ} {A : X → Type ℓ'}
→ (σ τ : Σ X A) → ((σ ≡ τ) ≃ (Σ[ p ∈ (σ .fst) ≡ (τ .fst) ] (subst A p (σ .snd) ≡ (τ .snd))))
Σ-≡-≃ {A = A} σ τ = pathToEquiv (pathSigma≡sigmaPath σ τ)
-- This cubical proof is much shorter than in HoTT but requires that A, B live in the same universe.
Σ-cong : {X : Type ℓ} {A B : X → Type ℓ'} →
((x : X) → (A x ≡ B x)) → (Σ X A ≡ Σ X B)
Σ-cong {X = X} p i = Σ[ x ∈ X ] (p x i)
-- Two lemmas for the more general formulation using equivalences
NatΣ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''}
→ ((x : X) → (A x) → (B x)) → (Σ X A) → (Σ X B)
NatΣ τ (x , a) = (x , τ x a)
Σ-to-PathP : {X : Type ℓ} {A : X → Type ℓ'} {x : X} {a b : A x}
→ (a ≡ b) → PathP (λ i → Σ X A) (x , a) (x , b)
Σ-to-PathP {x = x} p i = (x , p i)
Σ-cong-≃ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''} →
((x : X) → (A x ≃ B x)) → (Σ X A ≃ Σ X B)
Σ-cong-≃ {X = X} {A = A} {B = B} φ = isoToEquiv (iso (NatΣ f) (NatΣ g) NatΣ-ε NatΣ-η)
where
f : (x : X) → (A x) → (B x)
f x = equivFun (φ x)
g : (x : X) → (B x) → (A x)
g x = equivFun (invEquiv (φ x))
η : (x : X) → (a : A x) → (g x) ((f x) a) ≡ a
η x = retEq (invEquiv (φ x))
ε : (x : X) → (b : B x) → f x (g x b) ≡ b
ε x = secEq (invEquiv (φ x))
NatΣ-η : (w : Σ X A) → NatΣ g (NatΣ f w) ≡ w
NatΣ-η (x , a) = (x , g x (f x a)) ≡⟨ Σ-to-PathP (η x a) ⟩
(x , a) ∎
NatΣ-ε : (u : Σ X B) → NatΣ f (NatΣ g u) ≡ u
NatΣ-ε (x , b) = (x , f x (g x b)) ≡⟨ Σ-to-PathP (ε x b) ⟩
(x , b) ∎
-- The next result is stated a bit awkwardly but is rather straightforward to prove.
Σ-change-of-variable-Iso : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y)
→ (isHAEquiv f) → (Iso (Σ X (A ∘ f)) (Σ Y A))
Σ-change-of-variable-Iso {ℓ = ℓ} {ℓ' = ℓ'} {X = X} {Y = Y} {A = A} f isHAEquivf = iso φ ψ φψ ψφ
where
g : Y → X
g = isHAEquiv.g isHAEquivf
ε : (x : X) → (g (f x)) ≡ x
ε = isHAEquiv.sec isHAEquivf
η : (y : Y) → f (g y) ≡ y
η = isHAEquiv.ret isHAEquivf
τ : (x : X) → cong f (ε x) ≡ η (f x)
τ = isHAEquiv.com isHAEquivf
φ : (Σ X (A ∘ f)) → (Σ Y A)
φ (x , a) = (f x , a)
ψ : (Σ Y A) → (Σ X (A ∘ f))
ψ (y , a) = (g y , subst A (sym (η y)) a)
φψ : (z : (Σ Y A)) → φ (ψ z) ≡ z
φψ (y , a) = sigmaPath→pathSigma (φ (ψ (y , a))) (y , a)
(η y , transportTransport⁻ (λ i → A (η y i)) a)
-- last term proves transp (λ i → A (η y i)) i0 (transp (λ i → A (η y (~ i))) i0 a) ≡ a
ψφ : (z : (Σ X (A ∘ f))) → ψ (φ z) ≡ z
ψφ (x , a) = sigmaPath→pathSigma (ψ (φ (x , a))) (x , a) (ε x , q)
where
b : A (f (g (f x)))
b = (transp (λ i → A (η (f x) (~ i))) i0 a)
q : transp (λ i → A (f (ε x i))) i0 (transp (λ i → A (η (f x) (~ i))) i0 a) ≡ a
q = transp (λ i → A (f (ε x i))) i0 b ≡⟨ i ⟩
transp (λ i → A (η (f x) i)) i0 b ≡⟨ transportTransport⁻ (λ i → A (η (f x) i)) a ⟩
a ∎
where
i : (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (η (f x) i)) i0 b)
i = subst (λ p → (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (p i)) i0 b))
(τ x) refl
-- Using the result above we can prove the following quite useful result.
Σ-change-of-variable-≃ : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y)
→ (isEquiv f) → ((Σ X (A ∘ f)) ≃ (Σ Y A))
Σ-change-of-variable-≃ f isEquivf =
isoToEquiv (Σ-change-of-variable-Iso f (equiv→HAEquiv (f , isEquivf) .snd))
Σ-assoc-Iso : (X : Type ℓ) (A : X → Type ℓ') (P : Σ X A → Type ℓ'')
→ (Iso (Σ (Σ X A) P) (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a))))
Σ-assoc-Iso X A P = iso f g ε η
where
f : (Σ (Σ X A) P) → (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a)))
f ((x , a) , p) = (x , (a , p))
g : (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a))) → (Σ (Σ X A) P)
g (x , (a , p)) = ((x , a) , p)
ε : section f g
ε n = refl
η : retract f g
η m = refl
Σ-assoc-≃ : (X : Type ℓ) (A : X → Type ℓ') (P : Σ X A → Type ℓ'')
→ (Σ (Σ X A) P) ≃ (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a)))
Σ-assoc-≃ X A P = isoToEquiv (Σ-assoc-Iso X A P)
-- A structure is a type-family S : Type ℓ → Type ℓ', i.e. for X : Type ℓ and s : S X, the pair (X , s)
-- means that X is equipped with a S-structure, which is witnessed by s.
-- An S-structure should have a notion of S-homomorphism, or rather S-isomorphism.
-- This will be implemented by a function ι
-- that gives us for any two types with S-structure (X , s) and (Y , t) a family:
-- ι (X , s) (Y , t) : (X ≃ Y) → Type ℓ''
-- Note that for any equivalence (f , e) : X ≃ Y the type ι (X , s) (Y , t) (f , e) need not to be
-- a proposition. Indeed this type should correspond to the ways s and t can be identified
-- as S-structures. This we call a standard notion of structure.
SNS : (S : Type ℓ → Type ℓ') (ι : StrIso S ℓ'') → Type (ℓ-max (ℓ-max (ℓ-suc ℓ) ℓ') ℓ'')
SNS {ℓ = ℓ} S ι = ∀ {X : (Type ℓ)} (s t : S X) → ((s ≡ t) ≃ ι (X , s) (X , t) (idEquiv X))
-- Escardo's ρ can actually be defined from this:
ρ : {ι : StrIso S ℓ''} (θ : SNS S ι) (A : TypeWithStr ℓ S) → (ι A A (idEquiv (typ A)))
ρ θ A = equivFun (θ (str A) (str A)) refl
-- We introduce the notation a bit differently:
_≃[_]_ : (A : TypeWithStr ℓ S) (ι : StrIso S ℓ'') (B : TypeWithStr ℓ S) → (Type (ℓ-max ℓ ℓ''))
A ≃[ ι ] B = Σ[ f ∈ ((typ A) ≃ (typ B)) ] (ι A B f)
Id→homEq : (S : Type ℓ → Type ℓ') (ι : StrIso S ℓ'')
→ (ρ : (A : TypeWithStr ℓ S) → ι A A (idEquiv (typ A)))
→ (A B : TypeWithStr ℓ S) → A ≡ B → (A ≃[ ι ] B)
Id→homEq S ι ρ A B p = J (λ y x → A ≃[ ι ] y) (idEquiv (typ A) , ρ A) p
-- Use a PathP version of Escardó's homomorphism-lemma
hom-lemma-dep : (S : Type ℓ → Type ℓ') (ι : StrIso S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S)
→ (p : (typ A) ≡ (typ B))
→ (PathP (λ i → S (p i)) (str A) (str B)) ≃ (ι A B (pathToEquiv p))
hom-lemma-dep S ι θ A B p = (J P (λ s → γ s) p) (str B)
where
P = (λ y x → (s : S y) → PathP (λ i → S (x i)) (str A) s ≃ ι A (y , s) (pathToEquiv x))
γ : (s : S (typ A)) → ((str A) ≡ s) ≃ ι A ((typ A) , s) (pathToEquiv refl)
γ s = subst (λ f → ((str A) ≡ s) ≃ ι A ((typ A) , s) f) (sym pathToEquivRefl) (θ (str A) s)
-- Define the inverse of Id→homEq directly.
ua-lemma : (A B : Type ℓ) (e : A ≃ B) → (pathToEquiv (ua e)) ≡ e
ua-lemma A B e = EquivJ (λ A f → (pathToEquiv (ua f)) ≡ f)
(subst (λ r → pathToEquiv r ≡ idEquiv B) (sym uaIdEquiv) pathToEquivRefl)
e
homEq→Id : (S : Type ℓ → Type ℓ') (ι : StrIso S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S) → (A ≃[ ι ] B) → A ≡ B
homEq→Id S ι θ A B (f , φ) = ΣPathP (p , q)
where
p = ua f
ψ : ι A B (pathToEquiv p)
ψ = subst (λ g → ι A B g) (sym (ua-lemma (typ A) (typ B) f)) φ
q : PathP (λ i → S (p i)) (str A) (str B)
q = equivFun (invEquiv (hom-lemma-dep S ι θ A B p)) ψ
-- Proof of the SIP:
SIP : (S : Type ℓ → Type ℓ') (ι : StrIso S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S) → ((A ≡ B) ≃ (A ≃[ ι ] B))
SIP S ι θ A B =
(A ≡ B) ≃⟨ i ⟩
(Σ[ p ∈ (typ A) ≡ (typ B) ] PathP (λ i → S (p i)) (str A) (str B)) ≃⟨ ii ⟩
(Σ[ p ∈ (typ A) ≡ (typ B) ] (ι A B (pathToEquiv p))) ≃⟨ iii ⟩
(A ≃[ ι ] B) ■
where
i = invEquiv Σ≃
ii = Σ-cong-≃ (hom-lemma-dep S ι θ A B)
iii = Σ-change-of-variable-≃ pathToEquiv (equivIsEquiv univalence)
-- A simple example: pointed types
pointed-structure : Type ℓ → Type ℓ
pointed-structure X = X
Pointed-Type : Type (ℓ-suc ℓ)
Pointed-Type {ℓ = ℓ} = Σ (Type ℓ) pointed-structure
pointed-ι : (A B : Pointed-Type) → (A .fst) ≃ (B. fst) → Type ℓ
pointed-ι (X , x) (Y , y) f = (equivFun f) x ≡ y
pointed-is-sns : SNS {ℓ = ℓ} pointed-structure pointed-ι
pointed-is-sns s t = idEquiv (s ≡ t)
pointed-type-sip : (X Y : Type ℓ) (x : X) (y : Y)
→ (Σ[ f ∈ X ≃ Y ] (f .fst) x ≡ y) ≃ ((X , x) ≡ (Y , y))
pointed-type-sip X Y x y = invEquiv (SIP pointed-structure pointed-ι pointed-is-sns (X , x) (Y , y))
| 38.036585
| 115
| 0.48616
|
4da100a2c1cb52c8182746aaee47bf68df89ff72
| 1,998
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Codata/Thunk.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
test/asset/agda-stdlib-1.0/Codata/Thunk.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Codata/Thunk.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The Thunk wrappers for sized codata, copredicates and corelations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Thunk where
open import Size
open import Relation.Unary
------------------------------------------------------------------------
-- Basic types.
record Thunk {ℓ} (F : Size → Set ℓ) (i : Size) : Set ℓ where
coinductive
field force : {j : Size< i} → F j
open Thunk public
Thunk^P : ∀ {f p} {F : Size → Set f} (P : Size → F ∞ → Set p)
(i : Size) (tf : Thunk F ∞) → Set p
Thunk^P P i tf = Thunk (λ i → P i (tf .force)) i
Thunk^R : ∀ {f g r} {F : Size → Set f} {G : Size → Set g}
(R : Size → F ∞ → G ∞ → Set r)
(i : Size) (tf : Thunk F ∞) (tg : Thunk G ∞) → Set r
Thunk^R R i tf tg = Thunk (λ i → R i (tf .force) (tg .force)) i
------------------------------------------------------------------------
-- Syntax
Thunk-syntax : ∀ {ℓ} → (Size → Set ℓ) → Size → Set ℓ
Thunk-syntax = Thunk
syntax Thunk-syntax (λ j → e) i = Thunk[ j < i ] e
------------------------------------------------------------------------
-- Basic functions.
-- Thunk is a functor
module _ {p q} {P : Size → Set p} {Q : Size → Set q} where
map : ∀[ P ⇒ Q ] → ∀[ Thunk P ⇒ Thunk Q ]
map f p .force = f (p .force)
-- Thunk is a comonad
module _ {p} {P : Size → Set p} where
extract : ∀[ Thunk P ] → P ∞
extract p = p .force
duplicate : ∀[ Thunk P ⇒ Thunk (Thunk P) ]
duplicate p .force .force = p .force
module _ {p q} {P : Size → Set p} {Q : Size → Set q} where
infixl 1 _<*>_
_<*>_ : ∀[ Thunk (P ⇒ Q) ⇒ Thunk P ⇒ Thunk Q ]
(f <*> p) .force = f .force (p .force)
-- We can take cofixpoints of functions only making Thunk'd recursive calls
module _ {p} (P : Size → Set p) where
cofix : ∀[ Thunk P ⇒ P ] → ∀[ P ]
cofix f = f λ where .force → cofix f
| 29.382353
| 75
| 0.458959
|
10a0e487478f5585726e742ecd35dc3bcfc667f8
| 113,985
|
agda
|
Agda
|
Agda/15-pullbacks.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/15-pullbacks.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/15-pullbacks.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --exact-split #-}
module 15-pullbacks where
import 14-fundamental-cover
open 14-fundamental-cover public
-- Section 13.1 Cartesian squares
{- We introduce the basic concepts of this chapter: commuting squares, cospans,
cones, and pullback squares. Pullback squares are also called cartesian
squares. -}
{- Commutativity of squares is expressed with a homotopy. -}
coherence-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(top : C → B) (left : C → A) (right : B → X) (bottom : A → X) →
UU (l3 ⊔ l4)
coherence-square top left right bottom =
(bottom ∘ left) ~ (right ∘ top)
{- A cospan is a pair of functions with a common codomain. -}
cospan :
{l1 l2 : Level} (l : Level) (A : UU l1) (B : UU l2) →
UU (l1 ⊔ (l2 ⊔ (lsuc l)))
cospan l A B =
Σ (UU l) (λ X → (A → X) × (B → X))
{- A cone on a cospan with a vertex C is a pair of functions from C into the
domains of the maps in the cospan, equipped with a homotopy witnessing that
the resulting square commutes. -}
cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → UU l4 → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
cone {A = A} {B = B} f g C =
Σ (C → A) (λ p → Σ (C → B) (λ q → coherence-square q p g f))
{- A map into the vertex of a cone induces a new cone. -}
cone-map :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} {C' : UU l5} →
cone f g C → (C' → C) → cone f g C'
cone-map f g c h =
pair
( (pr1 c) ∘ h)
( pair
( (pr1 (pr2 c)) ∘ h)
( (pr2 (pr2 c)) ·r h))
{- We introduce the universal property of pullbacks. -}
universal-property-pullback :
{l1 l2 l3 l4 : Level} (l : Level) {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X) {C : UU l4} → cone f g C →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ (l4 ⊔ (lsuc l)))))
universal-property-pullback l f g c =
(C' : UU l) → is-equiv (cone-map f g {C' = C'} c)
map-universal-property-pullback :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
({l : Level} → universal-property-pullback l f g c) →
{C' : UU l5} (c' : cone f g C') → C' → C
map-universal-property-pullback f g c up-c {C'} c' =
inv-is-equiv (up-c C') c'
eq-map-universal-property-pullback :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
(up-c : {l : Level} → universal-property-pullback l f g c) →
{C' : UU l5} (c' : cone f g C') →
Id (cone-map f g c (map-universal-property-pullback f g c up-c c')) c'
eq-map-universal-property-pullback f g c up-c {C'} c' =
issec-inv-is-equiv (up-c C') c'
{- Next we characterize the identity type of the type of cones with a given
vertex C. Note that in the definition of htpy-cone we do not use pattern
matching on the cones c and c'. This is to ensure that the type
htpy-cone f g c c' is a Σ-type for any c and c', not just for c and c' of the
form (pair p (pair q H)) and (pair p' (pair q' H')) respectively. -}
coherence-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c c' : cone f g C) →
(K : (pr1 c) ~ (pr1 c')) (L : (pr1 (pr2 c)) ~ (pr1 (pr2 c'))) → UU (l4 ⊔ l3)
coherence-htpy-cone f g c c' K L =
( (pr2 (pr2 c)) ∙h (htpy-left-whisk g L)) ~
( (htpy-left-whisk f K) ∙h (pr2 (pr2 c')))
htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} → cone f g C → cone f g C →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
htpy-cone f g c c' =
Σ ( (pr1 c) ~ (pr1 c'))
( λ K → Σ ((pr1 (pr2 c)) ~ (pr1 (pr2 c')))
( λ L → coherence-htpy-cone f g c c' K L))
reflexive-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
htpy-cone f g c c
reflexive-htpy-cone f g c =
pair htpy-refl (pair htpy-refl htpy-right-unit)
htpy-cone-eq :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c c' : cone f g C) →
Id c c' → htpy-cone f g c c'
htpy-cone-eq f g c .c refl =
reflexive-htpy-cone f g c
abstract
is-contr-total-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
is-contr (Σ (cone f g C) (htpy-cone f g c))
is-contr-total-htpy-cone {A = A} {B} f g {C} (pair p (pair q H)) =
is-contr-total-Eq-structure
( λ p' qH' K →
Σ ( q ~ (pr1 qH'))
( coherence-htpy-cone f g (pair p (pair q H)) (pair p' qH') K))
( is-contr-total-htpy p)
( pair p htpy-refl)
( is-contr-total-Eq-structure
( λ q' H' →
coherence-htpy-cone f g
( pair p (pair q H))
( pair p (pair q' H'))
( htpy-refl))
( is-contr-total-htpy q)
( pair q htpy-refl)
( is-contr-equiv'
( Σ ((f ∘ p) ~ (g ∘ q)) (λ H' → H ~ H'))
( equiv-tot
( λ H' → equiv-htpy-concat htpy-right-unit H'))
( is-contr-total-htpy H)))
abstract
is-fiberwise-equiv-htpy-cone-eq :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
is-fiberwise-equiv (htpy-cone-eq f g c)
is-fiberwise-equiv-htpy-cone-eq f g {C = C} c =
fundamental-theorem-id c
( htpy-cone-eq f g c c refl)
( is-contr-total-htpy-cone f g c)
( htpy-cone-eq f g c)
equiv-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) {C : UU l4} (c c' : cone f g C) →
Id c c' ≃ htpy-cone f g c c'
equiv-htpy-cone f g c c' =
pair (htpy-cone-eq f g c c') (is-fiberwise-equiv-htpy-cone-eq f g c c')
{- The inverse of htpy-cone-eq is the map eq-htpy-cone. -}
eq-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
{f : A → X} {g : B → X} {C : UU l4} (c c' : cone f g C) →
htpy-cone f g c c' → Id c c'
eq-htpy-cone {f = f} {g = g} c c' =
inv-is-equiv (is-fiberwise-equiv-htpy-cone-eq f g c c')
{- This completes our characterization of the identity type of the type of
cones with a fixed vertex C. -}
{- We now conclude the universal property of pullbacks as the following
statement of contractibility. -}
abstract
is-contr-universal-property-pullback :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
universal-property-pullback l5 f g c →
(C' : UU l5) (c' : cone f g C') →
is-contr (Σ (C' → C) (λ h → htpy-cone f g (cone-map f g c h) c'))
is-contr-universal-property-pullback {C = C} f g c up C' c' =
is-contr-equiv'
( Σ (C' → C) (λ h → Id (cone-map f g c h) c'))
( equiv-tot
(λ h → equiv-htpy-cone f g (cone-map f g c h) c'))
( is-contr-map-is-equiv (up C') c')
-- Section 13.2
{- The canonical pullback is a type which can be equipped with a cone that
satisfies the universal property of a pullback. -}
canonical-pullback : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → UU ((l1 ⊔ l2) ⊔ l3)
canonical-pullback {A = A} {B = B} f g = Σ A (λ x → Σ B (λ y → Id (f x) (g y)))
{- We construct the maps and homotopies that are part of the cone structure of
the canonical pullback. -}
π₁ : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
{f : A → X} {g : B → X} → canonical-pullback f g → A
π₁ = pr1
π₂ : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
{f : A → X} {g : B → X} → canonical-pullback f g → B
π₂ t = pr1 (pr2 t)
π₃ : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {f : A → X}
{g : B → X} → (f ∘ (π₁ {f = f} {g = g})) ~ (g ∘ (π₂ {f = f} {g = g}))
π₃ t = pr2 (pr2 t)
cone-canonical-pullback : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → cone f g (canonical-pullback f g)
cone-canonical-pullback f g = pair π₁ (pair π₂ π₃)
{- We show now that the canonical pullback satisfies the universal property of
a pullback. -}
abstract
universal-property-pullback-canonical-pullback : {l1 l2 l3 l4 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X) →
universal-property-pullback l4 f g (cone-canonical-pullback f g)
universal-property-pullback-canonical-pullback f g C =
is-equiv-comp
( cone-map f g (cone-canonical-pullback f g))
( tot (λ p → choice-∞))
( mapping-into-Σ)
( htpy-refl)
( is-equiv-mapping-into-Σ)
( is-equiv-tot-is-fiberwise-equiv
( λ p → is-equiv-choice-∞))
{- Next we establish a '3-for-2' property for pullbacks. -}
triangle-cone-cone : {l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4} {C' : UU l5}
{f : A → X} {g : B → X} (c : cone f g C) (c' : cone f g C')
(h : C' → C) (KLM : htpy-cone f g (cone-map f g c h) c') (D : UU l6) →
(cone-map f g {C' = D} c') ~ ((cone-map f g c) ∘ (λ (k : D → C') → h ∘ k))
triangle-cone-cone {C' = C'} {f = f} {g = g} c c' h KLM D k =
inv (ap
( λ t → cone-map f g {C' = D} t k)
{ x = (cone-map f g c h)}
{ y = c'}
( eq-htpy-cone (cone-map f g c h) c' KLM))
abstract
is-equiv-up-pullback-up-pullback : {l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4} {C' : UU l5}
(f : A → X) (g : B → X) (c : cone f g C) (c' : cone f g C')
(h : C' → C) (KLM : htpy-cone f g (cone-map f g c h) c') →
({l : Level} → universal-property-pullback l f g c) →
({l : Level} → universal-property-pullback l f g c') →
is-equiv h
is-equiv-up-pullback-up-pullback {C = C} {C' = C'} f g c c' h KLM up up' =
is-equiv-is-equiv-postcomp h
( λ D → is-equiv-right-factor
( cone-map f g {C' = D} c')
( cone-map f g c)
( λ (k : D → C') → h ∘ k)
( triangle-cone-cone {C = C} {C' = C'} {f = f} {g = g} c c' h KLM D)
( up D) (up' D))
abstract
up-pullback-up-pullback-is-equiv : {l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4} {C' : UU l5}
(f : A → X) (g : B → X) (c : cone f g C) (c' : cone f g C')
(h : C' → C) (KLM : htpy-cone f g (cone-map f g c h) c') → is-equiv h →
({l : Level} → universal-property-pullback l f g c) →
({l : Level} → universal-property-pullback l f g c')
up-pullback-up-pullback-is-equiv f g c c' h KLM is-equiv-h up D =
is-equiv-comp
( cone-map f g c')
( cone-map f g c)
( λ k → h ∘ k)
( triangle-cone-cone {f = f} {g = g} c c' h KLM D)
( is-equiv-postcomp-is-equiv h is-equiv-h D)
( up D)
abstract
up-pullback-is-equiv-up-pullback : {l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4} {C' : UU l5}
(f : A → X) (g : B → X) (c : cone f g C) (c' : cone f g C')
(h : C' → C) (KLM : htpy-cone f g (cone-map f g c h) c') →
({l : Level} → universal-property-pullback l f g c') →
is-equiv h →
({l : Level} → universal-property-pullback l f g c)
up-pullback-is-equiv-up-pullback f g c c' h KLM up' is-equiv-h D =
is-equiv-left-factor
( cone-map f g c')
( cone-map f g c)
( λ k → h ∘ k)
( triangle-cone-cone {f = f} {g = g} c c' h KLM D)
( up' D)
( is-equiv-postcomp-is-equiv h is-equiv-h D)
{- This concludes the '3-for-2-property' of pullbacks. -}
{- We characterize the identity type of the canonical pullback. -}
Eq-canonical-pullback :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (t t' : canonical-pullback f g) → UU (l1 ⊔ (l2 ⊔ l3))
Eq-canonical-pullback f g (pair a bp) t' =
let b = pr1 bp
p = pr2 bp
a' = pr1 t'
b' = pr1 (pr2 t')
p' = pr2 (pr2 t')
in
Σ (Id a a') (λ α → Σ (Id b b') (λ β → Id ((ap f α) ∙ p') (p ∙ (ap g β))))
reflexive-Eq-canonical-pullback :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (t : canonical-pullback f g) →
Eq-canonical-pullback f g t t
reflexive-Eq-canonical-pullback f g (pair a (pair b p)) =
pair refl (pair refl (inv right-unit))
Eq-canonical-pullback-eq :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (t t' : canonical-pullback f g) →
Id t t' → Eq-canonical-pullback f g t t'
Eq-canonical-pullback-eq f g t .t refl =
reflexive-Eq-canonical-pullback f g t
abstract
is-contr-total-Eq-canonical-pullback :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (t : canonical-pullback f g) →
is-contr (Σ (canonical-pullback f g) (Eq-canonical-pullback f g t))
is-contr-total-Eq-canonical-pullback f g (pair a (pair b p)) =
is-contr-total-Eq-structure
( λ a' bp' α →
Σ (Id b (pr1 bp')) (λ β → Id ((ap f α) ∙ (pr2 bp')) (p ∙ (ap g β))))
( is-contr-total-path a)
( pair a refl)
( is-contr-total-Eq-structure
( λ b' p' β → Id ((ap f refl) ∙ p') (p ∙ (ap g β)))
( is-contr-total-path b)
( pair b refl)
( is-contr-equiv'
( Σ (Id (f a) (g b)) (λ p' → Id p p'))
( equiv-tot
( λ p' → (equiv-concat' p' (inv right-unit)) ∘e (equiv-inv p p')))
( is-contr-total-path p)))
abstract
is-equiv-Eq-canonical-pullback-eq :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (t t' : canonical-pullback f g) →
is-equiv (Eq-canonical-pullback-eq f g t t')
is-equiv-Eq-canonical-pullback-eq f g t =
fundamental-theorem-id t
( reflexive-Eq-canonical-pullback f g t)
( is-contr-total-Eq-canonical-pullback f g t)
( Eq-canonical-pullback-eq f g t)
eq-Eq-canonical-pullback :
{ l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
( f : A → X) (g : B → X) {t t' : canonical-pullback f g} →
( α : Id (pr1 t) (pr1 t')) (β : Id (pr1 (pr2 t)) (pr1 (pr2 t'))) →
( Id ((ap f α) ∙ (pr2 (pr2 t'))) ((pr2 (pr2 t)) ∙ (ap g β))) → Id t t'
eq-Eq-canonical-pullback f g {pair a (pair b p)} {pair a' (pair b' p')} α β γ =
inv-is-equiv
( is-equiv-Eq-canonical-pullback-eq f g
( pair a (pair b p))
( pair a' (pair b' p')))
( pair α (pair β γ))
{- We establish the uniquely uniqueness of pullbacks. -}
htpy-cone-map-universal-property-pullback :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X) {C : UU l4} (c : cone f g C) →
(up-c : {l : Level} → universal-property-pullback l f g c) →
{C' : UU l5} (c' : cone f g C') →
htpy-cone f g
( cone-map f g c (map-universal-property-pullback f g c up-c c'))
( c')
htpy-cone-map-universal-property-pullback f g c up-c c' =
htpy-cone-eq f g
( cone-map f g c (map-universal-property-pullback f g c up-c c'))
( c')
( eq-map-universal-property-pullback f g c up-c c')
abstract
uniquely-unique-pullback :
{ l1 l2 l3 l4 l5 : Level}
{ A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4} {C' : UU l5}
( f : A → X) (g : B → X) (c : cone f g C) (c' : cone f g C') →
( {l : Level} → universal-property-pullback l f g c') →
( {l : Level} → universal-property-pullback l f g c) →
is-contr
( Σ (C' ≃ C) (λ h → htpy-cone f g (cone-map f g c (map-equiv h)) c'))
uniquely-unique-pullback {C = C} {C' = C'} f g c c' up-c' up-c =
is-contr-total-Eq-substructure
( is-contr-universal-property-pullback f g c up-c C' c')
( is-subtype-is-equiv)
( map-universal-property-pullback f g c up-c c')
( htpy-cone-map-universal-property-pullback f g c up-c c')
( is-equiv-up-pullback-up-pullback f g c c'
( map-universal-property-pullback f g c up-c c')
( htpy-cone-map-universal-property-pullback f g c up-c c')
up-c up-c')
{- The gap map of a square is the map fron the vertex of the cone into the
canonical pullback. -}
gap :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) → cone f g C → C → canonical-pullback f g
gap f g c z = pair ((pr1 c) z) (pair ((pr1 (pr2 c)) z) ((pr2 (pr2 c)) z))
{- The proposition is-pullback is the assertion that the gap map is an
equivalence. Note that this proposition is small, whereas the universal
property is a large proposition. Of course, we will show below that the
proposition is-pullback is equivalent to the universal property of
pullbacks. -}
is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) → cone f g C → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
is-pullback f g c = is-equiv (gap f g c)
{- We first establish that a cone is equal to the value of cone-map at
its own gap map. -}
htpy-cone-up-pullback-canonical-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
htpy-cone f g (cone-map f g (cone-canonical-pullback f g) (gap f g c)) c
htpy-cone-up-pullback-canonical-pullback f g c =
pair htpy-refl ( pair htpy-refl htpy-right-unit)
{- We show that the universal property of the pullback implies that the gap
map is an equivalence. -}
abstract
is-pullback-up-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
({l : Level} → universal-property-pullback l f g c) → is-pullback f g c
is-pullback-up-pullback f g c up =
is-equiv-up-pullback-up-pullback f g
( cone-canonical-pullback f g)
( c)
( gap f g c)
( htpy-cone-up-pullback-canonical-pullback f g c)
( universal-property-pullback-canonical-pullback f g)
( up)
{- We show that the universal property follows from the assumption that the
the gap map is an equivalence. -}
abstract
up-pullback-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → ({l : Level} → universal-property-pullback l f g c)
up-pullback-is-pullback f g c is-pullback-c =
up-pullback-up-pullback-is-equiv f g
( cone-canonical-pullback f g)
( c)
( gap f g c)
( htpy-cone-up-pullback-canonical-pullback f g c)
( is-pullback-c)
( universal-property-pullback-canonical-pullback f g)
-- Section 13.3 Fiber products
{- We construct the cone for two maps into the unit type. -}
cone-prod :
{i j : Level} (A : UU i) (B : UU j) →
cone (const A unit star) (const B unit star) (A × B)
cone-prod A B = pair pr1 (pair pr2 htpy-refl)
{- Cartesian products are a special case of pullbacks. -}
inv-gap-prod :
{i j : Level} (A : UU i) (B : UU j) →
canonical-pullback (const A unit star) (const B unit star) → A × B
inv-gap-prod A B (pair a (pair b p)) = pair a b
issec-inv-gap-prod :
{i j : Level} (A : UU i) (B : UU j) →
( ( gap (const A unit star) (const B unit star) (cone-prod A B)) ∘
( inv-gap-prod A B)) ~ id
issec-inv-gap-prod A B (pair a (pair b p)) =
eq-Eq-canonical-pullback
( const A unit star)
( const B unit star)
refl
refl
( is-prop-is-contr' (is-prop-is-contr is-contr-unit star star) p refl)
isretr-inv-gap-prod :
{i j : Level} (A : UU i) (B : UU j) →
( ( inv-gap-prod A B) ∘
( gap (const A unit star) (const B unit star) (cone-prod A B))) ~ id
isretr-inv-gap-prod A B (pair a b) =
eq-pair refl refl
abstract
is-pullback-prod :
{i j : Level} (A : UU i) (B : UU j) →
is-pullback (const A unit star) (const B unit star) (cone-prod A B)
is-pullback-prod A B =
is-equiv-has-inverse
( inv-gap-prod A B)
( issec-inv-gap-prod A B)
( isretr-inv-gap-prod A B)
{- We conclude that cartesian products satisfy the universal property of
pullbacks. -}
abstract
universal-property-pullback-prod :
{i j : Level} (A : UU i) (B : UU j) →
{l : Level} → universal-property-pullback l
( const A unit star)
( const B unit star)
( cone-prod A B)
universal-property-pullback-prod A B =
up-pullback-is-pullback
( const A unit star)
( const B unit star)
( cone-prod A B)
( is-pullback-prod A B)
{- Similar as the above, but now for families of products. -}
cone-fiberwise-prod :
{l1 l2 l3 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
cone (pr1 {A = X} {B = P}) (pr1 {A = X} {B = Q}) (Σ X (λ x → (P x) × (Q x)))
cone-fiberwise-prod P Q =
pair
( tot (λ x → pr1))
( pair
( tot (λ x → pr2))
( htpy-refl))
{- We will show that the fiberwise product is a pullback by showing that the
gap map is an equivalence. We do this by directly construct an inverse to
the gap map. -}
inv-gap-fiberwise-prod :
{l1 l2 l3 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
canonical-pullback (pr1 {B = P}) (pr1 {B = Q}) → Σ X (λ x → (P x) × (Q x))
inv-gap-fiberwise-prod P Q (pair (pair x p) (pair (pair .x q) refl)) =
pair x (pair p q)
issec-inv-gap-fiberwise-prod :
{l1 l2 l3 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
((gap (pr1 {B = P}) (pr1 {B = Q}) (cone-fiberwise-prod P Q)) ∘
(inv-gap-fiberwise-prod P Q)) ~ id
issec-inv-gap-fiberwise-prod P Q (pair (pair x p) (pair (pair .x q) refl)) =
eq-pair refl (eq-pair refl refl)
isretr-inv-gap-fiberwise-prod :
{l1 l2 l3 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
( ( inv-gap-fiberwise-prod P Q) ∘
( gap (pr1 {B = P}) (pr1 {B = Q}) (cone-fiberwise-prod P Q))) ~ id
isretr-inv-gap-fiberwise-prod P Q (pair x (pair p q)) = refl
{- With all the pieces in place we conclude that the fiberwise product is a
pullback. -}
abstract
is-pullback-fiberwise-prod :
{l1 l2 l3 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
is-pullback (pr1 {A = X} {B = P}) (pr1 {A = X} {B = Q})
(cone-fiberwise-prod P Q)
is-pullback-fiberwise-prod P Q =
is-equiv-has-inverse
( inv-gap-fiberwise-prod P Q)
( issec-inv-gap-fiberwise-prod P Q)
( isretr-inv-gap-fiberwise-prod P Q)
{- Furthermore we conclude that the fiberwise product satisfies the universal
property of pullbacks. -}
abstract
universal-property-pullback-fiberwise-prod :
{l1 l2 l3 l4 : Level} {X : UU l1} (P : X → UU l2) (Q : X → UU l3) →
universal-property-pullback l4 (pr1 {B = P}) (pr1 {B = Q})
(cone-fiberwise-prod P Q)
universal-property-pullback-fiberwise-prod P Q =
up-pullback-is-pullback pr1 pr1
( cone-fiberwise-prod P Q)
( is-pullback-fiberwise-prod P Q)
{- We now generalize the above to arbitrary maps and their fibers. -}
cone-total-prod-fibers :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → cone f g (Σ X (λ x → (fib f x) × (fib g x)))
cone-total-prod-fibers f g =
pair
( λ t → pr1 (pr1 (pr2 t)))
( pair
( λ t → pr1 (pr2 (pr2 t)))
( λ t → (pr2 (pr1 (pr2 t))) ∙ (inv (pr2 (pr2 (pr2 t))))))
cone-span :
{l1 l2 l3 l4 l5 l6 : Level} {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X)
{A' : UU l4} {B' : UU l5} {C : A' → B' → UU l6}
(i : A' → A) (j : B' → B)
(k : (x : A') (y : B') → C x y → Id (f (i x)) (g (j y))) →
cone f g (Σ A' (λ x → Σ B' (C x)))
cone-span f g i j k =
pair
( λ t → i (pr1 t))
( pair
( λ t → j (pr1 (pr2 t)))
( λ t → k (pr1 t) (pr1 (pr2 t)) (pr2 (pr2 t))))
abstract
is-pullback-cone-span-is-equiv :
{l1 l2 l3 l4 l5 l6 : Level} {A : UU l1} {B : UU l2}
{X : UU l3} (f : A → X) (g : B → X)
{A' : UU l4} {B' : UU l5} {C : A' → B' → UU l6}
(i : A' → A) (j : B' → B)
(k : (x' : A') (y' : B') → C x' y' → Id (f (i x')) (g (j y'))) →
is-equiv i → is-equiv j → ((x : A') (y : B') → is-equiv (k x y)) →
is-pullback f g (cone-span f g i j k)
is-pullback-cone-span-is-equiv {B = B} f g i j k
is-equiv-i is-equiv-j is-equiv-k =
is-equiv-toto-is-fiberwise-equiv-is-equiv-base-map
( λ x → Σ B (λ y → Id (f x) (g y)))
( i)
( λ x' → toto (λ y → Id (f (i x')) (g y)) j (k x'))
( is-equiv-i)
( λ x' → is-equiv-toto-is-fiberwise-equiv-is-equiv-base-map
( λ y → Id (f (i x')) (g y))
( j)
( k x')
( is-equiv-j)
( is-equiv-k x'))
abstract
is-pullback-total-prod-fibers :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) →
is-pullback f g (cone-total-prod-fibers f g)
is-pullback-total-prod-fibers f g =
is-equiv-comp
( gap f g (cone-total-prod-fibers f g))
( gap f g
(cone-span f g
( Σ-fib-to-domain f)
( Σ-fib-to-domain g)
( λ s t α → (pr2 (pr2 s)) ∙ (α ∙ (inv (pr2 (pr2 t)))))))
( gap
( pr1 {B = fib f})
( pr1 {B = fib g})
( cone-fiberwise-prod (fib f) (fib g)))
( λ t → refl)
( is-pullback-fiberwise-prod (fib f) (fib g))
( is-pullback-cone-span-is-equiv f g
( Σ-fib-to-domain f)
( Σ-fib-to-domain g)
( λ s t α → (pr2 (pr2 s)) ∙ (α ∙ (inv (pr2 (pr2 t)))))
( is-equiv-Σ-fib-to-domain f)
( is-equiv-Σ-fib-to-domain g)
( λ s t → is-equiv-comp _
( concat (pr2 (pr2 s)) (g (pr1 (pr2 t))))
( concat' (pr1 s) (inv (pr2 (pr2 t))))
( htpy-refl)
( is-equiv-concat' (pr1 s) (inv (pr2 (pr2 t))))
( is-equiv-concat (pr2 (pr2 s)) (g (pr1 (pr2 t))))))
-- Section 13.4 Fibers as pullbacks
square-fiber :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) (b : B) →
( f ∘ (pr1 {B = λ x → Id (f x) b})) ~
( (const unit B b) ∘ (const (fib f b) unit star))
square-fiber f b = pr2
cone-fiber :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) (b : B) →
cone f (const unit B b) (fib f b)
cone-fiber f b =
pair pr1 (pair (const (fib f b) unit star) (square-fiber f b))
abstract
is-pullback-cone-fiber :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
(b : B) → is-pullback f (const unit B b) (cone-fiber f b)
is-pullback-cone-fiber f b =
is-equiv-tot-is-fiberwise-equiv ( λ a →
is-equiv-left-unit-law-Σ-map-gen (λ t → Id (f a) b) is-contr-unit star)
abstract
universal-property-pullback-cone-fiber :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (b : B) →
universal-property-pullback l3 f (const unit B b) (cone-fiber f b)
universal-property-pullback-cone-fiber {B = B} f b =
up-pullback-is-pullback f (const unit B b)
( cone-fiber f b)
( is-pullback-cone-fiber f b)
cone-fiber-fam :
{l1 l2 : Level} {A : UU l1} (B : A → UU l2)
(a : A) → cone (pr1 {B = B}) (const unit A a) (B a)
cone-fiber-fam B a =
pair (λ b → pair a b) (pair (const (B a) unit star) (λ b → refl))
abstract
is-pullback-cone-fiber-fam :
{l1 l2 : Level} {A : UU l1} (B : A → UU l2) →
(a : A) → is-pullback (pr1 {B = B}) (const unit A a) (cone-fiber-fam B a)
is-pullback-cone-fiber-fam {A = A} B a =
is-equiv-comp
( gap (pr1 {B = B}) (const unit A a) (cone-fiber-fam B a))
( gap (pr1 {B = B}) (const unit A a) (cone-fiber (pr1 {B = B}) a))
( fib-pr1-fib-fam B a)
( λ y → refl)
( is-equiv-fib-pr1-fib-fam B a)
( is-pullback-cone-fiber pr1 a)
-- Section 13.5 Fiberwise equivalences
cone-subst :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (Q : B → UU l3) →
cone f (pr1 {B = Q}) (Σ A (λ x → Q (f x)))
cone-subst f Q =
pair pr1 (pair (Σ-map-base-map f Q) (λ t → refl))
inv-gap-cone-subst :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (Q : B → UU l3) →
canonical-pullback f (pr1 {B = Q}) → Σ A (λ x → Q (f x))
inv-gap-cone-subst f Q (pair x (pair (pair .(f x) q) refl)) =
pair x q
issec-inv-gap-cone-subst :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (Q : B → UU l3) →
((gap f (pr1 {B = Q}) (cone-subst f Q)) ∘ (inv-gap-cone-subst f Q)) ~ id
issec-inv-gap-cone-subst f Q (pair x (pair (pair .(f x) q) refl)) =
refl
isretr-inv-gap-cone-subst :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (Q : B → UU l3) →
((inv-gap-cone-subst f Q) ∘ (gap f (pr1 {B = Q}) (cone-subst f Q))) ~ id
isretr-inv-gap-cone-subst f Q (pair x q) =
refl
abstract
is-pullback-cone-subst :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (Q : B → UU l3) →
is-pullback f (pr1 {B = Q}) (cone-subst f Q)
is-pullback-cone-subst f Q =
is-equiv-has-inverse
( inv-gap-cone-subst f Q)
( issec-inv-gap-cone-subst f Q)
( isretr-inv-gap-cone-subst f Q)
cone-toto :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3}
(Q : B → UU l4) (f : A → B) (g : (x : A) → (P x) → (Q (f x))) →
cone f (pr1 {B = Q}) (Σ A P)
cone-toto Q f g = pair pr1 (pair (toto Q f g) (λ t → refl))
abstract
is-pullback-is-fiberwise-equiv :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3}
(Q : B → UU l4) (f : A → B) (g : (x : A) → (P x) → (Q (f x))) →
is-fiberwise-equiv g → is-pullback f (pr1 {B = Q}) (cone-toto Q f g)
is-pullback-is-fiberwise-equiv Q f g is-equiv-g =
is-equiv-comp
( gap f pr1 (cone-toto Q f g))
( gap f pr1 (cone-subst f Q))
( tot g)
( λ t → refl)
( is-equiv-tot-is-fiberwise-equiv is-equiv-g)
( is-pullback-cone-subst f Q)
abstract
universal-property-pullback-is-fiberwise-equiv :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3}
(Q : B → UU l4) (f : A → B) (g : (x : A) → (P x) → (Q (f x))) →
is-fiberwise-equiv g →
universal-property-pullback l5 f (pr1 {B = Q}) (cone-toto Q f g)
universal-property-pullback-is-fiberwise-equiv Q f g is-equiv-g =
up-pullback-is-pullback f pr1 (cone-toto Q f g)
( is-pullback-is-fiberwise-equiv Q f g is-equiv-g)
abstract
is-fiberwise-equiv-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3}
(Q : B → UU l4) (f : A → B) (g : (x : A) → (P x) → (Q (f x))) →
is-pullback f (pr1 {B = Q}) (cone-toto Q f g) → is-fiberwise-equiv g
is-fiberwise-equiv-is-pullback Q f g is-pullback-cone-toto =
is-fiberwise-equiv-is-equiv-tot g
( is-equiv-right-factor
( gap f pr1 (cone-toto Q f g))
( gap f pr1 (cone-subst f Q))
( tot g)
( λ t → refl)
( is-pullback-cone-subst f Q)
( is-pullback-cone-toto))
abstract
is-fiberwise-equiv-universal-property-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3}
(Q : B → UU l4) (f : A → B) (g : (x : A) → (P x) → (Q (f x))) →
( {l : Level} → universal-property-pullback l f (pr1 {B = Q})
(cone-toto Q f g)) →
is-fiberwise-equiv g
is-fiberwise-equiv-universal-property-pullback Q f g up =
is-fiberwise-equiv-is-pullback Q f g
( is-pullback-up-pullback f pr1 (cone-toto Q f g) up)
fib-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
(x : A) → fib (pr1 c) x → fib g (f x)
fib-square f g c x t =
let p = pr1 c
q = pr1 (pr2 c)
H = pr2 (pr2 c)
in
pair (q (pr1 t) ) ((inv (H (pr1 t))) ∙ (ap f (pr2 t)))
fib-square-id :
{l1 l2 : Level} {B : UU l1} {X : UU l2} (g : B → X) (x : X) →
fib-square id g (pair g (pair id htpy-refl)) x ~ id
fib-square-id g .(g b) (pair b refl) =
refl
square-tot-fib-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
( (gap f g c) ∘ (Σ-fib-to-domain (pr1 c))) ~
( (tot (λ a → tot (λ b → inv))) ∘ (tot (fib-square f g c)))
square-tot-fib-square f g c (pair .((pr1 c) x) (pair x refl)) =
let p = pr1 c
q = pr1 (pr2 c)
H = pr2 (pr2 c)
in
eq-pair refl
( eq-pair refl
( inv ((ap inv right-unit) ∙ (inv-inv (H x)))))
abstract
is-fiberwise-equiv-fib-square-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-fiberwise-equiv (fib-square f g c)
is-fiberwise-equiv-fib-square-is-pullback f g c pb =
let p = pr1 c
q = pr1 (pr2 c)
H = pr2 (pr2 c)
in
is-fiberwise-equiv-is-equiv-tot
( fib-square f g c)
( is-equiv-top-is-equiv-bottom-square
( Σ-fib-to-domain p)
( tot (λ x → tot (λ y → inv)))
( tot (fib-square f g c))
( gap f g c)
( square-tot-fib-square f g c)
( is-equiv-Σ-fib-to-domain p)
( is-equiv-tot-is-fiberwise-equiv
( λ x → is-equiv-tot-is-fiberwise-equiv
( λ y → is-equiv-inv (g y) (f x))))
( pb))
abstract
is-pullback-is-fiberwise-equiv-fib-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-fiberwise-equiv (fib-square f g c) → is-pullback f g c
is-pullback-is-fiberwise-equiv-fib-square f g c is-equiv-fsq =
let p = pr1 c
q = pr1 (pr2 c)
H = pr2 (pr2 c)
in
is-equiv-bottom-is-equiv-top-square
( Σ-fib-to-domain p)
( tot (λ x → tot (λ y → inv)))
( tot (fib-square f g c))
( gap f g c)
( square-tot-fib-square f g c)
( is-equiv-Σ-fib-to-domain p)
( is-equiv-tot-is-fiberwise-equiv
( λ x → is-equiv-tot-is-fiberwise-equiv
( λ y → is-equiv-inv (g y) (f x))))
( is-equiv-tot-is-fiberwise-equiv is-equiv-fsq)
abstract
is-trunc-is-pullback :
{l1 l2 l3 l4 : Level} (k : 𝕋) {A : UU l1} {B : UU l2} {C : UU l3}
{X : UU l4} (f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-trunc-map k g → is-trunc-map k (pr1 c)
is-trunc-is-pullback k f g c pb is-trunc-g a =
is-trunc-is-equiv k
( fib g (f a))
( fib-square f g c a)
( is-fiberwise-equiv-fib-square-is-pullback f g c pb a)
(is-trunc-g (f a))
abstract
is-emb-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-emb g → is-emb (pr1 c)
is-emb-is-pullback f g c pb is-emb-g =
is-emb-is-prop-map
( pr1 c)
( is-trunc-is-pullback neg-one-𝕋 f g c pb (is-prop-map-is-emb g is-emb-g))
abstract
is-equiv-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-equiv g → is-pullback f g c → is-equiv (pr1 c)
is-equiv-is-pullback f g c is-equiv-g pb =
is-equiv-is-contr-map
( is-trunc-is-pullback neg-two-𝕋 f g c pb
( is-contr-map-is-equiv is-equiv-g))
abstract
is-pullback-is-equiv :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-equiv g → is-equiv (pr1 c) → is-pullback f g c
is-pullback-is-equiv f g c is-equiv-g is-equiv-p =
is-pullback-is-fiberwise-equiv-fib-square f g c
( λ a → is-equiv-is-contr
( fib-square f g c a)
( is-contr-map-is-equiv is-equiv-p a)
( is-contr-map-is-equiv is-equiv-g (f a)))
-- Section 13.6 The pullback pasting property
coherence-square-comp-horizontal :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(top-left : A → B) (top-right : B → C)
(left : A → X) (mid : B → Y) (right : C → Z)
(bottom-left : X → Y) (bottom-right : Y → Z) →
coherence-square top-left left mid bottom-left →
coherence-square top-right mid right bottom-right →
coherence-square
(top-right ∘ top-left) left right (bottom-right ∘ bottom-left)
coherence-square-comp-horizontal
top-left top-right left mid right bottom-left bottom-right sq-left sq-right =
(bottom-right ·l sq-left) ∙h (sq-right ·r top-left)
coherence-square-comp-vertical :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(top : A → X)
(left-top : A → B) (right-top : X → Y)
(mid : B → Y)
(left-bottom : B → C) (right-bottom : Y → Z)
(bottom : C → Z) →
coherence-square top left-top right-top mid →
coherence-square mid left-bottom right-bottom bottom →
coherence-square
top (left-bottom ∘ left-top) (right-bottom ∘ right-top) bottom
coherence-square-comp-vertical
top left-top right-top mid left-bottom right-bottom bottom sq-top sq-bottom =
(sq-bottom ·r left-top) ∙h (right-bottom ·l sq-top)
cone-comp-horizontal :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(i : X → Y) (j : Y → Z) (h : C → Z) →
(c : cone j h B) → (cone i (pr1 c) A) → cone (j ∘ i) h A
cone-comp-horizontal i j h c d =
pair
( pr1 d)
( pair
( (pr1 (pr2 c)) ∘ (pr1 (pr2 d)))
( coherence-square-comp-horizontal
(pr1 (pr2 d)) (pr1 (pr2 c)) (pr1 d) (pr1 c) h i j
(pr2 (pr2 d)) (pr2 (pr2 c))))
cone-comp-vertical :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(f : C → Z) (g : Y → Z) (h : X → Y) →
(c : cone f g B) → cone (pr1 (pr2 c)) h A → cone f (g ∘ h) A
cone-comp-vertical f g h c d =
pair
( (pr1 c) ∘ (pr1 d))
( pair
( pr1 (pr2 d))
( coherence-square-comp-vertical
( pr1 (pr2 d)) (pr1 d) h (pr1 (pr2 c)) (pr1 c) g f
( pr2 (pr2 d)) (pr2 (pr2 c))))
fib-square-comp-horizontal :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(i : X → Y) (j : Y → Z) (h : C → Z) →
(c : cone j h B) (d : cone i (pr1 c) A) → (x : X) →
( fib-square (j ∘ i) h (cone-comp-horizontal i j h c d) x) ~
( (fib-square j h c (i x)) ∘ (fib-square i (pr1 c) d x))
fib-square-comp-horizontal i j h c d .(pr1 d a) (pair a refl) =
let f = pr1 d
k = pr1 (pr2 d)
H = pr2 (pr2 d)
g = pr1 c
l = pr1 (pr2 c)
K = pr2 (pr2 c)
in
eq-pair refl
( ( ap
( concat' (h (l (k a))) refl)
( distributive-inv-concat (ap j (H a)) (K (k a)))) ∙
( ( assoc (inv (K (k a))) (inv (ap j (H a))) refl) ∙
( ap
( concat (inv (K (k a))) (j (i (f a))))
( ( ap (concat' (j (g (k a))) refl) (inv (ap-inv j (H a)))) ∙
( inv (ap-concat j (inv (H a)) refl))))))
fib-square-comp-vertical :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(f : C → Z) (g : Y → Z) (h : X → Y) →
(c : cone f g B) (d : cone (pr1 (pr2 c)) h A) (x : C) →
( ( fib-square f (g ∘ h) (cone-comp-vertical f g h c d) x) ∘
( inv-map-fib-comp (pr1 c) (pr1 d) x)) ~
( ( inv-map-fib-comp g h (f x)) ∘
( toto
( λ t → fib h (pr1 t))
( fib-square f g c x)
( λ t → fib-square (pr1 (pr2 c)) h d (pr1 t))))
fib-square-comp-vertical f g h
(pair p (pair q H)) (pair p' (pair q' H')) .(p (p' a))
(pair (pair .(p' a) refl) (pair a refl)) =
eq-pair refl
( ( right-unit) ∙
( ( distributive-inv-concat (H (p' a)) (ap g (H' a))) ∙
( ( ap
( concat (inv (ap g (H' a))) (f (p (p' a))))
( inv right-unit)) ∙
( ap
( concat' (g (h (q' a)))
( pr2
( fib-square f g
( pair p (pair q H))
( p (p' a))
( pair (p' a) refl))))
( ( inv (ap-inv g (H' a))) ∙
( ap (ap g) (inv right-unit)))))))
abstract
is-pullback-rectangle-is-pullback-left-square :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(i : X → Y) (j : Y → Z) (h : C → Z)
(c : cone j h B) (d : cone i (pr1 c) A) →
is-pullback j h c → is-pullback i (pr1 c) d →
is-pullback (j ∘ i) h (cone-comp-horizontal i j h c d)
is-pullback-rectangle-is-pullback-left-square i j h c d is-pb-c is-pb-d =
is-pullback-is-fiberwise-equiv-fib-square (j ∘ i) h
( cone-comp-horizontal i j h c d)
( λ x → is-equiv-comp
( fib-square (j ∘ i) h (cone-comp-horizontal i j h c d) x)
( fib-square j h c (i x))
( fib-square i (pr1 c) d x)
( fib-square-comp-horizontal i j h c d x)
( is-fiberwise-equiv-fib-square-is-pullback i (pr1 c) d is-pb-d x)
( is-fiberwise-equiv-fib-square-is-pullback j h c is-pb-c (i x)))
abstract
is-pullback-left-square-is-pullback-rectangle :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(i : X → Y) (j : Y → Z) (h : C → Z)
(c : cone j h B) (d : cone i (pr1 c) A) →
is-pullback j h c → is-pullback (j ∘ i) h (cone-comp-horizontal i j h c d) →
is-pullback i (pr1 c) d
is-pullback-left-square-is-pullback-rectangle i j h c d is-pb-c is-pb-rect =
is-pullback-is-fiberwise-equiv-fib-square i (pr1 c) d
( λ x → is-equiv-right-factor
( fib-square (j ∘ i) h (cone-comp-horizontal i j h c d) x)
( fib-square j h c (i x))
( fib-square i (pr1 c) d x)
( fib-square-comp-horizontal i j h c d x)
( is-fiberwise-equiv-fib-square-is-pullback j h c is-pb-c (i x))
( is-fiberwise-equiv-fib-square-is-pullback (j ∘ i) h
( cone-comp-horizontal i j h c d) is-pb-rect x))
abstract
is-pullback-top-is-pullback-rectangle :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(f : C → Z) (g : Y → Z) (h : X → Y) →
(c : cone f g B) (d : cone (pr1 (pr2 c)) h A) →
is-pullback f g c →
is-pullback f (g ∘ h) (cone-comp-vertical f g h c d) →
is-pullback (pr1 (pr2 c)) h d
is-pullback-top-is-pullback-rectangle f g h c d is-pb-c is-pb-dc =
is-pullback-is-fiberwise-equiv-fib-square (pr1 (pr2 c)) h d
( λ x → is-fiberwise-equiv-is-equiv-toto-is-equiv-base-map
( λ t → fib h (pr1 t))
( fib-square f g c ((pr1 c) x))
( λ t → fib-square (pr1 (pr2 c)) h d (pr1 t))
( is-fiberwise-equiv-fib-square-is-pullback f g c is-pb-c ((pr1 c) x))
( is-equiv-top-is-equiv-bottom-square
( inv-map-fib-comp (pr1 c) (pr1 d) ((pr1 c) x))
( inv-map-fib-comp g h (f ((pr1 c) x)))
( toto
( λ t → fib h (pr1 t))
( fib-square f g c ((pr1 c) x))
( λ t → fib-square (pr1 (pr2 c)) h d (pr1 t)))
( fib-square f (g ∘ h) (cone-comp-vertical f g h c d) ((pr1 c) x))
( fib-square-comp-vertical f g h c d ((pr1 c) x))
( is-equiv-inv-map-fib-comp (pr1 c) (pr1 d) ((pr1 c) x))
( is-equiv-inv-map-fib-comp g h (f ((pr1 c) x)))
( is-fiberwise-equiv-fib-square-is-pullback f (g ∘ h)
( cone-comp-vertical f g h c d) is-pb-dc ((pr1 c) x)))
( pair x refl))
abstract
is-pullback-rectangle-is-pullback-top :
{l1 l2 l3 l4 l5 l6 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
(f : C → Z) (g : Y → Z) (h : X → Y) →
(c : cone f g B) (d : cone (pr1 (pr2 c)) h A) →
is-pullback f g c →
is-pullback (pr1 (pr2 c)) h d →
is-pullback f (g ∘ h) (cone-comp-vertical f g h c d)
is-pullback-rectangle-is-pullback-top f g h c d is-pb-c is-pb-d =
is-pullback-is-fiberwise-equiv-fib-square f (g ∘ h)
( cone-comp-vertical f g h c d)
( λ x → is-equiv-bottom-is-equiv-top-square
( inv-map-fib-comp (pr1 c) (pr1 d) x)
( inv-map-fib-comp g h (f x))
( toto
( λ t → fib h (pr1 t))
( fib-square f g c x)
( λ t → fib-square (pr1 (pr2 c)) h d (pr1 t)))
( fib-square f (g ∘ h) (cone-comp-vertical f g h c d) x)
( fib-square-comp-vertical f g h c d x)
( is-equiv-inv-map-fib-comp (pr1 c) (pr1 d) x)
( is-equiv-inv-map-fib-comp g h (f x))
( is-equiv-toto-is-fiberwise-equiv-is-equiv-base-map
( λ t → fib h (pr1 t))
( fib-square f g c x)
( λ t → fib-square (pr1 (pr2 c)) h d (pr1 t))
( is-fiberwise-equiv-fib-square-is-pullback f g c is-pb-c x)
( λ t → is-fiberwise-equiv-fib-square-is-pullback
(pr1 (pr2 c)) h d is-pb-d (pr1 t))))
-- Section 13.7 Descent for coproducts and Σ-types
fib-functor-coprod-inl-fib : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (x : A) →
fib f x → fib (functor-coprod f g) (inl x)
fib-functor-coprod-inl-fib f g x (pair a' p) =
pair (inl a') (ap inl p)
fib-fib-functor-coprod-inl : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (x : A) →
fib (functor-coprod f g) (inl x) → fib f x
fib-fib-functor-coprod-inl f g x (pair (inl a') p) =
pair a' (map-compute-eq-coprod-inl-inl (f a') x p)
fib-fib-functor-coprod-inl f g x (pair (inr b') p) =
ind-empty {P = λ t → fib f x}
( map-compute-eq-coprod-inr-inl (g b') x p)
issec-fib-fib-functor-coprod-inl : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (x : A) →
( (fib-functor-coprod-inl-fib f g x) ∘
( fib-fib-functor-coprod-inl f g x)) ~ id
issec-fib-fib-functor-coprod-inl f g .(f a') (pair (inl a') refl) =
eq-pair refl
( ap (ap inl)
( isretr-inv-is-equiv
( is-equiv-map-raise _ (Id (f a') (f a'))) refl))
issec-fib-fib-functor-coprod-inl f g x (pair (inr b') p) =
ind-empty
{ P = λ t → Id
( fib-functor-coprod-inl-fib f g x
( fib-fib-functor-coprod-inl f g x (pair (inr b') p)))
( pair (inr b') p)}
( map-compute-eq-coprod-inr-inl (g b') x p)
isretr-fib-fib-functor-coprod-inl : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (x : A) →
( (fib-fib-functor-coprod-inl f g x) ∘
( fib-functor-coprod-inl-fib f g x)) ~ id
isretr-fib-fib-functor-coprod-inl f g .(f a') (pair a' refl) =
eq-pair refl
( isretr-inv-is-equiv (is-equiv-map-raise _ (Id (f a') (f a'))) refl)
abstract
is-equiv-fib-functor-coprod-inl-fib : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (x : A) →
is-equiv (fib-functor-coprod-inl-fib f g x)
is-equiv-fib-functor-coprod-inl-fib f g x =
is-equiv-has-inverse
( fib-fib-functor-coprod-inl f g x)
( issec-fib-fib-functor-coprod-inl f g x)
( isretr-fib-fib-functor-coprod-inl f g x)
fib-functor-coprod-inr-fib : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (y : B) →
fib g y → fib (functor-coprod f g) (inr y)
fib-functor-coprod-inr-fib f g y (pair b' p) =
pair (inr b') (ap inr p)
fib-fib-functor-coprod-inr : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (y : B) →
fib (functor-coprod f g) (inr y) → fib g y
fib-fib-functor-coprod-inr f g y (pair (inl a') p) =
ind-empty {P = λ t → fib g y}
( map-compute-eq-coprod-inl-inr (f a') y p)
fib-fib-functor-coprod-inr f g y (pair (inr b') p) =
pair b' (map-compute-eq-coprod-inr-inr (g b') y p)
issec-fib-fib-functor-coprod-inr : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (y : B) →
( (fib-functor-coprod-inr-fib f g y) ∘
( fib-fib-functor-coprod-inr f g y)) ~ id
issec-fib-fib-functor-coprod-inr f g .(g b') (pair (inr b') refl) =
eq-pair refl
( ap (ap inr)
( isretr-inv-is-equiv
( is-equiv-map-raise _ (Id (g b') (g b'))) refl))
issec-fib-fib-functor-coprod-inr f g y (pair (inl a') p) =
ind-empty
{ P = λ t → Id
( fib-functor-coprod-inr-fib f g y
( fib-fib-functor-coprod-inr f g y (pair (inl a') p)))
( pair (inl a') p)}
( map-compute-eq-coprod-inl-inr (f a') y p)
isretr-fib-fib-functor-coprod-inr : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (y : B) →
( (fib-fib-functor-coprod-inr f g y) ∘
( fib-functor-coprod-inr-fib f g y)) ~ id
isretr-fib-fib-functor-coprod-inr f g .(g b') (pair b' refl) =
eq-pair refl
( isretr-inv-is-equiv (is-equiv-map-raise _ (Id (g b') (g b'))) refl)
abstract
is-equiv-fib-functor-coprod-inr-fib : {l1 l2 l1' l2' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
(f : A' → A) (g : B' → B) (y : B) →
is-equiv (fib-functor-coprod-inr-fib f g y)
is-equiv-fib-functor-coprod-inr-fib f g y =
is-equiv-has-inverse
( fib-fib-functor-coprod-inr f g y)
( issec-fib-fib-functor-coprod-inr f g y)
( isretr-fib-fib-functor-coprod-inr f g y)
cone-descent-coprod : {l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (i : X' → X)
(cone-A' : cone f i A') (cone-B' : cone g i B') →
cone (ind-coprod _ f g) i (coprod A' B')
cone-descent-coprod f g i (pair h (pair f' H)) (pair k (pair g' K)) =
pair
( functor-coprod h k)
( pair
( ind-coprod _ f' g')
( ind-coprod _ H K))
triangle-descent-square-fib-functor-coprod-inl-fib :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A' → A) (g : B' → B) (h : X' → X)
(αA : A → X) (αB : B → X) (αA' : A' → X') (αB' : B' → X')
(HA : (αA ∘ f) ~ (h ∘ αA')) (HB : (αB ∘ g) ~ (h ∘ αB')) (x : A) →
(fib-square αA h (pair f (pair αA' HA)) x) ~
( (fib-square (ind-coprod _ αA αB) h
( pair
( functor-coprod f g)
( pair (ind-coprod _ αA' αB') (ind-coprod _ HA HB))) (inl x)) ∘
( fib-functor-coprod-inl-fib f g x))
triangle-descent-square-fib-functor-coprod-inl-fib
{X = X} {X' = X'} f g h αA αB αA' αB' HA HB x (pair a' p) =
eq-pair refl
( ap (concat (inv (HA a')) (αA x))
( ap-comp (ind-coprod _ αA αB) inl p))
triangle-descent-square-fib-functor-coprod-inr-fib :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A' → A) (g : B' → B) (h : X' → X)
(αA : A → X) (αB : B → X) (αA' : A' → X') (αB' : B' → X')
(HA : (αA ∘ f) ~ (h ∘ αA')) (HB : (αB ∘ g) ~ (h ∘ αB')) (y : B) →
(fib-square αB h (pair g (pair αB' HB)) y) ~
( (fib-square (ind-coprod _ αA αB) h
( pair
( functor-coprod f g)
( pair (ind-coprod _ αA' αB') (ind-coprod _ HA HB))) (inr y)) ∘
( fib-functor-coprod-inr-fib f g y))
triangle-descent-square-fib-functor-coprod-inr-fib
{X = X} {X' = X'} f g h αA αB αA' αB' HA HB y ( pair b' p) =
eq-pair refl
( ap (concat (inv (HB b')) (αB y))
( ap-comp (ind-coprod _ αA αB) inr p))
abstract
descent-coprod : {l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (i : X' → X)
(cone-A' : cone f i A') (cone-B' : cone g i B') →
is-pullback f i cone-A' →
is-pullback g i cone-B' →
is-pullback (ind-coprod _ f g) i (cone-descent-coprod f g i cone-A' cone-B')
descent-coprod f g i (pair h (pair f' H)) (pair k (pair g' K))
is-pb-cone-A' is-pb-cone-B' =
is-pullback-is-fiberwise-equiv-fib-square
( ind-coprod _ f g)
( i)
( cone-descent-coprod f g i (pair h (pair f' H)) (pair k (pair g' K)))
( ind-coprod _
( λ x → is-equiv-left-factor
( fib-square f i (pair h (pair f' H)) x)
( fib-square (ind-coprod _ f g) i
( pair (functor-coprod h k)
( pair (ind-coprod _ f' g') (ind-coprod _ H K)))
( inl x))
( fib-functor-coprod-inl-fib h k x)
( triangle-descent-square-fib-functor-coprod-inl-fib
h k i f g f' g' H K x)
( is-fiberwise-equiv-fib-square-is-pullback f i
( pair h (pair f' H)) is-pb-cone-A' x)
( is-equiv-fib-functor-coprod-inl-fib h k x))
( λ y → is-equiv-left-factor
( fib-square g i (pair k (pair g' K)) y)
( fib-square
( ind-coprod _ f g) i
( pair
( functor-coprod h k)
( pair (ind-coprod _ f' g') (ind-coprod _ H K))) (inr y))
( fib-functor-coprod-inr-fib h k y)
( triangle-descent-square-fib-functor-coprod-inr-fib
h k i f g f' g' H K y)
( is-fiberwise-equiv-fib-square-is-pullback g i
( pair k (pair g' K)) is-pb-cone-B' y)
( is-equiv-fib-functor-coprod-inr-fib h k y)))
abstract
descent-coprod-inl : {l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (i : X' → X)
(cone-A' : cone f i A') (cone-B' : cone g i B') →
is-pullback
( ind-coprod _ f g)
( i)
( cone-descent-coprod f g i cone-A' cone-B') →
is-pullback f i cone-A'
descent-coprod-inl f g i (pair h (pair f' H)) (pair k (pair g' K))
is-pb-dsq =
is-pullback-is-fiberwise-equiv-fib-square f i (pair h (pair f' H))
( λ a → is-equiv-comp
( fib-square f i (pair h (pair f' H)) a)
( fib-square (ind-coprod _ f g) i
( cone-descent-coprod f g i
( pair h (pair f' H)) (pair k (pair g' K))) (inl a))
( fib-functor-coprod-inl-fib h k a)
( triangle-descent-square-fib-functor-coprod-inl-fib
h k i f g f' g' H K a)
( is-equiv-fib-functor-coprod-inl-fib h k a)
( is-fiberwise-equiv-fib-square-is-pullback (ind-coprod _ f g) i
( cone-descent-coprod f g i
( pair h (pair f' H)) (pair k (pair g' K))) is-pb-dsq (inl a)))
abstract
descent-coprod-inr : {l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (i : X' → X)
(cone-A' : cone f i A') (cone-B' : cone g i B') →
is-pullback
( ind-coprod _ f g)
( i)
( cone-descent-coprod f g i cone-A' cone-B') →
is-pullback g i cone-B'
descent-coprod-inr f g i (pair h (pair f' H)) (pair k (pair g' K))
is-pb-dsq =
is-pullback-is-fiberwise-equiv-fib-square g i (pair k (pair g' K))
( λ b → is-equiv-comp
( fib-square g i (pair k (pair g' K)) b)
( fib-square (ind-coprod _ f g) i
( cone-descent-coprod f g i
( pair h (pair f' H)) (pair k (pair g' K))) (inr b))
( fib-functor-coprod-inr-fib h k b)
( triangle-descent-square-fib-functor-coprod-inr-fib
h k i f g f' g' H K b)
( is-equiv-fib-functor-coprod-inr-fib h k b)
( is-fiberwise-equiv-fib-square-is-pullback (ind-coprod _ f g) i
( cone-descent-coprod f g i
( pair h (pair f' H)) (pair k (pair g' K))) is-pb-dsq (inr b)))
-- Descent for Σ-types
cone-descent-Σ : {l1 l2 l3 l4 l5 : Level}
{I : UU l1} {A : I → UU l2} {A' : I → UU l3} {X : UU l4} {X' : UU l5}
(f : (i : I) → A i → X) (h : X' → X)
(c : (i : I) → cone (f i) h (A' i)) →
cone (ind-Σ f) h (Σ I A')
cone-descent-Σ f h c =
pair
( tot (λ i → (pr1 (c i))))
( pair
( ind-Σ (λ i → (pr1 (pr2 (c i)))))
( ind-Σ (λ i → (pr2 (pr2 (c i))))))
triangle-descent-Σ : {l1 l2 l3 l4 l5 : Level}
{I : UU l1} {A : I → UU l2} {A' : I → UU l3} {X : UU l4} {X' : UU l5}
(f : (i : I) → A i → X) (h : X' → X)
(c : (i : I) → cone (f i) h (A' i)) →
(i : I) (a : A i) →
( fib-square (f i) h (c i) a) ~
((fib-square (ind-Σ f) h (cone-descent-Σ f h c) (pair i a)) ∘ (fib-tot-fib-ftr (λ i → (pr1 (c i))) (pair i a)))
triangle-descent-Σ f h c i .(pr1 (c i) a') (pair a' refl) = refl
abstract
descent-Σ : {l1 l2 l3 l4 l5 : Level}
{I : UU l1} {A : I → UU l2} {A' : I → UU l3} {X : UU l4} {X' : UU l5}
(f : (i : I) → A i → X) (h : X' → X)
(c : (i : I) → cone (f i) h (A' i)) →
((i : I) → is-pullback (f i) h (c i)) →
is-pullback (ind-Σ f) h (cone-descent-Σ f h c)
descent-Σ f h c is-pb-c =
is-pullback-is-fiberwise-equiv-fib-square
( ind-Σ f)
( h)
( cone-descent-Σ f h c)
( ind-Σ
( λ i a → is-equiv-left-factor
( fib-square (f i) h (c i) a)
( fib-square (ind-Σ f) h (cone-descent-Σ f h c) (pair i a))
( fib-tot-fib-ftr (λ i → pr1 (c i)) (pair i a))
( triangle-descent-Σ f h c i a)
( is-fiberwise-equiv-fib-square-is-pullback
(f i) h (c i) (is-pb-c i) a)
( is-equiv-fib-tot-fib-ftr (λ i → pr1 (c i)) (pair i a))))
abstract
descent-Σ' : {l1 l2 l3 l4 l5 : Level}
{I : UU l1} {A : I → UU l2} {A' : I → UU l3} {X : UU l4} {X' : UU l5}
(f : (i : I) → A i → X) (h : X' → X)
(c : (i : I) → cone (f i) h (A' i)) →
is-pullback (ind-Σ f) h (cone-descent-Σ f h c) →
((i : I) → is-pullback (f i) h (c i))
descent-Σ' f h c is-pb-dsq i =
is-pullback-is-fiberwise-equiv-fib-square (f i) h (c i)
( λ a → is-equiv-comp
( fib-square (f i) h (c i) a)
( fib-square (ind-Σ f) h (cone-descent-Σ f h c) (pair i a))
( fib-tot-fib-ftr (λ i → pr1 (c i)) (pair i a))
( triangle-descent-Σ f h c i a)
( is-equiv-fib-tot-fib-ftr (λ i → pr1 (c i)) (pair i a))
( is-fiberwise-equiv-fib-square-is-pullback (ind-Σ f) h
( cone-descent-Σ f h c) is-pb-dsq (pair i a)))
-- Extra material
-- Homotopical squares
{- We consider the situation where we have two 'parallel squares', i.e. a
diagram of the form
--------->
C ---------> B
| | | |
| | | |
V V V V
A ---------> X.
--------->
Suppose that between each parallel pair of maps there is a homotopy, and
that there is a homotopy between the homotopies that fill the two squares,
as expessed by the type coherence-htpy-square below. Our goal is to show
that if one of the squares is a pullback square, then so is the other.
We do so without using function extensionality. -}
coherence-htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) (c' : cone f' g' C)
(Hp : pr1 c ~ pr1 c') (Hq : pr1 (pr2 c) ~ pr1 (pr2 c')) → UU _
coherence-htpy-square {f = f} {f'} Hf {g} {g'} Hg c c' Hp Hq =
let p = pr1 c
q = pr1 (pr2 c)
H = pr2 (pr2 c)
p' = pr1 c'
q' = pr1 (pr2 c')
H' = pr2 (pr2 c')
in
( H ∙h ((g ·l Hq) ∙h (Hg ·r q'))) ~ (((f ·l Hp) ∙h (Hf ·r p')) ∙h H')
fam-htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) → (c' : cone f' g' C) →
(pr1 c ~ pr1 c') → UU _
fam-htpy-square {f = f} {f'} Hf {g} {g'} Hg c c' Hp =
Σ ((pr1 (pr2 c)) ~ (pr1 (pr2 c'))) (coherence-htpy-square Hf Hg c c' Hp)
htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
cone f g C → cone f' g' C → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
htpy-square
{f = f} {f'} Hf {g} {g'} Hg c c' =
Σ ((pr1 c) ~ (pr1 c')) (fam-htpy-square Hf Hg c c')
map-is-pullback-htpy :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
{f : A → X} {f' : A → X} (Hf : f ~ f')
{g : B → X} {g' : B → X} (Hg : g ~ g') →
canonical-pullback f' g' → canonical-pullback f g
map-is-pullback-htpy {f = f} {f'} Hf {g} {g'} Hg =
tot (λ a → tot (λ b →
( concat' (f a) (inv (Hg b))) ∘ (concat (Hf a) (g' b))))
abstract
is-equiv-map-is-pullback-htpy :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
{f : A → X} {f' : A → X} (Hf : f ~ f')
{g : B → X} {g' : B → X} (Hg : g ~ g') →
is-equiv (map-is-pullback-htpy Hf Hg)
is-equiv-map-is-pullback-htpy {f = f} {f'} Hf {g} {g'} Hg =
is-equiv-tot-is-fiberwise-equiv (λ a →
is-equiv-tot-is-fiberwise-equiv (λ b →
is-equiv-comp
( (concat' (f a) (inv (Hg b))) ∘ (concat (Hf a) (g' b)))
( concat' (f a) (inv (Hg b)))
( concat (Hf a) (g' b))
( htpy-refl)
( is-equiv-concat (Hf a) (g' b))
( is-equiv-concat' (f a) (inv (Hg b)))))
tot-pullback-rel : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) (x : A) → UU _
tot-pullback-rel {B = B} f g x = Σ B (λ y → Id (f x) (g y))
triangle-is-pullback-htpy :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f : A → X} {f' : A → X} (Hf : f ~ f')
{g : B → X} {g' : B → X} (Hg : g ~ g')
{c : cone f g C} {c' : cone f' g' C} (Hc : htpy-square Hf Hg c c') →
(gap f g c) ~ ((map-is-pullback-htpy Hf Hg) ∘ (gap f' g' c'))
triangle-is-pullback-htpy {A = A} {B} {X} {C} {f = f} {f'} Hf {g} {g'} Hg
{pair p (pair q H)} {pair p' (pair q' H')} (pair Hp (pair Hq HH)) z =
eq-Eq-canonical-pullback f g
( Hp z)
( Hq z)
( ( inv
( assoc (ap f (Hp z)) ((Hf (p' z)) ∙ (H' z)) (inv (Hg (q' z))))) ∙
( inv
( con-inv
( (H z) ∙ (ap g (Hq z)))
( Hg (q' z))
( ( ap f (Hp z)) ∙ ((Hf (p' z)) ∙ (H' z)))
( ( assoc (H z) (ap g (Hq z)) (Hg (q' z))) ∙
( ( HH z) ∙
( assoc (ap f (Hp z)) (Hf (p' z)) (H' z)))))))
abstract
is-pullback-htpy :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f : A → X} (f' : A → X) (Hf : f ~ f')
{g : B → X} (g' : B → X) (Hg : g ~ g')
{c : cone f g C} (c' : cone f' g' C) (Hc : htpy-square Hf Hg c c') →
is-pullback f' g' c' → is-pullback f g c
is-pullback-htpy
{f = f} f' Hf {g} g' Hg
{c = pair p (pair q H)} (pair p' (pair q' H'))
(pair Hp (pair Hq HH)) is-pb-c' =
is-equiv-comp
( gap f g (pair p (pair q H)))
( map-is-pullback-htpy Hf Hg)
( gap f' g' (pair p' (pair q' H')))
( triangle-is-pullback-htpy Hf Hg
{pair p (pair q H)} {pair p' (pair q' H')} (pair Hp (pair Hq HH)))
( is-pb-c')
( is-equiv-map-is-pullback-htpy Hf Hg)
abstract
is-pullback-htpy' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) {f' : A → X} (Hf : f ~ f')
(g : B → X) {g' : B → X} (Hg : g ~ g') →
(c : cone f g C) {c' : cone f' g' C} (Hc : htpy-square Hf Hg c c') →
is-pullback f g c → is-pullback f' g' c'
is-pullback-htpy'
f {f'} Hf g {g'} Hg
(pair p (pair q H)) {pair p' (pair q' H')}
(pair Hp (pair Hq HH)) is-pb-c =
is-equiv-right-factor
( gap f g (pair p (pair q H)))
( map-is-pullback-htpy Hf Hg)
( gap f' g' (pair p' (pair q' H')))
( triangle-is-pullback-htpy Hf Hg
{pair p (pair q H)} {pair p' (pair q' H')} (pair Hp (pair Hq HH)))
( is-equiv-map-is-pullback-htpy Hf Hg)
( is-pb-c)
{- In the following part we will relate the type htpy-square to the Identity
type of cones. Here we will rely on function extensionality. -}
reflexive-htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
htpy-square (htpy-refl {f = f}) (htpy-refl {f = g}) c c
reflexive-htpy-square f g c =
pair htpy-refl (pair htpy-refl htpy-right-unit)
htpy-square-eq-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c c' : cone f g C) →
Id c c' → htpy-square (htpy-refl {f = f}) (htpy-refl {f = g}) c c'
htpy-square-eq-htpy-refl f g c .c refl =
pair htpy-refl (pair htpy-refl htpy-right-unit)
htpy-square-htpy-refl-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) →
(c c' : cone f g C) →
htpy-cone f g c c' → htpy-square (htpy-refl {f = f}) (htpy-refl {f = g}) c c'
htpy-square-htpy-refl-htpy-cone f g
(pair p (pair q H)) (pair p' (pair q' H')) =
tot
( λ K → tot
( λ L M → ( htpy-ap-concat H _ _ htpy-right-unit) ∙h
( M ∙h htpy-ap-concat' _ _ H' (htpy-inv htpy-right-unit))))
abstract
is-equiv-htpy-square-htpy-refl-htpy-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) →
(c c' : cone f g C) →
is-equiv (htpy-square-htpy-refl-htpy-cone f g c c')
is-equiv-htpy-square-htpy-refl-htpy-cone f g
(pair p (pair q H)) (pair p' (pair q' H')) =
is-equiv-tot-is-fiberwise-equiv
( λ K → is-equiv-tot-is-fiberwise-equiv
( λ L → is-equiv-comp
( λ M → ( htpy-ap-concat H _ _ htpy-right-unit) ∙h
( M ∙h
( htpy-ap-concat' _ _ H' (htpy-inv htpy-right-unit))))
( htpy-concat
( htpy-ap-concat H _ _ htpy-right-unit)
( ((f ·l K) ∙h htpy-refl) ∙h H'))
( htpy-concat'
( H ∙h (g ·l L))
( htpy-ap-concat' _ _ H' (htpy-inv htpy-right-unit)))
( htpy-refl)
( is-equiv-htpy-concat'
( H ∙h (g ·l L))
( λ x → ap (λ z → z ∙ H' x) (inv right-unit)))
( is-equiv-htpy-concat
( λ x → ap (_∙_ (H x)) right-unit)
( ((f ·l K) ∙h htpy-refl) ∙h H'))))
abstract
is-contr-total-htpy-square-htpy-refl-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) →
(c : cone f g C) →
is-contr (Σ (cone f g C) (htpy-square (htpy-refl' f) (htpy-refl' g) c))
is-contr-total-htpy-square-htpy-refl-htpy-refl {A = A} {B} {X} {C}
f g (pair p (pair q H)) =
let c = pair p (pair q H) in
is-contr-is-equiv'
( Σ (cone f g C) (htpy-cone f g c))
( tot (htpy-square-htpy-refl-htpy-cone f g c))
( is-equiv-tot-is-fiberwise-equiv
( is-equiv-htpy-square-htpy-refl-htpy-cone f g c))
( is-contr-total-htpy-cone f g c)
abstract
is-contr-total-htpy-square-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) →
is-contr (Σ (cone f g' C) (htpy-square (htpy-refl' f) Hg c))
is-contr-total-htpy-square-htpy-refl {C = C} f {g} =
ind-htpy g
( λ g'' Hg' → ( c : cone f g C) →
is-contr (Σ (cone f g'' C) (htpy-square (htpy-refl' f) Hg' c)))
( is-contr-total-htpy-square-htpy-refl-htpy-refl f g)
abstract
is-contr-total-htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) →
is-contr (Σ (cone f' g' C) (htpy-square Hf Hg c))
is-contr-total-htpy-square {A = A} {B} {X} {C} {f} {f'} Hf {g} {g'} Hg =
ind-htpy
{ A = A}
{ B = λ t → X}
( f)
( λ f'' Hf' → (g g' : B → X) (Hg : g ~ g') (c : cone f g C) →
is-contr (Σ (cone f'' g' C) (htpy-square Hf' Hg c)))
( λ g g' Hg → is-contr-total-htpy-square-htpy-refl f Hg)
Hf g g' Hg
tr-tr-htpy-refl-cone :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
let tr-c = tr (λ x → cone x g C) (eq-htpy (htpy-refl {f = f})) c
tr-tr-c = tr (λ y → cone f y C) (eq-htpy (htpy-refl {f = g})) tr-c
in
Id tr-tr-c c
tr-tr-htpy-refl-cone {C = C} f g c =
let tr-c = tr (λ f''' → cone f''' g C) (eq-htpy htpy-refl) c
tr-tr-c = tr (λ g'' → cone f g'' C) (eq-htpy htpy-refl) tr-c
α : Id tr-tr-c tr-c
α = ap (λ t → tr (λ g'' → cone f g'' C) t tr-c) (eq-htpy-htpy-refl g)
β : Id tr-c c
β = ap (λ t → tr (λ f''' → cone f''' g C) t c) (eq-htpy-htpy-refl f)
in
α ∙ β
htpy-square-eq-htpy-refl-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c c' : cone f g C) →
let tr-c = tr (λ x → cone x g C) (eq-htpy (htpy-refl {f = f})) c
tr-tr-c = tr (λ y → cone f y C) (eq-htpy (htpy-refl {f = g})) tr-c
in
Id tr-tr-c c' → htpy-square (htpy-refl' f) (htpy-refl' g) c c'
htpy-square-eq-htpy-refl-htpy-refl f g c c' =
ind-is-equiv
( λ p → htpy-square (htpy-refl' f) (htpy-refl' g) c c')
( λ (p : Id c c') → (tr-tr-htpy-refl-cone f g c) ∙ p)
( is-equiv-concat (tr-tr-htpy-refl-cone f g c) c')
( htpy-square-eq-htpy-refl f g c c')
comp-htpy-square-eq-htpy-refl-htpy-refl :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c c' : cone f g C) →
( (htpy-square-eq-htpy-refl-htpy-refl f g c c') ∘
(concat (tr-tr-htpy-refl-cone f g c) c')) ~
( htpy-square-eq-htpy-refl f g c c')
comp-htpy-square-eq-htpy-refl-htpy-refl f g c c' =
htpy-comp-is-equiv
( λ p → htpy-square (htpy-refl' f) (htpy-refl' g) c c')
( λ (p : Id c c') → (tr-tr-htpy-refl-cone f g c) ∙ p)
( is-equiv-concat (tr-tr-htpy-refl-cone f g c) c')
( htpy-square-eq-htpy-refl f g c c')
abstract
htpy-square-eq' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) (c' : cone f g' C) →
let tr-c = tr (λ x → cone x g C) (eq-htpy (htpy-refl {f = f})) c
tr-tr-c = tr (λ y → cone f y C) (eq-htpy Hg) tr-c
in
Id tr-tr-c c' → htpy-square (htpy-refl' f) Hg c c'
htpy-square-eq' {C = C} f {g} =
ind-htpy g
( λ g'' Hg' →
( c : cone f g C) (c' : cone f g'' C) →
Id (tr (λ g'' → cone f g'' C) (eq-htpy Hg')
( tr (λ f''' → cone f''' g C) (eq-htpy (htpy-refl' f)) c)) c' →
htpy-square htpy-refl Hg' c c')
( htpy-square-eq-htpy-refl-htpy-refl f g)
comp-htpy-square-eq' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c c' : cone f g C) →
( ( htpy-square-eq' f htpy-refl c c') ∘
( concat (tr-tr-htpy-refl-cone f g c) c')) ~
( htpy-square-eq-htpy-refl f g c c')
comp-htpy-square-eq' {A = A} {B} {X} {C} f g c c' =
htpy-right-whisk
( htpy-eq (htpy-eq (htpy-eq (comp-htpy g
( λ g'' Hg' →
( c : cone f g C) (c' : cone f g'' C) →
Id (tr (λ g'' → cone f g'' C) (eq-htpy Hg')
( tr (λ f''' → cone f''' g C) (eq-htpy (htpy-refl' f)) c)) c' →
htpy-square htpy-refl Hg' c c')
( htpy-square-eq-htpy-refl-htpy-refl f g)) c) c'))
( concat (tr-tr-htpy-refl-cone f g c) c') ∙h
( comp-htpy-square-eq-htpy-refl-htpy-refl f g c c')
abstract
htpy-square-eq :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) (c' : cone f' g' C) →
let tr-c = tr (λ x → cone x g C) (eq-htpy Hf) c
tr-tr-c = tr (λ y → cone f' y C) (eq-htpy Hg) tr-c
in
Id tr-tr-c c' → htpy-square Hf Hg c c'
htpy-square-eq {A = A} {B} {X} {C} {f} {f'} Hf {g} {g'} Hg c c' p =
ind-htpy f
( λ f'' Hf' →
( g g' : B → X) (Hg : g ~ g') (c : cone f g C) (c' : cone f'' g' C) →
( Id (tr (λ g'' → cone f'' g'' C) (eq-htpy Hg)
( tr (λ f''' → cone f''' g C) (eq-htpy Hf') c)) c') →
htpy-square Hf' Hg c c')
( λ g g' → htpy-square-eq' f {g = g} {g' = g'})
Hf g g' Hg c c' p
comp-htpy-square-eq :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c c' : cone f g C) →
( ( htpy-square-eq htpy-refl htpy-refl c c') ∘
( concat (tr-tr-htpy-refl-cone f g c) c')) ~
( htpy-square-eq-htpy-refl f g c c')
comp-htpy-square-eq {A = A} {B} {X} {C} f g c c' =
htpy-right-whisk
( htpy-eq (htpy-eq (htpy-eq (htpy-eq (htpy-eq (htpy-eq (comp-htpy f
( λ f'' Hf' →
( g g' : B → X) (Hg : g ~ g') (c : cone f g C) (c' : cone f'' g' C) →
( Id ( tr (λ g'' → cone f'' g'' C) (eq-htpy Hg)
( tr (λ f''' → cone f''' g C) (eq-htpy Hf') c)) c') →
htpy-square Hf' Hg c c')
( λ g g' → htpy-square-eq' f {g = g} {g' = g'})) g) g)
htpy-refl) c) c'))
( concat (tr-tr-htpy-refl-cone f g c) c') ∙h
( comp-htpy-square-eq' f g c c')
abstract
is-fiberwise-equiv-htpy-square-eq :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) (c' : cone f' g' C) →
is-equiv (htpy-square-eq Hf Hg c c')
is-fiberwise-equiv-htpy-square-eq
{A = A} {B} {X} {C} {f} {f'} Hf {g} {g'} Hg c c' =
ind-htpy f
( λ f' Hf →
( g g' : B → X) (Hg : g ~ g') (c : cone f g C) (c' : cone f' g' C) →
is-equiv (htpy-square-eq Hf Hg c c'))
( λ g g' Hg c c' →
ind-htpy g
( λ g' Hg →
( c : cone f g C) (c' : cone f g' C) →
is-equiv (htpy-square-eq htpy-refl Hg c c'))
( λ c c' →
is-equiv-left-factor
( htpy-square-eq-htpy-refl f g c c')
( htpy-square-eq htpy-refl htpy-refl c c')
( concat (tr-tr-htpy-refl-cone f g c) c')
( htpy-inv (comp-htpy-square-eq f g c c'))
( fundamental-theorem-id c
( reflexive-htpy-square f g c)
( is-contr-total-htpy-square (htpy-refl' f) (htpy-refl' g) c)
( htpy-square-eq-htpy-refl f g c) c')
( is-equiv-concat (tr-tr-htpy-refl-cone f g c) c'))
Hg c c')
Hf g g' Hg c c'
eq-htpy-square :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{f f' : A → X} (Hf : f ~ f') {g g' : B → X} (Hg : g ~ g') →
(c : cone f g C) (c' : cone f' g' C) →
let tr-c = tr (λ x → cone x g C) (eq-htpy Hf) c
tr-tr-c = tr (λ y → cone f' y C) (eq-htpy Hg) tr-c
in
htpy-square Hf Hg c c' → Id tr-tr-c c'
eq-htpy-square Hf Hg c c' =
inv-is-equiv
{ f = htpy-square-eq Hf Hg c c'}
( is-fiberwise-equiv-htpy-square-eq Hf Hg c c')
-- Exercises
-- Exercise 10.1
cone-Id :
{l : Level} {A : UU l} (x y : A) →
cone (const unit A x) (const unit A y) (Id x y)
cone-Id x y =
pair
( const (Id x y) unit star)
( pair
( const (Id x y) unit star)
( id))
inv-gap-cone-Id :
{l : Level} {A : UU l} (x y : A) →
canonical-pullback (const unit A x) (const unit A y) → Id x y
inv-gap-cone-Id x y (pair star (pair star p)) = p
issec-inv-gap-cone-Id :
{l : Level} {A : UU l} (x y : A) →
( ( gap (const unit A x) (const unit A y) (cone-Id x y)) ∘
( inv-gap-cone-Id x y)) ~ id
issec-inv-gap-cone-Id x y (pair star (pair star p)) = refl
isretr-inv-gap-cone-Id :
{l : Level} {A : UU l} (x y : A) →
( ( inv-gap-cone-Id x y) ∘
( gap (const unit A x) (const unit A y) (cone-Id x y))) ~ id
isretr-inv-gap-cone-Id x y p = refl
abstract
is-pullback-cone-Id :
{l : Level} {A : UU l} (x y : A) →
is-pullback (const unit A x) (const unit A y) (cone-Id x y)
is-pullback-cone-Id x y =
is-equiv-has-inverse
( inv-gap-cone-Id x y)
( issec-inv-gap-cone-Id x y)
( isretr-inv-gap-cone-Id x y)
{- One way to solve this exercise is to show that Id (pr1 t) (pr2 t) is a
pullback for every t : A × A. This allows one to use path induction to
show that the inverse of the gap map is a section.
-}
cone-Id' :
{l : Level} {A : UU l} (t : A × A) →
cone (const unit (A × A) t) (diagonal A) (Id (pr1 t) (pr2 t))
cone-Id' {A = A} (pair x y) =
pair
( const (Id x y) unit star)
( pair
( const (Id x y) A x)
( λ p → eq-pair refl (inv p)))
inv-gap-cone-Id' :
{l : Level} {A : UU l} (t : A × A) →
canonical-pullback (const unit (A × A) t) (diagonal A) → Id (pr1 t) (pr2 t)
inv-gap-cone-Id' t (pair star (pair z p)) =
(ap pr1 p) ∙ (inv (ap pr2 p))
issec-inv-gap-cone-Id' :
{l : Level} {A : UU l} (t : A × A) →
( ( gap (const unit (A × A) t) (diagonal A) (cone-Id' t)) ∘
( inv-gap-cone-Id' t)) ~ id
issec-inv-gap-cone-Id' .(pair z z) (pair star (pair z refl)) = refl
isretr-inv-gap-cone-Id' :
{l : Level} {A : UU l} (t : A × A) →
( ( inv-gap-cone-Id' t) ∘
( gap (const unit (A × A) t) (diagonal A) (cone-Id' t))) ~ id
isretr-inv-gap-cone-Id' (pair x .x) refl = refl
abstract
is-pullback-cone-Id' :
{l : Level} {A : UU l} (t : A × A) →
is-pullback (const unit (A × A) t) (diagonal A) (cone-Id' t)
is-pullback-cone-Id' t =
is-equiv-has-inverse
( inv-gap-cone-Id' t)
( issec-inv-gap-cone-Id' t)
( isretr-inv-gap-cone-Id' t)
-- Exercise 10.2
diagonal-map :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
A → canonical-pullback f f
diagonal-map f x = pair x (pair x refl)
fib-ap-fib-diagonal-map :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B)
(t : canonical-pullback f f) →
(fib (diagonal-map f) t) → (fib (ap f) (pr2 (pr2 t)))
fib-ap-fib-diagonal-map f .(pair z (pair z refl)) (pair z refl) =
pair refl refl
fib-diagonal-map-fib-ap :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B)
(t : canonical-pullback f f) →
(fib (ap f) (pr2 (pr2 t))) → (fib (diagonal-map f) t)
fib-diagonal-map-fib-ap f (pair x (pair .x .refl)) (pair refl refl) =
pair x refl
issec-fib-diagonal-map-fib-ap :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B)
(t : canonical-pullback f f) →
((fib-ap-fib-diagonal-map f t) ∘ (fib-diagonal-map-fib-ap f t)) ~ id
issec-fib-diagonal-map-fib-ap f (pair x (pair .x .refl)) (pair refl refl) =
refl
isretr-fib-diagonal-map-fib-ap :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B)
(t : canonical-pullback f f) →
((fib-diagonal-map-fib-ap f t) ∘ (fib-ap-fib-diagonal-map f t)) ~ id
isretr-fib-diagonal-map-fib-ap f .(pair x (pair x refl)) (pair x refl) =
refl
abstract
is-equiv-fib-ap-fib-diagonal-map :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B)
(t : canonical-pullback f f) →
is-equiv (fib-ap-fib-diagonal-map f t)
is-equiv-fib-ap-fib-diagonal-map f t =
is-equiv-has-inverse
( fib-diagonal-map-fib-ap f t)
( issec-fib-diagonal-map-fib-ap f t)
( isretr-fib-diagonal-map-fib-ap f t)
abstract
is-trunc-diagonal-map-is-trunc-map :
{l1 l2 : Level} (k : 𝕋) {A : UU l1} {B : UU l2} (f : A → B) →
is-trunc-map (succ-𝕋 k) f → is-trunc-map k (diagonal-map f)
is-trunc-diagonal-map-is-trunc-map k f is-trunc-f (pair x (pair y p)) =
is-trunc-is-equiv k (fib (ap f) p)
( fib-ap-fib-diagonal-map f (pair x (pair y p)))
( is-equiv-fib-ap-fib-diagonal-map f (pair x (pair y p)))
( is-trunc-ap-is-trunc-map k f is-trunc-f x y p)
abstract
is-trunc-map-is-trunc-diagonal-map :
{l1 l2 : Level} (k : 𝕋) {A : UU l1} {B : UU l2} (f : A → B) →
is-trunc-map k (diagonal-map f) → is-trunc-map (succ-𝕋 k) f
is-trunc-map-is-trunc-diagonal-map
k f is-trunc-δ b (pair x p) (pair x' p') =
is-trunc-is-equiv k
( fib (ap f) (p ∙ (inv p')))
( fib-ap-eq-fib f (pair x p) (pair x' p'))
( is-equiv-fib-ap-eq-fib f (pair x p) (pair x' p'))
( is-trunc-is-equiv' k
( fib (diagonal-map f) (pair x (pair x' (p ∙ (inv p')))))
( fib-ap-fib-diagonal-map f (pair x (pair x' (p ∙ (inv p')))))
( is-equiv-fib-ap-fib-diagonal-map f (pair x (pair x' (p ∙ (inv p')))))
( is-trunc-δ (pair x (pair x' (p ∙ (inv p'))))))
abstract
is-equiv-diagonal-map-is-emb :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
is-emb f → is-equiv (diagonal-map f)
is-equiv-diagonal-map-is-emb f is-emb-f =
is-equiv-is-contr-map
( is-trunc-diagonal-map-is-trunc-map neg-two-𝕋 f
( is-prop-map-is-emb f is-emb-f))
abstract
is-emb-is-equiv-diagonal-map :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
is-equiv (diagonal-map f) → is-emb f
is-emb-is-equiv-diagonal-map f is-equiv-δ =
is-emb-is-prop-map f
( is-trunc-map-is-trunc-diagonal-map neg-two-𝕋 f
( is-contr-map-is-equiv is-equiv-δ))
-- Exercise 10.3
cone-swap :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) → cone f g C → cone g f C
cone-swap f g (pair p (pair q H)) = pair q (pair p (htpy-inv H))
map-canonical-pullback-swap :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → canonical-pullback f g → canonical-pullback g f
map-canonical-pullback-swap f g (pair a (pair b p)) =
pair b (pair a (inv p))
inv-inv-map-canonical-pullback-swap :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) →
(map-canonical-pullback-swap f g ∘ map-canonical-pullback-swap g f) ~ id
inv-inv-map-canonical-pullback-swap f g (pair b (pair a q)) =
eq-pair refl (eq-pair refl (inv-inv q))
abstract
is-equiv-map-canonical-pullback-swap :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → is-equiv (map-canonical-pullback-swap f g)
is-equiv-map-canonical-pullback-swap f g =
is-equiv-has-inverse
( map-canonical-pullback-swap g f)
( inv-inv-map-canonical-pullback-swap f g)
( inv-inv-map-canonical-pullback-swap g f)
triangle-map-canonical-pullback-swap :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
( gap g f (cone-swap f g c)) ~
( ( map-canonical-pullback-swap f g) ∘ ( gap f g c))
triangle-map-canonical-pullback-swap f g (pair p (pair q H)) x = refl
abstract
is-pullback-cone-swap :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-pullback g f (cone-swap f g c)
is-pullback-cone-swap f g c is-pb-c =
is-equiv-comp
( gap g f (cone-swap f g c))
( map-canonical-pullback-swap f g)
( gap f g c)
( triangle-map-canonical-pullback-swap f g c)
( is-pb-c)
( is-equiv-map-canonical-pullback-swap f g)
abstract
is-pullback-cone-swap' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback g f (cone-swap f g c) → is-pullback f g c
is-pullback-cone-swap' f g c is-pb-c' =
is-equiv-right-factor
( gap g f (cone-swap f g c))
( map-canonical-pullback-swap f g)
( gap f g c)
( triangle-map-canonical-pullback-swap f g c)
( is-equiv-map-canonical-pullback-swap f g)
( is-pb-c')
{- We conclude the swapped versions of some properties derived above, for
future convenience -}
abstract
is-trunc-is-pullback' :
{l1 l2 l3 l4 : Level} (k : 𝕋)
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-trunc-map k f → is-trunc-map k (pr1 (pr2 c))
is-trunc-is-pullback' k f g (pair p (pair q H)) pb is-trunc-f =
is-trunc-is-pullback k g f
( cone-swap f g (pair p (pair q H)))
( is-pullback-cone-swap f g (pair p (pair q H)) pb)
is-trunc-f
abstract
is-emb-is-pullback' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c → is-emb f → is-emb (pr1 (pr2 c))
is-emb-is-pullback' f g c pb is-emb-f =
is-emb-is-prop-map
( pr1 (pr2 c))
( is-trunc-is-pullback' neg-one-𝕋 f g c pb
( is-prop-map-is-emb f is-emb-f))
abstract
is-equiv-is-pullback' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-equiv f → is-pullback f g c → is-equiv (pr1 (pr2 c))
is-equiv-is-pullback' f g c is-equiv-f pb =
is-equiv-is-contr-map
( is-trunc-is-pullback' neg-two-𝕋 f g c pb
( is-contr-map-is-equiv is-equiv-f))
abstract
is-pullback-is-equiv' :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-equiv f → is-equiv (pr1 (pr2 c)) → is-pullback f g c
is-pullback-is-equiv' f g (pair p (pair q H)) is-equiv-f is-equiv-q =
is-pullback-cone-swap' f g (pair p (pair q H))
( is-pullback-is-equiv g f
( cone-swap f g (pair p (pair q H)))
is-equiv-f
is-equiv-q)
-- Exercise 10.4
cone-empty :
{l1 l2 l3 : Level} {B : UU l1} {X : UU l2} {C : UU l3} →
(g : B → X) (p : C → empty) (q : C → B) →
cone (ind-empty {P = λ t → X}) g C
cone-empty g p q =
pair p
( pair q
( λ c → ind-empty {P = λ t → Id (ind-empty (p c)) (g (q c))} (p c)))
abstract
descent-empty :
{l1 l2 l3 : Level} {B : UU l1} {X : UU l2} {C : UU l3} →
let f = ind-empty {P = λ t → X} in
(g : B → X) (c : cone f g C) → is-pullback f g c
descent-empty g c =
is-pullback-is-fiberwise-equiv-fib-square _ g c ind-empty
abstract
descent-empty' :
{l1 l2 l3 : Level} {B : UU l1} {X : UU l2} {C : UU l3} →
(g : B → X) (p : C → empty) (q : C → B) →
is-pullback (ind-empty {P = λ t → X}) g (cone-empty g p q)
descent-empty' g p q = descent-empty g (cone-empty g p q)
-- Exercise 10.5
{- We show that a square is a pullback square if and only if every exponent of
it is a pullback square. -}
cone-exponent :
{l1 l2 l3 l4 l5 : Level}
{A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} (T : UU l5)
(f : A → X) (g : B → X) (c : cone f g C) →
cone (λ (h : T → A) → f ∘ h) (λ (h : T → B) → g ∘ h) (T → C)
cone-exponent T f g (pair p (pair q H)) =
pair
( λ h → p ∘ h)
( pair
( λ h → q ∘ h)
( λ h → eq-htpy (H ·r h)))
map-canonical-pullback-exponent :
{l1 l2 l3 l4 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
(T : UU l4) →
canonical-pullback (λ (h : T → A) → f ∘ h) (λ (h : T → B) → g ∘ h) →
cone f g T
map-canonical-pullback-exponent f g T =
tot (λ p → tot (λ q → htpy-eq))
abstract
is-equiv-map-canonical-pullback-exponent :
{l1 l2 l3 l4 : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
(T : UU l4) → is-equiv (map-canonical-pullback-exponent f g T)
is-equiv-map-canonical-pullback-exponent f g T =
is-equiv-tot-is-fiberwise-equiv
( λ p → is-equiv-tot-is-fiberwise-equiv
( λ q → funext (f ∘ p) (g ∘ q)))
triangle-map-canonical-pullback-exponent :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(T : UU l5) (f : A → X) (g : B → X) (c : cone f g C) →
( cone-map f g {C' = T} c) ~
( ( map-canonical-pullback-exponent f g T) ∘
( gap
( λ (h : T → A) → f ∘ h)
( λ (h : T → B) → g ∘ h)
( cone-exponent T f g c)))
triangle-map-canonical-pullback-exponent
{A = A} {B} T f g (pair p (pair q H)) h =
eq-pair refl (eq-pair refl (inv (issec-eq-htpy (H ·r h))))
abstract
is-pullback-exponent-is-pullback :
{l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) → is-pullback f g c →
(T : UU l5) →
is-pullback
( λ (h : T → A) → f ∘ h)
( λ (h : T → B) → g ∘ h)
( cone-exponent T f g c)
is-pullback-exponent-is-pullback f g c is-pb-c T =
is-equiv-right-factor
( cone-map f g c)
( map-canonical-pullback-exponent f g T)
( gap (_∘_ f) (_∘_ g) (cone-exponent T f g c))
( triangle-map-canonical-pullback-exponent T f g c)
( is-equiv-map-canonical-pullback-exponent f g T)
( up-pullback-is-pullback f g c is-pb-c T)
abstract
is-pullback-is-pullback-exponent :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
((l5 : Level) (T : UU l5) → is-pullback
( λ (h : T → A) → f ∘ h)
( λ (h : T → B) → g ∘ h)
( cone-exponent T f g c)) →
is-pullback f g c
is-pullback-is-pullback-exponent f g c is-pb-exp =
is-pullback-up-pullback f g c
( λ T → is-equiv-comp
( cone-map f g c)
( map-canonical-pullback-exponent f g T)
( gap (_∘_ f) (_∘_ g) (cone-exponent T f g c))
( triangle-map-canonical-pullback-exponent T f g c)
( is-pb-exp _ T)
( is-equiv-map-canonical-pullback-exponent f g T))
-- Exercise 10.6
{- We construct the functoriality of cartesian products. -}
functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) → (A × B) → (C × D)
functor-prod f g (pair a b) = pair (f a) (g b)
functor-prod-pr1 :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) → (pr1 ∘ (functor-prod f g)) ~ (f ∘ pr1)
functor-prod-pr1 f g (pair a b) = refl
functor-prod-pr2 :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) → (pr2 ∘ (functor-prod f g)) ~ (g ∘ pr2)
functor-prod-pr2 f g (pair a b) = refl
{- For our convenience we show that the functorial action of cartesian products
preserves identity maps, compositions, homotopies, and equivalences. -}
functor-prod-id :
{l1 l2 : Level} {A : UU l1} {B : UU l2} →
(functor-prod (id {A = A}) (id {A = B})) ~ id
functor-prod-id (pair a b) = refl
functor-prod-comp :
{l1 l2 l3 l4 l5 l6 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
{E : UU l5} {F : UU l6} (f : A → C) (g : B → D) (h : C → E) (k : D → F) →
functor-prod (h ∘ f) (k ∘ g) ~ ((functor-prod h k) ∘ (functor-prod f g))
functor-prod-comp f g h k (pair a b) = refl
functor-prod-htpy :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
{f f' : A → C} (H : f ~ f') {g g' : B → D} (K : g ~ g') →
functor-prod f g ~ functor-prod f' g'
functor-prod-htpy {f = f} {f'} H {g} {g'} K (pair a b) =
eq-pair-triv (pair (H a) (K b))
abstract
is-equiv-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) →
is-equiv f → is-equiv g → is-equiv (functor-prod f g)
is-equiv-functor-prod f g
( pair (pair sf issec-sf) (pair rf isretr-rf))
( pair (pair sg issec-sg) (pair rg isretr-rg)) =
pair
( pair
( functor-prod sf sg)
( ( htpy-inv (functor-prod-comp sf sg f g)) ∙h
( (functor-prod-htpy issec-sf issec-sg) ∙h functor-prod-id)))
( pair
( functor-prod rf rg)
( ( htpy-inv (functor-prod-comp f g rf rg)) ∙h
( (functor-prod-htpy isretr-rf isretr-rg) ∙h functor-prod-id)))
{- Now we return to the solution of the exercise.
Note: the solution below involves a substantial amount of path algebra. It
would be nice to find a simpler solution.
-}
cone-fold :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) →
cone f g C → cone (functor-prod f g) (diagonal X) C
cone-fold f g (pair p (pair q H)) =
pair
( λ z → pair (p z) (q z))
( pair
( g ∘ q)
( λ z → eq-pair-triv (pair (H z) refl)))
map-cone-fold :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) → (g : B → X) →
canonical-pullback f g → canonical-pullback (functor-prod f g) (diagonal X)
map-cone-fold f g (pair a (pair b p)) =
pair
( pair a b)
( pair
( g b)
( eq-pair-triv (pair p refl)))
inv-map-cone-fold :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) → (g : B → X) →
canonical-pullback (functor-prod f g) (diagonal X) → canonical-pullback f g
inv-map-cone-fold f g (pair (pair a b) (pair x α)) =
pair a (pair b ((ap pr1 α) ∙ (inv (ap pr2 α))))
ap-diagonal :
{l : Level} {A : UU l} {x y : A} (p : Id x y) →
Id (ap (diagonal A) p) (eq-pair-triv (pair p p))
ap-diagonal refl = refl
eq-pair-triv-concat :
{l1 l2 : Level} {A : UU l1} {B : UU l2} {x x' x'' : A} {y y' y'' : B}
(p : Id x x') (p' : Id x' x'') (q : Id y y') (q' : Id y' y'') →
Id ( eq-pair-triv {s = pair x y} {t = pair x'' y''} (pair (p ∙ p') (q ∙ q')))
( ( eq-pair-triv {s = pair x y} {t = pair x' y'} (pair p q)) ∙
( eq-pair-triv (pair p' q')))
eq-pair-triv-concat refl p' refl q' = refl
issec-inv-map-cone-fold :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) →
((map-cone-fold f g) ∘ (inv-map-cone-fold f g)) ~ id
issec-inv-map-cone-fold {A = A} {B} {X} f g (pair (pair a b) (pair x α)) =
eq-Eq-canonical-pullback
( functor-prod f g)
( diagonal X)
refl
( ap pr2 α)
( ( ( ( inv (issec-pair-eq-triv' (pair (f a) (g b)) (pair x x) α)) ∙
( ap
( λ t → (eq-pair-triv ( pair t (ap pr2 α))))
( ( ( inv right-unit) ∙
( inv (ap (concat (ap pr1 α) x) (left-inv (ap pr2 α))))) ∙
( inv (assoc (ap pr1 α) (inv (ap pr2 α)) (ap pr2 α)))))) ∙
( eq-pair-triv-concat
( (ap pr1 α) ∙ (inv (ap pr2 α)))
( ap pr2 α)
( refl)
( ap pr2 α))) ∙
( ap
( concat
( eq-pair-triv
( pair ((ap pr1 α) ∙ (inv (ap pr2 α))) refl))
( pair x x))
( inv (ap-diagonal (ap pr2 α)))))
ap-pr1-eq-pair-triv :
{l1 l2 : Level} {A : UU l1} {B : UU l2}
{x x' : A} (p : Id x x') {y y' : B} (q : Id y y') →
Id (ap pr1 (eq-pair-triv' (pair x y) (pair x' y') (pair p q))) p
ap-pr1-eq-pair-triv refl refl = refl
ap-pr2-eq-pair-triv :
{l1 l2 : Level} {A : UU l1} {B : UU l2}
{x x' : A} (p : Id x x') {y y' : B} (q : Id y y') →
Id (ap pr2 (eq-pair-triv' (pair x y) (pair x' y') (pair p q))) q
ap-pr2-eq-pair-triv refl refl = refl
isretr-inv-map-cone-fold :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) →
((inv-map-cone-fold f g) ∘ (map-cone-fold f g)) ~ id
isretr-inv-map-cone-fold { A = A} { B = B} { X = X} f g (pair a (pair b p)) =
eq-Eq-canonical-pullback {A = A} {B = B} {X = X} f g
refl
refl
( inv
( ( ap
( concat' (f a) refl)
( ( ( ap
( λ t → t ∙
( inv (ap pr2 (eq-pair-triv'
( pair (f a) (g b))
( pair (g b) (g b))
( pair p refl)))))
( ap-pr1-eq-pair-triv p refl)) ∙
( ap (λ t → p ∙ (inv t)) (ap-pr2-eq-pair-triv p refl))) ∙
( right-unit))) ∙
( right-unit)))
abstract
is-equiv-map-cone-fold :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {X : UU l3}
(f : A → X) (g : B → X) → is-equiv (map-cone-fold f g)
is-equiv-map-cone-fold f g =
is-equiv-has-inverse
( inv-map-cone-fold f g)
( issec-inv-map-cone-fold f g)
( isretr-inv-map-cone-fold f g)
triangle-map-cone-fold :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
( gap (functor-prod f g) (diagonal X) (cone-fold f g c)) ~
( (map-cone-fold f g) ∘ (gap f g c))
triangle-map-cone-fold f g (pair p (pair q H)) z = refl
abstract
is-pullback-cone-fold-is-pullback :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback f g c →
is-pullback (functor-prod f g) (diagonal X) (cone-fold f g c)
is-pullback-cone-fold-is-pullback f g c is-pb-c =
is-equiv-comp
( gap (functor-prod f g) (diagonal _) (cone-fold f g c))
( map-cone-fold f g)
( gap f g c)
( triangle-map-cone-fold f g c)
( is-pb-c)
( is-equiv-map-cone-fold f g)
abstract
is-pullback-is-pullback-cone-fold :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
(f : A → X) (g : B → X) (c : cone f g C) →
is-pullback (functor-prod f g) (diagonal X) (cone-fold f g c) →
is-pullback f g c
is-pullback-is-pullback-cone-fold f g c is-pb-fold =
is-equiv-right-factor
( gap (functor-prod f g) (diagonal _) (cone-fold f g c))
( map-cone-fold f g)
( gap f g c)
( triangle-map-cone-fold f g c)
( is-equiv-map-cone-fold f g)
( is-pb-fold)
-- Exercise 10.7
cone-pair :
{l1 l2 l3 l4 l1' l2' l3' l4' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} {C' : UU l4'}
(f : A → X) (g : B → X) (f' : A' → X') (g' : B' → X') →
cone f g C → cone f' g' C' →
cone (functor-prod f f') (functor-prod g g') (C × C')
cone-pair f g f' g' (pair p (pair q H)) (pair p' (pair q' H')) =
pair
( functor-prod p p')
( pair
( functor-prod q q')
( ( htpy-inv (functor-prod-comp p p' f f')) ∙h
( ( functor-prod-htpy H H') ∙h
( functor-prod-comp q q' g g'))))
map-cone-pair' :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (f' : A' → X') (g' : B' → X') →
(t : A × A') (s : B × B') →
(Id (f (pr1 t)) (g (pr1 s))) × (Id (f' (pr2 t)) (g' (pr2 s))) →
(Id (pr1 (functor-prod f f' t)) (pr1 (functor-prod g g' s))) ×
(Id (pr2 (functor-prod f f' t)) (pr2 (functor-prod g g' s)))
map-cone-pair' f g f' g' (pair a a') (pair b b') = id
abstract
is-equiv-map-cone-pair' :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (f' : A' → X') (g' : B' → X') →
(t : A × A') (s : B × B') →
is-equiv (map-cone-pair' f g f' g' t s)
is-equiv-map-cone-pair' f g f' g' (pair a a') (pair b b') =
is-equiv-id _
map-cone-pair :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (f' : A' → X') (g' : B' → X') →
(canonical-pullback f g) × (canonical-pullback f' g') →
canonical-pullback (functor-prod f f') (functor-prod g g')
map-cone-pair {A' = A'} {B'} f g f' g' =
( tot
( λ t →
( tot
( λ s →
( eq-pair-triv ∘ (map-cone-pair' f g f' g' t s)))) ∘
( swap-total-Eq-structure
( λ y → Id (f (pr1 t)) (g y))
( λ y → B')
( λ y p y' → Id (f' (pr2 t)) (g' y'))))) ∘
( swap-total-Eq-structure
( λ x → Σ _ (λ y → Id (f x) (g y)))
( λ x → A')
( λ x t x' → Σ _ (λ y' → Id (f' x') (g' y'))))
triangle-map-cone-pair :
{l1 l2 l3 l4 l1' l2' l3' l4' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} {C' : UU l4'}
(f : A → X) (g : B → X) (c : cone f g C)
(f' : A' → X') (g' : B' → X') (c' : cone f' g' C') →
(gap (functor-prod f f') (functor-prod g g') (cone-pair f g f' g' c c')) ~
((map-cone-pair f g f' g') ∘ (functor-prod (gap f g c) (gap f' g' c')))
triangle-map-cone-pair
f g (pair p (pair q H)) f' g' (pair p' (pair q' H')) (pair z z') =
eq-pair refl (eq-pair refl right-unit)
abstract
is-equiv-map-cone-pair :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'}
(f : A → X) (g : B → X) (f' : A' → X') (g' : B' → X') →
is-equiv (map-cone-pair f g f' g')
is-equiv-map-cone-pair f g f' g' =
is-equiv-comp
( map-cone-pair f g f' g')
( tot ( λ t →
( tot
( λ s →
( eq-pair-triv ∘ (map-cone-pair' f g f' g' t s)))) ∘
( swap-total-Eq-structure _ _ _)))
( swap-total-Eq-structure _ _ _)
( htpy-refl)
( is-equiv-swap-total-Eq-structure _ _ _)
( is-equiv-tot-is-fiberwise-equiv
( λ t → is-equiv-comp
( ( tot
( λ s →
( eq-pair-triv ∘ (map-cone-pair' f g f' g' t s)))) ∘
( swap-total-Eq-structure
( λ y → Id (f (pr1 t)) (g y))
( λ y → _)
( λ y p y' → Id (f' (pr2 t)) (g' y'))))
( tot
( λ s →
( eq-pair-triv ∘ (map-cone-pair' f g f' g' t s))))
( swap-total-Eq-structure
( λ y → Id (f (pr1 t)) (g y))
( λ y → _)
( λ y p y' → Id (f' (pr2 t)) (g' y')))
( htpy-refl)
( is-equiv-swap-total-Eq-structure _ _ _)
( is-equiv-tot-is-fiberwise-equiv
( λ s → is-equiv-comp
( eq-pair-triv ∘ (map-cone-pair' f g f' g' t s))
( eq-pair-triv)
( map-cone-pair' f g f' g' t s)
( htpy-refl)
( is-equiv-map-cone-pair' f g f' g' t s)
( is-equiv-eq-pair-triv'
( functor-prod f f' t)
( functor-prod g g' s))))))
abstract
is-pullback-prod-is-pullback-pair :
{l1 l2 l3 l4 l1' l2' l3' l4' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} {C' : UU l4'}
(f : A → X) (g : B → X) (c : cone f g C)
(f' : A' → X') (g' : B' → X') (c' : cone f' g' C') →
is-pullback f g c → is-pullback f' g' c' →
is-pullback
( functor-prod f f') (functor-prod g g') (cone-pair f g f' g' c c')
is-pullback-prod-is-pullback-pair f g c f' g' c' is-pb-c is-pb-c' =
is-equiv-comp
( gap (functor-prod f f') (functor-prod g g') (cone-pair f g f' g' c c'))
( map-cone-pair f g f' g')
( functor-prod (gap f g c) (gap f' g' c'))
( triangle-map-cone-pair f g c f' g' c')
( is-equiv-functor-prod _ _ is-pb-c is-pb-c')
( is-equiv-map-cone-pair f g f' g')
map-fib-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (t : C × D) →
fib (functor-prod f g) t → (fib f (pr1 t)) × (fib g (pr2 t))
map-fib-functor-prod f g .(functor-prod f g (pair a b))
(pair (pair a b) refl) = pair (pair a refl) (pair b refl)
inv-map-fib-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (t : C × D) →
(fib f (pr1 t)) × (fib g (pr2 t)) → fib (functor-prod f g) t
inv-map-fib-functor-prod f g (pair .(f x) .(g y))
(pair (pair x refl) (pair y refl)) = pair (pair x y) refl
issec-inv-map-fib-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (t : C × D) →
((map-fib-functor-prod f g t) ∘ (inv-map-fib-functor-prod f g t)) ~ id
issec-inv-map-fib-functor-prod f g (pair .(f x) .(g y))
(pair (pair x refl) (pair y refl)) = refl
isretr-inv-map-fib-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (t : C × D) →
((inv-map-fib-functor-prod f g t) ∘ (map-fib-functor-prod f g t)) ~ id
isretr-inv-map-fib-functor-prod f g .(functor-prod f g (pair a b))
(pair (pair a b) refl) = refl
abstract
is-equiv-map-fib-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (t : C × D) →
is-equiv (map-fib-functor-prod f g t)
is-equiv-map-fib-functor-prod f g t =
is-equiv-has-inverse
( inv-map-fib-functor-prod f g t)
( issec-inv-map-fib-functor-prod f g t)
( isretr-inv-map-fib-functor-prod f g t)
abstract
is-equiv-left-factor-is-equiv-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (d : D) →
is-equiv (functor-prod f g) → is-equiv f
is-equiv-left-factor-is-equiv-functor-prod f g d is-equiv-fg =
is-equiv-is-contr-map
( λ x → is-contr-left-factor-prod
( fib f x)
( fib g d)
( is-contr-is-equiv'
( fib (functor-prod f g) (pair x d))
( map-fib-functor-prod f g (pair x d))
( is-equiv-map-fib-functor-prod f g (pair x d))
( is-contr-map-is-equiv is-equiv-fg (pair x d))))
abstract
is-equiv-right-factor-is-equiv-functor-prod :
{l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4}
(f : A → C) (g : B → D) (c : C) →
is-equiv (functor-prod f g) → is-equiv g
is-equiv-right-factor-is-equiv-functor-prod f g c is-equiv-fg =
is-equiv-is-contr-map
( λ y → is-contr-right-factor-prod
( fib f c)
( fib g y)
( is-contr-is-equiv'
( fib (functor-prod f g) (pair c y))
( map-fib-functor-prod f g (pair c y))
( is-equiv-map-fib-functor-prod f g (pair c y))
( is-contr-map-is-equiv is-equiv-fg (pair c y))))
abstract
is-pullback-left-factor-is-pullback-prod :
{l1 l2 l3 l4 l1' l2' l3' l4' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} {C' : UU l4'}
(f : A → X) (g : B → X) (c : cone f g C)
(f' : A' → X') (g' : B' → X') (c' : cone f' g' C') →
is-pullback
( functor-prod f f')
( functor-prod g g')
( cone-pair f g f' g' c c') →
canonical-pullback f' g' → is-pullback f g c
is-pullback-left-factor-is-pullback-prod f g c f' g' c' is-pb-cc' t =
is-equiv-left-factor-is-equiv-functor-prod (gap f g c) (gap f' g' c') t
( is-equiv-right-factor
( gap
( functor-prod f f')
( functor-prod g g')
( cone-pair f g f' g' c c'))
( map-cone-pair f g f' g')
( functor-prod (gap f g c) (gap f' g' c'))
( triangle-map-cone-pair f g c f' g' c')
( is-equiv-map-cone-pair f g f' g')
( is-pb-cc'))
abstract
is-pullback-right-factor-is-pullback-prod :
{l1 l2 l3 l4 l1' l2' l3' l4' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} {C : UU l4}
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} {C' : UU l4'}
(f : A → X) (g : B → X) (c : cone f g C)
(f' : A' → X') (g' : B' → X') (c' : cone f' g' C') →
is-pullback
( functor-prod f f')
( functor-prod g g')
( cone-pair f g f' g' c c') →
canonical-pullback f g → is-pullback f' g' c'
is-pullback-right-factor-is-pullback-prod f g c f' g' c' is-pb-cc' t =
is-equiv-right-factor-is-equiv-functor-prod (gap f g c) (gap f' g' c') t
( is-equiv-right-factor
( gap
( functor-prod f f')
( functor-prod g g')
( cone-pair f g f' g' c c'))
( map-cone-pair f g f' g')
( functor-prod (gap f g c) (gap f' g' c'))
( triangle-map-cone-pair f g c f' g' c')
( is-equiv-map-cone-pair f g f' g')
( is-pb-cc'))
-- Exercise 10.8
cone-Π :
{l1 l2 l3 l4 l5 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4} {C : I → UU l5}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i)
(c : (i : I) → cone (f i) (g i) (C i)) →
cone (postcomp-Π f) (postcomp-Π g) ((i : I) → C i)
cone-Π f g c =
pair
( postcomp-Π (λ i → pr1 (c i)))
( pair
( postcomp-Π (λ i → pr1 (pr2 (c i))))
( htpy-postcomp-Π (λ i → pr2 (pr2 (c i)))))
map-canonical-pullback-Π :
{l1 l2 l3 l4 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i) →
canonical-pullback (postcomp-Π f) (postcomp-Π g) →
(i : I) → canonical-pullback (f i) (g i)
map-canonical-pullback-Π f g (pair α (pair β γ)) i =
pair (α i) (pair (β i) (htpy-eq γ i))
inv-map-canonical-pullback-Π :
{l1 l2 l3 l4 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i) →
((i : I) → canonical-pullback (f i) (g i)) →
canonical-pullback (postcomp-Π f) (postcomp-Π g)
inv-map-canonical-pullback-Π f g h =
pair
( λ i → (pr1 (h i)))
( pair
( λ i → (pr1 (pr2 (h i))))
( eq-htpy (λ i → (pr2 (pr2 (h i))))))
issec-inv-map-canonical-pullback-Π :
{l1 l2 l3 l4 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i) →
((map-canonical-pullback-Π f g) ∘ (inv-map-canonical-pullback-Π f g)) ~ id
issec-inv-map-canonical-pullback-Π f g h =
eq-htpy
( λ i → eq-Eq-canonical-pullback (f i) (g i) refl refl
( inv
( ( right-unit) ∙
( htpy-eq (issec-eq-htpy (λ i → (pr2 (pr2 (h i))))) i))))
isretr-inv-map-canonical-pullback-Π :
{l1 l2 l3 l4 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i) →
((inv-map-canonical-pullback-Π f g) ∘ (map-canonical-pullback-Π f g)) ~ id
isretr-inv-map-canonical-pullback-Π f g (pair α (pair β γ)) =
eq-Eq-canonical-pullback
( postcomp-Π f)
( postcomp-Π g)
refl
refl
( inv (right-unit ∙ (isretr-eq-htpy γ)))
abstract
is-equiv-map-canonical-pullback-Π :
{l1 l2 l3 l4 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i) →
is-equiv (map-canonical-pullback-Π f g)
is-equiv-map-canonical-pullback-Π f g =
is-equiv-has-inverse
( inv-map-canonical-pullback-Π f g)
( issec-inv-map-canonical-pullback-Π f g)
( isretr-inv-map-canonical-pullback-Π f g)
triangle-map-canonical-pullback-Π :
{l1 l2 l3 l4 l5 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4} {C : I → UU l5}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i)
(c : (i : I) → cone (f i) (g i) (C i)) →
( postcomp-Π (λ i → gap (f i) (g i) (c i))) ~
( ( map-canonical-pullback-Π f g) ∘
( gap (postcomp-Π f) (postcomp-Π g) (cone-Π f g c)))
triangle-map-canonical-pullback-Π f g c h =
eq-htpy (λ i →
eq-Eq-canonical-pullback
(f i)
(g i)
refl refl
( (htpy-eq (issec-eq-htpy _) i) ∙ (inv right-unit)))
abstract
is-pullback-cone-Π :
{l1 l2 l3 l4 l5 : Level} {I : UU l1}
{A : I → UU l2} {B : I → UU l3} {X : I → UU l4} {C : I → UU l5}
(f : (i : I) → A i → X i) (g : (i : I) → B i → X i)
(c : (i : I) → cone (f i) (g i) (C i)) →
((i : I) → is-pullback (f i) (g i) (c i)) →
is-pullback (postcomp-Π f) (postcomp-Π g) (cone-Π f g c)
is-pullback-cone-Π f g c is-pb-c =
is-equiv-right-factor
( postcomp-Π (λ i → gap (f i) (g i) (c i)))
( map-canonical-pullback-Π f g)
( gap (postcomp-Π f) (postcomp-Π g) (cone-Π f g c))
( triangle-map-canonical-pullback-Π f g c)
( is-equiv-map-canonical-pullback-Π f g)
( is-equiv-postcomp-Π _ is-pb-c)
-- Exercise 10.9
hom-cospan :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X') →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ (l1' ⊔ (l2' ⊔ l3')))))
hom-cospan {A = A} {B} {X} f g {A'} {B'} {X'} f' g' =
Σ (A → A') (λ hA →
Σ (B → B') (λ hB →
Σ (X → X') (λ hX →
((f' ∘ hA) ~ (hX ∘ f)) × ((g' ∘ hB) ~ (hX ∘ g)))))
id-hom-cospan :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X) →
hom-cospan f g f g
id-hom-cospan f g =
pair id (pair id (pair id (pair htpy-refl htpy-refl)))
functor-canonical-pullback :
{l1 l2 l3 l1' l2' l3' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X') →
hom-cospan f' g' f g →
canonical-pullback f' g' → canonical-pullback f g
functor-canonical-pullback f g f' g'
(pair hA (pair hB (pair hX (pair HA HB)))) (pair a' (pair b' p')) =
pair (hA a') (pair (hB b') ((HA a') ∙ ((ap hX p') ∙ (inv (HB b')))))
cospan-hom-cospan-rotate :
{l1 l2 l3 l1' l2' l3' l1'' l2'' l3'' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X')
{A'' : UU l1''} {B'' : UU l2''} {X'' : UU l3''}
(f'' : A'' → X'') (g'' : B'' → X'')
(h : hom-cospan f' g' f g) (h' : hom-cospan f'' g'' f g) →
hom-cospan (pr1 h) (pr1 h') (pr1 (pr2 (pr2 h))) (pr1 (pr2 (pr2 h')))
cospan-hom-cospan-rotate f g f' g' f'' g'' (pair hA (pair hB (pair hX (pair HA HB)))) (pair hA' (pair hB' (pair hX' (pair HA' HB')))) =
pair f' (pair f'' (pair f (pair (htpy-inv HA) (htpy-inv HA'))))
cospan-hom-cospan-rotate' :
{l1 l2 l3 l1' l2' l3' l1'' l2'' l3'' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X')
{A'' : UU l1''} {B'' : UU l2''} {X'' : UU l3''}
(f'' : A'' → X'') (g'' : B'' → X'')
(h : hom-cospan f' g' f g) (h' : hom-cospan f'' g'' f g) →
hom-cospan
(pr1 (pr2 h)) (pr1 (pr2 h')) (pr1 (pr2 (pr2 h))) (pr1 (pr2 (pr2 h')))
cospan-hom-cospan-rotate' f g f' g' f'' g''
(pair hA (pair hB (pair hX (pair HA HB))))
(pair hA' (pair hB' (pair hX' (pair HA' HB')))) =
pair g' (pair g'' (pair g (pair (htpy-inv HB) (htpy-inv HB'))))
{-
map-3-by-3-canonical-pullback' :
{l1 l2 l3 l1' l2' l3' l1'' l2'' l3'' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X')
{A'' : UU l1''} {B'' : UU l2''} {X'' : UU l3''}
(f'' : A'' → X'') (g'' : B → X'')
(h : hom-cospan f' g' f g) (h' : hom-cospan f'' g'' f g) →
Σ ( canonical-pullback f' g') (λ t' →
Σ ( canonical-pullback f'' g'') (λ t'' →
Eq-canonical-pullback f g
( functor-canonical-pullback f g f' g' h t')
( functor-canonical-pullback f g f'' g'' h' t''))) →
Σ ( canonical-pullback (pr1 h) (pr1 h')) (λ s →
Σ ( canonical-pullback (pr1 (pr2 h)) (pr1 (pr2 h'))) (λ s' →
Eq-canonical-pullback (pr1 (pr2 (pr2 h))) (pr1 (pr2 (pr2 h')))
( functor-canonical-pullback
( pr1 (pr2 (pr2 h)))
( pr1 (pr2 (pr2 h')))
( pr1 h)
( pr1 h')
( cospan-hom-cospan-rotate f g f' g' f'' g'' h h')
( s))
( functor-canonical-pullback
( pr1 (pr2 (pr2 h)))
( pr1 (pr2 (pr2 h')))
( pr1 (pr2 h))
( pr1 (pr2 h'))
( cospan-hom-cospan-rotate' f g f' g' f'' g'' h h')
( s'))))
map-3-by-3-canonical-pullback' f g f' g' f'' g''
( pair hA (pair hB (pair hX (pair HA HB))))
( pair hA' (pair hB' (pair hX' (pair HA' HB'))))
( pair
( pair a' (pair b' p'))
( pair (pair a'' (pair b'' p'')) (pair α (pair β γ)))) =
pair (pair a' (pair a'' α)) (pair (pair b' (pair b'' β)) (pair p' (pair p'' {!!})))
map-3-by-3-canonical-pullback :
{l1 l2 l3 l1' l2' l3' l1'' l2'' l3'' : Level}
{A : UU l1} {B : UU l2} {X : UU l3} (f : A → X) (g : B → X)
{A' : UU l1'} {B' : UU l2'} {X' : UU l3'} (f' : A' → X') (g' : B' → X')
{A'' : UU l1''} {B'' : UU l2''} {X'' : UU l3''}
(f'' : A'' → X'') (g'' : B → X'')
(h : hom-cospan f' g' f g) (h' : hom-cospan f'' g'' f g) →
canonical-pullback
( functor-canonical-pullback f g f' g' h)
( functor-canonical-pullback f g f'' g'' h') →
canonical-pullback
( functor-canonical-pullback
( pr1 (pr2 (pr2 h)))
( pr1 (pr2 (pr2 h')))
( pr1 h)
( pr1 h')
( cospan-hom-cospan-rotate f g f' g' f'' g'' h h'))
( functor-canonical-pullback
( pr1 (pr2 (pr2 h)))
( pr1 (pr2 (pr2 h')))
( pr1 (pr2 h))
( pr1 (pr2 h'))
( cospan-hom-cospan-rotate' f g f' g' f'' g'' h h'))
map-3-by-3-canonical-pullback = {!!}
-}
| 38.18593
| 135
| 0.512357
|
cbf404f256b327fb8dc47e6827658e38262802ed
| 438
|
agda
|
Agda
|
neq.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
neq.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
neq.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module neq where
open import eq
open import negation
----------------------------------------------------------------------
-- syntax
----------------------------------------------------------------------
infix 4 _≢_
----------------------------------------------------------------------
-- defined types
----------------------------------------------------------------------
_≢_ : ∀ {ℓ}{A : Set ℓ} → A → A → Set ℓ
x ≢ y = ¬ (x ≡ y)
| 25.764706
| 70
| 0.200913
|
1cc20f5c1cbe629f0e4dac5a32b27de74d94f21f
| 1,030
|
agda
|
Agda
|
lib/Haskell/Prim/Real.agda
|
ioanasv/agda2hs
|
17cdbeb36af3d0b735c5db83bb811034c39a19cd
|
[
"MIT"
] | 1
|
2021-05-25T09:41:34.000Z
|
2021-05-25T09:41:34.000Z
|
lib/Haskell/Prim/Real.agda
|
ioanasv/agda2hs
|
17cdbeb36af3d0b735c5db83bb811034c39a19cd
|
[
"MIT"
] | null | null | null |
lib/Haskell/Prim/Real.agda
|
ioanasv/agda2hs
|
17cdbeb36af3d0b735c5db83bb811034c39a19cd
|
[
"MIT"
] | null | null | null |
module Haskell.Prim.Real where
open import Haskell.Prim
open import Haskell.Prim.Ord
open import Haskell.Prim.Enum
open import Haskell.Prim.Num
open import Haskell.Prim.Eq
open import Haskell.Prim.Int
open import Haskell.Prim.Integer
-- infixr 8 _^_ _^^_
-- infixl 7 _/_ _`quot`_ _`rem`_ _`div`_ _`mod`_
-- infixl 7 _%_
data Ratio (a : Set) : Set where
_:%_ : a -> a -> Ratio a
record Integral (a : Set) : Set where
field
toInteger : a -> Integer
open Integral ⦃ ... ⦄ public
instance
isIntegralInt : Integral Int
isIntegralInt . toInteger n = intToInteger n
infinity : Ratio Integer
notANumber : Ratio Integer
infinity = (toInteger 1) :% (toInteger 0)
notANumber = (toInteger 0) :% (toInteger 0)
-- _%_ : {{Integral a}} -> a -> a -> Ratio a
numerator : Ratio a -> a
denominator : Ratio a -> a
-- reduce : {{Integral a}} -> a -> a -> Ratio a
numerator (x :% _) = x
denominator (_ :% y) = y
-- record Real {Num a} (a : Set) : Set where
-- field
-- toRational : a -> Ratio Integer
| 20.6
| 49
| 0.646602
|
12012a76bb321269dad751cb3db5efe0eaa69529
| 559
|
agda
|
Agda
|
archive/agda-3/src/Oscar/Class/Transextensionality/Proposequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Oscar/Class/Transextensionality/Proposequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Oscar/Class/Transextensionality/Proposequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Congruity
open import Oscar.Class.Transextensionality
open import Oscar.Class.Transitivity
open import Oscar.Data.Proposequality
import Oscar.Class.Congruity.Proposequality
module Oscar.Class.Transextensionality.Proposequality where
instance
𝓣ransextensionalityProposequality : ∀
{a} {A : Ø a}
{m} {_⊸_ : A → A → Ø m}
⦃ _ : Transitivity.class _⊸_ ⦄
→ Transextensionality.class _⊸_ Proposequality transitivity
𝓣ransextensionalityProposequality .⋆ = congruity₂ _
| 27.95
| 63
| 0.779964
|
4a45571df994e2e7caf9035597a303338adab58f
| 3,854
|
agda
|
Agda
|
agda-stdlib-0.9/src/Category/Monad/State.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/src/Category/Monad/State.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Category/Monad/State.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The state monad
------------------------------------------------------------------------
module Category.Monad.State where
open import Category.Applicative.Indexed
open import Category.Monad
open import Category.Monad.Identity
open import Category.Monad.Indexed
open import Data.Product
open import Data.Unit
open import Function
open import Level
------------------------------------------------------------------------
-- Indexed state monads
IStateT : ∀ {i f} {I : Set i} → (I → Set f) → (Set f → Set f) → IFun I f
IStateT S M i j A = S i → M (A × S j)
StateTIMonad : ∀ {i f} {I : Set i} (S : I → Set f) {M} →
RawMonad M → RawIMonad (IStateT S M)
StateTIMonad S Mon = record
{ return = λ x s → return (x , s)
; _>>=_ = λ m f s → m s >>= uncurry f
}
where open RawMonad Mon
StateTIMonadZero : ∀ {i f} {I : Set i} (S : I → Set f) {M} →
RawMonadZero M → RawIMonadZero (IStateT S M)
StateTIMonadZero S Mon = record
{ monad = StateTIMonad S (RawMonadZero.monad Mon)
; ∅ = const ∅
}
where open RawMonadZero Mon
StateTIMonadPlus : ∀ {i f} {I : Set i} (S : I → Set f) {M} →
RawMonadPlus M → RawIMonadPlus (IStateT S M)
StateTIMonadPlus S Mon = record
{ monadZero = StateTIMonadZero S (RawIMonadPlus.monadZero Mon)
; _∣_ = λ m₁ m₂ s → m₁ s ∣ m₂ s
}
where open RawMonadPlus Mon
------------------------------------------------------------------------
-- State monad operations
record RawIMonadState {i f} {I : Set i} (S : I → Set f)
(M : IFun I f) : Set (i ⊔ suc f) where
field
monad : RawIMonad M
get : ∀ {i} → M i i (S i)
put : ∀ {i j} → S j → M i j (Lift ⊤)
open RawIMonad monad public
modify : ∀ {i j} → (S i → S j) → M i j (Lift ⊤)
modify f = get >>= put ∘ f
StateTIMonadState : ∀ {i f} {I : Set i} (S : I → Set f) {M} →
RawMonad M → RawIMonadState S (IStateT S M)
StateTIMonadState S Mon = record
{ monad = StateTIMonad S Mon
; get = λ s → return (s , s)
; put = λ s _ → return (_ , s)
}
where open RawIMonad Mon
------------------------------------------------------------------------
-- Ordinary state monads
RawMonadState : ∀ {f} → Set f → (Set f → Set f) → Set _
RawMonadState S M = RawIMonadState {I = ⊤} (λ _ → S) (λ _ _ → M)
module RawMonadState {f} {S : Set f} {M : Set f → Set f}
(Mon : RawMonadState S M) where
open RawIMonadState Mon public
StateT : ∀ {f} → Set f → (Set f → Set f) → Set f → Set f
StateT S M = IStateT {I = ⊤} (λ _ → S) M _ _
StateTMonad : ∀ {f} (S : Set f) {M} → RawMonad M → RawMonad (StateT S M)
StateTMonad S = StateTIMonad (λ _ → S)
StateTMonadZero : ∀ {f} (S : Set f) {M} →
RawMonadZero M → RawMonadZero (StateT S M)
StateTMonadZero S = StateTIMonadZero (λ _ → S)
StateTMonadPlus : ∀ {f} (S : Set f) {M} →
RawMonadPlus M → RawMonadPlus (StateT S M)
StateTMonadPlus S = StateTIMonadPlus (λ _ → S)
StateTMonadState : ∀ {f} (S : Set f) {M} →
RawMonad M → RawMonadState S (StateT S M)
StateTMonadState S = StateTIMonadState (λ _ → S)
State : ∀ {f} → Set f → Set f → Set f
State S = StateT S Identity
StateMonad : ∀ {f} (S : Set f) → RawMonad (State S)
StateMonad S = StateTMonad S IdentityMonad
StateMonadState : ∀ {f} (S : Set f) → RawMonadState S (State S)
StateMonadState S = StateTMonadState S IdentityMonad
LiftMonadState : ∀ {f S₁} (S₂ : Set f) {M} →
RawMonadState S₁ M →
RawMonadState S₁ (StateT S₂ M)
LiftMonadState S₂ Mon = record
{ monad = StateTIMonad (λ _ → S₂) monad
; get = λ s → get >>= λ x → return (x , s)
; put = λ s′ s → put s′ >> return (_ , s)
}
where open RawIMonadState Mon
| 32.661017
| 72
| 0.532693
|
128b3243bbddd1c3146c51db5a17e2168438c784
| 890
|
agda
|
Agda
|
test/Succeed/Issue5809.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | null | null | null |
test/Succeed/Issue5809.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Succeed/Issue5809.agda
|
antoinevanmuylder/agda
|
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
|
[
"BSD-2-Clause"
] | null | null | null |
-- Andreas, 2022-03-07, issue #5809 reported by jamestmartin
-- Regression in Agda 2.6.1.
-- Not reducing irrelevant projections lead to non-inferable elim-terms
-- and consequently to internal errors.
--
-- The fix is to treat irrelevant projections as just functions,
-- retaining their parameters, so that they remain inferable
-- even if not in normal form.
{-# OPTIONS --irrelevant-projections #-}
{-# OPTIONS --allow-unsolved-metas #-}
-- {-# OPTIONS --no-double-check #-}
-- {-# OPTIONS -v impossible:100 #-}
-- {-# OPTIONS -v tc:40 #-}
open import Agda.Builtin.Equality
record Squash {ℓ} (A : Set ℓ) : Set ℓ where
constructor squash
field
.unsquash : A
open Squash
.test : ∀ {ℓ} {A : Set ℓ} (x : A) (y : Squash A) → {!!}
test x y = {!!}
where
help : unsquash (squash x) ≡ unsquash y
help = refl
-- WAS: internal error.
-- Should succeed with unsolved metas.
| 26.969697
| 71
| 0.665169
|
12fa953fa68956c1848fa118718a248fbe036281
| 454
|
agda
|
Agda
|
test/Succeed/Issue1719.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1719.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1719.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import Issue1719.Common
open import Issue1719.Spans
open import Issue1719.Pushouts
module _ {d : Span} {l} {P : Pushout d → Set l}
(left* : (a : Span.A d) → P (left a))
(right* : (b : Span.B d) → P (right b))
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c) [ P ↓ glue c ]) where
test : (a : Span.A d) → Pushout-elim {P = P} left* right* glue* (left a) ↦ left* a
test a = idr
| 30.266667
| 91
| 0.577093
|
a1e2e612b5adc766d4a2f89f475492fe50b53b5a
| 193
|
agda
|
Agda
|
Computability/Enumeration/Univalence.agda
|
jesyspa/computability-in-agda
|
1b5cf338eb0adb90c1897383e05251ddd954efff
|
[
"MIT"
] | 2
|
2020-09-19T15:51:22.000Z
|
2021-04-30T11:15:51.000Z
|
Computability/Enumeration/Univalence.agda
|
jesyspa/computability-in-agda
|
1b5cf338eb0adb90c1897383e05251ddd954efff
|
[
"MIT"
] | null | null | null |
Computability/Enumeration/Univalence.agda
|
jesyspa/computability-in-agda
|
1b5cf338eb0adb90c1897383e05251ddd954efff
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
module Computability.Enumeration.Univalence where
open import Cubical.Core.Everything
open import Computability.Prelude
open import Computability.Enumeration.Base
| 19.3
| 49
| 0.818653
|
4d345e81c4b0a3e474f95e6212cb8d606de7cf66
| 3,834
|
agda
|
Agda
|
dom-eq.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 16
|
2018-03-12T14:32:03.000Z
|
2021-12-19T02:50:23.000Z
|
dom-eq.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 54
|
2017-06-29T20:53:34.000Z
|
2018-11-29T16:32:40.000Z
|
dom-eq.agda
|
hazelgrove/hazelnut-livelits-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 1
|
2019-09-13T18:20:02.000Z
|
2019-09-13T18:20:02.000Z
|
open import Prelude
open import Nat
open import core
open import contexts
open import lemmas-disjointness
module dom-eq where
-- main definition: two contexts are domain-equal when they produce (Some
-- x) on the same indices. note that the context need not map indices to
-- even the same type of contents; this is just a property about the
-- domains. the proofs that follow establish that this property is
-- respected in the appropriate ways by the context maniupulation
-- operators we use in the other judgements.
dom-eq : {A B : Set} → A ctx → B ctx → Set
dom-eq {A} {B} C1 C2 = ((n : Nat) → Σ[ x ∈ A ]( C1 n == Some x) → (Σ[ y ∈ B ](C2 n == Some y)))×
((n : Nat) → Σ[ y ∈ B ]( C2 n == Some y) → (Σ[ x ∈ A ](C1 n == Some x)))
-- the empty context has the same domain as itself
dom-∅ : {A B : Set} → dom-eq (λ _ → None {A}) (λ _ → None {B})
dom-∅ {A} {B} = (λ n x → abort (somenotnone (! (π2 x)))) , (λ n x → abort (somenotnone (! (π2 x))))
-- the singleton contexts formed with any contents but the same index has
-- the same domain
dom-single : {A B : Set} (x : Nat) {a : A} {b : B} → dom-eq (■ (x , a)) (■ (x , b))
dom-single {A} {B} x {α} {β} = (λ n x₁ → β , (ap1 (λ qq → (■ (qq , β)) n) (! (lem-dom-eq x₁)) · x∈■ _ _)) ,
(λ n x₁ → α , (ap1 (λ qq → (■ (qq , α)) n) (! (lem-dom-eq x₁)) · x∈■ _ _))
-- if two disjoint contexts each share a domain with two others, those
-- are also disjoint.
dom-eq-disj : {A B : Set} {Δ1 Δ2 : A ctx} {H1 H2 : B ctx} →
H1 ## H2 →
dom-eq Δ1 H1 →
dom-eq Δ2 H2 →
Δ1 ## Δ2
dom-eq-disj {A} {B} {Δ1} {Δ2} {H1} {H2} (d1 , d2) (de1 , de2) (de3 , de4) = guts1 , guts2
where
guts1 : (n : Nat) → dom Δ1 n → n # Δ2
guts1 n dom1 with ctxindirect H2 n
guts1 n dom1 | Inl x = abort (somenotnone (! (π2 x) · d1 n (de1 n dom1)))
guts1 n dom1 | Inr x with ctxindirect Δ2 n
guts1 n dom1 | Inr x₁ | Inl x = abort (somenotnone (! (π2 (de3 n x)) · x₁))
guts1 n dom1 | Inr x₁ | Inr x = x
guts2 : (n : Nat) → dom Δ2 n → n # Δ1
guts2 n dom2 with ctxindirect H1 n
guts2 n dom2 | Inl x = abort (somenotnone (! (π2 x) · d2 n (de3 n dom2)))
guts2 n dom2 | Inr x with ctxindirect Δ1 n
guts2 n dom2 | Inr x₁ | Inl x = abort (somenotnone (! (π2 (de1 n x)) · x₁))
guts2 n dom2 | Inr x₁ | Inr x = x
-- if two sets share a domain with disjoint sets, then their union shares
-- a domain with the union
dom-union : {A B : Set} {Δ1 Δ2 : A ctx} {H1 H2 : B ctx} →
H1 ## H2 →
dom-eq Δ1 H1 →
dom-eq Δ2 H2 →
dom-eq (Δ1 ∪ Δ2) (H1 ∪ H2)
dom-union {A} {B} {Δ1} {Δ2} {H1} {H2} disj (p1 , p2) (p3 , p4) = guts1 , guts2
where
guts1 : (n : Nat) →
Σ[ x ∈ A ] ((Δ1 ∪ Δ2) n == Some x) →
Σ[ y ∈ B ] ((H1 ∪ H2) n == Some y)
guts1 n (x , eq) with ctxindirect Δ1 n
guts1 n (x₁ , eq) | Inl x with p1 n x
... | q1 , q2 = q1 , x∈∪l H1 H2 n q1 q2
guts1 n (x₁ , eq) | Inr x with p3 n (_ , lem-dom-union-apt1 {Δ1 = Δ1} {Δ2 = Δ2} x eq)
... | q1 , q2 = q1 , x∈∪r H1 H2 n q1 q2 (##-comm disj)
guts2 : (n : Nat) →
Σ[ y ∈ B ] ((H1 ∪ H2) n == Some y) →
Σ[ x ∈ A ] ((Δ1 ∪ Δ2) n == Some x)
guts2 n (x , eq) with ctxindirect H1 n
guts2 n (x₁ , eq) | Inl x with p2 n x
... | q1 , q2 = q1 , x∈∪l Δ1 Δ2 n q1 q2
guts2 n (x₁ , eq) | Inr x with p4 n (_ , lem-dom-union-apt2 {Δ1 = H2} {Δ2 = H1} x (tr (λ qq → qq n == Some x₁) (∪comm H1 H2 disj) eq))
... | q1 , q2 = q1 , x∈∪r Δ1 Δ2 n q1 q2 (##-comm (dom-eq-disj disj (p1 , p2) (p3 , p4)))
| 49.153846
| 140
| 0.497392
|
cbe8e9581d4927d06fb7bf5313651a33734f2e82
| 746
|
agda
|
Agda
|
test/Succeed/Issue2321.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2321.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2321.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --guardedness #-}
open import Agda.Builtin.Coinduction
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Agda.Builtin.Nat
infixr 5 _∷_
data Stream (A : Set) : Set where
_∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A
head : ∀ {A} → Stream A → A
head (x ∷ xs) = x
tail : ∀ {A} → Stream A → Stream A
tail (x ∷ xs) = ♭ xs
take : ∀ {A} (n : Nat) → Stream A → List A
take zero xs = []
take (suc n) (x ∷ xs) = x ∷ take n (♭ xs)
accepted : ∀ {A} {n} (xs : Stream A) →
take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs)
accepted (x ∷ xs) = refl
private
rejected : ∀ {A} {n} (xs : Stream A) →
take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs)
rejected (x ∷ xs) = refl
| 24.064516
| 65
| 0.553619
|
06a8cd208bc0b054acd8044550c29354fae619e3
| 7,102
|
agda
|
Agda
|
lambda/hw7.agda
|
Lapin0t/lambda
|
09a231d9b3057d57b864070188ed9fe14a07eda2
|
[
"Apache-2.0"
] | null | null | null |
lambda/hw7.agda
|
Lapin0t/lambda
|
09a231d9b3057d57b864070188ed9fe14a07eda2
|
[
"Apache-2.0"
] | null | null | null |
lambda/hw7.agda
|
Lapin0t/lambda
|
09a231d9b3057d57b864070188ed9fe14a07eda2
|
[
"Apache-2.0"
] | null | null | null |
module lambda.hw7 where
open import Data.Product
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Binary.PropositionalEquality hiding (subst)
open import Data.Nat
open import Data.Fin hiding (lift)
open import lambda.untyped
open import lambda.vec
open import lambda.system-f renaming (⊢_∶_ to ⊢F_∶_; type to typeF)
hiding (subst; ↑; lift; subst₁)
open import lambda.system-d renaming (⊢_∶_ to ⊢D_∶_; type to typeD;
_⊢_∶_ to _⊢D_∶_; context to contextD)
-- Peio BORTHELLE -- Homework 7
-- Maybe it's a bit unusual to present things like this, we didn't do any Agda
-- but it would really have been more hassle formalizing the homework in Coq.
-- So here it is, there are some utilities in the other files and also some
-- bonus simply-typed lambda calculus. It was a bit more fun for me than to
-- write again some long derivation tree with no guarantee at all that there
-- isn't a stupid mistake kicking in. I tried to get the notations close to
-- what we had in the lesson, hope this doesn't look too alien.
-- Utilities
A B C : typeD
A = base 0
B = base 1
C = base 1
V₀ : ∀ {n} → typeF (suc n)
V₀ = var zero
V₁ : ∀ {n} → typeF (suc (suc n))
V₁ = var (suc zero)
module Q₁ where
-- Source terms
t₁ t₂ t₃ t₄ : term 0
t₁ = lam (app (var zero) (var zero))
t₂ = app t₁ (lam (var zero))
t₃ = app t₁ t₁
t₄ = lam (lam (app (var (suc zero)) (app (var zero) (var (suc zero)))))
-- a) system F
F₁ F₂ F₄ : typeF 0
F₁ = (∀' V₀ ⇒ V₀) ⇒ (∀' V₀ ⇒ V₀)
F₂ = ∀' V₀ ⇒ V₀
F₄ = ∀' ∀' (V₀ ⇒ V₁) ⇒ ((V₀ ⇒ V₁) ⇒ V₀) ⇒ V₁
F₁-p : ⊢F t₁ ∶ F₁
F₁-p = lam (∀' V₀ ⇒ V₀) (app (sub (∀' V₀ ⇒ V₀) ax) ax)
F₂-p : ⊢F t₂ ∶ F₂
F₂-p = app (lam (∀' V₀ ⇒ V₀) (app (sub (∀' V₀ ⇒ V₀) ax) ax)) (gen (lam V₀ ax))
-- t₃ is not normalizing: it has a non-trivial beta-reduction to itself.
-- Because system F is strongly normalizing this prooves that it has no valid
-- typing judgment.
t₃-no-norm : t₃ β* t₃
t₃-no-norm = β-beta ← ε
F₄-p : ⊢F t₄ ∶ F₄
F₄-p = gen (gen (lam (V₀ ⇒ V₁) (lam ((V₀ ⇒ V₁) ⇒ V₀) (app ax (app ax ax)))))
-- b) system D
σ₁ σ₂ σ₄ : typeD
σ₁ = (A ∧ A ⇒ B) ⇒ B
σ₂ = A ⇒ A
σ₄ = (A ⇒ B) ⇒ ((A ⇒ B) ⇒ A) ⇒ B
σ₁-p : ⊢D t₁ ∶ σ₁
σ₁-p = lam (app (∧ᵉʳ ax) (∧ᵉˡ ax))
σ₂-p : ⊢D t₂ ∶ σ₂
σ₂-p = app (lam (app (∧ᵉʳ ax) (∧ᵉˡ ax))) (∧ⁱ (lam ax) (lam ax))
-- Same as system F for t₃ because of the strongly normalizing property.
σ₄-p : ⊢D t₄ ∶ σ₄
σ₄-p = lam (lam (app ax (app ax ax)))
module Q₂ where
--
σ₁ σ₂ σ₃ σ₄ : typeD
σ₁ = ((A ∧ B) ⇒ C) ⇒ A ⇒ B ⇒ C
σ₂ = (A ⇒ B ⇒ C) ⇒ (A ∧ B) ⇒ C
σ₃ = (C ⇒ A ∧ C ⇒ B) ⇒ C ⇒ (A ∧ B)
σ₄ = C ⇒ (A ∧ B) ⇒ (C ⇒ A ∧ C ⇒ B)
σ₁-p : ∀ {t} → ¬ ⊢D t ∶ σ₁
σ₁-p p = {!!}
σ₂-p : ⊢D lam (lam (app (app (var (suc zero)) (var zero)) (var zero))) ∶ σ₂
σ₂-p = lam (lam (app (app ax (∧ᵉˡ ax)) (∧ᵉʳ ax)))
σ₃-p : ⊢D lam (lam (app (var (suc zero)) (var zero))) ∶ σ₃
σ₃-p = lam (lam (∧ⁱ (app (∧ᵉˡ ax) ax) (app (∧ᵉʳ ax) ax)))
σ₄-p : ⊢D lam (lam (lam (var (suc zero)))) ∶ σ₄
σ₄-p = lam (lam (∧ⁱ (lam (∧ᵉˡ ax)) (lam (∧ᵉʳ ax))))
module Q₃ where
-- I got stuck on applying the substitution lemma on function type that are
-- not lambda abstractions but ∧ eliminations. I don't manage to get from
-- a proof of that type to a proof with the argument type on the top of the
-- context. Maybe the substitution lemma is not well choosen.
subj-red : ∀ {n T} → {x y : term n} → {Γ : contextD n} → Γ ⊢D x ∶ T → x →β y → Γ ⊢D y ∶ T
subj-red ax ()
subj-red (∧ⁱ x₁ x₂) p = ∧ⁱ (subj-red x₁ p) (subj-red x₂ p)
subj-red (∧ᵉˡ x) p = ∧ᵉˡ (subj-red x p)
subj-red (∧ᵉʳ x) p = ∧ᵉʳ (subj-red x p)
subj-red (app (lam x) y) β-beta = subst-p x (λ { zero → y; (suc i) → ax })
subj-red (app (∧ᵉˡ x) y) β-beta = {! !}
subj-red (app (∧ᵉʳ x) y) β-beta = {! !}
subj-red (app x y) (β-app₁ p) = app (subj-red x p) y
subj-red (app x y) (β-app₂ p) = app x (subj-red y p)
subj-red (lam x) (β-lam p) = lam (subj-red x p)
module Q₄ where
-- The BNF grammar i use is:
--
-- <NF> ::= "λ" <VAR> "." <NF> | <NE>
-- <NE> ::= <NE> <NF> | <VAR>
--
-- I implemented this grammar as a judgment on untyped lambda terms
-- with the datatypes `lambda.untyped.norm` and `lambda.untyped.neut`.
-- Proof that NF and NE don't allow further derivation
-- This proof as well as the reciprocical were quite mechanized but still
-- a bit cumbersome.
nf-last : ∀ {n} → {x : term n} → norm x → ¬ ∃[ y ] (x →β y)
ne-last : ∀ {n} → {x : term n} → neut x → ¬ ∃[ y ] (x →β y)
nf-last (lam x) (lam y , β-lam p) = nf-last x (y , p)
nf-last (gnd x) (lam y , p) = ne-last x (lam y , p)
nf-last (gnd x) (var i , p) = ne-last x (var i , p)
nf-last (gnd x) (app a b , p) = ne-last x (app a b , p)
ne-last var (y , ())
ne-last (app () y) (_ , β-beta)
ne-last (app x y) (app a b , β-app₁ p) = ne-last x (a , p)
ne-last (app x y) (app a b , β-app₂ p) = nf-last y (b , p)
-- Proof that terms with no further derivation are in NF
last-nf : ∀ {n} → (x : term n) → ¬ ∃[ y ] (x →β y) → norm x
last-ne : ∀ {n y} → (x : term n) → ¬ ∃[ z ] (app x y →β z) → neut x
last-nf (lam x) p = lam (last-nf x λ { (y , p₂) → p (lam y , β-lam p₂) })
last-nf (var x) p = gnd var
last-nf (app x y) p = gnd (app
(last-ne x λ { (z , p₁) → p (z , p₁) })
(last-nf y λ { (a , b) → p (app x a , β-app₂ b) }))
last-ne {y = y} (lam x) p with p (subst₁ x y , β-beta)
... | ()
last-ne (var x) p = var
last-ne {y = y} (app x z) p = app
(last-ne x λ { (a , b) → p (app a y , β-app₁ b) })
(last-nf z λ { (a , b) → p (app (app x a) y , (β-app₁ (β-app₂ b))) })
const : ∀ {n} → contextD n
const {zero} = ε
const {suc n} = const ▸ base 0
-- Again because i messed up the renaming/substitution on ⊢D terms, i
-- did not get to formalize the typing properly here.
type-n : ∀ {n} → {x : term n} → norm x → ∃ (λ Γ → ∃ (λ T → Γ ⊢D x ∶ T))
type-e : ∀ {n} → {x : term n} → neut x → ∃ (λ Γ → ∃ (λ T → Γ ⊢D x ∶ T))
-- Here we compute inductively on the subterm, then "unload" the top of
-- the context A and the result type B into the type A ⇒ B.
type-n (lam x) = {! !}
type-n (gnd x) = type-e x
-- Here we create a context with fresh base types, assigning the matching
-- one to the term.
type-e (var {i}) = {! !}
-- Here we compute inductively on both subterms:
-- Γx ⊢D x ∶ Tx Γy ⊢D y ∶ Ty
-- x is a neutral term so it has a type looking like
-- T ⇒ A₁ ∧ T ⇒ A₁ ⇒ A₂ ∧ …
-- We then simply extend it with An = Ty. This requires some proof
-- rewriting with ∧ᵉ*.
type-e (app x y) = {! !}
-- Question 5
-- a) The definition of the conjunction in system F is:
-- conjⁱ : Γ ⊢F x ∶ A → Γ ⊢F y ∶ B → Γ ⊢F (x , y) ∶ A ∧F B
-- conjᵉʳ : Γ ⊢F x ∶ A ∧F B → Γ ⊢F π₀ x ∶ A
-- conjᵉˡ : Γ ⊢F x : A ∧F B → Γ ⊢F π₁ x ∶ B
-- The difference is that in system D, the conjunction is more of
-- an intersection: if a single term has 2 type judgements, then
-- it has a judgment for the intersection, whereas for system F
-- it is a couple of 2 different terms.
| 34.813725
| 91
| 0.559279
|
185cd6517d16c95343a080b3b4818b9a86429c7d
| 168
|
agda
|
Agda
|
Cubical/Data/Universe.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/Data/Universe.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/Data/Universe.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Universe where
open import Cubical.Data.Universe.Base public
open import Cubical.Data.Universe.Properties public
| 24
| 51
| 0.785714
|
315a1c1c6f7105c302271def83d0a8d8858534d6
| 210
|
agda
|
Agda
|
test/Compiler/simple/Issue1486.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Compiler/simple/Issue1486.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Compiler/simple/Issue1486.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue1486 where
open import Common.Prelude
postulate
QName : Set
{-# BUILTIN QNAME QName #-}
primitive
primShowQName : QName -> String
main : IO Unit
main = putStrLn (primShowQName (quote main))
| 15
| 44
| 0.733333
|
18fa83405304de1aec2fed4dd27ebe2744fe210c
| 7,088
|
agda
|
Agda
|
agda-stdlib/src/Data/Nat/GCD/Lemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Nat/GCD/Lemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Nat/GCD/Lemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.GCD.Lemmas where
open import Data.Nat.Base
open import Data.Nat.Properties
open import Data.Nat.Solver
open import Function
open import Relation.Binary.PropositionalEquality
open +-*-Solver
open ≡-Reasoning
private
distrib-comm : ∀ x k n → x * k + x * n ≡ x * (n + k)
distrib-comm =
solve 3 (λ x k n → x :* k :+ x :* n := x :* (n :+ k)) refl
distrib-comm₂ : ∀ d x k n → d + x * (n + k) ≡ d + x * k + x * n
distrib-comm₂ =
solve 4 (λ d x k n → d :+ x :* (n :+ k) := d :+ x :* k :+ x :* n) refl
-- Other properties
-- TODO: Can this proof be simplified? An automatic solver which can
-- handle ∸ would be nice...
lem₀ : ∀ i j m n → i * m ≡ j * m + n → (i ∸ j) * m ≡ n
lem₀ i j m n eq = begin
(i ∸ j) * m ≡⟨ *-distribʳ-∸ m i j ⟩
(i * m) ∸ (j * m) ≡⟨ cong (_∸ j * m) eq ⟩
(j * m + n) ∸ (j * m) ≡⟨ cong (_∸ j * m) (+-comm (j * m) n) ⟩
(n + j * m) ∸ (j * m) ≡⟨ m+n∸n≡m n (j * m) ⟩
n ∎
lem₁ : ∀ i j → 2 + i ≤′ 2 + j + i
lem₁ i j = ≤⇒≤′ $ s≤s $ s≤s $ m≤n+m i j
lem₂ : ∀ d x {k n} →
d + x * k ≡ x * n → d + x * (n + k) ≡ 2 * x * n
lem₂ d x {k} {n} eq = begin
d + x * (n + k) ≡⟨ distrib-comm₂ d x k n ⟩
d + x * k + x * n ≡⟨ cong₂ _+_ eq refl ⟩
x * n + x * n ≡⟨ solve 3 (λ x n k → x :* n :+ x :* n
:= con 2 :* x :* n)
refl x n k ⟩
2 * x * n ∎
lem₃ : ∀ d x {i k n} →
d + (1 + x + i) * k ≡ x * n →
d + (1 + x + i) * (n + k) ≡ (1 + 2 * x + i) * n
lem₃ d x {i} {k} {n} eq = begin
d + y * (n + k) ≡⟨ distrib-comm₂ d y k n ⟩
d + y * k + y * n ≡⟨ cong₂ _+_ eq refl ⟩
x * n + y * n ≡⟨ solve 3 (λ x n i → x :* n :+ (con 1 :+ x :+ i) :* n
:= (con 1 :+ con 2 :* x :+ i) :* n)
refl x n i ⟩
(1 + 2 * x + i) * n ∎
where y = 1 + x + i
lem₄ : ∀ d y {k i} n →
d + y * k ≡ (1 + y + i) * n →
d + y * (n + k) ≡ (1 + 2 * y + i) * n
lem₄ d y {k} {i} n eq = begin
d + y * (n + k) ≡⟨ distrib-comm₂ d y k n ⟩
d + y * k + y * n ≡⟨ cong₂ _+_ eq refl ⟩
(1 + y + i) * n + y * n ≡⟨ solve 3 (λ y i n → (con 1 :+ y :+ i) :* n :+ y :* n
:= (con 1 :+ con 2 :* y :+ i) :* n)
refl y i n ⟩
(1 + 2 * y + i) * n ∎
lem₅ : ∀ d x {n k} →
d + x * n ≡ x * k →
d + 2 * x * n ≡ x * (n + k)
lem₅ d x {n} {k} eq = begin
d + 2 * x * n ≡⟨ solve 3 (λ d x n → d :+ con 2 :* x :* n
:= d :+ x :* n :+ x :* n)
refl d x n ⟩
d + x * n + x * n ≡⟨ cong₂ _+_ eq refl ⟩
x * k + x * n ≡⟨ distrib-comm x k n ⟩
x * (n + k) ∎
lem₆ : ∀ d x {n i k} →
d + x * n ≡ (1 + x + i) * k →
d + (1 + 2 * x + i) * n ≡ (1 + x + i) * (n + k)
lem₆ d x {n} {i} {k} eq = begin
d + (1 + 2 * x + i) * n ≡⟨ solve 4 (λ d x i n → d :+ (con 1 :+ con 2 :* x :+ i) :* n
:= d :+ x :* n :+ (con 1 :+ x :+ i) :* n)
refl d x i n ⟩
d + x * n + y * n ≡⟨ cong₂ _+_ eq refl ⟩
y * k + y * n ≡⟨ distrib-comm y k n ⟩
y * (n + k) ∎
where y = 1 + x + i
lem₇ : ∀ d y {i} n {k} →
d + (1 + y + i) * n ≡ y * k →
d + (1 + 2 * y + i) * n ≡ y * (n + k)
lem₇ d y {i} n {k} eq = begin
d + (1 + 2 * y + i) * n ≡⟨ solve 4 (λ d y i n → d :+ (con 1 :+ con 2 :* y :+ i) :* n
:= d :+ (con 1 :+ y :+ i) :* n :+ y :* n)
refl d y i n ⟩
d + (1 + y + i) * n + y * n ≡⟨ cong₂ _+_ eq refl ⟩
y * k + y * n ≡⟨ distrib-comm y k n ⟩
y * (n + k) ∎
lem₈ : ∀ {i j k q} x y →
1 + y * j ≡ x * i → j * k ≡ q * i →
k ≡ (x * k ∸ y * q) * i
lem₈ {i} {j} {k} {q} x y eq eq′ =
sym (lem₀ (x * k) (y * q) i k lemma)
where
lemma = begin
x * k * i ≡⟨ solve 3 (λ x k i → x :* k :* i
:= x :* i :* k)
refl x k i ⟩
x * i * k ≡⟨ cong (_* k) (sym eq) ⟩
(1 + y * j) * k ≡⟨ solve 3 (λ y j k → (con 1 :+ y :* j) :* k
:= y :* (j :* k) :+ k)
refl y j k ⟩
y * (j * k) + k ≡⟨ cong (λ n → y * n + k) eq′ ⟩
y * (q * i) + k ≡⟨ solve 4 (λ y q i k → y :* (q :* i) :+ k
:= y :* q :* i :+ k)
refl y q i k ⟩
y * q * i + k ∎
lem₉ : ∀ {i j k q} x y →
1 + x * i ≡ y * j → j * k ≡ q * i →
k ≡ (y * q ∸ x * k) * i
lem₉ {i} {j} {k} {q} x y eq eq′ =
sym (lem₀ (y * q) (x * k) i k lemma)
where
lem = solve 3 (λ a b c → a :* b :* c := b :* c :* a) refl
lemma = begin
y * q * i ≡⟨ lem y q i ⟩
q * i * y ≡⟨ cong (λ n → n * y) (sym eq′) ⟩
j * k * y ≡⟨ sym (lem y j k) ⟩
y * j * k ≡⟨ cong (λ n → n * k) (sym eq) ⟩
(1 + x * i) * k ≡⟨ solve 3 (λ x i k → (con 1 :+ x :* i) :* k
:= x :* k :* i :+ k)
refl x i k ⟩
x * k * i + k ∎
lem₁₀ : ∀ {a′} b c {d} e f → let a = suc a′ in
a + b * (c * d * a) ≡ e * (f * d * a) →
d ≡ 1
lem₁₀ {a′} b c {d} e f eq =
m*n≡1⇒n≡1 (e * f ∸ b * c) d
(lem₀ (e * f) (b * c) d 1
(*-cancelʳ-≡ (e * f * d) (b * c * d + 1) (begin
e * f * d * a ≡⟨ solve 4 (λ e f d a → e :* f :* d :* a
:= e :* (f :* d :* a))
refl e f d a ⟩
e * (f * d * a) ≡⟨ sym eq ⟩
a + b * (c * d * a) ≡⟨ solve 4 (λ a b c d → a :+ b :* (c :* d :* a)
:= (b :* c :* d :+ con 1) :* a)
refl a b c d ⟩
(b * c * d + 1) * a ∎)))
where a = suc a′
lem₁₁ : ∀ {i j m n k d} x y →
1 + y * j ≡ x * i → i * k ≡ m * d → j * k ≡ n * d →
k ≡ (x * m ∸ y * n) * d
lem₁₁ {i} {j} {m} {n} {k} {d} x y eq eq₁ eq₂ =
sym (lem₀ (x * m) (y * n) d k (begin
x * m * d ≡⟨ *-assoc x m d ⟩
x * (m * d) ≡⟨ cong (x *_) (sym eq₁) ⟩
x * (i * k) ≡⟨ sym (*-assoc x i k) ⟩
x * i * k ≡⟨ cong₂ _*_ (sym eq) refl ⟩
(1 + y * j) * k ≡⟨ solve 3 (λ y j k → (con 1 :+ y :* j) :* k
:= y :* (j :* k) :+ k)
refl y j k ⟩
y * (j * k) + k ≡⟨ cong (λ p → y * p + k) eq₂ ⟩
y * (n * d) + k ≡⟨ cong₂ _+_ (sym $ *-assoc y n d) refl ⟩
y * n * d + k ∎))
| 39.597765
| 93
| 0.296699
|
39e851d58e1a39196dc9b9b5fc49244dccc82910
| 14,652
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Ideal.agda
|
antoinevanmuylder/cubical
|
5b40df813434aa11631ac240409ca2c4d849453c
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Ideal.agda
|
antoinevanmuylder/cubical
|
5b40df813434aa11631ac240409ca2c4d849453c
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Ideal.agda
|
antoinevanmuylder/cubical
|
5b40df813434aa11631ac240409ca2c4d849453c
|
[
"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
--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.534954
| 100
| 0.458913
|
0b9732b5c3c78cdf5b13bb5ff4b9bebd7a989e4d
| 150
|
agda
|
Agda
|
test/Fail/Issue278.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/fail/Issue278.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue278.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module Issue278 where
abstract
module A where
Foo : Set₁
Foo = Set
module B where
open A
Foo≡Set : Foo ≡ Set
Foo≡Set = refl
| 12.5
| 23
| 0.606667
|
127ba4fc7736066f4b1a1911313312d610e0a9fe
| 669
|
agda
|
Agda
|
test/Fail/Issue1963DisplayWithPostfixCopattern.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1963DisplayWithPostfixCopattern.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1963DisplayWithPostfixCopattern.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS -v tc.with.display:30 #-}
-- {-# OPTIONS -v tc.with.strip:30 #-}
open import Common.Product
open import Common.Prelude
open import Common.Equality
postulate
p : Nat → Nat
-- g : Nat → Nat × Nat
-- g x .proj₁ with p x
-- g x .proj₁ | 0 = 1
-- g x .proj₁ | suc y = 0
-- g x .proj₂ = suc x
-- h : Nat → Nat × Nat
-- h x .proj₁ with p x
-- h x .proj₁ | 0 = 1
-- proj₁ (h x) | suc y = 0
-- h x .proj₂ = suc x
f : Nat → Nat × Nat
f x .proj₁ with p x
... | 0 = 1
... | suc y = 0
f x .proj₂ = suc x
test : f 0 ≡ (0 , 1)
test = refl
-- EXPECTED ERROR:
-- f 0 .proj₁ | p 0 != zero of type Nat
-- when checking that the expression refl has type f 0 ≡ (0 , 1)
| 19.114286
| 64
| 0.562033
|
dc662c1ac226a01ddbce3dec2373b4e61ac23e90
| 763
|
agda
|
Agda
|
Path/Reasoning.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Path/Reasoning.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Path/Reasoning.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 1
|
2021-11-11T12:30:21.000Z
|
2021-11-11T12:30:21.000Z
|
{-# OPTIONS --cubical --safe #-}
module Path.Reasoning where
open import Prelude
infixr 2 ≡˘⟨⟩-syntax _≡⟨⟩_ ≡⟨∙⟩-syntax ≡⟨∙⟩[∙]-syntax
≡˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≡ z → y ≡ x → x ≡ z
≡˘⟨⟩-syntax _ y≡z y≡x = sym y≡x ; y≡z
syntax ≡˘⟨⟩-syntax x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z
≡⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≡ z → x ≡ y → x ≡ z
≡⟨∙⟩-syntax _ y≡z x≡y = x≡y ; y≡z
syntax ≡⟨∙⟩-syntax x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
_≡⟨⟩_ : ∀ (x : A) {y} → x ≡ y → x ≡ y
_ ≡⟨⟩ x≡y = x≡y
infix 2.5 _∎
_∎ : ∀ {A : Type a} (x : A) → x ≡ x
_∎ x = refl
≡⟨∙⟩[∙]-syntax : ∀ (x : A) {x′ y′ : B} {y z} → y ≡ z → x′ ≡ y′ → (x′ ≡ y′ → x ≡ y) → x ≡ z
≡⟨∙⟩[∙]-syntax _ y≡z x′≡y′ x′≡y′⇒x≡y = x′≡y′⇒x≡y x′≡y′ ; y≡z
syntax ≡⟨∙⟩[∙]-syntax x y≡z x′≡y′ x′≡y′⇒x≡y = x ≡⟨ x′≡y′⇒x≡y ⟩[ x′≡y′ ] y≡z
| 24.612903
| 90
| 0.406291
|
a13a145722c500eacf2916b2867ecd89004cff0b
| 3,436
|
agda
|
Agda
|
Cubical/Structures/Maybe.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/Structures/Maybe.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/Structures/Maybe.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-
Maybe structure: X ↦ Maybe (S X)
-}
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Structures.Maybe where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.SIP
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Unit
open import Cubical.Data.Empty
open import Cubical.Data.Maybe
private
variable
ℓ ℓ₁ ℓ₁' : Level
MaybeRel : {A B : Type ℓ} (R : A → B → Type ℓ₁) → Maybe A → Maybe B → Type ℓ₁
MaybeRel R nothing nothing = Lift Unit
MaybeRel R nothing (just _) = Lift ⊥
MaybeRel R (just _) nothing = Lift ⊥
MaybeRel R (just x) (just y) = R x y
congMaybeRel : {A B : Type ℓ} {R : A → B → Type ℓ₁} {S : A → B → Type ℓ₁'}
→ (∀ x y → R x y ≃ S x y)
→ ∀ ox oy → MaybeRel R ox oy ≃ MaybeRel S ox oy
congMaybeRel e nothing nothing = Lift≃Lift (idEquiv _)
congMaybeRel e nothing (just _) = Lift≃Lift (idEquiv _)
congMaybeRel e (just _) nothing = Lift≃Lift (idEquiv _)
congMaybeRel e (just x) (just y) = e x y
module MaybePathP where
Code : (A : I → Type ℓ) → Maybe (A i0) → Maybe (A i1) → Type ℓ
Code A = MaybeRel (PathP A)
encodeRefl : {A : Type ℓ} → ∀ ox → Code (λ _ → A) ox ox
encodeRefl nothing = lift tt
encodeRefl (just _) = refl
encode : (A : I → Type ℓ) → ∀ ox oy → PathP (λ i → Maybe (A i)) ox oy → Code A ox oy
encode A ox oy p = transport (λ j → Code (λ i → A (i ∧ j)) ox (p j)) (encodeRefl ox)
decode : {A : I → Type ℓ} → ∀ ox oy → Code A ox oy → PathP (λ i → Maybe (A i)) ox oy
decode nothing nothing p i = nothing
decode (just _) (just _) p i = just (p i)
decodeEncodeRefl : {A : Type ℓ} (ox : Maybe A) → decode ox ox (encodeRefl ox) ≡ refl
decodeEncodeRefl nothing = refl
decodeEncodeRefl (just _) = refl
decodeEncode : {A : I → Type ℓ} → ∀ ox oy p → decode ox oy (encode A ox oy p) ≡ p
decodeEncode {A = A} ox oy p =
transport
(λ k →
decode _ _ (transp (λ j → Code (λ i → A (i ∧ j ∧ k)) ox (p (j ∧ k))) (~ k) (encodeRefl ox))
≡ (λ i → p (i ∧ k)))
(decodeEncodeRefl ox)
encodeDecode : (A : I → Type ℓ) → ∀ ox oy c → encode A ox oy (decode ox oy c) ≡ c
encodeDecode A nothing nothing c = refl
encodeDecode A (just x) (just y) c =
transport
(λ k →
encode (λ i → A (i ∧ k)) _ _ (decode (just x) (just (c k)) (λ i → c (i ∧ k)))
≡ (λ i → c (i ∧ k)))
(transportRefl _)
Code≃PathP : {A : I → Type ℓ} → ∀ ox oy → Code A ox oy ≃ PathP (λ i → Maybe (A i)) ox oy
Code≃PathP {A = A} ox oy = isoToEquiv isom
where
isom : Iso _ _
isom .Iso.fun = decode ox oy
isom .Iso.inv = encode _ ox oy
isom .Iso.rightInv = decodeEncode ox oy
isom .Iso.leftInv = encodeDecode A ox oy
-- Structured isomorphisms
MaybeStructure : (S : Type ℓ → Type ℓ₁) → Type ℓ → Type ℓ₁
MaybeStructure S X = Maybe (S X)
MaybeEquivStr : {S : Type ℓ → Type ℓ₁}
→ StrEquiv S ℓ₁' → StrEquiv (MaybeStructure S) ℓ₁'
MaybeEquivStr ι (X , ox) (Y , oy) e = MaybeRel (λ x y → ι (X , x) (Y , y) e) ox oy
maybeUnivalentStr : {S : Type ℓ → Type ℓ₁} (ι : StrEquiv S ℓ₁')
→ UnivalentStr S ι → UnivalentStr (MaybeStructure S) (MaybeEquivStr ι)
maybeUnivalentStr ι θ {X , ox} {Y , oy} e =
compEquiv
(congMaybeRel (λ x y → θ {X , x} {Y , y} e) ox oy)
(MaybePathP.Code≃PathP ox oy)
| 34.36
| 99
| 0.618743
|
a1d8a0834c1c9b8df1e0d7b9660a44fb75d1f0ce
| 1,074
|
agda
|
Agda
|
test/Succeed/UnquoteDecl.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/UnquoteDecl.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/UnquoteDecl.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
module UnquoteDecl where
open import Common.Prelude
open import Common.Reflection
open import Common.Equality
infixr 3 _`⇒_
pattern _`⇒_ a b = pi (vArg a) (abs "_" b)
pattern `Nat = def (quote Nat) []
unquoteDecl x =
define (vArg x) (funDef `Nat (clause [] (quoteTerm 15) ∷ []))
y = x + 4
-- unquoteDecl loop = define loop (funDef `Nat (clause [] (def (quote loop) []) ∷ []))
pattern `zero = con (quote zero) []
pattern `suc n = con (quote suc) (vArg n ∷ [])
-- Note that in the body of the unquote, 'plus' really means 'quote plus'.
unquoteDecl plus =
define (vArg plus) (
funDef (`Nat `⇒ `Nat `⇒ `Nat)
( clause (vArg (con (quote zero) []) ∷ vArg (var "y") ∷ []) (var 0 [])
∷ clause (vArg (con (quote suc) (vArg (var "x") ∷ [])) ∷ vArg (var "y") ∷ [])
(`suc (def plus (vArg (var 1 []) ∷ vArg (var 0 []) ∷ [])))
∷ []))
prf : plus 1 1 ≡ 2
prf = refl
magicDef : FunDef
magicDef =
funDef (def (quote ⊥) [] `⇒ `Nat)
(absurdClause (vArg absurd ∷ []) ∷ [])
unquoteDecl magic = define (vArg magic) magicDef
| 26.85
| 86
| 0.570764
|
cb73f68544d248bf985f88687cf4cd5684272c6d
| 426
|
agda
|
Agda
|
Cubical/HITs/Bouquet/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/HITs/Bouquet/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Bouquet/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Definition of the Bouquet of circles of a type aka wedge of A circles
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.Bouquet.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
private
variable
ℓ : Level
data Bouquet (A : Type ℓ) : Type ℓ where
base : Bouquet A
loop : A → base ≡ base
Bouquet∙ : Type ℓ → Pointed ℓ
Bouquet∙ A = Bouquet A , base
| 17.04
| 71
| 0.701878
|
391a33f09618a9e542db5384f8a243f4a98933e8
| 14,573
|
agda
|
Agda
|
Everything.agda
|
bolt12/agda-categories
|
b813fa3e685eb4713bace6204b8084a343d549a3
|
[
"MIT"
] | null | null | null |
Everything.agda
|
bolt12/agda-categories
|
b813fa3e685eb4713bace6204b8084a343d549a3
|
[
"MIT"
] | null | null | null |
Everything.agda
|
bolt12/agda-categories
|
b813fa3e685eb4713bace6204b8084a343d549a3
|
[
"MIT"
] | null | null | null |
import Categories.2-Category
import Categories.2-Functor
import Categories.Adjoint
import Categories.Adjoint.AFT
import Categories.Adjoint.AFT.SolutionSet
import Categories.Adjoint.Alternatives
import Categories.Adjoint.Compose
import Categories.Adjoint.Construction.EilenbergMoore
import Categories.Adjoint.Construction.Kleisli
import Categories.Adjoint.Equivalence
import Categories.Adjoint.Equivalence.Properties
import Categories.Adjoint.Equivalents
import Categories.Adjoint.Instance.0-Truncation
import Categories.Adjoint.Instance.01-Truncation
import Categories.Adjoint.Instance.Core
import Categories.Adjoint.Instance.Discrete
import Categories.Adjoint.Instance.PosetCore
import Categories.Adjoint.Instance.StrictCore
import Categories.Adjoint.Mate
import Categories.Adjoint.Properties
import Categories.Adjoint.RAPL
import Categories.Adjoint.Relative
import Categories.Adjoint.TwoSided
import Categories.Adjoint.TwoSided.Compose
import Categories.Bicategory
import Categories.Bicategory.Bigroupoid
import Categories.Bicategory.Construction.1-Category
import Categories.Bicategory.Extras
import Categories.Bicategory.Instance.Cats
import Categories.Bicategory.Instance.EnrichedCats
import Categories.Bicategory.Opposite
import Categories.Category
import Categories.Category.BicartesianClosed
import Categories.Category.CMonoidEnriched
import Categories.Category.Cartesian
import Categories.Category.Cartesian.Properties
import Categories.Category.Cartesian.Structure
import Categories.Category.CartesianClosed
import Categories.Category.CartesianClosed.Canonical
import Categories.Category.CartesianClosed.Locally
import Categories.Category.CartesianClosed.Locally.Properties
import Categories.Category.CartesianClosed.Properties
import Categories.Category.Closed
import Categories.Category.Cocartesian
import Categories.Category.Cocomplete
import Categories.Category.Cocomplete.Finitely
import Categories.Category.Cocomplete.Finitely.Properties
import Categories.Category.Cocomplete.Properties
import Categories.Category.Complete
import Categories.Category.Complete.Finitely
import Categories.Category.Complete.Finitely.Properties
import Categories.Category.Complete.Properties
import Categories.Category.Complete.Properties.Construction
import Categories.Category.Complete.Properties.SolutionSet
import Categories.Category.Concrete
import Categories.Category.Concrete.Properties
import Categories.Category.Construction.0-Groupoid
import Categories.Category.Construction.Adjoints
import Categories.Category.Construction.Arrow
import Categories.Category.Construction.Cocones
import Categories.Category.Construction.Comma
import Categories.Category.Construction.Cones
import Categories.Category.Construction.Coproduct
import Categories.Category.Construction.Core
import Categories.Category.Construction.EilenbergMoore
import Categories.Category.Construction.Elements
import Categories.Category.Construction.EnrichedFunctors
import Categories.Category.Construction.F-Algebras
import Categories.Category.Construction.Fin
import Categories.Category.Construction.Functors
import Categories.Category.Construction.Graphs
import Categories.Category.Construction.Grothendieck
import Categories.Category.Construction.GroupAsCategory
import Categories.Category.Construction.Kleisli
import Categories.Category.Construction.MonoidAsCategory
import Categories.Category.Construction.Monoids
import Categories.Category.Construction.ObjectRestriction
import Categories.Category.Construction.Path
import Categories.Category.Construction.Presheaves
import Categories.Category.Construction.Properties.Comma
import Categories.Category.Construction.Properties.EilenbergMoore
import Categories.Category.Construction.Properties.Functors
import Categories.Category.Construction.Properties.Kleisli
import Categories.Category.Construction.Properties.Presheaves
import Categories.Category.Construction.Properties.Presheaves.Cartesian
import Categories.Category.Construction.Properties.Presheaves.CartesianClosed
import Categories.Category.Construction.Properties.Presheaves.Complete
import Categories.Category.Construction.Properties.Presheaves.FromCartesianCCC
import Categories.Category.Construction.Pullbacks
import Categories.Category.Construction.Thin
import Categories.Category.Core
import Categories.Category.Dagger
import Categories.Category.Dagger.Construction.Discrete
import Categories.Category.Dagger.Instance.Rels
import Categories.Category.Discrete
import Categories.Category.Duality
import Categories.Category.Equivalence
import Categories.Category.Equivalence.Properties
import Categories.Category.Finite
import Categories.Category.Finite.Fin
import Categories.Category.Finite.Fin.Construction.Discrete
import Categories.Category.Finite.Fin.Construction.Poset
import Categories.Category.Finite.Fin.Instance.Parallel
import Categories.Category.Finite.Fin.Instance.Span
import Categories.Category.Finite.Fin.Instance.Triangle
import Categories.Category.Groupoid
import Categories.Category.Groupoid.Properties
import Categories.Category.Helper
import Categories.Category.Indiscrete
import Categories.Category.Instance.Cartesians
import Categories.Category.Instance.Cats
import Categories.Category.Instance.EmptySet
import Categories.Category.Instance.FamilyOfSetoids
import Categories.Category.Instance.FamilyOfSets
import Categories.Category.Instance.FinCatShapes
import Categories.Category.Instance.FinSetoids
import Categories.Category.Instance.Globe
import Categories.Category.Instance.Groupoids
import Categories.Category.Instance.LawvereTheories
import Categories.Category.Instance.Monoidals
import Categories.Category.Instance.One
import Categories.Category.Instance.PointedSets
import Categories.Category.Instance.Posets
import Categories.Category.Instance.Properties.Cats
import Categories.Category.Instance.Properties.Posets
import Categories.Category.Instance.Properties.Setoids
import Categories.Category.Instance.Properties.Setoids.CCC
import Categories.Category.Instance.Properties.Setoids.Cocomplete
import Categories.Category.Instance.Properties.Setoids.Complete
import Categories.Category.Instance.Properties.Setoids.LCCC
import Categories.Category.Instance.Rels
import Categories.Category.Instance.Setoids
import Categories.Category.Instance.Sets
import Categories.Category.Instance.Simplex
import Categories.Category.Instance.SimplicialSet
import Categories.Category.Instance.SingletonSet
import Categories.Category.Instance.Span
import Categories.Category.Instance.StrictCats
import Categories.Category.Instance.StrictGroupoids
import Categories.Category.Instance.Zero
import Categories.Category.Inverse
import Categories.Category.Lift
import Categories.Category.Monoidal
import Categories.Category.Monoidal.Braided
import Categories.Category.Monoidal.Braided.Properties
import Categories.Category.Monoidal.Closed
import Categories.Category.Monoidal.Closed.IsClosed
import Categories.Category.Monoidal.Closed.IsClosed.Diagonal
import Categories.Category.Monoidal.Closed.IsClosed.Dinatural
import Categories.Category.Monoidal.Closed.IsClosed.Identity
import Categories.Category.Monoidal.Closed.IsClosed.L
import Categories.Category.Monoidal.Closed.IsClosed.Pentagon
import Categories.Category.Monoidal.CompactClosed
import Categories.Category.Monoidal.Construction.Minus2
import Categories.Category.Monoidal.Core
import Categories.Category.Monoidal.Instance.Cats
import Categories.Category.Monoidal.Instance.One
import Categories.Category.Monoidal.Instance.Setoids
import Categories.Category.Monoidal.Instance.Sets
import Categories.Category.Monoidal.Instance.StrictCats
import Categories.Category.Monoidal.Properties
import Categories.Category.Monoidal.Reasoning
import Categories.Category.Monoidal.Rigid
import Categories.Category.Monoidal.Star-Autonomous
import Categories.Category.Monoidal.Structure
import Categories.Category.Monoidal.Symmetric
import Categories.Category.Monoidal.Traced
import Categories.Category.Monoidal.Utilities
import Categories.Category.Product
import Categories.Category.Product.Properties
import Categories.Category.RigCategory
import Categories.Category.SetoidDiscrete
import Categories.Category.Site
import Categories.Category.Slice
import Categories.Category.Slice.Properties
import Categories.Category.Species
import Categories.Category.Species.Constructions
import Categories.Category.SubCategory
import Categories.Category.Topos
import Categories.Category.WithFamilies
import Categories.CoYoneda
import Categories.Comonad
import Categories.Comonad.Relative
import Categories.Diagram.Cocone
import Categories.Diagram.Cocone.Properties
import Categories.Diagram.Coend
import Categories.Diagram.Coequalizer
import Categories.Diagram.Coequalizer.Properties
import Categories.Diagram.Colimit
import Categories.Diagram.Colimit.DualProperties
import Categories.Diagram.Colimit.Lan
import Categories.Diagram.Colimit.Properties
import Categories.Diagram.Cone
import Categories.Diagram.Cone.Properties
import Categories.Diagram.Duality
import Categories.Diagram.End
import Categories.Diagram.End.Properties
import Categories.Diagram.Equalizer
import Categories.Diagram.Equalizer.Indexed
import Categories.Diagram.Equalizer.Limit
import Categories.Diagram.Equalizer.Properties
import Categories.Diagram.Finite
import Categories.Diagram.Limit
import Categories.Diagram.Limit.Properties
import Categories.Diagram.Limit.Ran
import Categories.Diagram.Pullback
import Categories.Diagram.Pullback.Limit
import Categories.Diagram.Pullback.Properties
import Categories.Diagram.Pushout
import Categories.Diagram.Pushout.Properties
import Categories.Diagram.SubobjectClassifier
import Categories.Enriched.Category
import Categories.Enriched.Category.Opposite
import Categories.Enriched.Category.Underlying
import Categories.Enriched.Functor
import Categories.Enriched.NaturalTransformation
import Categories.Enriched.NaturalTransformation.NaturalIsomorphism
import Categories.Enriched.Over.One
import Categories.Enriched.Over.Setoids
import Categories.Functor
import Categories.Functor.Algebra
import Categories.Functor.Bifunctor
import Categories.Functor.Bifunctor.Properties
import Categories.Functor.Cartesian
import Categories.Functor.Cartesian.Properties
import Categories.Functor.Coalgebra
import Categories.Functor.Construction.Constant
import Categories.Functor.Construction.Diagonal
import Categories.Functor.Construction.FromDiscrete
import Categories.Functor.Construction.LiftSetoids
import Categories.Functor.Construction.Limit
import Categories.Functor.Construction.ObjectRestriction
import Categories.Functor.Construction.SubCategory
import Categories.Functor.Construction.SubCategory.Properties
import Categories.Functor.Construction.Zero
import Categories.Functor.Core
import Categories.Functor.Duality
import Categories.Functor.Equivalence
import Categories.Functor.Fibration
import Categories.Functor.Groupoid
import Categories.Functor.Hom
import Categories.Functor.Hom.Properties
import Categories.Functor.Hom.Properties.Contra
import Categories.Functor.Hom.Properties.Covariant
import Categories.Functor.Instance.0-Truncation
import Categories.Functor.Instance.01-Truncation
import Categories.Functor.Instance.Core
import Categories.Functor.Instance.Discrete
import Categories.Functor.Instance.SetoidDiscrete
import Categories.Functor.Instance.StrictCore
import Categories.Functor.Limits
import Categories.Functor.Monoidal
import Categories.Functor.Monoidal.Properties
import Categories.Functor.Monoidal.Symmetric
import Categories.Functor.Power
import Categories.Functor.Power.Functorial
import Categories.Functor.Power.NaturalTransformation
import Categories.Functor.Presheaf
import Categories.Functor.Profunctor
import Categories.Functor.Properties
import Categories.Functor.Representable
import Categories.Functor.Slice
import Categories.GlobularSet
import Categories.Kan
import Categories.Kan.Duality
import Categories.Minus2-Category
import Categories.Minus2-Category.Construction.Indiscrete
import Categories.Minus2-Category.Instance.One
import Categories.Minus2-Category.Properties
import Categories.Monad
import Categories.Monad.Duality
import Categories.Monad.Idempotent
import Categories.Monad.Relative
import Categories.Monad.Strong
import Categories.Morphism
import Categories.Morphism.Cartesian
import Categories.Morphism.Duality
import Categories.Morphism.HeterogeneousIdentity
import Categories.Morphism.HeterogeneousIdentity.Properties
import Categories.Morphism.IsoEquiv
import Categories.Morphism.Isomorphism
import Categories.Morphism.Notation
import Categories.Morphism.Properties
import Categories.Morphism.Reasoning
import Categories.Morphism.Reasoning.Core
import Categories.Morphism.Reasoning.Iso
import Categories.Morphism.Universal
import Categories.Multi.Category.Indexed
import Categories.NaturalTransformation
import Categories.NaturalTransformation.Core
import Categories.NaturalTransformation.Dinatural
import Categories.NaturalTransformation.Equivalence
import Categories.NaturalTransformation.Hom
import Categories.NaturalTransformation.Monoidal
import Categories.NaturalTransformation.NaturalIsomorphism
import Categories.NaturalTransformation.NaturalIsomorphism.Equivalence
import Categories.NaturalTransformation.NaturalIsomorphism.Functors
import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal
import Categories.NaturalTransformation.NaturalIsomorphism.Properties
import Categories.NaturalTransformation.Properties
import Categories.Object.Coproduct
import Categories.Object.Duality
import Categories.Object.Exponential
import Categories.Object.Initial
import Categories.Object.Monoid
import Categories.Object.NaturalNumber
import Categories.Object.NaturalNumber.Properties.F-Algebras
import Categories.Object.Product
import Categories.Object.Product.Construction
import Categories.Object.Product.Core
import Categories.Object.Product.Indexed
import Categories.Object.Product.Indexed.Properties
import Categories.Object.Product.Limit
import Categories.Object.Product.Morphisms
import Categories.Object.Subobject
import Categories.Object.Subobject.Properties
import Categories.Object.Terminal
import Categories.Object.Terminal.Limit
import Categories.Object.Zero
import Categories.Pseudofunctor
import Categories.Pseudofunctor.Composition
import Categories.Pseudofunctor.Hom
import Categories.Pseudofunctor.Identity
import Categories.Pseudofunctor.Instance.EnrichedUnderlying
import Categories.Theory.Lawvere
import Categories.Utils.EqReasoning
import Categories.Utils.Product
import Categories.Yoneda
import Categories.Yoneda.Continuous
import Categories.Yoneda.Properties
| 44.02719
| 78
| 0.891649
|
d02d565eb3b9234b9d7c63193db7e3c809d6627a
| 6,416
|
agda
|
Agda
|
TotalParserCombinators/Parser.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
TotalParserCombinators/Parser.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
TotalParserCombinators/Parser.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The parser type
------------------------------------------------------------------------
module TotalParserCombinators.Parser where
open import Algebra
open import Category.Monad
open import Coinduction
open import Data.List
open import Data.Maybe using (Maybe; nothing; just)
open import Data.List.Any.Membership.Propositional
open import Data.List.Categorical as ListMonad
using () renaming (module MonadProperties to ListMonadProp)
open import Data.Product using (proj₂)
open import Function
open import Level
open import Relation.Binary.PropositionalEquality
open RawMonadPlus {f = zero} ListMonad.monadPlus
using ()
renaming ( return to return′
; ∅ to fail′
; _∣_ to _∣′_
; _⊛_ to _⊛′_
; _>>=_ to _>>=′_
)
------------------------------------------------------------------------
-- Helper functions
-- Flattening for potential lists.
flatten : {A : Set} → Maybe (List A) → List A
flatten nothing = []
flatten (just xs) = xs
-- fs ⊛flatten mxs is a variant of fs ⊛′ flatten mxs, with the
-- property that fs ⊛flatten nothing evaluates to [].
_⊛flatten_ : {A B : Set} → List (A → B) → Maybe (List A) → List B
fs ⊛flatten nothing = []
fs ⊛flatten just xs = fs ⊛′ xs
-- Applies the function to the value, returning the empty list if
-- there is no function.
apply : {A B : Set} → Maybe (A → List B) → A → List B
apply nothing x = []
apply (just f) x = f x
-- bind mxs mf is a variant of flatten mxs >>=′ apply mf, with the
-- property that bind mxs nothing evaluates to [].
bind : {A B : Set} → Maybe (List A) → Maybe (A → List B) → List B
bind mxs nothing = []
bind mxs (just f) = flatten mxs >>=′ f
-- Verification of some claims made above.
module Claims where
⊛flatten-⊛-flatten : ∀ {A B : Set} (fs : List (A → B)) mxs →
fs ⊛flatten mxs ≡ (fs ⊛′ flatten mxs)
⊛flatten-⊛-flatten fs nothing = sym $ ListMonadProp.right-zero fs
⊛flatten-⊛-flatten fs (just xs) = refl
⊛flatten-nothing : {A B : Set} (fs : List (A → B)) →
fs ⊛flatten nothing ≡ []
⊛flatten-nothing fs = refl
bind-flatten->>=-apply : ∀ {A B : Set} mxs (mf : Maybe (A → List B)) →
bind mxs mf ≡ (flatten mxs >>=′ apply mf)
bind-flatten->>=-apply mxs (just f) = refl
bind-flatten->>=-apply mxs nothing =
sym $ ListMonadProp.right-zero (flatten mxs)
bind-nothing : {A B : Set} (mxs : Maybe (List A)) →
bind mxs nothing ≡ [] {A = B}
bind-nothing mxs = refl
------------------------------------------------------------------------
-- Parsers
infixl 50 _⊛_ _<$>_ _⊛flatten_
infixl 10 _>>=_
infixl 5 _∣_
-- The list index is the "initial bag"; it contains the results which
-- can be emitted without consuming any input. For
-- p : Parser Tok R xs
-- we have
-- x ∈ xs iff x ∈ p · []
-- (see TotalParserCombinators.InitialBag).
mutual
data Parser (Tok : Set) : (R : Set) → List R → Set₁ where
return : ∀ {R} (x : R) → Parser Tok R (return′ x)
fail : ∀ {R} → Parser Tok R fail′
token : Parser Tok Tok fail′
_∣_ : ∀ {R xs₁ xs₂}
(p₁ : Parser Tok R xs₁ )
(p₂ : Parser Tok R xs₂) →
Parser Tok R (xs₁ ∣′ xs₂)
_<$>_ : ∀ {R₁ R₂ xs}
(f : R₁ → R₂)
(p : Parser Tok R₁ xs) →
Parser Tok R₂ (map f xs)
_⊛_ : ∀ {R₁ R₂ fs xs}
(p₁ : ∞⟨ xs ⟩Parser Tok (R₁ → R₂) (flatten fs) )
(p₂ : ∞⟨ fs ⟩Parser Tok R₁ (flatten xs)) →
Parser Tok R₂ (flatten fs ⊛flatten xs)
_>>=_ : ∀ {R₁ R₂ xs} {f : Maybe (R₁ → List R₂)}
(p₁ : ∞⟨ f ⟩Parser Tok R₁ (flatten xs))
(p₂ : (x : R₁) → ∞⟨ xs ⟩Parser Tok R₂ (apply f x)) →
Parser Tok R₂ (bind xs f)
nonempty : ∀ {R xs} (p : Parser Tok R xs) → Parser Tok R []
cast : ∀ {R xs₁ xs₂} (xs₁≈xs₂ : xs₁ ∼[ bag ] xs₂)
(p : Parser Tok R xs₁) → Parser Tok R xs₂
∞⟨_⟩Parser : {A : Set} → Maybe A → Set → (R : Set) → List R → Set₁
∞⟨ nothing ⟩Parser Tok R₁ xs = ∞ (Parser Tok R₁ xs)
∞⟨ just _ ⟩Parser Tok R₁ xs = Parser Tok R₁ xs
-- Note that, with the definition above, a sequenced parser is
-- /allowed/ to be delayed if the "other" parser is not nullable, but
-- it does not have to be.
-- Note also that it would be safe to make the first argument of _>>=_
-- coinductive if apply f x ≡_[] for all x in xs. I suspect that this
-- criterion would be awkward to work with, though. Instead I only
-- allow the argument to be coinductive if f ≡ nothing.
-- Finally note that some of the combinators above are not included in
-- the paper "Total Parser Combinators".
------------------------------------------------------------------------
-- Examples
private
-- Note that these parsers can be both left and right recursive:
leftRight : ∀ {R Tok} → Parser Tok R _
leftRight {R} = ♯ (const <$> leftRight) ⊛ ♯ leftRight {R}
leftRight′ : ∀ {R Tok} → Parser Tok R _
leftRight′ {R} = ♯ leftRight′ {R} >>= λ _ → ♯ leftRight′
-- More examples, included to ensure that all implicit arguments are
-- inferred automatically.
p : {Tok R : Set} → Parser Tok R _
p = token >>= λ _ → ♯ p
p′ : {Tok : Set} → Parser Tok Tok _
p′ = ♯ p′ >>= λ _ → token
------------------------------------------------------------------------
-- Helper functions
-- Returns the initial bag.
initial-bag : ∀ {Tok R xs} → Parser Tok R xs → List R
initial-bag {xs = xs} _ = xs
-- Forces if necessary.
♭? : ∀ {Tok R₁ R₂} {m : Maybe R₂} {xs} →
∞⟨ m ⟩Parser Tok R₁ xs → Parser Tok R₁ xs
♭? {m = nothing} = ♭
♭? {m = just _} = id
-- Is the argument parser forced? If the result is just something,
-- then it is.
forced? : ∀ {Tok A R xs} {m : Maybe A} →
∞⟨ m ⟩Parser Tok R xs → Maybe A
forced? {m = m} _ = m
forced?′ : {Tok R₁ R₂ A : Set} {m : Maybe A} {f : R₁ → List R₂} →
((x : R₁) → ∞⟨ m ⟩Parser Tok R₂ (f x)) → Maybe A
forced?′ {m = m} _ = m
-- Short synonyms for just and nothing. ◌ stands for "delayed" (think
-- "not here") and ○ for "not delayed".
◌ : {R : Set} → Maybe R
◌ = nothing
○ : {R : Set} {x : R} → Maybe R
○ {x = x} = just x
| 33.072165
| 76
| 0.529925
|
1871cab6d693ae7f7be9db117b7d0e8abae540a8
| 13,410
|
agda
|
Agda
|
Numeral/Matrix/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Numeral/Matrix/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Numeral/Matrix/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Numeral.Matrix.Proofs where
import Lvl
open import Syntax.Number
open import Data
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.Boolean.Stmt.Proofs
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
import Functional as Fn
open import Function.Equals
open import Lang.Inspect
open import Logic.Predicate
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Numeral.Finite
open import Numeral.Finite.Bound
open import Numeral.Finite.Oper
open import Numeral.Finite.Oper.Comparisons
open import Numeral.Finite.Oper.Comparisons.Proofs
open import Numeral.Finite.Proofs
open import Numeral.Matrix as Matrix using (Matrix ; SquareMatrix)
open import Numeral.Natural
open import Numeral.CoordinateVector as Vector using (Vector)
import Numeral.CoordinateVector.Proofs as Vector
open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_ ; _≢_ to _≢ₑ_)
open import Relator.Equals.Proofs.Equivalence
open import Structure.Function
open import Structure.Operator.Group
open import Structure.Operator.Monoid
open import Structure.Operator.Properties
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Function
open import Syntax.Implication
open import Syntax.Transitivity
open import Type
private variable ℓ ℓₑ : Lvl.Level
private variable T A B : Type{ℓ}
module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
private variable s : ℕ ⨯ ℕ
private variable w h n : ℕ
private variable x y z : 𝕟(n)
private variable id id₁ id₂ zero elem 𝟎ₛ 𝟏ₛ : T
private variable f g inv : T → T
private variable _▫_ _▫₁_ _▫₂_ _+ₛ_ _⋅ₛ_ : T → T → T
private variable v v₁ v₂ : Vector(n)(T)
private variable M : Matrix(s)(T)
instance
matrix-equiv : Equiv(Matrix(s)(T))
Equiv._≡_ matrix-equiv (Matrix.mat proj₁) (Matrix.mat proj₂) = proj₁ ⊜ proj₂
Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence matrix-equiv)) = reflexivity(_⊜_)
Symmetry.proof (Equivalence.symmetry (Equiv.equivalence matrix-equiv)) = symmetry(_⊜_)
Transitivity.proof (Equivalence.transitivity (Equiv.equivalence matrix-equiv)) = transitivity(_⊜_)
instance
matrix-map₂-binaryOperator : ⦃ oper : BinaryOperator(_▫_) ⦄ → BinaryOperator(Matrix.map₂{s = s}(_▫_))
BinaryOperator.congruence (matrix-map₂-binaryOperator {_▫_ = _▫_} ⦃ oper ⦄) (intro p) (intro q) = intro (congruence₂(_▫_) ⦃ oper ⦄ p q)
instance
matrix-map₂-identityₗ : ⦃ ident : Identityₗ(_▫_)(id) ⦄ → Identityₗ(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
Identityₗ.proof (matrix-map₂-identityₗ {_▫_ = _▫_} {id = id}) = intro(identityₗ(_▫_)(id))
instance
matrix-map₂-identityᵣ : ⦃ ident : Identityᵣ(_▫_)(id) ⦄ → Identityᵣ(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
Identityᵣ.proof (matrix-map₂-identityᵣ {_▫_ = _▫_} {id = id}) = intro(identityᵣ(_▫_)(id))
instance
matrix-map₂-identity : ⦃ ident : Identity(_▫_)(id) ⦄ → Identity(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
matrix-map₂-identity = intro
instance
matrix-map₂-absorberₗ : ⦃ absorb : Absorberₗ(_▫_)(id) ⦄ → Absorberₗ(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
Absorberₗ.proof (matrix-map₂-absorberₗ {_▫_ = _▫_} {id = id}) = intro(absorberₗ(_▫_)(id))
instance
matrix-map₂-absorberᵣ : ⦃ absorb : Absorberᵣ(_▫_)(id) ⦄ → Absorberᵣ(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
Absorberᵣ.proof (matrix-map₂-absorberᵣ {_▫_ = _▫_} {id = id}) = intro(absorberᵣ(_▫_)(id))
instance
matrix-map₂-absorber : ⦃ absorb : Absorber(_▫_)(id) ⦄ → Absorber(Matrix.map₂{s = s}(_▫_)) (Matrix.fill(id))
matrix-map₂-absorber = intro
instance
matrix-map₂-commutativity : ⦃ comm : Commutativity(_▫_) ⦄ → Commutativity(Matrix.map₂{s = s}(_▫_))
Commutativity.proof (matrix-map₂-commutativity {_▫_ = _▫_}) = intro(commutativity(_▫_))
instance
matrix-map₂-associativity : ⦃ assoc : Associativity(_▫_) ⦄ → Associativity(Matrix.map₂{s = s}(_▫_))
Associativity.proof (matrix-map₂-associativity {_▫_ = _▫_}) = intro(associativity(_▫_))
instance
matrix-map₂-map-inverseFunctionₗ : ⦃ ident : Identityₗ(_▫_)(id) ⦄ ⦃ inver : InverseFunctionₗ(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunctionₗ(Matrix.map₂{s = s}(_▫_)) ⦃ [∃]-intro _ ⦄ (Matrix.map inv)
InverseFunctionₗ.proof (matrix-map₂-map-inverseFunctionₗ {_▫_ = _▫_} {inv = inv}) = intro (inverseFunctionₗ(_▫_) ⦃ [∃]-intro _ ⦄ (inv))
instance
matrix-map₂-map-inverseFunctionᵣ : ⦃ ident : Identityᵣ(_▫_)(id) ⦄ ⦃ inver : InverseFunctionᵣ(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunctionᵣ(Matrix.map₂{s = s}(_▫_)) ⦃ [∃]-intro _ ⦄ (Matrix.map inv)
InverseFunctionᵣ.proof (matrix-map₂-map-inverseFunctionᵣ {_▫_ = _▫_} {inv = inv}) = intro (inverseFunctionᵣ(_▫_) ⦃ [∃]-intro _ ⦄ (inv))
instance
matrix-map₂-map-inverseFunction : ⦃ ident : Identity(_▫_)(id) ⦄ ⦃ inver : InverseFunction(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunction(Matrix.map₂{s = s}(_▫_)) ⦃ [∃]-intro _ ⦄ (Matrix.map inv)
matrix-map₂-map-inverseFunction = intro
instance
matrix-map-function : ⦃ func : Function(f) ⦄ → Function(Matrix.map{s = s} (f))
Function.congruence matrix-map-function (intro p) = intro(congruence₁ _ p)
instance
matrix-map₂-monoid : ⦃ monoid : Monoid(_▫_) ⦄ → Monoid(Matrix.map₂{s = s}(_▫_))
Monoid.identity-existence matrix-map₂-monoid = [∃]-intro(Matrix.fill(_))
instance
matrix-map₂-group : ⦃ group : Group(_▫_) ⦄ → Group(Matrix.map₂{s = s}(_▫_))
Group.monoid matrix-map₂-group = matrix-map₂-monoid
Group.inverse-existence matrix-map₂-group = [∃]-intro _
diagMat-element-zero : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ zero) ↔ ((x ≢ₑ y) ∨ (Vector.proj v(x) ≡ zero))
diagMat-element-zero {zero = zero}{𝐒 n}{v = v}{x = x}{y = y} =
[↔]-intro ([↔]-to-[←] [→ₗ][∨][∧]-preserving ([∧]-intro l₁ l₂)) r ⦗ [↔]-transitivity ⦘ᵣ
[∨]-mapₗ-[↔] ([↔]-transitivity false-true-opposites ([↔]-symmetry([¬]-unaryOperator [≡][≡?]-equivalence)))
where
l₁ : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ zero) ← IsFalse(x ≡? y)
l₁ p with 𝐹 ← (x ≡? y) = reflexivity(_≡_)
l₂ : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ zero) ← (Vector.proj v(x) ≡ zero)
l₂ p with (x ≡? y)
... | 𝑇 = p
... | 𝐹 = reflexivity(_≡_)
r : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ zero) → (IsFalse(x ≡? y) ∨ (Vector.proj v(x) ≡ zero))
r p with (x ≡? y)
... | 𝑇 = [∨]-introᵣ p
... | 𝐹 = [∨]-introₗ [⊤]-intro
diagMat-element-vector : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ Vector.proj v(x)) ↔ ((x ≡ₑ y) ∨ (Vector.proj v(x) ≡ zero))
diagMat-element-vector {zero = zero}{𝐒 n}{v = v}{x = x}{y = y} =
[↔]-intro ([↔]-to-[←] [→ₗ][∨][∧]-preserving ([∧]-intro l₁ l₂)) r ⦗ [↔]-transitivity ⦘ᵣ
[∨]-mapₗ-[↔] ([↔]-symmetry [≡][≡?]-equivalence)
where
l₁ : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ Vector.proj v(x)) ← IsTrue(x ≡? y)
l₁ p with 𝑇 ← (x ≡? y) = reflexivity(_≡_)
l₂ : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ Vector.proj v(x)) ← (Vector.proj v(x) ≡ zero)
l₂ p with (x ≡? y)
... | 𝑇 = reflexivity(_≡_)
... | 𝐹 = symmetry(_≡_) p
r : (Matrix.proj (SquareMatrix.diagMat zero v) (x , y) ≡ Vector.proj v(x)) → (IsTrue(x ≡? y) ∨ (Vector.proj v(x) ≡ zero))
r p with (x ≡? y)
... | 𝑇 = [∨]-introₗ [⊤]-intro
... | 𝐹 = [∨]-introᵣ (symmetry(_≡_) p)
scalarMat-element-zero : (Matrix.proj (SquareMatrix.scalarMat zero elem) (x , y) ≡ zero) ↔ ((x ≢ₑ y) ∨ (elem ≡ zero))
scalarMat-element-zero {zero = zero}{elem = elem}{x = x}{y = y} =
Matrix.proj (SquareMatrix.scalarMat zero elem) (x , y) ≡ zero ⇔-[]
Matrix.proj (SquareMatrix.diagMat zero (Vector.fill elem)) (x , y) ≡ zero ⇔-[ diagMat-element-zero ]
(x ≢ₑ y) ∨ (Vector.proj (Vector.fill elem)(x) ≡ zero) ⇔-[]
(x ≢ₑ y) ∨ (elem ≡ zero) ⇔-end
scalarMat-element-scalar : (Matrix.proj (SquareMatrix.scalarMat zero elem) (x , y) ≡ elem) ↔ ((x ≡ₑ y) ∨ (elem ≡ zero))
scalarMat-element-scalar {zero = zero}{elem = elem}{x = x}{y = y} =
Matrix.proj (SquareMatrix.scalarMat zero elem) (x , y) ≡ elem ⇔-[]
Matrix.proj (SquareMatrix.diagMat zero (Vector.fill elem)) (x , y) ≡ Vector.fill elem(x) ⇔-[ diagMat-element-vector ]
(x ≡ₑ y) ∨ (Vector.proj (Vector.fill elem)(x) ≡ zero) ⇔-[]
(x ≡ₑ y) ∨ (elem ≡ zero) ⇔-end
map₂-tail : Vector.tail(Vector.map₂(_▫_) v₁ v₂) ≡ Vector.map₂(_▫_) (Vector.tail v₁) (Vector.tail v₂)
_⊜_.proof (map₂-tail {d = 𝐒(d)}) = reflexivity(_≡_)
-- TODO: Probably not neccessary : row-tail : ∀{M : Matrix(𝐒(w) , 𝐒(h))(T)}{i} → Vector.tail(Matrix.row {s = (𝐒(w) , 𝐒(h))} M (𝐒(i))) ≡ Matrix.row {s = (w , h)}(Matrix.minor M(𝟎 , 𝟎))(i)
col-scalarMat-is-indexProject : ∀{false true : T}{i : 𝕟(n)} → (Matrix.col(SquareMatrix.scalarMat {d = n} false true)(i) ≡ Vector.indexProject i true false)
_⊜_.proof (col-scalarMat-is-indexProject {i = i}) {x} with (i ≡? x)
... | 𝑇 = reflexivity(_≡_)
... | 𝐹 = reflexivity(_≡_)
row-scalarMat-is-indexProject : ∀{false true : T}{i : 𝕟(n)} → (Matrix.row(SquareMatrix.scalarMat {d = n} false true)(i) ≡ Vector.indexProject i true false)
_⊜_.proof (row-scalarMat-is-indexProject {i = i}) {x} with (i ≡? x) | (x ≡? i) | commutativity ⦃ [≡]-equiv ⦄ (_≡?_) {i}{x}
... | 𝑇 | 𝑇 | [≡]-intro = reflexivity(_≡_)
... | 𝑇 | 𝐹 | ()
... | 𝐹 | 𝑇 | ()
... | 𝐹 | 𝐹 | [≡]-intro = reflexivity(_≡_)
module _
⦃ oper₁ : BinaryOperator(_+ₛ_) ⦄
⦃ oper₂ : BinaryOperator(_⋅ₛ_) ⦄
⦃ ident₁ : Identityᵣ(_+ₛ_)(𝟎ₛ) ⦄
⦃ ident₂ : Identityᵣ(_⋅ₛ_)(𝟏ₛ) ⦄
⦃ absor₂ : Absorberᵣ(_⋅ₛ_)(𝟎ₛ) ⦄
where
instance
postulate matrix-multPattern-identityᵣ : Identityᵣ{T₁ = Matrix(s) T}(Matrix.multPattern(_+ₛ_)(_⋅ₛ_) 𝟎ₛ) (SquareMatrix.scalarMat 𝟎ₛ 𝟏ₛ)
{-_⊜_.proof (Identityᵣ.proof (matrix-multPattern-identityᵣ ) {M}) {x , y} =
Matrix.proj (Matrix.multPattern(_+ₛ_)(_⋅ₛ_) 𝟎ₛ M (SquareMatrix.scalarMat 𝟎ₛ 𝟏ₛ)) (x , y) 🝖[ _≡_ ]-[]
Vector.foldᵣ(_+ₛ_) 𝟎ₛ (Vector.map₂(_⋅ₛ_) (Matrix.row(M)(y)) (Matrix.col(SquareMatrix.scalarMat 𝟎ₛ 𝟏ₛ)(x))) 🝖[ _≡_ ]-[ congruence₁(Vector.foldᵣ(_+ₛ_) 𝟎ₛ) (congruence₂ᵣ(Vector.map₂(_⋅ₛ_))(Matrix.row M(y)) (col-scalarMat-is-indexProject {false = 𝟎ₛ}{true = 𝟏ₛ}{i = x})) ]
Vector.foldᵣ(_+ₛ_) 𝟎ₛ (Vector.map₂(_⋅ₛ_) (Matrix.row(M)(y)) (Vector.indexProject x 𝟏ₛ 𝟎ₛ)) 🝖[ _≡_ ]-[ congruence₁(Vector.foldᵣ(_+ₛ_) 𝟎ₛ) (Vector.map₂-indexProject-identityᵣ {v = Matrix.row(M)(y)}{i = x}) ]
Vector.foldᵣ(_+ₛ_) 𝟎ₛ (Vector.indexProject x (Vector.proj(Matrix.row(M)(y))(x)) 𝟎ₛ) 🝖[ _≡_ ]-[]
Vector.foldᵣ(_+ₛ_) 𝟎ₛ (Vector.indexProject x (Matrix.proj M(x , y)) 𝟎ₛ) 🝖[ _≡_ ]-[ {!!} ]
Matrix.proj M(x , y) ⋅ₛ (Vector.foldᵣ(_+ₛ_) 𝟎ₛ (Vector.indexProject x 𝟏ₛ 𝟎ₛ)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅ₛ_)(_) {!!} ]
Matrix.proj M(x , y) ⋅ₛ 𝟏ₛ 🝖[ _≡_ ]-[ identityᵣ(_⋅ₛ_)(𝟏ₛ) ]
Matrix.proj M(x , y) 🝖-end
-}
module _
⦃ oper₁ : BinaryOperator(_+ₛ_) ⦄
⦃ oper₂ : BinaryOperator(_⋅ₛ_) ⦄
⦃ ident₁ : Identityₗ(_▫₁_)(id₁) ⦄
⦃ ident₂ : Identityₗ(_▫₂_)(id₂) ⦄
⦃ absor₂ : Absorberₗ(_⋅ₛ_)(𝟎ₛ) ⦄
where
instance
postulate matrix-multPattern-identityₗ : Identityₗ{T₂ = Matrix(n , n) T}(Matrix.multPattern(_▫₂_)(_▫₁_) id₁) (SquareMatrix.scalarMat id₂ id₁)
module _
⦃ oper₁ : BinaryOperator(_+ₛ_) ⦄
⦃ oper₂ : BinaryOperator(_⋅ₛ_) ⦄
⦃ ident₁ : Identity(_▫₁_)(id₁) ⦄
⦃ ident₂ : Identity(_▫₂_)(id₂) ⦄
⦃ absor₂ : Absorber(_⋅ₛ_)(𝟎ₛ) ⦄
where
instance
postulate matrix-multPattern-identity : Identity{T = Matrix(n , n) T}(Matrix.multPattern(_▫₂_)(_▫₁_) id₁) (SquareMatrix.scalarMat id₂ id₁)
{-
instance
matrix-map₂-distributivityᵣ : ⦃ dist : Distributivityᵣ(_▫₁_)(_▫₂_) ⦄ → Distributivityᵣ(Matrix.multPattern(_▫₂_)(_▫₁_) id) (Matrix.map₂{s = s}(_▫₂_))
_⊜_.proof (Distributivityᵣ.proof (matrix-map₂-distributivityᵣ {_▫₁_} {_▫₂_} {id = id}) {a} {b} {c}) {x , y} =
Matrix.proj(Matrix.multPattern(_▫₂_) (_▫₁_) id (Matrix.map₂(_▫₂_) a b) c) (x , y) 🝖[ _≡_ ]-[]
Vector.foldᵣ(_▫₂_) id (Vector.map₂ (_▫₁_) (Matrix.row(Matrix.map₂(_▫₂_) a b)(y)) (Matrix.col(c)(x))) 🝖[ _≡_ ]-[]
Vector.foldᵣ(_▫₂_) id (Vector.map₂(_▫₁_) (λ x₁ → (Matrix.proj a (x₁ , y)) ▫₂ (Matrix.proj b (x₁ , y))) (λ y₁ → Matrix.proj c (x , y₁))) 🝖[ _≡_ ]-[ {!!} ]
(Vector.foldᵣ(_▫₂_) id (Vector.map₂ _▫₁_ (λ x₁ → Matrix.proj a (x₁ , y)) (λ y₁ → Matrix.proj c (x , y₁)))) ▫₂ (Vector.foldᵣ(_▫₂_) id (Vector.map₂(_▫₁_) (λ x₁ → Matrix.proj b (x₁ , y)) (λ y₁ → Matrix.proj c (x , y₁)))) 🝖[ _≡_ ]-[]
(Vector.foldᵣ(_▫₂_) id (Vector.map₂ (_▫₁_) (Matrix.row(a)(y)) (Matrix.col(c)(x)))) ▫₂ (Vector.foldᵣ(_▫₂_) id (Vector.map₂ (_▫₁_) (Matrix.row(b)(y)) (Matrix.col(c)(x)))) 🝖[ _≡_ ]-[]
Matrix.proj(Matrix.map₂(_▫₂_) (Matrix.multPattern(_▫₂_)(_▫₁_) id a c) (Matrix.multPattern(_▫₂_)(_▫₁_) id b c)) (x , y) 🝖-end
-}
| 56.344538
| 276
| 0.605369
|
dc07affd2ce5a2a5562a1597212d1b1e9968c81d
| 5,338
|
agda
|
Agda
|
Categories/Object/BinaryCoproducts.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/Object/BinaryCoproducts.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/Object/BinaryCoproducts.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
module Categories.Object.BinaryCoproducts {o ℓ e} (C : Category o ℓ e) where
open Category C
open Equiv
open import Level
import Categories.Object.Coproduct as Coproduct
open import Categories.Morphisms C
open module CP = Coproduct C hiding (module BinCoproducts)
open CP public using (BinCoproducts)
record BinaryCoproducts : Set (o ⊔ ℓ ⊔ e) where
infix 10 _⧻_
field
coproduct : ∀ {A B} → Coproduct A B
_∐_ : Obj → Obj → Obj
A ∐ B = Coproduct.A+B (coproduct {A} {B})
∐-comm : ∀ {A B} → _≅_ (A ∐ B) (B ∐ A)
∐-comm = Commutative coproduct coproduct
∐-assoc : ∀ {X Y Z} → _≅_ (X ∐ (Y ∐ Z)) ((X ∐ Y) ∐ Z)
∐-assoc = Associative coproduct coproduct coproduct coproduct
-- Convenience!
i₁ : {A B : Obj} → (A ⇒ (A ∐ B))
i₁ = Coproduct.i₁ coproduct
i₂ : {A B : Obj} → (B ⇒ (A ∐ B))
i₂ = Coproduct.i₂ coproduct
[_,_] : ∀ {A B Q} → (A ⇒ Q) → (B ⇒ Q) → ((A ∐ B) ⇒ Q)
[_,_] = Coproduct.[_,_] coproduct
.commute₁ : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₁ ≡ f
commute₁ = Coproduct.commute₁ coproduct
.commute₂ : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₂ ≡ g
commute₂ = Coproduct.commute₂ coproduct
.universal : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} {i : (A ∐ B) ⇒ C}
→ i ∘ i₁ ≡ f → i ∘ i₂ ≡ g → [ f , g ] ≡ i
universal = Coproduct.universal coproduct
assocˡ : ∀ {A B C} → (((A ∐ B) ∐ C) ⇒ (A ∐ (B ∐ C)))
assocˡ = _≅_.g ∐-assoc
assocʳ : ∀ {A B C} → ((A ∐ (B ∐ C)) ⇒ ((A ∐ B) ∐ C))
assocʳ = _≅_.f ∐-assoc
.g-η : ∀ {A B C} {f : (A ∐ B) ⇒ C} → [ f ∘ i₁ , f ∘ i₂ ] ≡ f
g-η = Coproduct.g-η coproduct
.η : ∀ {A B} → [ i₁ , i₂ ] ≡ id {A ∐ B}
η = Coproduct.η coproduct
.[]-cong₂ : ∀ {A B C} → {f f′ : A ⇒ C} {g g′ : B ⇒ C} → f ≡ f′ → g ≡ g′ → [ f , g ] ≡ [ f′ , g′ ]
[]-cong₂ = Coproduct.[]-cong₂ coproduct
-- If I _really_ wanted to, I could do this for a specific pair of coproducts like the rest above, but I'll write that one
-- when I need it.
_⧻_ : ∀ {A B C D} → (A ⇒ B) → (C ⇒ D) → ((A ∐ C) ⇒ (B ∐ D))
f ⧻ g = [ i₁ ∘ f , i₂ ∘ g ]
-- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version
-- that doesn't have an explicit id in it, too?
left : ∀ {A B C} → (A ⇒ B) → ((A ∐ C) ⇒ (B ∐ C))
left f = f ⧻ id
right : ∀ {A C D} → (C ⇒ D) → ((A ∐ C) ⇒ (A ∐ D))
right g = id ⧻ g
-- Just to make this more obvious
.⧻∘i₁ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → (f ⧻ g) ∘ i₁ ≡ i₁ ∘ f
⧻∘i₁ {f = f} {g} = commute₁
.⧻∘i₂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → (f ⧻ g) ∘ i₂ ≡ i₂ ∘ g
⧻∘i₂ {f = f} {g} = commute₂
.[]∘⧻ : ∀ {A B C D E} → {f : B ⇒ E} {f′ : A ⇒ B} {g : D ⇒ E} {g′ : C ⇒ D} → [ f , g ] ∘ ( f′ ⧻ g′ ) ≡ [ f ∘ f′ , g ∘ g′ ]
[]∘⧻ {f = f} {f′} {g} {g′} = sym (universal helper₁ helper₂)
where
helper₁ : ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₁ ≡ f ∘ f′
helper₁ =
begin
([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₁
↓⟨ assoc ⟩
[ f , g ] ∘ ((f′ ⧻ g′) ∘ i₁)
↓⟨ ∘-resp-≡ʳ ⧻∘i₁ ⟩
[ f , g ] ∘ (i₁ ∘ f′)
↑⟨ assoc ⟩
([ f , g ] ∘ i₁) ∘ f′
↓⟨ ∘-resp-≡ˡ commute₁ ⟩
f ∘ f′
∎
where
open HomReasoning
helper₂ : ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₂ ≡ g ∘ g′
helper₂ =
begin
([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₂
↓⟨ assoc ⟩
[ f , g ] ∘ ((f′ ⧻ g′) ∘ i₂)
↓⟨ ∘-resp-≡ʳ ⧻∘i₂ ⟩
[ f , g ] ∘ (i₂ ∘ g′)
↑⟨ assoc ⟩
([ f , g ] ∘ i₂) ∘ g′
↓⟨ ∘-resp-≡ˡ commute₂ ⟩
g ∘ g′
∎
where
open HomReasoning
.[]∘left : ∀ {A B C D} → {f : C ⇒ B} {f′ : B ⇒ A} {g′ : D ⇒ A} → [ f′ , g′ ] ∘ left f ≡ [ f′ ∘ f , g′ ]
[]∘left {f = f} {f′} {g′} =
begin
[ f′ , g′ ] ∘ left f
↓⟨ []∘⧻ ⟩
[ f′ ∘ f , g′ ∘ id ]
↓⟨ []-cong₂ refl identityʳ ⟩
[ f′ ∘ f , g′ ]
∎
where
open HomReasoning
.[]∘right : ∀ {A B D E} → {f′ : B ⇒ A} {g : E ⇒ D} {g′ : D ⇒ A} → [ f′ , g′ ] ∘ right g ≡ [ f′ , g′ ∘ g ]
[]∘right {f′ = f′} {g} {g′} =
begin
[ f′ , g′ ] ∘ right g
↓⟨ []∘⧻ ⟩
[ f′ ∘ id , g′ ∘ g ]
↓⟨ []-cong₂ identityʳ refl ⟩
[ f′ , g′ ∘ g ]
∎
where
open HomReasoning
.⧻∘⧻ : ∀ {A B C D E F} → {f : B ⇒ C} → {f′ : A ⇒ B} {g : E ⇒ F} {g′ : D ⇒ E} → (f ⧻ g) ∘ (f′ ⧻ g′) ≡ (f ∘ f′) ⧻ (g ∘ g′)
⧻∘⧻ {B = B} {E = E} {f = f} {f′} {g} {g′} =
begin
(f ⧻ g) ∘ (f′ ⧻ g′)
↓⟨ []∘⧻ ⟩
[ (i₁ ∘ f) ∘ f′ , (i₂ ∘ g) ∘ g′ ]
↓⟨ []-cong₂ assoc assoc ⟩
(f ∘ f′) ⧻ (g ∘ g′)
∎
where
open HomReasoning
.∘[] : ∀ {A B C D} {f : B ⇒ A} {g : C ⇒ A} {q : A ⇒ D} → q ∘ [ f , g ] ≡ [ q ∘ f , q ∘ g ]
∘[] = sym (universal (trans assoc (∘-resp-≡ʳ commute₁)) (trans assoc (∘-resp-≡ʳ commute₂)))
Bin→Binary : BinCoproducts -> BinaryCoproducts
Bin→Binary bc = record { coproduct = λ {A} {B} → record {
A+B = A + B;
i₁ = i₁;
i₂ = i₂;
[_,_] = [_,_];
commute₁ = commute₁;
commute₂ = commute₂;
universal = universal } }
where
open CP.BinCoproducts bc
| 30.678161
| 124
| 0.40296
|
10add8eac244c4eef91a0357b6dbe42835911fa5
| 5,043
|
agda
|
Agda
|
core/lib/types/PushoutFlattening.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
core/lib/types/PushoutFlattening.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
core/lib/types/PushoutFlattening.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.Pi
open import lib.types.Sigma
open import lib.types.Span
open import lib.types.Paths
import lib.types.Generic1HIT as Generic1HIT
open import lib.types.Pushout
module lib.types.PushoutFlattening {i} {j} {k} {d : Span {i} {j} {k}} where
open Span d renaming (f to g; g to h)
module PushoutRecType {l} (left* : A → Type l) (right* : B → Type l)
(glue* : (c : C) → left* (g c) ≃ right* (h c)) where
open PushoutRec left* right* (ua ∘ glue*) public
abstract
coe-glue-β : (c : C) (a : left* (g c))
→ coe (ap f (glue c)) a == –> (glue* c) a
coe-glue-β c a =
coe (ap f (glue c)) a =⟨ glue-β c |in-ctx (λ u → coe u a) ⟩
coe (ua (glue* c)) a =⟨ coe-β (glue* c) a ⟩
–> (glue* c) a =∎
coe!-glue-β : (c : C) (b : right* (h c))
→ coe! (ap f (glue c)) b == <– (glue* c) b
coe!-glue-β c b =
coe! (ap f (glue c)) b =⟨ glue-β c |in-ctx (λ u → coe! u b) ⟩
coe! (ua (glue* c)) b =⟨ coe!-β (glue* c) b ⟩
<– (glue* c) b =∎
↓-glue-out : (c : C) {a : left* (g c)} {b : right* (h c)}
→ a == b [ f ↓ glue c ]
→ –> (glue* c) a == b
↓-glue-out c {a} {b} p =
–> (glue* c) a =⟨ ! (coe-glue-β c a) ⟩
coe (ap f (glue c)) a =⟨ to-transp p ⟩
b =∎
↓-glue-in : (c : C) {a : left* (g c)} {b : right* (h c)}
→ –> (glue* c) a == b
→ a == b [ f ↓ glue c ]
↓-glue-in c {a} {b} p = from-transp f (glue c) (coe-glue-β c a ∙ p)
private
module _ where
fA : Type _
fA = Σ A left*
fB : Type _
fB = Σ B right*
fC : Type _
fC = Σ C (left* ∘ g)
fg : fC → fA
fg (c , c') = (g c , c')
fh : fC → fB
fh (c , c') = (h c , –> (glue* c) c')
f-d : Span
f-d = span fA fB fC fg fh
flattening : Σ (Pushout d) f == Pushout f-d
flattening = Σ= p p' ∙ q ∙ r ∙ s where
module G = PushoutGeneric {d = d}
P-cc : Coprod A B → Type _
P-cc (inl a) = left* a
P-cc (inr b) = right* b
module P = G.RecType P-cc glue*
import lib.types.Flattening as Flattening
module FlatteningPushout = Flattening
(Coprod A B) C (inl ∘ g) (inr ∘ h) P-cc glue*
open FlatteningPushout public hiding (flattening-equiv; module P)
p-equiv : Pushout d ≃ G.T
p-equiv = G.generic-pushout
p : Pushout d == G.T
p = ua p-equiv
p' : f == P.f [ (λ X → (X → Type _)) ↓ p ]
p' = ↓-app→cst-in (λ {t} {t'} q →
Pushout-elim {P = λ t → f t == P.f (–> p-equiv t)}
(λ a → idp) (λ b → idp)
(λ c → ↓-='-in'
(ap (P.f ∘ (–> p-equiv)) (glue c) =⟨ ap-∘ P.f (–> p-equiv) (glue c) ⟩
ap P.f (ap (–> p-equiv) (glue c)) =⟨ G.To.glue-β c |in-ctx ap P.f ⟩
ap P.f (pp c) =⟨ P.pp-β c ⟩
ua (glue* c) =⟨ ! (glue-β c) ⟩
ap f (glue c) =∎))
t ∙ ap P.f (↓-idf-ua-out _ q))
--
module fG' = Generic1HIT At Bt ft gt
q : Σ G.T P.f == fG'.T
q = ua FlatteningPushout.flattening-equiv
--
{-
This part is basically [Generic1HIT=] applied to the flattening lemma
for coproducts. Maybe it would make sense to refactor it that way.
-}
module fG = PushoutGeneric {d = f-d}
r : fG'.T == fG.T
r = ua (equiv to from to-from from-to) where
to-cc : At → fG.T
to-cc (inl a , a') = fG.cc (inl (a , a'))
to-cc (inr b , b') = fG.cc (inr (b , b'))
module To = fG'.Rec to-cc fG.pp
to : fG'.T → fG.T
to = To.f
from-cc : Coprod fA fB → fG'.T
from-cc (inl (a , a')) = fG'.cc (inl a , a')
from-cc (inr (b , b')) = fG'.cc (inr b , b')
module From = fG.Rec from-cc fG'.pp
from : fG.T → fG'.T
from = From.f
abstract
to-from : (x : fG.T) → to (from x) == x
to-from = fG.elim to-from-cc to-from-pp where
to-from-cc : (x : Coprod fA fB)
→ to (from (fG.cc x)) == fG.cc x
to-from-cc (inl _) = idp
to-from-cc (inr _) = idp
to-from-pp : (c : fC)
→ idp == idp [ (λ x → to (from x) == x) ↓ fG.pp c ]
to-from-pp c = ↓-∘=idf-in' to from
(ap to (ap from (fG.pp c)) =⟨ From.pp-β c |in-ctx ap to ⟩
ap to (fG'.pp c) =⟨ To.pp-β c ⟩
fG.pp c =∎)
from-to : (x : fG'.T) → from (to x) == x
from-to = fG'.elim from-to-cc from-to-pp where
from-to-cc : (a : At) → from (to (fG'.cc a)) == fG'.cc a
from-to-cc (inl _ , _) = idp
from-to-cc (inr _ , _) = idp
from-to-pp : (b : Bt)
→ idp == idp [ (λ x → from (to x) == x) ↓ fG'.pp b ]
from-to-pp b = ↓-∘=idf-in' from to
(ap from (ap to (fG'.pp b)) =⟨ To.pp-β b |in-ctx ap from ⟩
ap from (fG.pp b) =⟨ From.pp-β b ⟩
fG'.pp b =∎)
--
s : fG.T == Pushout f-d
s = ! (ua fG.generic-pushout)
| 29.491228
| 87
| 0.453103
|
202061a000e2d8bd18515ad3c90553ba88242793
| 1,080
|
agda
|
Agda
|
Cubical/HITs/Localization/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/HITs/Localization/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Localization/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Localization.Properties 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.Equiv.PathSplit
open isPathSplitEquiv
open import Cubical.HITs.Localization.Base
module _ {ℓα ℓs ℓt} {A : Type ℓα} {S : A → Type ℓs} {T : A → Type ℓt} where
rec : ∀ {F : ∀ α → S α → T α} {ℓ ℓ'} {X : Type ℓ} {Y : Type ℓ'}
→ (lY : isLocal F Y) → (X → Y) → Localize F X → Y
rec lY g ∣ x ∣ = g x
rec lY g (ext α f t) = fst (sec (lY α)) (λ s → rec lY g (f s)) t
rec lY g (isExt α f s i) = snd (sec (lY α)) (λ s → rec lY g (f s)) i s
rec lY f (≡ext α g h p t i) = fst (secCong (lY α) (λ t → rec lY f (g t)) (λ t → rec lY f (h t)))
(λ i s → rec lY f (p s i)) i t
rec lY f (≡isExt α g h p t i j) = snd (secCong (lY α) (λ t → rec lY f (g t)) (λ t → rec lY f (h t)))
(λ i s → rec lY f (p s i)) i j t
| 45
| 102
| 0.552778
|
39b8b50c3c1e4760ed880f06057f823d99fae931
| 8,479
|
agda
|
Agda
|
src/FOmegaInt/Kinding/Declarative/Equivalence.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 12
|
2017-06-13T16:05:35.000Z
|
2021-09-27T05:53:06.000Z
|
src/FOmegaInt/Kinding/Declarative/Equivalence.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 1
|
2021-05-14T08:09:40.000Z
|
2021-05-14T08:54:39.000Z
|
src/FOmegaInt/Kinding/Declarative/Equivalence.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 2
|
2021-05-13T22:29:48.000Z
|
2021-05-14T10:25:05.000Z
|
------------------------------------------------------------------------
-- Equivalence of the two variants of declarative kinding of Fω with
-- interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Declarative.Equivalence where
open import Data.Product using (proj₁)
open import FOmegaInt.Syntax
import FOmegaInt.Typing as Original
open import FOmegaInt.Kinding.Declarative as Extended
open import FOmegaInt.Kinding.Declarative.Validity
private
module O where
open Original public
open Typing public
module E where
open Extended public
open Kinding public
open Syntax
open TermCtx
open Kinding
open KindedSubstitution
open Original.Typing
hiding (_ctx; _⊢_wf; _⊢_kd; _⊢Tp_∈_; _⊢_<∷_; _⊢_<:_∈_; _⊢_≅_; _⊢_≃_∈_)
-- Soundness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This soundness proof simply forgets about all the validity
-- conditions in the extended rules.
mutual
sound-wf : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → Γ O.⊢ a wf
sound-wf (wf-kd k-kd) = wf-kd (sound-kd k-kd)
sound-wf (wf-tp a∈*) = wf-tp (sound-Tp∈ a∈*)
sound-ctx : ∀ {n} {Γ : Ctx n} → Γ ctx → Γ O.ctx
sound-ctx E.[] = O.[]
sound-ctx (a-wf E.∷ Γ-ctx) = sound-wf a-wf O.∷ sound-ctx Γ-ctx
sound-kd : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ O.⊢ k kd
sound-kd (kd-⋯ a∈* b∈*) = kd-⋯ (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
sound-kd (kd-Π j-kd k-kd) = kd-Π (sound-kd j-kd) (sound-kd k-kd)
sound-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Tp a ∈ k → Γ O.⊢Tp a ∈ k
sound-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
∈-var x (sound-ctx Γ-ctx) Γ[x]≡kd-k
sound-Tp∈ (∈-⊥-f Γ-ctx) = ∈-⊥-f (sound-ctx Γ-ctx)
sound-Tp∈ (∈-⊤-f Γ-ctx) = ∈-⊤-f (sound-ctx Γ-ctx)
sound-Tp∈ (∈-∀-f k-kd a∈*) = ∈-∀-f (sound-kd k-kd) (sound-Tp∈ a∈*)
sound-Tp∈ (∈-→-f a∈* b∈*) = ∈-→-f (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
sound-Tp∈ (∈-Π-i j-kd a∈k k-kd) = ∈-Π-i (sound-kd j-kd) (sound-Tp∈ a∈k)
sound-Tp∈ (∈-Π-e a∈Πjk b∈j k-kd k[b]-kd) =
∈-Π-e (sound-Tp∈ a∈Πjk) (sound-Tp∈ b∈j)
sound-Tp∈ (∈-s-i a∈b⋯c) = ∈-s-i (sound-Tp∈ a∈b⋯c)
sound-Tp∈ (∈-⇑ a∈j j<∷k) = ∈-⇑ (sound-Tp∈ a∈j) (sound-<∷ j<∷k)
sound-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → Γ O.⊢ j <∷ k
sound-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*) =
<∷-⋯ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
sound-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
<∷-Π (sound-<∷ j₂<∷j₁) (sound-<∷ k₁<∷k₂) (sound-kd Πj₁k₁-kd)
sound-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ∈ k → Γ O.⊢ a <: b ∈ k
sound-<: (<:-refl a∈k) = <:-refl (sound-Tp∈ a∈k)
sound-<: (<:-trans a<:b∈k b<:c∈k) =
<:-trans (sound-<: a<:b∈k) (sound-<: b<:c∈k)
sound-<: (<:-β₁ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
<:-β₁ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
sound-<: (<:-β₂ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
<:-β₂ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
sound-<: (<:-η₁ a∈Πjk) = <:-η₁ (sound-Tp∈ a∈Πjk)
sound-<: (<:-η₂ a∈Πjk) = <:-η₂ (sound-Tp∈ a∈Πjk)
sound-<: (<:-⊥ a∈b⋯c) = <:-⊥ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-⊤ a∈b⋯c) = <:-⊤ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
<:-∀ (sound-<∷ k₂<∷k₁) (sound-<: a₁<:a₂∈*) (sound-Tp∈ ∀k₁a₁∈*)
sound-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
<:-→ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
sound-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
<:-λ (sound-<: a₁<:a₂∈Πjk)
(sound-Tp∈ Λj₁a₁∈Πjk) (sound-Tp∈ Λj₂a₂∈Πjk)
sound-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j b₁∈j k-kd k[b₁]-kd) =
<:-· (sound-<: a₁<:a₂∈Πjk) (sound-≃ b₁≃b₁∈j)
sound-<: (<:-⟨| a∈b⋯c) = <:-⟨| (sound-Tp∈ a∈b⋯c)
sound-<: (<:-|⟩ a∈b⋯c) = <:-|⟩ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-⋯-i a₁<:a₂∈b⋯c) = <:-⋯-i (sound-<: a₁<:a₂∈b⋯c)
sound-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
<:-⇑ (sound-<: a₁<:a₂∈j) (sound-<∷ j<∷k)
sound-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ O.⊢ a ≃ b ∈ k
sound-≃ (<:-antisym a<:b∈k b<:a∈k) =
<:-antisym (sound-<: a<:b∈k) (sound-<: b<:a∈k)
sound-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ O.⊢ j ≅ k
sound-≅ (<∷-antisym j<∷k k<∷j) =
<∷-antisym (sound-<∷ j<∷k) (sound-<∷ k<∷j)
-- Completeness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This proves that the validity conditions in the extended rules are
-- in fact redundant, i.e. they follow from validity properties of the
-- remaining premises (of the rules in question)
mutual
complete-wf : ∀ {n} {Γ : Ctx n} {a} → Γ O.⊢ a wf → Γ ⊢ a wf
complete-wf (wf-kd k-kd) = wf-kd (complete-kd k-kd)
complete-wf (wf-tp a∈*) = wf-tp (complete-Tp∈ a∈*)
complete-ctx : ∀ {n} {Γ : Ctx n} → Γ O.ctx → Γ ctx
complete-ctx O.[] = E.[]
complete-ctx (a-wf O.∷ Γ-ctx) = complete-wf a-wf E.∷ complete-ctx Γ-ctx
complete-kd : ∀ {n} {Γ : Ctx n} {k} → Γ O.⊢ k kd → Γ ⊢ k kd
complete-kd (kd-⋯ a∈* b∈*) = kd-⋯ (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
complete-kd (kd-Π j-kd k-kd) = kd-Π (complete-kd j-kd) (complete-kd k-kd)
complete-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ O.⊢Tp a ∈ k → Γ ⊢Tp a ∈ k
complete-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
∈-var x (complete-ctx Γ-ctx) Γ[x]≡kd-k
complete-Tp∈ (∈-⊥-f Γ-ctx) = ∈-⊥-f (complete-ctx Γ-ctx)
complete-Tp∈ (∈-⊤-f Γ-ctx) = ∈-⊤-f (complete-ctx Γ-ctx)
complete-Tp∈ (∈-∀-f k-kd a∈*) = ∈-∀-f (complete-kd k-kd) (complete-Tp∈ a∈*)
complete-Tp∈ (∈-→-f a∈* b∈*) = ∈-→-f (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
complete-Tp∈ (∈-Π-i j-kd a∈k) =
∈-Π-i (complete-kd j-kd) a∈k′ k-kd
where
a∈k′ = complete-Tp∈ a∈k
k-kd = Tp∈-valid a∈k′
complete-Tp∈ (∈-Π-e a∈Πjk b∈j) with Tp∈-valid (complete-Tp∈ a∈Πjk)
... | (kd-Π j-kd k-kd) =
∈-Π-e (complete-Tp∈ a∈Πjk) b∈j′ k-kd k[b]-kd
where
b∈j′ = complete-Tp∈ b∈j
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-Tp∈ (∈-s-i a∈b⋯c) = ∈-s-i (complete-Tp∈ a∈b⋯c)
complete-Tp∈ (∈-⇑ a∈j j<∷k) = ∈-⇑ (complete-Tp∈ a∈j) (complete-<∷ j<∷k)
complete-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j <∷ k → Γ ⊢ j <∷ k
complete-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*) =
<∷-⋯ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
complete-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
<∷-Π (complete-<∷ j₂<∷j₁) (complete-<∷ k₁<∷k₂) (complete-kd Πj₁k₁-kd)
complete-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a <: b ∈ k → Γ ⊢ a <: b ∈ k
complete-<: (<:-refl a∈k) = <:-refl (complete-Tp∈ a∈k)
complete-<: (<:-trans a<:b∈k b<:c∈k) =
<:-trans (complete-<: a<:b∈k) (complete-<: b<:c∈k)
complete-<: (<:-β₁ a∈k b∈j) =
<:-β₁ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
where
a∈k′ = complete-Tp∈ a∈k
b∈j′ = complete-Tp∈ b∈j
k-kd = Tp∈-valid a∈k′
a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-<: (<:-β₂ a∈k b∈j) =
<:-β₂ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
where
a∈k′ = complete-Tp∈ a∈k
b∈j′ = complete-Tp∈ b∈j
k-kd = Tp∈-valid a∈k′
a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-<: (<:-η₁ a∈Πjk) = <:-η₁ (complete-Tp∈ a∈Πjk)
complete-<: (<:-η₂ a∈Πjk) = <:-η₂ (complete-Tp∈ a∈Πjk)
complete-<: (<:-⊥ a∈b⋯c) = <:-⊥ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-⊤ a∈b⋯c) = <:-⊤ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
<:-∀ (complete-<∷ k₂<∷k₁) (complete-<: a₁<:a₂∈*) (complete-Tp∈ ∀k₁a₁∈*)
complete-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
<:-→ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
complete-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
<:-λ (complete-<: a₁<:a₂∈Πjk)
(complete-Tp∈ Λj₁a₁∈Πjk) (complete-Tp∈ Λj₂a₂∈Πjk)
complete-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j)
with <:-valid-kd (complete-<: a₁<:a₂∈Πjk)
... | (kd-Π j-kd k-kd) =
<:-· (complete-<: a₁<:a₂∈Πjk) b₁≃b₂∈j′ b₁∈j k-kd k[b₁]-kd
where
b₁≃b₂∈j′ = complete-≃ b₁≃b₁∈j
b₁∈j = proj₁ (≃-valid b₁≃b₂∈j′)
k[b₁]-kd = kd-[] k-kd (∈-tp b₁∈j)
complete-<: (<:-⟨| a∈b⋯c) = <:-⟨| (complete-Tp∈ a∈b⋯c)
complete-<: (<:-|⟩ a∈b⋯c) = <:-|⟩ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-⋯-i a₁<:a₂∈b⋯c) = <:-⋯-i (complete-<: a₁<:a₂∈b⋯c)
complete-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
<:-⇑ (complete-<: a₁<:a₂∈j) (complete-<∷ j<∷k)
complete-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a ≃ b ∈ k → Γ ⊢ a ≃ b ∈ k
complete-≃ (<:-antisym a<:b∈k b<:a∈k) =
<:-antisym (complete-<: a<:b∈k) (complete-<: b<:a∈k)
complete-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j ≅ k → Γ ⊢ j ≅ k
complete-≅ (<∷-antisym j<∷k k<∷j) =
<∷-antisym (complete-<∷ j<∷k) (complete-<∷ k<∷j)
| 40.764423
| 78
| 0.482604
|
a1a6703d414d7d40f2f571b8780bbba737a2d0f8
| 813
|
agda
|
Agda
|
SOAS/Context.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 39
|
2021-11-09T20:39:55.000Z
|
2022-03-19T17:33:12.000Z
|
SOAS/Context.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 1
|
2021-11-21T12:19:32.000Z
|
2021-11-21T12:19:32.000Z
|
SOAS/Context.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 4
|
2021-11-09T20:39:59.000Z
|
2022-01-24T12:49:17.000Z
|
-- Concrete definition of contexts over a sort T
module SOAS.Context {T : Set} where
open import SOAS.Common
open import Data.List using (List; []; _∷_; _++_)
-- Context: a list of types
data Ctx : Set where
∅ : Ctx
_∙_ : (α : T) → (Γ : Ctx) → Ctx
infixr 50 _∙_
-- Singleton context
pattern _⌋ τ = τ ∙ ∅
pattern ⌈_⌋ α = α ∙ ∅
pattern ⌊_ α = α
infixr 60 _⌋
infix 70 ⌈_⌋
infix 70 ⌊_
-- Context concatenation
_∔_ : Ctx → Ctx → Ctx
∅ ∔ Δ = Δ
(α ∙ Γ) ∔ Δ = α ∙ (Γ ∔ Δ)
infixl 20 _∔_
-- Context concatenation is associative
∔-assoc : (Γ Δ Θ : Ctx) → ((Γ ∔ Δ) ∔ Θ) ≡ (Γ ∔ (Δ ∔ Θ))
∔-assoc ∅ Δ Θ = refl
∔-assoc (α ∙ Γ) Δ Θ = cong (α ∙_) (∔-assoc Γ Δ Θ)
-- Empty context is right unit of context concatenation
∔-unitʳ : (Γ : Ctx) → Γ ∔ ∅ ≡ Γ
∔-unitʳ ∅ = refl
∔-unitʳ (α ∙ Γ) = cong (α ∙_) (∔-unitʳ Γ)
| 20.846154
| 55
| 0.567036
|
1c45bfc7ca5528c76a40b182c55d12aba50ea34b
| 549
|
agda
|
Agda
|
src/exercices/Equal.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | 2
|
2021-03-12T18:31:14.000Z
|
2021-05-04T09:35:36.000Z
|
src/exercices/Equal.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | null | null | null |
src/exercices/Equal.agda
|
d-plaindoux/colca
|
a81447af3ab2ba898bb7d57be71369abbba12d81
|
[
"MIT"
] | null | null | null |
--
-- Created by Dependently-Typed Lambda Calculus on 2020-09-24
-- Equal
-- Author: dplaindoux
--
module Equal where
open import Data.Nat using (ℕ; zero; suc)
open import Data.Bool using (Bool; true; false)
infix 30 _=?_
data Type : Set where
nat : Type
▲_ : Type → Set
▲ nat = ℕ
_=?_ : { a : Type } → ▲ a → ▲ a → Bool
_=?_ {nat} zero zero = true
_=?_ {nat} (suc m) (suc n) = m =? n
_=?_ {nat} _ _ = false
Nat :
∀self(P : Nat → Set) →
∀(zero : P(λz. λs. z)) →
∀(succ : ∀(n : Nat) → P (λz. λs. s n)) →
P self
| 17.709677
| 61
| 0.540984
|
c50cb5a45ba8ed82b7884f0c17686cb25d6c85b6
| 634
|
agda
|
Agda
|
test/Succeed/GeneralizeWithPatternLambda.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/GeneralizeWithPatternLambda.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/GeneralizeWithPatternLambda.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Primitive
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
variable
ℓ : Level
A : Set ℓ
n : Nat
infixr 4 _∷_
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_∷_ : A → Vec A n → Vec A (suc n)
variable
xs : Vec A n
data T (n : Nat) (f : Nat → Nat) : Set where
it : T n f
appT : ∀ {f} → T n f → Nat
appT {n = n} {f = f} it = f n
length : Vec A n → Nat
length {n = n} _ = n
-- This should not break.
bar : (xs : Vec Nat n) → T n λ { m → m + length xs }
bar xs = it
ys : Vec Nat 5
ys = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []
-- Check that it doesn't
no-fail : appT (bar ys) ≡ 10
no-fail = refl
| 16.25641
| 52
| 0.555205
|
1c783bef7ce73c6f72fbd05357df936e9afe8e82
| 143
|
agda
|
Agda
|
Cubical/HITs/S2.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/S2.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/S2.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.S2 where
open import Cubical.HITs.S2.Base public
-- open import Cubical.HITs.S2.Properties public
| 20.428571
| 48
| 0.748252
|
0e964b33bff4b8be15787e52b65d585fa5176b03
| 5,092
|
agda
|
Agda
|
Fields/Orders/LeastUpperBounds/Examples.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Fields/Orders/LeastUpperBounds/Examples.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Fields/Orders/LeastUpperBounds/Examples.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 LogicalFormulae
open import Setoids.Subset
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Sets.EquivalenceRelations
open import Rings.Orders.Total.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Definition
open import Fields.Fields
open import Groups.Definition
open import Functions.Definition
module Fields.Orders.LeastUpperBounds.Examples {a b c : _} {A : Set a} {S : Setoid {a} {b} A} {_<_ : Rel {_} {c} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} {pOrder : SetoidPartialOrder S _<_} {pOrderedRing : PartiallyOrderedRing R pOrder} (orderedRing : TotallyOrderedRing pOrderedRing) (F : Field R) (isNontrivial : Setoid._∼_ S (Ring.0R R) (Ring.1R R) → False) where
open PartiallyOrderedRing pOrderedRing
open Setoid S
open Equivalence eq
open SetoidTotalOrder (TotallyOrderedRing.total orderedRing)
open Field F
open Ring R
open SetoidPartialOrder pOrder
open Group additiveGroup
open import Rings.Orders.Partial.Lemmas pOrderedRing
open import Rings.Orders.Total.Lemmas orderedRing
open import Fields.Orders.LeastUpperBounds.Definition pOrder
charNot2 : Setoid._∼_ S (Ring.1R R + Ring.1R R) (Ring.0R R) → False
charNot2 = orderedImpliesCharNot2 nontrivial
openIntervalPred : (a : A) → (b : A) → a < b → A → Set _
openIntervalPred a b a<b x = (a < x) && (x < b)
openInterval : (a : A) → (b : A) → (a<b : a < b) → subset S (openIntervalPred a b a<b)
openInterval a b a<b x=y (a<x ,, x<b) = SetoidPartialOrder.<WellDefined pOrder reflexive x=y a<x ,, SetoidPartialOrder.<WellDefined pOrder x=y reflexive x<b
1/2 : A
1/2 with allInvertible (1R + 1R) charNot2
... | n , _ = n
1/2Is1/2 : 1/2 * (1R + 1R) ∼ 1R
1/2Is1/2 with allInvertible (1R + 1R) charNot2
... | n , pr = pr
1/2Is1/2' : (1/2 + 1/2) ∼ 1R
1/2Is1/2' = transitive (+WellDefined (symmetric identIsIdent) (symmetric identIsIdent)) (transitive (transitive (symmetric *DistributesOver+') *Commutative) 1/2Is1/2)
halfHalves : (a : A) → ((a + a) * 1/2) ∼ a
halfHalves a = transitive *DistributesOver+' (transitive (transitive (transitive (symmetric *DistributesOver+) (*WellDefined reflexive 1/2Is1/2')) *Commutative) identIsIdent)
0<1/2 : 0R < 1/2
0<1/2 = halvePositive 1/2 (<WellDefined reflexive (symmetric (transitive (symmetric (transitive *DistributesOver+ (+WellDefined (transitive *Commutative identIsIdent) (transitive *Commutative identIsIdent)))) 1/2Is1/2)) (0<1 nontrivial))
min<mean : (a b : A) → a < b → a < ((a + b) * 1/2)
min<mean a b a<b = <WellDefined (transitive *DistributesOver+' (transitive (+WellDefined *Commutative *Commutative) (transitive (symmetric *DistributesOver+') (transitive (*WellDefined 1/2Is1/2' reflexive) identIsIdent)))) reflexive a+a<a+b
where
a+a<a+b : ((a + a) * 1/2) < ((a + b) * 1/2)
a+a<a+b = ringCanMultiplyByPositive 0<1/2 (<WellDefined reflexive groupIsAbelian (orderRespectsAddition a<b a))
mean<max : (a b : A) → a < b → ((a + b) * 1/2) < b
mean<max a b a<b = <WellDefined reflexive (halfHalves b) a+b<b+b
where
a+b<b+b : ((a + b) * 1/2) < ((b + b) * 1/2)
a+b<b+b = ringCanMultiplyByPositive 0<1/2 (orderRespectsAddition a<b b)
example1 : (a b : A) (a<b : a < b) → LeastUpperBound (openInterval a b a<b) b
LeastUpperBound.upperBound (example1 a b a<b) y (a<y ,, y<b) = inl y<b
LeastUpperBound.leastUpperBound (example1 a b a<b) y isUpperBound with totality b y
LeastUpperBound.leastUpperBound (example1 a b a<b) y isUpperBound | inl (inl x) = inl x
LeastUpperBound.leastUpperBound (example1 a b a<b) y isUpperBound | inl (inr y<b) = exFalso false
where
betterBound : A
betterBound = (y + b) * 1/2
p1 : ((y + b) * 1/2) < ((b + b) * 1/2)
p1 = ringCanMultiplyByPositive 0<1/2 (orderRespectsAddition y<b b)
p2 : betterBound < b
p2 = <WellDefined reflexive (transitive (*WellDefined (transitive (symmetric (+WellDefined identIsIdent identIsIdent)) (transitive (+WellDefined *Commutative *Commutative) (symmetric *DistributesOver+))) reflexive) (transitive (symmetric *Associative) (transitive (transitive (*WellDefined reflexive (transitive *Commutative 1/2Is1/2)) *Commutative) identIsIdent))) p1
a<y : a < y
a<y with isUpperBound ((a + b) * 1/2) (min<mean a b a<b ,, mean<max a b a<b)
a<y | inl a+b/2<y = <Transitive (min<mean a b a<b) a+b/2<y
a<y | inr a+b/2=y = <WellDefined reflexive a+b/2=y (min<mean a b a<b)
p3 : ((a + a) * 1/2) < ((y + b) * 1/2)
p3 = ringCanMultiplyByPositive 0<1/2 (ringAddInequalities a<y a<b)
a<betterBound : a < betterBound
a<betterBound = <WellDefined (halfHalves a) reflexive p3
bad : (betterBound < y) || (betterBound ∼ y)
bad = isUpperBound betterBound (a<betterBound ,, p2)
false : False
false with bad
false | inl mean<y with min<mean y b y<b
... | y<mean = irreflexive (<Transitive y<mean mean<y)
false | inr x = irreflexive (<WellDefined (symmetric x) reflexive (min<mean y b y<b))
LeastUpperBound.leastUpperBound (example1 a b a<b) y isUpperBound | inr x = inr x
| 53.041667
| 372
| 0.694619
|
18c6f37c38d1da2d59f65215f76e720c82c087a7
| 1,471
|
agda
|
Agda
|
proofs/AKS/Nat/Base.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | 1
|
2020-12-01T22:38:27.000Z
|
2020-12-01T22:38:27.000Z
|
proofs/AKS/Nat/Base.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | null | null | null |
proofs/AKS/Nat/Base.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | null | null | null |
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Nullary.Decidable using (False; map)
open import Function.Equivalence as FE using ()
module AKS.Nat.Base where
open import Agda.Builtin.FromNat using (Number)
open import Data.Nat using (ℕ; _+_; _∸_; _*_; _≟_; _<ᵇ_; pred) public
open ℕ public
open import Data.Nat.Literals using (number)
instance
ℕ-number : Number ℕ
ℕ-number = number
data ℕ⁺ : Set where
ℕ+ : ℕ → ℕ⁺
_+⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺
ℕ+ n +⁺ ℕ+ m = ℕ+ (suc (n + m))
_*⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺
ℕ+ n *⁺ ℕ+ m = ℕ+ (n + m * (suc n))
_≟⁺_ : Decidable {A = ℕ⁺} _≡_
ℕ+ n ≟⁺ ℕ+ m = map (FE.equivalence (λ { refl → refl }) (λ { refl → refl })) (n ≟ m)
⟅_⇑⟆ : ∀ n {≢0 : False (n ≟ zero)} → ℕ⁺
⟅ suc n ⇑⟆ = ℕ+ n
⟅_⇓⟆ : ℕ⁺ → ℕ
⟅ ℕ+ n ⇓⟆ = suc n
instance
ℕ⁺-number : Number ℕ⁺
ℕ⁺-number = record
{ Constraint = λ n → False (n ≟ zero)
; fromNat = λ n {{≢0}} → ⟅ n ⇑⟆ {≢0}
}
infix 4 _≤_
record _≤_ (n : ℕ) (m : ℕ) : Set where
constructor lte
field
k : ℕ
≤-proof : n + k ≡ m
infix 4 _≥_
_≥_ : ℕ → ℕ → Set
n ≥ m = m ≤ n
infix 4 _≰_
_≰_ : ℕ → ℕ → Set
n ≰ m = ¬ (n ≤ m)
infix 4 _≱_
_≱_ : ℕ → ℕ → Set
n ≱ m = ¬ (m ≤ n)
infix 4 _<_
_<_ : ℕ → ℕ → Set
n < m = suc n ≤ m
infix 4 _≮_
_≮_ : ℕ → ℕ → Set
n ≮ m = ¬ (n < m)
infix 4 _>_
_>_ : ℕ → ℕ → Set
n > m = m < n
infix 4 _≯_
_≯_ : ℕ → ℕ → Set
n ≯ m = m ≮ n
| 18.858974
| 83
| 0.541808
|
4d5798e866e33bb6dc1d1e36b932ae0389bbecce
| 1,038
|
agda
|
Agda
|
Definition/Conversion/Consequences/Completeness.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 30
|
2017-05-20T03:05:21.000Z
|
2022-03-30T18:01:07.000Z
|
Definition/Conversion/Consequences/Completeness.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 4
|
2017-06-22T12:49:23.000Z
|
2021-02-22T10:37:24.000Z
|
Definition/Conversion/Consequences/Completeness.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 8
|
2017-10-18T14:18:20.000Z
|
2021-11-27T15:58:33.000Z
|
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Consequences.Completeness where
open import Definition.Untyped hiding (_∷_)
open import Definition.Typed
open import Definition.Conversion
open import Definition.Conversion.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Escape
open import Definition.LogicalRelation.Fundamental
open import Tools.Nat
open import Tools.Product
private
variable
n : Nat
Γ : Con Term n
-- Algorithmic equality is derivable from judgemental equality of types.
completeEq : ∀ {A B} → Γ ⊢ A ≡ B → Γ ⊢ A [conv↑] B
completeEq A≡B =
let [Γ] , [A] , [B] , [A≡B] = fundamentalEq A≡B
in escapeEqᵛ [Γ] [A] [A≡B]
-- Algorithmic equality is derivable from judgemental equality of terms.
completeEqTerm : ∀ {t u A} → Γ ⊢ t ≡ u ∷ A → Γ ⊢ t [conv↑] u ∷ A
completeEqTerm t≡u =
let [Γ] , modelsTermEq [A] [t] [u] [t≡u] = fundamentalTermEq t≡u
in escapeEqTermᵛ [Γ] [A] [t≡u]
| 30.529412
| 72
| 0.72447
|
4a4a7b7af19dbe28e19be9416da15caa1ed26920
| 849
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Bool.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Bool.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Bool.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Booleans
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Bool where
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; refl)
------------------------------------------------------------------------
-- The boolean type and some operations
open import Data.Bool.Base public
------------------------------------------------------------------------
-- Publicly re-export queries
open import Data.Bool.Properties public
using (_≟_)
------------------------------------------------------------------------
-- Some properties
decSetoid : DecSetoid _ _
decSetoid = PropEq.decSetoid _≟_
| 26.53125
| 72
| 0.42874
|
dfb384c7c5c00683e724b58d5f4114727818be4d
| 52
|
agda
|
Agda
|
agda.agda
|
Andaraz/hello-world
|
5434416e6b0468a4c06ff7575540f186c38fc58d
|
[
"MIT"
] | 3
|
2021-03-23T13:03:38.000Z
|
2021-06-24T03:20:51.000Z
|
agda.agda
|
Andaraz/hello-world
|
5434416e6b0468a4c06ff7575540f186c38fc58d
|
[
"MIT"
] | 1
|
2021-03-28T09:19:07.000Z
|
2021-03-28T09:19:58.000Z
|
agda.agda
|
Andaraz/hello-world
|
5434416e6b0468a4c06ff7575540f186c38fc58d
|
[
"MIT"
] | 1
|
2021-05-10T13:28:32.000Z
|
2021-05-10T13:28:32.000Z
|
open import IO
main = run (putStr "Hello, World!")
| 13
| 35
| 0.673077
|
0ba222165823f2d8c10f51b2c77908b03df20a66
| 587
|
agda
|
Agda
|
test/interaction/Issue3650.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue3650.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue3650.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
data Tm : Set where
tzero : Tm
tsucc : Tm → Tm
tdiff : Tm → Tm → Tm
variable
m n n' : Tm
data NotZero : Tm → Set where
nzsucc : NotZero (tsucc n)
nzdiff : NotZero (tdiff m n)
data Equal : Tm → Tm → Set where
esucc : NotZero n → Equal (tsucc (tdiff tzero n)) n
ediff : Equal n n' → Equal (tdiff m n) (tdiff m n')
data Foo : Tm → Set where
fleft : Foo m → Foo (tdiff m n)
frght : Foo n → Foo (tdiff m (tsucc n))
foo : Foo n → Equal n n' → Foo n'
foo (fleft f) e = {!!}
foo (frght (frght f)) (ediff (esucc nz)) = {!nz!} -- case-split on nz replaces nz with nzsucc
| 23.48
| 93
| 0.596252
|
a11a3706d070ea4ba09aff7d99aa90ea6543dc58
| 131
|
agda
|
Agda
|
proofs/AKS/Modular/Quotient.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | 1
|
2020-12-01T22:38:27.000Z
|
2020-12-01T22:38:27.000Z
|
proofs/AKS/Modular/Quotient.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | null | null | null |
proofs/AKS/Modular/Quotient.agda
|
mckeankylej/thesis
|
ddad4c0d5f384a0219b2177461a68dae06952dde
|
[
"MIT"
] | null | null | null |
module AKS.Modular.Quotient where
open import AKS.Modular.Quotient.Base public
open import AKS.Modular.Quotient.Properties public
| 26.2
| 50
| 0.847328
|
4ab11587a268587da464b724ee5662fce3dc05ec
| 3,341
|
agda
|
Agda
|
Streams/SizedStreams.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
Streams/SizedStreams.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
Streams/SizedStreams.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
open import Function
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P
open ≡-Reasoning
open import Data.Empty
open import Data.Unit
open import Data.Sum as Sum
open import Data.Product as Prod
record ℕ∞ : Set where
coinductive
field pred : ⊤ ⊎ ℕ∞
open ℕ∞ public
data-~ℕ∞~ : ⊤ ⊎ ℕ∞ → ⊤ ⊎ ℕ∞ → Set
record _~ℕ∞~_ (n m : ℕ∞) : Set where
coinductive
field
pred~ : data-~ℕ∞~ (pred n) (pred m)
open _~ℕ∞~_ public
data-~ℕ∞~ (inj₁ tt) (inj₁ tt) = ⊤
data-~ℕ∞~ (inj₁ tt) (inj₂ m') = ⊥
data-~ℕ∞~ (inj₂ n') (inj₁ tt) = ⊥
data-~ℕ∞~ (inj₂ n') (inj₂ m') = n' ~ℕ∞~ m'
refl-ℕ∞ : {n : ℕ∞} → n ~ℕ∞~ n
pred~ (refl-ℕ∞ {n}) with pred n
pred~ refl-ℕ∞ | inj₁ tt = tt
pred~ refl-ℕ∞ | inj₂ n' = refl-ℕ∞
∞ : ℕ∞
pred ∞ = inj₂ ∞
succ : ℕ∞ → ℕ∞
pred (succ n) = inj₂ n
_+∞_ : ℕ∞ → ℕ∞ → ℕ∞
pred (n +∞ m) with pred n | pred m
pred (n +∞ m) | inj₁ tt | inj₁ tt = inj₁ tt
pred (n +∞ m) | inj₁ tt | inj₂ m' = inj₂ m'
pred (n +∞ m) | inj₂ n' | inj₁ tt = inj₂ n'
pred (n +∞ m) | inj₂ n' | inj₂ m' = inj₂ (record { pred = inj₂ (n' +∞ m') })
+∞-comm : (n m : ℕ∞) → (n +∞ m) ~ℕ∞~ (m +∞ n)
pred~ (+∞-comm n m) with pred n | pred m
pred~ (+∞-comm n m) | inj₁ tt | inj₁ tt = tt
pred~ (+∞-comm n m) | inj₁ tt | inj₂ m' = refl-ℕ∞
pred~ (+∞-comm n m) | inj₂ n' | inj₁ tt = refl-ℕ∞
pred~ (+∞-comm n m) | inj₂ n' | inj₂ m'
= record { pred~ = +∞-comm n' m' }
2×_ : ℕ∞ → ℕ∞
pred (2× n) with pred n
pred (2× n) | inj₁ tt = inj₁ tt
pred (2× n) | inj₂ n' = inj₂ (record { pred = inj₂ (2× n') })
StrData : Set → (ℕ∞ → Set) → ⊤ ⊎ ℕ∞ → Set
StrData A F (inj₁ tt) = ⊤
StrData A F (inj₂ d') = A × F d'
record Str (A : Set) (d : ℕ∞) : Set where
coinductive
field
str-out : StrData A (Str A) (pred d)
open Str public
reidx-Str : ∀{n m A} → n ~ℕ∞~ m → Str A n → Str A m
str-out (reidx-Str {n} {m} p s) with pred n | pred m | pred~ p | str-out s
str-out (reidx-Str p s) | inj₁ tt | inj₁ tt | _ | _ = tt
str-out (reidx-Str p s) | inj₁ tt | inj₂ m' | () | _
str-out (reidx-Str p s) | inj₂ n' | inj₁ tt | () | _
str-out (reidx-Str p s) | inj₂ n' | inj₂ m' | q | (a , s')
= (a , reidx-Str q s')
tl : ∀{d A} → Str A (succ d) → Str A d
tl {d} s = proj₂ (str-out s)
tl₂ : ∀{d A} → Str A (succ (succ d)) → Str A d
tl₂ {d} s = proj₂ (str-out (proj₂ (str-out s)))
even : ∀{d A} → Str A (2× d) → Str A d
str-out (even {d} s) with pred d | str-out s
str-out (even s) | inj₁ tt | tt = tt
str-out (even s) | inj₂ d' | (a , s') with str-out s'
str-out (even s) | inj₂ d' | (a , s') | (_ , s'') = (a , even s'')
zip₂ : ∀{m n A} → Str A m → Str A n → Str A (m +∞ n)
str-out (zip₂ {m} {n} s t) with pred m | pred n | str-out s | str-out t
str-out (zip₂ s t) | inj₁ tt | inj₁ tt | tt | _ = tt
str-out (zip₂ s t) | inj₁ tt | inj₂ n' | tt | u = u
str-out (zip₂ s t) | inj₂ m' | inj₁ tt | (a , s') | tt = (a , s')
str-out (zip₂ s t) | inj₂ m' | inj₂ n' | (a , s') | (b , t')
= (a , record { str-out = (b , zip₂ s' t') })
𝔹 : Set
𝔹 = ⊤ ⊎ ⊤
l r : 𝔹
l = inj₁ tt
r = inj₂ tt
L R : Str 𝔹 ∞
str-out L = (l , L)
str-out R = (r , R)
restr : ∀{A} → Str A ∞ → (d : ℕ∞) → Str A d
str-out (restr s d) with pred d | str-out s
str-out (restr s d) | inj₁ tt | _ = tt
str-out (restr s d) | inj₂ d' | (a , s') = (a , restr s' d')
foo : ∀{d} → Str 𝔹 d
str-out (foo {d}) with pred d
str-out foo | inj₁ tt = tt
str-out foo | inj₂ d' = (l , even {!!})
| 28.313559
| 76
| 0.523496
|
a108f0c85174309b4c6156f0d09844008a1448b6
| 6,521
|
agda
|
Agda
|
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Oscar.Data.Term.internal.SubstituteAndSubstitution {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Category.Action
open import Oscar.Category.Category
open import Oscar.Category.CategoryAction
open import Oscar.Category.Functor
open import Oscar.Category.Morphism
open import Oscar.Category.Semifunctor
open import Oscar.Category.Semigroupoid
open import Oscar.Category.Setoid
open import Oscar.Category.SemigroupoidAction
open import Oscar.Data.Equality
open import Oscar.Data.Equality.properties
open import Oscar.Data.Fin
open import Oscar.Data.Nat
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Vec
open import Oscar.Function
open import Oscar.Level
open import Oscar.Relation
𝕞₁ : Morphism _ _ _
𝕞₁ = Fin ⇨ Term
𝕞₂ : Morphism _ _ _
𝕞₂ = Term ⇨ Term
𝕞₂ₛ : Nat → Morphism _ _ _
𝕞₂ₛ N = Terms N ⇨ Terms N
module 𝔐₁ = Morphism 𝕞₁
module 𝔐₂ = Morphism 𝕞₂
module 𝔐₂ₛ (N : Nat) where open Morphism (𝕞₂ₛ N) public using () renaming (_↦_ to _[_↦_])
private
infix 19 _◂_ _◂s_
mutual
_◂_ : ∀ {m n} → m 𝔐₁.↦ n → m 𝔐₂.↦ n
σ̇ ◂ i 𝑥 = σ̇ 𝑥
_ ◂ leaf = leaf
σ̇ ◂ (τl fork τr) = (σ̇ ◂ τl) fork (σ̇ ◂ τr)
σ̇ ◂ (function fn τs) = function fn (σ̇ ◂s τs) where
_◂s_ : ∀ {m n} → m ⊸ n → ∀ {N} → N 𝔐₂ₛ.[ m ↦ n ] -- Vec (Term m) N → Vec (Term n) N
f ◂s [] = []
f ◂s (t ∷ ts) = f ◂ t ∷ f ◂s ts
_∙_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n
_∙_ f g = (f ◂_) ∘ g
mutual
◂-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_
◂-extensionality p (i x) = p x
◂-extensionality p leaf = refl
◂-extensionality p (s fork t) = cong₂ _fork_ (◂-extensionality p s) (◂-extensionality p t)
◂-extensionality p (function fn ts) = cong (function fn) (◂s-extensionality p ts)
◂s-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → ∀ {N} → _◂s_ f {N} ≡̇ _◂s_ g
◂s-extensionality p [] = refl
◂s-extensionality p (t ∷ ts) = cong₂ _∷_ (◂-extensionality p t) (◂s-extensionality p ts)
mutual
◂-associativity : ∀ {l m} (f : l ⊸ m) {n} (g : m ⊸ n) → (g ∙ f) ◂_ ≡̇ (g ◂_) ∘ (f ◂_)
◂-associativity _ _ (i _) = refl
◂-associativity _ _ leaf = refl
◂-associativity _ _ (τ₁ fork τ₂) = cong₂ _fork_ (◂-associativity _ _ τ₁) (◂-associativity _ _ τ₂)
◂-associativity f g (function fn ts) = cong (function fn) (◂s-associativity f g ts)
◂s-associativity : ∀ {l m n} (f : l ⊸ m) (g : m ⊸ n) → ∀ {N} → (_◂s_ (g ∙ f) {N}) ≡̇ (g ◂s_) ∘ (f ◂s_)
◂s-associativity _ _ [] = refl
◂s-associativity _ _ (τ ∷ τs) = cong₂ _∷_ (◂-associativity _ _ τ) (◂s-associativity _ _ τs)
∙-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → (h ∙ g) ∙ f ≡̇ h ∙ (g ∙ f)
∙-associativity f g h x rewrite ◂-associativity g h (f x) = refl
∙-extensionality : ∀ {l m} {f₁ f₂ : l ⊸ m} → f₁ ≡̇ f₂ → ∀ {n} {g₁ g₂ : m ⊸ n} → g₁ ≡̇ g₂ → g₁ ∙ f₁ ≡̇ g₂ ∙ f₂
∙-extensionality {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = ◂-extensionality g₁≡̇g₂ (f₂ x)
instance
IsSemigroupoid𝕞₁∙ : IsSemigroupoid 𝕞₁ _∙_
IsSemigroupoid.extensionality IsSemigroupoid𝕞₁∙ = ∙-extensionality
IsSemigroupoid.associativity IsSemigroupoid𝕞₁∙ = ∙-associativity
𝕘₁ : Semigroupoid _ _ _
𝕘₁ = 𝕞₁ , _∙_
𝕘₂ : Semigroupoid _ _ _
𝕘₂ = 𝕞₂ , (λ ‵ → _∘_ ‵)
𝕘₂ₛ : Nat → Semigroupoid _ _ _
𝕘₂ₛ N = 𝕞₂ₛ N , (λ ‵ → _∘_ ‵)
𝕘₁,₂ : Semigroupoids _ _ _ _ _ _
𝕘₁,₂ = 𝕘₁ , 𝕘₂
instance
IsSemifunctor𝕘₁₂◂ : IsSemifunctor 𝕘₁,₂ _◂_
IsSemifunctor.extensionality IsSemifunctor𝕘₁₂◂ = ◂-extensionality
IsSemifunctor.distributivity IsSemifunctor𝕘₁₂◂ = ◂-associativity
𝕗◂ : Semifunctor _ _ _ _ _ _
𝕗◂ = 𝕘₁,₂ , _◂_
𝕘₁,₂ₛ : Nat → Semigroupoids _ _ _ _ _ _
𝕘₁,₂ₛ N = 𝕘₁ , 𝕘₂ₛ N
instance
IsSemifunctor𝕘₁,₂ₛ◂s : ∀ {N} → IsSemifunctor (𝕘₁,₂ₛ N) (λ ‵ → _◂s_ ‵)
IsSemifunctor.extensionality IsSemifunctor𝕘₁,₂ₛ◂s f≡̇g τs = ◂s-extensionality f≡̇g τs
IsSemifunctor.distributivity IsSemifunctor𝕘₁,₂ₛ◂s f g x = ◂s-associativity f g x
𝕗◂s : Nat → Semifunctor _ _ _ _ _ _
𝕗◂s N = 𝕘₁,₂ₛ N , (λ ‵ → _◂s_ ‵)
𝕒₂ : Action _ _ _
𝕒₂ = actionΣ Term
𝕒₂ₛ : Nat → Action _ _ _
𝕒₂ₛ N = actionΣ (Terms N)
instance
IsSemigroupoidAction𝕘₁𝕒₂◂ : IsSemigroupoidAction 𝕘₁ 𝕒₂ _◂_
IsSemigroupoidAction.extensionality IsSemigroupoidAction𝕘₁𝕒₂◂ {s₁ = s₁} refl f₁≡̇f₂ = ◂-extensionality f₁≡̇f₂ s₁
IsSemigroupoidAction.associativity IsSemigroupoidAction𝕘₁𝕒₂◂ s f g = ◂-associativity f g s
IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s : ∀ {N} → IsSemigroupoidAction 𝕘₁ (𝕒₂ₛ N) (λ ‵ → _◂s_ ‵)
IsSemigroupoidAction.extensionality IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s {s₁ = s₁} refl f₁≡̇f₂ = ◂s-extensionality f₁≡̇f₂ s₁
IsSemigroupoidAction.associativity IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s s f g = ◂s-associativity f g s
𝕟◂ : SemigroupoidAction _ _ _ _ _
𝕟◂ = [ 𝕘₁ / 𝕒₂ ] _◂_
𝕟◂s : Nat → SemigroupoidAction _ _ _ _ _
𝕟◂s N = [ 𝕘₁ / 𝕒₂ₛ N ] (λ ‵ → _◂s_ ‵)
private
ε : ∀ {m} → m ⊸ m
ε = i
mutual
◂-identity : ∀ {m} (t : Term m) → ε ◂ t ≡ t
◂-identity (i x) = refl
◂-identity leaf = refl
◂-identity (s fork t) = cong₂ _fork_ (◂-identity s) (◂-identity t)
◂-identity (function fn ts) = cong (function fn) (◂s-identity ts)
◂s-identity : ∀ {N m} (t : Vec (Term m) N) → ε ◂s t ≡ t
◂s-identity [] = refl
◂s-identity (t ∷ ts) = cong₂ _∷_ (◂-identity t) (◂s-identity ts)
∙-left-identity : ∀ {m n} (f : m ⊸ n) → ε ∙ f ≡̇ f
∙-left-identity f = ◂-identity ∘ f
∙-right-identity : ∀ {m n} (f : m ⊸ n) → f ∙ ε ≡̇ f
∙-right-identity _ _ = refl
instance
IsCategory𝕘₁ε : IsCategory 𝕘₁ ε
IsCategory.left-identity IsCategory𝕘₁ε = ∙-left-identity
IsCategory.right-identity IsCategory𝕘₁ε = ∙-right-identity
𝔾₁ : Category _ _ _
𝔾₁ = 𝕘₁ , ε
𝔾₂ : Category _ _ _
𝔾₂ = 𝕘₂ , id
𝔾₂ₛ : Nat → Category _ _ _
𝔾₂ₛ N = 𝕘₂ₛ N , id
𝔾₁,₂ : Categories _ _ _ _ _ _
𝔾₁,₂ = 𝔾₁ , 𝔾₂
𝔾₁,₂ₛ : Nat → Categories _ _ _ _ _ _
𝔾₁,₂ₛ N = 𝔾₁ , 𝔾₂ₛ N
instance
IsFunctor𝔾₁,₂◂ : IsFunctor 𝔾₁,₂ _◂_
IsFunctor.identity IsFunctor𝔾₁,₂◂ _ = ◂-identity
𝔽◂ : Functor _ _ _ _ _ _
𝔽◂ = 𝔾₁,₂ , _◂_
instance
IsFunctor𝔾₁,₂ₛ◂ : ∀ {N} → IsFunctor (𝔾₁,₂ₛ N) (λ ‵ → _◂s_ ‵)
IsFunctor.identity IsFunctor𝔾₁,₂ₛ◂ _ = ◂s-identity -- ◂-identity
𝔽s : Nat → Functor _ _ _ _ _ _
𝔽s N = 𝔾₁,₂ₛ N , (λ ‵ → _◂s_ ‵)
instance
IsCategoryAction𝔾₁𝕒₂◂ : IsCategoryAction 𝔾₁ 𝕒₂ _◂_
IsCategoryAction.identity IsCategoryAction𝔾₁𝕒₂◂ = ◂-identity
IsCategoryAction𝔾₁𝕒₂ₛ◂s : ∀ {N} → IsCategoryAction 𝔾₁ (𝕒₂ₛ N) (λ ‵ → _◂s_ ‵)
IsCategoryAction.identity IsCategoryAction𝔾₁𝕒₂ₛ◂s = ◂s-identity
ℕ◂ : CategoryAction _ _ _ _ _
ℕ◂ = [ 𝔾₁ / 𝕒₂ ] _◂_
ℕ◂s : Nat → CategoryAction _ _ _ _ _
ℕ◂s N = [ 𝔾₁ / 𝕒₂ₛ N ] (λ ‵ → _◂s_ ‵)
| 29.776256
| 117
| 0.625671
|
50b1dbd0bd051d8be904aafb31c4d3eb08bf945c
| 473
|
agda
|
Agda
|
test/Succeed/Issue1719.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1719.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1719.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K --rewriting --confluence-check #-}
open import Issue1719.Common
open import Issue1719.Spans
open import Issue1719.Pushouts
module _ {d : Span} {l} {P : Pushout d → Set l}
(left* : (a : Span.A d) → P (left a))
(right* : (b : Span.B d) → P (right b))
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c) [ P ↓ glue c ]) where
test : (a : Span.A d) → Pushout-elim {P = P} left* right* glue* (left a) ↦ left* a
test a = idr
| 31.533333
| 91
| 0.585624
|
4a5b428a85b4f35b4001459c4ae2c53eb170ddcb
| 144
|
agda
|
Agda
|
test/Succeed/Issue586.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue586.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue586.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Run this test case in safe mode
-- {-# OPTIONS --safe #-} -- does not parse (2012-03-12 Andreas)
module Issue586 where
Foo : Set1
Foo = Set
| 20.571429
| 64
| 0.659722
|
06079f7a5fde6eb86489bde8b4d0ff0ed72de167
| 403
|
agda
|
Agda
|
archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Oscar/Data/ProperlyExtensionNothing.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Oscar.Prelude
open import Oscar.Data.𝟘
module Oscar.Data.ProperlyExtensionNothing where
module _
{𝔵} {𝔛 : Ø 𝔵}
{𝔬} {𝔒 : 𝔛 → Ø 𝔬}
{ℓ}
{ℓ̇} {_↦_ : ∀ {x} → 𝔒 x → 𝔒 x → Ø ℓ̇}
where
record ProperlyExtensionNothing (P : ExtensionṖroperty ℓ 𝔒 _↦_) : Ø 𝔵 ∙̂ 𝔬 ∙̂ ℓ where
constructor ∁
field
π₀ : ∀ {n} {f : 𝔒 n} → π₀ (π₀ P) f → 𝟘
open ProperlyExtensionNothing public
| 20.15
| 88
| 0.600496
|
4de670d81f9a72f2403e25e6e06a4f1a6ec3563a
| 2,958
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Membership/Propositional/Properties/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Membership/Propositional/Properties/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Membership/Propositional/Properties/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Core properties related to propositional list membership.
------------------------------------------------------------------------
-- This file is needed to break the cyclic dependency with the proof
-- `Any-cong` in `Data.Any.Properties` which relies on `Any↔` in this
-- file.
{-# OPTIONS --without-K --safe #-}
module Data.List.Membership.Propositional.Properties.Core where
open import Function.Base using (flip; id; _∘_)
open import Function.Inverse using (_↔_; inverse)
open import Data.List.Base using (List)
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
open import Data.List.Membership.Propositional
open import Data.Product as Prod
using (_,_; proj₁; proj₂; uncurry′; ∃; _×_)
open import Level using (Level)
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl)
open import Relation.Unary using (Pred; _⊆_)
private
variable
a p q : Level
A : Set a
------------------------------------------------------------------------
-- Lemmas relating map and find.
map∘find : ∀ {P : Pred A p} {xs}
(p : Any P xs) → let p′ = find p in
{f : _≡_ (proj₁ p′) ⊆ P} →
f refl ≡ proj₂ (proj₂ p′) →
Any.map f (proj₁ (proj₂ p′)) ≡ p
map∘find (here p) hyp = P.cong here hyp
map∘find (there p) hyp = P.cong there (map∘find p hyp)
find∘map : ∀ {P : Pred A p} {Q : Pred A q}
{xs : List A} (p : Any P xs) (f : P ⊆ Q) →
find (Any.map f p) ≡ Prod.map id (Prod.map id f) (find p)
find∘map (here p) f = refl
find∘map (there p) f rewrite find∘map p f = refl
------------------------------------------------------------------------
-- find satisfies a simple equality when the predicate is a
-- propositional equality.
find-∈ : ∀ {x : A} {xs : List A} (x∈xs : x ∈ xs) →
find x∈xs ≡ (x , x∈xs , refl)
find-∈ (here refl) = refl
find-∈ (there x∈xs) rewrite find-∈ x∈xs = refl
------------------------------------------------------------------------
-- find and lose are inverses (more or less).
lose∘find : ∀ {P : Pred A p} {xs : List A}
(p : Any P xs) →
uncurry′ lose (proj₂ (find p)) ≡ p
lose∘find p = map∘find p P.refl
find∘lose : ∀ (P : Pred A p) {x xs}
(x∈xs : x ∈ xs) (pp : P x) →
find {P = P} (lose x∈xs pp) ≡ (x , x∈xs , pp)
find∘lose P x∈xs p
rewrite find∘map x∈xs (flip (P.subst P) p)
| find-∈ x∈xs
= refl
------------------------------------------------------------------------
-- Any can be expressed using _∈_
module _ {P : Pred A p} where
∃∈-Any : ∀ {xs} → (∃ λ x → x ∈ xs × P x) → Any P xs
∃∈-Any = uncurry′ lose ∘ proj₂
Any↔ : ∀ {xs} → (∃ λ x → x ∈ xs × P x) ↔ Any P xs
Any↔ = inverse ∃∈-Any find from∘to lose∘find
where
from∘to : ∀ v → find (∃∈-Any v) ≡ v
from∘to p = find∘lose _ (proj₁ (proj₂ p)) (proj₂ (proj₂ p))
| 34
| 72
| 0.503381
|
1241eeb7ac79c1cc1772efb834b23c3af04095d9
| 503
|
agda
|
Agda
|
test/Succeed/Issue1456.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1456.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1456.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
record Ord (A : Set) : Set where
field f : A → A
instance
OrdNat : Ord Nat
OrdNat = record { f = λ x → x }
postulate
T : Nat → Set
R : ∀ {A} {{_ : Ord A}} → A → Set
-- Before solving the type of m, instance search considers it to
-- be a potential candidate for Ord Nat. It then proceeds to check
-- uniqueness by comparing m and OrdNat. The problem was that this
-- left a constraint m == OrdNat that leaked into the state.
foo : Set
foo = ∀ (n : Nat) m → R n → T m
| 23.952381
| 66
| 0.640159
|
4d8824685a5bd83a2547f19d78a0620c10f8d129
| 1,582
|
agda
|
Agda
|
src/Haskell/Modules/Eq.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Haskell/Modules/Eq.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Haskell/Modules/Eq.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
module Haskell.Modules.Eq where
open import Haskell.Modules.ToBool
------------------------------------------------------------------------------
open import Data.Bool hiding (_≟_; not)
open import Data.List as DL
open import Data.Maybe using (Maybe; just; nothing)
import Data.Nat as DN
open import Function using (_$_; _∘_)
import Relation.Binary.PropositionalEquality as PE using (_≡_; refl)
import Relation.Nullary as RN
record Eq {a} (A : Set a) : Set a where
infix 4 _≟_ _==_ _/=_
field
_≟_ : (a b : A) → RN.Dec (a PE.≡ b)
_==_ : A → A → Bool
a == b = toBool $ a ≟ b
_/=_ : A → A → Bool
a /= b = not (a == b)
open Eq ⦃ ... ⦄ public
import Data.List.Relation.Unary.Any as Any using (any)
elem : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ → A → DL.List A → Bool
elem x = toBool ∘ Any.any (x ≟_)
instance
Eq-Nat : Eq DN.ℕ
Eq._≟_ Eq-Nat = DN._≟_
Eq-Maybe : ∀ {a} {A : Set a} ⦃ _ : Eq A ⦄ → Eq (Maybe A)
Eq._≟_ Eq-Maybe nothing nothing = RN.yes PE.refl
Eq._≟_ Eq-Maybe (just _) nothing = RN.no λ ()
Eq._≟_ Eq-Maybe nothing (just _) = RN.no λ ()
Eq._≟_ Eq-Maybe (just a) (just b)
with a ≟ b
... | RN.no proof = RN.no λ where PE.refl → proof PE.refl
... | RN.yes PE.refl = RN.yes PE.refl
| 32.285714
| 111
| 0.557522
|
4dc63128accbf3a15d9a8d69cb8822f6aee1d85b
| 280
|
agda
|
Agda
|
test/fail/IrrelevantLevelToSet.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/fail/IrrelevantLevelToSet.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/IrrelevantLevelToSet.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --experimental-irrelevance #-}
{-# OPTIONS --universe-polymorphism #-}
module IrrelevantLevelToSet where
open import Imports.Level
-- should fail, because Set i /= Set j for i /= j, so i is not irrelevant in Set i
MySet : .(i : Level) -> Set (suc i)
MySet i = Set i
| 28
| 82
| 0.685714
|
dc072c78f0fa5072ca7c198acc3a1275acd55486
| 1,032
|
agda
|
Agda
|
test/Succeed/Issue4142.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4142.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4142.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-10-21, issue #4142, reported and test case by Jason Hu
-- When the record-expression-to-copattern-translation is revisited
-- after positivity checking, the defCopatternLHS flag needs to be
-- updated as well!
-- {-# OPTIONS -v tc.cc.record:20 #-}
-- {-# OPTIONS -v tc.conv:30 #-}
open import Agda.Builtin.Equality
record WrapSet : Set1 where
constructor wrap
-- eta-equality -- WAS: needed for test
field
Wrapped : Set
eta : WrapSet
eta .Wrapped = Wrapped
pack : WrapSet
pack = record { Wrapped = Wrapped }
-- The positivity check makes WrapSet an eta-record after the fact.
-- Thus, the record-expression-to-copattern-translation is run again for pack.
open WrapSet
-- Make sure eta was inferred correctly for WrapSet
hasEta : (w : WrapSet) → w ≡ record{ Wrapped = Wrapped w }
hasEta w = refl
-- When we have a definition by copattern matching it works.
works : (w : WrapSet) → w ≡ eta w
works w = refl
-- Should also work for pack.
test : (w : WrapSet) → w ≡ pack w
test w = refl
| 24
| 78
| 0.695736
|
dc270a9e313fa0ed52243dfc90c68fd1f291f22e
| 315
|
agda
|
Agda
|
test/Fail/Issue1025.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1025.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1025.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K #-}
module Issue1025 where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
postulate mySpace : Set
postulate myPoint : mySpace
data Foo : myPoint ≡ myPoint → Set where
foo : Foo refl
test : {e : myPoint ≡ myPoint} → (a : Foo e) → (i : a ≡ a) → i ≡ refl
test foo refl = {!!}
| 19.6875
| 69
| 0.590476
|
1247ef967e7f662e56abc06fb96ac885f21bc374
| 1,425
|
agda
|
Agda
|
cohomology/ExactPairIso.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
cohomology/ExactPairIso.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
cohomology/ExactPairIso.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.Exactness
module cohomology.ExactPairIso where
{- An exact sequence 0 → G → H → 0 implies that G == H -}
module _ {i} {G H K L : Group i} {φ : H →ᴳ K}
(ex : ExactSeq (G ⟨ cst-hom ⟩→ H ⟨ φ ⟩→ K ⟨ cst-hom ⟩→ L ⊣|)) where
private
inj : (h₁ h₂ : Group.El H) → GroupHom.f φ h₁ == GroupHom.f φ h₂ → h₁ == h₂
inj = zero-kernel-injective φ
(λ h p → Trunc-rec (Group.El-level H _ _) (λ s → ! (snd s))
(ktoi (exact-get ex 0) h p))
exact-pair-iso : H == K
exact-pair-iso = surj-inj-= φ inj (λ k → ktoi (exact-get ex 1) k idp)
module _ {i} {G H K J : Group i} {φ : G →ᴳ H} {ψ : H →ᴳ K}
{χ : K →ᴳ J} (p : G == 0ᴳ) (q : J == 0ᴳ)
(ex : ExactSeq (G ⟨ φ ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)) where
private
ex₁ : ExactSeq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)
ex₁ = transport
(λ {(G' , φ') → ExactSeq (G' ⟨ φ' ⟩→ H ⟨ ψ ⟩→ K ⟨ χ ⟩→ J ⊣|)})
(pair= p (prop-has-all-paths-↓ {B = λ L → L →ᴳ H}
(raise-level ⟨-2⟩ 0ᴳ-hom-out-level)))
ex
ex₂ : ExactSeq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ cst-hom ⟩→ 0ᴳ ⊣|)
ex₂ = transport
(λ {(J' , χ') → ExactSeq (0ᴳ ⟨ cst-hom ⟩→ H ⟨ ψ ⟩→ K ⟨ χ' ⟩→ J' ⊣|)})
(pair= q (prop-has-all-paths-↓ {B = λ L → K →ᴳ L}
(raise-level _ 0ᴳ-hom-in-level)))
ex₁
exact-pair-path-iso : H == K
exact-pair-path-iso = exact-pair-iso ex₂
| 33.139535
| 78
| 0.489123
|
0b0308d0906ac54dbf147665b7b7ebcd73a28867
| 1,061
|
agda
|
Agda
|
Lambda/Substitution/TwoSemantics.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | 1
|
2021-02-13T14:48:45.000Z
|
2021-02-13T14:48:45.000Z
|
Lambda/Substitution/TwoSemantics.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
Lambda/Substitution/TwoSemantics.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The two big-step semantics given by Leroy and Grall in "Coinductive
-- big-step operational semantics"
------------------------------------------------------------------------
module Lambda.Substitution.TwoSemantics where
open import Codata.Musical.Notation
open import Lambda.Syntax
open WHNF
open import Lambda.Substitution
-- Big-step semantics for terminating computations.
infix 4 _⇓_
data _⇓_ {n} : Tm n → Value n → Set where
val : ∀ {v} → ⌜ v ⌝ ⇓ v
app : ∀ {t₁ t₂ t v v′}
(t₁⇓ : t₁ ⇓ ƛ t)
(t₂⇓ : t₂ ⇓ v)
(t₁t₂⇓ : t / sub ⌜ v ⌝ ⇓ v′) →
t₁ · t₂ ⇓ v′
-- Big-step semantics for non-terminating computations.
infix 4 _⇑
data _⇑ {n} : Tm n → Set where
·ˡ : ∀ {t₁ t₂}
(t₁⇑ : ∞ (t₁ ⇑)) →
t₁ · t₂ ⇑
·ʳ : ∀ {t₁ t₂ v}
(t₁⇓ : t₁ ⇓ v)
(t₂⇑ : ∞ (t₂ ⇑)) →
t₁ · t₂ ⇑
app : ∀ {t₁ t₂ t v}
(t₁⇓ : t₁ ⇓ ƛ t)
(t₂⇓ : t₂ ⇓ v)
(t₁t₂⇓ : ∞ (t / sub ⌜ v ⌝ ⇑)) →
t₁ · t₂ ⇑
| 24.674419
| 72
| 0.435438
|
1291a8a82bd28abc62c612941f3a2d3ca1488ed5
| 329
|
agda
|
Agda
|
examples/Termination/TerminationTwoConstructors.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/Termination/TerminationTwoConstructors.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/Termination/TerminationTwoConstructors.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --termination-depth=2 #-}
module TerminationTwoConstructors where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
f : Nat -> Nat
f zero = zero
f (suc zero) = zero
f (suc (suc n)) with zero
... | m = f (suc n)
{- this type checks with --termination-depth >= 2
calls:
f -> f_with (-2)
f_with -> f (+1)
-}
| 14.954545
| 49
| 0.601824
|
12785d891f556a28ce085d62366f34593898b359
| 1,521
|
agda
|
Agda
|
agda-stdlib/src/Data/DifferenceVec.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/DifferenceVec.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/DifferenceVec.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Vectors with fast append
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.DifferenceVec where
open import Data.DifferenceNat
open import Data.Vec.Base as V using (Vec)
open import Function
import Data.Nat.Base as N
infixr 5 _∷_ _++_
DiffVec : ∀ {ℓ} → Set ℓ → Diffℕ → Set ℓ
DiffVec A m = ∀ {n} → Vec A n → Vec A (m n)
[] : ∀ {a} {A : Set a} → DiffVec A 0#
[] = λ k → k
_∷_ : ∀ {a} {A : Set a} {n} → A → DiffVec A n → DiffVec A (suc n)
x ∷ xs = λ k → V._∷_ x (xs k)
[_] : ∀ {a} {A : Set a} → A → DiffVec A 1#
[ x ] = x ∷ []
_++_ : ∀ {a} {A : Set a} {m n} →
DiffVec A m → DiffVec A n → DiffVec A (m + n)
xs ++ ys = λ k → xs (ys k)
toVec : ∀ {a} {A : Set a} {n} → DiffVec A n → Vec A (toℕ n)
toVec xs = xs V.[]
-- fromVec xs is linear in the length of xs.
fromVec : ∀ {a} {A : Set a} {n} → Vec A n → DiffVec A (fromℕ n)
fromVec xs = λ k → xs ⟨ V._++_ ⟩ k
head : ∀ {a} {A : Set a} {n} → DiffVec A (suc n) → A
head xs = V.head (toVec xs)
tail : ∀ {a} {A : Set a} {n} → DiffVec A (suc n) → DiffVec A n
tail xs = λ k → V.tail (xs k)
take : ∀ {a} {A : Set a} m {n} →
DiffVec A (fromℕ m + n) → DiffVec A (fromℕ m)
take N.zero xs = []
take (N.suc m) xs = head xs ∷ take m (tail xs)
drop : ∀ {a} {A : Set a} m {n} →
DiffVec A (fromℕ m + n) → DiffVec A n
drop N.zero xs = xs
drop (N.suc m) xs = drop m (tail xs)
| 26.684211
| 72
| 0.480605
|
a1f4b66a57714e88541851488a3f6b1d460a82f5
| 503
|
agda
|
Agda
|
LibraBFT/Impl/OBM/Prelude.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 4
|
2020-12-16T19:43:41.000Z
|
2021-12-18T19:24:05.000Z
|
LibraBFT/Impl/OBM/Prelude.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 72
|
2021-02-04T05:04:33.000Z
|
2022-03-25T05:36:11.000Z
|
LibraBFT/Impl/OBM/Prelude.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 6
|
2020-12-16T19:43:52.000Z
|
2022-02-18T01:04:32.000Z
|
{- 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
-}
open import LibraBFT.Base.KVMap as Map
open import LibraBFT.Prelude
module LibraBFT.Impl.OBM.Prelude where
lookupOrInsert : ∀ {K V : Set} → K → V → Map.KVMap K V → Map.KVMap K V
lookupOrInsert k v m =
if Map.kvm-member k m
then m
else Map.insert k v m
| 29.588235
| 111
| 0.735586
|
392fa60e7c95956e61144a43ab79c261e8437dfa
| 261
|
agda
|
Agda
|
src/cpnd1/Data/Nat/FromNat.agda
|
wenkokke/nodcap
|
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
|
[
"MIT"
] | 4
|
2018-09-05T08:58:11.000Z
|
2019-09-24T20:16:35.000Z
|
src/cpnd1/Data/Nat/FromNat.agda
|
pepijnkokke/nodcap
|
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
|
[
"MIT"
] | null | null | null |
src/cpnd1/Data/Nat/FromNat.agda
|
pepijnkokke/nodcap
|
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
|
[
"MIT"
] | 1
|
2018-09-05T08:58:13.000Z
|
2018-09-05T08:58:13.000Z
|
open import Agda.Builtin.Nat
open import Agda.Builtin.FromNat
open import Data.Unit using (⊤)
open import Function using (const)
module Data.Nat.FromNat where
instance
NumberNat : Number Nat
NumberNat = record { Constraint = const ⊤ ; fromNat = λ n → n }
| 23.727273
| 65
| 0.743295
|
5060e93c2fc3eba349b83f5433ef299093820dca
| 6,279
|
agda
|
Agda
|
theorems/cw/cohomology/cellular/ChainComplex.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/cellular/ChainComplex.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/cellular/ChainComplex.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import cw.DegreeByProjection
open import cohomology.ChainComplex
module cw.cohomology.cellular.ChainComplex {i : ULevel} where
chain-template : ∀ {n} (skel : Skeleton {i} n) {m}
→ Dec (m ≤ n) → AbGroup i
chain-template skel (inl m≤n) = FreeAbGroup (cells-nth m≤n skel)
chain-template skel (inr _) = Lift-abgroup {j = i} Unit-abgroup
abstract
boundary-nth-template : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ {m : ℕ} (m≤n : m ≤ n) (Sm≤n : S m ≤ n)
→ cw-init (cw-take Sm≤n skel) == cw-take (≤-trans lteS Sm≤n) skel
→ cw-take (≤-trans lteS Sm≤n) skel == cw-take m≤n skel
→ FreeAbGroup.grp (cells-nth Sm≤n skel)
→ᴳ FreeAbGroup.grp (cells-nth m≤n skel)
boundary-nth-template skel dec fin-sup m≤n Sm≤n path₀ path₁ =
transportᴳ (λ lower-skel → FreeAbGroup.grp (cells-last lower-skel)) (path₀ ∙ path₁)
∘ᴳ boundary-nth Sm≤n skel dec fin-sup
boundary-template : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ AbGroup.grp (chain-template skel Sm≤n?)
→ᴳ AbGroup.grp (chain-template skel m≤n?)
boundary-template skel dec fin-sup _ (inr _) = cst-hom
boundary-template skel dec fin-sup (inr m≰n) (inl Sm≤n) = ⊥-rec $ m≰n (≤-trans lteS Sm≤n)
boundary-template skel dec fin-sup (inl m≤n) (inl Sm≤n) =
boundary-nth-template skel dec fin-sup m≤n Sm≤n (cw-init-take Sm≤n skel)
(ap (λ m≤n → cw-take m≤n skel) (≤-has-all-paths (≤-trans lteS Sm≤n) m≤n))
chain-complex : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ ChainComplex i
chain-complex {n} skel dec fin-sup = record {M} where
module M where
head : AbGroup i
head = Lift-abgroup {j = i} ℤ-abgroup
chain : ℕ → AbGroup i
chain m = chain-template skel (≤-dec m n)
augment : AbGroup.grp (chain 0) →ᴳ AbGroup.grp head
augment = FreeAbGroup-extend head λ _ → lift 1
boundary : ∀ m → (AbGroup.grp (chain (S m)) →ᴳ AbGroup.grp (chain m))
boundary m = boundary-template skel dec fin-sup (≤-dec m n) (≤-dec (S m) n)
cochain-complex : ∀ {j} {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ AbGroup j → CochainComplex (lmax i j)
cochain-complex skel dec fin-sup G = complex-dualize
(chain-complex skel dec fin-sup) G
{- properties of coboundaries -}
abstract
private
path-lemma₀ : ∀ {n} (skel : Skeleton {i} (S n)) {m} (m<n : m < n) (Sm<n : S m < n)
→ ap (λ m≤Sn → cw-take m≤Sn skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
== ap (λ m≤n → cw-take m≤n (cw-init skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
path-lemma₀ skel m<n Sm<n =
ap (λ m≤Sn → cw-take m≤Sn skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
=⟨ ap (ap (λ m≤Sn → cw-take m≤Sn skel)) (contr-has-all-paths _ _) ⟩
ap (λ m≤Sn → cw-take m≤Sn skel) (ap (lteSR ∘ inr) (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ∘-ap (λ m≤Sn → cw-take m≤Sn skel) (lteSR ∘ inr) _ ⟩
ap (λ Sm<n → cw-take (lteSR (inr Sm<n)) skel) (<-has-all-paths (<-trans ltS Sm<n) m<n)
=⟨ ap-∘ (λ m≤n → cw-take m≤n (cw-init skel)) inr _ ⟩
ap (λ m≤n → cw-take m≤n (cw-init skel)) (ap inr (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ap (ap (λ m≤n → cw-take m≤n (cw-init skel))) (contr-has-all-paths _ _) ⟩
ap (λ m≤n → cw-take m≤n (cw-init skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
=∎
path-lemma₁ : ∀ {n} (skel : Skeleton {i} (S (S n)))
→ ap (λ n≤SSn → cw-take n≤SSn skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
== ap (λ n≤Sn → cw-take n≤Sn (cw-init skel)) (≤-has-all-paths lteS lteS)
path-lemma₁ skel =
ap (λ n≤SSn → cw-take n≤SSn skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
=⟨ ap (ap (λ n≤SSn → cw-take n≤SSn skel)) (contr-has-all-paths _ _) ⟩
idp
=⟨ ap (ap (λ n≤Sn → cw-take n≤Sn (cw-init skel))) (contr-has-all-paths _ _) ⟩
ap (λ n≤Sn → cw-take n≤Sn (cw-init skel)) (≤-has-all-paths lteS lteS)
=∎
path-lemma₂ : ∀ {n} (skel : Skeleton {i} (S n))
→ ap (λ n≤Sn → cw-take n≤Sn skel) (≤-has-all-paths lteS lteS) == idp
path-lemma₂ skel =
ap (λ n≤Sn → cw-take n≤Sn skel) (≤-has-all-paths lteS lteS)
=⟨ ap (ap (λ n≤Sn → cw-take n≤Sn skel)) (contr-has-all-paths _ _) ⟩
idp
=∎
abstract
boundary-template-descend-from-far : ∀ {n} (skel : Skeleton {i} (S n)) dec fin-sup {m} m<n Sm<n
→ boundary-template {n = S n} skel dec fin-sup {m} (inl (lteSR (inr m<n))) (inl (lteSR (inr Sm<n)))
== boundary-template {n = n} (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
(inl (inr m<n)) (inl (inr Sm<n))
boundary-template-descend-from-far skel dec fin-sup m<n Sm<n =
ap (boundary-nth-template skel dec fin-sup (lteSR (inr m<n)) (lteSR (inr Sm<n)) (cw-init-take (lteSR (inr Sm<n)) skel))
(path-lemma₀ skel m<n Sm<n)
boundary-template-descend-from-two-above : ∀ {n} (skel : Skeleton {i} (S (S n))) dec fin-sup
→ boundary-template {n = S (S n)} skel dec fin-sup (inl (lteSR lteS)) (inl lteS)
== boundary-template {n = (S n)} (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
(inl lteS) (inl lteE)
boundary-template-descend-from-two-above skel dec fin-sup =
ap (boundary-nth-template skel dec fin-sup (lteSR lteS) lteS idp) (path-lemma₁ skel)
boundary-template-β : ∀ {n} (skel : Skeleton {i} (S n)) dec fin-sup
→ boundary-template {n = S n} skel dec fin-sup (inl lteS) (inl lteE)
== FreeAbGroup-extend
(FreeAbGroup (cells-last (cw-init skel)))
(boundary'-last skel dec fin-sup)
boundary-template-β skel dec fin-sup = group-hom= $
ap (GroupHom.f ∘ boundary-nth-template skel dec fin-sup lteS lteE idp) (path-lemma₂ skel)
| 49.833333
| 125
| 0.583851
|
3179ed6b777838d8d217a9e7974f92c49ac21a55
| 10,688
|
agda
|
Agda
|
lib/types/LoopSpace.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
lib/types/LoopSpace.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
lib/types/LoopSpace.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NConnected
open import lib.types.Nat
open import lib.types.TLevel
open import lib.types.Empty
open import lib.types.Group
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Paths
open import lib.types.Sigma
open import lib.types.Truncation
open import lib.cubical.Square
module lib.types.LoopSpace where
module _ {i} where
⊙Ω : Ptd i → Ptd i
⊙Ω (A , a) = ⊙[ (a == a) , idp ]
Ω : Ptd i → Type i
Ω = fst ∘ ⊙Ω
⊙Ω^ : (n : ℕ) → Ptd i → Ptd i
⊙Ω^ O X = X
⊙Ω^ (S n) X = ⊙Ω (⊙Ω^ n X)
Ω^ : (n : ℕ) → Ptd i → Type i
Ω^ n X = fst (⊙Ω^ n X)
idp^ : ∀ {i} (n : ℕ) {X : Ptd i} → Ω^ n X
idp^ n {X} = snd (⊙Ω^ n X)
{- for n ≥ 1, we have a group structure on the loop space -}
module _ {i} where
!^ : (n : ℕ) (t : n ≠ O) {X : Ptd i} → Ω^ n X → Ω^ n X
!^ O t = ⊥-rec (t idp)
!^ (S n) _ = !
conc^ : (n : ℕ) (t : n ≠ O) {X : Ptd i} → Ω^ n X → Ω^ n X → Ω^ n X
conc^ O t = ⊥-rec (t idp)
conc^ (S n) _ = _∙_
{- pointed versions of functions on paths -}
private
pt-lemma : ∀ {i} {A : Type i} {x y : A} (p : x == y)
→ ! p ∙ (idp ∙' p) == idp
pt-lemma idp = idp
⊙conc : ∀ {i} {X : Ptd i} → fst (⊙Ω X ⊙× ⊙Ω X ⊙→ ⊙Ω X)
⊙conc = (uncurry _∙_ , idp)
⊙ap : ∀ {i j} {X : Ptd i} {Y : Ptd j}
→ fst (X ⊙→ Y) → fst (⊙Ω X ⊙→ ⊙Ω Y)
⊙ap (f , fpt) = ((λ p → ! fpt ∙ ap f p ∙' fpt) , pt-lemma fpt)
⊙ap2 : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
→ fst (X ⊙× Y ⊙→ Z) → fst (⊙Ω X ⊙× ⊙Ω Y ⊙→ ⊙Ω Z)
⊙ap2 (f , fpt) = ((λ {(p , q) → ! fpt ∙ ap2 (curry f) p q ∙' fpt}) ,
pt-lemma fpt)
⊙ap-∘ : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y))
→ ⊙ap (g ⊙∘ f) == ⊙ap g ⊙∘ ⊙ap f
⊙ap-∘ (g , idp) (f , idp) = ⊙λ= (λ p → ap-∘ g f p) idp
⊙ap-idf : ∀ {i} {X : Ptd i} → ⊙ap (⊙idf X) == ⊙idf _
⊙ap-idf = ⊙λ= ap-idf idp
⊙ap2-fst : ∀ {i j} {X : Ptd i} {Y : Ptd j}
→ ⊙ap2 {X = X} {Y = Y} ⊙fst == ⊙fst
⊙ap2-fst = ⊙λ= (uncurry ap2-fst) idp
⊙ap2-snd : ∀ {i j} {X : Ptd i} {Y : Ptd j}
→ ⊙ap2 {X = X} {Y = Y} ⊙snd == ⊙snd
⊙ap2-snd = ⊙λ= (uncurry ap2-snd) idp
⊙ap-ap2 : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l}
(G : fst (Z ⊙→ W)) (F : fst (X ⊙× Y ⊙→ Z))
→ ⊙ap G ⊙∘ ⊙ap2 F == ⊙ap2 (G ⊙∘ F)
⊙ap-ap2 (g , idp) (f , idp) =
⊙λ= (uncurry (ap-ap2 g (curry f))) idp
⊙ap2-ap : ∀ {i j k l m}
{X : Ptd i} {Y : Ptd j} {U : Ptd k} {V : Ptd l} {Z : Ptd m}
(G : fst ((U ⊙× V) ⊙→ Z)) (F₁ : fst (X ⊙→ U)) (F₂ : fst (Y ⊙→ V))
→ ⊙ap2 G ⊙∘ pair⊙→ (⊙ap F₁) (⊙ap F₂) == ⊙ap2 (G ⊙∘ pair⊙→ F₁ F₂)
⊙ap2-ap (g , idp) (f₁ , idp) (f₂ , idp) =
⊙λ= (λ {(p , q) → ap2-ap-l (curry g) f₁ p (ap f₂ q)
∙ ap2-ap-r (λ x v → g (f₁ x , v)) f₂ p q})
idp
⊙ap2-diag : ∀ {i j} {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙× X ⊙→ Y))
→ ⊙ap2 F ⊙∘ ⊙diag == ⊙ap (F ⊙∘ ⊙diag)
⊙ap2-diag (f , idp) = ⊙λ= (ap2-diag (curry f)) idp
{- ap and ap2 for higher loop spaces -}
ap^ : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j}
→ fst (X ⊙→ Y) → fst (⊙Ω^ n X ⊙→ ⊙Ω^ n Y)
ap^ O F = F
ap^ (S n) F = ⊙ap (ap^ n F)
ap2^ : ∀ {i j k} (n : ℕ) {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
→ fst ((X ⊙× Y) ⊙→ Z)
→ fst ((⊙Ω^ n X ⊙× ⊙Ω^ n Y) ⊙→ ⊙Ω^ n Z)
ap2^ O F = F
ap2^ (S n) F = ⊙ap2 (ap2^ n F)
ap^-idf : ∀ {i} (n : ℕ) {X : Ptd i} → ap^ n (⊙idf X) == ⊙idf _
ap^-idf O = idp
ap^-idf (S n) = ap ⊙ap (ap^-idf n) ∙ ⊙ap-idf
ap^-ap2^ : ∀ {i j k l} (n : ℕ) {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l}
(G : fst (Z ⊙→ W)) (F : fst ((X ⊙× Y) ⊙→ Z))
→ ap^ n G ⊙∘ ap2^ n F == ap2^ n (G ⊙∘ F)
ap^-ap2^ O G F = idp
ap^-ap2^ (S n) G F = ⊙ap-ap2 (ap^ n G) (ap2^ n F) ∙ ap ⊙ap2 (ap^-ap2^ n G F)
ap2^-fst : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j}
→ ap2^ n {X} {Y} ⊙fst == ⊙fst
ap2^-fst O = idp
ap2^-fst (S n) = ap ⊙ap2 (ap2^-fst n) ∙ ⊙ap2-fst
ap2^-snd : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j}
→ ap2^ n {X} {Y} ⊙snd == ⊙snd
ap2^-snd O = idp
ap2^-snd (S n) = ap ⊙ap2 (ap2^-snd n) ∙ ⊙ap2-snd
ap2^-ap^ : ∀ {i j k l m} (n : ℕ)
{X : Ptd i} {Y : Ptd j} {U : Ptd k} {V : Ptd l} {Z : Ptd m}
(G : fst ((U ⊙× V) ⊙→ Z)) (F₁ : fst (X ⊙→ U)) (F₂ : fst (Y ⊙→ V))
→ ap2^ n G ⊙∘ pair⊙→ (ap^ n F₁) (ap^ n F₂) == ap2^ n (G ⊙∘ pair⊙→ F₁ F₂)
ap2^-ap^ O G F₁ F₂ = idp
ap2^-ap^ (S n) G F₁ F₂ =
⊙ap2-ap (ap2^ n G) (ap^ n F₁) (ap^ n F₂) ∙ ap ⊙ap2 (ap2^-ap^ n G F₁ F₂)
ap2^-diag : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙× X ⊙→ Y))
→ ap2^ n F ⊙∘ ⊙diag == ap^ n (F ⊙∘ ⊙diag)
ap2^-diag O F = idp
ap2^-diag (S n) F = ⊙ap2-diag (ap2^ n F) ∙ ap ⊙ap (ap2^-diag n F)
module _ {i} {X : Ptd i} where
{- Prove these as lemmas now
- so we don't have to deal with the n = O case later -}
conc^-unit-l : (n : ℕ) (t : n ≠ O) (q : Ω^ n X)
→ (conc^ n t (idp^ n) q) == q
conc^-unit-l O t _ = ⊥-rec (t idp)
conc^-unit-l (S n) _ _ = idp
conc^-unit-r : (n : ℕ) (t : n ≠ O) (q : Ω^ n X)
→ (conc^ n t q (idp^ n)) == q
conc^-unit-r O t = ⊥-rec (t idp)
conc^-unit-r (S n) _ = ∙-unit-r
conc^-assoc : (n : ℕ) (t : n ≠ O) (p q r : Ω^ n X)
→ conc^ n t (conc^ n t p q) r == conc^ n t p (conc^ n t q r)
conc^-assoc O t = ⊥-rec (t idp)
conc^-assoc (S n) _ = ∙-assoc
!^-inv-l : (n : ℕ) (t : n ≠ O) (p : Ω^ n X)
→ conc^ n t (!^ n t p) p == idp^ n
!^-inv-l O t = ⊥-rec (t idp)
!^-inv-l (S n) _ = !-inv-l
!^-inv-r : (n : ℕ) (t : n ≠ O) (p : Ω^ n X)
→ conc^ n t p (!^ n t p) == idp^ n
!^-inv-r O t = ⊥-rec (t idp)
!^-inv-r (S n) _ = !-inv-r
abstract
ap^-conc^ : ∀ {i j} (n : ℕ) (t : n ≠ O)
{X : Ptd i} {Y : Ptd j} (F : fst (X ⊙→ Y)) (p q : Ω^ n X)
→ fst (ap^ n F) (conc^ n t p q)
== conc^ n t (fst (ap^ n F) p) (fst (ap^ n F) q)
ap^-conc^ O t _ _ _ = ⊥-rec (t idp)
ap^-conc^ (S n) _ {X = X} {Y = Y} F p q =
! gpt ∙ ap g (p ∙ q) ∙' gpt
=⟨ ap-∙ g p q |in-ctx (λ w → ! gpt ∙ w ∙' gpt) ⟩
! gpt ∙ (ap g p ∙ ap g q) ∙' gpt
=⟨ lemma (ap g p) (ap g q) gpt ⟩
(! gpt ∙ ap g p ∙' gpt) ∙ (! gpt ∙ ap g q ∙' gpt) ∎
where
g : Ω^ n X → Ω^ n Y
g = fst (ap^ n F)
gpt : g (idp^ n) == idp^ n
gpt = snd (ap^ n F)
lemma : ∀ {i} {A : Type i} {x y : A}
→ (p q : x == x) (r : x == y)
→ ! r ∙ (p ∙ q) ∙' r == (! r ∙ p ∙' r) ∙ (! r ∙ q ∙' r)
lemma p q idp = idp
{- ap^ preserves (pointed) equivalences -}
module _ {i j} {X : Ptd i} {Y : Ptd j} where
is-equiv-ap^ : (n : ℕ) (F : fst (X ⊙→ Y)) (e : is-equiv (fst F))
→ is-equiv (fst (ap^ n F))
is-equiv-ap^ O F e = e
is-equiv-ap^ (S n) F e =
pre∙-is-equiv (! (snd (ap^ n F)))
∘ise post∙'-is-equiv (snd (ap^ n F))
∘ise snd (equiv-ap (_ , is-equiv-ap^ n F e) _ _)
equiv-ap^ : (n : ℕ) (F : fst (X ⊙→ Y)) (e : is-equiv (fst F))
→ Ω^ n X ≃ Ω^ n Y
equiv-ap^ n F e = (fst (ap^ n F) , is-equiv-ap^ n F e)
Ω^-level-in : ∀ {i} (m : ℕ₋₂) (n : ℕ) (X : Ptd i)
→ (has-level ((n -2) +2+ m) (fst X) → has-level m (Ω^ n X))
Ω^-level-in m O X pX = pX
Ω^-level-in m (S n) X pX =
Ω^-level-in (S m) n X
(transport (λ k → has-level k (fst X)) (! (+2+-βr (n -2) m)) pX)
(idp^ n) (idp^ n)
Ω^-conn-in : ∀ {i} (m : ℕ₋₂) (n : ℕ) (X : Ptd i)
→ (is-connected ((n -2) +2+ m) (fst X)) → is-connected m (Ω^ n X)
Ω^-conn-in m O X pX = pX
Ω^-conn-in m (S n) X pX =
path-conn $ Ω^-conn-in (S m) n X $
transport (λ k → is-connected k (fst X)) (! (+2+-βr (n -2) m)) pX
{- Eckmann-Hilton argument -}
module _ {i} {X : Ptd i} where
ap2-conc-is-conc : (α β : Ω^ 2 X) → ap2 _∙_ α β == conc^ 2 (ℕ-S≠O _) α β
ap2-conc-is-conc α β = ap2-out _∙_ α β ∙ ap2 _∙_ (lemma α) (ap-idf β)
where
lemma : ∀ {i} {A : Type i} {x y : A} {p q : x == y} (α : p == q)
→ ap (λ r → r ∙ idp) α == ∙-unit-r p ∙ α ∙' ! (∙-unit-r q)
lemma {p = idp} idp = idp
⊙ap2-conc-is-conc : ⊙ap2 (⊙conc {X = X}) == ⊙conc
⊙ap2-conc-is-conc = ⊙λ= (uncurry ap2-conc-is-conc) idp
conc^2-comm : (α β : Ω^ 2 X) → conc^ 2 (ℕ-S≠O _) α β == conc^ 2 (ℕ-S≠O _) β α
conc^2-comm α β = ! (⋆2=conc^ α β) ∙ ⋆2=⋆'2 α β ∙ ⋆'2=conc^ α β
where
⋆2=conc^ : (α β : Ω^ 2 X) → α ⋆2 β == conc^ 2 (ℕ-S≠O _) α β
⋆2=conc^ α β = ap (λ π → π ∙ β) (∙-unit-r α)
⋆'2=conc^ : (α β : Ω^ 2 X) → α ⋆'2 β == conc^ 2 (ℕ-S≠O _) β α
⋆'2=conc^ α β = ap (λ π → β ∙ π) (∙-unit-r α)
{- Pushing truncation through loop space -}
module _ {i} where
Trunc-Ω^ : (m : ℕ₋₂) (n : ℕ) (X : Ptd i)
→ ⊙Trunc m (⊙Ω^ n X) == ⊙Ω^ n (⊙Trunc ((n -2) +2+ m) X)
Trunc-Ω^ m O X = idp
Trunc-Ω^ m (S n) X =
⊙Trunc m (⊙Ω^ (S n) X)
=⟨ ! (pair= (Trunc=-path [ _ ] [ _ ]) (↓-idf-ua-in _ idp)) ⟩
⊙Ω (⊙Trunc (S m) (⊙Ω^ n X))
=⟨ ap ⊙Ω (Trunc-Ω^ (S m) n X) ⟩
⊙Ω^ (S n) (⊙Trunc ((n -2) +2+ S m) X)
=⟨ +2+-βr (n -2) m |in-ctx (λ k → ⊙Ω^ (S n) (⊙Trunc k X)) ⟩
⊙Ω^ (S n) (⊙Trunc (S (n -2) +2+ m) X) ∎
Ω-Trunc-equiv : (m : ℕ₋₂) (X : Ptd i)
→ Ω (⊙Trunc (S m) X) ≃ Trunc m (Ω X)
Ω-Trunc-equiv m X = Trunc=-equiv [ snd X ] [ snd X ]
{- A loop space is a pregroup, and a group if it has the right level -}
module _ {i} (n : ℕ) (t : n ≠ O) (X : Ptd i) where
Ω^-group-structure : GroupStructure (Ω^ n X)
Ω^-group-structure = record {
ident = idp^ n;
inv = !^ n t;
comp = conc^ n t;
unitl = conc^-unit-l n t;
unitr = conc^-unit-r n t;
assoc = conc^-assoc n t;
invr = !^-inv-r n t;
invl = !^-inv-l n t
}
Ω^-Group : has-level ⟨ n ⟩ (fst X) → Group i
Ω^-Group pX = group
(Ω^ n X)
(Ω^-level-in ⟨0⟩ n X $
transport (λ t → has-level t (fst X)) (+2+-comm ⟨0⟩ (n -2)) pX)
Ω^-group-structure
{- Our definition of Ω^ builds up loops on the outside,
- but this is equivalent to building up on the inside -}
module _ {i} where
⊙Ω^-inner-path : (n : ℕ) (X : Ptd i)
→ ⊙Ω^ (S n) X == ⊙Ω^ n (⊙Ω X)
⊙Ω^-inner-path O X = idp
⊙Ω^-inner-path (S n) X = ap ⊙Ω (⊙Ω^-inner-path n X)
⊙Ω^-inner-out : (n : ℕ) (X : Ptd i)
→ fst (⊙Ω^ (S n) X ⊙→ ⊙Ω^ n (⊙Ω X))
⊙Ω^-inner-out O _ = (idf _ , idp)
⊙Ω^-inner-out (S n) X = ap^ 1 (⊙Ω^-inner-out n X)
Ω^-inner-out : (n : ℕ) (X : Ptd i)
→ (Ω^ (S n) X → Ω^ n (⊙Ω X))
Ω^-inner-out n X = fst (⊙Ω^-inner-out n X)
Ω^-inner-out-conc^ : (n : ℕ) (t : n ≠ O)
(X : Ptd i) (p q : Ω^ (S n) X)
→ Ω^-inner-out n X (conc^ (S n) (ℕ-S≠O _) p q)
== conc^ n t (Ω^-inner-out n X p) (Ω^-inner-out n X q)
Ω^-inner-out-conc^ O t X _ _ = ⊥-rec (t idp)
Ω^-inner-out-conc^ (S n) t X p q =
ap^-conc^ 1 (ℕ-S≠O _) (⊙Ω^-inner-out n X) p q
Ω^-inner-is-equiv : (n : ℕ) (X : Ptd i)
→ is-equiv (fst (⊙Ω^-inner-out n X))
Ω^-inner-is-equiv O X = is-eq (idf _) (idf _) (λ _ → idp) (λ _ → idp)
Ω^-inner-is-equiv (S n) X =
is-equiv-ap^ 1 (⊙Ω^-inner-out n X) (Ω^-inner-is-equiv n X)
Ω^-inner-equiv : (n : ℕ) (X : Ptd i) → Ω^ (S n) X ≃ Ω^ n (⊙Ω X)
Ω^-inner-equiv n X = _ , Ω^-inner-is-equiv n X
| 32.685015
| 79
| 0.448821
|
10abd42e1b9a5e13c6cad07fdedf912952c1a4cb
| 3,423
|
agda
|
Agda
|
Structures.agda
|
jvoigtlaender/bidiragda
|
a5abbd177f032523d1d9d3fa4b9137aefe88dee0
|
[
"MIT"
] | null | null | null |
Structures.agda
|
jvoigtlaender/bidiragda
|
a5abbd177f032523d1d9d3fa4b9137aefe88dee0
|
[
"MIT"
] | null | null | null |
Structures.agda
|
jvoigtlaender/bidiragda
|
a5abbd177f032523d1d9d3fa4b9137aefe88dee0
|
[
"MIT"
] | null | null | null |
module Structures where
open import Category.Functor using (RawFunctor ; module RawFunctor)
open import Category.Monad using (module RawMonad)
open import Data.Maybe using (Maybe) renaming (monad to MaybeMonad)
open import Data.Nat using (ℕ)
open import Data.Vec as V using (Vec)
import Data.Vec.Properties as VP
open import Function using (_∘_ ; flip ; id)
open import Function.Equality using (_⟶_ ; _⇨_ ; _⟨$⟩_)
open import Relation.Binary using (_Preserves_⟶_)
open import Relation.Binary.PropositionalEquality as P using (_≗_ ; _≡_ ; refl ; module ≡-Reasoning)
open import Generic using (sequenceV)
record IsFunctor (F : Set → Set) (f : {α β : Set} → (α → β) → F α → F β) : Set₁ where
field
cong : {α β : Set} → f {α} {β} Preserves _≗_ ⟶ _≗_
identity : {α : Set} → f {α} id ≗ id
composition : {α β γ : Set} → (g : β → γ) → (h : α → β) →
f (g ∘ h) ≗ f g ∘ f h
isCongruence : {α β : Set} → (P.setoid α ⇨ P.setoid β) ⟶ P.setoid (F α) ⇨ P.setoid (F β)
isCongruence {α} {β} = record
{ _⟨$⟩_ = λ g → record
{ _⟨$⟩_ = f (_⟨$⟩_ g)
; cong = P.cong (f (_⟨$⟩_ g))
}
; cong = λ {g} {h} g≗h {x} x≡y → P.subst (λ z → f (_⟨$⟩_ g) x ≡ f (_⟨$⟩_ h) z) x≡y (cong (λ _ → g≗h refl) x)
}
record Functor (f : Set → Set) : Set₁ where
field
rawfunctor : RawFunctor f
isFunctor : IsFunctor f (RawFunctor._<$>_ rawfunctor)
open RawFunctor rawfunctor public
open IsFunctor isFunctor public
record IsShaped (S : Set)
(C : Set → S → Set)
(arity : S → ℕ)
(content : {α : Set} {s : S} → C α s → Vec α (arity s))
(fill : {α : Set} → (s : S) → Vec α (arity s) → C α s)
: Set₁ where
field
content-fill : {α : Set} {s : S} → (c : C α s) → fill s (content c) ≡ c
fill-content : {α : Set} → (s : S) → (v : Vec α (arity s)) → content (fill s v) ≡ v
fmap : {α β : Set} → (f : α → β) → {s : S} → C α s → C β s
fmap f {s} c = fill s (V.map f (content c))
isFunctor : (s : S) → IsFunctor (flip C s) (λ f → fmap f)
isFunctor s = record
{ cong = λ g≗h c → P.cong (fill s) (VP.map-cong g≗h (content c))
; identity = λ c → begin
fill s (V.map id (content c))
≡⟨ P.cong (fill s) (VP.map-id (content c)) ⟩
fill s (content c)
≡⟨ content-fill c ⟩
c ∎
; composition = λ g h c → P.cong (fill s) (begin
V.map (g ∘ h) (content c)
≡⟨ VP.map-∘ g h (content c) ⟩
V.map g (V.map h (content c))
≡⟨ P.cong (V.map g) (P.sym (fill-content s (V.map h (content c)))) ⟩
V.map g (content (fill s (V.map h (content c)))) ∎)
} where open ≡-Reasoning
fmap-content : {α β : Set} → (f : α → β) → {s : S} → content {β} {s} ∘ fmap f ≗ V.map f ∘ content
fmap-content f c = fill-content _ (V.map f (content c))
fill-fmap : {α β : Set} → (f : α → β) → (s : S) → fmap f ∘ fill s ≗ fill s ∘ V.map f
fill-fmap f s v = P.cong (fill s ∘ V.map f) (fill-content s v)
sequence : {α : Set} {s : S} → C (Maybe α) s → Maybe (C α s)
sequence {s = s} c = fill s <$> sequenceV (content c)
where open RawMonad MaybeMonad
record Shaped (S : Set) (C : Set → S → Set) : Set₁ where
field
arity : S → ℕ
content : {α : Set} {s : S} → C α s → Vec α (arity s)
fill : {α : Set} → (s : S) → Vec α (arity s) → C α s
isShaped : IsShaped S C arity content fill
open IsShaped isShaped public
| 38.897727
| 112
| 0.539293
|
10c613e4a738fdda72fcc94872f874d0dccbd5f9
| 2,184
|
agda
|
Agda
|
Cubical/HITs/2GroupoidTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/HITs/2GroupoidTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/HITs/2GroupoidTruncation/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Properties of 2-groupoid truncations
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.2GroupoidTruncation.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.HITs.2GroupoidTruncation.Base
private
variable
ℓ : Level
A : Type ℓ
rec : ∀ {B : Type ℓ} → is2Groupoid B → (A → B) → ∥ A ∥₂ → B
rec gB f ∣ x ∣₂ = f x
rec gB f (squash₂ _ _ _ _ _ _ t u i j k l) =
gB _ _ _ _ _ _ (λ m n o → rec gB f (t m n o)) (λ m n o → rec gB f (u m n o))
i j k l
elim : {B : ∥ A ∥₂ → Type ℓ}
(bG : (x : ∥ A ∥₂) → is2Groupoid (B x))
(f : (x : A) → B ∣ x ∣₂) (x : ∥ A ∥₂) → B x
elim bG f ∣ x ∣₂ = f x
elim bG f (squash₂ x y p q r s u v i j k l) =
isOfHLevel→isOfHLevelDep 4 bG _ _ _ _ _ _
(λ j k l → elim bG f (u j k l)) (λ j k l → elim bG f (v j k l))
(squash₂ x y p q r s u v)
i j k l
elim2 : {B : ∥ A ∥₂ → ∥ A ∥₂ → Type ℓ}
(gB : ((x y : ∥ A ∥₂) → is2Groupoid (B x y)))
(g : (a b : A) → B ∣ a ∣₂ ∣ b ∣₂)
(x y : ∥ A ∥₂) → B x y
elim2 gB g = elim (λ _ → is2GroupoidΠ (λ _ → gB _ _))
(λ a → elim (λ _ → gB _ _) (g a))
elim3 : {B : (x y z : ∥ A ∥₂) → Type ℓ}
(gB : ((x y z : ∥ A ∥₂) → is2Groupoid (B x y z)))
(g : (a b c : A) → B ∣ a ∣₂ ∣ b ∣₂ ∣ c ∣₂)
(x y z : ∥ A ∥₂) → B x y z
elim3 gB g = elim2 (λ _ _ → is2GroupoidΠ (λ _ → gB _ _ _))
(λ a b → elim (λ _ → gB _ _ _) (g a b))
2GroupoidTruncIs2Groupoid : is2Groupoid ∥ A ∥₂
2GroupoidTruncIs2Groupoid a b p q r s = squash₂ a b p q r s
2GroupoidTruncIdempotent≃ : is2Groupoid A → ∥ A ∥₂ ≃ A
2GroupoidTruncIdempotent≃ {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 (λ _ → isOfHLevelSuc 4 2GroupoidTruncIs2Groupoid _ _) (λ _ → refl)
2GroupoidTruncIdempotent : is2Groupoid A → ∥ A ∥₂ ≡ A
2GroupoidTruncIdempotent hA = ua (2GroupoidTruncIdempotent≃ hA)
| 31.652174
| 89
| 0.570513
|
50eb04987f2f1cf33592c9a1b5f8e49cd3e45300
| 4,184
|
agda
|
Agda
|
OldBasicILP/UntypedSyntax/ClosedHilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
OldBasicILP/UntypedSyntax/ClosedHilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
OldBasicILP/UntypedSyntax/ClosedHilbertSequential.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
-- Hilbert-style formalisation of closed syntax.
-- Sequences of terms.
module OldBasicILP.UntypedSyntax.ClosedHilbertSequential where
open import OldBasicILP.UntypedSyntax.Common public
-- Closed, untyped representations.
data Rep : ℕ → Set where
NIL : Rep zero
MP : ∀ {n} → Fin n → Fin n → Rep n → Rep (suc n)
CI : ∀ {n} → Rep n → Rep (suc n)
CK : ∀ {n} → Rep n → Rep (suc n)
CS : ∀ {n} → Rep n → Rep (suc n)
NEC : ∀ {n} → ∀ {`n} → Rep (suc `n) → Rep n → Rep (suc n)
CDIST : ∀ {n} → Rep n → Rep (suc n)
CUP : ∀ {n} → Rep n → Rep (suc n)
CDOWN : ∀ {n} → Rep n → Rep (suc n)
CPAIR : ∀ {n} → Rep n → Rep (suc n)
CFST : ∀ {n} → Rep n → Rep (suc n)
CSND : ∀ {n} → Rep n → Rep (suc n)
UNIT : ∀ {n} → Rep n → Rep (suc n)
-- Anti-bug wrappers.
record Proof : Set where
constructor [_]
field
{len} : ℕ
rep : Rep (suc len)
open ClosedSyntax (Proof) public
-- Concatenation of representations.
_⧺ᴿ_ : ∀ {n₁ n₂} → Rep n₁ → Rep n₂ → Rep (n₁ + n₂)
r₁ ⧺ᴿ NIL = r₁
r₁ ⧺ᴿ MP i j r₂ = MP (monoFin weak≤+₂ i) (monoFin weak≤+₂ j) (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CI r₂ = CI (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CK r₂ = CK (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CS r₂ = CS (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ NEC `r r₂ = NEC `r (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CDIST r₂ = CDIST (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CUP r₂ = CUP (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CDOWN r₂ = CDOWN (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CPAIR r₂ = CPAIR (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CFST r₂ = CFST (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CSND r₂ = CSND (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ UNIT r₂ = UNIT (r₁ ⧺ᴿ r₂)
-- Modus ponens and necessitation in nested form.
APP : ∀ {n₁ n₂} → Rep (suc n₁) → Rep (suc n₂) → Rep (suc (suc n₂ + suc n₁))
APP {n₁} {n₂} r₁ r₂ = MP zero (monoFin (weak≤+₁ (suc n₁)) zero) (r₂ ⧺ᴿ r₁)
BOX : ∀ {n} → Rep (suc n) → Rep (suc zero)
BOX {n} r = NEC r NIL
-- Derivations.
mutual
infix 3 ⊢ᴰ_
data ⊢ᴰ_ : Cx Ty → Set where
nil : ⊢ᴰ ∅
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} → ∀ {`Ξ} → (d : ⊢ᴰ `Ξ , A)
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ ᴿ⌊ d ⌋ ] ⦂ A
cdist : ∀ {Ξ A B} → ∀ {n₁ n₂} → {r₁ : Rep (suc n₁)} → {r₂ : Rep (suc n₂)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r₁ ] ⦂ (A ▻ B) ▻ [ r₂ ] ⦂ A ▻ [ APP r₁ r₂ ] ⦂ B
cup : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ [ BOX r ] ⦂ [ r ] ⦂ A
cdown : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ A
cpair : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ B ▻ A ∧ B
cfst : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ A
csnd : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ B
unit : ∀ {Ξ} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , ⊤
-- Projection from derivations to representations.
ᴿ⌊_⌋ : ∀ {Ξ} → ⊢ᴰ Ξ → Rep ᴺ⌊ Ξ ⌋
ᴿ⌊ nil ⌋ = NIL
ᴿ⌊ mp i j d ⌋ = MP ⁱ⌊ i ⌋ ⁱ⌊ j ⌋ ᴿ⌊ d ⌋
ᴿ⌊ ci d ⌋ = CI ᴿ⌊ d ⌋
ᴿ⌊ ck d ⌋ = CK ᴿ⌊ d ⌋
ᴿ⌊ cs d ⌋ = CS ᴿ⌊ d ⌋
ᴿ⌊ nec `d d ⌋ = NEC ᴿ⌊ `d ⌋ ᴿ⌊ d ⌋
ᴿ⌊ cdist d ⌋ = CDIST ᴿ⌊ d ⌋
ᴿ⌊ cup d ⌋ = CUP ᴿ⌊ d ⌋
ᴿ⌊ cdown d ⌋ = CDOWN ᴿ⌊ d ⌋
ᴿ⌊ cpair d ⌋ = CPAIR ᴿ⌊ d ⌋
ᴿ⌊ cfst d ⌋ = CFST ᴿ⌊ d ⌋
ᴿ⌊ csnd d ⌋ = CSND ᴿ⌊ d ⌋
ᴿ⌊ unit d ⌋ = UNIT ᴿ⌊ d ⌋
-- Anti-bug wrappers.
infix 3 ⊢_
⊢_ : Ty → Set
⊢ A = ∃ (λ Ξ → ⊢ᴰ Ξ , A)
-- Concatenation of derivations.
_⧺ᴰ_ : ∀ {Ξ₁ Ξ₂} → ⊢ᴰ Ξ₁ → ⊢ᴰ Ξ₂ → ⊢ᴰ Ξ₁ ⧺ Ξ₂
d₁ ⧺ᴰ nil = d₁
d₁ ⧺ᴰ mp i j d₂ = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ ci d₂ = ci (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ ck d₂ = ck (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cs d₂ = cs (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ nec `d d₂ = nec `d (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cdist d₂ = cdist (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cup d₂ = cup (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cdown d₂ = cdown (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cpair d₂ = cpair (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cfst d₂ = cfst (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ csnd d₂ = csnd (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ unit d₂ = unit (d₁ ⧺ᴰ d₂)
-- Modus ponens and necessitation in nested form.
app : ∀ {A B} → ⊢ A ▻ B → ⊢ A → ⊢ B
app {A} {B} (Ξ₁ , d₁) (Ξ₂ , d₂) = Ξ₃ , d₃
where Ξ₃ = (Ξ₂ , A) ⧺ (Ξ₁ , A ▻ B)
d₃ = mp top (mono∈ (weak⊆⧺₁ (Ξ₁ , A ▻ B)) top) (d₂ ⧺ᴰ d₁)
box : ∀ {A} → (t : ⊢ A) → ⊢ [ ᴿ⌊ π₂ t ⌋ ] ⦂ A
box (Ξ , d) = ∅ , nec d nil
| 28.657534
| 89
| 0.446224
|
4d853c861c92576a4531ba65316fe9e900135785
| 32,142
|
agda
|
Agda
|
theorems/homotopy/3x3/Common.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
theorems/homotopy/3x3/Common.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/homotopy/3x3/Common.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
module homotopy.3x3.Common where
open import HoTT public hiding (↓-='-in; ↓-='-out; ↓-=-in; ↓-=-out; ↓-∘=idf-in)
!-∘-ap-inv : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A}
(p : a == b)
→ ap-∘ f g p == ! (∘-ap f g p)
!-∘-ap-inv f g idp = idp
!-ap-∘-inv : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A}
(p : a == b)
→ ∘-ap f g p == ! (ap-∘ f g p)
!-ap-∘-inv f g idp = idp
!-∘-ap : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A}
(p : a == b)
→ ! (∘-ap f g p) == ap-∘ f g p
!-∘-ap f g idp = idp
!-ap-∘ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A}
(p : a == b)
→ ! (ap-∘ f g p) == ∘-ap f g p
!-ap-∘ f g idp = idp
module _ {i} {A : Type i} where
_,_=□_,_ : {a b b' c : A} (p : a == b) (q : b == c)
(r : a == b') (s : b' == c) → Type i
(idp , q =□ r , idp) = (q == r)
idp□ : {a b : A} {p : a == b} → idp , p =□ idp , p
idp□ {p = idp} = idp
idp□-i : {a b : A} {p : a == b} → p , idp =□ idp , p
idp□-i {p = idp} = idp
idp,=□idp,-in : {a b : A} {p q : a == b}
→ p == q → idp , p =□ idp , q
idp,=□idp,-in {q = idp} α = α
idp,=□idp,-out : {a b : A} {p q : a == b}
→ idp , p =□ idp , q → p == q
idp,=□idp,-out {q = idp} α = α
idp,=□idp,-β : {a b : A} {p q : a == b}
(α : p == q) → idp,=□idp,-out (idp,=□idp,-in α) == α
idp,=□idp,-β {q = idp} α = idp
idp,=□idp,-η : {a b : A} {p q : a == b}
(α : idp , p =□ idp , q) → idp,=□idp,-in (idp,=□idp,-out α) == α
idp,=□idp,-η {q = idp} α = idp
,idp=□,idp-in : {a b : A} {p q : a == b}
→ p == q → p , idp =□ q , idp
,idp=□,idp-in {p = idp} α = α
,idp=□,idp-out : {a b : A} {p q : a == b}
→ p , idp =□ q , idp → p == q
,idp=□,idp-out {p = idp} α = α
,idp=□,idp-β : {a b : A} {p q : a == b}
(α : p == q) → ,idp=□,idp-out (,idp=□,idp-in α) == α
,idp=□,idp-β {p = idp} α = idp
,idp=□,idp-η : {a b : A} {p q : a == b}
(α : p , idp =□ q , idp) → ,idp=□,idp-in (,idp=□,idp-out α) == α
,idp=□,idp-η {p = idp} α = idp
,idp=□idp,-in : {a b : A} {p q : a == b}
→ p == q → p , idp =□ idp , q
,idp=□idp,-in {p = idp} = idp,=□idp,-in
,idp=□idp,-out : {a b : A} {p q : a == b}
→ p , idp =□ idp , q → p == q
,idp=□idp,-out {p = idp} {q} α = idp,=□idp,-out α
,idp=□idp,-β : {a b : A} {p q : a == b}
(α : p == q) → ,idp=□idp,-out (,idp=□idp,-in α) == α
,idp=□idp,-β {p = idp} α = idp,=□idp,-β α
,idp=□idp,-η : {a b : A} {p q : a == b}
(α : p , idp =□ idp , q) → ,idp=□idp,-in (,idp=□idp,-out α) == α
,idp=□idp,-η {p = idp} α = idp,=□idp,-η α
infix 40 _∙□-i/_/_/ _∙□-o/_/_/
_∙□-i/_/_/ : {a b b' c : A} {p : a == b} {q q' : b == c}
{r r' : a == b'} {s : b' == c}
→ (p , q =□ r , s) → (q' == q) → (r == r')
→ (p , q' =□ r' , s)
α ∙□-i/ idp / idp / = α
_∙□-o/_/_/ : {a b b' c : A} {p p' : a == b} {q : b == c}
{r : a == b'} {s s' : b' == c}
→ (p , q =□ r , s) → (p' == p) → (s == s')
→ (p' , q =□ r , s')
α ∙□-o/ idp / idp / = α
infix 80 _∙□h_
_∙□h_ : {a b b' c c' d : A} {p : a == b} {q : b == c} {r : a == b'}
{s : b' == c} {t : c == d} {u : b' == c'} {v : c' == d}
→ (p , q =□ r , s) → (s , t =□ u , v) → (p , q ∙ t =□ r ∙ u , v)
_∙□h_ {p = idp} {s = idp} {v = idp} idp idp = idp
module _ {i j} {A : Type i} {B : Type j} (f : A → B) where
ap□ : {a b b' c : A} {p : a == b} {q : b == c} {r : a == b'} {s : b' == c}
→ (p , q =□ r , s) → (ap f p , ap f q =□ ap f r , ap f s)
ap□ {p = idp} {s = idp} α = ap (ap f) α
module _ {i j} {A : Type i} {B : Type j} (f : A → B) where
ap□-,idp=□idp,-in : {a b : A} {p q : a == b}
(α : p == q) → ap□ f (,idp=□idp,-in α) == ,idp=□idp,-in (ap (ap f) α)
ap□-,idp=□idp,-in {p = idp} idp = idp
module _ {i j} {A : Type i} {B : A → Type j} where
_,_=□d-i_,_ : {a b : A} {p : a == b} {u v : B a} {w x : B b}
→ (u == v) → (v == w [ B ↓ p ])
→ (u == x [ B ↓ p ]) → (x == w)
→ Type j
_,_=□d-i_,_ idp α β idp = (α == β)
-- _,_=□d-i_,_ {p = idp} = _,_=□_,_
idp,=□d-iidp,-out : {a : A} {u w : B a} {α β : u == w}
→ (idp , α =□d-i idp , β) → α == β
idp,=□d-iidp,-out {β = idp} x = x
,idp=□d-iidp,-out : {a : A} {u w : B a} {α β : u == w}
→ (α , idp =□d-i idp , β) → α == β
,idp=□d-iidp,-out {α = idp} x = idp,=□d-iidp,-out x
idp,=□d-iidp,-in : {a : A} {u w : B a} {α β : u == w}
→ α == β → (idp , α =□d-i idp , β)
idp,=□d-iidp,-in {β = idp} x = x
,idp=□d-iidp,-in : {a : A} {u w : B a} {α β : u == w}
→ α == β → (α , idp =□d-i idp , β)
,idp=□d-iidp,-in {α = idp} x = idp,=□d-iidp,-in x
infix 40 _◃/_/_/
_◃/_/_/ : {a b : A} {p : a == b} {u v : B a} {w x : B b}
→ (v == w [ B ↓ p ]) → (u == v) → (w == x)
→ (u == x [ B ↓ p ])
α ◃/ idp / idp / = α
module _ {i} {A : Type i} where
_,_,_=□□_,_,_ : {a0 b0 b'0 c0 a1 b1 b'1 c1 : A}
{p0 : a0 == b0} {q0 : b0 == c0} {r0 : a0 == b'0} {s0 : b'0 == c0}
{p1 : a1 == b1} {q1 : b1 == c1} {r1 : a1 == b'1} {s1 : b'1 == c1}
{a* : a0 == a1} {b* : b0 == b1} {b'* : b'0 == b'1} {c* : c0 == c1}
→ (p0 , q0 =□ r0 , s0) → (s0 , c* =□ b'* , s1) → (r0 , b'* =□ a* , r1)
→ (q0 , c* =□ b* , q1) → (p0 , b* =□ a* , p1) → (p1 , q1 =□ r1 , s1)
→ Type i
_,_,_=□□_,_,_ {p0 = idp} {s0 = idp} {p1 = idp} {s1 = idp} idp idp β γ idp idp = β == γ
{- Nondependent identity type -}
module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where
↓-='-in : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u , ap g p =□ ap f p , v)
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in {p = idp} α = ,idp=□idp,-out α
↓-='-out : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ (u , ap g p =□ ap f p , v)
↓-='-out {p = idp} α = ,idp=□idp,-in α
↓-='-β : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
(α : (u , ap g p =□ ap f p , v))
→ ↓-='-out (↓-='-in α) == α
↓-='-β {p = idp} α = ,idp=□idp,-η α
module _ {i j k} {A : Type i} {B : Type j} (C : Type k) {g h : B → C} (f : A → B) where
lemma-a : {x y : A} (p : x == y) {u : g (f x) == h (f x)} {v : g (f y) == h (f y)} {q : f x == f y} (r : ap f p == q)
(α : u == v [ (λ z → g z == h z) ↓ q ])
→ ↓-='-out (↓-ap-out= (λ z → g z == h z) f p r α) == ↓-='-out α ∙□-i/ ap-∘ h f p ∙ ap (ap h) r / ! (ap (ap g) r) ∙ ∘-ap g f p /
lemma-a idp idp idp = idp
{- Dependent identity type -}
↓-=-in : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B}
{x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u , apd f p =□d-i apd g p , v)
→ (u == v [ (λ x → g x == f x) ↓ p ])
↓-=-in {B = B} {p = idp} {u} {v} α = ,idp=□d-iidp,-out α
↓-=-out : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B}
{x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u == v [ (λ x → g x == f x) ↓ p ])
→ (u , apd f p =□d-i apd g p , v)
↓-=-out {B = B} {p = idp} {u} {v} α = ,idp=□d-iidp,-in α
↓-=□-in : ∀ {i j} {A : Type i} {B : Type j} {f g g' h : A → B}
{x y : A} {α : x == y} {p : (x : A) → f x == g x} {q : (x : A) → g x == h x}
{r : (x : A) → f x == g' x} {s : (x : A) → g' x == h x}
{u : (p x , q x =□ r x , s x)} {v : (p y , q y =□ r y , s y)}
→ (u , ↓-='-out (apd s α) , ↓-='-out (apd r α) =□□ ↓-='-out (apd q α) , ↓-='-out (apd p α) , v)
→ (u == v [ (λ x → (p x , q x =□ r x , s x)) ↓ α ])
↓-=□-in {α = idp} = ch _ _ where
ch : ∀ {j} {B : Type j} {f g g' h : B} {p : f == g} {q : g == h}
{r : f == g'} {s : g' == h} (u v : p , q =□ r , s)
→ u , ,idp=□idp,-in idp , ,idp=□idp,-in idp =□□ ,idp=□idp,-in idp , ,idp=□idp,-in idp , v
→ u == v
ch {p = idp} {s = idp} u v = ,idp=□idp,-out ∘ ch2 u idp idp v where
ch2 : ∀ {i} {A : Type i} {a b : A}
{q q' r r' : a == b}
(p : q == r) (p' : r == r')
(s' : q == q') (s : q' == r')
→ (p , idp , ,idp=□idp,-in p' =□□ ,idp=□idp,-in s' , idp , s) → (p , p' =□ s' , s)
ch2 idp p' s' idp α = ! (,idp=□idp,-β p') ∙ ap ,idp=□idp,-out α ∙ ,idp=□idp,-β s'
-- Dependent path in a type of the form [λ x → x ≡ g (f x)]
module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where
↓-idf=∘-in : {x y : A} {p : x == y} {u : x == g (f x)} {v : y == g (f y)}
→ (u , ap g (ap f p) =□ p , v)
→ (u == v [ (λ x → x == g (f x)) ↓ p ])
↓-idf=∘-in {p = idp} q = ,idp=□idp,-out q
↓-∘=idf-in : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y}
→ (u , p =□ ap g (ap f p) , v)
→ (u == v [ (λ x → g (f x) == x) ↓ p ])
↓-∘=idf-in {p = idp} q = ,idp=□idp,-out q
module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k}
(f : B → C) (g : A → B) (h : A' → B) where
ap-∙∙`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d)
→ ap f (ap g p ∙ q ∙ ap h r) == ap (f ∘ g) p ∙ ap f q ∙ ap (f ∘ h) r
ap-∙∙`∘`∘ idp q idp = ap-∙ f q idp
ap-∙∙!`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c)
→ ap f (ap g p ∙ q ∙ ap h (! r)) == ap (f ∘ g) p ∙ ap f q ∙ ! (ap (f ∘ h) r)
ap-∙∙!`∘`∘ idp q idp = ap-∙ f q idp
ap-∙∙!'`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c)
→ ap f (ap g p ∙ q ∙ ! (ap h r)) == ap (f ∘ g) p ∙ ap f q ∙ ! (ap (f ∘ h) r)
ap-∙∙!'`∘`∘ idp q idp = ap-∙ f q idp
ap-!∙∙`∘`∘ : {a b : A} {c d : A'} (p : b == a) (q : g b == h c) (r : c == d)
→ ap f (ap g (! p) ∙ q ∙ ap h r) == ! (ap (f ∘ g) p) ∙ ap f q ∙ ap (f ∘ h) r
ap-!∙∙`∘`∘ idp q idp = ap-∙ f q idp
ap-!'∙∙`∘`∘ : {a b : A} {c d : A'} (p : b == a) (q : g b == h c) (r : c == d)
→ ap f (! (ap g p) ∙ q ∙ ap h r) == ! (ap (f ∘ g) p) ∙ ap f q ∙ ap (f ∘ h) r
ap-!'∙∙`∘`∘ idp q idp = ap-∙ f q idp
module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : B → Type k}
(f : Π B C) (g : A → B) (h : A' → B) where
apd-∙∙`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d)
→ apd f (ap g p ∙ q ∙ ap h r) == ↓-ap-in _ _ (apd (f ∘ g) p) ∙ᵈ apd f q ∙ᵈ ↓-ap-in _ _ (apd (f ∘ h) r)
apd-∙∙`∘`∘ idp q idp = ch q where
ch : {a b : B} (q : a == b)
→ apd f (q ∙ idp) == idp ∙ᵈ apd f q ∙ᵈ idp
ch idp = idp
module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} {f : A → B} {f' : A' → B} {g h : B → C} where
lemma-b : {x y : A} {z t : A'} {p : x == y} {q : z == t} (r : f y == f' z)
{a : g (f x) == h (f x)} {b : g (f y) == h (f y)}
{c : g (f' z) == h (f' z)} {d : g (f' t) == h (f' t)}
(u : a == b [ (λ x → g (f x) == h (f x)) ↓ p ]) (v : (b , ap h r =□ ap g r , c))
(w : c == d [ (λ x → g (f' x) == h (f' x)) ↓ q ])
→ ↓-='-out (↓-ap-in _ f u ∙ᵈ ↓-='-in v ∙ᵈ ↓-ap-in _ f' w) == (↓-='-out u ∙□h (v ∙□h ↓-='-out w)) ∙□-i/ ap-∙∙`∘`∘ h f f' p r q / ! (ap-∙∙`∘`∘ g f f' p r q) /
lemma-b {p = idp} {q = idp} r idp v idp = ch r v where
ch : ∀ {a b : B} (r : a == b) {p : g a == h a} {q : g b == h b} (v : (p , ap h r =□ ap g r , q))
→ ↓-='-out (idp ∙ᵈ ↓-='-in v ∙ᵈ idp)
== (,idp=□idp,-in idp ∙□h (v ∙□h ,idp=□idp,-in idp))
∙□-i/ ap-∙ h r idp / ! (ap-∙ g r idp) /
ch idp v = ch2 (,idp=□idp,-out v) ∙ (,idp=□idp,-η v |in-ctx (λ u → ,idp=□idp,-in idp ∙□h (u ∙□h ,idp=□idp,-in idp))) where
ch2 : ∀ {i} {A : Type i} {a b : A} {p q : a == b} (v' : p == q)
→ ,idp=□idp,-in (v' ∙ idp) == ,idp=□idp,-in idp ∙□h (,idp=□idp,-in v' ∙□h ,idp=□idp,-in idp)
ch2 {p = idp} v' = ch3 v' where
ch3 : ∀ {i} {A : Type i} {a : A} {q : a == a} (v' : idp == q)
→ idp,=□idp,-in (v' ∙ idp) == (,idp=□idp,-in idp ∙□h (idp,=□idp,-in v' ∙□h ,idp=□idp,-in idp))
ch3 idp = idp
module _ {i} {A : Type i} where
pp-coh : {a b b' c c' d d' e : A}
{p : a == b} {q : b == c} {r : c == d} {s : e == d}
{t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e}
→ (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w) → (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r)
pp-coh {p = idp} {q} {idp} {idp} {idp} {idp} {idp} {idp} α = (! α) ∙ (∙-unit-r q)
pp-coh! : {a b b' c c' d d' e : A}
{u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d}
{t : b' == a} {p : a == b} {q : b == c} {r : c == d}
→ (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r) → (p , (q ∙ r ∙ (! s)) =□ ((! t) ∙ u ∙ v) , w)
pp-coh! {u = idp} {idp} {idp} {idp} {idp} {idp} {q} {idp} α = ∙-unit-r q ∙ (! α)
pp-coh-β : {a b b' c c' d d' e : A}
{u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d}
{t : b' == a} {p : a == b} {q : b == c} {r : c == d}
(α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r))
→ pp-coh {p = p} {q = q} {r = r} {s = s} {t = t} {u = u} {v = v} {w = w}
(pp-coh! {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} α) == α
pp-coh-β {u = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp
pp-coh!-β : {a b b' c c' d d' e : A}
{p : a == b} {q : b == c} {r : c == d} {s : e == d}
{t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e}
(α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w))
→ pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r}
(pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α) == α
pp-coh!-β {p = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp
module _ {i j} {A : Type i} {B : Type j} where
ap-∙∙ : (f : A → B) {x y z t : A} (p : x == y) (q : y == z) (r : z == t) → ap f (p ∙ q ∙ r) == ap f p ∙ ap f q ∙ ap f r
ap-∙∙ f idp q idp = ap-∙ f q idp
ap-∙∙! : (f : A → B) {x y z t : A} (p : x == y) (q : y == z) (r : t == z) → ap f (p ∙ q ∙ ! r) == ap f p ∙ ap f q ∙ ! (ap f r)
ap-∙∙! f idp q idp = ap-∙ f q idp
ap-!∙∙ : (f : A → B) {x y z t : A} (p : y == x) (q : y == z) (r : z == t) → ap f (! p ∙ q ∙ r) == ! (ap f p) ∙ ap f q ∙ ap f r
ap-!∙∙ f idp q idp = ap-∙ f q idp
module _ {i j k} {A : Type i} {B : Type j} {C₁ C₂ C₃ C₄ : Type k} {g₁ : C₁ → A} {g₂ : C₂ → A} {g₃ : C₃ → A} {g₄ : C₄ → A} (f : A → B) where
ap□-pp-coh : {a b b' c c' d d' e : A}
{p : a == b} {q : b == c} {r : c == d} {s : e == d}
{t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e}
(α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w))
→ ap□ f (pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α) ==
pp-coh {p = ap f p} {ap f q} {ap f r} {ap f s} {ap f t} {ap f u} {ap f v} {ap f w}
(ap□ f α ∙□-i/ ! (ap-∙∙! f q r s) / ap-!∙∙ f t u v /)
∙□-i/ ap-∙∙ f v w s / ! (ap-∙∙ f t p q) /
ap□-pp-coh {p = idp} {q} {idp} {idp} {idp} {idp} {idp} {idp} α = c q idp α where
c : {a b : A} (q q' : a == b) (α : q ∙ idp == q')
→ ap (ap f) (! α ∙ ∙-unit-r q) ==
(! (ap (ap f) α ∙□-i/ ! (ap-∙∙! f q idp idp) / idp /) ∙
∙-unit-r (ap f q))
∙□-i/ idp / ! (ap-∙∙ f idp idp q) /
c idp q' α = d α where
d : {a b : A} {q q' : a == b} (α : q == q')
→ ap (ap f) (! α ∙ idp) == ! (ap (ap f) α) ∙ idp
d idp = idp
ap□-coh : {a₁ b₁ : C₁} {a₂ b₂ : C₂} {a₃ b₃ : C₃} {a₄ b₄ : C₄}
{p : g₃ b₃ == g₁ a₁} {q : a₁ == b₁} {r : g₁ b₁ == g₂ b₂} {s : a₂ == b₂}
{t : a₃ == b₃} {u : g₃ a₃ == g₄ a₄} {v : a₄ == b₄} {w : g₄ b₄ == g₂ a₂}
(α : (p , (ap g₁ q ∙ r ∙ (! (ap g₂ s))) =□ (! (ap g₃ t) ∙ u ∙ ap g₄ v) , w))
→ ap□ f (pp-coh {p = p} {ap g₁ q} {r} {ap g₂ s} {ap g₃ t} {u} {ap g₄ v} {w} α) ==
pp-coh {p = ap f p} {ap (f ∘ g₁) q} {ap f r} {ap (f ∘ g₂) s} {ap (f ∘ g₃) t} {ap f u} {ap (f ∘ g₄) v} {ap f w}
(ap□ f α ∙□-i/ ! (ap-∙∙!'`∘`∘ f g₁ g₂ q r s) / ap-!'∙∙`∘`∘ f g₃ g₄ t u v /)
∙□-i/ ap-∙∙`∘`∘ f g₄ g₂ v w s / ! (ap-∙∙`∘`∘ f g₃ g₁ t p q) /
ap□-coh {p = p} {idp} {r} {idp} {idp} {u} {idp} {w} α = ap□-pp-coh {p = p} {idp} {r} {idp} {idp} {u} {idp} {w} α
module _ {i j k} {A : Type i} {B : Type j} {C₁ C₂ C₃ C₄ : Type k} {g₁ : C₁ → A} {g₂ : C₂ → A} {g₃ : C₃ → A} {g₄ : C₄ → A} (f : A → B) where
ap□-pp-coh! : {a b b' c c' d d' e : A}
{u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d}
{t : b' == a} {p : a == b} {q : b == c} {r : c == d}
(α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r))
→ ap□ f (pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r} α) ==
pp-coh! {u = ap f u} {ap f v} {ap f w} {ap f s} {ap f t} {ap f p} {ap f q} {ap f r}
(ap□ f α ∙□-i/ ! (ap-∙∙ f v w s) / ap-∙∙ f t p q /)
∙□-i/ ap-∙∙! f q r s / ! (ap-!∙∙ f t u v) /
ap□-pp-coh! {u = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp
ap□-coh! : {a₁ b₁ : C₁} {a₂ b₂ : C₂} {a₃ b₃ : C₃} {a₄ b₄ : C₄}
{u : g₃ a₃ == g₄ a₄} {v : a₄ == b₄} {w : g₄ b₄ == g₂ a₂} {s : a₂ == b₂}
{t : a₃ == b₃} {p : g₃ b₃ == g₁ a₁} {q : a₁ == b₁} {r : g₁ b₁ == g₂ b₂}
(α : (u , (ap g₄ v ∙ w ∙ ap g₂ s) =□ (ap g₃ t ∙ p ∙ ap g₁ q) , r))
→ ap□ f (pp-coh! {u = u} {ap g₄ v} {w} {ap g₂ s} {ap g₃ t} {p} {ap g₁ q} {r} α) ==
pp-coh! {u = ap f u} {ap (f ∘ g₄) v} {ap f w} {ap (f ∘ g₂) s} {ap (f ∘ g₃) t} {ap f p} {ap (f ∘ g₁) q} {ap f r}
(ap□ f α ∙□-i/ ! (ap-∙∙`∘`∘ f g₄ g₂ v w s) / ap-∙∙`∘`∘ f g₃ g₁ t p q /)
∙□-i/ ap-∙∙!'`∘`∘ f g₁ g₂ q r s / ! (ap-!'∙∙`∘`∘ f g₃ g₄ t u v) /
ap□-coh! {u = u} {idp} {w} {idp} {idp} {p} {idp} {r} α = ap□-pp-coh! {u = u} {idp} {w} {idp} {idp} {p} {idp} {r} α
module _ {i} {A : Type i} where
lemma : {a b b' c c' d d' e : A}
{u u' : b' == c'} {v : c' == d'} {w w' : d' == e} {s : e == d}
{t : b' == a} {p p' : a == b} {q : b == c} {r r' : c == d}
(β : u' == u) (γ : w' == w) (δ : p' == p) (ε : r' == r)
(α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r))
→ pp-coh {p = p'} {q} {r'} {s} {t} {u'} {v} {w'}
(pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r} α
∙□-o/ δ / ! γ /
∙□-i/ ε |in-ctx (λ x → q ∙ x ∙ ! s) / (! β) |in-ctx (λ x → ! t ∙ x ∙ v) /) == α ∙□-o/ β / ! ε / ∙□-i/ γ |in-ctx (λ x → v ∙ x ∙ s) / (! δ) |in-ctx (λ x → t ∙ x ∙ q) /
lemma {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} idp idp idp idp α = pp-coh-β {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} α
lemma! : {a b b' c c' d d' e : A}
{p p' : a == b} {q : b == c} {r r' : c == d} {s : e == d}
{t : b' == a} {u u' : b' == c'} {v : c' == d'} {w w' : d' == e}
(β : p' == p) (γ : r' == r) (δ : u' == u) (ε : w' == w)
(α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w))
→ pp-coh! {u = u'} {v} {w'} {s} {t} {p'} {q} {r'}
(pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α
∙□-o/ δ / ! γ /
∙□-i/ ε |in-ctx (λ w → v ∙ w ∙ s) / (! β) |in-ctx (λ p → t ∙ p ∙ q) /) == α ∙□-o/ β / ! ε / ∙□-i/ γ |in-ctx (λ r → q ∙ r ∙ ! s) / (! δ) |in-ctx (λ u → ! t ∙ u ∙ v) /
lemma! {p = p} {q = q} {r = r} {s = s} {t = t} {u = u} {v = v} {w = w} idp idp idp idp α = pp-coh!-β {p = p} {q} {r} {s} {t} {u} {v} {w} α
module _ {i j} {A : Type i} {B : A → Type j} where
coh1 : {a b : A} {α : a == b} {u v : B a} {w x : B b}
{p : u == w [ B ↓ α ]} {q : w == x} {r : u == v} {s : v == x [ B ↓ α ]}
→ (r , s =□d-i p , q) → p == s ◃/ r / ! q /
coh1 {α = idp} {p = idp} {idp} {idp} {s} β = ! β
module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f g : A → B) (h : B → C) where
ap↓-↓-='-in-β : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
(α : (u , ap g p =□ ap f p , v))
→ ap↓ (ap h) {p = p} {u = u} {v = v} (↓-='-in {p = p} α)
== ↓-='-in ((ap□ h α) ∙□-i/ (ap-∘ h g p) / (∘-ap h f p) /)
ap↓-↓-='-in-β {p = idp} = t where
t : {x y : B} {u v : x == y} (α : (u , idp =□ idp , v))
→ ap (ap h) (,idp=□idp,-out α) == ,idp=□idp,-out (ap□ h α)
t {u = idp} {v} = t' where
t' : {x y : B} {u v : x == y} (α : (idp , u =□ idp , v))
→ ap (ap h) (idp,=□idp,-out α) == idp,=□idp,-out (ap□ h α)
t' {u} {v = idp} α = idp
ap□-↓-='-out-β : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
(α : u == v [ (λ x → f x == g x) ↓ p ])
→ ap□ h (↓-='-out α) == ↓-='-out (ap↓ (ap h) α) ∙□-i/ ∘-ap h g p / ap-∘ h f p /
ap□-↓-='-out-β {p = idp} idp = ap□-,idp=□idp,-in h idp
thing : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u u' : f x == g x} {v v' : f y == g y}
(α : (u , ap g p =□ ap f p , v)) (r : u' == u) (s : v == v')
→ ↓-='-out (↓-='-in α ◃/ r / s /) == α ∙□-o/ r / s /
thing α idp idp = ↓-='-β α
ap↓-∘ : ∀ {i j k l} {A : Type i} {B : A → Type j} {C : A → Type k} {D : A → Type l}
(f : {a : A} → C a → D a) (g : {a : A} → B a → C a)
{x y : A} {p : x == y} {u : B x} {v : B y} (q : u == v [ B ↓ p ])
→ ap↓ (f ∘ g) q == ap↓ f (ap↓ g q)
ap↓-∘ f g {p = idp} idp = idp
ap↓-◃/ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k}
(f : {a : A} → B a → C a) {x y : A} {p : x == y} {u u' : B x} {v v' : B y}
(q : u == v [ B ↓ p ]) (r : u' == u) (s : v == v')
→ ap↓ f (q ◃/ r / s /) == ap↓ f q ◃/ ap f r / ap f s /
ap↓-◃/ f {p = idp} idp idp idp = idp
ap□-∙□-i/ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
{a b b' c : A} {p : a == b} {q q' : b == c} {r r' : a == b'} {s : b' == c}
(α : (p , q =□ r , s)) (t : q' == q) (u : r == r')
→ ap□ f (α ∙□-i/ t / u /) == ap□ f α ∙□-i/ ap (ap f) t / ap (ap f) u /
ap□-∙□-i/ f {p = idp} {s = idp} idp idp idp = idp
ap-∘^3-coh : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(h : C → D) (g : B → C) (f : A → B) {a b : A} (p : a == b)
→ ap (ap h) (∘-ap g f p) ∙ ∘-ap h (g ∘ f) p ∙ ap-∘ (h ∘ g) f p == ∘-ap h g (ap f p)
ap-∘^3-coh h g f idp = idp
ap-∘^3-coh' : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(h : C → D) (g : B → C) (f : A → B) {a b : A} (p : a == b)
→ ∘-ap (h ∘ g) f p ∙ ap-∘ h (g ∘ f) p ∙ ap (ap h) (ap-∘ g f p) == ap-∘ h g (ap f p)
ap-∘^3-coh' h g f idp = idp
ap-∘-ap-coh : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
(g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q)
→ ap (ap g) (! α |in-ctx (ap f)) ∙ ∘-ap g f p ∙ (α |in-ctx (ap (g ∘ f)))
== ∘-ap g f q
ap-∘-ap-coh g f idp = ∙-unit-r _
ap-∘-ap-coh' : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
(g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q)
→ (! α |in-ctx (ap (g ∘ f))) ∙ ap-∘ g f p ∙ ap (ap g) (α |in-ctx (ap f))
== ap-∘ g f q
ap-∘-ap-coh' g f idp = ∙-unit-r _
ap-∘-ap-coh'2 : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
(g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q)
→ (! (α |in-ctx (ap (g ∘ f)))) ∙ ap-∘ g f p ∙ ap (ap g) (α |in-ctx (ap f))
== ap-∘ g f q
ap-∘-ap-coh'2 g f {p = idp} idp = idp
module _ {i i' j k l} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} {D : Type l}
(f2 : C → D) (f1 : B → C) (g : A → B) (h : A' → B) where
ap-∘-ap-∙∙!`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c)
→ ! (ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r)
∙ ap (ap f2) (! (ap-∙∙!`∘`∘ f1 g h p q r))
∙ ∘-ap f2 f1 (ap g p ∙ q ∙ ap h (! r))
∙ ap-∙∙!`∘`∘ (f2 ∘ f1) g h p q r
== ((∘-ap f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r)))
ap-∘-ap-∙∙!`∘`∘-coh idp q idp = coh q where
coh : {a b : B} (q : a == b) →
! (ap-∙ f2 (ap f1 q) idp)
∙ ap (ap f2) (! (ap-∙ f1 q idp))
∙ ∘-ap f2 f1 (q ∙ idp)
∙ ap-∙ (f2 ∘ f1) q idp
== ap (λ u → u ∙ idp) (∘-ap f2 f1 q)
coh idp = idp
ap-∘-ap-!∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g a == h c) (r : c == d)
→ ! (ap-!∙∙`∘`∘ (f2 ∘ f1) g h p q r)
∙ ap-∘ f2 f1 (ap g (! p) ∙ q ∙ ap h r)
∙ ap (ap f2) (ap-!∙∙`∘`∘ f1 g h p q r)
∙ ap-!'∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r
== ((ap-∘ f2 f1 q) |in-ctx (λ u → ! (ap (f2 ∘ f1 ∘ g) p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-!∙∙`∘`∘-coh idp q idp = coh q where
coh : {a b : B} (q : a == b)
→ ! (ap-∙ (f2 ∘ f1) q idp) ∙ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ap (λ u → u ∙ idp) (ap-∘ f2 f1 q)
coh idp = idp
ap-∘-ap-∙∙2`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d)
→ ! (ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r)
∙ ap-∘ f2 f1 (ap g p ∙ q ∙ ap h r)
∙ ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r)
∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r
== ((ap-∘ f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-∙∙2`∘`∘-coh idp q idp = coh q where
coh : {a b : B} (q : a == b)
→ ! (ap-∙ (f2 ∘ f1) q idp) ∙ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ap (λ u → u ∙ idp) (ap-∘ f2 f1 q)
coh idp = idp
ap-∘-ap-∙∙3`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d)
→ ! (ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r)
∙ ap (ap f2) (! (ap-∙∙`∘`∘ f1 g h p q r))
∙ ∘-ap f2 f1 (ap g p ∙ q ∙ ap h r)
∙ ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r
== ((∘-ap f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-∙∙3`∘`∘-coh idp q idp = coh q where
coh : {a b : B} (q : a == b) →
! (ap-∙ f2 (ap f1 q) idp)
∙ ap (ap f2) (! (ap-∙ f1 q idp))
∙ ∘-ap f2 f1 (q ∙ idp)
∙ ap-∙ (f2 ∘ f1) q idp
== ap (λ u → u ∙ idp) (∘-ap f2 f1 q)
coh idp = idp
ap-∘-ap-∙∙4`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : c == d)
→ ap-∘ f2 f1 (ap g p ∙ q ∙ ap h r)
∙ ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r)
∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) r))
∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
==
ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r
∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-∙∙4`∘`∘-coh idp {q = q} idp idp = coh q where
coh : {a b : B} (q : a == b)
→ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp
coh idp = idp
ap-∘-ap-∙∙5`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g a == h c} {q' : f1 (g a) == f1 (h c)} (α : ap f1 q == q') (r : c == d)
→ ap-∘ f2 f1 (ap g (! p) ∙ q ∙ ap h r)
∙ ap (ap f2) (ap-!∙∙`∘`∘ f1 g h p q r)
∙ ap (ap f2) (α |in-ctx (λ u → ! (ap (f1 ∘ g) p) ∙ u ∙ ap (f1 ∘ h) r))
∙ ap-!'∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
==
ap-∙∙`∘`∘ (f2 ∘ f1) g h (! p) q r
∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) (! p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) (! p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
∙ (ap-! (f2 ∘ f1 ∘ g) p |in-ctx (λ u → u ∙ ap f2 q' ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-∙∙5`∘`∘-coh idp {q = q} idp idp = coh q where
coh : {a b : B} (q : a == b)
→ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp
coh idp = idp
ap-∘-ap-∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : c == d)
→ ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r)
∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) r))
∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
==
∘-ap f2 f1 (ap g p ∙ q ∙ ap h r)
∙ ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r
∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r))
ap-∘-ap-∙∙`∘`∘-coh idp {q = q} idp idp = coh q where
coh : {a b : B} (q : a == b)
→ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp
coh idp = idp
ap-∘-ap-∙∙!'`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : d == c)
→ ap (ap f2) (ap-∙∙!`∘`∘ f1 g h p q r)
∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ! (ap (f1 ∘ h) r)))
∙ ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
==
∘-ap f2 f1 (ap g p ∙ q ∙ ap h (! r))
∙ ap-∙∙!`∘`∘ (f2 ∘ f1) g h p q r
∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r)))
∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r)))
ap-∘-ap-∙∙!'`∘`∘-coh idp {q = q} idp idp = coh q where
coh : {a b : B} (q : a == b)
→ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp
== ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp
coh idp = idp
ap-∘-ap-∙∙!'2`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : d == c)
→ ap (ap f2) (ap-∙∙!`∘`∘ f1 g h p q r)
∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ! (ap (f1 ∘ h) r)))
∙ ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
==
ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q (! r))
∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) (! r)))
∙ ap-∙∙!`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r
ap-∘-ap-∙∙!'2`∘`∘-coh idp {q = q} idp idp = idp
module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k}
(f : B → C) (g : A → B) (h : A' → B) where
ap-!∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : b == a) {q : g b == h c} {q' : f (g b) == f (h c)} (α : ap f q == q') (r : c == d)
→ ap-!∙∙`∘`∘ f g h p q r
∙ ap (λ u → ! (ap (f ∘ g) p) ∙ u ∙ ap (f ∘ h) r) α
∙ ! (ap-! (f ∘ g) p |in-ctx (λ u → u ∙ q' ∙ ap (f ∘ h) r))
==
ap-∙∙`∘`∘ f g h (! p) q r
∙' ap (λ u → ap (f ∘ g) (! p) ∙ u ∙ ap (f ∘ h) r) α
ap-!∙∙`∘`∘-coh idp {q = q} idp idp = ∙-unit-r (ap-∙ f q idp)
ap-∙∙!`∘`∘-coh1 : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f (g b) == f (h c)} (α : ap f q == q') (r : d == c)
→ ap-∙∙!`∘`∘ f g h p q r
∙ ap (λ u → ap (f ∘ g) p ∙ u ∙ ! (ap (f ∘ h) r)) α
==
ap-∙∙`∘`∘ f g h p q (! r)
∙ ap (λ u → ap (f ∘ g) p ∙ u ∙ ap (f ∘ h) (! r)) α
∙ (ap-! (f ∘ h) r |in-ctx (λ u → ap (f ∘ g) p ∙ q' ∙ u))
ap-∙∙!`∘`∘-coh1 idp {q = q} idp idp = idp
ap-∙∙!`∘`∘-coh2 : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} (r : d == c)
→ (ap-! (f ∘ h) r |in-ctx (λ u → ap (f ∘ g) p ∙ ap f q ∙ u))
∙ ! (ap-∙∙!`∘`∘ f g h p q r)
==
! (ap-∙∙`∘`∘ f g h p q (! r))
ap-∙∙!`∘`∘-coh2 idp {q} idp = idp
ap-∘-coh : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(f : C → D) (g : B → C) (h : A → B) {a b : A} (p : a == b) {p' : h a == h b} (α : ap h p == p')
→ ap-∘ f (g ∘ h) p ∙ ap (ap f) (ap-∘ g h p) ∙ ap (ap f) (α |in-ctx (ap g)) ∙ ∘-ap f g p'
== ap-∘ (f ∘ g) h p ∙ ap (ap (f ∘ g)) α
ap-∘-coh f g h idp idp = idp
ap-∘-coh2 : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(f : C → D) (g : B → C) (h : A → B) {a b : A} (p : a == b) {p' : h a == h b} (α : ap h p == p')
→ ap-∘ f (g ∘ h) p ∙ ap (ap f) (ap-∘ g h p) ∙ ap (ap f) (α |in-ctx (ap g))
== ap-∘ (f ∘ g) h p ∙ ap (ap (f ∘ g)) α ∙ ap-∘ f g p'
ap-∘-coh2 f g h idp idp = idp
∙-|in-ctx : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b c : A}
(p : a == b) (q : b == c)
→ (p |in-ctx f) ∙ (q |in-ctx f) == ((p ∙ q) |in-ctx f)
∙-|in-ctx f idp idp = idp
∙□-i/-rewrite : ∀ {i} {A : Type i} {a b b' c : A} {p : a == b} {q q' : b == c}
{r r' : a == b'} {s : b' == c}
(α : (p , q =□ r , s)) {β β' : q' == q} (eqβ : β == β') {γ γ' : r == r'}
(eqγ : γ == γ')
→ (α ∙□-i/ β / γ / == α ∙□-i/ β' / γ' /)
∙□-i/-rewrite α idp idp = idp
| 47.060029
| 181
| 0.330813
|
107eb0dd06a5b414c239cdf5538780011e1db0ce
| 427
|
agda
|
Agda
|
test/Fail/Issue2250.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue2250.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue2250.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-10-11, AIM XXIV, issue #2250
{-# OPTIONS --injective-type-constructors #-}
open import Common.Prelude
open import Common.Equality
abstract
f : Bool → Bool
f x = true
same : f true ≡ f false
same = refl
-- f should not be treated as injective here,
-- even though f true and f false do not reduce.
not-same : f true ≡ f false → ⊥
not-same () -- should be yellow
absurd : ⊥
absurd = not-same same
| 18.565217
| 48
| 0.672131
|
c582334b1d4b3e093d040f58531505738296912c
| 9,032
|
agda
|
Agda
|
complexity/Idea.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 2
|
2016-04-26T20:22:22.000Z
|
2019-08-08T12:27:18.000Z
|
complexity/Idea.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 1
|
2020-03-23T08:39:04.000Z
|
2020-05-12T00:32:45.000Z
|
complexity/Idea.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | null | null | null |
open import Preliminaries
module Idea where
{- de Bruijn indices are representd as proofs that
an element is in a list -}
data _∈_ {A : Set} : (x : A) (l : List A) → Set where -- type \in
i0 : {x : A} {xs : List A} → x ∈ x :: xs
iS : {x y : A} {xs : List A} → x ∈ xs → x ∈ y :: xs
{- types of the STLC -}
data Tp : Set where
b : Tp -- uninterpreted base type
_⇒_ : Tp → Tp → Tp -- type \=>
{- contexts are lists of Tp's -}
Ctx = List Tp
_,,_ : Ctx → Tp → Ctx
Γ ,, τ = τ :: Γ
infixr 10 _⇒_
infixr 9 _,,_
infixr 8 _⊢_ -- type \entails
infix 9 _⊇_
data _⊢_ (Γ : Ctx) : Tp → Set
data _≡_ {Γ : Ctx} : {τ : Tp} → Γ ⊢ τ → Γ ⊢ τ → Set
_⊢c_ : Ctx → Ctx → Set
_⊇_ : Ctx → Ctx → Set -- type \sup=
ids : {Γ : Ctx} → Γ ⊢c Γ
rename : {Γ Γ' : Ctx} {τ : Tp} → Γ' ⊇ Γ → Γ ⊢ τ → Γ' ⊢ τ
subst : {Γ Γ' : Ctx}{τ : Tp} → Γ ⊢c Γ' → Γ' ⊢ τ → Γ ⊢ τ
_·ss_ : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊢c Γ2 → Γ2 ⊢c Γ3 → Γ1 ⊢c Γ3
subst1 : {Γ : Ctx} {τ τ0 : Tp} → Γ ⊢ τ0 → (Γ ,, τ0) ⊢ τ → Γ ⊢ τ
{- Γ ⊢ τ represents a term of type τ in context Γ -}
data _⊢_ (Γ : Ctx) where
c : Γ ⊢ b -- some constant of the base type
v : {τ : Tp}
→ τ ∈ Γ
→ Γ ⊢ τ
lam : {τ1 τ2 : Tp}
→ Γ ,, τ1 ⊢ τ2
→ Γ ⊢ τ1 ⇒ τ2
app : {τ1 τ2 : Tp}
→ Γ ⊢ τ1 ⇒ τ2
→ Γ ⊢ τ1
→ Γ ⊢ τ2
foo : {A : Tp} (e1 e2 : Γ ⊢ A) → e1 ≡ e2 → Γ ⊢ A
{-foo : (e1 : ™ Gamma A) (e2 : ™ Gamma A) -> e1 \equiv e2 -> ™ Gamma A-}
Γ' ⊇ [] = Unit
Γ' ⊇ (τ :: Γ) = (Γ' ⊇ Γ) × (τ ∈ Γ')
rename-var : {Γ Γ' : Ctx} {τ : Tp} → Γ' ⊇ Γ → τ ∈ Γ → τ ∈ Γ'
rename-var (ρ , x') i0 = x'
rename-var (ρ , _) (iS x) = rename-var ρ x
p· : {Γ : Ctx} {Γ' : Ctx} → Γ ⊇ Γ' → {τ : Tp} → (Γ ,, τ) ⊇ Γ'
p· {Γ' = []} ren = <>
p· {Γ' = (τ :: Γ')} (ρ , x) = p· ρ , iS x
idr : {Γ : Ctx} → Γ ⊇ Γ
idr {[]} = <>
idr {τ :: Γ} = p· idr , i0
-- category with families notation
p : {Γ : Ctx} {τ : Tp} → (Γ ,, τ ⊇ Γ)
p = p· idr
addvar-ren : {Γ Γ' : Ctx} {τ : Tp} → Γ' ⊇ Γ → Γ' ,, τ ⊇ Γ ,, τ
addvar-ren ρ = (p· ρ , i0)
data _≡_ {Γ : Ctx} where
CongApp : {τ1 τ2 : Tp} {e e' : Γ ⊢ τ1 ⇒ τ2} {e1 e1' : Γ ⊢ τ1}
→ e ≡ e' → e1 ≡ e1'
→ (app e e1) ≡ (app e' e1')
CongLam : {τ1 τ2 : Tp} {e e' : (τ1 :: Γ) ⊢ τ2}
→ e ≡ e'
→ (lam e) ≡ (lam e')
SubstId : ∀ {τ} {e : Γ ⊢ τ} → subst ids e ≡ e
SubstComp : ∀ {Γ1 Γ2} {τ} {θ' : Γ ⊢c Γ2} {θ : Γ2 ⊢c Γ1} {e : Γ1 ⊢ τ} → subst θ' (subst θ e) ≡ subst (θ' ·ss θ) e
Stepβ : {τ1 τ2 : Tp} {e : Γ ,, τ1 ⊢ τ2} {e1 : Γ ⊢ τ1}
→ (app (lam e) e1) ≡ subst1 e1 e
Refl : {τ : Tp} {e : Γ ⊢ τ} → e ≡ e
Trans : {τ : Tp} {e1 e2 e3 : Γ ⊢ τ}
→ e1 ≡ e2 → e2 ≡ e3
→ e1 ≡ e3
SubstCong : ∀ {Γ2} {τ} {Θ : Γ ⊢c Γ2} {e1 e2 : Γ2 ⊢ τ} → e1 ≡ e2 → subst Θ e1 ≡ subst Θ e2
RenCong : ∀ {Γ2} {τ} {ρ : Γ ⊇ Γ2} {e1 e2 : Γ2 ⊢ τ} → e1 ≡ e2 → rename ρ e1 ≡ rename ρ e2
rename ρ c = c
rename ρ (v x) = v (rename-var ρ x)
rename ρ (lam e) = lam (rename (addvar-ren ρ) e)
rename ρ (app e e') = app (rename ρ e) (rename ρ e')
rename ρ (foo e1 e2 p) = foo (rename ρ e1) (rename ρ e2) (RenCong p)
_·rr_ : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊇ Γ2 → Γ2 ⊇ Γ3 → Γ1 ⊇ Γ3
_·rr_ {Γ1} {Γ2} {[]} ρ2 ρ3 = <>
_·rr_ {Γ1} {Γ2} {x :: Γ3} ρ2 (ρ3 , x3) = (ρ2 ·rr ρ3) , rename-var ρ2 x3
Γ' ⊢c [] = Unit
Γ' ⊢c (τ :: Γ) = (Γ' ⊢c Γ) × (Γ' ⊢ τ)
_·rs_ : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊇ Γ2 → Γ2 ⊢c Γ3 → Γ1 ⊢c Γ3
_·rs_ {Γ1} {Γ2} {[]} ρ θ = <>
_·rs_ {Γ1} {Γ2} {τ3 :: Γ3} ρ (θ , e) = ρ ·rs θ , rename ρ e
addvar : {Γ Γ' : Ctx} {τ : Tp} → Γ ⊢c Γ' → (Γ ,, τ) ⊢c (Γ' ,, τ)
addvar θ = p ·rs θ , v i0
ids {[]} = <>
ids {τ :: Γ} = p ·rs ids , v i0
subst-var : {Γ Γ' : Ctx}{τ : Tp} → Γ ⊢c Γ' → τ ∈ Γ' → Γ ⊢ τ
subst-var (θ , e) i0 = e
subst-var (θ , _) (iS x) = subst-var θ x
subst1 e0 e = subst (ids , e0) e
-- composition of renamings and substitutions
_·sr_ : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊢c Γ2 → Γ2 ⊇ Γ3 → Γ1 ⊢c Γ3
_·sr_ {Γ1} {Γ2} {[]} θ ρ = <>
_·sr_ {Γ1} {Γ2} {τ3 :: Γ3} θ (ρ , x) = _·sr_ θ ρ , subst-var θ x
_·ss_ {Γ3 = []} θ1 θ2 = <>
_·ss_ {Γ1} {Γ2} {τ :: Γ3} θ1 (θ2 , e2) = θ1 ·ss θ2 , subst θ1 e2
subst θ c = c
subst θ (v x) = subst-var θ x
subst θ (lam e) = lam (subst (addvar θ) e)
subst θ (app e e') = app (subst θ e) (subst θ e')
subst {Γ} {Γ'} {τ} Θ (foo e1 e2 p) = foo (subst Θ e1) (subst Θ e2) (SubstCong p)
postulate
semfoo : (A : Set) (x y : A) -> x == y -> A
module Semantics (B : Set) (elB : B) where
⟦_⟧t : Tp → Set
⟦_⟧c : Ctx → Set
⟦_⟧v : {Γ : Ctx} {τ : Tp} → τ ∈ Γ → ⟦ Γ ⟧c → ⟦ τ ⟧t
⟦_⟧ : {Γ : Ctx} {τ : Tp} → Γ ⊢ τ → ⟦ Γ ⟧c → ⟦ τ ⟧t
sound : {Γ : Ctx} {τ : Tp} {e : Γ ⊢ τ} {e' : Γ ⊢ τ} → e ≡ e'
→ (γ : ⟦ Γ ⟧c) → ⟦ e ⟧ γ == ⟦ e' ⟧ γ
⟦ b ⟧t = B
⟦ τ1 ⇒ τ2 ⟧t = ⟦ τ1 ⟧t → ⟦ τ2 ⟧t
⟦ [] ⟧c = Unit
⟦ τ :: Γ ⟧c = ⟦ Γ ⟧c × ⟦ τ ⟧t
⟦_⟧v i0 γ = snd γ
⟦_⟧v (iS x) γ = ⟦ x ⟧v (fst γ)
⟦ c ⟧ γ = elB
⟦ v x ⟧ γ = ⟦ x ⟧v γ
⟦ lam e ⟧ γ = \ x → ⟦ e ⟧ (γ , x)
⟦ app e1 e2 ⟧ γ = ⟦ e1 ⟧ γ (⟦ e2 ⟧ γ)
⟦ (foo e1 e2 p) ⟧ γ = semfoo {!!} (⟦ e1 ⟧ γ) (⟦ e2 ⟧ γ) (sound {_} {_} {e1} {e2} p γ)
⟦_⟧s : {Γ Γ' : Ctx} → Γ ⊢c Γ' → ⟦ Γ ⟧c → ⟦ Γ' ⟧c
⟦_⟧s {Γ' = []} θ _ = <>
⟦_⟧s {Γ' = τ :: Γ'} (θ , e) γ = ⟦ θ ⟧s γ , ⟦ e ⟧ γ
⟦_⟧r : {Γ Γ' : Ctx} → Γ ⊇ Γ' → ⟦ Γ ⟧c → ⟦ Γ' ⟧c
⟦_⟧r {Γ' = []} θ _ = <>
⟦_⟧r {Γ' = τ :: Γ'} (θ , x) γ = ⟦ θ ⟧r γ , ⟦ x ⟧v γ
interp-rename-var : {Γ' Γ : Ctx} {τ : Tp} (x : τ ∈ Γ) (θ : Γ' ⊇ Γ)
→ (γ' : ⟦ Γ' ⟧c) → ⟦ rename-var θ x ⟧v γ' == (⟦ x ⟧v (⟦ θ ⟧r γ'))
interp-rename-var i0 θ γ' = Refl
interp-rename-var (iS x) θ γ' = interp-rename-var x (fst θ) γ'
interp-subst-var : {Γ' Γ : Ctx} {τ : Tp} (x : τ ∈ Γ) (θ : Γ' ⊢c Γ)
→ (γ' : ⟦ Γ' ⟧c) → ⟦ subst-var θ x ⟧ γ' == (⟦ x ⟧v (⟦ θ ⟧s γ'))
interp-subst-var i0 θ γ' = Refl
interp-subst-var (iS x) θ γ' = interp-subst-var x (fst θ) γ'
interp-p· : {Γ : Ctx} {Γ' : Ctx} → (θ : Γ ⊇ Γ') → {τ : Tp} (γ' : _)
→ ⟦ p· θ {τ = τ} ⟧r γ' == ⟦ θ ⟧r (fst γ')
interp-p· {Γ' = []} θ γ' = Refl
interp-p· {Γ' = τ' :: Γ'} θ γ' = ap2 _,_ (interp-p· (fst θ) _) Refl
interp-idr : {Γ : Ctx} (γ : _) → ⟦ idr {Γ} ⟧r γ == γ
interp-idr {[]} γ = Refl
interp-idr {x :: Γ} γ = ap (λ x₁ → x₁ , snd γ) (interp-idr (fst γ) ∘ interp-p· idr γ)
interp-rename : {Γ' Γ : Ctx} {τ : Tp} (e : Γ ⊢ τ) (θ : Γ' ⊇ Γ)
→ (γ' : ⟦ Γ' ⟧c) → ⟦ rename θ e ⟧ γ' == (⟦ e ⟧ (⟦ θ ⟧r γ'))
interp-rename c θ γ' = Refl
interp-rename (v x) θ γ' = interp-rename-var x θ γ'
interp-rename (lam e) θ γ' = λ= (λ x → ap ⟦ e ⟧ (ap2 _,_ (interp-p· θ (γ' , x)) Refl) ∘ interp-rename e (addvar-ren θ) (γ' , x))
interp-rename (app e e₁) θ γ' = ap2 (λ f x → f x) (interp-rename e θ γ') (interp-rename e₁ θ γ')
interp-rename (foo e1 e2 p) Θ γ' = {!!} --interp-rename e1 Θ γ'
interp-·rs : {Γ1 Γ2 Γ3 : Ctx} → (θ1 : Γ1 ⊇ Γ2) (θ2 : Γ2 ⊢c Γ3) (γ : _) → ⟦ θ1 ·rs θ2 ⟧s γ == ⟦ θ2 ⟧s (⟦ θ1 ⟧r γ)
interp-·rs {Γ3 = []} θ1 θ2 γ = Refl
interp-·rs {Γ3 = τ :: Γ3} θ1 (θ2 , e) γ = ap2 _,_ (interp-·rs θ1 θ2 γ) (interp-rename e θ1 γ)
interp-subst : {Γ' Γ : Ctx} {τ : Tp} (e : Γ ⊢ τ) (θ : Γ' ⊢c Γ)
→ (γ' : ⟦ Γ' ⟧c) → ⟦ subst θ e ⟧ γ' == (⟦ e ⟧ (⟦ θ ⟧s γ'))
interp-subst c θ γ' = Refl
interp-subst (v x) θ γ' = interp-subst-var x θ γ'
interp-subst (lam e) θ γ' = λ= (λ x → ap (λ h → ⟦ e ⟧ (h , x)) (ap ⟦ θ ⟧s (interp-idr γ' ∘ interp-p· idr (γ' , x)) ∘ interp-·rs (p· idr) θ _) ∘ interp-subst e (addvar θ) (γ' , x))
interp-subst (app e e₁) θ γ' = ap2 (λ f x → f x) (interp-subst e θ γ') (interp-subst e₁ θ γ')
interp-subst (foo e1 e2 p) Θ γ' = {!!} --interp-subst e1 Θ γ'
interp-·ss : {Γ1 Γ2 Γ3 : Ctx} → (θ1 : Γ1 ⊢c Γ2) (θ2 : Γ2 ⊢c Γ3) (γ : _) → ⟦ θ1 ·ss θ2 ⟧s γ == ⟦ θ2 ⟧s (⟦ θ1 ⟧s γ)
interp-·ss {Γ3 = []} θ1 θ2 γ = Refl
interp-·ss {Γ3 = τ :: Γ3} θ1 (θ2 , e) γ = ap2 _,_ (interp-·ss θ1 θ2 γ) (interp-subst e θ1 γ)
interp-ids : ∀ {Γ} (γ : _) → ⟦ ids {Γ} ⟧s γ == γ
interp-ids {[]} γ = Refl
interp-ids {τ :: Γ} γ = ap (λ x → x , snd γ) (((interp-idr (fst γ) ∘ interp-p· idr γ) ∘ interp-ids (⟦ p ⟧r γ)) ∘ interp-·rs p ids γ)
sound (CongApp D D') γ = ap2 (λ f x → f x) (sound D γ) (sound D' γ)
sound (CongLam D) γ = λ= (λ x → sound D (γ , x))
sound {e' = e'} SubstId γ = ap ⟦ e' ⟧ (interp-ids γ) ∘ interp-subst e' ids γ
sound (SubstComp {θ' = θ'}{θ}{e = e}) γ = ((! (interp-subst e _ γ) ∘ ap ⟦ e ⟧ (! (interp-·ss θ' θ γ))) ∘ interp-subst e θ (⟦ θ' ⟧s γ)) ∘ interp-subst (subst θ e) θ' γ
sound (Stepβ {e = e} {e1 = e1}) γ = ! (interp-subst e (ids , e1) γ) ∘ ap (λ x → ⟦ e ⟧ (x , ⟦ e1 ⟧ γ)) (! (interp-ids γ))
sound Refl γ = Refl
sound (Trans D D₁) γ = sound D₁ γ ∘ sound D γ
sound {Γ'} (SubstCong {Γ} {τ} {Θ} {e1} {e2} D) γ = {!!} --(! (interp-subst e2 Θ γ) ∘ sound D (⟦ Θ ⟧s γ)) ∘ interp-subst e1 Θ γ
sound {Γ'} (RenCong {Γ} {τ} {ρ} {e1} {e2} D) γ = {!!} --(! (interp-rename e2 ρ γ) ∘ sound D (⟦ ρ ⟧r γ)) ∘ interp-rename e1 ρ γ
| 39.614035
| 183
| 0.428587
|
0ea50eb6b8a72066b86a7ef6eef57811e94d5402
| 1,123
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Preorder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Preorder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Preorder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties satisfied by preorders
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Properties.Preorder
{p₁ p₂ p₃} (P : Preorder p₁ p₂ p₃) where
open import Function
open import Data.Product as Prod
open Relation.Binary.Preorder P
-- The inverse relation is also a preorder.
invIsPreorder : IsPreorder _≈_ (flip _∼_)
invIsPreorder = record
{ isEquivalence = isEquivalence
; reflexive = reflexive ∘ Eq.sym
; trans = flip trans
}
invPreorder : Preorder p₁ p₂ p₃
invPreorder = record { isPreorder = invIsPreorder }
------------------------------------------------------------------------
-- For every preorder there is an induced equivalence
InducedEquivalence : Setoid _ _
InducedEquivalence = record
{ _≈_ = λ x y → x ∼ y × y ∼ x
; isEquivalence = record
{ refl = (refl , refl)
; sym = swap
; trans = Prod.zip trans (flip trans)
}
}
| 26.116279
| 72
| 0.541407
|
dfa47df508347623f043c85e164179fa4cc5b51b
| 5,986
|
agda
|
Agda
|
examples/outdated-and-incorrect/DTP08/conor/Talk.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/outdated-and-incorrect/DTP08/conor/Talk.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/outdated-and-incorrect/DTP08/conor/Talk.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
{-# OPTIONS --no-positivity-check
#-}
{-
Data, Deliberately
Conor McBride
Workshop in Dependently Typed Programming
Nottingham, 2008
(Agda rendering by Ulf Norell)
-}
module Talk where
open import SomeBasicStuff
-- Codes for (first order) inductive families.
data Code (I : Set) : Set1 where
arg : (A : Set) -> (A -> Code I) -> Code I
rec : I -> Code I -> Code I
out : I -> Code I
-- The semantics of a code is a functor.
⟦_⟧ : {I : Set} -> Code I -> (I -> Set) -> I -> Set
⟦ out i ⟧ X j = i == j
⟦ arg A B ⟧ X j = Σ A \a -> ⟦ B a ⟧ X j
⟦ rec i C ⟧ X j = X i × ⟦ C ⟧ X j
map : {I : Set}{X Y : I -> Set}(C : Code I) ->
({i : I} -> X i -> Y i) ->
{i : I} -> ⟦ C ⟧ X i -> ⟦ C ⟧ Y i
map (out i) f x = x
map (arg A B) f (a , b) = a , map (B a) f b
map (rec i C) f (a , b) = f a , map C f b
-- Tying the recursive knot. The positivity checker won't spot that
-- ⟦ C ⟧ X i is strictly positive i X, so we've switched it off.
data μ {I : Set}(C : Code I) : I -> Set where
<_> : forall {i} -> ⟦ C ⟧ (μ C) i -> μ C i
-- Who needs a primitive case-construct anyway?
case_of_ : {A : Set1}{ts : Enumeration} -> Enum ts -> Table A ts -> A
case t of tbl = lookup tbl t
-- The code for lists
`List` : Set -> Code True
`List` X = arg _ \t ->
case t of
"nil" ↦ out _
∣ "cons" ↦ arg X (\_ -> rec _ (out _))
∣ []
-- The actual list type
List : Set -> Set
List A = μ (`List` A) _
-- We can define the code for vectors directly. However, the point is
-- that we won't have to.
`VecD` : Set -> Code Nat
`VecD` X = arg _ \t ->
case t of
"nil" ↦ out zero
∣ "cons" ↦ ( arg Nat \n ->
arg X \_ ->
rec n (out (suc n))
)
∣ []
-- An ornamentation of a datatype adds some new indexing.
data Orn {I : Set}(J : I -> Set) : Code I -> Set1 where
arg : forall {A B} -> ((a : A) -> Orn J (B a)) -> Orn J (arg A B)
rec : forall {i C} -> J i -> Orn J C -> Orn J (rec i C)
out : forall {i} -> J i -> Orn J (out i)
new : forall {C} -> (A : Set) -> (A -> Orn J C) -> Orn J C
-- An ornamented datatype is indexed by pairs of the old and the new index.
orn : {I : Set}{J : I -> Set}{C : Code I} -> Orn J C -> Code (Σ I J)
orn (out j) = out (_ , j)
orn (arg B) = arg _ \a -> orn (B a)
orn (new A B) = arg A \a -> orn (B a)
orn (rec j C) = rec (_ , j) (orn C)
-- We can forget the ornamentation and recover an element of the original type.
forget' : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}
{X : Σ I J -> Set}{Y : I -> Set} ->
({i : I}{j : J i} -> X (i , j) -> Y i) ->
(ΔC : Orn J C) -> ⟦ orn ΔC ⟧ X (i , j) -> ⟦ C ⟧ Y i
forget' φ (out j) refl = refl
forget' φ (arg B) (a , b) = a , forget' φ (B a) b
forget' φ (new A B) (a , b) = forget' φ (B a) b
forget' φ (rec j C) (a , b) = φ a , forget' φ C b
-- The termination checker runs into the same problem as the positivity
-- checker--it can't tell that forget' φ C x is only applying φ to
-- things smaller than x.
forget : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}
(ΔC : Orn J C) -> μ (orn ΔC) (i , j) -> μ C i
forget ΔC < x > = < forget' (forget ΔC) ΔC x >
-- A C-algebra over X takes us from ⟦ C ⟧ X i to X i.
Alg : {I : Set} -> Code I -> (I -> Set) -> Set
Alg C X = forall i -> ⟦ C ⟧ X i -> X i
-- We can fold by an algebra.
fold : {I : Set}{X : I -> Set}{C : Code I} ->
Alg C X -> {i : I} -> μ C i -> X i
fold {C = C} φ < x > = φ _ (map C (fold φ) x)
-- A type can be ornamented an arbitrary algebra over its functor.
decorate : {I : Set}{X : I -> Set}(C : Code I)
(φ : Alg C X) -> Orn X C
decorate (out i) φ = out (φ i refl)
decorate (arg A B) φ = arg \a -> decorate (B a) (\i b -> φ i (a , b))
decorate {X = X} (rec i C) φ = new (X i) \x -> rec x (decorate C \i b -> φ i (x , b))
-- Main theorem: If you have an element in a type decorated by φ, you
-- can recover forgotten decorations by folding with φ. Specialised to
-- lists and vectors we get
-- ∀ xs : Vec A n. length (forget xs) == n.
-- Two-level definition as usual.
thm' : {I : Set}{X J : I -> Set}{Y : Σ I J -> Set}
(C : Code I){i : I}{j : J i}(φ : Alg C J)
(F : {i : I} -> X i -> J i)
(ψ : {i : I}{j : J i} -> Y (i , j) -> X i) ->
({i : I}{j : J i}(z : Y (i , j)) -> F (ψ z) == j) ->
let ΔC = decorate C φ in
(x : ⟦ orn ΔC ⟧ Y (i , j)) ->
φ i (map C F (forget' ψ ΔC x)) == j
thm' (out i) φ F ψ ih refl = refl
thm' (arg A B) φ F ψ ih (a , b) = thm' (B a) (\i b -> φ i (a , b)) F ψ ih b
thm' (rec i C) {i = i0}{j = j0} φ F ψ ih (j , x , c)
with F (ψ x) | ih x | thm' C (\i b -> φ i (j , b)) F ψ ih c
... | .j | refl | rest = rest
thm : {I : Set}{J : I -> Set}(C : Code I){i : I}{j : J i}(φ : Alg C J) ->
(x : μ (orn (decorate C φ)) (i , j)) ->
fold φ (forget (decorate C φ) x) == j
thm C φ < x > = thm' C φ (fold φ) (forget (decorate C φ)) (thm C φ) x
-- Vectors as decorated lists.
lengthAlg : {A : Set} -> Alg (`List` A) (\_ -> Nat)
lengthAlg _ (enum ."nil" zero , _) = zero
lengthAlg _ (enum ."cons" (suc zero) , x , n , _) = suc n
lengthAlg _ (enum _ (suc (suc ())) , _)
length : {A : Set} -> List A -> Nat
length = fold lengthAlg
-- Now vectors are really lists decorated by their length.
`Vec` : (A : Set) -> Orn (\_ -> Nat) (`List` A)
`Vec` A = decorate (`List` A) lengthAlg
Vec : Set -> Nat -> Set
Vec A n = μ (orn (`Vec` A)) (_ , n)
nil : {A : Set} -> Vec A zero
nil = < enum "nil" zero , refl >
cons : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)
cons {n = n} x xs = < enum "cons" (suc zero) , x , n , xs , refl >
-- The proof that the index of the vector is really the length follows directly
-- from our main theorem.
corollary : {A : Set}{n : Nat}(xs : Vec A n) ->
length (forget (`Vec` _) xs) == n
corollary = thm (`List` _) lengthAlg
| 35.211765
| 85
| 0.500501
|
cb7eb240a05495163dcfb40d799d4d1ab8d78fa2
| 6,597
|
agda
|
Agda
|
benchmark/monad/MonadPostulates.agda
|
alex-mckenna/agda
|
78b62cd24bbd570271a7153e44ad280e52ef3e29
|
[
"BSD-3-Clause"
] | 1
|
2016-03-17T01:45:59.000Z
|
2016-03-17T01:45:59.000Z
|
benchmark/monad/MonadPostulates.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
benchmark/monad/MonadPostulates.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
------------------------------------------------------------------------
-- Parser monad
------------------------------------------------------------------------
open import Relation.Binary
open import Relation.Binary.OrderMorphism
open import Relation.Binary.PropositionalEquality
import Relation.Binary.Properties.StrictTotalOrder as STOProps
open import Data.Product
open import Level
module MonadPostulates where
postulate
-- Input string positions.
Position : Set
_<P_ : Rel Position zero
posOrdered : IsStrictTotalOrder _≡_ _<P_
-- Input strings.
Input : Position -> Set
-- In order to be able to store results in a memo table (and avoid
-- having to lift the table code to Set1) the result types have to
-- come from the following universe:
Result : Set
⟦_⟧ : Result -> Set
-- Memoisation keys. These keys must uniquely identify the
-- computation that they are associated with, when paired up with
-- the current input string position.
Key : let PosPoset = STOProps.poset
(record { Carrier = _ ; _≈_ = _; _<_ = _
; isStrictTotalOrder = posOrdered })
MonoFun = PosPoset ⇒-Poset PosPoset in
MonoFun -> Result -> Set
_≈'_ _<_ : Rel (∃₂ Key) zero
keyOrdered : IsStrictTotalOrder _≈'_ _<_
-- Furthermore the underlying equality needs to be strong enough.
funsEqual : _≈'_ =[ proj₁ ]⇒ _≡_
resultsEqual : _≈'_ =[ (\rfk -> proj₁ (proj₂ rfk)) ]⇒ _≡_
-- where
open _⇒-Poset_
open STOProps (record { Carrier = _ ; _≈_ = _; _<_ = _
; isStrictTotalOrder = posOrdered })
import IndexedMap as Map -- renaming (Map to MemoTable)
open import Category.Monad
open import Category.Monad.State
import Data.List as List; open List using (List)
open import Data.Unit hiding (poset; _≤_)
open import Function
open import Data.Maybe hiding (Eq)
open import Data.Product.Relation.Lex.Strict
open import Data.Product.Relation.Pointwise.NonDependent
import Relation.Binary.On as On
------------------------------------------------------------------------
-- Monotone functions
MonoFun : Set
MonoFun = poset ⇒-Poset poset
------------------------------------------------------------------------
-- Memo tables
-- Indices and keys used by the memo table.
Index : Set
Index = Position × MonoFun × Result
data MemoTableKey : Index -> Set where
key : forall {f r} (key : Key f r) pos -> MemoTableKey (pos , f , r)
-- Input strings of a certain maximum length.
Input≤ : Position -> Set
Input≤ pos = ∃ \pos′ -> pos′ ≤ pos × Input pos′
-- Memo table values.
Value : Index -> Set
Value (pos , f , r) = List (⟦ r ⟧ × Input≤ (fun f pos))
-- Shuffles the elements to simplify defining equality and order
-- relations for the keys.
shuffle : ∃ MemoTableKey -> Position × ∃₂ Key
shuffle ((pos , f , r) , key k .pos) = (pos , f , r , k)
-- Equality and order.
Eq : Rel (∃ MemoTableKey) _
Eq = Pointwise _≡_ _≈'_ on shuffle
Lt : Rel (∃ MemoTableKey) _
Lt = ×-Lex _≡_ _<P_ _<_ on shuffle
isOrdered : IsStrictTotalOrder Eq Lt
isOrdered = On.isStrictTotalOrder shuffle
(×-isStrictTotalOrder posOrdered keyOrdered)
indicesEqual′ : Eq =[ proj₁ ]⇒ _≡_
indicesEqual′ {((_ , _ , _) , key _ ._)}
{((_ , _ , _) , key _ ._)} (eq₁ , eq₂) =
cong₂ _,_ eq₁ (cong₂ _,_ (funsEqual eq₂) (resultsEqual eq₂))
open Map isOrdered (\{k₁} {k₂} -> indicesEqual′ {k₁} {k₂}) Value
{-
------------------------------------------------------------------------
-- Parser monad
-- The parser monad is built upon a list monad, for backtracking, and
-- two state monads. One of the state monads stores a memo table, and
-- is unaffected by backtracking. The other state monad, which /is/
-- affected by backtracking, stores the remaining input string.
-- The memo table state monad.
module MemoState = RawMonadState (StateMonadState MemoTable)
-- The list monad.
module List = RawMonadPlus List.ListMonadPlus
-- The inner monad (memo table plus list).
module IM where
Inner : Set -> Set
Inner R = State MemoTable (List R)
InnerMonadPlus : RawMonadPlus Inner
InnerMonadPlus = record
{ monadZero = record
{ monad = record
{ return = \x -> return (List.return x)
; _>>=_ = \m f -> List.concat <$> (List.mapM monad f =<< m)
}
; ∅ = return List.∅
}
; _∣_ = \m₁ m₂ -> List._∣_ <$> m₁ ⊛ m₂
}
where
open MemoState
InnerMonadState : RawMonadState MemoTable Inner
InnerMonadState = record
{ monad = RawMonadPlus.monad InnerMonadPlus
; get = List.return <$> get
; put = \s -> List.return <$> put s
}
where open MemoState
open RawMonadPlus InnerMonadPlus public
open RawMonadState InnerMonadState public
using (get; put; modify)
-- The complete parser monad.
module PM where
P : MonoFun -> Set -> Set
P f A = forall {n} -> Input n -> IM.Inner (A × Input≤ (fun f n))
-- Memoises the computation, assuming that the key is sufficiently
-- unique.
memoise : forall {f r} -> Key f r -> P f ⟦ r ⟧ -> P f ⟦ r ⟧
memoise k p {pos} xs =
let open IM in helper =<< lookup k′ <$> get
where
i = (pos , _)
k′ : MemoTableKey i
k′ = key k pos
helper : Maybe (Value i) -> State MemoTable (Value i)
helper (just ris) = return ris where open MemoState
helper nothing = p xs >>= \ris ->
modify (insert k′ ris) >>
return ris
where open MemoState
-- Other monadic operations.
return : forall {A} -> A -> P idM A
return a = \xs -> IM.return (a , _ , refl , xs)
_>>=_ : forall {A B f g} -> P f A -> (A -> P g B) -> P (g ∘M f) B
_>>=_ {g = g} m₁ m₂ xs =
m₁ xs ⟨ IM._>>=_ ⟩ \ays ->
let a = proj₁ ays
le = proj₁ $ proj₂ $ proj₂ ays
ys = proj₂ $ proj₂ $ proj₂ ays in
fix le ⟨ IM._<$>_ ⟩ m₂ a ys
where
lemma : forall {i j k} -> j ≤ k -> i ≤ fun g j -> i ≤ fun g k
lemma j≤k i≤gj = trans i≤gj (monotone g j≤k)
fix : forall {A i j} -> i ≤ j ->
A × Input≤ (fun g i) ->
A × Input≤ (fun g j)
fix le = map-× id (map-Σ id (map-× (lemma le) id))
∅ : forall {A} -> P idM A
∅ = const IM.∅
_∣_ : forall {A f} -> P f A -> P f A -> P f A
m₁ ∣ m₂ = \xs -> IM._∣_ (m₁ xs) (m₂ xs)
put : forall {n} -> Input n -> P (constM n) ⊤
put xs = \_ -> IM.return (_ , _ , refl , xs)
modify : forall {A f} ->
(forall {n} -> Input n -> A × Input (fun f n)) ->
P f A
modify g xs = IM.return (proj₁ gxs , _ , refl , proj₂ gxs)
where gxs = g xs
-}
| 28.682609
| 72
| 0.576929
|
39944a3437468127a76da36bdc6b24df553b4319
| 1,416
|
agda
|
Agda
|
src/Example.agda
|
notogawa/agda-haskell-example
|
9ad77d2aed8f950151e009135a9dfc02bc32ce65
|
[
"BSD-3-Clause"
] | 5
|
2015-07-28T05:04:58.000Z
|
2017-11-07T01:35:46.000Z
|
src/Example.agda
|
notogawa/agda-haskell-example
|
9ad77d2aed8f950151e009135a9dfc02bc32ce65
|
[
"BSD-3-Clause"
] | null | null | null |
src/Example.agda
|
notogawa/agda-haskell-example
|
9ad77d2aed8f950151e009135a9dfc02bc32ce65
|
[
"BSD-3-Clause"
] | null | null | null |
module Example where
open import Data.List
-- reverse
rev : ∀ {a} {A : Set a} → List A → List A
rev [] = []
rev (x ∷ xs) = rev xs ++ [ x ]
-- https://code.google.com/p/agda/issues/detail?id=1252 暫定対策
rev' = rev
{-# COMPILED_EXPORT rev' rev' #-}
private
open import Relation.Binary.PropositionalEquality
-- reverse2回で元に戻る証明
lemma : ∀ {a} {A : Set a} (x : A) (xs : List A) → rev (xs ∷ʳ x) ≡ x ∷ rev xs
lemma x [] = refl
lemma x (_ ∷ xs)
rewrite lemma x xs
= refl
revrev-is-id : ∀ {a} {A : Set a} (xs : List A) → rev (rev xs) ≡ xs
revrev-is-id [] = refl
revrev-is-id (x ∷ xs)
rewrite lemma x (rev xs)
| revrev-is-id xs
= refl
open import Data.Empty
head : ∀ {a} {A : Set a} (xs : List A) → {xs≢[] : xs ≢ []} → A
head [] {xs≠[]} = ⊥-elim (xs≠[] refl)
head (x ∷ xs) = x
{-
{-# COMPILED_EXPORT head safeHead' #-}
-- エラーになる
-- The type _≡_ cannot be translated to a Haskell type.
-- when checking the pragma COMPILED_EXPORT head' safeHead
--
-- つまり,証明オブジェクトを取るような関数は,
-- そのままではCOMPILED_EXPORTできないことが多い
-}
open import Data.Maybe
head' : ∀ {a} {A : Set a} (xs : List A) → Maybe A
head' = go where
go : ∀ {a} {A : Set a} (xs : List A) → Maybe A
go [] = nothing
go (x ∷ xs) = just (head (x ∷ xs) {λ ()})
{-# COMPILED_EXPORT head' safeHead' #-}
-- つまり,安全なheadを使うには,
-- 安全なものだけ渡せるようにしてjustで結果が得られ,
-- それ以外についてはnothingになるように,
-- 適切にラップしないとCOMPILED_EXPORTできない.
| 24.413793
| 78
| 0.591808
|
4d46e5f5ca856fb3e0792e1fb92a1f63bf57f377
| 5,463
|
agda
|
Agda
|
README/DependentlyTyped/NBE/Weakening.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | 5
|
2020-04-16T12:14:44.000Z
|
2020-07-08T22:51:36.000Z
|
README/DependentlyTyped/NBE/Weakening.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | null | null | null |
README/DependentlyTyped/NBE/Weakening.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Weakening for the NBE values
------------------------------------------------------------------------
import Axiom.Extensionality.Propositional as E
import Level
open import Data.Universe
-- The code makes use of the assumption that propositional equality of
-- functions is extensional.
module README.DependentlyTyped.NBE.Weakening
(Uni₀ : Universe Level.zero Level.zero)
(ext : E.Extensionality Level.zero Level.zero)
where
open import Data.Product renaming (curry to c)
open import deBruijn.Substitution.Data
open import Function.Base hiding (_∋_)
import README.DependentlyTyped.NBE.Value as Value
open Value Uni₀ renaming ([_] to [̌_])
import README.DependentlyTyped.NormalForm as NF
open NF Uni₀ renaming ([_] to [_]n)
import README.DependentlyTyped.NormalForm.Substitution as NFS
open NFS Uni₀
import README.DependentlyTyped.Term as Term; open Term Uni₀
import Relation.Binary.PropositionalEquality as P
open P.≡-Reasoning
mutual
-- Weakening.
w̌k[_] : ∀ {Γ} σ τ → V̌alue Γ τ → V̌alue (Γ ▻ σ) (τ /̂ ŵk)
w̌k[ _ ] (⋆ , τ) t = t /⊢n Renaming.wk
w̌k[ _ ] (el , τ) [ t ]el = [ t /⊢n Renaming.wk ]el
w̌k[ σ ] (π _ _ , τ) f =
(λ Γ₊ → proj₁ f (σ ◅ Γ₊)) , w̌k-π-well-behaved τ f
w̌k : ∀ {Γ σ} τ → V̌alue Γ τ → V̌alue (Γ ▻ σ) (τ /̂ ŵk)
w̌k τ v = w̌k[ _ ] τ v
abstract
-- The Π case of weakening is well-behaved.
w̌k-π-well-behaved :
∀ {Γ σ sp₁ sp₂} τ (f : V̌alue Γ (π sp₁ sp₂ , τ)) →
W̌ell-behaved sp₁ sp₂ (τ /̂I ŵk) (λ Γ₊ → proj₁ f (σ ◅ Γ₊))
w̌k-π-well-behaved {σ = σ} τ f Γ₊ v =
let lemma = begin
[ ⟦̌ τ /̂I ŵk ∣ (λ Γ₊ → proj₁ f (σ ◅ Γ₊)) ⟧-π /̂Val ŵk₊ Γ₊ ] ≡⟨ /̂Val-cong (P.sym $ w̌eaken-corresponds-π τ f) P.refl ⟩
[ ⟦̌_⟧ {σ = τ} f /̂Val ŵk[ σ ] /̂Val ŵk₊ Γ₊ ] ≡⟨ P.refl ⟩
[ ⟦̌ τ ∣ proj₁ f ⟧-π /̂Val ŵk₊ (σ ◅ Γ₊) ] ∎
in begin
[ (⟦̌ τ /̂I ŵk ∣ (λ Γ₊ → proj₁ f (σ ◅ Γ₊)) ⟧-π /̂Val ŵk₊ Γ₊ ) ˢ ⟦̌ v ⟧ ] ≡⟨ ˢ-cong lemma P.refl ⟩
[ (⟦̌ τ ∣ proj₁ f ⟧-π /̂Val ŵk₊ (σ ◅ Γ₊)) ˢ ⟦̌ v ⟧ ] ≡⟨ proj₂ f (σ ◅ Γ₊) v ⟩
[ ⟦̌ proj₁ f (σ ◅ Γ₊) v ⟧ ] ∎
-- The Π case of weakening weakens.
w̌eaken-corresponds-π :
∀ {Γ σ sp₁ sp₂} τ (f : V̌alue Γ (π sp₁ sp₂ , τ)) →
⟦̌_⟧ {σ = τ} f /̂Val ŵk[ σ ] ≅-Value
⟦̌ τ /̂I ŵk ∣ (λ Γ₊ → proj₁ f (σ ◅ Γ₊)) ⟧-π
w̌eaken-corresponds-π {σ = σ} τ f =
let f̌ = ⟦̌_⟧ {σ = τ} f
in begin
[ f̌ /̂Val ŵk[ σ ] ] ≡⟨ P.refl ⟩
[ c ((f̌ /̂Val ŵk₊ (σ ◅ fst τ /̂ ŵk ◅ ε)) ˢ lookup zero) ] ≡⟨ curry-cong $
ˢ-cong (P.refl {x = [ f̌ /̂Val ŵk₊ (σ ◅ fst τ /̂ ŵk ◅ ε) ]})
(P.sym $ ňeutral-to-normal-identity _ _) ⟩
[ c ((f̌ /̂Val ŵk₊ (σ ◅ fst τ /̂ ŵk ◅ ε)) ˢ ⟦ žero _ _ ⟧n) ] ≡⟨ curry-cong $ proj₂ f (σ ◅ fst τ /̂ ŵk ◅ ε) _ ⟩
[ c ⟦̌ proj₁ f (σ ◅ fst τ /̂ ŵk ◅ ε) (řeflect _ (var zero)) ⟧ ] ≡⟨ P.sym $ unfold-⟦̌∣⟧-π (τ /̂I ŵk) (λ Γ₊ → proj₁ f (σ ◅ Γ₊)) ⟩
[ ⟦̌ τ /̂I ŵk ∣ (λ Γ₊ → proj₁ f (σ ◅ Γ₊)) ⟧-π ] ∎
-- Weakening.
w̌eaken : ∀ {Γ} {σ : Type Γ} → [ V̌al ⟶ V̌al ] ŵk[ σ ]
w̌eaken = record
{ function = w̌k
; corresponds = corr
}
where
abstract
-- Weakening weakens.
corr : ∀ {Γ σ} τ (v : V̌alue Γ τ) →
⟦̌ v ⟧ /̂Val ŵk[ σ ] ≅-Value ⟦̌ w̌k[ σ ] τ v ⟧
corr (⋆ , τ) t = t /⊢n-lemma Renaming.wk
corr (el , τ) [ t ]el = t /⊢n-lemma Renaming.wk
corr (π sp₁ sp₂ , τ) f = w̌eaken-corresponds-π τ f
-- Variables can be turned into values.
v̌ar : [ Var ⟶⁼ V̌al ]
v̌ar = record
{ function = λ _ x → řeflect _ (var x)
; corresponds = λ _ x → P.sym $ ňeutral-to-normal-identity _ (var x)
}
-- Values can be turned into terms.
--
-- This definition uses the assumption that propositional equality of
-- functions is extensional. I don't know how much work is required to
-- avoid this assumption, or if it is even possible to do so.
V̌al↦Tm : V̌al ↦ Tm
V̌al↦Tm = record
{ trans = record
{ function = λ _ v → ⌊ řeify _ v ⌋
; corresponds = λ _ _ → P.refl
}
; simple = record
{ weaken = w̌eaken
; var = v̌ar
; weaken-var = w̌eaken-v̌ar _
}
}
where
open Renaming hiding (var)
abstract
w̌eaken-v̌ar : ∀ {Γ σ} τ (x : Γ ∋ τ) →
w̌k[ σ ] τ (v̌ar ⊙ x) ≅-V̌alue v̌ar ⊙ suc[ σ ] x
w̌eaken-v̌ar (⋆ , τ) x = begin
[̌ var (x /∋ wk) ] ≡⟨ ≅-⊢n-⇒-≅-Value-⋆ $ var-n-cong $ ≅-⊢-⇒-≅-∋ $ /∋-wk x ⟩
[̌ var (suc x) ] ∎
w̌eaken-v̌ar (el , τ) x = begin
[̌ [ var (x /∋ wk) ]el ] ≡⟨ ≅-⊢n-⇒-≅-Value-el $ var-n-cong $ ≅-⊢-⇒-≅-∋ $ /∋-wk x ⟩
[̌ [ var (suc x) ]el ] ∎
w̌eaken-v̌ar {σ = σ} (π _ _ , τ) x = ,-cong ext λ Γ₊ v → begin
[̌ řeflect _ ((var x /⊢n wk₊ (σ ◅ Γ₊)) · řeify _ v) ] ≡⟨ řeflect-cong $
·n-cong (var-n-cong $ ≅-⊢-⇒-≅-∋ $ /∋-wk₊-◅ x Γ₊)
(P.refl {x = [ řeify _ v ]n}) ⟩
[̌ řeflect _ ((var (suc x) /⊢n wk₊ Γ₊) · řeify _ v) ] ∎
module V̌al-subst = _↦_ V̌al↦Tm
| 38.202797
| 137
| 0.448655
|
12eda935fc1b7836dcd7ad8cfec55e5f5353cfdd
| 5,981
|
agda
|
Agda
|
test/epic/RunTests.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
test/epic/RunTests.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
test/epic/RunTests.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --no-termination-check #-}
module RunTests where
open import Prelude.Bool
open import Prelude.Char
open import Prelude.Exit
open import Prelude.IO
open import Prelude.List
open import Prelude.Nat
open import Prelude.Product
open import Prelude.String
open import Prelude.Unit
postulate
Stream : Set
popen : String -> String -> IO Stream
pclose : Stream -> IO Unit
readChar : Stream -> IO Char
strLen : String -> Nat
charAt : (s : String) -> Nat -> Char
{-# COMPILED_EPIC popen (s : String, m : String, u : Unit) ->
Ptr = foreign Ptr "popen" (s : String, m : String) #-}
{-# COMPILED_EPIC pclose (s : Ptr, u : Unit) ->
Unit = foreign Int "pclose" (s : Ptr) ; u #-}
{-# COMPILED_EPIC readChar (s : Ptr, u : Unit) ->
Int = foreign Int "fgetc" (s : Ptr) #-}
{-# COMPILED_EPIC strLen (s : Any) ->
BigInt = foreign BigInt "intToBig"
(foreign Int "strlen" (s : String) : Int) #-}
{-# COMPILED_EPIC charAt (s : Any, n : BigInt) ->
Int = foreign Int "charAtBig" (s : String, n : BigInt) #-}
_`_`_ : {A B C : Set}(x : A)(f : A -> B -> C)(y : B) -> C
x ` f ` y = f x y
infixr 9 _∘_
_∘_ : {A : Set}{B : A -> Set}{C : (x : A) -> B x -> Set}
(f : {a : A}(b : B a)-> C a b)
(g : (a : A) -> B a)(x : A) -> C x (g x)
f ∘ g = λ x -> f (g x)
infixr 1 _$_
_$_ : {A : Set}{B : A -> Set}(f : (x : A) -> B x)(x : A) -> B x
f $ x = f x
readStream : Stream -> IO (List Char)
readStream stream =
c <- readChar stream ,
if' charEq eof c
then pclose stream ,, return []
else ( cs <- readStream stream
, return (c :: cs) )
system : String -> IO (List Char)
system s =
putStrLn $ "running " +S+ s ,,
x <- popen s "r" ,
y <- readStream x ,
return y
span : {A : Set} -> (p : A -> Bool) -> List A -> List A × List A
span p [] = [] , []
span p (a :: as) with p a
... | false = [] , a :: as
... | true with span p as
... | xs , ys = (a :: xs) , ys
groupBy : {A : Set} -> (A -> A -> Bool) -> List A -> List (List A)
groupBy _ [] = []
groupBy eq (x :: xs) with span (eq x) xs
... | ys , zs = (x :: ys) :: groupBy eq zs
comparing : {A B : Set} -> (A -> B) -> (B -> B -> Bool) -> A -> A -> Bool
comparing f _==_ x y = f x == f y
FilePath : Set
FilePath = String
and : List Bool -> Bool
and [] = true
and (true :: xs) = and xs
and (false :: _) = false
sequence : {A : Set} -> List (IO A) -> IO (List A)
sequence [] = return []
sequence (x :: xs) =
r <- x ,
rs <- sequence xs ,
return (r :: rs)
mapM : {A B : Set} -> (A -> IO B) -> List A -> IO (List B)
mapM f xs = sequence (map f xs)
printList : List Char -> IO Unit
printList xs =
mapM printChar xs ,,
printChar '\n'
printResult : FilePath -> List Char -> List Char -> IO Unit
printResult filename l1 l2 with l1 ` listEq charEq ` l2
... | true = putStrLn (filename +S+ ": Success!")
... | false = putStrLn (filename +S+ ": Fail!") ,,
putStrLn "Expected:" ,,
printList l2 ,,
putStrLn "Got:" ,,
printList l1
-- The environment variable `AGDA_BIN` is defined in the Makefile.
compile : FilePath -> FilePath -> IO Unit
compile dir file =
agda-bin <- getEnv "AGDA_BIN" ,
system $ agda-bin +S+
" --epic --compile-dir=" +S+ dir +S+ "bin/ " +S+ dir +S+ file ,,
return unit
readFile : FilePath -> IO (List Char)
readFile file = system $ "cat " +S+ file
-- This won't work because of a bug in Epic...
{-
validFile : List Char -> Bool
validFile f with span (not ∘ charEq '.') f
... | _ , ('.' :: 'a' :: 'g' :: 'd' :: 'a' :: []) = true
... | _ , ('.' :: 'o' :: 'u' :: 't' :: []) = true
... | _ = false
-}
stripFileEnding : FilePath -> FilePath
stripFileEnding fp = fromList $ fst $ span (not ∘ charEq '.') (fromString fp)
testFile : FilePath -> FilePath -> FilePath -> IO Bool
testFile outdir agdafile outfile =
compile outdir agdafile ,,
out <- system $ outdir +S+ "bin/" +S+ stripFileEnding agdafile ,
expected <- readFile (outdir +S+ outfile) ,
printResult agdafile out expected ,,
return (out ` listEq charEq ` expected)
testFile' : FilePath -> List (List Char) -> IO Bool
testFile' outdir (agdafile :: outfile :: _) =
testFile outdir (fromList agdafile) (fromList outfile)
testFile' _ _ = return true
isNewline : Char -> Bool
isNewline '\n' = true
isNewline _ = false
lines : List Char -> List (List Char)
lines list with span (not ∘ isNewline) list
... | l , [] = l :: []
... | l , _ :: s' = l :: lines s'
getFiles : FilePath -> IO (List (List Char))
getFiles dir =
out <- system $ "ls " +S+ dir ,
putStrLn "getFiles after ls" ,,
-- mapM (printList ∘ snd) $ map (span (not ∘ charEq '.')) $ lines out ,,
return $ lines out -- filter validFile $ lines out
isDot : Char -> Bool
isDot '.' = true
isDot _ = false
testFiles : FilePath -> IO Bool
testFiles dir =
files <- getFiles dir ,
putStrLn "Found the following files in the tests directory:" ,,
mapM printList files ,,
res <- mapM (testFile' dir) (groupBy (comparing (fst ∘ span (not ∘ isDot)) (listEq charEq)) files) ,
return $ and res
getCurrentDirectory : IO FilePath
getCurrentDirectory = fromList <$> system "pwd"
main : IO Unit
main =
dir' <- getCurrentDirectory ,
putStrLn (fromList (fromString dir')) ,,
putStrLn "hello" ,,
putStrLn (fromList (tail ('h' :: 'e' :: 'j' :: []))) ,,
printList (fromString "hej igen") ,,
putStrLn (fromList (tail (fromString "hello"))) ,,
dir <- fromList ∘ init ∘ fromString <$> getCurrentDirectory ,
putStrLn dir ,,
system ("rm " +S+ dir +S+ "/tests/*.agdai") ,,
res <- testFiles (dir +S+ "/tests/") ,
if res
then (
putStrLn "All tests succeeded!" ,,
exit exitSuccess
)
else (
putStrLn "Not all tests succeeded" ,,
exit exitFailure
)
| 29.17561
| 102
| 0.552583
|
0ec8ab2e9f3fa2f75b1672bfcfe6f8f07a66cb99
| 3,998
|
agda
|
Agda
|
Groups/SymmetricGroups/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/SymmetricGroups/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/SymmetricGroups/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 LogicalFormulae
open import Setoids.Setoids
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Groups.Definition
open import Sets.EquivalenceRelations
open import Setoids.Functions.Extension
module Groups.SymmetricGroups.Definition where
data SymmetryGroupElements {a b : _} {A : Set a} (S : Setoid {a} {b} A) : Set (a ⊔ b) where
sym : {f : A → A} → SetoidBijection S S f → SymmetryGroupElements S
symmetricSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Setoid (SymmetryGroupElements S)
Setoid._∼_ (symmetricSetoid S) (sym {f} bijF) (sym {g} bijG) = ExtensionallyEqual {S = S} {S} (SetoidBijection.wellDefined bijF) (SetoidBijection.wellDefined bijG)
Equivalence.reflexive (Setoid.eq (symmetricSetoid S)) {sym {f} bijF} = extensionallyEqualReflexive S S f (SetoidBijection.wellDefined bijF) (SetoidBijection.wellDefined bijF)
Equivalence.symmetric (Setoid.eq (symmetricSetoid S)) {sym {f} bijF} {sym {g} bijG} f~g = extensionallyEqualSymmetric S S f g (SetoidBijection.wellDefined bijF) (SetoidBijection.wellDefined bijG) f~g
Equivalence.transitive (Setoid.eq (symmetricSetoid S)) {sym {f} bijF} {sym {g} bijG} {sym {h} bijH} f~g g~h = extensionallyEqualTransitive S S f g h (SetoidBijection.wellDefined bijF) (SetoidBijection.wellDefined bijG) (SetoidBijection.wellDefined bijH) f~g g~h
symmetricGroupOp : {a b : _} {A : Set a} {S : Setoid {a} {b} A} (f g : SymmetryGroupElements S) → SymmetryGroupElements S
symmetricGroupOp (sym {f} bijF) (sym {g} bijG) = sym (setoidBijComp bijG bijF)
symmetricGroupInv : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → SymmetryGroupElements S → SymmetryGroupElements S
symmetricGroupInv S (sym {f} bijF) with setoidBijectiveImpliesInvertible bijF
... | record { inverse = inverse ; inverseWellDefined = iwd ; isLeft = isLeft ; isRight = isRight } = sym (setoidInvertibleImpliesBijective (record { fWellDefined = iwd ; inverse = f ; inverseWellDefined = SetoidInjection.wellDefined (SetoidBijection.inj bijF) ; isLeft = λ b → isRight b ; isRight = λ b → isLeft b }))
symmetricGroupInvIsLeft : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → {x : SymmetryGroupElements S} → Setoid._∼_ (symmetricSetoid S) (symmetricGroupOp (symmetricGroupInv S x) x) (sym setoidIdIsBijective)
symmetricGroupInvIsLeft {A = A} S {sym {f = f} fBij} = ans
where
ans : {x : A} → Setoid._∼_ S (SetoidInvertible.inverse (setoidBijectiveImpliesInvertible fBij) (f x)) x
ans {x} with SetoidSurjection.surjective (SetoidBijection.surj fBij) {f x}
ans {x} | a , b = SetoidInjection.injective (SetoidBijection.inj fBij) b
symmetricGroupInvIsRight : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → {x : SymmetryGroupElements S} → Setoid._∼_ (symmetricSetoid S) (symmetricGroupOp x (symmetricGroupInv S x)) (sym setoidIdIsBijective)
symmetricGroupInvIsRight {A = A} S {sym {f = f} fBij} = ans
where
ans : {x : A} → Setoid._∼_ S (f (SetoidInvertible.inverse (setoidBijectiveImpliesInvertible fBij) x)) x
ans {x} with SetoidSurjection.surjective (SetoidBijection.surj fBij) {x}
ans {x} | a , b = b
symmetricGroup : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Group (symmetricSetoid S) (symmetricGroupOp {A = A})
Group.+WellDefined (symmetricGroup A) {sym {m} bijM} {sym {n} bijN} {sym {x} bijX} {sym {y} bijY} m~x n~y = transitive m~x (SetoidBijection.wellDefined bijX n~y)
where
open Equivalence (Setoid.eq A)
Group.0G (symmetricGroup A) = sym setoidIdIsBijective
Group.inverse (symmetricGroup S) = symmetricGroupInv S
Group.+Associative (symmetricGroup A) {sym {f} bijF} {sym {g} bijG} {sym {h} bijH} = Equivalence.reflexive (Setoid.eq A)
Group.identRight (symmetricGroup A) {sym {f} bijF} = Equivalence.reflexive (Setoid.eq A)
Group.identLeft (symmetricGroup A) {sym {f} bijF} = Equivalence.reflexive (Setoid.eq A)
Group.invLeft (symmetricGroup S) {x} = symmetricGroupInvIsLeft S {x}
Group.invRight (symmetricGroup S) {x} = symmetricGroupInvIsRight S {x}
| 75.433962
| 318
| 0.721111
|
12744016e01bd9a8a2af7221dbdc1425cedd567a
| 11,411
|
agda
|
Agda
|
src/Fragment/Tactic/Fragment.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 18
|
2021-06-15T15:45:39.000Z
|
2022-01-17T17:26:09.000Z
|
src/Fragment/Tactic/Fragment.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 1
|
2021-06-16T09:44:31.000Z
|
2021-06-16T10:24:15.000Z
|
src/Fragment/Tactic/Fragment.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 3
|
2021-06-15T15:34:50.000Z
|
2021-06-16T08:04:31.000Z
|
{-# OPTIONS --without-K --safe #-}
module Fragment.Tactic.Fragment where
open import Reflection hiding (name; Type; _≟_)
open import Reflection.Term using (_≟_)
open import Level using (_⊔_)
open import Relation.Binary using (Setoid)
open import Data.Bool using (Bool; _∨_; true; false; if_then_else_)
open import Data.Nat using (ℕ)
open import Data.List using (List; []; _∷_; map; sum; length)
open import Data.Vec using (fromList)
open import Data.Product using (_×_; _,_)
open import Data.Unit using (⊤; tt)
open import Data.String using (String; _++_)
open import Data.Maybe using (Maybe; just; nothing)
open import Fragment.Tactic.Utils
open import Fragment.Equational.Theory
open import Fragment.Equational.Model
open import Fragment.Equational.FreeExtension hiding (reduce)
open import Fragment.Algebra.Signature
import Fragment.Algebra.Free as Free
read-goal : List (Arg Term) → TC (Term × List (Arg Term))
read-goal (vArg x ∷ xs) = return (x , xs)
read-goal (_ ∷ xs) = read-goal xs
read-goal [] = typeError (strErr "failed to read goal" ∷ [])
read-goals : List (Arg Term) → TC (Term × Term)
read-goals xs = do (fst , xs) ← read-goal xs
(snd , _) ← read-goal xs
return (fst , snd)
extract-goals : Term → TC (Term × Term)
extract-goals (var _ args) = read-goals args
extract-goals (con _ args) = read-goals args
extract-goals (def _ args) = read-goals args
extract-goals (meta _ args) = read-goals args
extract-goals t =
typeError (strErr "can't read goals from" ∷ termErr t ∷ [])
record Operator : Set where
constructor operator
field
name : Name
normalised : Term
arity : ℕ
open Operator
record CoreCtx : Set where
field
signature : Term
theory : Term
model : Term
carrier : Term
frex : Term
record GlobalCtx : Set where
field
core : CoreCtx
operators : List Operator
telescope : List (Arg String)
lhs : Term
rhs : Term
open CoreCtx core public
pattern modelType Θ a ℓ = def (quote Model) (vArg Θ ∷ hArg a ∷ hArg ℓ ∷ [])
ctx : Name → Term → Term → TC GlobalCtx
ctx frex model goal
= do τ ← inferType model
γ ← inferType goal
signature ← extract-Σ τ
theory ← extract-Θ τ
carrier ← normalise (def (quote ∥_∥) (vra theory ∷ vra model ∷ []))
let core = record { signature = signature
; theory = theory
; model = model
; carrier = carrier
; frex = def frex []
}
operators ← extract-ops core
(inner , telescope) ← strip-telescope γ
(lhs , rhs) ← extract-goals inner
return (record { core = core
; operators = operators
; telescope = telescope
; lhs = lhs
; rhs = rhs
})
where modelErr : ∀ {a} {A : Set a} → Term → String → TC A
modelErr t err =
typeError ( termErr t
∷ strErr "isn't a"
∷ nameErr (quote Model)
∷ strErr ("(" ++ err ++ ")")
∷ []
)
extract-Σ : Term → TC Term
extract-Σ (modelType Θ _ _) = normalise (def (quote Theory.Σ) (vra Θ ∷ []))
extract-Σ t = modelErr t "when extracting the signature"
extract-Θ : Term → TC Term
extract-Θ (modelType Θ _ _) = normalise Θ
extract-Θ t = modelErr t "when extracting the theory"
extract-arity : CoreCtx → Name → TC ℕ
extract-arity ctx op
= do τ ← inferType (def (quote _⟦_⟧_)
( vra (CoreCtx.theory ctx)
∷ vra (CoreCtx.model ctx)
∷ vra (con op [])
∷ []
))
α ← extract-type-arg τ
vec-len α
extract-interp : CoreCtx → Name → ℕ → TC Term
extract-interp ctx op arity
= do let t = def (quote _⟦_⟧_)
( vra (CoreCtx.theory ctx)
∷ vra (CoreCtx.model ctx)
∷ vra (con op [])
∷ []
)
normalise (n-ary arity (apply t (vra (vec (debrujin arity)) ∷ [])))
extract-ops : CoreCtx → TC (List Operator)
extract-ops ctx
= do ops ← normalise (def (quote ops) (vra (CoreCtx.signature ctx) ∷ []))
symbols ← extract-constructors ops
arities ← listTC (map (extract-arity ctx) symbols)
interps ← listTC (mapList (map (extract-interp ctx) symbols) arities)
return (mapList (mapList (map operator symbols) interps) arities)
record FoldCtx {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
constructor foldCtx
field
global : GlobalCtx
f : Term → B → A × B
g : Operator → List A → A
ε : B
open GlobalCtx global public
mutual
map-fold : ∀ {a b} {A : Set a} {B : Set b}
→ FoldCtx A B → List (Arg Term) → B → TC (List A × B)
map-fold ctx [] acc = return ([] , acc)
map-fold ctx (vArg x ∷ xs) acc
= do (x , acc) ← fold-acc ctx x acc
(xs , acc) ← map-fold ctx xs acc
return (x ∷ xs , acc)
map-fold ctx (_ ∷ xs) acc = map-fold ctx xs acc
fold-inner : ∀ {a b} {A : Set a} {B : Set b}
→ FoldCtx A B → Operator → Term → B → TC (List A × B)
fold-inner ctx op (var _ args) acc = map-fold ctx (ekat (arity op) args) acc
fold-inner ctx op (con _ args) acc = map-fold ctx (ekat (arity op) args) acc
fold-inner ctx op (def _ args) acc = map-fold ctx (ekat (arity op) args) acc
fold-inner ctx op (meta _ args) acc = map-fold ctx (ekat (arity op) args) acc
fold-inner ctx op (pat-lam _ args) acc = map-fold ctx (ekat (arity op) args) acc
fold-inner _ _ t _ = typeError (termErr t ∷ strErr "has no arguments" ∷ [])
fold-acc : ∀ {a b} {A : Set a} {B : Set b} → FoldCtx A B → Term → B → TC (A × B)
fold-acc ctx t acc
= do op? ← find (λ x → prefix (arity x) (normalised x) t) (FoldCtx.operators ctx)
resolve op?
where resolve : Maybe Operator → TC _
resolve (just op)
= do (args , acc) ← fold-inner ctx op t acc
return ((FoldCtx.g ctx) op args , acc)
resolve nothing = return ((FoldCtx.f ctx) t acc)
fold : ∀ {a b} {A : Set a} {B : Set b} → FoldCtx A B → Term → TC (A × B)
fold ctx t = fold-acc ctx t (FoldCtx.ε ctx)
fold-⊤ : ∀ {a} {A : Set a} → GlobalCtx
→ (Term → A) → (Operator → List A → A) → Term → TC A
fold-⊤ ctx f g t
= do (x , _) ← fold (foldCtx ctx (λ x _ → (f x , tt)) g tt) t
return x
accumulate : ∀ {a} {A : Set a} → GlobalCtx
→ (Term → A → A) → A → Term → TC A
accumulate ctx f ε t
= do (_ , acc) ← fold (foldCtx ctx (λ x acc → (tt , f x acc)) (λ _ _ → tt) ε) t
return acc
leaves : GlobalCtx → Term → TC ℕ
leaves ctx = fold-⊤ ctx (λ _ → 1) (λ _ → sum)
mutual
argsOpen : Term → List (Arg Term) → TC Bool
argsOpen τ [] = return false
argsOpen τ (vArg x ∷ xs)
= do head ← isOpen τ x
tail ← argsOpen τ xs
return (head ∨ tail)
argsOpen τ (_ ∷ xs) = argsOpen τ xs
isOpen : Term → Term → TC Bool
isOpen τ t@(var _ _) = hasType τ t
isOpen τ t@(meta _ _) = hasType τ t
isOpen τ (con c args) = argsOpen τ args
isOpen τ (def f args) = argsOpen τ args
isOpen τ unknown = return true
isOpen τ _ = return false
findOpen : GlobalCtx → List Term → Term → TC (List Term)
findOpen ctx ε t = flatten (accumulate ctx binding (return ε) t)
where binding : Term → TC (List Term) → TC (List Term)
binding t env
= do env ← env
let τ = CoreCtx.carrier (GlobalCtx.core ctx)
open? ← isOpen τ t
if open? then return (insert env t)
else return env
buildSyntax : GlobalCtx → List Term → Term → TC Term
buildSyntax ctx env t = fold-⊤ ctx buildInj buildTerm t
where bt : Term
bt = def (quote Free.BT)
( vra (GlobalCtx.signature ctx)
∷ vra (GlobalCtx.carrier ctx)
∷ vra (lit (nat (length env)))
∷ []
)
buildAtom : Term → Term
buildAtom t =
con (quote Free.Term.atom)
( hra (GlobalCtx.signature ctx)
∷ hra unknown
∷ hra bt
∷ vra t
∷ []
)
buildDyn : ℕ → Term
buildDyn n =
con (quote Free.BT.dyn)
( hra (GlobalCtx.signature ctx)
∷ hra unknown
∷ hra (GlobalCtx.carrier ctx)
∷ hra (lit (nat (length env)))
∷ vra (fin n)
∷ []
)
buildSta : Term → Term
buildSta t =
con (quote Free.BT.sta)
( hra (GlobalCtx.signature ctx)
∷ hra unknown
∷ hra (GlobalCtx.carrier ctx)
∷ hra (lit (nat (length env)))
∷ vra t
∷ []
)
buildInj : Term → Term
buildInj t with indexOf env t
... | just n = buildAtom (buildDyn n)
... | nothing = buildAtom (buildSta t)
buildTerm : Operator → List Term → Term
buildTerm op xs =
con (quote Free.Term.term)
( hra (GlobalCtx.signature ctx)
∷ hra unknown
∷ hra bt
∷ hra (lit (nat (arity op)))
∷ vra (con (name op) [])
∷ vra (vec (fromList xs))
∷ []
)
environment : List Term → Term
environment env = vec (fromList env)
macro
fragment : Name → Term → Term → TC ⊤
fragment frex model goal
= do ctx ← ctx frex model goal
env ← findOpen ctx [] (GlobalCtx.lhs ctx)
env ← findOpen ctx env (GlobalCtx.rhs ctx)
lhs ← buildSyntax ctx env (GlobalCtx.lhs ctx)
rhs ← buildSyntax ctx env (GlobalCtx.rhs ctx)
let n = length env
let frex = def (quote FreeExtension._[_])
( hra (GlobalCtx.theory ctx)
∷ vra (GlobalCtx.frex ctx)
∷ vra (GlobalCtx.model ctx)
∷ vra (lit (nat n))
∷ []
)
let setoid = def (quote ∥_∥/≈)
( hra (GlobalCtx.theory ctx)
∷ vra frex
∷ []
)
let p = def (quote Setoid.refl) (vra setoid ∷ [])
let frexify = def (quote frexify)
( vra (GlobalCtx.theory ctx)
∷ vra (GlobalCtx.frex ctx)
∷ vra (GlobalCtx.model ctx)
∷ vra (vec (fromList env))
∷ hra lhs
∷ hra rhs
∷ vra p
∷ []
)
frexify ← restore-telescope (GlobalCtx.telescope ctx) frexify
unify frexify goal
| 34.370482
| 85
| 0.502498
|
181a8dc0d8cea9bbf79aecac70cd1bbb50ba9499
| 3,031
|
agda
|
Agda
|
agda-stdlib-0.9/README/AVL.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/README/AVL.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/README/AVL.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some examples showing how the AVL tree module can be used
------------------------------------------------------------------------
module README.AVL where
------------------------------------------------------------------------
-- Setup
-- AVL trees are defined in Data.AVL.
import Data.AVL
-- This module is parametrised by keys, which have to form a (strict)
-- total order, and values, which are indexed by keys. Let us use
-- natural numbers as keys and vectors of strings as values.
import Data.Nat.Properties as ℕ
open import Data.String using (String)
open import Data.Vec using (Vec; _∷_; [])
open import Relation.Binary using (module StrictTotalOrder)
open Data.AVL (Vec String)
(StrictTotalOrder.isStrictTotalOrder ℕ.strictTotalOrder)
------------------------------------------------------------------------
-- Construction of trees
-- Some values.
v₁ = "cepa" ∷ []
v₁′ = "depa" ∷ []
v₂ = "apa" ∷ "bepa" ∷ []
-- Empty and singleton trees.
t₀ : Tree
t₀ = empty
t₁ : Tree
t₁ = singleton 2 v₂
-- Insertion of a key-value pair into a tree.
t₂ = insert 1 v₁ t₁
-- If you insert a key-value pair and the key already exists in the
-- tree, then the old value is thrown away.
t₂′ = insert 1 v₁′ t₂
-- Deletion of the mapping for a certain key.
t₃ = delete 2 t₂
-- Conversion of a list of key-value mappings to a tree.
open import Data.List using (_∷_; [])
open import Data.Product as Prod using (_,_; _,′_)
t₄ = fromList ((2 , v₂) ∷ (1 , v₁) ∷ [])
------------------------------------------------------------------------
-- Queries
-- Let us formulate queries as unit tests.
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
-- Searching for a key.
open import Data.Bool using (true; false)
open import Data.Maybe as Maybe using (just; nothing)
q₀ : lookup 2 t₂ ≡ just v₂
q₀ = refl
q₁ : lookup 2 t₃ ≡ nothing
q₁ = refl
q₂ : 3 ∈? t₂ ≡ false
q₂ = refl
q₃ : 1 ∈? t₄ ≡ true
q₃ = refl
-- Turning a tree into a sorted list of key-value pairs.
q₄ : toList t₁ ≡ (2 , v₂) ∷ []
q₄ = refl
q₅ : toList t₂ ≡ (1 , v₁) ∷ (2 , v₂) ∷ []
q₅ = refl
q₅′ : toList t₂′ ≡ (1 , v₁′) ∷ (2 , v₂) ∷ []
q₅′ = refl
------------------------------------------------------------------------
-- Views
-- Partitioning a tree into the smallest element plus the rest, or the
-- largest element plus the rest.
open import Function using (id)
v₆ : headTail t₀ ≡ nothing
v₆ = refl
v₇ : Maybe.map (Prod.map id toList) (headTail t₂) ≡
just ((1 , v₁) , ((2 , v₂) ∷ []))
v₇ = refl
v₈ : initLast t₀ ≡ nothing
v₈ = refl
v₉ : Maybe.map (Prod.map toList id) (initLast t₄) ≡
just (((1 , v₁) ∷ []) ,′ (2 , v₂))
v₉ = refl
------------------------------------------------------------------------
-- Further reading
-- Variations of the AVL tree module are available:
-- • Finite maps with indexed keys and values.
import Data.AVL.IndexedMap
-- • Finite sets.
import Data.AVL.Sets
| 22.619403
| 72
| 0.549324
|
dfabfd03c73b2d77a281d52485cdaf0d09d961d7
| 1,417
|
agda
|
Agda
|
TotalRecognisers/Simple/Expression.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
TotalRecognisers/Simple/Expression.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
TotalRecognisers/Simple/Expression.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Example: Right recursive expression grammar
------------------------------------------------------------------------
module TotalRecognisers.Simple.Expression where
open import Coinduction
open import Data.Bool
open import Data.Char as Char using (Char)
open import Data.String as String using (String)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Decidable
import TotalRecognisers.Simple as P
private
open module PC = P Char Char._≟_ hiding (_·_)
open PC.P using (_·_)
------------------------------------------------------------------------
-- Recognisers for bits and binary numbers
-- Bits.
bit = tok '0' ∣ tok '1'
-- Numbers.
number = bit · ♯ (empty ∣ number)
------------------------------------------------------------------------
-- An expression grammar
-- t ∷= f '+' t ∣ f
-- f ∷= a '*' f ∣ a
-- a ∷= '(' t ')' ∣ n
mutual
term = factor · ♯ (tok '+' · ♯ term)
∣ factor
factor = atom · ♯ (tok '*' · ♯ factor)
∣ atom
atom = tok '(' · ♯ term · ♯ tok ')'
∣ number
------------------------------------------------------------------------
-- Unit tests
module Tests where
test : ∀ {n} → P n → String → Bool
test p s = ⌊ String.toList s ∈? p ⌋
ex₁ : test term "0*(0+0)" ≡ true
ex₁ = refl
ex₂ : test term "0*(0+0" ≡ false
ex₂ = refl
| 22.854839
| 72
| 0.455187
|
239dcf7d73c8cf246072308325a5d39e97027195
| 2,009
|
agda
|
Agda
|
src/fot/FOTC/Program/ABP/Fair/Type.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Program/ABP/Fair/Type.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Program/ABP/Fair/Type.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Fairness of the ABP channels
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.ABP.Fair.Type where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.List
open import FOTC.Program.ABP.Terms
------------------------------------------------------------------------------
-- The Fair co-inductive predicate
-- From (Dybjer and Sander 1989): al : F*T if al is a list of zero or
-- more 0's followed by a final 1.
data F*T : D → Set where
f*tnil : F*T (T ∷ [])
f*tcons : ∀ {ft} → F*T ft → F*T (F ∷ ft)
-- Functor for the Fair type.
-- FairF : (D → Set) → D → Set
-- FairF A os = ∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ A os'
-- Fair is the greatest fixed of FairF (by Fair-out and Fair-coind).
postulate Fair : D → Set
-- Fair a is post-fixed point of FairF, i.e.
--
-- Fair ≤ FairF Fair.
postulate Fair-out : ∀ {os} → Fair os →
∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ Fair os'
{-# ATP axiom Fair-out #-}
-- Fair is the greatest post-fixed point of FairF, i.e.
--
-- ∀ A. A ≤ FairF A ⇒ A ≤ Fair.
--
-- N.B. This is an axiom schema. Because in the automatic proofs we
-- *must* use an instance, we do not add this postulate as an ATP
-- axiom.
postulate
Fair-coind :
(A : D → Set) →
-- A is post-fixed point of FairF.
(∀ {os} → A os → ∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ A os') →
-- Fair is greater than A.
∀ {os} → A os → Fair os
------------------------------------------------------------------------------
-- References
--
-- Dybjer, Peter and Sander, Herbert P. (1989). A Functional
-- Programming Approach to the Specification and Verification of
-- Concurrent Systems. Formal Aspects of Computing 1, pp. 303–319.
| 32.403226
| 78
| 0.498756
|
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.