A quasi-Borel space
$X$ consists of an underlying set
$X$ and a set of functions
$M_X \subseteq (\mathbb{R} \rightarrow X)$ satisfying:
- $M_X$ contains all constant functions.
- $M_X$ is closed under composition with measurable functions. So if $f : \mathbb{R} \rightarrow \mathbb{R}$ is measurable and $\alpha \in M_X$, then $\alpha \circ f \in M_X$.
- $M_X$ is closed under defining piecewise functions using functions on disjoint Borel domains.
So, for any partition of $\mathbb{R} = \cup_{i\in\mathbb{N}} S_i$ with $S_i$ Borel, and $\{\alpha_i \in M_X\}_{i\in\mathbb{N}^\prime}$, then the piecewise function $\beta(x) = \alpha_i(x)$ when $x \in S_i$ is in the space $M_X$.
---
The key to understanding quasi-Borel spaces is to understand the role that A higher-order language for probabilistic programming.
```haskell
-- A set of basic types + kinds.
data BT = Unit | Bool | Nat | Real | PosReal | BT x BT | List(BT)
-- A set of types + kinds.
data T = BT | M[T] | T -> T | T x T | List(T)
-- A set of terms.
data Expr = -- Variables, builtins, and application.
x | c | f | Expr Expr
| <Expr, Expr> -- A product constructor.
| Project(i, Expr) -- Product destructor.
-- Pattern matching.
| case Expr with [match(i, x_i) => Expr] over i
-- Recursive function definitions.
| letrec f x = Expr
| return Expr | bind Expr Expr -- Monadic return + bind.
-- Query computes a posterior from a prior + likelihood.
| query Expr => Expr
-- Primitives representing basic distributions.
| Uniform(Expr, Expr) | Bern(Expr) | Gauss(Expr, Expr)
```
---
The language `HPPROG` is a typed lambda calculus with products, pattern matching, recursive function definitions, and monadic lifting/binding as well as conditioning.
1. `Product -> <Expr ,Expr>`
2. `Pattern matching -> case Expr with [match(i, x_i) => Expr] over i`
3. `Recursive function definitions -> letrec f x = Expr`
3. `Monadic lift -> return Expr` with monadic type `M[T]`.
4. `Monadic bind -> bind Expr Expr` with monadic type `M[T]`
5. `Query -> query Expr Expr` with resultant monadic type `M[T]`.
______
.cols[
.thirty[
<h4><center>Monadic bind</center></h4>
A logic for probabilistic programs.
```haskell
-- A.k.a. terms.
data EnrE = Expr
| E(x, EnrE, Expr(x))
| scale(EnrE, EnrE)
| normalize(EnrE)
-- A.k.a formula.
data LogF = (EnrE = EnrE)
| (EnrE < EnrE)
| Top
| Btm
| LogF & LogF
| LogF => LogF
| not LogF
| Forall(x, T, LogF)
| Exists(x, T, LogF)
```
---
Let's quickly look at the extended typing rules for enriched expressions.
.cols[
.fifty[