Recursively enumerable sets of bit strings are halting sets of the ambient model #
exists_semidecider: for every recursively enumerable predicate p on bit strings (Mathlib's
REPred) there is a well-scoped program S of the ambient model that halts on the encoding
encode x of a bit string x exactly when p x. This is the form in which the
compressibility criterion (MIPRE.Cost.compressibility_criterion) consumes semidecidability
— its hypothesis hS : ∀ x, Halts S (encode x) ↔ x ∉ B — and, with rePred_halts (the
halting set of a program on encoded strings is recursively enumerable), it identifies REPred
on bit strings with the halting sets of the model (MIPRE.isRE_iff).
The route is that of exists_compile: through Turing.ToPartrec.Code and its translation
Prog.ofCode, with one obstacle. A ToPartrec code cannot see trailing zeros of its input
list (its primitives read [] and 0 :: v alike), whereas the bit false encodes as
nil = ofNat 0, so no translated code can separate x from x ++ [false]. So S first shifts
every bit up by one — shiftRevProg, a loop, which reverses the list on the way as loops
naturally do — producing the encL-encoding of a list of ones and twos, which a ToPartrec
loop (BitCode.convCode) folds into the Mathlib code number Encodable.encode x of the
original string; a ToPartrec code for the r.e. predicate, from
Turing.ToPartrec.Code.exists_code, then runs on that number.
A ToPartrec code reading a bit string off a list of ones and twos #
[a, b, rest...] ↦ [b, a, rest...] (and [a] ↦ [0, a]).
Equations
Instances For
The step of the fold, [acc, n] ↦ pair n acc + 1, as a function on vectors: it is
Encodable.encode (b :: l) from n = encode b and acc = encode l.
Instances For
Body of the folding loop, given a step code cg: on [acc, n + 1, rest...] continue with
[pair n acc + 1, rest...]; on [acc] (or [acc, 0, ...]) stop with [acc].
Equations
- One or more equations did not get rendered due to their size.
Instances For
The fold computed by the loop: foldEnc [n₁, …, nₖ] acc pairs the entries onto the
accumulator from the left.
Equations
- MIPRE.Cost.BitCode.foldEnc [] x✝ = x✝
- MIPRE.Cost.BitCode.foldEnc (n :: w) x✝ = MIPRE.Cost.BitCode.foldEnc w (Nat.pair n x✝ + 1)
Instances For
The conversion code: on a list of positive naturals w.map (· + 1) it returns
[foldEnc w 0].
Equations
Instances For
Folding the codes of the bits of l onto the code of m yields the code of
l.reverse ++ m.
An r.e. predicate on bit strings is the halting set of a ToPartrec code on the list of
shifted bit codes of the reversed string.
Shifting the bits up by one, in the ambient model #
Body of shiftRevProg: on state cons xs acc, stop with acc if xs is empty, otherwise
move cons nil (head xs) onto acc.
Equations
- One or more equations did not get rendered due to their size.
Instances For
shiftRevProg on list l computes list ((l.map (cons nil)).reverse): on an encoded bit
string, the reversed list of its bits shifted up by one (cons_nil_ofBool).
Equations
Instances For
A bit shifted up by one is the unary numeral of its code plus one: false ↦ ofNat 1,
true ↦ ofNat 2.
The output of shiftRevProg on an encoded bit string is the encL-encoding of the shifted
codes of the bits of the reversed string.
The semidecider #
Recursively enumerable predicates are halting sets. For every r.e. predicate p on bit
strings there is a well-scoped program halting on encode x exactly when p x: the hypothesis
hS of compressibility_criterion, for p := (· ∉ B).
The converse: halting sets are recursively enumerable #
The encoding of bit strings as data is primitive recursive.