Open jmikedupont2 opened 9 months ago
In UniMath, a dependent pair type is written as (x : X) * (P x)
, where X
is the type of the label, and P
is a type family that determines the type of the content depending on the label. A value of this type is written as tpair X P x p
, where x
is the label and p
is the content. The shape of the box is determined by the type X
and the type family P
. For example, if X
is bool
and P
is the constant type family nat
, then the shape of the box is either (true, n)
or (false, n)
, where n
is any natural number. The label is either true
or false
, and the content is a natural number.
To access the label and the content of a dependent pair, we can use the projection functions pr1
and pr2
. The function pr1
takes a dependent pair and returns its label. The function pr2
takes a dependent pair and returns its content. For example, if s
is a dependent pair of type (x : X) * (P x)
, then pr1 s
is the label of type X
, and pr2 s
is the content of type P (pr1 s)
. Note that the type of the content depends on the value of the label.
I hope this clarifies how to label the contents, labels and shape of the box in UniMath. If you have any other questions, feel free to ask me. 😊
Source: Conversation with Bing, 2/4/2024 (1) Dependent pair types of finite types - Agda-UniMath. https://jonaprieto.github.io/agda-unimath/univalent-combinatorics.dependent-pair-types.html. (2) From Signatures to Monads in UniMath - Springer. https://link.springer.com/content/pdf/10.1007/s10817-018-9474-4.pdf. (3) From Signatures to Monads in UniMath | Journal of Automated Reasoning. https://link.springer.com/article/10.1007/s10817-018-9474-4.
Sure, I can help you with that. A type family P is a function that takes a value of some type X and returns a type. For example, if X is the type of natural numbers, then P could be a type family that returns the type of vectors of length X. A type family P can be seen as a way of defining a type that depends on another type.
In UniMath, a type family P is defined using the notation P : X -> UU
, where X
is the type of the input and UU
is the type of types. For example, the following code defines a type family vec
that takes a natural number n
and returns the type of vectors of length n
:
Definition vec (n : nat) : UU := ∑ l : list nat, length l = n.
Here, vec
is a dependent pair type, where the first component is a list of natural numbers and the second component is a proof that the length of the list is equal to n
. The symbol ∑
is used to denote a dependent pair type, and the symbol =
is used to denote an identity type.
A type family P can also be defined using the notation P : ∏ x : X, UU
, where ∏
is used to denote a dependent function type. This notation is equivalent to the previous one, but it makes the dependency on x
more explicit. For example, the following code defines the same type family vec
as before, but using the ∏
notation:
Definition vec : ∏ n : nat, UU := λ n, ∑ l : list nat, length l = n.
Here, λ
is used to denote a lambda abstraction, which is a way of defining a function by giving an expression for its output. The expression λ n, ∑ l : list nat, length l = n
is a function that takes a natural number n
and returns a dependent pair type as before.
I hope this explains how to define a type family P in UniMath. If you have any other questions, feel free to ask me. 😊
Source: Conversation with Bing, 2/4/2024 (1) The universal property of identity types - Agda-UniMath. https://jonaprieto.github.io/agda-unimath/foundation.universal-property-identity-types.html. (2) Universal Algebra in UniMath - arXiv.org. https://arxiv.org/pdf/2102.05952.pdf. (3) Introduction to Univalent Foundations of Mathematics with Agda - arXiv.org. https://arxiv.org/pdf/1911.00580v2.pdf. (4) undefined. https://github.com/amato-gianluca/UniMath/releases/tag/ITP2021.
Sure, I can explain each symbol in your goal. Here is a table that summarizes their meanings and definitions:
Symbol | Meaning | Definition |
---|---|---|
X | A type | A type is a collection of values that share some properties. For example, nat is the type of natural numbers. |
UU | The type of types | UU is a special type that contains all the types that can be constructed in UniMath. For example, nat : UU means that nat is a type in UU. |
P, Q | Type families | A type family is a function that takes a value of some type and returns a type. For example, P : X -> UU means that P is a type family that takes a value of type X and returns a type in UU . |
f | An equivalence | An equivalence is a function that preserves the structure and properties of the types it maps. For example, f : ∏ x : X, P x ≃ Q x means that f is a function that takes a value x of type X and returns an equivalence between the types P x and Q x . |
∏ | A dependent function type | A dependent function type is a type of functions that can have different output types depending on the input value. For example, ∏ x : X, P x is the type of functions that take a value x of type X and return a value of type P x . |
≃ | An identity type | An identity type is a type that expresses the equality between two values of the same type. For example, P x ≃ Q x is the type of proofs that P x and Q x are equal types. |
xp | A dependent pair | A dependent pair is a pair of values, where the type of the second value depends on the value of the first one. For example, xp : ∑ y : X, Q y means that xp is a pair of a value y of type X and a value of type Q y . |
∑ | A dependent pair type | A dependent pair type is a type of pairs that have a dependency between the first and the second component. For example, (x : X) * (P x) is the type of pairs that have a value x of type X and a value of type P x . |
I hope this table helps you understand the symbols in your goal. If you have any other questions, feel free to ask me. 😊
Source: Conversation with Bing, 2/4/2024 (1) Symbolsdefinedbyunicode-math - texdoc. https://texdoc.org/serve/unimath-symbols.pdf/0. (2) Unimath Symbols. https://onemathematicalcat.org/MathJaxDocumentation/unimath-symbols.pdf. (3) Symbolsdefinedbyunicode-math. https://ctan.math.washington.edu/tex-archive/fonts/erewhon-math/unimath-erewhon.pdf.
Goal: X : UU P : X → UU Q : X → UU f : ∏ x : X, P x ≃ Q x xp : ∑ y : X, Q y
(totalfun P Q (λ x : X, f x) (totalfun Q P (λ x : X, invmap (f x)) xp) = xp)
DEBUG:Going to execute: PTRDEBUGTACsimple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) || simple refine (p ) Level 0: Backtrace:
In environment X : UU P, Q : X → UU f : ∏ x : X, P x ≃ Q x xp : ∑ y : X, Q y The term "total2_paths_f" has type "∏ p : pr1 ?s = pr1 ?s', transportf ?B p (pr2 ?s) = pr2 ?s' → ?s = ?s'" while it is expected to have type "totalfun P Q (λ x : X, f x) (totalfun Q P (λ x : X, invmap (f x)) xp) = xp". Level 0: Backtrace:
In environment X : UU P, Q : X → UU f : ∏ x : X, P x ≃ Q x xp : ∑ y : X, Q y The term "total2_paths_f" has type "∏ p : pr1 ?s = pr1 ?s', transportf ?B p (pr2 ?s) = pr2 ?s' → ?s = ?s'" while it is expected to have type "totalfun P Q (λ x : X, f x) (totalfun Q P (λ x : X, invmap (f x)) xp) = xp".
TcDebug (0) > NONE??? LtacNotationCall (no location),/mnt/data1/2024/01/05/UniMath/UniMath/Foundations/Init.vsimple_rapply:172, Init (UniMath.Foundations),/mnt/data1/2024/01/05/UniMath/UniMath/Foundations/Init.v??? LtacNotationCall:189, Init (UniMath.Foundations),/mnt/data1/2024/01/05/UniMath/UniMath/Foundations/PartA.v:3438
I see. You want to understand the intuition behind the proof, not just the formal steps. Let me try to explain it using some metaphors and analogies.
The goal is to show that two dependent pairs are equal. A dependent pair is a pair of values, where the type of the second value depends on the value of the first one. For example, a dependent pair of type
(x : nat) * (vector nat x)
is a pair of a natural number and a vector of that length. A dependent pair can be seen as a package that contains two things: a label and a content. The label tells us what kind of content we have, and the content depends on the label.The lemma
total2_paths_f
says that two packages are equal if their labels are equal and their contents are equal after transporting them along the equality of the labels. Transporting is a way of moving a value from one type to another, using an equality between the types. For example, if we have a vector of length 3 and an equality3 = 2 + 1
, we can transport the vector to a vector of length 2 + 1, by adding or removing an element. Transporting can be seen as a repacking operation, where we change the shape of the content to fit the new label.The problem is that your goal does not match the conclusion of the lemma. Your goal says that two packages are equal if their labels are equal and their contents are equal without transporting them. This means that you have two packages that have the same shape, but different labels. This can happen if the labels are equivalent, but not equal. For example,
3
and2 + 1
are equivalent natural numbers, but not equal. Equivalence is a weaker notion of equality, that allows some flexibility or variation. Equivalence can be seen as a translation operation, where we change the language or notation of the label, but not the meaning.To use the lemma
total2_paths_f
, you need to convert your equivalence into an equality, and then transport your contents accordingly. This can be done by using some other lemmas that deal with equivalence and transport. The lemmatotalfun_paths
says that two packages are equal if their labels are equal and their contents are equal pointwise. The lemmaweqhomot
says that two equivalences are equal if they agree on all inputs. The lemmainvmap_eq
says that the inverse of an equivalence is equal to the equivalence applied to the equality of its outputs. The lemmahomotweqinvweq
says that applying an equivalence and then its inverse is equal to the identity function.Using these lemmas, you can show that your packages have equal labels, by applying the equivalences
f
andinvmap (f x)
to the labels, and usingweqhomot
andinvmap_eq
to show that they are equal. Then, you can show that your packages have equal contents, by applying the same equivalences to the contents, and usingweqhomot
andhomotweqinvweq
to show that they are equal. Finally, you can usetotal2_paths2
to conclude that your packages are equal, without transporting anything.I hope this explanation makes sense to you. If you have any other questions, feel free to ask me. 😊