Skip to content

Commit 113ebdb

Browse files
committed
improvements
1 parent fc175cf commit 113ebdb

25 files changed

+1075
-250
lines changed

UALib/Relations/Continuous.lagda

+38-19
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,31 @@ We refer to such relations as *dependent continuous relations* (or *dependent re
3232

3333

3434

35+
#### <a id="continuous-and-dependent-relations">Continuous and dependent relations</a>
3536

37+
We now define the type `ContRel` which represents predicates of arbitrary arity over a single type `A`. We call this the type of *continuous relations*.<sup>[1](Relations.Continuous.html#fn1)</sup>)
3638

39+
\begin{code}
3740

41+
ContRel : 𝓥 ̇ → 𝓤 ̇ → (𝓦 : Universe) → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⁺ ̇
42+
ContRel I A 𝓦 = (I → A) → 𝓦 ̇
3843

44+
\end{code}
3945

40-
#### <a id="continuous-relations">Continuous relations</a>
41-
42-
We now define the type `ContRel` which represents predicates of arbitrary arity over a single type `A`. We call this the type of *continuous relations*.<sup>[1](Relations.Continuous.html#fn1)</sup>)
46+
We now exploit the full power of dependent types to define a completely general relation type. Specifically, we let the tuples inhabit a dependent function type `𝒜 : I → 𝓤 ̇`, where the codomain may depend upon the input coordinate `i : I` of the domain. Heuristically, think of the inhabitants of the following type as relations from `𝒜 i` to `𝒜 j` to `𝒜 k` to …. (This is only an heuristic since \ab I can represent an uncountable collection.\cref{uncountable}.<sup>[2](Relations.Continuous.html#fn2)</sup>)
4347

4448
\begin{code}
4549

46-
ContRel : 𝓥 ̇ → 𝓤 ̇ → (𝓦 : Universe) → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⁺ ̇
47-
ContRel I A 𝓦 = (I → A) → 𝓦 ̇
50+
DepRel : (I : 𝓥 ̇)(I → 𝓤 ̇) → (𝓦 : Universe) → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⁺ ̇
51+
DepRel I 𝒜 𝓦 = Π 𝒜 → 𝓦 ̇
4852

4953
\end{code}
5054

55+
We call `DepRel` the type of *dependent relations*.
5156

5257

5358

54-
#### <a id="compatibility-with-continuous-relations">Compatibility with continuous relations</a>
59+
#### <a id="compatibility-with-general-relations">Compatibility with general relations</a>
5560

5661
We now define some functions that make it easy to assert that a given operation is compatible with a given relation. The first is an *evaluation* function which "lifts" an `I`-ary relation to an `(I → J)`-ary relation. The lifted relation will relate an `I`-tuple of `J`-tuples when the "`I`-slices" (or "rows") of the `J`-tuples belong to the original relation.
5762

@@ -80,19 +85,6 @@ To readers who find the syntax of the last two definitions nauseating, we recomm
8085
Now `eval-cont-rel R 𝒶` is defined by `∀ j → R (λ i → 𝒶 i j)` which represents the assertion that each row of the `I` columns shown above belongs to the original relation `R`. Finally, `cont-compatible-op` takes a `J`-ary operation `𝑓 : Op J A` and an `I`-tuple `𝒶 : I → J → A` of `J`-tuples, and determines whether the `I`-tuple `λ i → 𝑓 (𝑎 i)` belongs to `R`.
8186

8287

83-
#### <a id="dependent-relations">Dependent relations</a>
84-
85-
In this section we exploit the power of dependent types to define a completely general relation type. Specifically, we let the tuples inhabit a dependent function type `𝒜 : I → 𝓤 ̇`, where the codomain may depend upon the input coordinate `i : I` of the domain. Heuristically, think of the inhabitants of the following type as relations from `𝒜 i` to `𝒜 j` to `𝒜 k` to …. (This is only an heuristic since \ab I can represent an uncountable collection.\cref{uncountable}.<sup>[2](Relations.Continuous.html#fn2)</sup>)
86-
87-
\begin{code}
88-
89-
DepRel : (I : 𝓥 ̇) → (I → 𝓤 ̇) → (𝓦 : Universe) → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⁺ ̇
90-
DepRel I 𝒜 𝓦 = Π 𝒜 → 𝓦 ̇
91-
92-
\end{code}
93-
94-
We call `DepRel` the type of *dependent relations*.
95-
9688
Above we saw lifts of continuous relations and what it means for such relations to be compatible with operations. We conclude this module by defining the (only slightly more complicated) lift of dependent relations, and the type that represents compatibility of a dependent relation with an operation.
9789

9890
\begin{code}
@@ -129,3 +121,30 @@ module _ {I J : 𝓥 ̇} {𝒜 : I → 𝓤 ̇} where
129121
<span style="float:right;">[Relations.Quotients →](Relations.Quotients.html)</span>
130122

131123
{% include UALib.Links.md %}
124+
125+
126+
127+
<!--
128+
129+
UNNECESSARY. The ∈ and ⊆ relations defined for Pred are polymorphic and they work just fine
130+
for the general relation types.
131+
132+
133+
134+
Just as we did for unary predicates, we can define inclusion relations for our new general relation types.
135+
136+
_∈C_ : {I : 𝓥 ̇}{A : 𝓤 ̇} → (I → A) → ContRel I A 𝓦 → 𝓦 ̇
137+
x ∈C R = R x
138+
139+
_⊆C_ : {I : 𝓥 ̇}{A : 𝓤 ̇ } → ContRel I A 𝓦 → ContRel I A 𝓩 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⊔ 𝓩 ̇
140+
P ⊆C Q = ∀ {x} → x ∈C P → x ∈C Q
141+
142+
_∈D_ : {I : 𝓥 ̇}{𝒜 : I → 𝓤 ̇} → Π 𝒜 → DepRel I 𝒜 𝓦 → 𝓦 ̇
143+
x ∈D R = R x
144+
145+
_⊆D_ : {I : 𝓥 ̇}{𝒜 : I → 𝓤 ̇ } → DepRel I 𝒜 𝓦 → DepRel I 𝒜 𝓩 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ⊔ 𝓩 ̇
146+
P ⊆D Q = ∀ {x} → x ∈D P → x ∈D Q
147+
148+
infix 4 _⊆C_ _⊆D_
149+
150+
-->

UALib/Relations/Extensionality.lagda

+21-54
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,28 @@ open import Relations.Truncation public
1919

2020
\end{code}
2121

22-
#### <a id="propositions">Predicate extensionality</a>
23-
2422
The principle of *proposition extensionality* asserts that logically equivalent propositions are equivalent. That is, if `P` and `Q` are propositions and if `P ⊆ Q` and `Q ⊆ P`, then `P ≡ Q`. For our purposes, it will suffice to formalize this notion for general predicates, rather than for propositions (i.e., truncated predicates). As such, we call the next type `pred-ext` (instead of, say, `prop-ext`).
2523

2624
\begin{code}
2725

2826
pred-ext : (𝓤 𝓦 : Universe) → (𝓤 ⊔ 𝓦) ⁺ ̇
2927
pred-ext 𝓤 𝓦 = ∀ {A : 𝓤 ̇}{P Q : Pred A 𝓦 } → P ⊆ Q → Q ⊆ P → P ≡ Q
28+
29+
\end{code}
30+
31+
We also define *relation extensionality* principles which generalize the predicate extensionality princple just defined (though these are not yet needed in other modules of the [UALib][]).
32+
33+
\begin{code}
34+
35+
cont-rel-ext : (𝓤 𝓥 𝓦 : Universe) → (𝓤 ⊔ 𝓥 ⊔ 𝓦) ⁺ ̇
36+
cont-rel-ext 𝓤 𝓥 𝓦 = ∀ {I : 𝓥 ̇}{A : 𝓤 ̇}{P Q : ContRel I A 𝓦 } → P ⊆ Q → Q ⊆ P → P ≡ Q
37+
38+
dep-rel-ext : (𝓤 𝓥 𝓦 : Universe) → (𝓤 ⊔ 𝓥 ⊔ 𝓦) ⁺ ̇
39+
dep-rel-ext 𝓤 𝓥 𝓦 = ∀ {I : 𝓥 ̇}{𝒜 : I → 𝓤 ̇}{P Q : DepRel I 𝒜 𝓦 } → P ⊆ Q → Q ⊆ P → P ≡ Q
40+
3041
\end{code}
3142

43+
Note that each of the types above merely define an extensionality principle. They do not postulate that the principle holds. If we wish to postulate, say, `pred-ext`, then we do so by assuming that type is inhabited (see, for example, the definition of `block-ext` below).
3244

3345

3446
#### <a id="quotient-extensionality">Quotient extensionality</a>
@@ -60,67 +72,22 @@ module _ {𝓤 𝓦 : Universe}{A : 𝓤 ̇}{R : Rel A 𝓦} where
6072
block-ext : pred-ext 𝓤 𝓦 → IsEquivalence R → {u v : A} → R u v → [ u ]{R} ≡ [ v ]{R}
6173
block-ext pe Req {u}{v} Ruv = pe (/-subset Req Ruv) (/-supset Req Ruv)
6274

63-
to-subtype|uip :
64-
blk-uip A R → {C D : Pred A 𝓦}{c : IsBlock C {R}}{d : IsBlock D {R}} → C ≡ D → (C , c) ≡ (D , d)
65-
to-subtype|uip buip {C}{D}{c}{d}CD = to-Σ-≡(CD , buip D(transport(λ B → IsBlock B)CD c)d)
66-
67-
68-
block-ext|uip :
69-
pred-ext 𝓤 𝓦 → blk-uip A R → IsEquivalence R → {u v : A} → R u v → ⟪ u ⟫ ≡ ⟪ v ⟫
70-
block-ext|uip pe buip Req Ruv = to-subtype|uip buip (block-ext pe Req Ruv)
71-
72-
\end{code}
73-
74-
75-
----------------------------
76-
77-
#### <a id="general-propositions">General propositions*</a>
7875

79-
This section presents the `general-propositions` submodule of the [Relations.Truncation][] module.<sup>[*](Relations.Truncation.html#fn0)</sup>
76+
to-subtype|uip : blk-uip A R → {C D : Pred A 𝓦}{c : IsBlock C {R}}{d : IsBlock D {R}}
77+
→ C ≡ D → (C , c) ≡ (D , d)
8078

79+
to-subtype|uip buip {C}{D}{c}{d}CD = to-Σ-≡(CD , buip D(transport(λ B → IsBlock B)CD c)d)
8180

82-
Recall, we defined a type called `ContRel` in the [Relations.Continuous][] module to represent relations of arbitrary arity. Naturally, we define the corresponding truncated types, the inhabitants of which we will call *continuous propositions*.
83-
84-
\begin{code}
85-
86-
module general-propositions {𝓤 : Universe}{I : 𝓥 ̇} where
87-
88-
open import Relations.Continuous using (ContRel; DepRel)
89-
90-
IsContProp : {A : 𝓤 ̇}{𝓦 : Universe} → ContRel I A 𝓦 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ̇
91-
IsContProp {A = A} P = Π 𝑎 ꞉ (I → A) , is-subsingleton (P 𝑎)
92-
93-
ContProp : 𝓤 ̇ → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
94-
ContProp A 𝓦 = Σ P ꞉ (ContRel I A 𝓦) , IsContProp P
95-
96-
cont-prop-ext : 𝓤 ̇ → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
97-
cont-prop-ext A 𝓦 = {P Q : ContProp A 𝓦 } → ∣ P ∣ ⊆ ∣ Q ∣ → ∣ Q ∣ ⊆ ∣ P ∣ → P ≡ Q
98-
99-
\end{code}
100-
101-
102-
While we're at it, we might as well take the abstraction one step further and define the type of *truncated dependent relations*, which we call *dependent propositions*.
103-
104-
\begin{code}
105-
106-
IsDepProp : {I : 𝓥 ̇}{𝒜 : I → 𝓤 ̇}{𝓦 : Universe} → DepRel I 𝒜 𝓦 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ̇
107-
IsDepProp {I = I} {𝒜} P = Π 𝑎 ꞉ Π 𝒜 , is-subsingleton (P 𝑎)
10881

109-
DepProp : (I → 𝓤 ̇)(𝓦 : Universe)𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
110-
DepProp 𝒜 𝓦 = Σ P ꞉ (DepRel I 𝒜 𝓦) , IsDepProp P
82+
block-ext|uip : pred-ext 𝓤 𝓦blk-uip A RIsEquivalence R
83+
→ ∀ {u v : A} → R u v → ⟪ u ⟫ ≡ ⟪ v ⟫
11184

112-
dep-prop-ext : (I → 𝓤 ̇) → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
113-
dep-prop-ext 𝒜 𝓦 = {P Q : DepProp 𝒜 𝓦} → ∣ P ∣ ⊆ ∣ Q ∣ → ∣ Q ∣ ⊆ ∣ P ∣ → P ≡ Q
85+
block-ext|uip pe buip Req Ruv = to-subtype|uip buip (block-ext pe Req Ruv)
11486

11587
\end{code}
11688

11789

118-
-----------------------------------
119-
120-
<sup>*</sup><span class="footnote" id="fn0"> Sections marked with an asterisk include new types that are more abstract and general than some of the types defined in other sections. As yet these general types are not used elsewhere in the [UALib][], so sections marked * may be safely skimmed or skipped.</span>
121-
122-
<br>
123-
<br>
90+
---------------------------------------
12491

12592
[← Relations.Truncation](Relations.Truncation.html)
12693
<span style="float:right;">[Algebras →](Algebras.html)</span>

UALib/Relations/Quotients.lagda

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ This section presents the [Relations.Quotients][] module of the [Agda Universal
1515

1616
module Relations.Quotients where
1717

18-
open import Relations.Discrete public
18+
open import Relations.Continuous public
1919

2020
\end{code}
2121

22-
**N.B.**. We import [Relations.Discrete][] since we don't yet need any of the types defined in the [Relations.Continuous][] module.
22+
<!-- **N.B.**. We import [Relations.Discrete][] since we don't yet need any of the types defined in the [Relations.Continuous][] module. -->
2323

2424

2525
#### <a id="properties-of-binary-relations">Properties of binary relations</a>

UALib/Relations/Truncation.lagda

+36
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,46 @@ Embeddings are always monic, so we conclude that when a function's codomain is a
108108
\end{code}
109109

110110

111+
----------------------------
112+
113+
#### <a id="general-propositions">General propositions*</a>
114+
115+
This section defines more general truncated predicates which we call *continuous propositions* and *dependent propositions*. Recall, above (in the [Relations.Continuous][] module) we defined types called `ContRel` and `DepRel` to represent relations of arbitrary arity over arbitrary collections of sorts.
116+
117+
Naturally, we define the corresponding *truncated continuous relation type* and *truncated dependent relation type*, the inhabitants of which we will call *continuous propositions* and *dependent propositions*, respectively.
118+
119+
\begin{code}
120+
121+
module _ {𝓤 : Universe}{I : 𝓥 ̇} where
122+
123+
open import Relations.Continuous using (ContRel; DepRel)
124+
125+
IsContProp : {A : 𝓤 ̇}{𝓦 : Universe} → ContRel I A 𝓦 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ̇
126+
IsContProp {A = A} P = Π 𝑎 ꞉ (I → A) , is-subsingleton (P 𝑎)
127+
128+
ContProp : 𝓤 ̇ → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
129+
ContProp A 𝓦 = Σ P ꞉ (ContRel I A 𝓦) , IsContProp P
130+
131+
cont-prop-ext : 𝓤 ̇ → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
132+
cont-prop-ext A 𝓦 = {P Q : ContProp A 𝓦 } → ∣ P ∣ ⊆ ∣ Q ∣ → ∣ Q ∣ ⊆ ∣ P ∣ → P ≡ Q
133+
134+
IsDepProp : {I : 𝓥 ̇}{𝒜 : I → 𝓤 ̇}{𝓦 : Universe} → DepRel I 𝒜 𝓦 → 𝓥 ⊔ 𝓤 ⊔ 𝓦 ̇
135+
IsDepProp {I = I} {𝒜} P = Π 𝑎 ꞉ Π 𝒜 , is-subsingleton (P 𝑎)
136+
137+
DepProp : (I → 𝓤 ̇) → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
138+
DepProp 𝒜 𝓦 = Σ P ꞉ (DepRel I 𝒜 𝓦) , IsDepProp P
139+
140+
dep-prop-ext : (I → 𝓤 ̇) → (𝓦 : Universe) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇
141+
dep-prop-ext 𝒜 𝓦 = {P Q : DepProp 𝒜 𝓦} → ∣ P ∣ ⊆ ∣ Q ∣ → ∣ Q ∣ ⊆ ∣ P ∣ → P ≡ Q
142+
143+
\end{code}
111144

112145

113146
-----------------------------------
114147

148+
<sup>*</sup><span class="footnote" id="fn0"> Sections marked with an asterisk include new types that are more abstract and general than some of the types defined in other sections. As yet these general types are not used elsewhere in the [UALib][], so sections marked * may be safely skimmed or skipped.</span>
149+
150+
115151
<sup>1</sup><span class="footnote" id="fn1"> As [Escardó][] explains, "at this point, with the definition of these notions, we are entering the realm of univalent mathematics, but not yet needing the univalence axiom."</span>
116152

117153
<sup>2</sup><span class="footnote" id="fn2"> See [https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html\#sigmaequality](www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html\#sigmaequality).</span>

0 commit comments

Comments
 (0)