Theorem 5.6 (Scott 1981, PRG-19, ยง5) โ the FULL closure: partial recursive โน #
ฮป-definable
Theorem56.lean builds the constructive heart (strict starting functions, the
primitive-recursion
and ฮผ combinators with their scheme equations). This file wires those pieces
together against
Mathlib's arity-aware inductive predicates Nat.Primrec'/Nat.Partrec' (over
List.Vector โ n),
whose constructors are exactly Scott's generation grammar:
Nat.Primrec':zero,succ,get i(projection),comp,prec(primitive recursion);Nat.Partrec':prim,comp,rfind(minimization).
We prove: every Nat.Primrec'/Nat.Partrec' function is denoted by an
approximable map
ฯ : ๐ฉ โ N, where ๐ฉ := N^โ (Exercise 3.16) is the universal argument domain
โ a k-ary
function is realised by a single map that depends only on coordinates 0..k-1.
The realisation is
very strict (Scott): โฅ in any relevant coordinate forces โฅ, which is what
makes composition and
minimisation compose. The capstone is partrec_lamDef and the 1-ary corollary
partrec_one.
T.bot = Example23.botElt (both least); bridges zeroMap_bot (lands in
T.bot) with
cond_bot
(phrased with Example23.botElt).
Element builders. #
none โฆ โฅ, some n โฆ nฬ.
Equations
Instances For
The argument element of ๐ฉ carrying a List.Vector โ n in its first n
coordinates.
Equations
- Domain.Neighborhood.Theorem56Full.vecElem v = Domain.Neighborhood.Theorem56Full.argElem fun (i : Fin n) => some (v.get i)
Instances For
Components through push. #
The strictifier guard1/strictGuardN (Scott's cond(zero(x),ยท,ยท) #
device).
guard1 j ฯ z = cond(zero(zโฑผ), ฯ z, ฯ z): equals ฯ z when zโฑผ is total, โฅ
when zโฑผ = โฅ.
Composing the guards for j = 0..n-1 makes a map very strict in its first n
coordinates.
Test coordinate j: cond(zero(zโฑผ), ฯ z, ฯ z).
Equations
- One or more equations did not get rendered due to their size.
Instances For
If ฯ z = โฅ and zโฑผ is total-or-โฅ, the guard stays โฅ.
On arguments whose first n coordinates are all total, the guard is
transparent.
If some coordinate i < n is โฅ (and z is arg-like), the guard forces โฅ.
โจgโ, โฆ, g_{n-1}โฉ : ๐ฉ โ ๐ฉ placing gแตข at coordinate i (< n) and โฅ
beyond.
Equations
- One or more equations did not get rendered due to their size.
- Domain.Neighborhood.Theorem56Full.tupleMap 0 x_2 = Domain.Neighborhood.constMap Domain.Neighborhood.Theorem56Full.๐ฉ Domain.Neighborhood.Theorem56Full.๐ฉ.bot
Instances For
Coordinate i < n of the tuple is exactly gแตข.
The ฮป-definability specification. #
ฯ : ๐ฉ โ N realises the n-ary partial function f (a very strict
ฮป-definition):
ฯ returns f's value on total arguments, โฅ where f is undefined, and โฅ on
any arg-like
input with a โฅ among its first n coordinates.
- defined (v : List.Vector โ n) (c : โ) : c โ f v โ ฯ.toElementMap (vecElem v) = Example43.natElem c
- undef (v : List.Vector โ n) : ยฌ(f v).Dom โ ฯ.toElementMap (vecElem v) = Example43.N.bot
- strict (z : ๐ฉ.Element) : ArgLike z โ โ i < n, component z i = Example43.N.bot โ ฯ.toElementMap z = Example43.N.bot
Instances For
Every coordinate j < n of vecElem v is the total v.get j.
vecElem v has total coordinates throughout its arity.
Master constructor. Wrapping an inner map (correct on total arguments)
in strictGuardN n
yields a full, very strict ฮป-definition. The strict clause is then automatic.
The total-function specialisation of lamDef_of_inner.
Primitive recursive base cases: zero, succ, get. #
zero : Vector โ 0 โ โ, the constant 0 (nullary).
succ : Vector โ 1 โ โ, v โฆ v.head + 1.
get i : Vector โ n โ โ, the i-th projection.
Transport a ฮป-definition along pointwise equality of the realised function.
The value a realiser takes on a total argument is total-or-โฅ (arg-like).
Composition. #
Coordinates of the bottom stack are โฅ.
Coordinates โฅ n of the tuple are โฅ.
The tuple of realisers, applied to a total argument, equals vecElem w where
wแตข = gแตข(v).
The tuple of realisers, applied to a total argument, is arg-like.
Membership in mOfFn (Part monad): a vector is produced iff each coordinate
is a value.
Composition (Scott's multivariate composition). If f and each gแตข are
ฮป-defined, so is
v โฆ (โจgโ v, โฆ, g_{nn-1} vโฉ) >>= f.
A realiser of a total function evaluates to its value.
Composition of total functions (the Nat.Primrec'.comp shape).
Primitive recursion. #
The recursion lives over prod (funSpace ๐ฉ N) ๐ฉ: k is the unknown, z the
argument stack whose
head is the recursion variable and whose tail carries the parameters. The body is
M(k, z) = cond(zero(head z), f(tail z), g(โจpred(head z), โจk(โจpred(head z), tail zโฉ), tail zโฉโฉ)).
The primitive-recursion body.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The primitive-recursion operator R(k) = ฮปz. โฆ.
Equations
Instances For
recMap : ๐ฉ โ N, the least fixed point of recOp (before strictifying).
Equations
Instances For
The defining recursion equation.
Primitive recursion computes. recMap(โจd, uโฉ) = (Nat.rec (f u) (g โฆ) d).
Primitive recursion (Nat.Primrec'.prec shape).
Closure of the primitive recursive functions. #
Every Nat.Primrec' function is ฮป-definable by a (very strict)
approximable map.
Minimisation (rfind). #
The ฮผ-operator searches upward for the least k with f(k ::แตฅ v) = 0. We carry
the counter in the
head coordinate of the stack. The search body over prod (funSpace ๐ฉ N) ๐ฉ is
S(k, z) = cond(zero(f z), head z, k(push(succ(head z), tail z))) :
if the current value f z is 0, return the counter head z; otherwise recurse
with the counter
bumped by one. searchMap is the least fixed point, and findMap kicks the
search off at counter 0.
The hard direction is divergence: when no k zeroes f, every finite
approximant Sโฟ(โฅ) returns
โฅ along the search trace, so the directed sup (Theorem 4.2(iii)) is โฅ too.
The search body S(k, z) = cond(zero(f z), head z, k(push(succ(head z), tail z))).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The search operator S(k) = ฮปz. โฆ, whose least fixed point is the running
search.
Equations
Instances For
searchMap : ๐ฉ โ N, the least fixed point of findOp (the counter lives in
coordinate 0).
Equations
Instances For
The defining recursion equation of the search.
findMap : ๐ฉ โ N starts the search with counter 0.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Search step (found). If f(k ::แตฅ v) = 0, the search returns the counter
k.
Search step (continue). If f(k ::แตฅ v) โ 0, the search advances to
counter k + 1.
Capstone (least zero โน value). If m is a zero of f(ยท ::แตฅ v) and
nothing below it is,
then
starting from any counter j โค m the search returns m. (Downward induction on
m - j.)
Divergence via the directed sup of approximants. #
The least map of the function space evaluates to โฅ everywhere.
The 0-th approximant Sโฐ(โฅ) is the bottom map.
Value of the 0-th approximant: โฅ.
Recursion equation for the approximant values: S^{m+1}(โฅ) unfolds one search
step using
Sแต(โฅ) as the continuation.
Along a no-zero trace, every finite approximant returns โฅ (induction on
the approximant
index, with the counter universally quantified since the search advances it).
Divergence. If f(ยท ::แตฅ v) has no zero, the search is โฅ from every
counter. The fixed
point
is the directed union of the approximants Sแต(โฅ) (Theorem 4.2(iii)); pushing the
evaluation at
vecElem (k ::แตฅ v) through this sup (continuity, toElementMap_iSupDirected)
reduces the claim to
iterVal_bot.
Minimisation (Nat.Partrec'.rfind shape). Given a (very strict) realiser
of a total
f : Vector โ (n+1) โ โ, strictGuardN n (findMap ฯf) ฮป-defines
v โฆ ฮผk. f(k ::แตฅ v) = 0.
Closure of the partial recursive functions โ the full meta-theorem. #
Theorem 5.6 (Scott 1981, PRG-19) โ every partial recursive function is
ฮป-definable. For each
Nat.Partrec' function f : Vector โ n โ. โ there is an approximable map ฯ : ๐ฉ โ N that is a
very strict ฮป-definition of f: it returns f's value on total arguments, โฅ
where f is
undefined, and โฅ on any arg-like input with a โฅ among its first n
coordinates.
Scott's 1-ary statement. #
Every partial recursive h : โ โ. โ is realised by an approximable map ฯ : N โ N over the flat
naturals: ฯ(nฬ) = mฬ when h n = m, ฯ(nฬ) = โฅ when h n diverges, and ฯ(โฅ) = โฅ (strictness).
Inject N โ ๐ฉ as the stack whose only nonzero coordinate is the head.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Scott's 1-ary meta-theorem. A partial recursive h : โ โ. โ (presented as
a unary
Nat.Partrec') is denoted by a single approximable map ฯ : N โ N that is
correct on values,
divergent where h diverges, and strict.