Documentation

DescriptiveComplexity.Problems.Wide.RegChannelBack

Where a backward reading of an accepting run starts #

A run that accepts ends in NexPh.acceptP, which is one of the phases the program can never leave (NexPh.PostGuess). So somewhere along the run there is a first configuration in a post-guess phase, and this file finds it and recognizes its tape.

Two facts do it. The phases before it are all the outer layer's, so the rules fired up to that point keep the file, keep the addressed tracks and write bits (nexRule_keepsFile_of_ne_eval and its two siblings) – which is exactly what DescriptiveComplexity.Draw.Data.ShapedAt propagates along a run. And an accepting configuration is in a post-guess phase, so the search has something to find.

What comes out is a configuration whose tape is an ixBack of some tape state and whose phase is post-guess: the point where the machine's nondeterminism is spent, the guess is written on the tape, and the rest of the run is the evaluation's – deterministic, and read forward.

The first time a property holds #

theorem DescriptiveComplexity.exists_first_of {P : Prop} {n : } (hn : P n) :
mn, P m i < m, ¬P i

A property that holds at some time holds first at some time, with nothing before it. This is Nat.find in the form a run's reading wants: the index, that it is no later than the one it was given, and that every earlier index misses.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.nexProgHanded_facts_of_not_postGuess {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] {R' : Type} {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (r : R') (hph : ¬(PR.rules r).srcPh.PostGuess) :

Every rule the machine can fire outside the post-guess phases keeps the file, keeps the addressed tracks and writes bits. The evaluation's rules fire from an evaluation phase (nexEvalHosrcF), and those are post-guess – so a rule whose source phase is not is one of the outer layer's, where the three facts are nexRule_keepsFile_of_ne_eval and its siblings.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.postGuess_of_acc {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] [LinearOrder A] [LinearOrder (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] {R' : Type} [LinearOrder R'] [FirstOrder.Language.wide.Structure (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)] {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} (haccPh : ∀ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : dt.CtlIxA), PR.accept p fp = NexPh.acceptP) (hR : PR.table.Reads) {c : Config (WPoint (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd))} (hacc : (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Acc c.state) :
∃ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : Fin (Fintype.card (dt.CtlIx dt.SlotIx))A), c.state = Sum.inr (stateElt PR.zero p f) p.PostGuess

An accepting configuration is in a post-guess phase, and its state is a phase state: the accepting predicate names NexPh.acceptP, and an accepting state is canonically padded, so it is stateElt of its own pointer. This is what gives the search for the entry something to find.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.nexProgHanded_dstPh_ne_start {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] {R' : Type} {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (r : R') :

No rule enters the start phase. The machine is in it at time zero and never again – which is what tells a reading that every step after the first fires a rule that keeps the marker rather than writing it.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.nexProgHanded_setsSlot_wk {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] {R' : Type} {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (r : R') (hph : (PR.rules r).srcPh = NexPh.start) (t : dt.SlotIx) (ht : t = Slot.wk t = Slot.bot) :
Rule.SetsSlot dt PR.one t (PR.rules r)

The start step writes the marker and the bottom mark, and it is the only rule that fires from the start phase.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.nexProgHanded_keepsSlot_wk {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] {R' : Type} {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (r : R') (hph : ¬(PR.rules r).srcPh.PostGuess) (hst : (PR.rules r).srcPh NexPh.start) (t : dt.SlotIx) (ht : t = Slot.wk t = Slot.bot) :
Rule.KeepsSlot dt t (PR.rules r)

Every other rule of the outer layer keeps the marker and the bottom mark: the evaluation's fire from a post-guess phase and the start step from the start phase, so a rule whose source phase is neither leaves them where they are.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.nexProgHanded_dstPh_homeGuess {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] {R' : Type} {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (r : R') (f : dt.CtlIxA) (gt : dt.SlotIxA) (hg : (PR.rules r).guard f gt) (hsrc : ¬(PR.rules r).srcPh.PostGuess) (hdst : (PR.rules r).dstPh.PostGuess) :

The one way into the post-guess phases is the guess's stop, and it lands in the walk home. The sweep over the region is never done – where it stops is the program's choice, so GuessSpec.Done is False and the exit that would land in NexPh.guessDoneP can never fire – so a rule that leaves the pre-guess phases leaves them for NexPh.homeGuessP. That is the phase a backward reading finds at its entry, and it is the one reachesIn_homeGuessTail runs from.

Dependency graph
theorem DescriptiveComplexity.Draw.Data.exists_postGuess_shaped {L : FirstOrder.Language} {dt : Data L} {A I : Type} [Fintype dt.SlotIx] [LinearOrder A] [LinearOrder (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] {R' : Type} [LinearOrder R'] [FirstOrder.Language.wide.Structure (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)] {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {args : (v : dt.VarIx) → dt.VarArgs v} {bot : Option dt.KIx} (hcov : NexCovered PR (dt.regionSpec PR.zero PR.one) args bot) (haccPh : ∀ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : dt.CtlIxA), PR.accept p fp = NexPh.acceptP) (hR : PR.table.Reads) {lay : Layout dt A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) I} {st₀ : TapeSt dt A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) I} (g : Config (WPoint (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd))) (hhead : ∀ (i : ), ∃ (v : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp), (g i).head = Sum.inl v) (h0 : ShapedAt PR lay st₀ (g 0)) (n : ) (hstep : i < n, (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Step (g i) (g (i + 1))) (hacc : (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Acc (g n).state) :
mn, ShapedAt PR lay st₀ (g m) (∀ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : Fin (Fintype.card (dt.CtlIx dt.SlotIx))A), (g m).state = Sum.inr (stateElt PR.zero p f)p.PostGuess) i < m, ∀ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : Fin (Fintype.card (dt.CtlIx dt.SlotIx))A), (g i).state = Sum.inr (stateElt PR.zero p f)¬p.PostGuess

The first post-guess configuration of a run, with its tape recognized. Every step before it fires a rule of the outer layer, and those keep the file – so the shape the channel wrote at time zero is still there, and the tape is an ixBack of a tape state (exists_ixBack_of_shape). The phase at that time is one the machine never leaves, which is what DescriptiveComplexity.Draw.Data.not_acc_of_verdict_false_of asks of its entry.

This is where a backward reading starts: the guess is on the tape, the run from here on is the evaluation's, and it is deterministic.

Dependency graph

The run from the entry, forward again #

theorem DescriptiveComplexity.Draw.Data.nexProgHanded_reachesIn_homeGuessTail {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] [LinearOrder A] [Finite A] [Finite dt.KIx] [Nonempty A] [L.IsRelational] [L.Structure A] [LinearOrder (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] [Finite (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] {R' : Type} [LinearOrder R'] [Finite R'] [FirstOrder.Language.wide.Structure (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)] {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {bot : Option dt.KIx} (hE : NexEmitted PR bot) (hR : PR.table.Reads) (hlin : IsLinOrd WMLe) (hord : ∀ (x y : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd), WMLe x y tagTupleLe x y) {st : TapeSt dt A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.RegIx} {v y v' : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp} (hwkS : st.wk = fun (r : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp) => r = v) (hyv : WMSetLe WMLe v y) (hvv' : WMIncr WMLe v v') (f : dt.CtlIxA) (hexG : dt.exitG PR.one (PR.passTracksAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) (fun (x : dt.RegIx) => False) v)) :
(wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).ReachesIn (wideRank y - wideRank v + 1) { state := Sum.inr (PR.stElt NexPh.homeGuessP f), head := Sum.inl y, tape := wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) fun (x : dt.RegIx) => False) (PR.syElt PR.blank) } { state := Sum.inr (PR.stElt (NexPh.evalP (EvalPh.chk 0)) f), head := Sum.inl v', tape := wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) fun (x : dt.RegIx) => False) (PR.syElt PR.blank) }

From the entry to the evaluation, at the handed program: the walk home and the dispatch (reachesIn_homeGuessTail) with the program's rules discharged (nexProgHanded_rules), over the file the channel hands it. The tape is whatever the guess left – the lemma reads none of it but the marker – so this is the step a backward reading takes from the configuration exists_postGuess_shaped hands it.

Dependency graph

The tape state the entry carries #

theorem DescriptiveComplexity.Draw.Data.exists_entry_state {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] [LinearOrder A] [Finite A] [Finite dt.KIx] [Nonempty A] [Nonempty dt.KIx] [L.IsRelational] [L.Structure A] [LinearOrder (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] [Finite (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] {R' : Type} [LinearOrder R'] [Finite R'] [FirstOrder.Language.wide.Structure (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)] {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {bot : Option dt.KIx} (hE : NexEmitted PR bot) (hR : PR.table.Reads) (hlin : IsLinOrd WMLe) (hord : ∀ (x y : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd), WMLe x y tagTupleLe x y) {v₀ : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp} (hvreg : ∀ (x : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd), (∃ (k : dt.KIx), x.1 = Tag.arg k) IsTopNonArg xv₀ wmRegSeg x) (g : Config (WPoint (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd))) (hhead : ∀ (i : ), ∃ (v : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp), (g i).head = Sum.inl v) (hhead0 : (g 0).head = Sum.inl v₀) (hstate0 : (g 0).state = Sum.inr (PR.stElt NexPh.start fun (x : dt.CtlIx) => PR.zero)) (h0 : (g 0).tape = wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.mir PR.initBackReg fun (x : dt.RegIx) => False) (PR.syElt PR.blank)) (n : ) (hstep : i < n, (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Step (g i) (g (i + 1))) (hacc : (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Acc (g n).state) :
mn, ∃ (st : TapeSt dt A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.RegIx), (g m).tape = wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) fun (x : dt.RegIx) => False) (PR.syElt PR.blank) (st.wk = fun (r : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp) => r = v₀) (st.mir = fun (x : dt.RegIx) => False) (st.tgt = fun (x : dt.RegIx) => False) (st.sav = fun (x : dt.RegIx) => False) (st.val = fun (x : dt.RegIx) => False) (st.bot = fun (r : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp) => r = v₀) (∀ (p : NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) (f : Fin (Fintype.card (dt.CtlIx dt.SlotIx))A), (g m).state = Sum.inr (stateElt PR.zero p f)p.PostGuess) ∃ (fm : dt.CtlIxA), (g m).state = Sum.inr (PR.stElt NexPh.homeGuessP fm)

The entry's tape, read as a tape state. The channel's tape is recognizable (tapeShape_initBackReg), the reading survives to the first post-guess time (exists_postGuess_shaped) and there the tape is an ixBack (exists_ixBack_of_shape) whose mirror, target, saved mirror and valuation are empty. The marker is the one write of the opening the reading has to read: the start step sets it at the cell the head began on and no later rule touches it (track_set_of_seq, nexProgHanded_setsSlot_wk, nexProgHanded_keepsSlot_wk), so the state's working track marks that cell alone.

That is every hypothesis the evaluation's entry state is asked for except the stage tracks, which are the guess's and are read off the same ixBack.

Dependency graph

No acceptance, from a false verdict at the entry #

theorem DescriptiveComplexity.Draw.Data.not_acc_of_entry_verdict {L : FirstOrder.Language} {dt : Data L} {A : Type} [Fintype dt.SlotIx] [LinearOrder A] [Finite A] [Finite dt.KIx] [Nonempty A] [L.IsRelational] [L.Structure A] [LinearOrder (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] [Finite (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF))] {R' : Type} [LinearOrder R'] [Finite R'] [FirstOrder.Language.wide.Structure (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)] {PR : Prog A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.CtlIx dt.SlotIx dt.KIx dt.dd} {bot : Option dt.KIx} (hE : NexEmitted PR bot) (hR : PR.table.Reads) (hlin : IsLinOrd WMLe) (hord : ∀ (x y : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd), WMLe x y tagTupleLe x y) {st : TapeSt dt A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.RegIx} {v₀ y v' : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp} (hwk : st.wk = fun (r : Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.ddProp) => r = v₀) (hmirS : st.mir = fun (x : dt.RegIx) => False) (hyv : WMSetLe WMLe v₀ y) (hvv' : WMIncr WMLe v₀ v') (fm : dt.CtlIxA) (hexG : dt.exitG PR.one (PR.passTracksAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) (fun (x : dt.RegIx) => False) v₀)) {e : } {fq : dt.CtlIxA} {cT : Config (WPoint (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd))} (heval : (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).ReachesIn e { state := Sum.inr (PR.stElt (NexPh.evalP (EvalPh.chk 0)) fm), head := Sum.inl v', tape := wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.val (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) st.val) (PR.syElt PR.blank) } cT) (hstateT : cT.state = Sum.inr (PR.stElt NexPh.acceptP fq)) (hbit : ¬(dt.varArgsOf PR.zero PR.one none).accBit fq) {entry c : Config (WPoint (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd))} (hentrySt : entry.state = Sum.inr (PR.stElt NexPh.homeGuessP fm)) (hentryHd : entry.head = Sum.inl y) (hentryTp : entry.tape = wideTape (PR.trackTapeAt (regLaid hlin hord).cell Slot.mir (dt.ixBack (regLaid hlin hord).toLayout PR.zero PR.one st) fun (x : dt.RegIx) => False) (PR.syElt PR.blank)) (hreach : Relation.ReflTransGen (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Step entry c) (hacc : (wideData (Univ A R' (NexPh (Option dt.KIx) (EvalPh dt.nv dt.PMF)) dt.KIx dt.dd)).Acc c.state) :

An entry whose verdict is false accepts nothing. From the configuration a backward reading finds – the walk home, at the tape state it recovered – the machine's run is forced: the walk home and the dispatch (nexProgHanded_reachesIn_homeGuessTail), then the evaluation, which ends in the accepting phase with the bit the sentence's own value. If that bit is clear the run is a dead end, and from a post-guess configuration the machine has only one run (not_acc_of_verdict_false_of) – so nothing below the entry accepts.

This is the backward direction's last step: the reading supplies the entry, the evaluation supplies the verdict, and the false verdict of a no-instance closes it.

Dependency graph