2020 James B. Wilson

Colorado State University

 

Relations & algebra

Part I: Unary relations and subalgebras

Objectives

  • Define relations
  • Define modulo
  • Add algebra

Relations

Sample uses of Relations

  • 15 is positive.
  • \(2 \leq 5\)

  • \(27 = 3^3\)

  • \(\{(1,0),(0,1),(1/2,1/2)\}\) are collinear.

These are true because we have evidence:  

E.g. 15 is a successor to a positive number so it is positive.

Other evidence would also be acceptable.

Further uses of Relations

  • -7 is positive.
  • \(12 \leq 5\)

  • \(49 = 3^3\)

  • \(\{(1,0),(0,1),(0,0)\}\) are collinear.

Despite being untrue, these still use relations properly.

No evidence will be had of these claims.

A mere proposition \(P\) is a type of data where:

If there is data of that type, it is all equal, i.e.

\[x,y:P\Rightarrow e:x=_P y\]

Witness we didn't insist that there was data of that type.

 

Not all propositions are true!

\(proof:Proposition\)

Different proofs witness one truth;

in this sense proofs are "equal".

Proposition "IsEven"

\[\frac{n:\mathbb{N}}{IsEven(n):Type}(F)\]

 

\[\frac{k:\mathbb{N} \vdash e: n=_{\mathbb{N}} k+k}{witness(k):IsEven(n)}(I)\]

Elimination and computation are trivial.

 

  • \(IsEven(6)\) is a mere proposition, and it is true as we can inhabit with introduction \(witness(3):IsEven(6)\).
  • \(IsEven(5)\) is a mere proposition, but no introduction rule can give witness to it.  It isn't true.

Towards Formalizing Relations

  • \(P(n):\equiv\) \(n\) is positive.
  • \(Q(x_1,x_2):\equiv (x_1 \leq x_2)\)

  • \(R(y_1,y_2):\equiv (y_1 = y_2)\)

  • \(S(p_1,p_2,p_3):\equiv \{p_1,p_2,p_3\}\) are collinear.

These are no longer mere propositions,

they are functions into mere propositions.

A (homogeneous) relation on \(A\) is a function of type

\[A^n\to Prop\]

where \(Prop\) is the type of all mere propositions.

  • Binary relation: \(A^2\to Prop\), e.g. \(=,\leq\)
  • Unary relation: \(A^1\to Prop\), e.g. "is positive"
  • Ternary relation: \(A^3\to Prop\) e.g. "is collinear".
  • Nullary relations aren't interesting.

 

(FYI: Heterogeneous relations just means \(A_1\times \cdots\times A_n\to Prop\).)

Unary Relation = Subsets

Given a relation \(P:A\to Prop\) we separate those \(a:A\) where the proposition \(P(a)\) has evidence.  Formally a subset (subtype) is

\[\{a:A\mid P(a)\}:=\bigsqcup_{a:A} P(a).\]

That is, the terms \((a,proof:P(a))\).

 

If there is no evidence for \(P(a)\) then \((a,proof:P(a))\) doesn't exist.  We say \(a\) is "not in" the subset.

Note. There is a function \(\iota:\{a:A\mid P(a)\}\to A\) that forgets the evidence.

\[(a:A,e:P(a))\mapsto (a:A).\]

 

Claim. \(\iota(x)=_A\iota(y)\Rightarrow x=_{S}y\) where \(S=\{a:A\mid P(a)\}\).

Proof. \(a=\iota_A(a,e:P(a))=\iota_A(b,f:P(b)=b\) implies \(a=b\).

So \(P(a)=P(b)\).

As \(P(a)\) is a mere proposition its terms are all equal so \(e=f\) and so \(x=(a,e)=(b,f)=y\).  \(\Box\).

Proposition "IsEven"

\[\frac{n:\mathbb{N}}{IsEven(n):Type}(F)\]

\[\frac{k:\mathbb{N} \vdash e: n=_{\mathbb{N}} k+k}{witness(k):IsEven(n)}(I)\]

There is only one term of this type so elimination and computation are trivial.

 

\[\{n\in \mathbb{N}\mid P(n)\}=\{(0,witness(0)), (2,witness(1)),\ldots\}\]

 

The forgetful map gives us \(\{0,2,4,\ldots\}\).

Example

Unary Relation on algebra

=

Sub-algebra

Fix \(\mathbb{Z}\) as a \(\{+,-,0\}\)-algebra.

 

Fix a unary relation \(P:\mathbb{Z}\to Prop\)

 

Goal: use \(\mathbb{Z}\) to make \[S=\{n\in\mathbb{Z}\mid P(n)\}=\bigsqcup_{n\in\mathbb{Z}} P(n)\]

into a \(\{+,-0\}\)-algebra?

  • Needs a binary op \(+:S^2\to S\)
  • Needs a unary op \(-:S\to S\)
  • Needs a nullary op \(\hat{0}:S^0\to S\)

Fix \(\mathbb{N}\) as a \(\{+,0\}\)-algebra, and \(P:\mathbb{N}\to Prop\)

 

Goal: get algebra on \(S=\{n\in\mathbb{N}\mid P(n)\}=\bigsqcup_{n\in\mathbb{N}} P(n)\).

Claim. If there is a function \(\oplus:P(m)\times P(n)\to P(m+n)\) then

\[m,n\in S\Rightarrow m+n\in S\]

 

Proof. \(m,n\in S\) is short for \[(m,e),(n,f) : S\] where \(e:P(m)\) and \(f:P(n)\).  As \(e\oplus f:P(m+n)\) we get

\((m+n,e\oplus f):S\)  \(\Box\)

 

Fix \(\mathbb{N}\) as a \(\{+,0\}\)-algebra, and \(P:\mathbb{N}\to Prop\)

 

Goal: get algebra on \(S=\{n\in\mathbb{N}\mid P(n)\}=\bigsqcup_{n\in\mathbb{N}} P(n)\).

Claim. If there is a function \(\ominus:P(n)\to P(-n)\) then

\[n\in S\Rightarrow -n\in S\]

 

Proof. \(n\in S\) is short for \[(n,f) : S\] where \(e:P(n)\).  As \(\ominus e:P(n)\) we get

\((n,\ominus e):S\).  That is, \(-n\in S\).  \(\Box\)

 

Fix \(\mathbb{N}\) as a \(\{+,0\}\)-algebra, and \(P:\mathbb{N}\to Prop\)

 

Goal: get algebra on \(S=\{n\in\mathbb{N}\mid P(n)\}=\bigsqcup_{n\in\mathbb{N}} P(n)\).

Claim. If there is a function \(\hat{0}:\{\bot\}\to P(0)\) then \(0\in S\).

Proof. \((0,\hat{0}(\bot)):S\).   \(\Box\).

A sub-algebra means...

A relation \(P:A\to Prop\) which has functions

  • For each operator \(\times:A\times A\to A\) there is a function \[\otimes:P(a)\times P(b)\to P(a\times b).\]
  • For each operator \(-:A\to A\) there is a function \[\ominus:P(a)\to P(-a).\]
  • For each nullary/constant in the signature \(\epsilon:A\) there is a constant \[\hat{\epsilon}:P(\epsilon).\]

You can generalize this to any signature accordingly.

Binary Relation =

Set of subsets

Given a relation \(\rho:A^2\to Prop\) we get a new type of data "A mod \(\rho\)", obvious formation, introduction:

\[\frac{a:A}{[a]:A/\rho}(I)\]

Elimination fetches back the "a", computation confirms that.

 

Now we add a new class of rule called equality:

\[\frac{[a],[b]:A/\rho\qquad e:\rho(a,b)}{wit(e):[a]=_{A/\rho} [b]}(=).\]

Short-hand

\[\begin{aligned} A/\rho & := (a:A)\mapsto [a]\\ & \mid wit:\rho(a,b)\to [a]=_{A/\rho} [b]\end{aligned}\]

Modulo

Given a relation \(\rho:A^2\to Prop\), and \(1\leq i\leq n\) we get a new type of data "A mod \(\rho\)":

\[A/\rho := \bigsqcup_{a_1:A} \rho(a_1,-).\]

Note that \(\rho(a_1,-):A\to Prop\) is a function.

Popular short-hand includes:

\[[a_1]=\bar{a}_1=\rho(a_1,-)=\{a_2:A\mid \rho(a_1,a_2)\}\]

\[A/\rho= \{\rho(a_1,-) \mid a_1:A\}\]

Caution some notation is self-reference (impredicative). Needs careful logic.

Modulo

Given a relation \(\rho:A^2\to Prop\), and \(1\leq i\leq n\) we get a new type of data "A mod \(\rho\)":

\[A/\rho := \bigsqcup_{a_1:A} \rho(a_1,-)\]

where the classes (or "fibres") are

\[\rho(a_1,-) := \bigsqcup_{a_2:A} \rho(a_1,a_2).\]

A popular short-hand includes:

\[A/\rho= \{\rho(a_1,-) \mid a_1:A\}\]

\[[a_1]=\bar{a}_1=\rho(a_1,-)=\{a_2:A\mid \rho(a_1,a_2)\}\]

Caution some notation is self-reference (impredicative). Needs careful logic.

Modulo

\(\rho:\mathbb{N}^2\to Prop\) where 

\(\rho(m,n) = m+n\) is positive.

\([0]=\rho(0,-)=\{1,2,3,\ldots\}\)

\([1]=\rho(1,-)=\{0,1,2,\ldots\}\)

\([2]=\rho(2,-)=\{0,1,2,\ldots\}\)

... so as functions [1]=[2]=[3]=...

 

\[\mathbb{N}/\rho = \{[0],[1]\}.\]

\(\rho:\mathbb{N}^2\to Prop\) where 

\(\rho(m,n) = m+n\) is even.

\([0]=\rho(0,-)=\{0,2,4,\ldots\}\)

\([1]=\rho(1,-)=\{1,3,5,\ldots\}\)

\([2]=\rho(2,-)=\{0,2,4,\ldots\}\)

\([3]=\rho(3,-)=\{1,3,5,\ldots\}\)

....

\[\mathbb{N}/\rho = \{[0],[1]\}\]

but not the same classes (fibres) as the previous!

(This is where short-hand notation fails us!)

  1. Given a relation \(\rho:A^2\to Prop\), define \(\rho\backslash A\) based on fibres \(\rho(-,a_2)\).  
  2. Given a relation \(\rho:A^n\to Prop\), and \(1\leq i\leq n\) define \(A/{\rho_i}\) based on fibres \(\rho(\cdots,a_i,\cdots)\).

 

Words like "left" and "right" used to distinguish \(A/\rho\) from \(\rho\backslash A\)...trouble is no one can remember which is which!

It is common to find people who use \(A/\rho\) for both.

Exercise