The alphabet of the machine simulating a ToPartrec code #
The static data of the RE-hardness of DescriptiveComplexity.HALT
(PCP-HARDNESS.md §2): the machine M(c) that the reduction draws simulates
the sequential semantics Turing.ToPartrec.step of a fixed code c, so
its states and symbols are indexed by the positions of the syntax tree of
c – a finite type built by recursion on c, the SubPos pattern of the
CODEHALT reduction – and by nothing else. This file carries those positions
(DescriptiveComplexity.HaltHard.CPos), the continuations restricted to
subcodes (DescriptiveComplexity.HaltHard.PCont), the tape alphabet
(DescriptiveComplexity.HaltHard.SimSym) and the encoding of a configuration
as a tape word:
bk … bk endL ⟦TOP⟧ gap ⟦…⟧ gap ⟦BASE⟧ gap mid gap ⟦value, mirrored⟧ endR bk …
- the value
[n₁, …, nₖ]sits between the fixed separatormidand the movable right markerendR, written mirrored: blocks in reverse order, each blockcomfirst, so the word readscom 1^nₖ … com 1^n₁and the head block's digits end atendR. The mirroring is what gives every operation on the head of the value unbounded room: prepending grows the word atendR, into the blank half-tape, and no marker ever has to move over another letter. The cell right ofmidis kept blank, so a block separator can always be closed next to an empty value; - a continuation frame is a header letter – carrying the position of its
code, if it has one – followed by its stored value: a
cons₁frame stores it straight (encVal), which is what one marked copy loop writes atendL, and acons₂frame stores it mirrored, which is what the destructive move of the exchange writes; the top frame sits leftmost; - frames may be separated by blank gaps – erasing a consumed frame just
leaves one – and the frame region is bounded by the movable left marker
endLand the fixed separatormid.
Every code in a continuation frame reached from stepNormal c … /stepRet
is a subcode of c, so the positioned continuations PCont mirror
Turing.ToPartrec.Cont with positions for codes;
DescriptiveComplexity.HaltHard.PCont.toCont projects back, and the
simulation is stated over PCont throughout.
The positions of the syntax tree of a code #
The positions of the syntax tree of a ToPartrec code, by recursion on
the code: one tag per node, so that drawing the machine of a fixed code costs
nothing at any instance size.
Equations
- DescriptiveComplexity.HaltHard.CPos Turing.ToPartrec.Code.zero' = Unit
- DescriptiveComplexity.HaltHard.CPos Turing.ToPartrec.Code.succ = Unit
- DescriptiveComplexity.HaltHard.CPos Turing.ToPartrec.Code.tail = Unit
- DescriptiveComplexity.HaltHard.CPos (f.cons fs) = (Unit ⊕ DescriptiveComplexity.HaltHard.CPos f ⊕ DescriptiveComplexity.HaltHard.CPos fs)
- DescriptiveComplexity.HaltHard.CPos (f.comp g) = (Unit ⊕ DescriptiveComplexity.HaltHard.CPos f ⊕ DescriptiveComplexity.HaltHard.CPos g)
- DescriptiveComplexity.HaltHard.CPos (f.case g) = (Unit ⊕ DescriptiveComplexity.HaltHard.CPos f ⊕ DescriptiveComplexity.HaltHard.CPos g)
- DescriptiveComplexity.HaltHard.CPos f.fix = (Unit ⊕ DescriptiveComplexity.HaltHard.CPos f)
Instances For
Dependency graph
Dependency graph
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.HaltHard.instDecidableEqCPos Turing.ToPartrec.Code.zero' = DescriptiveComplexity.HaltHard.instDecidableEqCPos._aux_1
- DescriptiveComplexity.HaltHard.instDecidableEqCPos Turing.ToPartrec.Code.succ = DescriptiveComplexity.HaltHard.instDecidableEqCPos._aux_3
- DescriptiveComplexity.HaltHard.instDecidableEqCPos Turing.ToPartrec.Code.tail = DescriptiveComplexity.HaltHard.instDecidableEqCPos._aux_5
- DescriptiveComplexity.HaltHard.instDecidableEqCPos f.fix = DescriptiveComplexity.HaltHard.instDecidableEqCPos._aux_13 f (DescriptiveComplexity.HaltHard.instDecidableEqCPos f)
Dependency graph
The root position.
Equations
- DescriptiveComplexity.HaltHard.cRoot Turing.ToPartrec.Code.zero' = ()
- DescriptiveComplexity.HaltHard.cRoot Turing.ToPartrec.Code.succ = ()
- DescriptiveComplexity.HaltHard.cRoot Turing.ToPartrec.Code.tail = ()
- DescriptiveComplexity.HaltHard.cRoot (f.cons fs) = Sum.inl ()
- DescriptiveComplexity.HaltHard.cRoot (f.comp g) = Sum.inl ()
- DescriptiveComplexity.HaltHard.cRoot (f.case g) = Sum.inl ()
- DescriptiveComplexity.HaltHard.cRoot f.fix = Sum.inl ()
Instances For
Dependency graph
Dependency graph
The subcode sitting at a position.
Equations
- DescriptiveComplexity.HaltHard.codeAt x_2 = Turing.ToPartrec.Code.zero'
- DescriptiveComplexity.HaltHard.codeAt x_2 = Turing.ToPartrec.Code.succ
- DescriptiveComplexity.HaltHard.codeAt x_2 = Turing.ToPartrec.Code.tail
- DescriptiveComplexity.HaltHard.codeAt (Sum.inl val) = f.cons fs
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inl q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inr q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inl val) = f.comp g
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inl q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inr q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inl val) = f.case g
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inl q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr (Sum.inr q)) = DescriptiveComplexity.HaltHard.codeAt q
- DescriptiveComplexity.HaltHard.codeAt (Sum.inl val) = f.fix
- DescriptiveComplexity.HaltHard.codeAt (Sum.inr q) = DescriptiveComplexity.HaltHard.codeAt q
Instances For
Dependency graph
Dependency graph
The positions of the immediate subterms: the first child of a binary node.
Equations
- DescriptiveComplexity.HaltHard.child₁ x_2 = none
- DescriptiveComplexity.HaltHard.child₁ x_2 = none
- DescriptiveComplexity.HaltHard.child₁ x_2 = none
- DescriptiveComplexity.HaltHard.child₁ (Sum.inl val) = some (Sum.inr (Sum.inl (DescriptiveComplexity.HaltHard.cRoot f)))
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos fs) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inl val) = some (Sum.inr (Sum.inl (DescriptiveComplexity.HaltHard.cRoot f)))
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos g) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inl val) = some (Sum.inr (Sum.inl (DescriptiveComplexity.HaltHard.cRoot f)))
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos g) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₁ q)
- DescriptiveComplexity.HaltHard.child₁ (Sum.inl val) = some (Sum.inr (DescriptiveComplexity.HaltHard.cRoot f))
- DescriptiveComplexity.HaltHard.child₁ (Sum.inr q) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr r) (DescriptiveComplexity.HaltHard.child₁ q)
Instances For
Dependency graph
The positions of the immediate subterms: the second child of a binary node.
Equations
- DescriptiveComplexity.HaltHard.child₂ x_2 = none
- DescriptiveComplexity.HaltHard.child₂ x_2 = none
- DescriptiveComplexity.HaltHard.child₂ x_2 = none
- DescriptiveComplexity.HaltHard.child₂ (Sum.inl val) = some (Sum.inr (Sum.inr (DescriptiveComplexity.HaltHard.cRoot fs)))
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos fs) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inl val) = some (Sum.inr (Sum.inr (DescriptiveComplexity.HaltHard.cRoot g)))
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos g) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inl val) = some (Sum.inr (Sum.inr (DescriptiveComplexity.HaltHard.cRoot g)))
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inl q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr (Sum.inl r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr (Sum.inr q)) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos g) => Sum.inr (Sum.inr r)) (DescriptiveComplexity.HaltHard.child₂ q)
- DescriptiveComplexity.HaltHard.child₂ (Sum.inl val) = none
- DescriptiveComplexity.HaltHard.child₂ (Sum.inr q) = Option.map (fun (r : DescriptiveComplexity.HaltHard.CPos f) => Sum.inr r) (DescriptiveComplexity.HaltHard.child₂ q)
Instances For
Dependency graph
The codes at the children #
The step function dispatches on the code at a position and moves to its
children, so the simulation needs to read the child positions' codes off the
parent's. The two functions below are the code-level shadows of
DescriptiveComplexity.HaltHard.child₁/child₂, and the lemmas identify the
two readings.
The left immediate subterm of a code.
Equations
Instances For
Dependency graph
The right immediate subterm of a code.
Equations
Instances For
Dependency graph
The code at the first child is the first subterm of the code at the position.
Dependency graph
The code at the second child is the second subterm of the code at the position.
Dependency graph
The first child of the code at p, defaulting to the root – the default
is never taken at the positions the machine visits.
Equations
Instances For
Dependency graph
The second child of the code at p.
Equations
Instances For
Dependency graph
The code at the first child, when the position holds a code with a first subterm.
Dependency graph
The code at the second child, when the position holds a code with a second subterm.
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Continuations over positions #
Every code stored in a continuation reached from stepNormal c/stepRet is
a subcode of c, so the simulation works with continuations carrying
positions and projects back to Turing.ToPartrec.Cont when it meets the
library semantics.
A continuation whose codes are positions of the syntax tree of c.
- halt
{c : Turing.ToPartrec.Code}
: PCont c
The empty continuation.
- cons₁
{c : Turing.ToPartrec.Code}
: CPos c → List ℕ → PCont c → PCont c
The first half of a
cons: evaluate the second component on the stored value. - cons₂
{c : Turing.ToPartrec.Code}
: List ℕ → PCont c → PCont c
The second half of a
cons: prepend the stored head. - comp
{c : Turing.ToPartrec.Code}
: CPos c → PCont c → PCont c
A pending composition.
- fix
{c : Turing.ToPartrec.Code}
: CPos c → PCont c → PCont c
A pending fixpoint.
Instances For
Dependency graph
The continuation a positioned continuation stands for.
Equations
- DescriptiveComplexity.HaltHard.PCont.halt.toCont = Turing.ToPartrec.Cont.halt
- (DescriptiveComplexity.HaltHard.PCont.cons₁ p as k).toCont = Turing.ToPartrec.Cont.cons₁ (DescriptiveComplexity.HaltHard.codeAt p) as k.toCont
- (DescriptiveComplexity.HaltHard.PCont.cons₂ ns k).toCont = Turing.ToPartrec.Cont.cons₂ ns k.toCont
- (DescriptiveComplexity.HaltHard.PCont.comp p k).toCont = Turing.ToPartrec.Cont.comp (DescriptiveComplexity.HaltHard.codeAt p) k.toCont
- (DescriptiveComplexity.HaltHard.PCont.fix p k).toCont = Turing.ToPartrec.Cont.fix (DescriptiveComplexity.HaltHard.codeAt p) k.toCont
Instances For
Dependency graph
The tape alphabet #
The tape alphabet of the simulating machine: the blank, the unary digit
and the block separator (each with a primed copy for the one non-destructive
copy loop), the three markers – the movable endL and endR and the fixed
mid – and one header letter per continuation frame shape, the ones carrying
a code carrying its position.
- bk
{c : Turing.ToPartrec.Code}
: SimSym c
The blank.
- one
{c : Turing.ToPartrec.Code}
: SimSym c
The unary digit.
- one'
{c : Turing.ToPartrec.Code}
: SimSym c
The marked unary digit, inside a copy loop.
- com
{c : Turing.ToPartrec.Code}
: SimSym c
The block separator closing each number.
- com'
{c : Turing.ToPartrec.Code}
: SimSym c
The marked block separator, inside a copy loop.
- endL
{c : Turing.ToPartrec.Code}
: SimSym c
The movable left end of the frame region.
- mid
{c : Turing.ToPartrec.Code}
: SimSym c
The fixed separator between the frames and the value.
- endR
{c : Turing.ToPartrec.Code}
: SimSym c
The movable right end of the value region.
- hCons₁
{c : Turing.ToPartrec.Code}
: CPos c → SimSym c
The header of a
cons₁frame, carrying the position of its code. - hCons₂
{c : Turing.ToPartrec.Code}
: SimSym c
The header of a
cons₂frame. - hComp
{c : Turing.ToPartrec.Code}
: CPos c → SimSym c
The header of a
compframe, carrying the position of its code. - hFix
{c : Turing.ToPartrec.Code}
: CPos c → SimSym c
The header of a
fixframe, carrying the position of its code.
Instances For
Dependency graph
Dependency graph
Words #
The word of one number: its unary digits, closed by a separator.
Equations
Instances For
Dependency graph
The word of a value, head block leftmost. The value region of the tape
holds (encVal v).reverse – blocks in reverse order, each separator before
its digits – so that the head block ends at the movable marker endR and
every operation on it has the blank half-tape to grow into.
Equations
Instances For
Dependency graph
The word of one continuation frame: its header, then its stored value –
straight in a cons₁ frame (what the marked copy loop writes), mirrored in a
cons₂ frame (what the destructive move of the exchange writes).
Equations
- DescriptiveComplexity.HaltHard.encFrame DescriptiveComplexity.HaltHard.PCont.halt = []
- DescriptiveComplexity.HaltHard.encFrame (DescriptiveComplexity.HaltHard.PCont.cons₁ p as k) = DescriptiveComplexity.HaltHard.SimSym.hCons₁ p :: DescriptiveComplexity.HaltHard.encVal as
- DescriptiveComplexity.HaltHard.encFrame (DescriptiveComplexity.HaltHard.PCont.cons₂ ns k) = DescriptiveComplexity.HaltHard.SimSym.hCons₂ :: (DescriptiveComplexity.HaltHard.encVal ns).reverse
- DescriptiveComplexity.HaltHard.encFrame (DescriptiveComplexity.HaltHard.PCont.comp p k) = [DescriptiveComplexity.HaltHard.SimSym.hComp p]
- DescriptiveComplexity.HaltHard.encFrame (DescriptiveComplexity.HaltHard.PCont.fix p k) = [DescriptiveComplexity.HaltHard.SimSym.hFix p]