# formalizing the QACI alignment formal-goal

*this work was done by Tamsin Leake and Julia Persson at Orthogonal.*  
*thanks to mesaoptimizer for his help putting together this post.*


what does the QACI plan for formal-goal alignment actually look like when formalized as math? in this post, we'll be presenting our current formalization, which we believe has most critical details filled in.

# 1. math constructs

in this first part, we'll be defining a collection of mathematical constructs which we'll be using in the rest of the post.

## 1.1. basic set theory

we'll be assuming basic set theory notation; in particular, $\color{#6669ff}{A×B×C}$ is the set of tuples whose elements are respectively members of the sets $\color{#6669ff}{A}$, $\color{#6669ff}{B}$, and $\color{#6669ff}{C}$, and for $\color{#6669ff}{n∈ℕ}$, $\color{#6669ff}{S^n}$ is the set of tuples of $\color{#6669ff}{n}$ elements, all members of $\color{#6669ff}{S}$.

$\color{#6669ff}{𝔹=\{⊤,⊥\}}$ is the set of booleans and $\color{#6669ff}{ℕ}$ is the set of natural numbers including $\color{#6669ff}{0}$.

given a set $\color{#6669ff}{X}$, $\color{#6669ff}{\mathcal{P}(X)}$ will be the set of subsets of $\color{#6669ff}{X}$.

$\color{#6669ff}{\# S}$ is the cardinality (number of different elements) in set $\color{#6669ff}{S}$.

for some set $\color{#6669ff}{X}$ and some complete ordering $\color{#6669ff}{<\;∈\;X^2→𝔹}$, $\color{#6669ff}{\textit{min}_<}$ and $\color{#6669ff}{\textit{max}_<}$ are two functions of type $\color{#6669ff}{\mathcal{P}(X)\backslash\{∅\}→X}$ finding the respective minimum and maximum element of non-empty sets when they exist, using $\color{#6669ff}{<}$ as an ordering.

## 1.2. functions and programs

if $\color{#6669ff}{n∈ℕ}$, then we'll denote $\color{#6669ff}{f∘^n}$ as repeated composition of $\color{#6669ff}{f}$: $\color{#6669ff}{f∘…∘f}$ ($\color{#6669ff}{n}$ times), with $\color{#6669ff}{∘}$ being the composition operator: $\color{#6669ff}{(f∘g)(x)=f(g(x))}$.

$\color{#6669ff}{λx:X.B}$ is an anonymous function defined over set $\color{#6669ff}{X}$, whose parameter $\color{#6669ff}{x}$ is bound to its argument in its body $\color{#6669ff}{B}$ when it is called.

$\color{#6669ff}{A→B}$ is the set of functions from $\color{#6669ff}{A}$ to $\color{#6669ff}{B}$, with $\color{#6669ff}{→}$ being right-associative ($\color{#6669ff}{A→B→C}$ is $\color{#6669ff}{A→(B→C)}$). if $\color{#6669ff}{f\;∈\;A→B→C}$, then $\color{#6669ff}{f(x)(y)}$ is simply $\color{#6669ff}{f}$ applied once to $\color{#6669ff}{x\;∈\;A}$, and then the resulting function of type $\color{#6669ff}{B→C}$ being applied to $\color{#6669ff}{y\;∈\;B}$. $\color{#6669ff}{A→B}$ is sometimes denoted $\color{#6669ff}{B^A}$ in set theory.

$\color{#6669ff}{A\overset{H}→B}$ is the set of always-halting, always-succeeding, deterministic programs taking as input an $\color{#6669ff}{A}$ and returning a $\color{#6669ff}{B}$.

given $\color{#6669ff}{f∈A\overset{H}→B}$ and $\color{#6669ff}{x∈A}$, $\color{#6669ff}{R(f,x)\;∈\;ℕ\backslash\{0\}}$ is the runtime duration of executing $\color{#6669ff}{f}$ with input $\color{#6669ff}{x}$, measured in compute steps doing a constant amount of work each — such as turing machine updates.

## 1.3. sum notation

i'll be using a syntax for sums $\color{#6669ff}{\sum}$ in which the sum iterates over all possibles values for the variables listed *above* it, given that the constraints *below* it hold.

$$\color{#6669ff}{
	\begin{split}
		&x,y
\\	&\sum\;y &=\;1
\\	&y=x\;\textit{mod}\;2 &
\\	&x∈\{1,2,3,4\}&
\\	&x\;≤\;2 &
\\	&&
	\end{split}
}$$

says "for any value of $\color{#6669ff}{x}$ and $\color{#6669ff}{y}$ where these three constraints hold, sum $\color{#6669ff}{y}$".

## 1.4. distributions

for any countable set $\color{#6669ff}{X}$, the set of distributions over $\color{#6669ff}{X}$ is defined as:

$$\color{#6669ff}{
	\mathrm{Δ}_X\;≔\;\{f|f\;∈\;X→[0;1],\begin{split}\overset{x}{\underset{x∈X}{\sum}}\end{split}f(x)\;≤\;1\}
}$$

a function $\color{#6669ff}{f\;∈\;X→[0;1]}$ is a distribution $\color{#6669ff}{\mathrm{Δ}_X}$ over $\color{#6669ff}{X}$ if and only if its sum over all of $\color{#6669ff}{X}$ is never greater than 1. we call "mass" the scalar in $\color{#6669ff}{[0;1]}$ which a distribution assigns to any value. note that in our definition of distribution, we do not require that the distribution over all elements in the domain sums up to 1, but merely that it sums up to *at most* 1. this means that different distributions can have different "total mass".

we define $\color{#6669ff}{\mathrm{Δ}^0_X\;∈\;\mathrm{Δ}_X}$ as the empty distribution: $\color{#6669ff}{\mathrm{Δ}^0_X(x)=0}$.

we define $\color{#6669ff}{\mathrm{Δ}^1_X\;∈\;X→\mathrm{Δ}_X}$ as the distribution entirely concentrated on one element: $\color{#6669ff}{\mathrm{Δ}^1_X(x)(y)=\begin{cases}1&\text{if}\;y=x\\0&\text{if}\;y\;≠\;x\end{cases}}$

we define $\color{#6669ff}{\textit{Normalize}_X\;∈\;\mathrm{Δ}_X→\mathrm{Δ}_X}$ which modifies a distribution to make it sum to 1 over all of its elements, except for empty distributions:

$$\color{#6669ff}{
	\textit{Normalize}_X(δ)(x)\;≔\;\begin{cases}
		\frac{δ(x)}{\begin{split}\overset{y}{\underset{y∈X}{\sum}}\end{split}δ(y)} & \text{if}\;δ\;≠\;\mathrm{Δ}^0_X
\\	0 & \text{if}\;δ=\mathrm{Δ}^0_X
	\end{cases}
}$$

we define $\color{#6669ff}{\textit{Uniform}_X}$ as a distribution attributing equal value to every different element in a finite set $\color{#6669ff}{X}$, or the empty distribution if $\color{#6669ff}{X}$ is infinite.

$$\color{#6669ff}{
	\textit{Uniform}_X(x)\;≔\;\begin{cases}
		\frac{1}{\# X} & \text{if}\; \# X\;∈\;ℕ
\\	0              & \text{if}\; \# X\;∉\;ℕ
	\end{cases}
}$$

we define $\color{#6669ff}{\textit{max}^\mathrm{Δ}_X\;∈\;\mathrm{Δ}_X→\mathcal{P}(X)}$ as the function finding the elements of a distribution with the highest value:

$$\color{#6669ff}{
	\textit{max}^\mathrm{Δ}_X(δ)\;≔\;\{x|x∈X,∀x^\prime∈X:\;δ(x^\prime)\;≤\;δ(x)\}
}$$

## 1.5. constrained mass

given distributions, we will define a notation which i'll call "constrained mass".

it is defined as a syntactic structure that turns into a sum:

$$\color{#6669ff}{
	\begin{split}
		& v_1,\ldots,v_p &   & v_1,\ldots,v_p
\\	&\mathbf{M}\;[V] &≔\;& \sum\;X_1(x_1)\;⋅\;\ldots\;⋅\;X_n(x_n)\;⋅\;V
\\	& x_1\;:\;X_1    &   & x_1\;∈\;\textit{domain}(X_1)
\\	& \vdots         &   & \vdots
\\	& x_n\;:\;X_n    &   & x_{n}\;∈\;\textit{domain}(X_n)
\\	& C_1            &   & C_1
\\	& \vdots         &   & \vdots
\\	& C_m            &   & C_m
	\end{split}
}$$

in which variables $\color{#6669ff}{x}$ are sampled from their respective distributions $\color{#6669ff}{X}$, such that each instance of $\color{#6669ff}{V}$ is multiplied by $\color{#6669ff}{X(x)}$ for each $\color{#6669ff}{x}$. constraints $\color{#6669ff}{C}$ and iterated variables $\color{#6669ff}{v}$ are kept as-is.

it is intended to weigh its expression body $\color{#6669ff}{V}$ by various sets of assignments of values to the variables $\color{#6669ff}{v}$, weighed by how much mass the $\color{#6669ff}{X}$ distributions return and filtered for when the $\color{#6669ff}{C}$ constraints hold.

to take a fairly abstract but fully calculable example,

$$\color{#6669ff}{
	\begin{split}
		&\overset{x,f}{\mathbf{M}}\;[f(x,2)] &≔\;&\overset{x,f}{\sum}\;\left(λn:\{1,2,3\}.\frac{n}{10}\right)(x)\;⋅\;\textit{Uniform}_{\{\textit{min},\textit{max}\}}(f)\;⋅\;f(x,2)
\\	& x\;:\;λn:\{1,2,3\}.\frac{n}{10}& & x\;∈\;\textit{domain}\left(λn:\{1,2,3\}.\frac{n}{10}\right)
\\	& f\;:\;\textit{Uniform}_{\{\textit{min},\textit{max}\}} & & f\;∈\;\textit{domain}(\textit{Uniform}_{\{\textit{min},\textit{max}\}})
\\	& x\;\textit{mod}\;2\;≠\;0 & & x\;\textit{mod}\;2\;≠\;0
\\ &&=& \overset{x,f}{\sum}\;\frac{x}{10}\;⋅\;\frac{1}{2}\;⋅\;f(x,2)
\\	&& & x\;∈\;\{1,2,3\}
\\	&& & f\;∈\;\{\textit{min},\textit{max}\}
\\	&& & x\;\textit{mod}\;2\;≠\;0
\\ &&=& \frac{1\;⋅\;\textit{min}(1,2)}{10\;⋅\;2} + \frac{3\;⋅\;\textit{min}(3,2)}{10\;⋅\;2} + \frac{1\;⋅\;\textit{max}(1,2)}{10\;⋅\;2} + \frac{3\;⋅\;\textit{max}(3,2)}{10\;⋅\;2}
\\ &&=& \frac{1\;⋅\;1+3\;⋅\;2+1\;⋅\;2+3\;⋅\;3}{20} = \frac{1+6+2+9}{20} = \frac{18}{20} = \frac{9}{10}
	\end{split}
}$$

in this syntax, the variables being sampled from distributions are allowed to be bound by an arbitrary amount of logical constraints or new variable bindings below it, other than the variables being sampled from distributions.

## 1.6. bitstrings

$\color{#6669ff}{𝔹^*}$ is the set of finite bitstrings.

bitstrings can be compared using the lexicographic order $\color{#6669ff}{<_{𝔹^*}}$, and concatenated using the $\color{#6669ff}{\|}$ operator. for a bitstring $\color{#6669ff}{x\;∈\;𝔹^*}$, $\color{#6669ff}{{|x|}\;∈\;ℕ}$ is its length in number of bits.

for any countable set $\color{#6669ff}{X}$, $\color{#6669ff}{\textit{Encode}_X\;∈\;X→𝔹^*}$ and will be some reasonable function to convert values to bitstrings, such that $\color{#6669ff}{∀(x,y)∈X^2:\;\textit{Encode}_X(x)=\textit{Encode}_X(y)\;⇔\;x=y}$. "reasonable" entails constraints such as:

* it can be computed efficiently.
* it can be inverted efficiently and unambiguously.
* its output's size is somewhat proportional to the actual amount of information. for example, integers are encoded in binary, not unary.

## 1.7. cryptography

we posit $\color{#6669ff}{σ\;≔\;𝔹^\bar{σ}}$, the set of "signatures", sufficiently large bitstrings for cryptographic and uniqueness purposes, with their length defined as $\color{#6669ff}{\bar{σ}=2^{31}}$ for now. this *feels* to me like it should be enough, and if it isn't then something is fundamentally wrong with the whole scheme, such that no manageable larger size would do either.

we posit a function $\color{#6669ff}{\textit{ExpensiveHash}\;∈\;𝔹^*\overset{H}→σ}$, to generate fixed-sized strings from seed bitstrings, which must satisfy the following:

* it must be too expensive for the AI to compute *in any way* (including through superintelligently clever tricks), but cheap enough that we can compute it outside of the AI — for example, it could require quantum computation, and the AI could be restricted to classical computers
* it should take longer to compute (again, in any way) than the expected correct versions of $\color{#6669ff}{\textit{Loc}}$'s $\color{#6669ff}{f,g}$ functions (as will be defined later) could afford to run
* it should tend to be collision-resistant

at some point, we might come up with more formal ways to define $\color{#6669ff}{\textit{ExpensiveHash}}$ in a way that checks that it isn't being computed inside $\color{#6669ff}{\textit{Loc}}$'s $\color{#6669ff}{f,g}$ functions, nor inside the AI.

## 1.8. text and math evaluation

for any countable set $\color{#6669ff}{X}$, we'll be assuming $\color{#6669ff}{\textit{EvalMath}_X\;∈\;𝔹^*→\{\{x\}|x∈X\}∪\{∅\}}$ to interpret a piece of text as a piece of math in some formal language, evaluating to either:

* a set of just one element of $\color{#6669ff}{X}$, if the math parses and evaluates properly to an element of $\color{#6669ff}{X}$
* an empty set otherwise

for example,

$$\color{#6669ff}{
	\begin{split}
		&\textit{EvalMath}_ℕ(\text{"1+2"})=\{3\}
\\	&\textit{EvalMath}_ℕ(\text{"hello"})=∅
	\end{split}
}$$

## 1.9. kolmogorov simplicity

for any countable sets $\color{#6669ff}{X}$ and $\color{#6669ff}{P}$:

$\color{#6669ff}{K^-_X\;∈\;\mathrm{Δ}_X}$ is some "[kolmogorov](https://en.wikipedia.org/wiki/Kolmogorov_complexity) simplicity" distribution over set $\color{#6669ff}{X}$ which has the properties of never assigning 0, and summing/converging to 1 over all of $\color{#6669ff}{X}$. it must satisfy $\color{#6669ff}{∀x∈X:\;K^-_X(x)>0}$ and $\color{#6669ff}{\begin{split}\overset{x}{\underset{x∈X}{\sum}}\end{split}K^-_X(x)=1}$.

$\color{#6669ff}{K^-}$ is expected to give more mass to simpler elements, in an information-theoretic sense.

notably, it is expected to "deduplicate" information that appears in multiple parts of a same mathematical object, such that even if $\color{#6669ff}{x\;∈\;𝔹^*}$ holds lots of information, $\color{#6669ff}{K^-_{𝔹^*}(x)}$ is not much higher (higher simplicity, i.e. lower complexity) to $\color{#6669ff}{K^-_{𝔹^*×𝔹^*}(x,x)}$.

we could define $\color{#6669ff}{K^-_X}$ [similarly to cross-entropy](https://www.lesswrong.com/posts/KcvJXhKqx4itFNWty/k-complexity-is-silly-use-cross-entropy-instead), with some universal turing machine $\color{#6669ff}{\textit{UTM}\;∈\;𝔹^*×ℕ→𝔹^*}$ returning the state of its tape after a certain number of compute steps:

$$\color{#6669ff}{
	\begin{split}
		& i,n
\\	K^-_X\;≔\;\textit{Normalize}_X(
			λx:X.&\sum\;\frac{1}{ (2^{|i|}\;⋅\;(n+1))^2} \;
		)
\\	& i\;∈\;𝔹^*
\\	& n\;∈\;ℕ
\\	& \textit{UTM}(i,n)=\textit{Encode}_X(x)
	\end{split}
}$$

*kolmogorov simplicity over $\color{#6669ff}{X}$ with a prior from $\color{#6669ff}{P}$*, of type $\color{#6669ff}{K^{-\sim}_{P,X}\;:\;P→\mathrm{Δ}_X}$, allows elements it samples over to share information with a prior piece of information in $\color{#6669ff}{P}$. it is defined as $\color{#6669ff}{K^{-\sim}_{P,X}(p)\;≔\;\textit{Normalize}_X(λx:X.K^-_{P×X}(p,x))}$.

# 2. physics

in this section we posit some formalisms for modeling world-states, and sketch out an implementation for them.

## 2.1. general physics

we will posit some countable set $\color{#6669ff}{Ω}$ of world-states, and a distribution $\color{#6669ff}{Ω_α\;∈\;\mathrm{Δ}_Ω}$ of possible initial world-states.

we'll also posit a function $\color{#6669ff}{Ω^→_α\;∈\;Ω→\mathrm{Δ}_Ω}$ which produces a distribution of future world-states for any specific world-state in the universe starting at $\color{#6669ff}{α}$.

given an initial world-state $\color{#6669ff}{α\;∈\;Ω}$, we'll call $\color{#6669ff}{Ω^→_α(α)}$ the "universe" that it gives rise to. it must be the case that $\color{#6669ff}{\begin{split}\overset{ω}{\underset{ω\;∈\;Ω}{\sum}}\end{split}Ω^→_α(α)(ω)=1}$.

when $\color{#6669ff}{α}$ describes the start of a quantum universe, individual world-states $\color{#6669ff}{Ω}$ following it by $\color{#6669ff}{Ω^→_α}$ would be expected to correspond to [many-worlds everett branches](https://www.lesswrong.com/tag/many-worlds-interpretation).

for concreteness's sake, we could posit $\color{#6669ff}{Ω\;⊂\;𝔹^*}$, though note that $\color{#6669ff}{α}$ is expected to not just hold information about the initial state of the universe, but also about how it is computed forwards.

given a particular $\color{#6669ff}{α\;∈\;Ω}$:

finally, we define $\color{#6669ff}{\textit{SimilarPasts}_α\;∈\;Ω×Ω→[0;1]}$ which checks how much they have past world-states $\color{#6669ff}{ω_{\textit{past}}}$ in common:

$$\color{#6669ff}{
	\begin{split}
		& ω_1
\\	\textit{SimilarPasts}_α(ω_2,ω_2^\prime)\;≔\;&\mathbf{M}\;\left[
			Ω^→_α(ω_1)(ω_2)\;⋅\;Ω^→_α(ω_1)(ω_2^\prime)
		\right]
\\	& ω_1\;:\;Ω^→_α(α)
	\end{split}
}$$

## 2.2. quantum turing machines

we will sketch out here a proposal for $\color{#6669ff}{Ω}$, $\color{#6669ff}{Ω_α}$, and $\color{#6669ff}{Ω^→}$ such that our world-state $\color{#6669ff}{w}$ has hopefully non-exponentially-small $\color{#6669ff}{Ω^→_α(α)(ω)}$.

the basis for this will be a universal [quantum turing machine](https://en.wikipedia.org/wiki/Quantum_Turing_machine). we will posit:

* $\color{#6669ff}{\textit{Tape}\;≔\;\{s|s\;∈\;\mathcal{P}(ℤ),\#s\;∈\;ℕ\}}$ the set of turing machine tapes, as *finite* (thanks to $\color{#6669ff}{\#s\;∈\;ℕ}$) sets of relative integers representing positions in the tape holding a 1 rather than a 0.
* $\color{#6669ff}{State}$ some finite ($\color{#6669ff}{\#S∈ℕ}$) set of states, and some $\color{#6669ff}{\textit{state}_0\;∈\;\textit{State}}$.
* $\color{#6669ff}{Ω\;≔\;\textit{Tape}×\textit{State}×ℤ}$: world-states consist of a tape, state, and machine head index.
* $\color{#6669ff}{\mathrm{Δ}^q_Ω\;≔\;\{f|f\;∈\;Ω→ℂ,\begin{split}\overset{ω}{\underset{ω∈Ω}{\sum}}\end{split}{\|f(ω)\|}^2=1\}}$ the set of "quantum distributions" over world-states
* $\color{#6669ff}{\textit{Step}\;∈\;\mathrm{Δ}^q_Ω→\mathrm{Δ}^q_Ω}$ the "time step" operator running some universal turing machine's transition matrix to turn one quantum distribution of world-states into another

we'll also define $\color{#6669ff}{\mathrm{Δ}^2_ℕ\;∈\;\mathrm{Δ}_ℕ}$ as the "quadratic realityfluid distribution" which assigns diminishing quantities to natural numbers, but only quadratically diminishing: $\color{#6669ff}{\mathrm{Δ}^2_ℕ(n)\;≔\;\textit{Normalize}_ℕ\left({\large{\frac{1}{(n+1)^2}}}\right)}$

we can then define $\color{#6669ff}{Ω^→}$ as repeated applications of $\color{#6669ff}{\textit{Step}}$, with quadratically diminishing realityfluid:

$$\color{#6669ff}{
	\begin{split}
		& n_1,n_2,s
\\	Ω^→_α(ω_1)(ω_2)\;≔\;c\;⋅\;&\mathbf{M}\left[s(n_1,ω_1)\;⋅\;s(n_1+n_2,ω_2)\right]
\\	&n_1\;:\;\mathrm{Δ}^2_ℕ
\\	&n_2\;:\;\mathrm{Δ}^2_ℕ
\\	&s(n,ω)={\|\textit{Step}∘^n(\mathrm{Δ}^1_Ω(α))(ω)\|}^2
	\end{split}
}$$

where the constant $\color{#6669ff}{c}$ is whatever scalar it needs to be for $\color{#6669ff}{\begin{split}\overset{ω}{\underset{ω\;∈\;Ω}{\sum}}\end{split}Ω^→_α(α)(ω)=1}$ to be satisfied.

this implementation of $\color{#6669ff}{Ω^→_α}$ measures how much $\color{#6669ff}{ω_2}$ is in the future of $\color{#6669ff}{ω_1}$ by finding paths from $\color{#6669ff}{α}$ to $\color{#6669ff}{ω_1}$, and then longer paths from $\color{#6669ff}{α}$ to $\color{#6669ff}{ω_2}$.

and finally, we define $\color{#6669ff}{Ω_α}$ as a distribution giving non-zero value to world-states $\color{#6669ff}{(t,state_0,0)}$ where $\color{#6669ff}{t}$ is a tape where no negative-index cells are set to 1.

$$\color{#6669ff}{
	Ω_α(t,s,i)\;≔\;\begin{cases}
		& \mathrm{Δ}^2_ℕ\left(\begin{split}\overset{n}{\underset{n∈t}{\sum}}\end{split} 2^n\right) & \text{if}\;s=state_0,i=0,t\;⊂\;ℕ
\\	&0 & \text{otherwise}
	\end{cases}
}$$

because we selected a universal (quantum) turing machine, there is at least one input tape implementing any single quantum algorithm, including the quantum algorithm implementing our physics.

# 3. implementing QACI

finally, we get into the core mechanisms of QACI.

the core idea of QACI is "blob location": mathematically formalizing the idea of locating our world and locating bitstrings (which i'll call "blobs") stored on computers within that world, out of the space of all possible computational universes, by sampling over functions which extract those blobs from world-states in $\color{#6669ff}{Ω}$ and functions which can produce a counterfactual world where that blob has been replaced with another blob of the same length (in number of bits).

## 3.1. question blob and observation

throughout these functions, we will posit the following constants:

* the initial factual question blob $\color{#6669ff}{q\;∈\;𝔹^*}$
* two "observation" blobs $\color{#6669ff}{μ_1\;∈\;𝔹^*}$ and $\color{#6669ff}{μ_2\;∈\;𝔹^*}$

$\color{#6669ff}{μ_1,μ_2}$ are variables which will be passed around, called "observations". in normal AI agent framings, an AI would have a history of actions and observations, and decide on its next action based on that; but, in the one-shot framing we use, there is only a single action and a fixed set of observations. the observations, in practice, will be a very large pieces of data helping the AI locate itself in the multiverse of all possible computations, as well as get a better idea of how and where it is being ran. we will likely include in it things like:

* a full explanation of the QACI alignment plan, including the math
* the AI's code
* a dump of wikipedia and other large parts of the internet
* a copy of some LLM

$\color{#6669ff}{μ_1}$ will be produced before the question blob is generated, and $\color{#6669ff}{μ_2}$ will be produced after the question blob is generated but before the AI is launched.

## 3.2. overview

the overall shape of what we're doing can be seen on the illustration below: we start at the start of the universe $\color{#6669ff}{\color{#76c281}α}$, and use four blob locations and a counterfactual blob function call to locate five other world-states. the illustration shows distributions of future and past world-states, as well as a particular sampling of for all four blob locations.

* we sample $\color{#6669ff}{\color{#ff6a85}{ω_{μ_1}}}$ using $\color{#6669ff}{\color{#999}{\textit{Loc}(α,Ω^→_α({\color{#76c281}α}),{\color{#ff6a85}{μ_1}},ξ)}}$, world-states containing the first observation $\color{#6669ff}{\color{#ff6a85}{μ_1}}$
* we sample $\color{#6669ff}{\color{#f3936f}{ω_{μ_2}}}$ using $\color{#6669ff}{\color{#999}{\textit{Loc}(α,Ω^→_α({\color{#ff6a85}{ω_{μ_1}}}),{\color{#f3936f}{μ_2}},ξ)}}$, world-states containing the second observation $\color{#6669ff}{\color{#f3936f}{μ_2}}$
* we sample $\color{#6669ff}{\color{#f263ed}{ω_q}}$ using $\color{#6669ff}{\color{#999}{\textit{Loc}(α,Ω^→_α({\color{#ff6a85}{ω_{μ_1}}}),{\color{#f263ed}q},ξ)}}$, world-states containing the question blob $\color{#6669ff}{\color{#f263ed}{q}}$, but requiring that its world-state $\color{#6669ff}{\color{#f263ed}{ω_q}}$ precede the world-state $\color{#6669ff}{\color{#f3936f}{ω_{μ_2}}}$
* we get $\color{#6669ff}{\color{#ccc22b}{ω_q^\prime}}$, the world-state with a counterfactual question blob, using blob location $\color{#6669ff}{\color{#f263ed}{γ_q}}$ found by sampling $\color{#6669ff}{\color{#f263ed}{ω_q}}$
* we sample $\color{#6669ff}{\color{#21d5ff}{ω_r}}$ using $\color{#6669ff}{\color{#999}{\textit{Loc}(α,Ω^→_α({\color{#ccc22b}{ω_q^\prime}}),{\color{#21d5ff}r},ξ)}}$, possible world-states containing an answer to a given counterfactual question $\color{#6669ff}{\color{#ccc22b}{q^\prime}}$

![](https://carado.moe/qaci-math-2.svg)

the location path from $\color{#6669ff}{\color{#ccc22b}{ω_q\prime}}$ to $\color{#6669ff}{\color{#21d5ff}{ω_r}}$ is used to run QACI intervals, where counterfactual questions $\color{#6669ff}{\color{#ccc22b}{q^\prime}}$ are inserted and answers $\color{#6669ff}{\color{#21d5ff}{r}}$ are located in their future.

(we could also build fancier schemes where we locate the AI's returned action, or its code running over time, in order to "tie more tightly" the blob locations to the AI — but it is not clear that this helps much with blob location failure modes i'm concerned about.)

for the moment, we merely rely on $\color{#6669ff}{\color{#ff6a85}{μ_1}}$ and $\color{#6669ff}{\color{#f3936f}{μ_2}}$ being uniquely identifying enough — though implementing them as *static bitstrings* might suffice, perhaps they could instead be implemented as *[lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) associative maps*. when the AI tries to access members of those maps, code which computes or fetches information from the world (such as from the internet) would be executed determines the contents of that part of the observation object. this way, the observation would be conceptualized as a static object to the AI — and indeed it wouldn't be able to observe any mutations — but it'd be able to observe arbitrary amounts of the world, not just amounts we'd have previously downloaded.

we could make the QACI return not a scoring over actions but a proper utility function, but this only constrains the AI's action space and doesn't look like it helps in any way, including making QACI easier for the AI to make good guesses about. perhaps with utility functions we find a way to make the AI go "ah, well i'm not able to steer much future in world-states where i'm in hijacked sims", but it's not clear how or even that this helps much. so for now, the math focuses on this simple case of returning an action-scoring function.

## 3.3. blob location

for any blob length (in bits) $\color{#6669ff}{n\;∈\;ℕ}$:

first, we'll posit $\color{#6669ff}{Γ_n\;≔\;𝔹^n→Ω}$ the set of blob locations; they're identified by a counterfactual blob location function, which takes any counterfactual blob and return the world-state in which a factual blob has been replaced with that counterfactual blob.

$\color{#6669ff}{\textit{Loc}_n\;∈\;Ω×\mathrm{Δ}_Ω×𝔹^n×Ξ→\mathrm{Δ}_{Γ_n}}$ tries to locate an individual blob $\color{#6669ff}{b}$ (as a bitstring of length $\color{#6669ff}{n}$) in a particular world-state sampled from the time-distribution (past or future) $\color{#6669ff}{δ}$ (which will usually be a distribution returned by $\color{#6669ff}{Ω^→_α}$) within the universe starting at $\color{#6669ff}{α}$.

it returns a distribution over counterfactual insertion functions of type $\color{#6669ff}{𝔹^n→Ω}$ which take a counterfactual blob and return the matching counterfactual world-state. the elements in that distribution typically sum up to much less than 1; the total amount they sum up to corresponds to how much $\color{#6669ff}{\textit{Loc}}$ finds the given blob in the given world-state to begin with; thus, sampling from a distribution returned by $\color{#6669ff}{\textit{Loc}}$ in a constrained mass calculation $\color{#6669ff}{\mathbf{M}}$ is useful even if said result is not used, because of its multiplying factor.

note that the returned counterfactual insertion function can be used to locate the factual world-state — simply give it the factual blob as input.

$\color{#6669ff}{Ξ}$ is some countably infinite set of arbitrary pieces of information which each call to $\color{#6669ff}{\textit{Loc}}$ can use internally — the goal of this is for multiple different calls to $\color{#6669ff}{\textit{Loc}}$ to be able to share some prior information, while only being penalized by $\color{#6669ff}{K^-}$ for it once. for example, an element of $\color{#6669ff}{Ξ}$ might describe how to extract the contents of a specific laptop's memory from physics, and individual $\color{#6669ff}{\textit{Loc}}$ calls only need to specify the date and the memory range. for concreteness, we can posit $\color{#6669ff}{Ξ\;≔\;𝔹^*}$, the set of finite bitstrings.

$$\color{#6669ff}{
	\begin{split}
		& f,g,ω,b^\prime,τ
\\	\textit{Loc}_n(α,δ,b,ξ)(γ)\;≔\;&\mathbf{M}
		\left[
			\frac{
				\textit{SimilarPasts}_α(ω,g(b^\prime,τ))
			}{
				R(g,(b^\prime,τ))+R(f,g(b^\prime,τ))
			}
		\right]
\\	& (f,g)\;:\;K^{-\sim}_{Ξ,(Ω\overset{H}→𝔹^n×𝔹^*)×(𝔹^n×𝔹^*\overset{H}→Ω)}(ξ)
\\	& ω\;:\;λω:\textit{max}^Δ_X\left(λω:Ω.\begin{cases}
			δ(ω) & \text{if}\;f(ω)=(b,τ)
\\		0 & \text{otherwise}
		\end{cases}\right).δ(ω)
\\	& b^\prime\;:\;\textit{Uniform}_{𝔹^n}
\\	& \begin{split}
			∀b^{\prime\prime}∈𝔹^n:\;& γ(b^{\prime\prime})=g(b^{\prime\prime},τ)
\\		& f(γ(b^{\prime\prime}))=(b^{\prime\prime},τ)
		\end{split}
	\end{split}
}$$

$\color{#6669ff}{\textit{Loc}}$ works by sampling a pair of functions $\color{#6669ff}{f,g}$, which convert world-states forth and back into {pairs whose first element is the blob and whose second element represents everything in the world-state except the blob}.

that latter piece of information is called $\color{#6669ff}{τ}$ (tau), and rather than being sampled $\color{#6669ff}{τ}$ is defined by the return value of $\color{#6669ff}{f}$ on the original world-state — notably, $\color{#6669ff}{τ}$ is not penalized for being arbitrarily large, though $\color{#6669ff}{f}$ and $\color{#6669ff}{g}$ are penalized for their compute time.

for a given fixed pair of $\color{#6669ff}{f}$ and $\color{#6669ff}{g}$, $\color{#6669ff}{\textit{Loc}}$ finds the set of hypothesis world-states $\color{#6669ff}{ω}$ with the highest value within the time-distribution $\color{#6669ff}{δ}$ for which $\color{#6669ff}{f,g}$ work as intended. this is intended to select the "closest in time" world-states in $\color{#6669ff}{δ}$, to avoid adversarial attackers generating their own factual blobs and capturing our location.

it then weighs locations using, for every counterfactual blob $\color{#6669ff}{b^\prime\;∈\;𝔹^n}$:

* the degree to which counterfactual world-states tend to share pasts with the original factual world-state, for $\color{#6669ff}{b^\prime}$.
* the compute time of $\color{#6669ff}{g}$ and $\color{#6669ff}{f}$ on counterfactual blobs and world-states respectively.

note that $\color{#6669ff}{\textit{Loc}_n}$, by design, only supports counterfactual blobs whose length $\color{#6669ff}{n}$ is equal to the length of the initial factual blob $\color{#6669ff}{b}$ — it wouldn't really make sense to talk about "replacing bits" if the bits are different.

in effect, $\color{#6669ff}{\textit{Loc}}$ takes random $\color{#6669ff}{f,g}$ decoding and re-encoding programs, measures how complex and expensive they are and how far from our desired distributions are world-states in which they work, and how close to the factual world-state their counterfactual world-states are.

## 3.4. blob signing

we'll define $\color{#6669ff}{Π\;≔\;𝔹^{{|q|}-\bar{σ}}}$, the set of possible answer bitstring payloads. 

counterfactual questions will not be signed, and thus will be the set of bitstrings of the same length as the factual question — $\color{#6669ff}{𝔹^{|q|}}$.

we'll define $\color{#6669ff}{\textit{Sign}\;∈\;Π×𝔹^*→𝔹^{|q|}}$ as $\color{#6669ff}{\textit{Sign}(π,k)\;≔\;\textit{ExpensiveHash}(π\|k)\|π}$. this functions tags blob payloads using a "signature" generated from a seed bitstring, concatenating it to the blob payload.

## 3.5. action-scoring functions

we will posit $\color{#6669ff}{A\;⊂\;𝔹^*}$ as the finite set of actions the AI can take, as a finite set of bitstrings.

we'll call $\color{#6669ff}{U\;≔\;A→[0;1]}$ the set of "scoring functions" over actions — functions which "have an opinion" about various actions. this is similar to utility functions, except it's over actions rather than over worlds or world-histories.

they can be composed using $\color{#6669ff}{\textit{Compose}\;∈\;\mathrm{Δ}_U→U}$, which could be simple scoring-function averaging:

$$\color{#6669ff}{
		\begin{split}
			& u
\\		\textit{Compose}(δ)(a)\;\overset{?}≔\;&\mathbf{M}\;[u(a)]
\\		& u\;:\;δ
		\end{split}
}$$

but alternatively, we could use something like [Diffractor's Rose bargaining](https://www.lesswrong.com/posts/vJ7ggyjuP4u2yHNcP/threat-resistant-bargaining-megapost-introducing-the-rose) to reduce the ability for scoring/utility functions to threaten each other — and notably ours.

$$\color{#6669ff}{
	\textit{Compose}\;\overset{?}≔\;\textit{Rose}
}$$

(where i'm using $\color{#6669ff}{\overset{?}≔}$ to mean "maybe define this way, but i'm not sure")

## 3.6. QACI query

using those, we define $\color{#6669ff}{\textit{QACI}\;∈\;Ω×Γ_{|q|}×Ξ×𝔹^{|q|}→\mathrm{Δ}_Π}$ which given a physics hypothesis $\color{#6669ff}{α}$, a question blob location $\color{#6669ff}{γ_q}$, and a blob location prior $\color{#6669ff}{ξ}$, returns the highest guess returned answer payload $\color{#6669ff}{π_r}$ for a given counterfactual question $\color{#6669ff}{q^\prime}$.

$$\color{#6669ff}{
	\begin{split}
			& γ_r
\\		\textit{QACI}(α,γ_q,ξ,q^\prime)(π_r)\;≔\;&\mathbf{M}\;[1]
\\		& γ_r\;:\;\textit{Loc}_{|q|}(α,Ω^→_α(γ_q(q^\prime)),\textit{Sign}(π_r,q^\prime),ξ)
	\end{split}
}$$

$\color{#6669ff}{\textit{QACI}}$ works by sampling answer blob locations $\color{#6669ff}{γ_r}$, from world-states in the future of the counterfactual question world-state $\color{#6669ff}{γ_q(q^\prime)}$, signed using $\color{#6669ff}{q^\prime}$.

with its first three parameters fixed, $\color{#6669ff}{\textit{QACI}}$ becomes the straightforward counterfactual query function $\color{#6669ff}{𝔹^{|q|}→\mathrm{Δ}_{Π}}$: one can call it with arbitrary counterfactual text inputs (within the size limitation), and get a distribution over possible answers, which can easily be collapsed using $\color{#6669ff}{\textit{max}^\mathrm{Δ}_Π}$.

## 3.7. top-level QACI call

the top-level call to the $\color{#6669ff}{\textit{QACI}}$ query function, $\color{#6669ff}{\textit{QACI}_0\;∈\;Ω×Γ_{|q|}×Ξ→\mathrm{Δ}_U}$ interprets its output as a piece of math and executes it with, as parameters, various global and contextual values it might need access to, and returns a distribution over action-scoring functions:

$$\color{#6669ff}{
	\begin{split}
		& π_r,f
\\	\textit{QACI}_0(α,γ_q,ξ)(u)\;≔\;&\mathbf{M}\;[1]
\\	& π_r\;:\;\textit{QACI}(α,γ_q,ξ,q^\prime_0)
\\	& f\;∈\;\textit{EvalMath}_{\{q\}×\{μ_1\}×\{μ_2\}×Ω×Γ_{|q|}×Ξ→U}(π_r)
\\	& f(q,μ_1,μ_2,α,γ_q,ξ)=u
	\end{split}
}$$

where $\color{#6669ff}{q^\prime_0\;∈\;𝔹^{|q|}}$ is the initial counterfactual blob, such as "return a good scoring of actions" encoded in ASCII, padded with zeros to be of the right length.

$\color{#6669ff}{\textit{QACI}_0}$'s distribution over answers demands that the answer payload $\color{#6669ff}{π_r}$, when interpreted as math and with all required contextual variables passed as input ($\color{#6669ff}{q,μ_1,μ_2,α,γ_q,ξ}$), returns an action-scoring function equal to $\color{#6669ff}{u}$ — this is how it measures the weight of any action-scoring function $\color{#6669ff}{u}$.

$\color{#6669ff}{\mathbf{M}\;[1]}$ makes it that $\color{#6669ff}{\textit{QACI}_0}$'s distributions are only determined by the sampled variables and logical requirements.

$\color{#6669ff}{\textit{EvalMath}}$'s $\color{#6669ff}{f}$ function having access to $\color{#6669ff}{\textit{QACI}}$'s distribution over output texts rather than best candidate allows it to discard as many invalid candidates as it needs and stick to ones that match whatever constraits it has.

## 3.8. action scoring

we'll posit the AI as $\color{#6669ff}{\textit{AI}\;∈\;U→A}$ — a program which tries to satisfy a scoring over actions, by making a high-expected-score guess.

we define $\color{#6669ff}{\textit{Score}\;∈\;U}$, the action-scoring function which the AI will be making guesses about as a scoring function over actions, which happens to be one that is, hopefully, good. this is the scoring function for which the AI will be trying to produce an action that is as favorable as possible, within its limited capabilities.

$$\color{#6669ff}{
	\begin{split}
		& α,ξ,γ_{μ_1},γ_{μ_2},γ_q
\\	\textit{Score}\;≔\;\textit{Compose}(λu:U.&\mathbf{M}\;\left[\textit{Normalize}_U(\textit{QACI}_0(α,γ_q,ξ))(u)\right]\;)
\\	& α\;:\;Ω_α
\\	& ξ\;:\;K^-_Ξ
\\	& \begin{split}
			& γ_{μ_1}&&:\;\textit{Loc}_{|{μ_1}|}&&(α,Ω^→_α(α         &&),μ_1&&,ξ)
\\		& γ_{μ_2}&&:\;\textit{Loc}_{|{μ_2}|}&&(α,Ω^→_α(γ_{μ_1}(μ_1)&&),μ_2&&,ξ)
\\		& γ_q    &&:\;\textit{Loc}_{|q|  }&&(α,Ω^→_α(γ_{μ_1}(μ_1)&&),q  &&,ξ)
		\end{split}
\\	& Ω^→_α(γ_q(q))(γ_{μ_2}(μ_2))>Ω^→_α(γ_{μ_2}(μ_2))(γ_q(q))
	\end{split}
}$$

where the following variables are sampled:

* an initial state of the universe $\color{#6669ff}{α}$.
* a blob location prior $\color{#6669ff}{ξ}$, sampled for simplicity.
* the blob locations of $\color{#6669ff}{μ_1}$, $\color{#6669ff}{μ_2}$, and $\color{#6669ff}{q}$.

and the world-state containing the second observation $\color{#6669ff}{μ_2}$ is required to be in the future of the word-state containing the question $\color{#6669ff}{q}$.

then, we rate possible actions $\color{#6669ff}{a}$ by composing the scoring functions produced by $\color{#6669ff}{\textit{QACI}_0}$ for all of those blob location hypotheses.

for any question location, the set of action-scoring functions sampled by $\color{#6669ff}{\textit{QACI}_0}$ is normalized. this is because pairs of *AI-action location and question location* should not be penalized for having a "harder to find" answer — once the observations and question have been located, we want to obtain the answer no matter what.

finally, we'll just execute the action returned by $\color{#6669ff}{\textit{AI}(\textit{Score})}$.