Codata

Using data that comes to us.

2025 James B. Wilson

https://slides.com/jameswilson-3/codata/

A math example of codata

def C(n) :
    if n is even :
       return n / 2
    else 
    	return 3n+1

k = SECRET_NUMBER
while k > 1 :
	print k
    k = C(k) 
10
5
16
8
4
2
1
11
34
17
52
26
13
40
20
10
5
16
8
4
2
1
  1. Source of data that comes in parts (rows)
  2. It can be followed by more parts (rows)
  3. We don't seem to know when it will stop, if it in fact stops

The famous Collatz Conjecture is that this always stops at 1, no one knows.

Codata

With your group, choose a scenario

  1. You have a source of data that breaks down into parts.
  2. Each part could be followed by another part.
  3. It might come to an end, but you have no control as to when and if you will have the time to wait for that end.

Describe how your choice matches all three criteria.

A math codata

  1. Idea: \(\mathbb{N}^{\infty}=\{0, 1,2,3,\ldots, n,\ldots, \infty\}\)
  2. Each \(n\in \mathbb{N}^{\infty}\) can be one of:
    1. \(0\)
    2. \(++k\) for some \(k\in \mathbb{N}^{\infty}\)
    3. \(\infty\)

So the "predecessor" algebra is

\[--n =\begin{cases} Fail & n=0\\ k & n=++k \\ \infty & n= \infty\end{cases}\]

Organize you codata as an algebra

  1. For each stage in you data write down the processes that could explain a part.
  2. For each process in 1 write down the data it depends on, like a predecessor might.
  3. For each data it depends separate the parts that get you back to the starting point.

Abstract

For every processor write it as a function \[\mathbb{A}\to \mathbb{A}^n\] where n is the number of terms of times data of the same type is given as dependent for that operator.

Wrap up 

  • Inductive data is an algebra that constructs through introduction rules, like nil and cons;  (0, ++); (leaf, branch)
  • Coinductive data is a coalgebra the desconstructs through elimination rules like (fail, pred, \(\infty\)) or the ones you just created.

Codata

By James Wilson

Codata

We explore the reasons for codata and how they lead us to world of approximation and error analysis.

  • 11