BB(6) hunt
Machines / W4-3

1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---

W4-3local proof 20Kill claimedSkelet 1-like Class 2bbchallenge ↗Explorer

How we proved it never halts

A base-3 odometer made of tape flaws

The tape looks like a zebra stripe, 0101…, with a few dozen flaws: spots where two neighbouring cells match (00 or 11). The head sweeps back and forth, flipping every cell it crosses. Flipping keeps matching neighbours matching, so the pattern of flaws changes only where the head runs into one. Read the right way, the flaws form a base-3 odometer: a chain of digits in the middle counts the head's trips, and a four-digit dial at the left end ticks each time the chain rolls over.

The key idea: the head's behaviour repeats every four cells, so what happens at a flaw depends only on its position counted in fours and on the order of the flaws, not on exact distances, as long as flaws are not crowded together. A million-cell gap acts like a short gap with the same remainder, so one finite computation covers every size.

Why that settles it: a round ends when the dial overflows; then the chain regroups and the right end moves on to the next of six phases. After six rounds the picture repeats with two more digits and its long flawless stretches roughly nine times longer. The missing instruction fires only if the head, moving right, pushes a flaw two cells along while another flaw sits right beside it. No piece of a round does that, and every round ends in the same family of tapes, so the run never stops.

In Rocq (busycoq), a verified simulator that treats gap lengths as symbols replays the first 2.6 trillion steps. It then checks every chain block, dial tick and right-end phase for all sizes, and that each round returns to the same family of tapes.

#20local proof number
2,584lines of Rocq
74 sto compile
6/6automatic checks
space-time diagram, first 10,000 steps from blank
The first 10,000 steps from a blank tape. Time runs down; white is 1.
About this picture

The standard picture (bbchallenge.org's Default view): each row is the whole tape at one step, time runs downward, and the head's path draws the pattern.

bbchallenge-defaultStart blankRows steps 0 → 10,000, top to bottomWindow cells −200..199, left to rightColors 1 0 or unvisited

Overview

In one sentence

Multi-level counter on 00/11 defects between inert fossil blocks; a new fossil 3F+72 cells long each epoch.

Submitted mechanism Between two blank ends the tape is alternating except at defects (two equal neighbours). A sweep complements the cells it crosses, so the defect pattern changes only when the head meets a defect. Sweeps run through fixed 4-cycles of states, and at a defect the head passes, turns or wiggles depending only on the defect's position mod 4 against the head's phase. Halting needs two adjacent defects met in one particular phase. (submission/README.md, Mechanism)

Upstream
Kill claimed · PR #17merged 2026-10-14 06:20 UTC by ccz181078 · Sk1Class2_v3.v · TM6 · on Submissions →
Rocq proof
check_kill PASS · first Oct 12 21:03
2,584 lines · 138 KB .v · compile 74.1 s · coqchk pass · 0 axioms · PASS Oct 12 21:03 (re-run Oct 14 14:57)
· the .v file
Automatic review
6 of 6 checks passtemplate: verify/SBCv6.v Module TM21 (adapted from) · details in Proof →
Class
Skelet 1-like Class 2ours: sheet Skelet 1-like Class 2 ≠ ours Skelet 1-like: multi-level counter on phase defects between inert fossil blocks (x3 per epoch) · low confidence
On the list
not on BB6_holdouts_663.txt (line 341 of the previous list) · historical 740 line 341
eqv ×6sim 1e15
Your calls on file 5
funded
option: sync_stage · date: 2026-10-12 · campaign: class2_closeout · stage: 3
2026-10-12 · induction_stage
Fund one ~2 h induction stage to prove W4-3's record macro for every u (a finite U-digit transducer plus induction), or park W4-3 with the exact record macro? (Dennis: b (fund all five), 2026-10-12)
2026-10-12 · macro_stage
Fund one ~2 h stage to derive W4-3's level-3 counter as an exact macro on the defect labels, or park W4-3 now with its exact defect model? (Dennis: apply recommendations (2026-10-12))
2026-10-11 · rules_stage
Fund one ~2 h stage to derive W4-3's phase rule and an exact defect-level model, or park it with #32/R4 as a multi-level counter? (Dennis: go with recommendations (2026-10-11))
2026-10-12 · sync_stage
Park W4-3 (and siblings 512/588) with its closed U-digit transducer, or fund one more ~2 h sync stage to derive the X/Y synchronization and the U-chain counter lemma? (Dennis 2026-10-12: close out Skelet 1-like Class 2 (fund the next stage instead of parking))

Mechanism

What to check here: the pictures show the mechanism that the rule table describes.

How it works: 6 notes
  • The tape is alternating cells with isolated defects (00 or 11). Sweeps flip every pair. A leftward head turns at a 00 in D-phase (E reads 0) or at an 11 in E-phase (C reads 1). A rightward head turns only at a 00 in B-phase (C reads 0), so the phase decides pass or turn.
  • Level 1: the head bounces between the right edge and a wall W that moves 1 cell per hit (E-turn 00 at x -> 11 at x-1, C-turn 11 at x -> 00 at x-1; 554/555 single-turn trips to 3e6). W eats the active block X while the right block Y grows by about 1.7 cells per trip.
  • Deeper trips stop at the defects between fossil blocks, which cycle through 2 or 3 positions (e.g. 180 -> 179 -> 178 -> 180), and at the left end. This is a mixed-radix counter, and each overflow ends a phase. There are 3 phases per epoch: X grows, then Y grows, then W eats X and Y freezes into a fossil.
  • Epoch laws, exact on every epoch from blank to 2e10 steps: fossils F = 2736 -> 8280 -> 24912 -> 74808 cells (F' = 3F + 72); mid blocks X = 248 -> 752 -> 2264 -> 6800 (X' = 3X + 8). There are 3 left records per epoch (3 cells each), and each epoch takes 9.04x longer than the one before.
  • Fossil lengths are inert mod 4. Inserting 4j cells into any block (fossils or X) leaves the run unchanged except for those lengths (4/4 starts, to 3.5e9 steps, the new blocks are identical). Inserting 2 mod 4 cells changes the run (3/3; one ran off a 2^25-cell tape).
  • Halting needs C> 111 or A> 11, i.e. two adjacent defects in the wrong phase. The run has no halt to 2e10 steps, and neither sibling halts to 2e9.

Figures for Checkpoint A

Fig 1 · bbchallenge default view, 10,000 steps

The site's view. Fine pair stripes fill a slowly widening bell; the left edge barely moves.

bbchallenge default view, 10,000 steps
bbchallenge-defaultStart blankRows every step: steps 0..9,999 squeezed into 500 px rows as on bbchallenge.orgWindow cells -200..199, 1 px = 1 cellColors 1 0 or never visited head after a right/left move
Rows: 1 px row = 20 steps · Colors: red/green: pale = blended by the squeeze
Fig 2 · Wall trips at step 2.7 millionQ1

Rows every 100 steps. Black wedges are left sweeps; their left tips are turns. Compare short and long tips.

Wall trips at step 2.7 million
bbchallenge-defaultStart mid-run: step 2,700,000Rows every 100 stepsWindow cells -34..3178, 1 px = 2 cellsColors 1 0 head after a right/left move
Start: tape from the blank run · Rows: steps 2,700,000..3,000,000 (3,001 rows) · Window: every 2nd cell sampled; the fossil 970-cell block is at cells 180..1149, the wall near 1270 · Colors: black: a swept region shows its flipped phase
Fig 3 · Block phases at right recordsQ2

One row per new rightmost cell; sampling every 8th cell turns each alternating block into one flat colour.

Block phases at right records
bbchallenge-defaultStart blankRows right records onlyWindow cells -40..4999, 1 px = 8 cellsColors 1 0 or never visited head
Rows: one row per new rightmost cell (5,000 rows, steps 0..7,612,581) · Window: every 8th cell sampled, so an alternating block shows its phase as one colour · Colors: black: sampled cells
More figures (1)Fig 4: Records view, 1 px = 1 cell
Fig 4 · Records view, 1 px = 1 cell

Fig 3's span at full resolution: the right edge grows like sqrt(t), the left edge in rare jumps.

Records view, 1 px = 1 cell
bbchallenge-defaultStart blankRows left and right recordsWindow cells -40..4959, 1 px = 1 cellColors 1 0 or never visited head after a right/left move
Rows: 5,000 rows, steps 0..7,546,801
Rules (6/7 validated)1 failing · exact tape rewrites the proof will formalize, each re-checked by simulation
rulefrom ⟶ tocasesstepschecked
S1 B-sweep
B> (01)2n
⟶ (10)2n B>
odd count: B> 01^(2n+1) -> 10^(2n+1) A> in 4n+2 steps (60/60 too)4n✓60/60
S2 C-sweep
C> (10)2n
⟶ (01)2n C>
—4n✓60/60
S3/S4 D-sweeps left
(01)2n <D | (10)2n <D
⟶ <D (10)2n | <D (01)2n
60/60 each4n✓120/120
P1 A passes a pair
A> 10
⟶ 10 B>
A> 11 halts (2 steps); C> 111 halts (3 steps)4✓62/62
W defect turn (single-turn trips)
E-turn: 00 at x | C-turn: 11 at x
⟶ 11 at x-1 | 00 at x-1; some passed 00-defects reset +2 cells
every single-turn trip from step 2e4 to 3e6; the 1 miss (step 446,473) is at an epoch change; which passed defects reset is not yet derived—✗554/555
Fossils inert mod 4
run from step 597,279,037 with 4j cells inserted in blocks
⟶ same run; only those block lengths change
4 random insertions (all blocks / first fossil / X only), compared at the next 2 left records; inserting 2 mod 4 cells changes the run (3/3 negative controls)+0.2..4.1 M steps over 2.4e9✓4/4
Epoch laws
fossil F_k, mid block X_k
⟶ F_(k+1) = 3 F_k + 72, X_(k+1) = 3 X_k + 8
F: 2736 -> 8280 -> 24912 -> 74808 (to 1e10); X: 248 -> 752 -> 2264 -> 6800; observed, not derivedepoch time x9.04✓6/6
Compressed historythe tape as 0∞ J F_1 .. F_k X Y C> 0∞ (rows: the 3rd left record of each 9-cell group) at 17 moments: where the rules are read off
0∞ J F_1 .. F_k X Y C> 0∞ (rows: the 3rd left record of each 9-cell group)
steplohi
29,330-22346
91,395-25586
442,986-281,152
647,767-311,394
1,212,916-342,123
4,664,921-373,819
6,952,350-404,608
12,289,411-436,792
43,669,198-4611,918
65,532,919-4914,320
114,511,040-5220,881
398,088,769-5536,257
597,235,426-5843,526
1,041,302,739-6163,206
3,599,625,458-64109,372
5,399,920,255-67131,214
9,400,201,940-70190,263
lolast -70
-22-7029,3309.4e9log xstep 29330: lo = 22step 91395: lo = 25step 442986: lo = 28step 647767: lo = 31step 1212916: lo = 34step 4664921: lo = 37step 6952350: lo = 40step 12289411: lo = 43step 43669198: lo = 46step 65532919: lo = 49step 114511040: lo = 52step 398088769: lo = 55step 597235426: lo = 58step 1041302739: lo = 61step 3599625458: lo = 64step 5399920255: lo = 67step 9400201940: lo = 70
hilast 190,263
1.9e534629,3309.4e9log xstep 29330: hi = 346step 91395: hi = 586step 442986: hi = 1152step 647767: hi = 1394step 1212916: hi = 2123step 4664921: hi = 3819step 6952350: hi = 4608step 12289411: hi = 6792step 43669198: hi = 11918step 65532919: hi = 14320step 114511040: hi = 20881step 398088769: hi = 36257step 597235426: hi = 43526step 1041302739: hi = 63206step 3599625458: hi = 109372step 5399920255: hi = 131214step 9400201940: hi = 190263
Template comparisontemplate: partly applies · the nearest solved proof, what carries over, and the transitions that differ
01
A1RB0RF
B1RC0RB
C1LD0RA
D1LE0LD
E1RB0LC
F1LA---
file
—
module
—
machine
1RB0LE_1RC0RC_1LD0RB_1LA0LE_1LD1LF_1LD--- (8 transitions apart)
diff
different table (4-5 transitions from #11/#33 under the best renaming); no shared rules
note
Nearest proved neighbour: our kill #11 (Sk1C2, SBCv6 TM21 architecture). Its .v has one counter level: shift lemmas S1-S6, window lemmas T1-T14, digit lemmas Lb/Lf/Rb/Ro, the rules M_spec / Mdrop_spec / O_spec, and an abstract INV over one digit list. W4-3 matches only the bottom layer (sweep and turn lemmas). Its counter has unboundedly many levels: fossil defects with 2-3 states, the 3-phase epoch and the left-end counter, and #11 has no analogue of these. The closest open cases are #32/R4 (multi-level counter, parked).
Proof strategy & riskshow the formal proof will go · 3 risks to watch

Build an exact abstract model at the defect level: turn/pass/reset rules by phase, the wall trip, and fossils kept only mod 4. Check that it reproduces every trip to 1e9, then look for a recursive invariant over the fossil list (epoch = 3 counter overflows). Siblings 512/588 would then need only a new init.

  • ▲The phase rule is not derived yet: which defects turn, pass or reset depends on the head's phase. The left-end region (a small counter that grows 3 cells per phase) is not ruled.
  • ▲A proof needs a recursive multi-level invariant with no template (the same shape as #32/R4, parked). Expect several stages.
  • ▲Residues mod 4 matter: a block of the wrong residue changes the run (one perturbed start ran off the tape), so the invariant must pin every fossil residue.
Stats & provenance2·1010 steps simulated · 269,297 cells · the status in full · files
simulated
2·1010 steps
tape
269,297 cells · 134,642 nonzeros
growth
span ~ t^0.5 (x3 per epoch, epoch time x9.04); left edge -9 cells per epoch (3 left records of 3 cells); lo = -70, hi = 269,226 at 2e10
status now
check_kill PASS, independently re-verified (status.json, 2026-10-13)
observer's note
Mechanism partly ruled (sweeps, turns, wall trip, epoch laws, mod-4 inertness); level-2 phase rule, left end and invariant open: confidence low.
files
observe.json · notes.md · proof.md · how_proved.md · status.json · 1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v

Proof & checks

6/6 automatic checks pass

Kill 20 · Skelet 1-like Class 2 · the kill file 1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v: 2584 lines, 447 items · the package submission/

✓ 6/6 automatic checks pass · Checkpoint B: no note from Dennis yet · template (adapted from): verify/SBCv6.v Module TM21 · 1% of our lines identical
1What is provedCheck: the string, the theorem and every check_kill line are green, and the .v on disk is the one that was checked (same sha256).
Machine
1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---
vs holdout list
✓ byte-exact: the .v literal (L31) == 2026-10-07_778.txt line 363 (41 bytes, via tools/holdouts.py)
Theorem
✓ Lemma nonhalt : ~ halts tm c0. L2542
check_kill
✓ PASS · 17/17 checks pass · compile 74.14 s · coqchk pass (1743.06 s) · assumptions: 0 (closed) · 2026-10-14 21:57:32 UTC · check_kill.txt · 2 runs on file
Checked .v
sha256 13db03a7aa9a83a3…
✓1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v13db03a7aa9a83a3… = checked
✓submission/1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v13db03a7aa9a83a3… = checked
Status
✓Killed: never halts updated 2026-10-13
✓ args✓ input✓ framework✓ framework_build✓ forbidden✓ structure✓ tm_text✓ theorem_text✓ coq✓ names✓ compile✓ tm_rocq✓ theorem_rocq✓ isolation✓ assumptions✓ coqchk✓ integrity
All 17 check_kill checks with their one-line results
✓args6x2 machine, framework module Individual62, mode nonhalt
✓input141728 bytes, 2584 lines, 2440 sentences
✓frameworkHEAD 0940bb9cf434ba68f0c025dabfde45a219999973 == pin; no tracked changes under verify/
✓framework_build13 needed framework .vo files present and fresh, with native code no older than the .vo
✓forbiddennone of 30 forbidden patterns occur (ground rule 1's words: anywhere; command words: outside comments and strings; comments never split a token)
✓structure8 Require name(s) allowed; no top-level Variable/Context; no shadowing; Module/Section balanced
✓tm_textline 31: TM_from_str "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---" == <tm> (41 bytes)
✓theorem_textline 2542: nonhalt : ~halts tm c0
✓coqcoqc 8.20.1 ([local working file]
✓nameshalts, c0, TM_from_str resolved inside Individual62
✓compilecompiled in 74.1s with all appended checks
✓tm_rocqBB6Kill.Candidate.tm = BusyCoq.Individual62.TM_from_str "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---" by eq_refl (in-file and isolated)
✓theorem_rocqnonhalt : ~ halts (TM_from_str "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---") c0 with absolute names (in-file and isolated)
✓isolationonly stock proof plugins loaded; guard/positivity/universe checking on, definitional UIP off
✓assumptions0 assumption(s), all in the baseline
✓coqchkcoqchk -norec BB6Kill.Candidate ok (1743.1s); its context summary lists nothing of the file's own
✓integrityinput sha256 and framework HEAD/cleanliness identical before and after
2Where it came fromCheck: the template is the one you expect, and the measured reuse (tiles, the reuse figure, diff) agrees with what the README says was kept and changed (quoted).
1%of our lines identical to the template
1changed lines
2196added lines (ours only)
288template lines dropped
1 / 1 / 445items identical / adapted / new
What the package README says it reused and changed (submission/README.md line 20, Template and what changed), quoted:

The outer shape is verify/SBCv6.v, Module TM21: configurations over a digit-block list, one invariant, a closure lemma, multistep_nonhalt + progress_nonhalt_cond. The computed, proved-correct step is the idea of verify/Sk1like_TC_v1.v.

  • Changed: TM21's hand-composed window lemmas are replaced by the verified simulator. The digit list is a chain of eight-state blocks with an exit phase. The right region needs an executor with 4-cycle jumps, and one macro step is a whole record interval (81 x 3^K visits) with six invariant classes and u -> 9u per period.

The file is 2,584 lines. The accompanying write-up is the informal proof; its first table maps each section to lemma names.

Fig P1 · Reuse of the template, line by line and by name

Top two bars: non-blank lines after the TM string is replaced by <TM> and whitespace is collapsed. Bottom bar: our Definitions/Lemmas/… by name.

ours 2228 lines
1% identical · 1 changed · 2196 added
template 320 lines
10% kept verbatim · 288 not in ours
our items 447
1 identical · 1 adapted · 445 new · 26 template-only
identicalchanged / adaptedours only (new)template only
Template part: lines 1–53 (shared header, before the first Module) + 3703–4008 (body of Module TM21; the Module/End lines left out). Ours: lines 26–2584 (header comment 1–25 left out). Line diff: Python difflib SequenceMatcher; inside a replaced block, line pairs at least 75% alike count as changed, the rest as removed + added.

Template-only names: segRLs_trans_add, sideRLs_trans_add, sideRLs_trans_S, tm', C0, C1, LH, toLH, LC1, LC0, Ov, Ov_spec, RC, RIncs, Ov', LIncs, LIncs_spec, S', BigStep, init, length_LIncs, LIncs_k, length_Ov, LWF, aWF, LWF_spec

Side-by-side diff: template (320 lines) vs ours (2228 lines), 2485 lines differ; runs of identical lines and long template-only runs folded
identicalequal once each TM string is <TM>changedours onlytemplate only
templateours
1From BusyCoq Require Import Individual62.27From BusyCoq Require Import Individual62.
2Require Import ZifyNat Lia.
28Require Import Lia ZifyNat String List Arith NArith ZArith.
3Require Import ZArith.
29Import ListNotations.
4Require Import String.
5Require Import List.
⋯ 38 template-only lines (template 6–49), not in ours
50 [ eassumption | ];
51 try esx ].
3704Definition tm := Eval compute in (TM_from_str "1RB1LB_0LC1RD_0RA1LC_0RB1RE_0RD0LF_---1LE").31Definition tm := Eval compute in (TM_from_str "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---").
33Notation "c --> c'" := (c -[ tm ]-> c') (at level 40).
3706Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40).34Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40).
3707Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).35Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).
3709Definition tm' := flip tm.
37Open Scope nat_scope.
3711Notation "l <| r" := (l <{{C}} [] *> r) (at level 30).
39(* ===================================================================== *)
3712Notation "l |> r" := (l <* [] {{E}}> r) (at level 30).
40(* A symbolic run-length simulator. *)
3714Notation hL := (C,[]).
41(* The tape is cut into alternating runs. A run is a first symbol and a *)
3715Notation hR := (E,[]).
42(* length; a length is a linear form c + sum v_i x_i over N. A side is *)
3716Notation hLR2 := [(hL,hR)].
43(* a list of runs (nearest the head first) followed by either the blank *)
3717Notation hRL2 := [(hR,hL)].
44(* stream or an abstract side. The simulator crosses a whole run in one *)
3719Definition C0 n m := <[0;1]^^(n) <+ <[0;0;1] <+ <[0;1]^^m <+ <[1].
45(* step when the head state is in one of the two sweep cycles. *)
3720Definition C1 n m := <[0;1]^^(n) <+ <[0;1;1] <+ <[0;1]^^m <+ <[1].
46(* ===================================================================== *)
3722Inductive LH := LH1|LH2|LH3.
48Definition sneg (s : Sym) : Sym := match s with S0 => S1 | S1 => S0 end.
3724Definition toLH x :=
49Definition seqb (a b : Sym) : bool :=
3725match x with
50 match a, b with S0, S0 | S1, S1 => true | _, _ => false end.
3726| LH1 => 0inf
52Record lf := LF { lc : N; lv : list N }.
3727| LH2 => 0inf <* <[1;1;0;1;0;1;1]
54Fixpoint dot (vs nu : list N) : N :=
3728| LH3 => 0inf <* <[1;1;1]
55 match vs, nu with
56 | v :: vs', x :: nu' => (v * x + dot vs' nu')%N
57 | _, _ => 0%N
3729end.58 end.
3731Notation LS := (list (nat*nat)).
60Definition ev (nu : list N) (a : lf) : nat := N.to_nat (lc a + dot (lv a) nu).
3733Fixpoint LC1(x:LS)(y:LH):side :=
62Fixpoint zadd (a b : list N) : list N :=
3734match x with63 match a, b with
3735| [] => toLH y
64 | x :: a', y :: b' => (x + y)%N :: zadd a' b'
3736| (n,m)::t => LC1 t y <* C1 n m
65 | [], _ => b
66 | _, [] => a
3737end.67 end.
3739Fixpoint LC0(x:LS)(y:LH):side :=
69Definition lf_add (a b : lf) : lf := LF (lc a + lc b) (zadd (lv a) (lv b)).
3740match x with
70Definition lf_S (a : lf) : lf := LF (N.succ (lc a)) (lv a).
3741| [] => toLH y
71Definition lf_one : lf := LF 1 [].
3742| (n,m)::t => LC0 t y <* C0 n m
72Definition allz (vs : list N) : bool := forallb (fun v => N.eqb v 0) vs.
73Definition all4 (vs : list N) : bool := forallb (fun v => N.eqb (N.modulo v 4) 0) vs.
74Definition is_zero (a : lf) : bool := andb (N.eqb (lc a) 0) (allz (lv a)).
75Definition is_one (a : lf) : bool := andb (N.eqb (lc a) 1) (allz (lv a)).
76Definition posb (a : lf) : bool := negb (N.eqb (lc a) 0).
78Inductive tl_ := T0 | TV (k : nat).
79Definition run : Type := (Sym * lf)%type.
80Definition sd : Type := (list run * tl_)%type.
82Fixpoint alt (b : Sym) (n : nat) : list Sym :=
83 match n with O => [] | S n' => b :: alt (sneg b) n' end.
85Definition ev_tl (sg : nat -> side) (t : tl_) : side :=
86 match t with T0 => const S0 | TV k => sg k end.
88Fixpoint ev_runs (nu : list N) (rs : list run) (s : side) : side :=
89 match rs with
90 | [] => s
91 | (b, n) :: rs' => alt b (ev nu n) *> ev_runs nu rs' s
3743end.92 end.
3745Inductive Ov: LS->LH->nat->LS->LH->Prop :=
94Definition ev_sd nu sg (s : sd) : side := ev_runs nu (fst s) (ev_tl sg (snd s)).
3746| Ov_1 m a:
96Fixpoint pop_runs (rs : list run) (t : tl_) : option (Sym * sd) :=
3747 m<>O ->
97 match rs with
3748 Ov [(2,m)] LH1 a [(m,a)] LH2
98 | (b, n) :: rs' =>
3749| Ov_2 a:
99 if is_zero n then pop_runs rs' t
3750 Ov [] LH2 a [(2,a)] LH3
100 else if posb n then
3751| Ov_3 a:
101 Some (b, ((if is_one n then rs' else (sneg b, LF (N.pred (lc n)) (lv n)) :: rs'), t))
3752 Ov [] LH3 a [(2,a)] LH1
102 else None
3753| Ov_S x y n m a x' y':
103 | [] => match t with T0 => Some (S0, ([], T0)) | TV _ => None end
3754 Ov x y n x' y' ->
104 end.
3755 m<>O ->
106Definition pop (s : sd) : option (Sym * sd) := pop_runs (fst s) (snd s).
3756 Ov (x<:(n,m)) y a (x'<:(m,a)) y'
108Definition push (w : Sym) (s : sd) : sd :=
3757.
109 match s with
3759Lemma Ov_spec x y a x' y':
110 | ((b0, n0) :: rs, t) =>
3760 Ov x y a x' y' ->
111 if seqb w b0 then ((w, lf_one) :: (b0, n0) :: rs, t)
3761 forall r,
112 else ((w, lf_S n0) :: rs, t)
3762 LC1 x y <| [0;1]^^(1+a) *> [1] *> r -->+
113 | ([], t) => ([(w, lf_one)], t)
3763 LC0 x' y' |> r.
114 end.
116(* the symbol that would continue the alternation after a run (c, n) *)
117Definition afterb (c : Sym) (n : lf) : Sym := if N.eqb (N.modulo (lc n) 2) 0 then c else sneg c.
119Definition push_run (c : Sym) (n : lf) (s : sd) : sd :=
120 match s with
121 | ((b0, n0) :: rs, t) =>
122 if seqb (afterb c n) b0 then ((c, lf_add n n0) :: rs, t)
123 else ((c, n) :: (b0, n0) :: rs, t)
124 | ([], t) => ([(c, n)], t)
125 end.
127(* the two sweep cycles *)
128Definition cR_st (i : nat) : Q :=
129 match i mod 4 with 0 => B | 1 => C | 2 => A | _ => B end.
130Definition cR_bt (i : nat) : Sym :=
131 match i mod 4 with 0 => S0 | 1 => S1 | 2 => S0 | _ => S1 end.
132Definition cR_idx (q : Q) (b : Sym) : option nat :=
133 match q, b with
134 | B, S0 => Some 0 | C, S1 => Some 1 | A, S0 => Some 2 | B, S1 => Some 3
135 | _, _ => None
136 end.
137Definition cL_st (i : nat) : Q :=
138 match i mod 4 with 0 => D | 1 => D | 2 => E | _ => C end.
139Definition cL_bt (i : nat) : Sym :=
140 match i mod 4 with 0 => S1 | 1 => S0 | 2 => S1 | _ => S0 end.
141Definition cL_idx (q : Q) (b : Sym) : option nat :=
142 match q, b with
143 | D, S1 => Some 0 | D, S0 => Some 1 | E, S1 => Some 2 | C, S0 => Some 3
144 | _, _ => None
145 end.
147(* the last symbol of a run (c, n) *)
148Definition lastb (c : Sym) (n : lf) : Sym := if N.eqb (N.modulo (lc n) 2) 0 then sneg c else c.
150Inductive cfg := Rc (q : Q) (l r : sd) | Lc (q : Q) (l r : sd).
152Definition ev_cfg nu sg (c : cfg) : Q * tape :=
153 match c with
154 | Rc q l r => (ev_sd nu sg l) {{q}}> (ev_sd nu sg r)
155 | Lc q l r => (ev_sd nu sg l) <{{q}} (ev_sd nu sg r)
156 end.
158Definition single (c : cfg) : option cfg :=
159 match c with
160 | Rc q l r =>
161 match pop r with
162 | Some (s, r') =>
163 match tm (q, s) with
164 | Some (w, R, q') => Some (Rc q' (push w l) r')
165 | Some (w, L, q') => Some (Lc q' l (push w r'))
166 | None => None
167 end
168 | None => None
169 end
170 | Lc q l r =>
171 match pop l with
172 | Some (s, l') =>
173 match tm (q, s) with
174 | Some (w, R, q') => Some (Rc q' (push w l') r)
175 | Some (w, L, q') => Some (Lc q' l' (push w r))
176 | None => None
177 end
178 | None => None
179 end
180 end.
182Definition tag (o : option cfg) : option (cfg * bool) :=
183 match o with Some c => Some (c, true) | None => None end.
185Definition sstep (c : cfg) : option (cfg * bool) :=
186 match c with
187 | Rc q l ((b, n) :: rs, t) =>
188 if is_zero n then Some (Rc q l (rs, t), false) else
189 match cR_idx q b with
190 | Some i =>
191 if all4 (lv n) then
192 Some (Rc (cR_st (i + N.to_nat (N.modulo (lc n) 4))) (push_run (sneg (lastb b n)) n l) (rs, t), posb n)
193 else tag (single c)
194 | None => tag (single c)
195 end
196 | Lc q ((b, n) :: ls, t) r =>
197 if is_zero n then Some (Lc q (ls, t) r, false) else
198 match cL_idx q b with
199 | Some i =>
200 if all4 (lv n) then
201 Some (Lc (cL_st (i + N.to_nat (N.modulo (lc n) 4))) (ls, t) (push_run (sneg (lastb b n)) n r), posb n)
202 else tag (single c)
203 | None => tag (single c)
204 end
205 | _ => tag (single c)
206 end.
208(* run exactly p steps; the flag says whether at least one TM step was made *)
209Fixpoint runp (p : positive) (c : cfg) : option (cfg * bool) :=
210 match p with
211 | xH => sstep c
212 | xO p' =>
213 match runp p' c with
214 | Some (c1, b1) => match runp p' c1 with Some (c2, b2) => Some (c2, orb b1 b2) | None => None end
215 | None => None
216 end
217 | xI p' =>
218 match sstep c with
219 | Some (c0, b0) =>
220 match runp p' c0 with
221 | Some (c1, b1) => match runp p' c1 with Some (c2, b2) => Some (c2, orb b0 (orb b1 b2)) | None => None end
222 | None => None
223 end
224 | None => None
225 end
226 end.
228(* ===================================================================== *)
229(* Soundness *)
230(* ===================================================================== *)
232Lemma sneg_neq a b : seqb a b = false -> b = sneg a.
233Proof. destruct a, b; cbn; congruence. Qed.
235Lemma seqb_eq a b : seqb a b = true -> a = b.
236Proof. destruct a, b; cbn; congruence. Qed.
238Lemma sneg_sneg a : sneg (sneg a) = a.
239Proof. destruct a; reflexivity. Qed.
241Lemma dot_zadd a b nu : dot (zadd a b) nu = (dot a nu + dot b nu)%N.
3764Proof.242Proof.
3765 intro H.
243 revert b nu. induction a as [|x a IH]; intros [|y b] [|z nu]; cbn; try lia.
3766 induction H; intros.
244 rewrite IH, N.mul_add_distr_r. lia.
3767 - destruct m. 1: lia.
3768 es.
⋯ 6 template-only lines (template 3769–3774), not in ours
3775 follow100 IHOv.
3776 es.
3777Qed.245Qed.
3779Definition RC n m := [0;1]^^(1+n) *> [1] *> [0;1]^^m *> 0inf.
247Lemma ev_add nu a b : ev nu (lf_add a b) = ev nu a + ev nu b.
3781Lemma RIncs k n m:
248Proof. unfold ev, lf_add; cbn. rewrite dot_zadd. lia. Qed.
3782 sideRLs tm (hRL2^^k) (RC n m) (RC (k+n) (k+m)).
250Lemma ev_S nu a : ev nu (lf_S a) = S (ev nu a).
251Proof. unfold ev, lf_S; cbn. lia. Qed.
253Lemma allz_dot vs nu : allz vs = true -> dot vs nu = 0%N.
3783Proof.254Proof.
3784 unfold RC.
255 unfold allz in *. revert nu. induction vs as [|v vs IH]; intros [|x nu] H; cbn [dot forallb] in *; try reflexivity.
3785 sideRLs_ind k.
256 apply andb_prop in H as [H1 H2]. apply N.eqb_eq in H1. subst. rewrite IH by exact H2. lia.
3786Qed.257Qed.
3788Lemma Ov' x y a x' y' b:
259Lemma all4_dot vs nu : all4 vs = true -> exists k, dot vs nu = (4 * k)%N.
3789 Ov x y a x' y' ->
3790 LC1 x y <| RC a b -->+
3791 LC0 x' y' <| RC b 1.
3792Proof.260Proof.
3793 unfold RC.
261 unfold all4 in *. revert nu. induction vs as [|v vs IH]; intros [|x nu] H; cbn [dot forallb] in *; try (exists 0%N; lia).
3794 intro H.
262 apply andb_prop in H as [H1 H2]. apply N.eqb_eq in H1.
3795 eapply Ov_spec in H.
263 destruct (IH nu H2) as [k Hk].
3796 follow10 H.
264 apply N.Div0.mod_divides in H1 as [j Hj].
3797 es.
265 exists (j * x + k)%N. rewrite Hk, Hj. lia.
3798Qed.266Qed.
3800Inductive LIncs: LS->LS->nat->Prop :=
268Lemma ev_zero nu a : is_zero a = true -> ev nu a = 0.
3801| LIncs_O:
269Proof.
3802 LIncs [] [] 0
270 unfold is_zero, ev. intros H. apply andb_prop in H as [H1 H2].
3803| LIncs_S x y k n m:
271 apply N.eqb_eq in H1. rewrite H1, (allz_dot _ _ H2). reflexivity.
3804 LIncs x y k ->
272Qed.
3805 LIncs (x<:(n,k+m)) (y<:(k+n,m)) (k*2+1)
274Lemma ev_one nu a : is_one a = true -> ev nu a = 1.
3806.
275Proof.
3808Lemma LIncs_spec x y k z:
276 unfold is_one, ev. intros H. apply andb_prop in H as [H1 H2].
3809 LIncs x y k ->
277 apply N.eqb_eq in H1. rewrite H1, (allz_dot _ _ H2). reflexivity.
3810 sideRLs tm' (hLR2^^k) (LC0 x z) (LC1 y z).
278Qed.
280Lemma ev_pos nu a : posb a = true -> ev nu a = S (ev nu (LF (N.pred (lc a)) (lv a))).
281Proof.
282 unfold posb, ev. cbn. intros H. apply Bool.negb_true_iff, N.eqb_neq in H. lia.
283Qed.
285Lemma ev_mod4 nu a : all4 (lv a) = true -> exists k, ev nu a = N.to_nat (lc a) + 4 * k.
286Proof.
287 intros H. destruct (all4_dot _ nu H) as [k Hk]. unfold ev. rewrite Hk.
288 exists (N.to_nat k). lia.
289Qed.
291Lemma ev_runs_app nu rs1 rs2 s : ev_runs nu (rs1 ++ rs2) s = ev_runs nu rs1 (ev_runs nu rs2 s).
292Proof. induction rs1 as [|[b n] rs1 IH]; cbn; [reflexivity|]. rewrite IH. reflexivity. Qed.
294Lemma pop_runs_spec nu sg rs t b s' :
295 pop_runs rs t = Some (b, s') -> ev_runs nu rs (ev_tl sg t) = b >> ev_sd nu sg s'.
296Proof.
297 revert b s'. induction rs as [|[b0 n] rs IH]; intros b s' H; cbn in H.
298 - destruct t; [|discriminate]. inversion H; subst. cbn. apply const_unfold.
299 - destruct (is_zero n) eqn:Ez.
300 + cbn. rewrite (ev_zero nu n Ez). cbn. apply IH, H.
301 + destruct (posb n) eqn:Ep; [|discriminate].
302 inversion H; subst; clear H. cbn.
303 destruct (is_one n) eqn:Eo.
304 * rewrite (ev_one nu n Eo). reflexivity.
305 * rewrite (ev_pos nu n Ep). reflexivity.
306Qed.
308Lemma pop_spec nu sg s b s' : pop s = Some (b, s') -> ev_sd nu sg s = b >> ev_sd nu sg s'.
309Proof. destruct s as [rs t]. apply pop_runs_spec. Qed.
311Lemma push_spec nu sg w s : ev_sd nu sg (push w s) = w >> ev_sd nu sg s.
312Proof.
313 destruct s as [[|[b0 n0] rs] t]; cbn; [reflexivity|].
314 destruct (seqb w b0) eqn:E; cbn; [reflexivity|].
315 rewrite ev_S. cbn. rewrite <-(sneg_neq _ _ E). reflexivity.
316Qed.
318Definition afterb_nat (c : Sym) (n : nat) : Sym := if Nat.eqb (n mod 2) 0 then c else sneg c.
320Lemma afterb_nat_S c m : afterb_nat c (S m) = afterb_nat (sneg c) m.
321Proof.
322 unfold afterb_nat.
323 destruct (Nat.eqb_spec (S m mod 2) 0), (Nat.eqb_spec (m mod 2) 0); try lia;
324 [symmetry; apply sneg_sneg | reflexivity].
325Qed.
327Lemma alt_add c m k : alt c (m + k) = alt c m ++ alt (afterb_nat c m) k.
328Proof.
329 revert c. induction m as [|m IH]; intros c; [reflexivity|].
330 change (S m + k) with (S (m + k)). cbn [alt app].
331 rewrite IH, afterb_nat_S. reflexivity.
332Qed.
334Lemma afterb_ev nu c n : all4 (lv n) = true -> afterb c n = afterb_nat c (ev nu n).
335Proof.
336 intros H. destruct (ev_mod4 nu n H) as [k Hk]. rewrite Hk. unfold afterb, afterb_nat.
337 destruct (N.eqb_spec (lc n mod 2) 0), (Nat.eqb_spec ((N.to_nat (lc n) + 4 * k) mod 2) 0);
338 try reflexivity; exfalso; lia.
339Qed.
341Lemma push_run_spec nu sg c n s :
342 all4 (lv n) = true -> ev_sd nu sg (push_run c n s) = alt c (ev nu n) *> ev_sd nu sg s.
343Proof.
344 intros H4. destruct s as [[|[b0 n0] rs] t]; cbn; [reflexivity|].
345 destruct (seqb (afterb c n) b0) eqn:E; cbn.
346 - rewrite ev_add, alt_add, Str_app_assoc. apply seqb_eq in E.
347 rewrite <-(afterb_ev nu c n H4), E. reflexivity.
348 - reflexivity.
349Qed.
351Definition lastb_nat (c : Sym) (m : nat) : Sym := if Nat.eqb (m mod 2) 0 then sneg c else c.
353Lemma lastb_ev nu c n : all4 (lv n) = true -> lastb c n = lastb_nat c (ev nu n).
354Proof.
355 intros H. destruct (ev_mod4 nu n H) as [k Hk]. rewrite Hk. unfold lastb, lastb_nat.
356 destruct (N.eqb_spec (lc n mod 2) 0), (Nat.eqb_spec ((N.to_nat (lc n) + 4 * k) mod 2) 0);
357 try reflexivity; exfalso; lia.
358Qed.
360Lemma rev_alt b m (l : side) :
361 alt (sneg (lastb_nat b (S m))) (S m) *> l = alt (sneg (lastb_nat (sneg b) m)) m *> (sneg b >> l).
362Proof.
363 rewrite <-Nat.add_1_r, alt_add, Str_app_assoc. cbn [alt Str_app].
364 unfold lastb_nat, afterb_nat.
365 destruct (Nat.eqb_spec ((m + 1) mod 2) 0), (Nat.eqb_spec (m mod 2) 0); try lia;
366 destruct b; reflexivity.
367Qed.
369Lemma cR_cases i : (i mod 4 = 0 /\ S i mod 4 = 1) \/ (i mod 4 = 1 /\ S i mod 4 = 2) \/
370 (i mod 4 = 2 /\ S i mod 4 = 3) \/ (i mod 4 = 3 /\ S i mod 4 = 0).
371Proof. lia. Qed.
373Lemma cR_tm i : tm (cR_st i, cR_bt i) = Some (sneg (cR_bt i), R, cR_st (S i)).
374Proof.
375 unfold cR_st, cR_bt. destruct (cR_cases i) as [[H1 H2]|[[H1 H2]|[[H1 H2]|[H1 H2]]]];
376 rewrite H1, H2; reflexivity.
377Qed.
379Lemma cR_bt_S i : cR_bt (S i) = sneg (cR_bt i).
380Proof.
381 unfold cR_bt. destruct (cR_cases i) as [[H1 H2]|[[H1 H2]|[[H1 H2]|[H1 H2]]]];
382 rewrite H1, H2; reflexivity.
383Qed.
385Lemma cL_tm i : tm (cL_st i, cL_bt i) = Some (sneg (cL_bt i), L, cL_st (S i)).
386Proof.
387 unfold cL_st, cL_bt. destruct (cR_cases i) as [[H1 H2]|[[H1 H2]|[[H1 H2]|[H1 H2]]]];
388 rewrite H1, H2; reflexivity.
389Qed.
391Lemma cL_bt_S i : cL_bt (S i) = sneg (cL_bt i).
392Proof.
393 unfold cL_bt. destruct (cR_cases i) as [[H1 H2]|[[H1 H2]|[[H1 H2]|[H1 H2]]]];
394 rewrite H1, H2; reflexivity.
395Qed.
397Lemma accR_step i l X :
398 (l {{cR_st i}}> (cR_bt i >> X)) --> ((sneg (cR_bt i) >> l) {{cR_st (S i)}}> X).
399Proof. exact (step_right (cR_tm i)). Qed.
401Lemma accL_step i r X :
402 ((cL_bt i >> X) <{{cL_st i}} r) --> (X <{{cL_st (S i)}} (sneg (cL_bt i) >> r)).
403Proof. exact (step_left (cL_tm i)). Qed.
405Lemma accR m : forall i l r,
406 (l {{cR_st i}}> (alt (cR_bt i) m *> r)) -->*
407 ((alt (sneg (lastb_nat (cR_bt i) m)) m *> l) {{cR_st (i + m)}}> r).
408Proof.
409 induction m as [|m IH]; intros i l r.
410 - rewrite Nat.add_0_r. apply evstep_refl.
411 - eapply evstep_step; [cbn [alt Str_app]; apply accR_step|].
412 pose proof (IH (S i) (sneg (cR_bt i) >> l) r) as H. rewrite cR_bt_S in H.
413 rewrite rev_alt, Nat.add_succ_r. exact H.
414Qed.
416Lemma accR_S m i l r :
417 (l {{cR_st i}}> (alt (cR_bt i) (S m) *> r)) -->+
418 ((alt (sneg (lastb_nat (cR_bt i) (S m))) (S m) *> l) {{cR_st (i + S m)}}> r).
419Proof.
420 eapply progress_intro; [cbn [alt Str_app]; apply accR_step|].
421 pose proof (accR m (S i) (sneg (cR_bt i) >> l) r) as H. rewrite cR_bt_S in H.
422 rewrite rev_alt, Nat.add_succ_r. exact H.
423Qed.
425Lemma accL m : forall i l r,
426 ((alt (cL_bt i) m *> l) <{{cL_st i}} r) -->*
427 (l <{{cL_st (i + m)}} (alt (sneg (lastb_nat (cL_bt i) m)) m *> r)).
428Proof.
429 induction m as [|m IH]; intros i l r.
430 - rewrite Nat.add_0_r. apply evstep_refl.
431 - eapply evstep_step; [cbn [alt Str_app]; apply accL_step|].
432 pose proof (IH (S i) l (sneg (cL_bt i) >> r)) as H. rewrite cL_bt_S in H.
433 rewrite rev_alt, Nat.add_succ_r. exact H.
434Qed.
436Lemma accL_S m i l r :
437 ((alt (cL_bt i) (S m) *> l) <{{cL_st i}} r) -->+
438 (l <{{cL_st (i + S m)}} (alt (sneg (lastb_nat (cL_bt i) (S m))) (S m) *> r)).
439Proof.
440 eapply progress_intro; [cbn [alt Str_app]; apply accL_step|].
441 pose proof (accL m (S i) l (sneg (cL_bt i) >> r)) as H. rewrite cL_bt_S in H.
442 rewrite rev_alt, Nat.add_succ_r. exact H.
443Qed.
445Lemma single_spec nu sg c c' : single c = Some c' -> ev_cfg nu sg c --> ev_cfg nu sg c'.
446Proof.
447 destruct c as [q l r|q l r]; cbn [single].
448 - destruct (pop r) as [[s r']|] eqn:Ep; [|discriminate].
449 pose proof (pop_spec nu sg r s r' Ep) as Hr.
450 destruct (tm (q, s)) as [[[w [|]] q']|] eqn:Et; intros H; inversion H; subst; clear H;
451 cbn [ev_cfg]; rewrite Hr, ?push_spec.
452 + exact (step_left Et).
453 + exact (step_right Et).
454 - destruct (pop l) as [[s l']|] eqn:Ep; [|discriminate].
455 pose proof (pop_spec nu sg l s l' Ep) as Hl.
456 destruct (tm (q, s)) as [[[w [|]] q']|] eqn:Et; intros H; inversion H; subst; clear H;
457 cbn [ev_cfg]; rewrite Hl, ?push_spec.
458 + exact (step_left Et).
459 + exact (step_right Et).
460Qed.
462Definition Rel (b : bool) (c c' : Q * tape) : Prop := if b then c -->+ c' else c -->* c'.
464Lemma Rel_trans b1 b2 c c' c'' : Rel b1 c c' -> Rel b2 c' c'' -> Rel (orb b1 b2) c c''.
465Proof.
466 destruct b1, b2; cbn; intros H1 H2.
467 - eapply progress_trans; eauto.
468 - eapply progress_evstep_trans; eauto.
469 - eapply evstep_progress_trans; eauto.
470 - eapply evstep_trans; eauto.
471Qed.
473Lemma tag_spec nu sg c o c' b : o = single c -> tag o = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
474Proof.
475 intros -> H. unfold tag in H. destruct (single c) eqn:E; [|discriminate].
476 inversion H; subst. cbn. apply progress_base. apply single_spec, E.
477Qed.
479Lemma cR_idx_spec q b i : cR_idx q b = Some i -> q = cR_st i /\ b = cR_bt i.
480Proof. destruct q, b; cbn; intros H; inversion H; subst; split; reflexivity. Qed.
482Lemma cL_idx_spec q b i : cL_idx q b = Some i -> q = cL_st i /\ b = cL_bt i.
483Proof. destruct q, b; cbn; intros H; inversion H; subst; split; reflexivity. Qed.
485Lemma cR_st_mod i k : cR_st (i + N.to_nat (N.modulo k 4)) = cR_st (i + N.to_nat k).
486Proof.
487 unfold cR_st. rewrite N2Nat.inj_mod by discriminate. change (N.to_nat 4) with 4.
488 rewrite Nat.Div0.add_mod_idemp_r. reflexivity.
489Qed.
491Lemma cL_st_mod i k : cL_st (i + N.to_nat (N.modulo k 4)) = cL_st (i + N.to_nat k).
492Proof.
493 unfold cL_st. rewrite N2Nat.inj_mod by discriminate. change (N.to_nat 4) with 4.
494 rewrite Nat.Div0.add_mod_idemp_r. reflexivity.
495Qed.
497Lemma cR_st_add4 i a k : cR_st (i + (a + 4 * k)) = cR_st (i + a).
498Proof. unfold cR_st. replace ((i + (a + 4 * k)) mod 4) with ((i + a) mod 4) by lia. reflexivity. Qed.
500Lemma cL_st_add4 i a k : cL_st (i + (a + 4 * k)) = cL_st (i + a).
501Proof. unfold cL_st. replace ((i + (a + 4 * k)) mod 4) with ((i + a) mod 4) by lia. reflexivity. Qed.
503Lemma sstep_spec nu sg c c' b : sstep c = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
3811Proof.504Proof.
3812 intros H.505 intros H.
3813 induction H.
506 destruct c as [q l [[|[b0 n] rs] t]|q [[|[b0 n] ls] t] r];
3814 - esx.
507 try (eapply tag_spec; [reflexivity | exact H]).
3815 - cbn[LC0]; cbn[LC1].
508 - cbn [sstep] in H.
3816 eapply segRLs_sideRLs_concat.
509 destruct (is_zero n) eqn:Ez.
3817 2: apply IHLIncs.
510 + inversion H; subst. cbn. unfold ev_sd. cbn [fst snd ev_runs]. rewrite (ev_zero nu n Ez). cbn. apply evstep_refl.
3818 clear.
511 + destruct (cR_idx q b0) as [i|] eqn:Ei; [|eapply tag_spec; [reflexivity|exact H]].
3819 unfold C0,C1.
512 destruct (all4 (lv n)) eqn:E4; [|eapply tag_spec; [reflexivity|exact H]].
3820 gen n m.
513 inversion H; subst; clear H.
3821 induction k; intros.
514 destruct (cR_idx_spec _ _ _ Ei) as [-> ->].
3822 1: esx.
515 cbn [ev_cfg]. rewrite push_run_spec by exact E4. unfold ev_sd at 2. cbn [fst snd ev_runs].
3823 specialize (IHk n (S m)).
516 rewrite (lastb_ev nu _ _ E4), cR_st_mod.
3824 replace (S k*2+1) with ((k*2+1)+2) by lia.
517 destruct (ev_mod4 nu n E4) as [k Hk].
3825 replace (S k) with (k+1) by lia.
518 replace (cR_st (i + N.to_nat (lc n))) with (cR_st (i + ev nu n)) by (rewrite Hk; apply cR_st_add4).
3826 remember (k*2+1) as k2.
519 unfold posb. destruct (N.eqb_spec (lc n) 0) as [Hz|Hz]; cbn.
3827 do 2 rewrite lpow_add.
520 * apply accR.
3828 replace (k+1+m) with (k+S m) by lia.
521 * destruct (ev nu n) as [|m] eqn:Em; [lia|]. apply accR_S.
3829 eapply segRLs_trans.
522 - cbn [sstep] in H.
3830 1: apply IHk.
523 destruct (is_zero n) eqn:Ez.
3831 simpl_tape; cbn.
524 + inversion H; subst. cbn. unfold ev_sd. cbn [fst snd ev_runs]. rewrite (ev_zero nu n Ez). cbn. apply evstep_refl.
3832 esx.
525 + destruct (cL_idx q b0) as [i|] eqn:Ei; [|eapply tag_spec; [reflexivity|exact H]].
526 destruct (all4 (lv n)) eqn:E4; [|eapply tag_spec; [reflexivity|exact H]].
527 inversion H; subst; clear H.
528 destruct (cL_idx_spec _ _ _ Ei) as [-> ->].
529 cbn [ev_cfg]. rewrite push_run_spec by exact E4. unfold ev_sd at 1. cbn [fst snd ev_runs].
530 rewrite (lastb_ev nu _ _ E4), cL_st_mod.
531 destruct (ev_mod4 nu n E4) as [k Hk].
532 replace (cL_st (i + N.to_nat (lc n))) with (cL_st (i + ev nu n)) by (rewrite Hk; apply cL_st_add4).
533 unfold posb. destruct (N.eqb_spec (lc n) 0) as [Hz|Hz]; cbn.
534 * apply accL.
535 * destruct (ev nu n) as [|m] eqn:Em; [lia|]. apply accL_S.
3833Qed.536Qed.
3835Definition S' '(x,y,z) := LC0 x y <| RC z 1.
538Lemma runp_spec nu sg p : forall c c' b, runp p c = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
3837Lemma BigStep x y z x0 x1 y0 k:
3838 LIncs x x0 k ->
3839 Ov x0 y (k+z) x1 y0 ->
3840 S' (x,y,z) -->+
3841 S' (x1,y0,k+1).
3842Proof.539Proof.
3843 unfold S'.
540 induction p as [p IH|p IH|]; intros c c' b H; cbn [runp] in H.
3844 intros I1 I2.
541 - destruct (sstep c) as [[c0 b0]|] eqn:E0; [|discriminate].
3845 eapply LIncs_spec in I1.
542 destruct (runp p c0) as [[c1 b1]|] eqn:E1; [|discriminate].
3846 eapply Ov' in I2.
543 destruct (runp p c1) as [[c2 b2]|] eqn:E2; [|discriminate].
3847 epose proof (sideRLs_concat_1L (RIncs k _ _) I1) as I1'.
544 inversion H; subst.
3848 follow I1'.
545 eapply Rel_trans; [apply (sstep_spec nu sg _ _ _ E0)|].
3849 apply I2.
546 eapply Rel_trans; [apply (IH _ _ _ E1)|apply (IH _ _ _ E2)].
547 - destruct (runp p c) as [[c1 b1]|] eqn:E1; [|discriminate].
548 destruct (runp p c1) as [[c2 b2]|] eqn:E2; [|discriminate].
549 inversion H; subst.
550 eapply Rel_trans; [apply (IH _ _ _ E1)|apply (IH _ _ _ E2)].
551 - apply sstep_spec, H.
3850Qed.552Qed.
3852Lemma init:
554(* ===================================================================== *)
3853 c0 -->*
555(* Running to a target configuration *)
3854 S' (<[(2,2);(1%nat,3);(2,5)],LH1,4).
556(* ===================================================================== *)
558Fixpoint strip0 (vs : list N) : list N :=
559 match vs with
560 | [] => []
561 | v :: vs' => match strip0 vs' with [] => if N.eqb v 0 then [] else [v] | w => v :: w end
562 end.
564Fixpoint listN_eqb (a b : list N) : bool :=
565 match a, b with
566 | [], [] => true
567 | x :: a', y :: b' => andb (N.eqb x y) (listN_eqb a' b')
568 | _, _ => false
569 end.
571Definition lf_eqb (a b : lf) : bool := andb (N.eqb (lc a) (lc b)) (listN_eqb (strip0 (lv a)) (strip0 (lv b))).
573Definition runs_eqb (a b : list run) : bool :=
574 (fix f (a b : list run) := match a, b with
575 | [], [] => true
576 | (x, n) :: a', (y, m) :: b' => andb (andb (seqb x y) (lf_eqb n m)) (f a' b')
577 | _, _ => false end) a b.
579Definition tl_eqb (a b : tl_) : bool :=
580 match a, b with T0, T0 => true | TV i, TV j => Nat.eqb i j | _, _ => false end.
582Definition sd_eqb (a b : sd) : bool := andb (runs_eqb (fst a) (fst b)) (tl_eqb (snd a) (snd b)).
584Definition q_eqb (a b : Q) : bool :=
585 match a, b with A, A | B, B | C, C | D, D | E, E | F, F => true | _, _ => false end.
587Definition cfg_eqb (a b : cfg) : bool :=
588 match a, b with
589 | Rc q l r, Rc q' l' r' => andb (q_eqb q q') (andb (sd_eqb l l') (sd_eqb r r'))
590 | Lc q l r, Lc q' l' r' => andb (q_eqb q q') (andb (sd_eqb l l') (sd_eqb r r'))
591 | _, _ => false
592 end.
594Lemma dot_strip0 vs nu : dot (strip0 vs) nu = dot vs nu.
3855Proof.595Proof.
3856 esx.
596 revert nu. induction vs as [|v vs IH]; intros nu; [reflexivity|].
597 cbn [strip0]. destruct (strip0 vs) as [|w ws] eqn:E.
598 - destruct (N.eqb_spec v 0) as [->|Hv]; destruct nu as [|x nu]; cbn [dot]; try reflexivity.
599 + rewrite <-IH. cbn. lia.
600 + rewrite <-IH. cbn. lia.
601 - destruct nu as [|x nu]; cbn [dot]; [reflexivity|]. rewrite <-IH. reflexivity.
3857Qed.602Qed.
3859Lemma length_LIncs {x y k}:
604Lemma listN_eqb_eq a b : listN_eqb a b = true -> a = b.
3860 LIncs x y k ->
3861 length y = length x.
3862Proof.605Proof.
3863 intros H.
606 revert b. induction a as [|x a IH]; intros [|y b] H; cbn in H; try discriminate; [reflexivity|].
3864 induction H; cbn; lia.
607 apply andb_prop in H as [H1 H2]. apply N.eqb_eq in H1. subst. f_equal. apply IH, H2.
3865Qed.608Qed.
3867Lemma LIncs_k x y k:
610Lemma lf_eqb_ev nu a b : lf_eqb a b = true -> ev nu a = ev nu b.
3868 LIncs x y k ->
3869 k = 2^(length x)-1.
3870Proof.611Proof.
3871 intros H.
612 unfold lf_eqb, ev. intros H. apply andb_prop in H as [H1 H2].
3872 induction H; cbn; lia.
613 apply N.eqb_eq in H1. apply listN_eqb_eq in H2.
614 rewrite H1, <-(dot_strip0 (lv a)), <-(dot_strip0 (lv b)), H2. reflexivity.
3873Qed.615Qed.
3875Lemma length_Ov {x y a x' y'}:
617Lemma runs_eqb_ev nu a b s : runs_eqb a b = true -> ev_runs nu a s = ev_runs nu b s.
3876 Ov x y a x' y' ->
3877 length x' = length x + (match y with LH1 => 0 | _ => 1 end).
3878Proof.618Proof.
3879 intro H.
619 revert b. induction a as [|[x n] a IH]; intros [|[y m] b] H; cbn in H; try discriminate; [reflexivity|].
3880 induction H; cbn; trivial.
620 apply andb_prop in H as [H1 H3]. apply andb_prop in H1 as [H1 H2].
3881 rewrite IHOv; trivial.
621 apply seqb_eq in H1. subst. cbn. rewrite (lf_eqb_ev nu _ _ H2), (IH _ H3). reflexivity.
3882Qed.622Qed.
3884Inductive LWF: LS->LH->Prop :=
624Lemma sd_eqb_ev nu sg a b : sd_eqb a b = true -> ev_sd nu sg a = ev_sd nu sg b.
3885| LWF_S x y n m
3886 (Ha:LWF x y)
⋯ 25 template-only lines (template 3887–3914), not in ours
3915 Ov x0 y a x1 y0 /\
3916 LWF x1 y0.
3917Proof.625Proof.
3918 intro H.
626 destruct a as [ra ta], b as [rb tb]. unfold sd_eqb, ev_sd; cbn [fst snd]. intros H.
3919 gen a.
627 apply andb_prop in H as [H1 H2].
3920 induction H.
628 assert (ta = tb) as ->.
3921 - intros.
629 { destruct ta, tb; cbn in H2; try discriminate; [reflexivity|]. apply Nat.eqb_eq in H2. subst. reflexivity. }
3922 epose proof (IHLWF _ _) as [x0 [k [I1 [x1 [y0 [I2 I3]]]]]].
630 apply runs_eqb_ev, H1.
3923 epose proof (LIncs_k _ _ _ I1); subst.
3924 eexists _,_; split.
⋯ 52 template-only lines (template 3925–3976), not in ours
3977 2,3: cbn; lia.
3978 apply LWF_O_1.
3979Qed.631Qed.
3981Close Scope sym.
633Lemma q_eqb_eq a b : q_eqb a b = true -> a = b.
3983Lemma nonhalt: ~halts tm c0.
634Proof. destruct a, b; cbn; congruence. Qed.
636Lemma cfg_eqb_ev nu sg a b : cfg_eqb a b = true -> ev_cfg nu sg a = ev_cfg nu sg b.
637Proof.
638 destruct a as [q l r|q l r], b as [q' l' r'|q' l' r']; cbn [cfg_eqb]; intros H; try discriminate;
639 apply andb_prop in H as [H1 H]; apply andb_prop in H as [H2 H3];
640 apply q_eqb_eq in H1; subst; cbn [ev_cfg];
641 rewrite (sd_eqb_ev nu sg _ _ H2), (sd_eqb_ev nu sg _ _ H3); reflexivity.
642Qed.
644Definition rstep (tgt : cfg) (st : cfg * bool * bool) : cfg * bool * bool :=
645 let '(c, pr, dn) := st in
646 if dn then st else
647 match sstep c with
648 | Some (c', b) => (c', orb pr b, cfg_eqb c' tgt)
649 | None => st
650 end.
652(* reach fuel c tgt = true: c reaches tgt in at most fuel simulator steps, at least one machine step *)
653Definition reach (fuel : positive) (c tgt : cfg) : bool :=
654 let '(c', pr, dn) := Pos.iter (rstep tgt) (c, false, false) fuel in andb pr dn.
656Lemma reach_spec fuel c tgt : reach fuel c tgt = true ->
657 forall nu sg, ev_cfg nu sg c -->+ ev_cfg nu sg tgt.
658Proof.
659 intros H nu sg. unfold reach in H.
660 pose (Inv := fun st : cfg * bool * bool => let '(c', pr, dn) := st in
661 Rel pr (ev_cfg nu sg c) (ev_cfg nu sg c') /\ (dn = true -> cfg_eqb c' tgt = true)).
662 assert (HI : Inv (Pos.iter (rstep tgt) (c, false, false) fuel)).
663 { apply Pos.iter_invariant.
664 - intros [[c1 pr] dn] [HR Hd]. unfold rstep.
665 destruct dn; [split; assumption|].
666 destruct (sstep c1) as [[c2 b]|] eqn:Es; [|split; assumption].
667 split; [|intros E; exact E].
668 apply (Rel_trans _ _ _ _ _ HR (sstep_spec nu sg _ _ _ Es)).
669 - split; [apply evstep_refl | discriminate]. }
670 destruct (Pos.iter (rstep tgt) (c, false, false) fuel) as [[c' pr] dn].
671 destruct HI as [HR Hd]. apply andb_prop in H as [-> ->].
672 rewrite <-(cfg_eqb_ev nu sg _ _ (Hd eq_refl)). exact HR.
673Qed.
675Definition cn (n : N) : lf := LF n [].
677(* ===================================================================== *)
678(* Blocks of the chain. *)
679(* ===================================================================== *)
681Fixpoint mkruns (b : Sym) (ns : list lf) : list run :=
682 match ns with [] => [] | n :: ns' => (b, n) :: mkruns (lastb b n) ns' end.
684(* gap variables of an m = 3 block: t = 4 + 4 x0, s = 4 + 4 x1, a = 1 + 4 x2, lp = 2 + 4 x3 *)
685Definition vt c := LF c [4;0;0;0]%N.
686Definition vs c := LF c [0;4;0;0]%N.
687Definition va c := LF c [0;0;4;0]%N.
688Definition vl c := LF c [0;0;0;4]%N.
690Inductive lab := U0 | U1 | U2 | W0 | W1 | D0 | D1 | D2.
692Definition lens (s : lab) : list lf :=
693 match s with
694 | U0 => [cn 3; vt 4; vs 4; va 1; vl 2]
695 | U1 => [cn 3; vt 4; vs 4; va 2; vl 1]
696 | U2 => [cn 3; vt 4; vs 4; va 3; vl 0]
697 | W0 => [cn 3; vt 1; vs 6; va 4; vl 0]
698 | W1 => [cn 3; vt 2; vs 5; va 4; vl 0]
699 | D0 => [cn 3; vt 3; vs 4; va 4; vl 0]
700 | D1 => [cn 2; vt 4; vs 4; va 4; vl 0]
701 | D2 => [cn 1; vt 5; vs 4; va 4; vl 0]
702 end%N.
703Definition blk (s : lab) : list run := mkruns S0 (lens s).
705(* a full block after the head has passed it leftward (now on the right of the head) *)
706Definition rlens (s : lab) : list lf :=
707 match s with
708 | D0 => [vl 0; va 4; vs 4; vt 3; cn 3]
709 | _ => [vl 0; va 3; vs 4; vt 4; cn 3]
710 end%N.
711Definition rblk (s : lab) : list run := mkruns S0 (rlens s).
713(* block 1 (m = 1), concrete *)
714Inductive lab1 := P0 | P1 | PD0 | PD1 | PD2.
715Definition lens1 (s : lab1) : list lf :=
716 match s with
717 | P0 => [cn 3; cn 1; cn 3] | P1 => [cn 3; cn 2; cn 2] | PD0 => [cn 3; cn 3; cn 1]
718 | PD1 => [cn 2; cn 4; cn 1] | PD2 => [cn 1; cn 5; cn 1]
719 end%N.
720Definition blk1 (s : lab1) : list run := mkruns S0 (lens1 s).
721Definition rblk1 : list run := mkruns S1 [cn 1; cn 3; cn 3]%N.
723(* exit phase: true = c + 2 (state A at the cut), false = c (state B) *)
724Definition stp (p : bool) : Q := if p then A else B.
726Definition turn (s : lab) : option (lab * bool) :=
727 match s with
728 | U0 => Some (U1, true) | U1 => Some (U2, true) | W0 => Some (W1, true) | W1 => Some (D0, true)
729 | D1 => Some (D0, false) | D2 => Some (D1, false) | _ => None
730 end.
731Definition reset (s : lab) (p : bool) : option (lab * bool) :=
732 match s, p with
733 | U2, true => Some (U0, true) | U2, false => Some (W0, true) | D0, false => Some (D2, false)
734 | _, _ => None
735 end.
736Definition turn1 (s : lab1) : option (lab1 * bool) :=
737 match s with
738 | P0 => Some (P1, true) | P1 => Some (PD0, true) | PD1 => Some (PD0, false) | PD2 => Some (PD1, false)
739 | PD0 => None
740 end.
742Definition sg2 (L R : side) : nat -> side := fun k => match k with O => L | _ => R end.
744Lemma reach_LR fuel q q' l l' nu L R :
745 reach fuel (Lc q (l, TV 0) ([], TV 1)) (Rc q' (l', TV 0) ([], TV 1)) = true ->
746 ev_runs nu l L <{{q}} R -->+ ev_runs nu l' L {{q'}}> R.
747Proof. intros H. exact (reach_spec _ _ _ H nu (sg2 L R)). Qed.
749Lemma reach_LL fuel q q' l r' nu L R :
750 reach fuel (Lc q (l, TV 0) ([], TV 1)) (Lc q' ([], TV 0) (r', TV 1)) = true ->
751 ev_runs nu l L <{{q}} R -->+ L <{{q'}} ev_runs nu r' R.
752Proof. intros H. exact (reach_spec _ _ _ H nu (sg2 L R)). Qed.
754Lemma reach_RR fuel q q' r l' nu L R :
755 reach fuel (Rc q ([], TV 0) (r, TV 1)) (Rc q' (l', TV 0) ([], TV 1)) = true ->
756 L {{q}}> ev_runs nu r R -->+ ev_runs nu l' L {{q'}}> R.
757Proof. intros H. exact (reach_spec _ _ _ H nu (sg2 L R)). Qed.
759Lemma blk_turn s s' p nu L R : turn s = Some (s', p) ->
760 ev_runs nu (blk s) L <{{D}} R -->+ ev_runs nu (blk s') L {{stp p}}> R.
761Proof.
762 intros H. destruct s; cbn in H; inversion H; subst; clear H; cbn [stp];
763 apply (reach_LR 100); vm_compute; reflexivity.
764Qed.
766Lemma blk_pass s nu L R : turn s = None ->
767 ev_runs nu (blk s) L <{{D}} R -->+ L <{{D}} ev_runs nu (rblk s) R.
768Proof.
769 intros H. destruct s; cbn in H; inversion H; apply (reach_LL 100); vm_compute; reflexivity.
770Qed.
772Lemma blk_reset s p s' p' nu L R : reset s p = Some (s', p') ->
773 L {{stp p}}> ev_runs nu (rblk s) R -->+ ev_runs nu (blk s') L {{stp p'}}> R.
774Proof.
775 intros H. destruct s, p; cbn in H; inversion H; subst; clear H; cbn [stp];
776 apply (reach_RR 100); vm_compute; reflexivity.
777Qed.
779Lemma blk1_turn s s' p L R : turn1 s = Some (s', p) ->
780 ev_runs [] (blk1 s) L <{{D}} R -->+ ev_runs [] (blk1 s') L {{stp p}}> R.
781Proof.
782 intros H. destruct s; cbn in H; inversion H; subst; clear H; cbn [stp];
783 apply (reach_LR 100); vm_compute; reflexivity.
784Qed.
786Lemma blk1_pass L R : ev_runs [] (blk1 PD0) L <{{D}} R -->+ L <{{E}} ev_runs [] rblk1 R.
787Proof. refine (reach_LL 100 D E (blk1 PD0) rblk1 [] L R _). vm_compute. reflexivity. Qed.
789Lemma blk1_back L R : L {{B}}> ev_runs [] rblk1 R -->+ ev_runs [] (blk1 PD2) L {{B}}> R.
790Proof. refine (reach_RR 100 B B rblk1 (blk1 PD2) [] L R _). vm_compute. reflexivity. Qed.
792(* ===================================================================== *)
793(* The left word: a 4-digit ternary counter (episodes 0..79), and the *)
794(* left record (episode 80). *)
795(* ===================================================================== *)
797Definition dgr (v : nat) : list run :=
798 match v with
799 | O => [(S0, cn 1); (S0, cn 5)]
800 | S O => [(S0, cn 2); (S1, cn 4)]
801 | _ => [(S0, cn 3); (S0, cn 3)]
802 end%N.
804Definition lw (i : nat) : list run :=
805 if Nat.ltb i 81 then
806 [(S1, cn 3); (S1, cn 4)] ++ dgr (i mod 3) ++ dgr (i / 3 mod 3) ++ dgr (i / 9 mod 3) ++ dgr (i / 27 mod 3)
807 ++ [(S0, cn 2)]
808 else [(S0, cn 6); (S1, cn 4)] ++ dgr 0 ++ dgr 0 ++ dgr 0 ++ dgr 0 ++ [(S0, cn 2)].
810Definition LWs (i : nat) : side := ev_runs [] (lw i) (const S0).
812Lemma reach_T0 fuel q q' l l' (Y : side) :
813 reach fuel (Lc q (l, T0) ([], TV 0)) (Rc q' (l', T0) ([], TV 0)) = true ->
814 ev_runs [] l (const S0) <{{q}} Y -->+ ev_runs [] l' (const S0) {{q'}}> Y.
815Proof. intros H. exact (reach_spec _ _ _ H [] (fun _ => Y)). Qed.
817Definition lw_ok (i : nat) : bool := reach 1000 (Lc E (lw i, T0) ([], TV 0)) (Rc B (lw (S i), T0) ([], TV 0)).
819Lemma lw_all : forallb lw_ok (seq 0 81) = true.
820Proof. vm_compute. reflexivity. Qed.
822Lemma lw_ok_spec i Y : lw_ok i = true ->
823 ev_runs [] (lw i) (const S0) <{{E}} Y -->+ ev_runs [] (lw (S i)) (const S0) {{B}}> Y.
824Proof. exact (reach_T0 1000 E B (lw i) (lw (S i)) Y). Qed.
826Lemma lw_ok_lt i : i < 81 -> lw_ok i = true.
827Proof. intros Hi. pose proof lw_all as H. rewrite forallb_forall in H. apply H, in_seq. lia. Qed.
829Lemma lw_ep i Y : i < 81 -> LWs i <{{E}} Y -->+ LWs (S i) {{B}}> Y.
830Proof. intros Hi. apply lw_ok_spec, lw_ok_lt, Hi. Qed.
832(* ===================================================================== *)
833(* The chain: m = 3 blocks (nearest the head first), then block 1, then *)
834(* the left word. *)
835(* ===================================================================== *)
837Fixpoint chs (ls : list lab) (nus : list (list N)) (L : side) : side :=
838 match ls, nus with
839 | s :: ls', nu :: nus' => ev_runs nu (blk s) (chs ls' nus' L)
840 | _, _ => L
841 end.
843Fixpoint rchs (ls : list lab) (nus : list (list N)) (R : side) : side :=
844 match ls, nus with
845 | s :: ls', nu :: nus' => rchs ls' nus' (ev_runs nu (rblk s) R)
846 | _, _ => R
847 end.
849Fixpoint visit3 (ls : list lab) : option (list lab * bool) :=
850 match ls with
851 | [] => None
852 | s :: ls' =>
853 match turn s with
854 | Some (s', p) => Some (s' :: ls', p)
855 | None =>
856 match visit3 ls' with
857 | Some (ls'', p') => match reset s p' with Some (s'', p'') => Some (s'' :: ls'', p'') | None => None end
858 | None => None
859 end
860 end
861 end.
863Fixpoint cb (ls : list lab) (p : bool) : option (list lab * bool) :=
864 match ls with
865 | [] => Some ([], p)
866 | s :: ls' =>
867 match cb ls' p with
868 | Some (ls'', p') => match reset s p' with Some (s'', p'') => Some (s'' :: ls'', p'') | None => None end
869 | None => None
870 end
871 end.
873Definition fullb (s : lab) : bool := match turn s with None => true | Some _ => false end.
875Lemma visit3_spec ls : forall ls' p nus L R, visit3 ls = Some (ls', p) -> length ls = length nus ->
876 chs ls nus L <{{D}} R -->+ chs ls' nus L {{stp p}}> R.
877Proof.
878 induction ls as [|s ls IH]; intros ls' p nus L R H Hl; [discriminate|].
879 destruct nus as [|nu nus]; [discriminate|]. cbn in Hl. injection Hl as Hl.
880 cbn [visit3] in H.
881 destruct (turn s) as [[s1 p1]|] eqn:Et.
882 - inversion H; subst. cbn [chs]. apply blk_turn, Et.
883 - destruct (visit3 ls) as [[ls1 p1]|] eqn:Ev; [|discriminate].
884 destruct (reset s p1) as [[s2 p2]|] eqn:Er; [|discriminate].
885 inversion H; subst; clear H. cbn [chs].
886 eapply progress_trans; [apply blk_pass, Et|].
887 eapply progress_trans; [apply (IH _ _ _ _ _ eq_refl Hl)|].
888 apply blk_reset, Er.
889Qed.
891Lemma pass_spec ls : forall nus L R, forallb fullb ls = true -> length ls = length nus ->
892 chs ls nus L <{{D}} R -->* L <{{D}} rchs ls nus R.
893Proof.
894 induction ls as [|s ls IH]; intros nus L R H Hl.
895 - destruct nus; [apply evstep_refl | discriminate].
896 - destruct nus as [|nu nus]; [discriminate|]. cbn in Hl. injection Hl as Hl.
897 cbn [forallb] in H. apply andb_prop in H as [H1 H2].
898 cbn [chs rchs].
899 eapply evstep_trans; [apply progress_evstep, blk_pass|].
900 + unfold fullb in H1. destruct (turn s); [discriminate | reflexivity].
901 + apply IH; assumption.
902Qed.
904Lemma cb_spec ls : forall p ls' p' nus L R, cb ls p = Some (ls', p') -> length ls = length nus ->
905 L {{stp p}}> rchs ls nus R -->* chs ls' nus L {{stp p'}}> R.
906Proof.
907 induction ls as [|s ls IH]; intros p ls' p' nus L R H Hl.
908 - destruct nus; [|discriminate]. inversion H; subst. apply evstep_refl.
909 - destruct nus as [|nu nus]; [discriminate|]. cbn in Hl. injection Hl as Hl.
910 cbn [cb] in H.
911 destruct (cb ls p) as [[ls1 p1]|] eqn:Ec; [|discriminate].
912 destruct (reset s p1) as [[s2 p2]|] eqn:Er; [|discriminate].
913 inversion H; subst; clear H. cbn [chs rchs].
914 eapply evstep_trans; [apply (IH _ _ _ _ _ _ Ec Hl)|].
915 apply progress_evstep, blk_reset, Er.
916Qed.
918Lemma visit3_len ls : forall ls' p, visit3 ls = Some (ls', p) -> length ls' = length ls.
919Proof.
920 induction ls as [|s ls IH]; intros ls' p H; [discriminate|]. cbn in H.
921 destruct (turn s) as [[s1 p1]|]; [inversion H; reflexivity|].
922 destruct (visit3 ls) as [[ls1 p1]|] eqn:E; [|discriminate].
923 destruct (reset s p1) as [[s2 p2]|]; [|discriminate].
924 inversion H; subst. cbn. rewrite (IH _ _ eq_refl). reflexivity.
925Qed.
927Lemma cb_len ls : forall p ls' p', cb ls p = Some (ls', p') -> length ls' = length ls.
928Proof.
929 induction ls as [|s ls IH]; intros p ls' p' H; cbn in H; [inversion H; reflexivity|].
930 destruct (cb ls p) as [[ls1 p1]|] eqn:E; [|discriminate].
931 destruct (reset s p1) as [[s2 p2]|]; [|discriminate].
932 inversion H; subst. cbn. rewrite (IH _ _ _ E). reflexivity.
933Qed.
935(* ===================================================================== *)
936(* One visit of the whole chain (Lemma C, C', and the left episodes). *)
937(* ===================================================================== *)
939Definition vst : Type := (list lab * lab1 * nat)%type.
941Definition lab1_eqb (a b : lab1) : bool :=
942 match a, b with P0, P0 | P1, P1 | PD0, PD0 | PD1, PD1 | PD2, PD2 => true | _, _ => false end.
944Definition vis (st : vst) : option (vst * bool) :=
945 let '(ls, b, i) := st in
946 match visit3 ls with
947 | Some (ls', p) => Some ((ls', b, i), p)
948 | None =>
949 if forallb fullb ls then
950 match turn1 b with
951 | Some (b', p1) => match cb ls p1 with Some (ls', p) => Some ((ls', b', i), p) | None => None end
952 | None =>
953 if andb (lab1_eqb b PD0) (Nat.ltb i 80) then
954 match cb ls false with Some (ls', p) => Some ((ls', PD2, S i), p) | None => None end
955 else None
956 end
957 else None
958 end.
960Definition b1s (b : lab1) (X : side) : side := ev_runs [] (blk1 b) X.
962Definition Gc (st : vst) (nus : list (list N)) (R : side) : Q * tape :=
963 let '(ls, b, i) := st in chs ls nus (b1s b (LWs i)) <{{D}} R.
964Definition Gx (st : vst) (nus : list (list N)) (p : bool) (R : side) : Q * tape :=
965 let '(ls, b, i) := st in chs ls nus (b1s b (LWs i)) {{stp p}}> R.
967Definition vlen (st : vst) : nat := let '(ls, _, _) := st in length ls.
969Lemma lab1_eqb_eq a b : lab1_eqb a b = true -> a = b.
970Proof. destruct a, b; cbn; congruence. Qed.
972Lemma vis_spec st st' p nus R : vis st = Some (st', p) -> vlen st = length nus ->
973 Gc st nus R -->+ Gx st' nus p R /\ vlen st' = vlen st.
974Proof.
975 destruct st as [[ls b] i]. cbn [vis vlen]. intros H Hl.
976 destruct (visit3 ls) as [[ls1 p1]|] eqn:Ev.
977 - inversion H; subst; clear H. cbn [Gc Gx vlen]. split.
978 + apply visit3_spec; assumption.
979 + apply (visit3_len _ _ _ Ev).
980 - destruct (forallb fullb ls) eqn:Ef; [|discriminate].
981 destruct (turn1 b) as [[b1 p1]|] eqn:Et.
982 + destruct (cb ls p1) as [[ls1 p2]|] eqn:Ec; [|discriminate].
983 inversion H; subst; clear H. cbn [Gc Gx vlen]. split; [|apply (cb_len _ _ _ _ Ec)].
984 eapply evstep_progress_trans; [apply pass_spec; assumption|].
985 unfold b1s at 1. eapply progress_evstep_trans; [apply blk1_turn, Et|].
986 apply cb_spec; assumption.
987 + destruct (andb (lab1_eqb b PD0) (Nat.ltb i 80)) eqn:Eb; [|discriminate].
988 apply andb_prop in Eb as [Eb Ei]. apply lab1_eqb_eq in Eb. subst b. apply Nat.ltb_lt in Ei.
989 destruct (cb ls false) as [[ls1 p2]|] eqn:Ec; [|discriminate].
990 inversion H; subst; clear H. cbn [Gc Gx vlen]. split; [|apply (cb_len _ _ _ _ Ec)].
991 eapply evstep_progress_trans; [apply pass_spec; assumption|].
992 unfold b1s at 1. eapply progress_trans; [apply blk1_pass|].
993 eapply progress_trans; [apply lw_ep; lia|].
994 eapply progress_evstep_trans; [apply blk1_back|].
995 apply (cb_spec _ false); assumption.
996Qed.
998(* ===================================================================== *)
999(* Right-region episodes, abstractly. *)
1000(* ===================================================================== *)
1002Definition Ep (p : bool) (R R' : side) : Prop := forall l, l {{stp p}}> R -->* l <{{D}} R'.
1004Fixpoint EpSeq (ps : list bool) (R R' : side) : Prop :=
1005 match ps with
1006 | [] => R = R'
1007 | p :: ps' => exists R1, Ep p R R1 /\ EpSeq ps' R1 R'
1008 end.
1010Fixpoint runv (n : nat) (st : vst) : option (vst * list bool) :=
1011 match n with
1012 | O => Some (st, [])
1013 | S n' =>
1014 match vis st with
1015 | Some (st1, p) => match runv n' st1 with Some (st2, ps) => Some (st2, p :: ps) | None => None end
1016 | None => None
1017 end
1018 end.
1020Lemma runv_spec n : forall st st' ps nus R R', runv n st = Some (st', ps) -> vlen st = length nus ->
1021 EpSeq ps R R' -> Gc st nus R -->* Gc st' nus R'.
1022Proof.
1023 induction n as [|n IH]; intros st st' ps nus R R' H Hl HE.
1024 - cbn in H. inversion H; subst. cbn in HE. subst. apply evstep_refl.
1025 - cbn [runv] in H.
1026 destruct (vis st) as [[st1 p]|] eqn:Ev; [|discriminate].
1027 destruct (runv n st1) as [[st2 ps2]|] eqn:Er; [|discriminate].
1028 inversion H; subst; clear H.
1029 destruct HE as [R1 [HE1 HE2]].
1030 destruct (vis_spec _ _ _ nus R Ev Hl) as [H1 H2].
1031 eapply evstep_trans; [apply progress_evstep, H1|].
1032 eapply evstep_trans; [|apply (IH st1 st' ps2 nus R1 R' Er); [congruence | exact HE2]].
1033 destruct st1 as [[ls1 b1] i1]. cbn [Gx Gc]. apply HE1.
1034Qed.
1036(* ===================================================================== *)
1037(* Lemma T: the visits of one record interval, as a computation on block *)
1038(* labels. *)
1039(* ===================================================================== *)
1041Lemma runv_add a : forall b st st1 ps1 st2 ps2,
1042 runv a st = Some (st1, ps1) -> runv b st1 = Some (st2, ps2) -> runv (a + b) st = Some (st2, ps1 ++ ps2).
1043Proof.
1044 induction a as [|a IH]; intros b st st1 ps1 st2 ps2 H1 H2.
1045 - cbn in H1. inversion H1; subst. exact H2.
1046 - change (S a + b) with (S (a + b)). cbn [runv] in H1 |- *. destruct (vis st) as [[st0 p]|]; [|discriminate].
1047 destruct (runv a st0) as [[st3 ps3]|] eqn:E; [|discriminate].
1048 inversion H1; subst. rewrite (IH _ _ _ _ _ _ E H2). reflexivity.
1049Qed.
1051Lemma runv_one st st' p : vis st = Some (st', p) -> runv 1 st = Some (st', [p]).
1052Proof. intros H. cbn. rewrite H. reflexivity. Qed.
1054Lemma vis3 ls ls' p b i : visit3 ls = Some (ls', p) -> vis (ls, b, i) = Some ((ls', b, i), p).
1055Proof. intros H. cbn. rewrite H. reflexivity. Qed.
1057Lemma repeat_add {X} (x : X) n m : repeat x (n + m) = repeat x n ++ repeat x m.
1058Proof. induction n; cbn in *; congruence. Qed.
1060Lemma repeat_snoc {X} (x : X) n l : repeat x n ++ x :: l = repeat x (S n) ++ l.
1061Proof. induction n; cbn in *; congruence. Qed.
1063Lemma pow3_pos j : 1 <= 3 ^ j.
1064Proof. induction j; cbn; lia. Qed.
1066Lemma visit3_U2 j X X' : visit3 X = Some (X', true) -> visit3 (repeat U2 j ++ X) = Some (repeat U0 j ++ X', true).
1067Proof. intros H. induction j as [|j IH]; cbn; [exact H|]. rewrite IH. reflexivity. Qed.
1069Lemma cb_U2 j X p X' : cb X p = Some (X', true) -> cb (repeat U2 j ++ X) p = Some (repeat U0 j ++ X', true).
1070Proof. intros H. induction j as [|j IH]; cbn; [exact H|]. rewrite IH. reflexivity. Qed.
1072Lemma visit3_full ls : forallb fullb ls = true -> visit3 ls = None.
1073Proof.
1074 induction ls as [|s ls IH]; cbn; intros H; [reflexivity|].
1075 apply andb_prop in H as [H1 H2]. unfold fullb in H1.
1076 destruct (turn s); [discriminate|]. rewrite IH by exact H2. reflexivity.
1077Qed.
1079Lemma fullb_U2 j : forallb fullb (repeat U2 j) = true.
1080Proof. induction j; cbn; auto. Qed.
1082Lemma fullb_D0 j : forallb fullb (repeat D0 j) = true.
1083Proof. induction j; cbn; auto. Qed.
1085Lemma fullb_app a b : forallb fullb a = true -> forallb fullb b = true -> forallb fullb (a ++ b) = true.
1086Proof. intros. rewrite forallb_app. apply andb_true_intro. auto. Qed.
1088Lemma rep_app {X} (x : X) a b : repeat x a ++ repeat x b = repeat x (a + b).
1089Proof. symmetry. apply repeat_add. Qed.
1091(* CU: the j blocks nearest the head count from all U0 to all U2 *)
1092Lemma CU j : forall rest b i,
1093 runv (3 ^ j - 1) (repeat U0 j ++ rest, b, i) = Some ((repeat U2 j ++ rest, b, i), repeat true (3 ^ j - 1)).
1094Proof.
1095 induction j as [|j IH]; intros rest b i; [reflexivity|].
1096 pose proof (pow3_pos j) as Hp.
1097 rewrite <-(repeat_snoc U0 j rest), <-(repeat_snoc U2 j rest).
1098 pose proof (IH (U0 :: rest) b i) as H1.
1099 assert (H2 : runv 1 (repeat U2 j ++ U0 :: rest, b, i) = Some ((repeat U0 j ++ U1 :: rest, b, i), repeat true 1))
1100 by (apply runv_one, vis3, visit3_U2; reflexivity).
1101 pose proof (IH (U1 :: rest) b i) as H3.
1102 assert (H4 : runv 1 (repeat U2 j ++ U1 :: rest, b, i) = Some ((repeat U0 j ++ U2 :: rest, b, i), repeat true 1))
1103 by (apply runv_one, vis3, visit3_U2; reflexivity).
1104 pose proof (IH (U2 :: rest) b i) as H5.
1105 pose proof (runv_add _ _ _ _ _ _ _ H4 H5) as H45.
1106 pose proof (runv_add _ _ _ _ _ _ _ H3 H45) as H35.
1107 pose proof (runv_add _ _ _ _ _ _ _ H2 H35) as H25.
1108 pose proof (runv_add _ _ _ _ _ _ _ H1 H25) as H.
1109 rewrite !rep_app in H.
1110 replace (3 ^ S j - 1) with ((3 ^ j - 1) + (1 + ((3 ^ j - 1) + (1 + (3 ^ j - 1))))) by (cbn; lia).
1111 exact H.
1112Qed.
1114(* CW: a suffix W0 U0^j counts to D0 U2^j *)
1115Lemma CW j : forall rest b i,
1116 runv (3 ^ S j - 1) (repeat U0 j ++ W0 :: rest, b, i) =
1117 Some ((repeat U2 j ++ D0 :: rest, b, i), repeat true (3 ^ S j - 1)).
1118Proof.
1119 intros rest b i. pose proof (pow3_pos j) as Hp.
1120 pose proof (CU j (W0 :: rest) b i) as H1.
1121 assert (H2 : runv 1 (repeat U2 j ++ W0 :: rest, b, i) = Some ((repeat U0 j ++ W1 :: rest, b, i), repeat true 1))
1122 by (apply runv_one, vis3, visit3_U2; reflexivity).
1123 pose proof (CU j (W1 :: rest) b i) as H3.
1124 assert (H4 : runv 1 (repeat U2 j ++ W1 :: rest, b, i) = Some ((repeat U0 j ++ D0 :: rest, b, i), repeat true 1))
1125 by (apply runv_one, vis3, visit3_U2; reflexivity).
1126 pose proof (CU j (D0 :: rest) b i) as H5.
1127 pose proof (runv_add _ _ _ _ _ _ _ H4 H5) as H45.
1128 pose proof (runv_add _ _ _ _ _ _ _ H3 H45) as H35.
1129 pose proof (runv_add _ _ _ _ _ _ _ H2 H35) as H25.
1130 pose proof (runv_add _ _ _ _ _ _ _ H1 H25) as H.
1131 rewrite !rep_app in H.
1132 replace (3 ^ S j - 1) with ((3 ^ j - 1) + (1 + ((3 ^ j - 1) + (1 + (3 ^ j - 1))))) by (cbn; lia).
1133 exact H.
1134Qed.
1136Fixpoint tc (j : nat) : nat :=
1137 match j with
1138 | O => 0
1139 | S O => 2
1140 | S j' => 3 ^ j + tc j'
1141 end.
1143Lemma tc_closed j : 2 * tc (S j) + 5 = 3 ^ S (S j).
1144Proof.
1145 induction j as [|j IH]; [reflexivity|].
1146 change (tc (S (S j))) with (3 ^ S (S j) + tc (S j)). cbn [Nat.pow] in *. lia.
1147Qed.
1149(* S3: from U0^j W0 d (d a D block that is not full) to all D *)
1150Lemma S3 j : forall d d' rest b i, turn d = Some (d', false) ->
1151 runv (tc (S j) + 1) (repeat U0 j ++ W0 :: d :: rest, b, i) =
1152 Some ((D2 :: repeat D1 j ++ d' :: rest, b, i), repeat true (tc (S j)) ++ [false]).
1153Proof.
1154 induction j as [|j IH]; intros d d' rest b i Hd.
1155 - pose proof (CW 0 (d :: rest) b i) as H1.
1156 assert (H2 : runv 1 (repeat U2 0 ++ D0 :: d :: rest, b, i) = Some ((D2 :: d' :: rest, b, i), [false]))
1157 by (apply runv_one, vis3; cbn; rewrite Hd; reflexivity).
1158 exact (runv_add _ _ _ _ _ _ _ H1 H2).
1159 - pose proof (pow3_pos (S (S j))) as Hp.
1160 pose proof (CW (S j) (d :: rest) b i) as H1.
1161 assert (H2 : runv 1 (repeat U2 (S j) ++ D0 :: d :: rest, b, i) =
1162 Some ((repeat U0 j ++ W0 :: D2 :: d' :: rest, b, i), repeat true 1)).
1163 { apply runv_one, vis3. rewrite <-repeat_snoc. apply visit3_U2. cbn. rewrite Hd. reflexivity. }
1164 pose proof (IH D2 D1 (d' :: rest) b i eq_refl) as H3.
1165 pose proof (runv_add _ _ _ _ _ _ _ H2 H3) as H23.
1166 pose proof (runv_add _ _ _ _ _ _ _ H1 H23) as H.
1167 rewrite repeat_snoc, app_assoc, rep_app, app_assoc, rep_app in H.
1168 change (tc (S (S j))) with (3 ^ S (S j) + tc (S j)).
1169 replace (3 ^ S (S j) + tc (S j) + 1) with ((3 ^ S (S j) - 1) + (1 + (tc (S j) + 1))) by lia.
1170 replace (3 ^ S (S j) + tc (S j)) with (3 ^ S (S j) - 1 + 1 + tc (S j)) by lia.
1171 exact H.
1172Qed.
1174(* ---- all-D words count like a plain ternary counter, every exit at phase c ---- *)
1176Definition isD (s : lab) : bool := match s with D0 | D1 | D2 => true | _ => false end.
1177Definition dv (s : lab) : nat := match s with D1 => 1 | D0 => 2 | _ => 0 end.
1178Fixpoint dval (ls : list lab) : nat := match ls with [] => 0 | s :: ls' => dv s + 3 * dval ls' end.
1179Definition dv1 (b : lab1) : nat := match b with PD1 => 1 | PD0 => 2 | _ => 0 end.
1180Definition isD1 (b : lab1) : bool := match b with PD0 | PD1 | PD2 => true | _ => false end.
1182Lemma dval_lt ls : forallb isD ls = true -> dval ls < 3 ^ length ls.
1183Proof.
1184 induction ls as [|s ls IH]; cbn; intros H; [lia|].
1185 apply andb_prop in H as [H1 H2]. specialize (IH H2). destruct s; cbn in *; try discriminate; lia.
1186Qed.
1188Lemma dval_max ls : forallb isD ls = true -> dval ls + 1 = 3 ^ length ls -> ls = repeat D0 (length ls).
1189Proof.
1190 induction ls as [|s ls IH]; cbn; intros H E; [reflexivity|].
1191 apply andb_prop in H as [H1 H2]. pose proof (dval_lt ls H2).
1192 destruct s; cbn in *; try discriminate; try lia. f_equal. apply IH; [exact H2 | lia].
1193Qed.
1195Lemma visit3_D ls : forallb isD ls = true -> dval ls + 1 < 3 ^ length ls ->
1196 exists ls', visit3 ls = Some (ls', false) /\ forallb isD ls' = true /\ dval ls' = dval ls + 1 /\
1197 length ls' = length ls.
1198Proof.
1199 induction ls as [|s ls IH]; cbn; intros H E; [lia|].
1200 apply andb_prop in H as [H1 H2]. pose proof (dval_lt ls H2).
1201 destruct s; cbn in H1; try discriminate.
1202 - assert (E' : dval ls + 1 < 3 ^ length ls) by (cbn in E; lia).
1203 destruct (IH H2 E') as [ls' [E1 [E2 [E3 E4]]]]. cbn. rewrite E1. cbn.
1204 exists (D2 :: ls'). cbn. rewrite E2, E3, E4. repeat split; lia.
1205 - exists (D0 :: ls). cbn. rewrite H2. repeat split; lia.
1206 - exists (D1 :: ls). cbn. rewrite H2. repeat split; lia.
1207Qed.
1209Lemma cb_D0 j : cb (repeat D0 j) false = Some (repeat D2 j, false).
1210Proof. induction j as [|j IH]; cbn; [reflexivity|]. rewrite IH. reflexivity. Qed.
1212Lemma isD_D2 j : forallb isD (repeat D2 j) = true.
1213Proof. induction j; cbn; auto. Qed.
1215Lemma dval_D2 j : dval (repeat D2 j) = 0.
1216Proof. induction j; cbn; lia. Qed.
1218Lemma dval_D1 j : 2 * dval (repeat D1 j) + 1 = 3 ^ j.
1219Proof. induction j; cbn in *; lia. Qed.
1221Lemma isD_D1 j : forallb isD (repeat D1 j) = true.
1222Proof. induction j; cbn; auto. Qed.
1224Lemma vis_b1 ls b b' p1 ls' p i : forallb fullb ls = true -> turn1 b = Some (b', p1) -> cb ls p1 = Some (ls', p) ->
1225 vis (ls, b, i) = Some ((ls', b', i), p).
1226Proof. intros H1 H2 H3. cbn. rewrite (visit3_full _ H1), H1, H2, H3. reflexivity. Qed.
1228Lemma vis_co ls ls' p i : forallb fullb ls = true -> i < 80 -> cb ls false = Some (ls', p) ->
1229 vis (ls, PD0, i) = Some ((ls', PD2, S i), p).
1230Proof.
1231 intros H1 H2 H3. cbv beta iota zeta delta [vis]. rewrite (visit3_full _ H1), H1. apply Nat.ltb_lt in H2.
1232 cbv beta iota delta [turn1 lab1_eqb andb]. rewrite H2, H3. reflexivity.
1233Qed.
1235Lemma allD n : forall ls b i, forallb isD ls = true -> isD1 b = true ->
1236 dval ls + 3 ^ length ls * dv1 b + n + 1 = 3 ^ S (length ls) ->
1237 runv n (ls, b, i) = Some ((repeat D0 (length ls), PD0, i), repeat false n).
1238Proof.
1239 induction n as [|n IH]; intros ls b i H1 H2 E; pose proof (dval_lt ls H1) as Hl; cbn [Nat.pow] in E.
1240 - assert (Eb : b = PD0) by (destruct b; cbn in *; try discriminate; try reflexivity; lia).
1241 subst b. cbn [dv1] in E. rewrite <-(dval_max ls H1) by lia. reflexivity.
1242 - destruct (Nat.lt_ge_cases (dval ls + 1) (3 ^ length ls)) as [Hlt|Hge].
1243 + destruct (visit3_D ls H1 Hlt) as [ls' [E1 [E2 [E3 E4]]]].
1244 cbn [runv]. rewrite (vis3 _ _ _ b i E1).
1245 rewrite (IH ls' b i E2 H2) by (rewrite E3, E4; cbn [Nat.pow]; lia). rewrite E4. reflexivity.
1246 + assert (Hd : dval ls + 1 = 3 ^ length ls) by lia.
1247 pose proof (dval_max ls H1 Hd) as Hr. remember (length ls) as m eqn:Em. subst ls.
1248 destruct b; cbn in H2; try discriminate; cbn [dv1] in E; [lia| |].
1249 * cbn [runv]. rewrite (vis_b1 _ PD1 PD0 false _ _ i (fullb_D0 m) eq_refl (cb_D0 m)).
1250 rewrite (IH (repeat D2 m) PD0 i (isD_D2 m) eq_refl) by (rewrite dval_D2, repeat_length; cbn; lia).
1251 rewrite repeat_length. reflexivity.
1252 * cbn [runv]. rewrite (vis_b1 _ PD2 PD1 false _ _ i (fullb_D0 m) eq_refl (cb_D0 m)).
1253 rewrite (IH (repeat D2 m) PD1 i (isD_D2 m) eq_refl) by (rewrite dval_D2, repeat_length; cbn; lia).
1254 rewrite repeat_length. reflexivity.
1255Qed.
1257Lemma cyc m i : i < 80 ->
1258 runv (3 ^ S m) (repeat D0 m, PD0, i) = Some ((repeat D0 m, PD0, S i), repeat false (3 ^ S m)).
1259Proof.
1260 intros Hi. pose proof (pow3_pos (S m)) as Hp.
1261 replace (3 ^ S m) with (1 + (3 ^ S m - 1)) by lia. rewrite repeat_add.
1262 eapply runv_add; [apply runv_one, (vis_co _ _ _ _ (fullb_D0 m) Hi (cb_D0 m))|].
1263 pose proof (allD (3 ^ S m - 1) (repeat D2 m) PD2 (S i) (isD_D2 m) eq_refl) as A.
1264 rewrite dval_D2, repeat_length in A. apply A. cbn [dv1]. lia.
1265Qed.
1267Lemma cycs c : forall m i, i + c <= 80 ->
1268 runv (c * 3 ^ S m) (repeat D0 m, PD0, i) = Some ((repeat D0 m, PD0, i + c), repeat false (c * 3 ^ S m)).
1269Proof.
1270 induction c as [|c IH]; intros m i Hi; [rewrite Nat.add_0_r; reflexivity|].
1271 change (S c * 3 ^ S m) with (3 ^ S m + c * 3 ^ S m).
1272 rewrite repeat_add. eapply runv_add; [apply cyc; lia|].
1273 replace (i + S c) with (S i + c) by lia. apply IH. lia.
1274Qed.
1276Lemma rep_app_cons {X} (x : X) a b l : repeat x a ++ (repeat x b ++ l) = repeat x (a + b) ++ l.
1277Proof. rewrite app_assoc, rep_app. reflexivity. Qed.
1279Lemma odd_pow3 j : exists k, 3 ^ j = 2 * k + 1.
1280Proof. induction j as [|j [k Hk]]; [exists 0; reflexivity|]. exists (3 * k + 1). cbn [Nat.pow]. lia. Qed.
1282Lemma half9 j : 2 * ((9 * 3 ^ j + 1) / 2) = 9 * 3 ^ j + 1.
1283Proof.
1284 destruct (odd_pow3 j) as [k Hk]. rewrite Hk.
1285 replace (9 * (2 * k + 1) + 1) with ((9 * k + 5) * 2) by lia. rewrite Nat.div_mul by lia. lia.
1286Qed.
1288(* Lemma T: one whole interval of visits, m = K - 1 blocks with m = 3 *)
1289Lemma interval m : 2 <= m ->
1290 exists T, 2 * T + 5 = 3 ^ S (S m) /\
1291 runv (81 * 3 ^ S m - 1) (repeat U0 m, P0, 0) =
1292 Some ((repeat D0 m, PD0, 80), repeat true T ++ repeat false (81 * 3 ^ S m - 1 - T)).
1293Proof.
1294 intros Hm. destruct m as [|[|m]]; [lia|lia|].
1295 pose proof (half9 (S m)) as Hh.
1296 set (y := 3 ^ S m) in *.
1297 assert (Hy : 1 <= y) by apply pow3_pos.
1298 assert (E3 : 3 ^ S (S m) = 3 * y) by reflexivity.
1299 assert (E9 : 3 ^ S (S (S m)) = 9 * y) by (cbn [Nat.pow]; unfold y; cbn [Nat.pow]; lia).
1300 pose proof (tc_closed m) as Etc. rewrite E3 in Etc.
1301 (* phase 1: block 1 plays the role of W *)
1302 assert (H1 : runv (3 ^ S (S (S m)) - 1) (repeat U0 (S (S m)), P0, 0) =
1303 Some ((repeat U2 (S (S m)), PD0, 0), repeat true (3 ^ S (S (S m)) - 1))).
1304 { pose proof (CU (S (S m)) [] P0 0) as A1. rewrite !app_nil_r in A1.
1305 assert (A2 : runv 1 (repeat U2 (S (S m)), P0, 0) = Some ((repeat U0 (S (S m)), P1, 0), repeat true 1)).
1306 { apply runv_one, (vis_b1 _ _ _ true); [apply fullb_U2 | reflexivity |].
1307 pose proof (cb_U2 (S (S m)) [] true [] eq_refl) as C. rewrite !app_nil_r in C. exact C. }
1308 pose proof (CU (S (S m)) [] P1 0) as A3. rewrite !app_nil_r in A3.
1309 assert (A4 : runv 1 (repeat U2 (S (S m)), P1, 0) = Some ((repeat U0 (S (S m)), PD0, 0), repeat true 1)).
1310 { apply runv_one, (vis_b1 _ _ _ true); [apply fullb_U2 | reflexivity |].
1311 pose proof (cb_U2 (S (S m)) [] true [] eq_refl) as C. rewrite !app_nil_r in C. exact C. }
1312 pose proof (CU (S (S m)) [] PD0 0) as A5. rewrite !app_nil_r in A5.
1313 pose proof (runv_add _ _ _ _ _ _ _ A4 A5) as A45.
1314 pose proof (runv_add _ _ _ _ _ _ _ A3 A45) as A35.
1315 pose proof (runv_add _ _ _ _ _ _ _ A2 A35) as A25.
1316 pose proof (runv_add _ _ _ _ _ _ _ A1 A25) as A.
1317 rewrite !rep_app in A. rewrite E3 in A. rewrite E9.
1318 replace (9 * y - 1) with (3 * y - 1 + (1 + (3 * y - 1 + (1 + (3 * y - 1))))) by lia. exact A. }
1319 (* carry-out 1 *)
1320 assert (H2 : runv 1 (repeat U2 (S (S m)), PD0, 0) = Some ((repeat U0 (S m) ++ [W0], PD2, 1), repeat true 1)).
1321 { apply runv_one, vis_co; [apply fullb_U2 | lia |].
1322 rewrite <-(app_nil_r (repeat U2 (S (S m)))), <-(repeat_snoc U2 (S m) []). apply cb_U2. reflexivity. }
1323 (* W-suffix of length S (S m) then the turn of block 1 *)
1324 pose proof (CW (S m) [] PD2 1) as H3.
1325 assert (H4 : runv 1 (repeat U2 (S m) ++ [D0], PD2, 1) = Some ((repeat U0 m ++ [W0; D2], PD1, 1), repeat true 1)).
1326 { apply runv_one, (vis_b1 _ _ _ false).
1327 - apply fullb_app; [apply fullb_U2 | reflexivity].
1328 - reflexivity.
1329 - rewrite <-(repeat_snoc U2 m [D0]). apply cb_U2. reflexivity. }
1330 pose proof (S3 m D2 D1 [] PD1 1 eq_refl) as H5.
1331 rewrite repeat_snoc, app_nil_r in H5.
1332 (* all-D counting up to the second carry-out *)
1333 assert (H6 : runv ((9 * y + 1) / 2) (D2 :: repeat D1 (S m), PD1, 1) =
1334 Some ((repeat D0 (S (S m)), PD0, 1), repeat false ((9 * y + 1) / 2))).
1335 { pose proof (dval_D1 (S m)) as Ed. fold y in Ed.
1336 pose proof (allD ((9 * y + 1) / 2) (D2 :: repeat D1 (S m)) PD1 1 ltac:(cbn; apply isD_D1) eq_refl) as A.
1337 cbn [length dval dv dv1] in A. rewrite repeat_length in A. apply A.
1338 rewrite E3, E9. lia. }
1339 (* 79 more carry-outs in the all-D regime *)
1340 pose proof (cycs 79 (S (S m)) 1 ltac:(lia)) as H7. rewrite E9 in H7.
1341 pose proof (runv_add _ _ _ _ _ _ _ H6 H7) as H67.
1342 pose proof (runv_add _ _ _ _ _ _ _ H5 H67) as H57.
1343 pose proof (runv_add _ _ _ _ _ _ _ H4 H57) as H47.
1344 pose proof (runv_add _ _ _ _ _ _ _ H3 H47) as H37.
1345 pose proof (runv_add _ _ _ _ _ _ _ H2 H37) as H27.
1346 pose proof (runv_add _ _ _ _ _ _ _ H1 H27) as H.
1347 rewrite rep_app, <-app_assoc in H. change [false] with (repeat false 1) in H.
1348 rewrite rep_app, !rep_app_cons in H. rewrite E3, E9 in H.
1349 assert (E27 : 3 ^ S (S (S (S m))) = 27 * y) by (unfold y; cbn [Nat.pow]; lia).
1350 exists (9 * y - 1 + 1 + (3 * y - 1) + 1 + tc (S m)). split; [rewrite E27; lia|].
1351 rewrite E9.
1352 replace (81 * (9 * y) - 1)
1353 with (9 * y - 1 + (1 + (3 * y - 1 + (1 + (tc (S m) + 1 + ((9 * y + 1) / 2 + 79 * (9 * y)))))))
1354 by lia.
1355 rewrite H.
1356 replace (9 * y - 1 + (1 + (3 * y - 1 + (1 + (tc (S m) + 1 + ((9 * y + 1) / 2 + 79 * (9 * y))))))
1357 - (9 * y - 1 + 1 + (3 * y - 1) + 1 + tc (S m)))
1358 with (1 + ((9 * y + 1) / 2 + 79 * (9 * y))) by lia.
1359 reflexivity.
1360Qed.
1362(* the chain side of one interval, on the machine *)
1363Lemma interval_tm m nus R R' : 2 <= m -> length nus = m ->
1364 (forall T, 2 * T + 5 = 3 ^ S (S m) -> EpSeq (repeat true T ++ repeat false (81 * 3 ^ S m - 1 - T)) R R') ->
1365 Gc (repeat U0 m, P0, 0) nus R -->* Gc (repeat D0 m, PD0, 80) nus R'.
1366Proof.
1367 intros Hm Hl HE. destruct (interval m Hm) as [T [ET Hr]].
1368 apply (runv_spec _ _ _ _ _ _ _ Hr); [cbn; rewrite repeat_length; auto | apply HE, ET].
1369Qed.
1371(* the record visit: carry-out at all D0, left episode 80 (the left record), carry back to all D2 *)
1372Lemma record_visit m nus R : length nus = m ->
1373 Gc (repeat D0 m, PD0, 80) nus R -->+ chs (repeat D2 m) nus (b1s PD2 (LWs 81)) {{B}}> R.
1374Proof.
1375 intros Hl. cbn [Gc].
1376 eapply evstep_progress_trans; [apply pass_spec; [apply fullb_D0 | rewrite repeat_length; auto]|].
1377 unfold b1s. eapply progress_trans; [apply blk1_pass|].
1378 eapply progress_trans; [apply lw_ep; lia|].
1379 eapply progress_evstep_trans; [apply blk1_back|].
1380 apply (cb_spec _ false _ false); [apply cb_D0 | rewrite repeat_length; auto].
1381Qed.
1383(* ===================================================================== *)
1384(* The right region: a verified symbolic executor for interval programs. *)
1385(* ===================================================================== *)
1387(* run the simulator until it is stuck (or out of fuel) *)
1388Fixpoint urun (p : positive) (c : cfg) : cfg * bool :=
1389 match p with
1390 | xH => match sstep c with Some (c', _) => (c', false) | None => (c, true) end
1391 | xO p' => let '(c1, s1) := urun p' c in if s1 then (c1, true) else urun p' c1
1392 | xI p' =>
1393 match sstep c with
1394 | Some (c0, _) => let '(c1, s1) := urun p' c0 in if s1 then (c1, true) else urun p' c1
1395 | None => (c, true)
1396 end
1397 end.
1399Lemma sstep_ev nu sg c c' b : sstep c = Some (c', b) -> ev_cfg nu sg c -->* ev_cfg nu sg c'.
1400Proof.
1401 intros E. pose proof (sstep_spec nu sg _ _ _ E) as H. destruct b; cbn in H; [apply progress_evstep|]; exact H.
1402Qed.
1404Lemma urun_spec p : forall c nu sg, ev_cfg nu sg c -->* ev_cfg nu sg (fst (urun p c)).
1405Proof.
1406 induction p as [p IH|p IH|]; intros c nu sg; cbn [urun].
1407 - destruct (sstep c) as [[c0 b]|] eqn:E; [|apply evstep_refl].
1408 pose proof (sstep_ev nu sg _ _ _ E) as H0.
1409 pose proof (IH c0 nu sg) as H1. destruct (urun p c0) as [c1 s1]. cbn [fst] in H1.
1410 destruct s1; cbn [fst].
1411 + eapply evstep_trans; eassumption.
1412 + eapply evstep_trans; [eassumption|]. eapply evstep_trans; [exact H1|]. apply IH.
1413 - pose proof (IH c nu sg) as H1. destruct (urun p c) as [c1 s1]. cbn [fst] in H1.
1414 destruct s1; cbn [fst]; [exact H1|]. eapply evstep_trans; [exact H1|]. apply IH.
1415 - destruct (sstep c) as [[c0 b]|] eqn:E; cbn [fst]; [|apply evstep_refl].
1416 exact (sstep_ev nu sg _ _ _ E).
1417Qed.
1419Definition tgtD (c : cfg) : option (list run) :=
1420 match c with
1421 | Lc D ([], TV O) (rr, T0) => Some rr
1422 | _ => None
1423 end.
1425Lemma tgtD_spec c rr : tgtD c = Some rr -> c = Lc D ([], TV 0) (rr, T0).
1426Proof.
1427 unfold tgtD. destruct c as [q l r|q [l t] [r t']]; [discriminate|].
1428 destruct q; try discriminate. destruct l; try discriminate.
1429 destruct t as [|[|k]]; try discriminate. destruct t'; try discriminate.
1430 intros H; inversion H; subst; reflexivity.
1431Qed.
1433Definition evR (nu : list N) (rr : list run) : side := ev_runs nu rr (const S0).
1435(* one episode of the right region, entered at phase p, the chain side abstract *)
1436Definition ep_run (p : bool) (rr : list run) : option (list run) :=
1437 tgtD (fst (urun 50000 (Rc (stp p) ([], TV 0) (rr, T0)))).
1439Lemma ep_run_spec p rr rr' : ep_run p rr = Some rr' -> forall nu, Ep p (evR nu rr) (evR nu rr').
1440Proof.
1441 unfold ep_run. intros H nu l.
1442 pose proof (urun_spec 50000 (Rc (stp p) ([], TV 0) (rr, T0)) nu (fun _ => l)) as U.
1443 destruct (urun 50000 (Rc (stp p) ([], TV 0) (rr, T0))) as [c s]. cbn [fst] in H, U.
1444 apply tgtD_spec in H. subst c. exact U.
1445Qed.
1447Fixpoint eps (ps : list bool) (rr : list run) : option (list run) :=
1448 match ps with
1449 | [] => Some rr
1450 | p :: ps' => match ep_run p rr with Some rr' => eps ps' rr' | None => None end
1451 end.
1453Lemma eps_spec ps : forall rr rr', eps ps rr = Some rr' -> forall nu, EpSeq ps (evR nu rr) (evR nu rr').
1454Proof.
1455 induction ps as [|p ps IH]; intros rr rr' H nu; cbn in H.
1456 - inversion H; reflexivity.
1457 - destruct (ep_run p rr) as [r1|] eqn:E; [|discriminate].
1458 exists (evR nu r1). split; [apply (ep_run_spec _ _ _ E) | apply (IH _ _ H)].
1459Qed.
1461Lemma EpSeq_app a : forall b R R1 R2, EpSeq a R R1 -> EpSeq b R1 R2 -> EpSeq (a ++ b) R R2.
1462Proof.
1463 induction a as [|p a IH]; intros b R R1 R2 H1 H2; cbn in *.
1464 - subst. exact H2.
1465 - destruct H1 as [R3 [H3 H4]]. exists R3. split; [exact H3 | apply (IH _ _ _ _ H4 H2)].
1466Qed.
1468(* ---- linear-form algebra ---- *)
1470Definition evN (nu : list N) (a : lf) : N := (lc a + dot (lv a) nu)%N.
1472Lemma dot_zadd2 v : forall a b, dot v (zadd a b) = (dot v a + dot v b)%N.
1473Proof.
1474 induction v as [|x v IH]; intros [|y a] [|z b]; cbn; try lia.
1475 rewrite IH. lia.
1476Qed.
1478Definition vscale (k : N) (w : list N) : list N := map (N.mul k) w.
1480Lemma dot_vscale v : forall k w, dot v (vscale k w) = (k * dot v w)%N.
1481Proof. unfold vscale. induction v as [|x v IH]; intros k [|y w]; cbn; try lia. rewrite IH. lia. Qed.
1483Lemma ev_runs_dot nu nu' T X : (forall v, dot v nu = dot v nu') -> ev_runs nu T X = ev_runs nu' T X.
1484Proof.
1485 intros H. induction T as [|[b a] T IH]; cbn; [reflexivity|]. unfold ev. rewrite H, IH. reflexivity.
1486Qed.
1488Definition subst_lf (w : list N) (a : lf) : lf := LF (lc a + dot (lv a) w) (lv a).
1489Definition subst_runs (w : list N) (T : list run) : list run := map (fun r => (fst r, subst_lf w (snd r))) T.
1491Lemma ev_runs_subst nu w T X : ev_runs nu (subst_runs w T) X = ev_runs (zadd nu w) T X.
1492Proof.
1493 unfold subst_runs. induction T as [|[b a] T IH]; cbn; [reflexivity|]. rewrite IH. unfold ev, subst_lf. cbn.
1494 rewrite dot_zadd2. f_equal. f_equal. lia.
1495Qed.
1497Definition lf_scale (k : N) (a : lf) : lf := LF (k * lc a) (map (N.mul k) (lv a)).
1499Lemma dot_scale_l vs : forall k nu, dot (map (N.mul k) vs) nu = (k * dot vs nu)%N.
1500Proof. induction vs as [|x vs IH]; intros k [|y nu]; cbn; try lia. rewrite IH. lia. Qed.
1502Lemma evN_add nu a b : evN nu (lf_add a b) = (evN nu a + evN nu b)%N.
1503Proof. unfold evN, lf_add. cbn. rewrite dot_zadd. lia. Qed.
1505Lemma evN_scale nu k a : evN nu (lf_scale k a) = (k * evN nu a)%N.
1506Proof. unfold evN, lf_scale. cbn. rewrite dot_scale_l. lia. Qed.
1508Fixpoint comp_aux (vs : list N) (sg : list lf) : lf :=
1509 match vs, sg with
1510 | v :: vs', s :: sg' => lf_add (lf_scale v s) (comp_aux vs' sg')
1511 | _, _ => LF 0 []
1512 end.
1513Definition compose_lf (sg : list lf) (a : lf) : lf := lf_add (LF (lc a) []) (comp_aux (lv a) sg).
1514Definition comp_runs (sg : list lf) (T : list run) : list run := map (fun r => (fst r, compose_lf sg (snd r))) T.
1516Lemma evN_comp_aux nu vs : forall sg, evN nu (comp_aux vs sg) = dot vs (map (evN nu) sg).
1517Proof.
1518 induction vs as [|v vs IH]; intros [|s sg]; cbn [comp_aux map dot]; try reflexivity.
1519 rewrite evN_add, evN_scale, IH. lia.
1520Qed.
1522Lemma evN_compose nu sg a : evN nu (compose_lf sg a) = evN (map (evN nu) sg) a.
1523Proof. unfold compose_lf. rewrite evN_add, evN_comp_aux. unfold evN at 1 3. cbn. lia. Qed.
1525Lemma ev_runs_comp nu sg T X : ev_runs nu (comp_runs sg T) X = ev_runs (map (evN nu) sg) T X.
1526Proof.
1527 unfold comp_runs. induction T as [|[b a] T IH]; cbn; [reflexivity|]. rewrite IH. unfold ev.
1528 change (lc (compose_lf sg a) + dot (lv (compose_lf sg a)) nu)%N with (evN nu (compose_lf sg a)).
1529 rewrite evN_compose. reflexivity.
1530Qed.
1532(* ---- the 4-cycle jump (Lemma J) ---- *)
1534Lemma jump_lemma T p dec inc :
1535 (forall nu, EpSeq [p; p; p; p] (evR nu (subst_runs dec T)) (evR nu (subst_runs inc T))) ->
1536 forall k nu, EpSeq (repeat p (4 * k)) (evR (zadd nu (vscale (N.of_nat k) dec)) T)
1537 (evR (zadd nu (vscale (N.of_nat k) inc)) T).
1538Proof.
1539 intros Hc k. induction k as [|k IH]; intros nu.
1540 - cbn [repeat Nat.mul EpSeq]. unfold evR. apply ev_runs_dot. intros v.
1541 rewrite !dot_zadd2, !dot_vscale. lia.
1542 - replace (4 * S k) with (4 + 4 * k) by lia. rewrite repeat_add.
1543 apply (EpSeq_app _ _ _ (evR (zadd (zadd nu inc) (vscale (N.of_nat k) dec)) T)).
1544 + specialize (Hc (zadd nu (vscale (N.of_nat k) dec))). unfold evR in *.
1545 rewrite !ev_runs_subst in Hc.
1546 replace (ev_runs (zadd nu (vscale (N.of_nat (S k)) dec)) T (const S0))
1547 with (ev_runs (zadd (zadd nu (vscale (N.of_nat k) dec)) dec) T (const S0))
1548 by (apply ev_runs_dot; intros v; rewrite !dot_zadd2, !dot_vscale; lia).
1549 replace (ev_runs (zadd (zadd nu inc) (vscale (N.of_nat k) dec)) T (const S0))
1550 with (ev_runs (zadd (zadd nu (vscale (N.of_nat k) dec)) inc) T (const S0))
1551 by (apply ev_runs_dot; intros v; rewrite !dot_zadd2; lia).
1552 exact Hc.
1553 + specialize (IH (zadd nu inc)). unfold evR in *.
1554 replace (ev_runs (zadd nu (vscale (N.of_nat (S k)) inc)) T (const S0))
1555 with (ev_runs (zadd (zadd nu inc) (vscale (N.of_nat k) inc)) T (const S0))
1556 by (apply ev_runs_dot; intros v; rewrite !dot_zadd2, !dot_vscale; lia).
1557 replace (ev_runs (zadd (zadd nu inc) (vscale (N.of_nat k) dec)) T (const S0))
1558 with (ev_runs (zadd (zadd nu inc) (vscale (N.of_nat k) dec)) T (const S0)) by reflexivity.
1559 exact IH.
1560Qed.
1562(* ---- building a jump from the actual configuration ---- *)
1564Definition uvar (i : nat) (c : N) : lf := LF c (repeat 0%N i ++ [4%N]).
1566Fixpoint zsub (a b : list N) : list N :=
1567 match a, b with
1568 | x :: a', y :: b' => (x - y)%N :: zsub a' b'
1569 | _, [] => a
1570 | [], _ => []
1571 end.
1573Fixpoint mk_jump (i : nat) (rr rr4 : list run) (c : lf) : option (list run * list N * list N * list lf) :=
1574 match rr, rr4 with
1575 | [], [] => Some ([], [], [], [])
1576 | (b, a) :: rr', (b4, a4) :: rr4' =>
1577 if negb (seqb b b4) then None else
1578 if negb (listN_eqb (strip0 (lv a)) (strip0 (lv a4))) then None else
1579 match mk_jump (S i) rr' rr4' c with
1580 | None => None
1581 | Some (T, dec, inc, sg) =>
1582 let d := (Z.of_N (lc a4) - Z.of_N (lc a))%Z in
1583 if negb (Z.eqb (Z.modulo d 4) 0) then None else
1584 let q := Z.div d 4 in
1585 if andb (allz (lv a)) (Z.eqb q 0) then
1586 Some ((b, a) :: T, 0%N :: dec, 0%N :: inc, LF 0 [] :: sg)
1587 else if Z.ltb q 0 then
1588 let dn := Z.to_N (- q) in
1589 let M := (lc a - 4 * dn * lc c)%N in
1590 let s := LF 0 (map (fun x => x / 4)%N (zsub (lv a) (map (N.mul (4 * dn)) (lv c)))) in
1591 Some ((b, uvar i M) :: T, dn :: dec, 0%N :: inc, s :: sg)
1592 else
1593 let s := LF 0 (map (fun x => x / 4)%N (lv a)) in
1594 Some ((b, uvar i (lc a)) :: T, 0%N :: dec, Z.to_N q :: inc, s :: sg)
1595 end
1596 | _, _ => None
1597 end.
1599Fixpoint mapadd (c : lf) (sg : list lf) (w : list N) : list lf :=
1600 match sg, w with
1601 | s :: sg', x :: w' => lf_add s (lf_scale x c) :: mapadd c sg' w'
1602 | _, _ => []
1603 end.
1605Lemma mapadd_ev nu c sg : forall w, length sg = length w ->
1606 map (evN nu) (mapadd c sg w) = zadd (map (evN nu) sg) (vscale (evN nu c) w).
1607Proof.
1608 induction sg as [|s sg IH]; intros [|x w] Hl; cbn in Hl; try discriminate; [reflexivity|].
1609 cbn [mapadd map vscale zadd]. injection Hl as Hl. rewrite (IH w Hl). unfold vscale.
1610 f_equal. rewrite evN_add, evN_scale. lia.
1611Qed.
1613Definition cyc4 (p : bool) : list bool := [p; p; p; p].
1615Definition jump_run (p : bool) (c : lf) (rr : list run) : option (list run) :=
1616 match eps (cyc4 p) rr with
1617 | None => None
1618 | Some rr4 =>
1619 match mk_jump 0 rr rr4 c with
1620 | None => None
1621 | Some (T, dec, inc, sg) =>
1622 if andb (Nat.eqb (length sg) (length dec)) (Nat.eqb (length sg) (length inc)) then
1623 match eps (cyc4 p) (subst_runs dec T) with
1624 | None => None
1625 | Some X =>
1626 if andb (runs_eqb X (subst_runs inc T)) (runs_eqb rr (comp_runs (mapadd c sg dec) T))
1627 then Some (comp_runs (mapadd c sg inc) T) else None
1628 end
1629 else None
1630 end
1631 end.
1633Lemma jump_run_spec p c rr rr' : jump_run p c rr = Some rr' ->
1634 forall nu, EpSeq (repeat p (4 * ev nu c)) (evR nu rr) (evR nu rr').
1635Proof.
1636 unfold jump_run. intros H nu.
1637 destruct (eps (cyc4 p) rr) as [rr4|]; [|discriminate].
1638 destruct (mk_jump 0 rr rr4 c) as [[[[T dec] inc] sg]|]; [|discriminate].
1639 destruct (andb (Nat.eqb (length sg) (length dec)) (Nat.eqb (length sg) (length inc))) eqn:El; [|discriminate].
1640 apply andb_prop in El as [El1 El2]. apply Nat.eqb_eq in El1, El2.
1641 destruct (eps (cyc4 p) (subst_runs dec T)) as [X|] eqn:EX; [|discriminate].
1642 destruct (andb (runs_eqb X (subst_runs inc T)) (runs_eqb rr (comp_runs (mapadd c sg dec) T))) eqn:Ec;
1643 [|discriminate].
1644 apply andb_prop in Ec as [Ec1 Ec2]. inversion H; subst rr'; clear H.
1645 assert (Hc : forall nu', EpSeq [p; p; p; p] (evR nu' (subst_runs dec T)) (evR nu' (subst_runs inc T))).
1646 { intros nu'. pose proof (eps_spec _ _ _ EX nu') as HX. unfold evR in *.
1647 rewrite <-(runs_eqb_ev nu' _ _ (const S0) Ec1). exact HX. }
1648 pose proof (jump_lemma T p dec inc Hc (ev nu c) (map (evN nu) sg)) as J.
1649 unfold ev in J at 2 3. rewrite N2Nat.id in J.
1650 unfold evR in *. rewrite (runs_eqb_ev nu _ _ (const S0) Ec2), !ev_runs_comp, !mapadd_ev by assumption.
1651 exact J.
1652Qed.
1654(* ---- programs: single episodes and jumps ---- *)
1656Inductive instr := ISingle (p : bool) | IJump (p : bool) (c : lf).
1658Definition seg : Type := (bool * lf)%type.
1660Fixpoint segs_ev (nu : list N) (ss : list seg) : list bool :=
1661 match ss with [] => [] | (p, n) :: ss' => repeat p (ev nu n) ++ segs_ev nu ss' end.
1663Fixpoint exec (prog : list instr) (rr : list run) : option (list run * list seg) :=
1664 match prog with
1665 | [] => Some (rr, [])
1666 | ISingle p :: prog' =>
1667 match ep_run p rr with
1668 | Some rr1 => match exec prog' rr1 with Some (rr2, ss) => Some (rr2, (p, cn 1) :: ss) | None => None end
1669 | None => None
1670 end
1671 | IJump p c :: prog' =>
1672 match jump_run p c rr with
1673 | Some rr1 => match exec prog' rr1 with Some (rr2, ss) => Some (rr2, (p, lf_scale 4 c) :: ss) | None => None end
1674 | None => None
1675 end
1676 end.
1678Lemma ev_scale4 nu c : ev nu (lf_scale 4 c) = 4 * ev nu c.
1679Proof. unfold ev. change (lc (lf_scale 4 c) + dot (lv (lf_scale 4 c)) nu)%N with (evN nu (lf_scale 4 c)).
1680 rewrite evN_scale. unfold evN. lia. Qed.
1682Lemma exec_spec prog : forall rr rr' ss, exec prog rr = Some (rr', ss) ->
1683 forall nu, EpSeq (segs_ev nu ss) (evR nu rr) (evR nu rr').
1684Proof.
1685 induction prog as [|[p|p c] prog IH]; intros rr rr' ss H nu; cbn [exec] in H.
1686 - inversion H; subst. reflexivity.
1687 - destruct (ep_run p rr) as [rr1|] eqn:E1; [|discriminate].
1688 destruct (exec prog rr1) as [[rr2 ss2]|] eqn:E2; [|discriminate].
1689 inversion H; subst; clear H. cbn [segs_ev].
1690 replace (ev nu (cn 1)) with 1 by reflexivity. cbn [repeat app].
1691 exists (evR nu rr1). split; [apply (ep_run_spec _ _ _ E1) | apply (IH _ _ _ E2)].
1692 - destruct (jump_run p c rr) as [rr1|] eqn:E1; [|discriminate].
1693 destruct (exec prog rr1) as [[rr2 ss2]|] eqn:E2; [|discriminate].
1694 inversion H; subst; clear H. cbn [segs_ev]. rewrite ev_scale4.
1695 apply (EpSeq_app _ _ _ (evR nu rr1)); [apply (jump_run_spec _ _ _ _ E1) | apply (IH _ _ _ E2)].
1696Qed.
1698(* the phase sequence of a program: all c_K + 2 episodes first, then all c_K episodes *)
1699Fixpoint sum_ph (p : bool) (ss : list seg) : lf :=
1700 match ss with
1701 | [] => LF 0 []
1702 | (q, n) :: ss' => if Bool.eqb p q then lf_add n (sum_ph p ss') else sum_ph p ss'
1703 end.
1704Fixpoint split_ok (seen_false : bool) (ss : list seg) : bool :=
1705 match ss with
1706 | [] => true
1707 | (true, _) :: ss' => andb (negb seen_false) (split_ok false ss')
1708 | (false, _) :: ss' => split_ok true ss'
1709 end.
1711Lemma ev_lf_add nu a b : ev nu (lf_add a b) = ev nu a + ev nu b.
1712Proof. apply ev_add. Qed.
1714Lemma split_false ss nu : split_ok true ss = true -> segs_ev nu ss = repeat false (ev nu (sum_ph false ss)).
1715Proof.
1716 induction ss as [|[q n] ss IH]; intros H; [reflexivity|].
1717 destruct q; cbn in H; [discriminate|]. cbn [segs_ev sum_ph Bool.eqb]. rewrite ev_lf_add, repeat_add, IH by exact H.
1718 reflexivity.
1719Qed.
1721Lemma sum_false_true ss : split_ok true ss = true -> sum_ph true ss = LF 0 [] \/ True.
1722Proof. auto. Qed.
1724Lemma split_spec ss nu : split_ok false ss = true ->
1725 segs_ev nu ss = repeat true (ev nu (sum_ph true ss)) ++ repeat false (ev nu (sum_ph false ss)).
1726Proof.
1727 induction ss as [|[q n] ss IH]; intros H; [reflexivity|].
1728 destruct q.
1729 - cbn in H. cbn [segs_ev sum_ph Bool.eqb]. rewrite ev_lf_add, repeat_add, IH by exact H. rewrite app_assoc. reflexivity.
1730 - cbn in H. cbn [segs_ev sum_ph Bool.eqb]. rewrite split_false by exact H.
1731 assert (Et : ev nu (sum_ph true ((false, n) :: ss)) = 0).
1732 { clear IH. cbn [sum_ph Bool.eqb]. revert H. induction ss as [|[q m] ss IH2]; intros H; [reflexivity|].
1733 destruct q; cbn in H; [discriminate|]. cbn [sum_ph Bool.eqb]. apply IH2, H. }
1734 cbn [sum_ph Bool.eqb] in Et. rewrite Et. cbn [repeat app]. rewrite ev_lf_add, repeat_add. reflexivity.
1735Qed.
1737Definition prog_check (prog : list instr) (rs re : list run) (T F : lf) : bool :=
1738 match exec prog rs with
1739 | Some (re', ss) =>
1740 andb (andb (runs_eqb re' re) (split_ok false ss)) (andb (lf_eqb (sum_ph true ss) T) (lf_eqb (sum_ph false ss) F))
1741 | None => false
1742 end.
1744Lemma prog_check_spec prog rs re T F : prog_check prog rs re T F = true ->
1745 forall nu, EpSeq (repeat true (ev nu T) ++ repeat false (ev nu F)) (evR nu rs) (evR nu re).
1746Proof.
1747 unfold prog_check. intros H nu.
1748 destruct (exec prog rs) as [[re' ss]|] eqn:E; [|discriminate].
1749 apply andb_prop in H as [H1 H2]. apply andb_prop in H1 as [H1 H3]. apply andb_prop in H2 as [H2 H4].
1750 pose proof (exec_spec _ _ _ _ E nu) as HE. rewrite (split_spec _ _ H3) in HE.
1751 rewrite (lf_eqb_ev nu _ _ H2), (lf_eqb_ev nu _ _ H4) in HE.
1752 unfold evR in *. rewrite <-(runs_eqb_ev nu _ _ (const S0) H1). exact HE.
1753Qed.
1755(* ===================================================================== *)
1756(* The six interval programs (Appendix B of the write-up), u = 1 + 8 t. *)
1757(* ===================================================================== *)
1759Definition tl1 (c a : N) : lf := LF c [a].
1760Definition Rs_r5 : list run := mkruns S0 [tl1 224492 1796256; tl1 673559 5388768; cn 8; tl1 9836 78732; tl1 1942069 15536448]%N.
1761Definition prog_r5 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 13 ++ [IJump false (tl1 43462 347733)] ++ repeat (ISingle false) 7.
1762Definition Rs_r0 : list run := mkruns S0 [tl1 74804 598752; tl1 224495 1796256; tl1 673560 5388768; tl1 2020752 16166304; cn 4; tl1 521610 4172796; cn 1]%N.
1763Definition prog_r0 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 9 ++ [IJump false (tl1 43463 347733)] ++ repeat (ISingle false) 7.
1764Definition Rs_r1 : list run := mkruns S0 [tl1 2020748 16166304; cn 7; tl1 551120 4408992; tl1 1564809 12518388; cn 2]%N.
1765Definition prog_r1 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 5 ++ [IJump false (tl1 130398 1043199)] ++ repeat (ISingle false) 4.
1766Definition Rs_r2 : list run := mkruns S0 [tl1 8276 66528; tl1 24911 199584; tl1 74808 598752; tl1 224496 1796256; tl1 673559 5388768; tl1 2020751 16166304; cn 8; tl1 29514 236196; tl1 5826224 46609344; cn 2]%N.
1767Definition prog_r2 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 8 ++ [IJump false (tl1 43464 347733)] ++ repeat (ISingle false) 4.
1768Definition Rs_r3 : list run := mkruns S0 [tl1 224492 1796256; tl1 673559 5388768; tl1 2020752 16166304; tl1 6062328 48498912; cn 4; tl1 1564810 12518388]%N.
1769Definition prog_r3 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 9 ++ [IJump false (tl1 130397 1043199)] ++ repeat (ISingle false) 4.
1770Definition Rs_r4 : list run := mkruns S0 [tl1 74804 598752; tl1 224495 1796256; tl1 673560 5388768; tl1 2020752 16166304; tl1 6062327 48498912; cn 7; tl1 1653368 13226976; tl1 4694422 37555164; cn 1]%N.
1771Definition prog_r4 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 6 ++ [IJump false (tl1 130397 1043199)] ++ repeat (ISingle false) 7.
1772Definition Re_r5 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673560 5388768); (S0, tl1 2020752 16166304); (S1, cn 4); (S0, tl1 521602 4172796)]%N.
1773Lemma int_r5 : prog_check prog_r5 Rs_r5 Re_r5 (tl1 3278 26244) (tl1 173868 1390932) = true.
1774Proof. vm_compute. reflexivity. Qed.
1775Definition Re_r0 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, tl1 2020751 16166304); (S1, cn 7); (S1, tl1 551120 4408992); (S0, tl1 1564798 12518388); (S1, cn 1)]%N.
1776Lemma int_r0 : prog_check prog_r0 Rs_r0 Re_r0 (tl1 3278 26244) (tl1 173868 1390932) = true.
1777Proof. vm_compute. reflexivity. Qed.
1778Definition Re_r1 : list run := [(S0, tl1 2020748 16166304); (S1, cn 8); (S0, tl1 29521 236196); (S0, tl1 5826161 46609344); (S0, cn 2)]%N.
1779Lemma int_r1 : prog_check prog_r1 Rs_r1 Re_r1 (tl1 9839 78732) (tl1 521601 4172796) = true.
1780Proof. vm_compute. reflexivity. Qed.
1781Definition Re_r2 : list run := [(S0, tl1 8276 66528); (S1, tl1 24912 199584); (S0, tl1 74808 598752); (S1, tl1 224495 1796256); (S1, tl1 673559 5388768); (S1, tl1 2020752 16166304); (S0, tl1 6062328 48498912); (S1, cn 3); (S1, tl1 1564801 12518388); (S1, cn 1)]%N.
1782Lemma int_r2 : prog_check prog_r2 Rs_r2 Re_r2 (tl1 3278 26244) (tl1 173868 1390932) = true.
1783Proof. vm_compute. reflexivity. Qed.
1784Definition Re_r3 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673560 5388768); (S0, tl1 2020752 16166304); (S1, tl1 6062327 48498912); (S1, cn 7); (S1, tl1 1653368 13226976); (S0, tl1 4694397 37555164); (S0, cn 2)]%N.
1785Lemma int_r3 : prog_check prog_r3 Rs_r3 Re_r3 (tl1 9839 78732) (tl1 521601 4172796) = true.
1786Proof. vm_compute. reflexivity. Qed.
1787Definition Re_r4 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, tl1 2020751 16166304); (S1, tl1 6062327 48498912); (S1, cn 7); (S1, tl1 88573 708588); (S1, tl1 17478488 139828032); (S0, cn 2)]%N.
1788Lemma int_r4 : prog_check prog_r4 Rs_r4 Re_r4 (tl1 9839 78732) (tl1 521601 4172796) = true.
1789Proof. vm_compute. reflexivity. Qed.
1791(* ===================================================================== *)
1792(* The regrouping after the record visit (write-up 6.2): the chain in D2 *)
1793(* is the same tape as a chain in U0 grouped one defect later. *)
1794(* ===================================================================== *)
1796Definition rtop (qs : list (list N)) (z : N) : N :=
1797 match qs with [] => z | q :: _ => nth 0 q 0%N end.
1799Fixpoint rshift (qs : list (list N)) (z : N) : list (list N) :=
1800 match qs with
1801 | [] => []
1802 | q :: qs' => [nth 1 q 0; nth 2 q 0; nth 3 q 0; rtop qs' z]%N :: rshift qs' z
1803 end.
1805Lemma shift_len qs z : length (rshift qs z) = length qs.
1806Proof. induction qs; cbn; congruence. Qed.
1808Lemma dot4 (a b c d : N) q :
1809 dot [a; b; c; d] q = (a * nth 0 q 0 + b * nth 1 q 0 + c * nth 2 q 0 + d * nth 3 q 0)%N.
1810Proof. destruct q as [|x0 [|x1 [|x2 [|x3 q]]]]; cbn; lia. Qed.
1812Lemma alt_split b m k : Nat.eqb (m mod 2) 0 = true -> alt b (m + k) = alt b m ++ alt b k.
1813Proof.
1814 intros H. rewrite alt_add. unfold afterb_nat. rewrite H. reflexivity.
1815Qed.
1817Lemma ev_q nu c a : ev nu (LF c a) = N.to_nat (c + dot a nu).
1818Proof. reflexivity. Qed.
1820Lemma regroup qs : forall z X X',
1821 X = alt S0 1 *> (alt S0 (2 + 4 * N.to_nat z) *> X') ->
1822 chs (repeat D2 (length qs)) qs X =
1823 alt S0 1 *> (alt S0 (2 + 4 * N.to_nat (rtop qs z)) *> chs (repeat U0 (length qs)) (rshift qs z) X').
1824Proof.
1825 induction qs as [|q qs IH]; intros z X X' HX; [exact HX|].
1826 cbn [length repeat chs rshift rtop]. rewrite (IH z X X' HX).
1827 set (Y := chs (repeat U0 (length qs)) (rshift qs z) X').
1828 change (blk D2) with [(S0, cn 1); (S0, vt 5); (S0, vs 4); (S1, va 4); (S0, vl 0)]%N.
1829 change (blk U0) with [(S0, cn 3); (S0, vt 4); (S1, vs 4); (S0, va 1); (S0, vl 2)]%N.
1830 cbn [ev_runs]. unfold ev, vt, vs, va, vl, cn. cbn [lc lv]. rewrite !dot4. cbn [nth dot].
1831 set (xt := nth 0 q 0%N). set (xs := nth 1 q 0%N). set (xa := nth 2 q 0%N). set (xI := nth 3 q 0%N).
1832 set (tz := rtop qs z).
1833 assert (E1 : alt S0 (N.to_nat (5 + (4 * xt + 0 * xs + 0 * xa + 0 * xI))) = alt S0 (2 + 4 * N.to_nat xt) ++ alt S0 3).
1834 { replace (N.to_nat (5 + (4 * xt + 0 * xs + 0 * xa + 0 * xI))) with ((2 + 4 * N.to_nat xt) + 3) by lia.
1835 apply alt_split. apply Nat.eqb_eq. replace (2 + 4 * N.to_nat xt) with (2 + N.to_nat xt * 2 * 2) by lia.
1836 rewrite Nat.Div0.mod_add. reflexivity. }
1837 assert (E2 : alt S0 (N.to_nat (1 + (0 * xs + 0 * xa + 4 * xI + 0 * tz))) = alt S0 (N.to_nat (0 + (0 * xt + 0 * xs + 0 * xa + 4 * xI))) ++ alt S0 1).
1838 { replace (N.to_nat (1 + (0 * xs + 0 * xa + 4 * xI + 0 * tz))) with (N.to_nat (0 + (0 * xt + 0 * xs + 0 * xa + 4 * xI)) + 1) by lia.
1839 apply alt_split. apply Nat.eqb_eq. replace (N.to_nat (0 + (0 * xt + 0 * xs + 0 * xa + 4 * xI))) with (0 + N.to_nat xI * 2 * 2) by lia.
1840 rewrite Nat.Div0.mod_add. reflexivity. }
1841 rewrite E1, E2, !Str_app_assoc. cbn [alt Str_app app].
1842 replace (N.to_nat (2 + (0 * xs + 0 * xa + 0 * xI + 4 * tz))) with (2 + 4 * N.to_nat tz) by lia.
1843 replace (N.to_nat (4 + (4 * xs + 0 * xa + 0 * xI + 0 * tz))) with (N.to_nat (4 + (0 * xt + 4 * xs + 0 * xa + 0 * xI))) by lia.
1844 replace (N.to_nat (4 + (0 * xs + 4 * xa + 0 * xI + 0 * tz))) with (N.to_nat (4 + (0 * xt + 0 * xs + 4 * xa + 0 * xI))) by lia.
1845 reflexivity.
1846Qed.
1848(* block 1 and the left word after the left record, regrouped *)
1849Lemma regroup_b1 : b1s PD2 (LWs 81) = alt S0 1 *> (alt S0 (2 + 4 * N.to_nat 0) *> b1s P0 (LWs 0)).
1850Proof. reflexivity. Qed.
1852(* ===================================================================== *)
1853(* Lemma S: one record interval, class by class. *)
1854(* ===================================================================== *)
1856Lemma drop_step L Re Rs nu X' :
1857 reach 100000 (Rc B (L, TV 0) (Re, T0)) (Lc D ([], TV 0) (Rs, T0)) = true ->
1858 ev_runs nu L X' {{B}}> evR nu Re -->+ X' <{{D}} evR nu Rs.
1859Proof. intros H. exact (reach_spec _ _ _ H nu (fun _ => X')). Qed.
1861Definition W5t (t : N) : N := (18701 + 149688 * t)%N.
1862Definition W5s (t : N) : N := (6227 + 49896 * t)%N.
1863Definition W5a (t : N) : N := (2069 + 16632 * t)%N.
1865Lemma rec_r5_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 74806 598752)], TV 0) (Re_r5, T0)) (Lc D ([], TV 0) (Rs_r0, T0)) = true.
1866Proof. vm_compute. reflexivity. Qed.
1868Lemma step_r5 t f1 deep :
1869 chs (repeat D2 (S (length deep))) ([W5t t; W5s t; W5a t; f1] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r5 -->+
1870 Gc (repeat U0 (S (length deep)), P0, 0) ([W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r0).
1871Proof.
1872 pose proof (regroup ([W5t t; W5s t; W5a t; f1] :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
1873 cbn [length] in E. rewrite E. clear E. cbn [rtop rshift nth Gc].
1874 set (X' := chs (repeat U0 (S (length deep))) ([W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N) (b1s P0 (LWs 0))).
1875 replace (2 + 4 * N.to_nat (W5t t)) with (ev [t] (tl1 74806 598752)) by (unfold ev, W5t, tl1; cbn [lc lv dot]; lia).
1876 change (alt S0 1 *> (alt S0 (ev [t] (tl1 74806 598752)) *> X')) with (ev_runs [t] [(S0, cn 1); (S0, tl1 74806 598752)] X').
1877 apply drop_step, rec_r5_ok.
1878Qed.
1880Lemma pow_K0 k0 e : 2 <= e -> 3 ^ (k0 + 2 * e) = 3 ^ (k0 + 4) * 9 ^ (e - 2).
1881Proof.
1882 intros He. replace (k0 + 2 * e) with ((k0 + 4) + 2 * (e - 2)) by lia.
1883 rewrite Nat.pow_add_r, Nat.pow_mul_r. reflexivity.
1884Qed.
1886(* one record interval of class r5 *)
1887Lemma S_r5 e t f1 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
1888 Gc (repeat U0 (S (length deep)), P0, 0) ([W5t t; W5s t; W5a t; f1] :: deep) (evR [t] Rs_r5) -->+
1889 Gc (repeat U0 (S (length deep)), P0, 0) ([W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r0).
1890Proof.
1891 intros He Ht Hl.
1892 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
1893 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r5 [t]) as HP.
1894 assert (E3 : 3 ^ S (S (S (length deep))) = 81 * 81 * (1 + 8 * N.to_nat t)).
1895 { rewrite Ht, Hl. replace (S (S (S (1 + 2 * e)))) with (4 + 2 * e) by lia.
1896 rewrite pow_K0 by exact He. reflexivity. }
1897 assert (E2 : 3 ^ S (S (length deep)) = 27 * 81 * (1 + 8 * N.to_nat t)).
1898 { rewrite Ht, Hl. replace (S (S (1 + 2 * e))) with (3 + 2 * e) by lia.
1899 rewrite pow_K0 by exact He. reflexivity. }
1900 rewrite E3 in ET. rewrite E2.
1901 replace T with (ev [t] (tl1 3278 26244)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
1902 replace (81 * (27 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 3278 26244)) with (ev [t] (tl1 173868 1390932))
1903 by (unfold ev, tl1; cbn [lc lv dot]; lia).
1904 exact HP.
1905 - eapply progress_trans; [apply record_visit; reflexivity|].
1906 apply step_r5.
1907Qed.
1909Definition wv (c a t : N) : N := (c + a * t)%N.
1911Lemma evN_tl1 c a t : evN [t] (tl1 c a) = wv c a t.
1912Proof. unfold evN, tl1, wv. cbn [lc lv dot]. lia. Qed.
1914Lemma take_step L first4 Re' Rs nu sg X' :
1915 reach 100000 (Rc B (L, TV 0) (first4, TV 1)) (Rc A (comp_runs sg (blk U0), TV 0) ([], TV 1)) = true ->
1916 ep_run true Re' = Some Rs ->
1917 ev_runs nu L X' {{B}}> ev_runs nu first4 (evR nu Re') -->+
1918 ev_runs (map (evN nu) sg) (blk U0) X' <{{D}} evR nu Rs.
1919Proof.
1920 intros H1 H2. eapply progress_evstep_trans.
1921 - exact (reach_spec _ _ _ H1 nu (sg2 X' (evR nu Re'))).
1922 - change (ev_runs nu (comp_runs sg (blk U0)) X' {{A}}> evR nu Re' -->*
1923 ev_runs (map (evN nu) sg) (blk U0) X' <{{D}} evR nu Rs).
1924 rewrite ev_runs_comp. apply (ep_run_spec _ _ _ H2 nu).
1925Qed.
1927Lemma split4 nu r1 r2 r3 b c v rest X :
1928 ev_runs nu (r1 :: r2 :: r3 :: (b, LF (3 + c) v) :: rest) X =
1929 ev_runs nu [r1; r2; r3; (b, cn 3)] (ev_runs nu ((sneg b, LF c v) :: rest) X).
1930Proof.
1931 destruct r1 as [b1 n1], r2 as [b2 n2], r3 as [b3 n3]. cbn [ev_runs].
1932 assert (E : alt b (ev nu (LF (3 + c) v)) = alt b 3 ++ alt (sneg b) (ev nu (LF c v))).
1933 { unfold ev. cbn [lc lv].
1934 replace (N.to_nat (3 + c + dot v nu)) with (3 + N.to_nat (c + dot v nu)) by lia.
1935 rewrite alt_add. reflexivity. }
1936 rewrite E, Str_app_assoc. reflexivity.
1937Qed.
1939(* ---------- r0 -> r1 (take in x1, x2, x3) ---------- *)
1941Definition W0t := wv 6227 49896.
1942Definition W0s := wv 2069 16632.
1943Definition W1t := wv 168389 1347192.
1944Definition W1s := wv 56123 449064.
1945Definition W1a := wv 18701 149688.
1946Definition W1I := wv 6227 49896.
1947Definition W1u := wv 2069 16632. (* t gap of block K-1 *)
1949Definition sig01 : list lf := [tl1 168389 1347192; tl1 56123 449064; tl1 18701 149688; tl1 6227 49896]%N.
1950Definition f4_r0 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, cn 3)]%N.
1951Definition Rp_r0 : list run := [(S0, tl1 2020748 16166304); (S1, cn 7); (S1, tl1 551120 4408992); (S0, tl1 1564798 12518388); (S1, cn 1)]%N.
1953Lemma rec_r0a : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 24910 199584)], TV 0) (f4_r0, TV 1))
1954 (Rc A (comp_runs sig01 (blk U0), TV 0) ([], TV 1)) = true.
1955Proof. vm_compute. reflexivity. Qed.
1956Lemma rec_r0b : ep_run true Rp_r0 = Some Rs_r1.
1957Proof. vm_compute. reflexivity. Qed.
1959Lemma split_r0 t : evR [t] Re_r0 = ev_runs [t] f4_r0 (evR [t] Rp_r0).
1960Proof.
1961 unfold evR, Re_r0, f4_r0, Rp_r0, tl1.
1962 change (2020751)%N with (3 + 2020748)%N. rewrite split4. reflexivity.
1963Qed.
1965Lemma step_r0 t f1 f2 deep :
1966 chs (repeat D2 (S (length deep))) ([W0t t; W0s t; f1; f2] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r0 -->+
1967 Gc (repeat U0 (S (S (length deep))), P0, 0)
1968 ([W1t t; W1s t; W1a t; W1I t] :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r1).
1969Proof.
1970 pose proof (regroup ([W0t t; W0s t; f1; f2] :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
1971 cbn [length] in E. rewrite E. clear E. cbn [rtop rshift nth Gc].
1972 set (X' := chs (repeat U0 (S (length deep))) ([W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N) (b1s P0 (LWs 0))).
1973 replace (2 + 4 * N.to_nat (W0t t)) with (ev [t] (tl1 24910 199584)) by (unfold ev, W0t, wv, tl1; cbn [lc lv dot]; lia).
1974 change (alt S0 1 *> (alt S0 (ev [t] (tl1 24910 199584)) *> X')) with (ev_runs [t] [(S0, cn 1); (S0, tl1 24910 199584)] X').
1975 rewrite split_r0.
1976 replace [W1t t; W1s t; W1a t; W1I t] with (map (evN [t]) sig01)
1977 by (unfold sig01; cbn [map]; rewrite !evN_tl1; reflexivity).
1978 change (chs (repeat U0 (S (S (length deep)))) (map (evN [t]) sig01 :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N)
1979 (b1s P0 (LWs 0))) with (ev_runs (map (evN [t]) sig01) (blk U0) X').
1980 apply take_step; [exact rec_r0a | exact rec_r0b].
1981Qed.
1983(* ---------- r3 -> r4 (drop 1) ---------- *)
1985Definition W3t := wv 18701 149688.
1987Lemma rec_r3_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 74806 598752)], TV 0) (Re_r3, T0)) (Lc D ([], TV 0) (Rs_r4, T0)) = true.
1988Proof. vm_compute. reflexivity. Qed.
1990Lemma step_r3 t f1 f2 f3 deep :
1991 chs (repeat D2 (S (length deep))) ([W3t t; f1; f2; f3] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r3 -->+
1992 Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r4).
1993Proof.
1994 pose proof (regroup ([W3t t; f1; f2; f3] :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
1995 cbn [length] in E. rewrite E. clear E. cbn [rtop rshift nth Gc].
1996 set (X' := chs (repeat U0 (S (length deep))) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (b1s P0 (LWs 0))).
1997 replace (2 + 4 * N.to_nat (W3t t)) with (ev [t] (tl1 74806 598752)) by (unfold ev, W3t, wv, tl1; cbn [lc lv dot]; lia).
1998 change (alt S0 1 *> (alt S0 (ev [t] (tl1 74806 598752)) *> X')) with (ev_runs [t] [(S0, cn 1); (S0, tl1 74806 598752)] X').
1999 apply drop_step, rec_r3_ok.
2000Qed.
2002(* ---------- r1 -> r2 (drop 5) ---------- *)
2004Definition sig12 : list lf := [tl1 56123 449064; tl1 18701 149688; tl1 6227 49896; tl1 2069 16632]%N.
2006Lemma rec_r1_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 673558 5388768)] ++ comp_runs sig12 (blk U0), TV 0) (Re_r1, T0))
2007 (Lc D ([], TV 0) (Rs_r2, T0)) = true.
2008Proof. vm_compute. reflexivity. Qed.
2010Lemma step_r1 t f1 f2 f3 deep :
2011 chs (repeat D2 (S (S (length deep)))) ([W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep) (b1s PD2 (LWs 81))
2012 {{B}}> evR [t] Re_r1 -->+
2013 Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r2).
2014Proof.
2015 pose proof (regroup ([W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
2016 cbn [length] in E. rewrite E. clear E. cbn [rtop rshift nth Gc].
2017 set (X' := chs (repeat U0 (S (length deep))) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (b1s P0 (LWs 0))).
2018 change (chs (repeat U0 (S (S (length deep)))) ([W1s t; W1a t; W1I t; W1u t] :: [f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N)
2019 (b1s P0 (LWs 0))) with (ev_runs [W1s t; W1a t; W1I t; W1u t] (blk U0) X').
2020 replace [W1s t; W1a t; W1I t; W1u t] with (map (evN [t]) sig12) by (unfold sig12; cbn [map]; rewrite !evN_tl1; reflexivity).
2021 rewrite <-ev_runs_comp.
2022 replace (2 + 4 * N.to_nat (W1t t)) with (ev [t] (tl1 673558 5388768)) by (unfold ev, W1t, wv, tl1; cbn [lc lv dot]; lia).
2023 change (alt S0 1 *> (alt S0 (ev [t] (tl1 673558 5388768)) *> ev_runs [t] (comp_runs sig12 (blk U0)) X'))
2024 with (ev_runs [t] ([(S0, cn 1); (S0, tl1 673558 5388768)] ++ comp_runs sig12 (blk U0)) X').
2025 apply drop_step, rec_r1_ok.
2026Qed.
2028(* ---------- r2 -> r3 (take in x1, x2, x3; the last t gap of the chain is free) ---------- *)
2030Definition xv : lf := LF 2 [0; 4]%N.
2031Definition sig23 : list lf := [tl1 18701 149688; tl1 6227 49896; tl1 2069 16632; LF 0 [0; 1]]%N.
2032Definition f4_r2 : list run := [(S0, tl1 8276 66528); (S1, tl1 24912 199584); (S0, tl1 74808 598752); (S1, cn 3)]%N.
2033Definition Rp_r2 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673559 5388768); (S1, tl1 2020752 16166304);
2034 (S0, tl1 6062328 48498912); (S1, cn 3); (S1, tl1 1564801 12518388); (S1, cn 1)]%N.
2036Lemma rec_r2a : reach 100000 (Rc B ([(S0, cn 1); (S0, xv)], TV 0) (f4_r2, TV 1))
2037 (Rc A (comp_runs sig23 (blk U0), TV 0) ([], TV 1)) = true.
2038Proof. vm_compute. reflexivity. Qed.
2039Lemma rec_r2b : ep_run true Rp_r2 = Some Rs_r3.
2040Proof. vm_compute. reflexivity. Qed.
2042Lemma split_r2 nu : evR nu Re_r2 = ev_runs nu f4_r2 (evR nu Rp_r2).
2043Proof.
2044 unfold evR, Re_r2, f4_r2, Rp_r2, tl1.
2045 change (224495)%N with (3 + 224492)%N. rewrite split4. reflexivity.
2046Qed.
2048Lemma step_r2 t q deep :
2049 chs (repeat D2 (S (length deep))) (q :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r2 -->+
2050 Gc (repeat U0 (S (S (length deep))), P0, 0)
2051 ([W3t t; wv 6227 49896 t; wv 2069 16632 t; nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [t] Rs_r3).
2052Proof.
2053 pose proof (regroup (q :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
2054 cbn [length] in E. rewrite E. clear E. cbn [rtop Gc].
2055 set (xK := nth 0 q 0%N).
2056 set (X' := chs (repeat U0 (S (length deep))) (rshift (q :: deep) 0%N) (b1s P0 (LWs 0))).
2057 replace (evR [t] Re_r2) with (evR [t; xK] Re_r2) by reflexivity.
2058 replace (evR [t] Rs_r3) with (evR [t; xK] Rs_r3) by reflexivity.
2059 replace (2 + 4 * N.to_nat xK) with (ev [t; xK] xv) by (unfold ev, xv; cbn [lc lv dot]; lia).
2060 change (alt S0 1 *> (alt S0 (ev [t; xK] xv) *> X')) with (ev_runs [t; xK] [(S0, cn 1); (S0, xv)] X').
2061 replace [W3t t; wv 6227 49896 t; wv 2069 16632 t; xK] with (map (evN [t; xK]) sig23)
2062 by (unfold sig23, W3t, wv, tl1, evN; cbn [map lc lv dot]; f_equal; [lia|f_equal; [lia|f_equal; [lia|f_equal; lia]]]).
2063 change (chs (repeat U0 (S (S (length deep)))) (map (evN [t; xK]) sig23 :: rshift (q :: deep) 0%N) (b1s P0 (LWs 0)))
2064 with (ev_runs (map (evN [t; xK]) sig23) (blk U0) X').
2065 rewrite split_r2.
2066 apply take_step; [exact rec_r2a | exact rec_r2b].
2067Qed.
2069(* ---------- r4 -> r5 (take in x1, x2, x3; next epoch, u -> 9 u, t -> 1 + 9 t) ---------- *)
2071Definition sub9_lf (l : lf) : lf := match lv l with [a] => LF (lc l + a) [9 * a] | _ => l end%N.
2072Definition sub9 (rs : list run) : list run := map (fun r => (fst r, sub9_lf (snd r))) rs.
2074Lemma ev_runs_sub9 t rs X : forallb (fun r => Nat.leb (length (lv (snd r))) 1) rs = true ->
2075 ev_runs [t] (sub9 rs) X = ev_runs [(1 + 9 * t)%N] rs X.
2076Proof.
2077 unfold sub9. induction rs as [|[b l] rs IH]; intros H; [reflexivity|].
2078 cbn [forallb] in H. apply andb_prop in H as [H1 H2]. cbn [map ev_runs fst snd]. rewrite IH by exact H2.
2079 f_equal. f_equal. unfold sub9_lf, ev. destruct l as [c [|a [|a' v]]]; cbn [lc lv dot length Nat.leb] in *; [reflexivity | f_equal; ring | discriminate].
2080Qed.
2082Lemma evR_sub9_r5 t : evR [t] (sub9 Rs_r5) = evR [(1 + 9 * t)%N] Rs_r5.
2083Proof. unfold evR. apply ev_runs_sub9. reflexivity. Qed.
2085Definition sig45 : list lf := [tl1 168389 1347192; tl1 56123 449064; tl1 18701 149688; LF 0 [0; 1]]%N.
2086Definition f4_r4 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, cn 3)]%N.
2087Definition Rp_r4 : list run := [(S0, tl1 2020748 16166304); (S1, tl1 6062327 48498912); (S1, cn 7);
2088 (S1, tl1 88573 708588); (S1, tl1 17478488 139828032); (S0, cn 2)]%N.
2090Lemma rec_r4a : reach 100000 (Rc B ([(S0, cn 1); (S0, xv)], TV 0) (f4_r4, TV 1))
2091 (Rc A (comp_runs sig45 (blk U0), TV 0) ([], TV 1)) = true.
2092Proof. vm_compute. reflexivity. Qed.
2093Lemma rec_r4b : ep_run true Rp_r4 = Some (sub9 Rs_r5).
2094Proof. vm_compute. reflexivity. Qed.
2096Lemma split_r4 nu : evR nu Re_r4 = ev_runs nu f4_r4 (evR nu Rp_r4).
2097Proof.
2098 unfold evR, Re_r4, f4_r4, Rp_r4, tl1.
2099 change (2020751)%N with (3 + 2020748)%N. rewrite split4. reflexivity.
2100Qed.
2102Lemma step_r4 t q deep :
2103 chs (repeat D2 (S (length deep))) (q :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r4 -->+
2104 Gc (repeat U0 (S (S (length deep))), P0, 0)
2105 ([W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); nth 0 q 0%N] :: rshift (q :: deep) 0%N)
2106 (evR [(1 + 9 * t)%N] Rs_r5).
2107Proof.
2108 pose proof (regroup (q :: deep) 0%N _ (b1s P0 (LWs 0)) regroup_b1) as E.
2109 cbn [length] in E. rewrite E. clear E. cbn [rtop Gc].
2110 set (xK := nth 0 q 0%N).
2111 set (X' := chs (repeat U0 (S (length deep))) (rshift (q :: deep) 0%N) (b1s P0 (LWs 0))).
2112 replace (evR [t] Re_r4) with (evR [t; xK] Re_r4) by reflexivity.
2113 rewrite <-evR_sub9_r5.
2114 replace (evR [t] (sub9 Rs_r5)) with (evR [t; xK] (sub9 Rs_r5)) by reflexivity.
2115 replace (2 + 4 * N.to_nat xK) with (ev [t; xK] xv) by (unfold ev, xv; cbn [lc lv dot]; lia).
2116 change (alt S0 1 *> (alt S0 (ev [t; xK] xv) *> X')) with (ev_runs [t; xK] [(S0, cn 1); (S0, xv)] X').
2117 replace [W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); xK] with (map (evN [t; xK]) sig45)
2118 by (unfold sig45, W5t, W5s, W5a, tl1, evN; cbn [map lc lv dot]; f_equal; [lia|f_equal; [lia|f_equal; [lia|f_equal; lia]]]).
2119 change (chs (repeat U0 (S (S (length deep)))) (map (evN [t; xK]) sig45 :: rshift (q :: deep) 0%N) (b1s P0 (LWs 0)))
2120 with (ev_runs (map (evN [t; xK]) sig45) (blk U0) X').
2121 rewrite split_r4.
2122 apply take_step; [exact rec_r4a | exact rec_r4b].
2123Qed.
2125Lemma S_r0 e t f1 f2 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
2126 Gc (repeat U0 (S (length deep)), P0, 0) ([W0t t; W0s t; f1; f2] :: deep) (evR [t] Rs_r0) -->+
2127 Gc (repeat U0 (S (S (length deep))), P0, 0) ([W1t t; W1s t; W1a t; W1I t] :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r1).
2128Proof.
2129 intros He Ht Hl.
2130 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
2131 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r0 [t]) as HP.
2132 assert (E3 : 3 ^ S (S (S (length deep))) = 81 * 81 * (1 + 8 * N.to_nat t)).
2133 { rewrite Ht, Hl. replace (S (S (S (1 + 2 * e)))) with (4 + 2 * e) by lia.
2134 rewrite pow_K0 by exact He. reflexivity. }
2135 assert (E2 : 3 ^ S (S (length deep)) = 27 * 81 * (1 + 8 * N.to_nat t)).
2136 { rewrite Ht, Hl. replace (S (S (1 + 2 * e))) with (3 + 2 * e) by lia.
2137 rewrite pow_K0 by exact He. reflexivity. }
2138 rewrite E3 in ET. rewrite E2.
2139 replace T with (ev [t] (tl1 3278 26244)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
2140 replace (81 * (27 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 3278 26244)) with (ev [t] (tl1 173868 1390932))
2141 by (unfold ev, tl1; cbn [lc lv dot]; lia).
2142 exact HP.
2143 - eapply progress_trans; [apply record_visit; reflexivity|].
2144 apply step_r0.
2145Qed.
2147Lemma S_r1 e t f1 f2 f3 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
2148 Gc (repeat U0 (S (S (length deep))), P0, 0) ([W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep) (evR [t] Rs_r1) -->+
2149 Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r2).
2150Proof.
2151 intros He Ht Hl.
2152 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
2153 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r1 [t]) as HP.
2154 assert (E3 : 3 ^ S (S (S (S (length deep)))) = 243 * 81 * (1 + 8 * N.to_nat t)).
2155 { rewrite Ht, Hl. replace (S (S (S (S (1 + 2 * e))))) with (5 + 2 * e) by lia.
2156 rewrite pow_K0 by exact He. reflexivity. }
2157 assert (E2 : 3 ^ S (S (S (length deep))) = 81 * 81 * (1 + 8 * N.to_nat t)).
2158 { rewrite Ht, Hl. replace (S (S (S (1 + 2 * e)))) with (4 + 2 * e) by lia.
2159 rewrite pow_K0 by exact He. reflexivity. }
2160 rewrite E3 in ET. rewrite E2.
2161 replace T with (ev [t] (tl1 9839 78732)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
2162 replace (81 * (81 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 9839 78732)) with (ev [t] (tl1 521601 4172796))
2163 by (unfold ev, tl1; cbn [lc lv dot]; lia).
2164 exact HP.
2165 - eapply progress_trans; [apply record_visit; reflexivity|].
2166 apply step_r1.
2167Qed.
2169Lemma S_r2 e t q deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
2170 Gc (repeat U0 (S (length deep)), P0, 0) (q :: deep) (evR [t] Rs_r2) -->+
2171 Gc (repeat U0 (S (S (length deep))), P0, 0) ([W3t t; wv 6227 49896 t; wv 2069 16632 t; nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [t] Rs_r3).
2172Proof.
2173 intros He Ht Hl.
2174 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
2175 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r2 [t]) as HP.
2176 assert (E3 : 3 ^ S (S (S (length deep))) = 81 * 81 * (1 + 8 * N.to_nat t)).
2177 { rewrite Ht, Hl. replace (S (S (S (1 + 2 * e)))) with (4 + 2 * e) by lia.
2178 rewrite pow_K0 by exact He. reflexivity. }
2179 assert (E2 : 3 ^ S (S (length deep)) = 27 * 81 * (1 + 8 * N.to_nat t)).
2180 { rewrite Ht, Hl. replace (S (S (1 + 2 * e))) with (3 + 2 * e) by lia.
2181 rewrite pow_K0 by exact He. reflexivity. }
2182 rewrite E3 in ET. rewrite E2.
2183 replace T with (ev [t] (tl1 3278 26244)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
2184 replace (81 * (27 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 3278 26244)) with (ev [t] (tl1 173868 1390932))
2185 by (unfold ev, tl1; cbn [lc lv dot]; lia).
2186 exact HP.
2187 - eapply progress_trans; [apply record_visit; reflexivity|].
2188 apply step_r2.
2189Qed.
2191Lemma S_r3 e t f1 f2 f3 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 2 + 2 * e ->
2192 Gc (repeat U0 (S (length deep)), P0, 0) ([W3t t; f1; f2; f3] :: deep) (evR [t] Rs_r3) -->+
2193 Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r4).
2194Proof.
2195 intros He Ht Hl.
2196 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
2197 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r3 [t]) as HP.
2198 assert (E3 : 3 ^ S (S (S (length deep))) = 243 * 81 * (1 + 8 * N.to_nat t)).
2199 { rewrite Ht, Hl. replace (S (S (S (2 + 2 * e)))) with (5 + 2 * e) by lia.
2200 rewrite pow_K0 by exact He. reflexivity. }
2201 assert (E2 : 3 ^ S (S (length deep)) = 81 * 81 * (1 + 8 * N.to_nat t)).
2202 { rewrite Ht, Hl. replace (S (S (2 + 2 * e))) with (4 + 2 * e) by lia.
2203 rewrite pow_K0 by exact He. reflexivity. }
2204 rewrite E3 in ET. rewrite E2.
2205 replace T with (ev [t] (tl1 9839 78732)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
2206 replace (81 * (81 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 9839 78732)) with (ev [t] (tl1 521601 4172796))
2207 by (unfold ev, tl1; cbn [lc lv dot]; lia).
2208 exact HP.
2209 - eapply progress_trans; [apply record_visit; reflexivity|].
2210 apply step_r3.
2211Qed.
2213Lemma S_r4 e t q deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 2 + 2 * e ->
2214 Gc (repeat U0 (S (length deep)), P0, 0) (q :: deep) (evR [t] Rs_r4) -->+
2215 Gc (repeat U0 (S (S (length deep))), P0, 0) ([W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [(1 + 9 * t)%N] Rs_r5).
2216Proof.
2217 intros He Ht Hl.
2218 eapply evstep_progress_trans; [apply interval_tm; [lia | reflexivity |]|].
2219 - intros T ET. pose proof (prog_check_spec _ _ _ _ _ int_r4 [t]) as HP.
2220 assert (E3 : 3 ^ S (S (S (length deep))) = 243 * 81 * (1 + 8 * N.to_nat t)).
2221 { rewrite Ht, Hl. replace (S (S (S (2 + 2 * e)))) with (5 + 2 * e) by lia.
2222 rewrite pow_K0 by exact He. reflexivity. }
2223 assert (E2 : 3 ^ S (S (length deep)) = 81 * 81 * (1 + 8 * N.to_nat t)).
2224 { rewrite Ht, Hl. replace (S (S (2 + 2 * e))) with (4 + 2 * e) by lia.
2225 rewrite pow_K0 by exact He. reflexivity. }
2226 rewrite E3 in ET. rewrite E2.
2227 replace T with (ev [t] (tl1 9839 78732)) by (unfold ev, tl1; cbn [lc lv dot]; lia).
2228 replace (81 * (81 * 81 * (1 + 8 * N.to_nat t)) - 1 - ev [t] (tl1 9839 78732)) with (ev [t] (tl1 521601 4172796))
2229 by (unfold ev, tl1; cbn [lc lv dot]; lia).
2230 exact HP.
2231 - eapply progress_trans; [apply record_visit; reflexivity|].
2232 apply step_r4.
2233Qed.
2235(* ===================================================================== *)
2236(* Base case: the blank tape reaches record exit 28. *)
2237(* ===================================================================== *)
2239Definition cfg28 : cfg :=
2240 Rc B
2241 ([(S0, cn 74808); (S1, cn 24912); (S0, cn 8277); (S0, cn 2737); (S0, cn 972); (S1, cn 36);
2242 (S0, cn 37); (S0, cn 37); (S0, cn 44); (S1, cn 24); (S0, cn 13); (S0, cn 9);
2243 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5);
2244 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 6); (S1, cn 4); (S0, cn 1);
2245 (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 2)], T0)
2246 ([(S1, cn 224495); (S1, cn 673559); (S1, cn 7); (S1, cn 9841); (S1, cn 1942040); (S0, cn 2)], T0).
2248(* The run from the blank tape to record exit 28, in 38 pieces of at most 500,000 simulator
2249 steps (each piece is one computation; intermediate configurations written out). *)
2250Definition mkc (rc : bool) (q : Q) (l r : list (Sym * N)) : cfg :=
2251 let f := map (fun x : Sym * N => (fst x, cn (snd x))) in
2252 if rc then Rc q (f l, T0) (f r, T0) else Lc q (f l, T0) (f r, T0).
2253Definition b28_0 : cfg := mkc true A [] [].
2254Definition b28_1 : cfg := mkc true F [(S0, 1%N); (S0, 5003%N); (S0, 9%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 21%N); (S0, 17%N); (S0, 8%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 34783%N); (S0, 2%N)].
2255Definition b28_2 : cfg := mkc false C [(S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S0, 2734%N); (S1, 8280%N); (S0, 24912%N); (S1, 74807%N); (S1, 7%N); (S1, 20408%N); (S0, 18958%N); (S1, 1%N)].
2256Definition b28_3 : cfg := mkc false E [(S0, 24913%N); (S0, 8280%N); (S1, 2736%N); (S0, 969%N); (S0, 37%N); (S0, 40%N); (S1, 36%N); (S0, 41%N); (S0, 25%N); (S0, 16%N); (S1, 8%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 74805%N); (S1, 8%N); (S0, 15237%N); (S0, 102601%N); (S0, 2%N)].
2257Definition b28_4 : cfg := mkc true B [(S1, 8%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 16%N); (S1, 23%N); (S1, 43%N); (S1, 36%N); (S0, 40%N); (S1, 35%N); (S1, 971%N); (S1, 2736%N); (S0, 8280%N); (S1, 24911%N); (S1, 74807%N); (S1, 8%N); (S0, 2576%N); (S1, 203893%N)].
2258Definition b28_5 : cfg := mkc false D [(S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 23%N); (S0, 15%N); (S0, 8%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 4%N); (S0, 47814%N); (S1, 1%N)].
2259Definition b28_6 : cfg := mkc false D [(S1, 55470%N); (S0, 61233%N); (S0, 7%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
2260Definition b28_7 : cfg := mkc true B [(S1, 61232%N); (S0, 5%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 126903%N); (S1, 1%N)].
2261Definition b28_8 : cfg := mkc true A [(S0, 204457%N); (S0, 58637%N); (S0, 9%N); (S0, 224494%N); (S1, 74808%N); (S0, 24912%N); (S1, 8280%N); (S0, 2735%N); (S0, 971%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
2262Definition b28_9 : cfg := mkc true B [(S1, 45980%N); (S0, 9%N); (S0, 224494%N); (S1, 74808%N); (S0, 24912%N); (S1, 8280%N); (S0, 2734%N); (S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 7%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N); (S1, 305726%N); (S0, 2%N)].
2263Definition b28_10 : cfg := mkc true B [(S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 5%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S0, 36%N); (S1, 971%N); (S1, 2735%N); (S1, 8280%N); (S0, 24912%N); (S1, 74807%N); (S1, 224495%N); (S1, 8%N); (S0, 33320%N); (S1, 407005%N)].
2264Definition b28_11 : cfg := mkc true B [(S0, 20664%N); (S1, 8%N); (S0, 224495%N); (S0, 74807%N); (S0, 24912%N); (S1, 8280%N); (S0, 2734%N); (S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 33%N); (S0, 45%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 508270%N); (S0, 2%N)].
2265Definition b28_12 : cfg := mkc false D [(S1, 8%N); (S0, 224493%N); (S0, 74809%N); (S0, 24912%N); (S1, 8280%N); (S0, 2733%N); (S0, 973%N); (S0, 36%N); (S1, 40%N); (S0, 33%N); (S0, 45%N); (S0, 24%N); (S1, 16%N); (S0, 7%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 8001%N); (S0, 609553%N); (S0, 2%N)].
2266Definition b28_13 : cfg := mkc true B [(S1, 224496%N); (S0, 74805%N); (S0, 24913%N); (S0, 8280%N); (S1, 2736%N); (S0, 970%N); (S1, 36%N); (S0, 40%N); (S1, 36%N); (S0, 41%N); (S0, 25%N); (S0, 16%N); (S1, 8%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 673560%N); (S1, 4%N); (S0, 22085%N); (S0, 2%N)].
2267Definition b28_14 : cfg := mkc false D [(S0, 74806%N); (S1, 24912%N); (S0, 8280%N); (S1, 2736%N); (S0, 971%N); (S0, 35%N); (S0, 40%N); (S1, 36%N); (S0, 43%N); (S0, 23%N); (S0, 16%N); (S1, 8%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 224496%N); (S0, 673560%N); (S1, 3%N); (S1, 82093%N); (S1, 1%N)].
2268Definition b28_15 : cfg := mkc false A [(S0, 1%N); (S0, 24911%N); (S0, 8280%N); (S1, 2736%N); (S0, 970%N); (S1, 36%N); (S0, 40%N); (S1, 36%N); (S0, 43%N); (S0, 23%N); (S0, 16%N); (S1, 8%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 74805%N); (S1, 224496%N); (S0, 673560%N); (S1, 4%N); (S0, 142098%N); (S1, 1%N)].
2269Definition b28_16 : cfg := mkc false D [(S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 21909%N); (S0, 2%N)].
2270Definition b28_17 : cfg := mkc true B [(S1, 93339%N); (S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24910%N); (S1, 8280%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [].
2271Definition b28_18 : cfg := mkc false A [(S0, 1%N); (S0, 164770%N); (S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
2272Definition b28_19 : cfg := mkc true B [(S0, 5%N); (S0, 673561%N); (S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 183703%N); (S1, 236201%N); (S1, 1%N)].
2273Definition b28_20 : cfg := mkc false D [(S1, 307633%N); (S1, 183704%N); (S0, 7%N); (S0, 673559%N); (S0, 224496%N); (S1, 74808%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N)].
2274Definition b28_21 : cfg := mkc false D [(S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 224496%N); (S1, 673559%N); (S1, 7%N); (S1, 183704%N); (S0, 379066%N); (S1, 1%N)].
2275Definition b28_22 : cfg := mkc true B [(S0, 7%N); (S0, 673559%N); (S0, 224496%N); (S1, 74808%N); (S0, 24910%N); (S1, 8280%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 183703%N); (S1, 450497%N); (S1, 1%N)].
2276Definition b28_23 : cfg := mkc false D [(S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 21%N); (S0, 17%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 6%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 74808%N); (S0, 224496%N); (S1, 673559%N); (S1, 7%N); (S1, 183704%N); (S0, 521925%N); (S0, 2%N)].
2277Definition b28_24 : cfg := mkc false D [(S1, 1%N); (S1, 611006%N); (S0, 176219%N); (S0, 9%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
2278Definition b28_25 : cfg := mkc true B [(S1, 712274%N); (S0, 163560%N); (S1, 8%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
2279Definition b28_26 : cfg := mkc true B [(S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 24912%N); (S0, 74808%N); (S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 150901%N); (S0, 813545%N); (S0, 2%N)].
2280Definition b28_27 : cfg := mkc true B [(S0, 914810%N); (S1, 138244%N); (S0, 9%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [].
2281Definition b28_28 : cfg := mkc true B [(S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 125586%N); (S1, 1016072%N); (S0, 2%N)].
2282Definition b28_29 : cfg := mkc true B [(S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 8%N); (S0, 112925%N); (S0, 1117353%N); (S0, 2%N)].
2283Definition b28_30 : cfg := mkc false A [(S0, 1%N); (S0, 7%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N); (S1, 100267%N); (S1, 1218616%N); (S0, 2%N)].
2284Definition b28_31 : cfg := mkc true C [(S1, 1%N); (S1, 1319886%N); (S0, 87610%N); (S1, 8%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [].
2285Definition b28_32 : cfg := mkc false A [(S0, 1%N); (S0, 1421144%N); (S1, 74952%N); (S0, 9%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N)].
2286Definition b28_33 : cfg := mkc false D [(S1, 1522415%N); (S1, 62293%N); (S1, 8%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 1%N)].
2287Definition b28_34 : cfg := mkc false E [(S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 673557%N); (S1, 8%N); (S0, 49634%N); (S1, 1623688%N); (S0, 2%N)].
2288Definition b28_35 : cfg := mkc true B [(S0, 36974%N); (S1, 8%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1724965%N)].
2289Definition b28_36 : cfg := mkc false D [(S1, 1826223%N); (S1, 24317%N); (S1, 8%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 1%N)].
2290Definition b28_37 : cfg := mkc false D [(S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 8279%N); (S1, 24912%N); (S0, 74808%N); (S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 11658%N); (S1, 1927496%N); (S0, 2%N)].
2291Lemma ck_0 : runp 500000 b28_0 = Some (b28_1, true).
2292Proof. native_compute. reflexivity. Qed.
2293Lemma ck_1 : runp 500000 b28_1 = Some (b28_2, true).
2294Proof. native_compute. reflexivity. Qed.
2295Lemma ck_2 : runp 500000 b28_2 = Some (b28_3, true).
2296Proof. native_compute. reflexivity. Qed.
2297Lemma ck_3 : runp 500000 b28_3 = Some (b28_4, true).
2298Proof. native_compute. reflexivity. Qed.
2299Lemma ck_4 : runp 500000 b28_4 = Some (b28_5, true).
2300Proof. native_compute. reflexivity. Qed.
2301Lemma ck_5 : runp 500000 b28_5 = Some (b28_6, true).
2302Proof. native_compute. reflexivity. Qed.
2303Lemma ck_6 : runp 500000 b28_6 = Some (b28_7, true).
2304Proof. native_compute. reflexivity. Qed.
2305Lemma ck_7 : runp 500000 b28_7 = Some (b28_8, true).
2306Proof. native_compute. reflexivity. Qed.
2307Lemma ck_8 : runp 500000 b28_8 = Some (b28_9, true).
2308Proof. native_compute. reflexivity. Qed.
2309Lemma ck_9 : runp 500000 b28_9 = Some (b28_10, true).
2310Proof. native_compute. reflexivity. Qed.
2311Lemma ck_10 : runp 500000 b28_10 = Some (b28_11, true).
2312Proof. native_compute. reflexivity. Qed.
2313Lemma ck_11 : runp 500000 b28_11 = Some (b28_12, true).
2314Proof. native_compute. reflexivity. Qed.
2315Lemma ck_12 : runp 500000 b28_12 = Some (b28_13, true).
2316Proof. native_compute. reflexivity. Qed.
2317Lemma ck_13 : runp 500000 b28_13 = Some (b28_14, true).
2318Proof. native_compute. reflexivity. Qed.
2319Lemma ck_14 : runp 500000 b28_14 = Some (b28_15, true).
2320Proof. native_compute. reflexivity. Qed.
2321Lemma ck_15 : runp 500000 b28_15 = Some (b28_16, true).
2322Proof. native_compute. reflexivity. Qed.
2323Lemma ck_16 : runp 500000 b28_16 = Some (b28_17, true).
2324Proof. native_compute. reflexivity. Qed.
2325Lemma ck_17 : runp 500000 b28_17 = Some (b28_18, true).
2326Proof. native_compute. reflexivity. Qed.
2327Lemma ck_18 : runp 500000 b28_18 = Some (b28_19, true).
2328Proof. native_compute. reflexivity. Qed.
2329Lemma ck_19 : runp 500000 b28_19 = Some (b28_20, true).
2330Proof. native_compute. reflexivity. Qed.
2331Lemma ck_20 : runp 500000 b28_20 = Some (b28_21, true).
2332Proof. native_compute. reflexivity. Qed.
2333Lemma ck_21 : runp 500000 b28_21 = Some (b28_22, true).
2334Proof. native_compute. reflexivity. Qed.
2335Lemma ck_22 : runp 500000 b28_22 = Some (b28_23, true).
2336Proof. native_compute. reflexivity. Qed.
2337Lemma ck_23 : runp 500000 b28_23 = Some (b28_24, true).
2338Proof. native_compute. reflexivity. Qed.
2339Lemma ck_24 : runp 500000 b28_24 = Some (b28_25, true).
2340Proof. native_compute. reflexivity. Qed.
2341Lemma ck_25 : runp 500000 b28_25 = Some (b28_26, true).
2342Proof. native_compute. reflexivity. Qed.
2343Lemma ck_26 : runp 500000 b28_26 = Some (b28_27, true).
2344Proof. native_compute. reflexivity. Qed.
2345Lemma ck_27 : runp 500000 b28_27 = Some (b28_28, true).
2346Proof. native_compute. reflexivity. Qed.
2347Lemma ck_28 : runp 500000 b28_28 = Some (b28_29, true).
2348Proof. native_compute. reflexivity. Qed.
2349Lemma ck_29 : runp 500000 b28_29 = Some (b28_30, true).
2350Proof. native_compute. reflexivity. Qed.
2351Lemma ck_30 : runp 500000 b28_30 = Some (b28_31, true).
2352Proof. native_compute. reflexivity. Qed.
2353Lemma ck_31 : runp 500000 b28_31 = Some (b28_32, true).
2354Proof. native_compute. reflexivity. Qed.
2355Lemma ck_32 : runp 500000 b28_32 = Some (b28_33, true).
2356Proof. native_compute. reflexivity. Qed.
2357Lemma ck_33 : runp 500000 b28_33 = Some (b28_34, true).
2358Proof. native_compute. reflexivity. Qed.
2359Lemma ck_34 : runp 500000 b28_34 = Some (b28_35, true).
2360Proof. native_compute. reflexivity. Qed.
2361Lemma ck_35 : runp 500000 b28_35 = Some (b28_36, true).
2362Proof. native_compute. reflexivity. Qed.
2363Lemma ck_36 : runp 500000 b28_36 = Some (b28_37, true).
2364Proof. native_compute. reflexivity. Qed.
2365Lemma ck_37 : runp 71896 b28_37 = Some (cfg28, true).
2366Proof. native_compute. reflexivity. Qed.
2367Lemma ck_ev p c c' : runp p c = Some (c', true) ->
2368 ev_cfg [] (fun _ => const S0) c -->* ev_cfg [] (fun _ => const S0) c'.
2369Proof. intros H. apply progress_evstep. exact (runp_spec [] (fun _ => const S0) _ _ _ _ H). Qed.
2371Lemma init28 : c0 -->* ev_cfg [] (fun _ => const S0) cfg28.
2372Proof.
2373 change c0 with (ev_cfg [] (fun _ => const S0) b28_0).
2374 eapply evstep_trans; [exact (ck_ev _ _ _ ck_0)|].
2375 eapply evstep_trans; [exact (ck_ev _ _ _ ck_1)|].
2376 eapply evstep_trans; [exact (ck_ev _ _ _ ck_2)|].
2377 eapply evstep_trans; [exact (ck_ev _ _ _ ck_3)|].
2378 eapply evstep_trans; [exact (ck_ev _ _ _ ck_4)|].
2379 eapply evstep_trans; [exact (ck_ev _ _ _ ck_5)|].
2380 eapply evstep_trans; [exact (ck_ev _ _ _ ck_6)|].
2381 eapply evstep_trans; [exact (ck_ev _ _ _ ck_7)|].
2382 eapply evstep_trans; [exact (ck_ev _ _ _ ck_8)|].
2383 eapply evstep_trans; [exact (ck_ev _ _ _ ck_9)|].
2384 eapply evstep_trans; [exact (ck_ev _ _ _ ck_10)|].
2385 eapply evstep_trans; [exact (ck_ev _ _ _ ck_11)|].
2386 eapply evstep_trans; [exact (ck_ev _ _ _ ck_12)|].
2387 eapply evstep_trans; [exact (ck_ev _ _ _ ck_13)|].
2388 eapply evstep_trans; [exact (ck_ev _ _ _ ck_14)|].
2389 eapply evstep_trans; [exact (ck_ev _ _ _ ck_15)|].
2390 eapply evstep_trans; [exact (ck_ev _ _ _ ck_16)|].
2391 eapply evstep_trans; [exact (ck_ev _ _ _ ck_17)|].
2392 eapply evstep_trans; [exact (ck_ev _ _ _ ck_18)|].
2393 eapply evstep_trans; [exact (ck_ev _ _ _ ck_19)|].
2394 eapply evstep_trans; [exact (ck_ev _ _ _ ck_20)|].
2395 eapply evstep_trans; [exact (ck_ev _ _ _ ck_21)|].
2396 eapply evstep_trans; [exact (ck_ev _ _ _ ck_22)|].
2397 eapply evstep_trans; [exact (ck_ev _ _ _ ck_23)|].
2398 eapply evstep_trans; [exact (ck_ev _ _ _ ck_24)|].
2399 eapply evstep_trans; [exact (ck_ev _ _ _ ck_25)|].
2400 eapply evstep_trans; [exact (ck_ev _ _ _ ck_26)|].
2401 eapply evstep_trans; [exact (ck_ev _ _ _ ck_27)|].
2402 eapply evstep_trans; [exact (ck_ev _ _ _ ck_28)|].
2403 eapply evstep_trans; [exact (ck_ev _ _ _ ck_29)|].
2404 eapply evstep_trans; [exact (ck_ev _ _ _ ck_30)|].
2405 eapply evstep_trans; [exact (ck_ev _ _ _ ck_31)|].
2406 eapply evstep_trans; [exact (ck_ev _ _ _ ck_32)|].
2407 eapply evstep_trans; [exact (ck_ev _ _ _ ck_33)|].
2408 eapply evstep_trans; [exact (ck_ev _ _ _ ck_34)|].
2409 eapply evstep_trans; [exact (ck_ev _ _ _ ck_35)|].
2410 eapply evstep_trans; [exact (ck_ev _ _ _ ck_36)|].
2411 exact (ck_ev _ _ _ ck_37).
2412Qed.
2415(* ===================================================================== *)
2416(* The invariant at the start of every record interval, and its closure. *)
2417(* ===================================================================== *)
2419Inductive cls := C5 | C0 | C1 | C2 | C3 | C4.
2421Definition Rs (r : cls) : list run :=
2422 match r with C5 => Rs_r5 | C0 => Rs_r0 | C1 => Rs_r1 | C2 => Rs_r2 | C3 => Rs_r3 | C4 => Rs_r4 end.
2424Definition ist : Type := (cls * nat * N * list (list N))%type.
2426Definition cfgI (s : ist) : Q * tape :=
2427 let '(r, e, t, nus) := s in Gc (repeat U0 (length nus), P0, 0) nus (evR [t] (Rs r)).
2429Definition win (r : cls) (e : nat) (t : N) (nus : list (list N)) : Prop :=
2430 match r with
2431 | C5 => exists f1 deep, nus = [W5t t; W5s t; W5a t; f1] :: deep /\ length deep = 1 + 2 * e
2432 | C0 => exists f1 f2 deep, nus = [W0t t; W0s t; f1; f2] :: deep /\ length deep = 1 + 2 * e
2433 | C1 => exists f1 f2 f3 deep, nus = [W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep /\
2434 length deep = 1 + 2 * e
2435 | C2 => exists q deep, nus = q :: deep /\ length deep = 1 + 2 * e
2436 | C3 => exists f1 f2 f3 deep, nus = [W3t t; f1; f2; f3] :: deep /\ length deep = 2 + 2 * e
2437 | C4 => exists q deep, nus = q :: deep /\ length deep = 2 + 2 * e
2438 end.
2440Definition Inv (s : ist) : Prop :=
2441 let '(r, e, t, nus) := s in 2 <= e /\ 1 + 8 * N.to_nat t = 9 ^ (e - 2) /\ win r e t nus.
2443Lemma inv_step s : Inv s -> exists s', cfgI s -->+ cfgI s' /\ Inv s'.
2444Proof.
2445 destruct s as [[[r e] t] nus]. intros [He [Ht Hw]].
2446 destruct r; cbn [win] in Hw.
2447 - destruct Hw as [f1 [deep [-> Hl]]].
2448 exists (C0, e, t, [W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N). split.
2449 + cbn [cfgI length Rs]. rewrite shift_len. apply (S_r5 e); assumption.
2450 + cbn [Inv win]. split; [exact He|]. split; [exact Ht|].
2451 exists f1, (rtop deep 0%N), (rshift deep 0%N). split; [reflexivity|]. rewrite shift_len. exact Hl.
2452 - destruct Hw as [f1 [f2 [deep [-> Hl]]]].
2453 exists (C1, e, t, [W1t t; W1s t; W1a t; W1I t] :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N). split.
2454 + cbn [cfgI length Rs]. rewrite shift_len. apply (S_r0 e); assumption.
2455 + cbn [Inv win]. split; [exact He|]. split; [exact Ht|].
2456 exists f1, f2, (rtop deep 0%N), (rshift deep 0%N). split; [reflexivity|]. rewrite shift_len. exact Hl.
2457 - destruct Hw as [f1 [f2 [f3 [deep [-> Hl]]]]].
2458 exists (C2, e, t, [f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N). split.
2459 + cbn [cfgI length Rs]. rewrite shift_len. apply (S_r1 e); assumption.
2460 + cbn [Inv win]. split; [exact He|]. split; [exact Ht|].
2461 exists [f1; f2; f3; rtop deep 0%N], (rshift deep 0%N). split; [reflexivity|]. rewrite shift_len. exact Hl.
2462 - destruct Hw as [q [deep [-> Hl]]].
2463 exists (C3, e, t, [W3t t; wv 6227 49896 t; wv 2069 16632 t; nth 0 q 0%N] :: rshift (q :: deep) 0%N). split.
2464 + cbn [cfgI length Rs]. rewrite shift_len. cbn [length]. apply (S_r2 e); assumption.
2465 + cbn [Inv win]. split; [exact He|]. split; [exact Ht|].
2466 exists (wv 6227 49896 t), (wv 2069 16632 t), (nth 0 q 0%N), (rshift (q :: deep) 0%N). split; [reflexivity|].
2467 rewrite shift_len. cbn [length]. lia.
2468 - destruct Hw as [f1 [f2 [f3 [deep [-> Hl]]]]].
2469 exists (C4, e, t, [f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N). split.
2470 + cbn [cfgI length Rs]. rewrite shift_len. apply (S_r3 e); assumption.
2471 + cbn [Inv win]. split; [exact He|]. split; [exact Ht|].
2472 exists [f1; f2; f3; rtop deep 0%N], (rshift deep 0%N). split; [reflexivity|]. rewrite shift_len. exact Hl.
2473 - destruct Hw as [q [deep [-> Hl]]].
2474 exists (C5, S e, (1 + 9 * t)%N, [W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); nth 0 q 0%N] :: rshift (q :: deep) 0%N).
2475 split.
2476 + cbn [cfgI length Rs]. rewrite shift_len. cbn [length]. apply (S_r4 e); assumption.
2477 + cbn [Inv win]. split; [lia|]. split.
2478 * replace (S e - 2) with (S (e - 2)) by lia. cbn [Nat.pow]. rewrite <-Ht. lia.
2479 * exists (nth 0 q 0%N), (rshift (q :: deep) 0%N). split; [reflexivity|]. rewrite shift_len. cbn [length]. lia.
2480Qed.
2482(* ===================================================================== *)
2483(* From record exit 28 to the invariant (class r5, e = 2, u = 1). *)
2484(* ===================================================================== *)
2486Definition L28 : list run :=
2487 [(S0, cn 74808); (S1, cn 24912); (S0, cn 8277); (S0, cn 2737); (S0, cn 972); (S1, cn 36);
2488 (S0, cn 37); (S0, cn 37); (S0, cn 44); (S1, cn 24); (S0, cn 13); (S0, cn 9);
2489 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5);
2490 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 6); (S1, cn 4); (S0, cn 1);
2491 (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 2)]%N.
2492Definition R28 : list run := [(S0, cn 224492); (S1, cn 673559); (S1, cn 7); (S1, cn 9841); (S1, cn 1942040); (S0, cn 2)]%N.
2494Definition nus28 : list (list N) :=
2495 [[18701; 6227; 2069; 683]; [242; 8; 9; 8]; [10; 5; 3; 1]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]]%N.
2497Lemma inv28 : Inv (C5, 2, 0%N, nus28).
2498Proof.
2499 cbn [Inv win]. split; [lia|]. split; [reflexivity|].
2500 exists 683%N, (tl nus28). split; reflexivity.
2501Qed.
2503Lemma split1 nu b c v rest X :
2504 ev_runs nu ((b, LF (3 + c) v) :: rest) X = ev_runs nu [(b, cn 3)] (ev_runs nu ((sneg b, LF c v) :: rest) X).
2505Proof.
2506 cbn [ev_runs]. unfold ev. cbn [lc lv].
2507 replace (N.to_nat (3 + c + dot v nu)) with (3 + N.to_nat (c + dot v nu)) by lia.
2508 rewrite alt_add, Str_app_assoc. reflexivity.
2509Qed.
2511Lemma b28a : reach 1000 (Rc B (L28, T0) ([(S1, cn 3)], TV 1)) (Rc A ((S0, cn 3) :: L28, T0) ([], TV 1)) = true.
2512Proof. vm_compute. reflexivity. Qed.
2514Lemma b28b : ep_run true R28 = Some (map (fun r => (fst r, cn (evN [0%N] (snd r)))) Rs_r5).
2515Proof. vm_compute. reflexivity. Qed.
2517Lemma b28_chain : ev_runs [] ((S0, cn 3) :: L28) (const S0) = chs (repeat U0 6) nus28 (b1s P0 (LWs 0)).
2518Proof. reflexivity. Qed.
2520Lemma b28_right : evR [] (map (fun r => (fst r, cn (evN [0%N] (snd r)))) Rs_r5) = evR [0%N] Rs_r5.
2521Proof. reflexivity. Qed.
2523Lemma base28 :
2524 ev_runs [] L28 (const S0) {{B}}> ev_runs [] ((S1, cn 224495) :: tl R28) (const S0) -->*
2525 cfgI (C5, 2, 0%N, nus28).
2526Proof.
2527 change (cn 224495) with (LF (3 + 224492) []).
2528 rewrite split1.
2529 eapply evstep_trans.
2530 - apply progress_evstep. exact (reach_spec _ _ _ b28a [] (sg2 (const S0) (evR [] R28))).
2531 - change (ev_runs [] ((S0, cn 3) :: L28) (const S0) {{A}}> evR [] R28 -->* cfgI (C5, 2, 0%N, nus28)).
2532 replace (cfgI (C5, 2, 0%N, nus28))
2533 with (ev_runs [] ((S0, cn 3) :: L28) (const S0) <{{D}} evR [] (map (fun r => (fst r, cn (evN [0%N] (snd r)))) Rs_r5)).
2534 + apply (ep_run_spec _ _ _ b28b []).
2535 + unfold cfgI, Gc. rewrite b28_chain, b28_right. reflexivity.
2536Qed.
2538(* ===================================================================== *)
2539(* The machine never halts. *)
2540(* ===================================================================== *)
2542Lemma nonhalt : ~ halts tm c0.
3984Proof.2543Proof.
3985 eapply multistep_nonhalt.2544 eapply multistep_nonhalt.
3986 1: apply init.
2545 - eapply evstep_trans; [apply init28 | exact base28].
3987 eapply progress_nonhalt_cond with (P:=fun '(x,y,z) => LWF x y /\ 1<=z).
2546 - apply (progress_nonhalt_cond tm ist (C5, 2, 0%N, nus28) cfgI Inv inv_step inv28).
3988 2:{
3989 split.
⋯ 15 template-only lines (template 3990–4004), not in ours
4005 Unshelve.
4006 apply aWF_intro; lia.
4007Qed.2547Qed.
2551(*
2552```
25531RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---
2555 0 1
2556A 1RB 0RF
2557B 1RC 0RB
2558C 1LD 0RA
2559D 1LE 0LD
2560E 1RB 0LC
2561F 1LA ---
2563sweep cycles (alternating cells, every cell complemented):
2564 right: B0 C1 A0 B1 (1RC 0RA 1RB 0RB)
2565 left : D1 D0 E1 C0 (0LD 1LE 0LC 1LD)
2567configuration at the start of a record interval (cfgI):
2568 chs (U0^m) nus (b1s P0 (LWs 0)) <{{D}} evR [t] (Rs r)
2569 chain: m = K - 1 blocks with m = 3 (gap variables nus, nearest the head first), block 1
2570 (m = 1), left word W_1; right region: run list Rs r, linear in t, u = 9^(e-2) = 1 + 8 t.
2572block rules (all gaps symbolic, both sides abstract), entering from the right at phase c (D):
2573 U0 -> U1, U1 -> U2, W0 -> W1, W1 -> D0 leave right at c + 2 (A)
2574 D1 -> D0, D2 -> D1 leave right at c (B)
2575 U2, D0 passed leave left at c + 2 (D)
2576entering from the left: U2 at c -> U0 (A), U2 at c + 2 -> W0 (A), D0 at c + 2 -> D2 (B)
2577block 1: P0 -> P1 -> PD0 (A), PD2 -> PD1 -> PD0 (B), PD0 passed (E), PD0 from the left -> PD2.
2579one interval (S_r): (81 * 3^K - 1) visits + episodes (interval_tm, int_r),
2580 record visit: carry-out at all D0, left record, carry back to all D2 (record_visit),
2581 regrouping one defect later (regroup), record-exit episode (step_r).
2582classes r5 -> r0 -> r1 -> r2 -> r3 -> r4 -> r5 (e + 1, t -> 1 + 9 t); K0 = 3 3 4 3 4 4.
2583```
2584*)
3Proof outlineCheck: the new items (green) carry the argument; the names read like the proof.md rules.

447 items in 1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v (2584 lines): 228 Lemma, 184 Definition, 28 Fixpoint, 6 Inductive, 1 Record. Tags against the template: identical = same name and same text once each file's own TM string is <TM> (marked "except the TM string" when that is the only difference); adapted = same name, different text; new = no item of that name in the template part.

#kindnamestatement (no proof body)linevs template
1Definitiontm
Definition tm := Eval compute in (TM_from_str "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---").
L31identicalexcept the TM string
2Definitionsneg
Definition sneg (s : Sym) : Sym := match s with S0 => S1 | S1 => S0 end.
L48new
3Definitionseqb
Definition seqb (a b : Sym) : bool :=
match a, b with S0, S0 | S1, S1 => true | _, _ => false end.
L49new
4Recordlf
Record lf := LF { lc : N; lv : list N }.
L52new
5Fixpointdot
Fixpoint dot (vs nu : list N) : N :=
match vs, nu with
| v :: vs', x :: nu' => (v * x + dot vs' nu')%N
| _, _ => 0%N
end.
L54new
6Definitionev
Definition ev (nu : list N) (a : lf) : nat := N.to_nat (lc a + dot (lv a) nu).
L60new
7Fixpointzadd
Fixpoint zadd (a b : list N) : list N :=
match a, b with
| x :: a', y :: b' => (x + y)%N :: zadd a' b'
| [], _ => b
| _, [] => a
end.
L62new
8Definitionlf_add
Definition lf_add (a b : lf) : lf := LF (lc a + lc b) (zadd (lv a) (lv b)).
L69new
9Definitionlf_S
Definition lf_S (a : lf) : lf := LF (N.succ (lc a)) (lv a).
L70new
10Definitionlf_one
Definition lf_one : lf := LF 1 [].
L71new
11Definitionallz
Definition allz (vs : list N) : bool := forallb (fun v => N.eqb v 0) vs.
L72new
12Definitionall4
Definition all4 (vs : list N) : bool := forallb (fun v => N.eqb (N.modulo v 4) 0) vs.
L73new
13Definitionis_zero
Definition is_zero (a : lf) : bool := andb (N.eqb (lc a) 0) (allz (lv a)).
L74new
14Definitionis_one
Definition is_one (a : lf) : bool := andb (N.eqb (lc a) 1) (allz (lv a)).
L75new
15Definitionposb
Definition posb (a : lf) : bool := negb (N.eqb (lc a) 0).
L76new
16Inductivetl_
Inductive tl_ := T0 | TV (k : nat).
L78new
17Definitionrun
Definition run : Type := (Sym * lf)%type.
L79new
18Definitionsd
Definition sd : Type := (list run * tl_)%type.
L80new
19Fixpointalt
Fixpoint alt (b : Sym) (n : nat) : list Sym :=
match n with O => [] | S n' => b :: alt (sneg b) n' end.
L82new
20Definitionev_tl
Definition ev_tl (sg : nat -> side) (t : tl_) : side :=
match t with T0 => const S0 | TV k => sg k end.
L85new
21Fixpointev_runs
Fixpoint ev_runs (nu : list N) (rs : list run) (s : side) : side :=
match rs with
| [] => s
| (b, n) :: rs' => alt b (ev nu n) *> ev_runs nu rs' s
end.
L88new
22Definitionev_sd
Definition ev_sd nu sg (s : sd) : side := ev_runs nu (fst s) (ev_tl sg (snd s)).
L94new
23Fixpointpop_runs
Fixpoint pop_runs (rs : list run) (t : tl_) : option (Sym * sd) :=
match rs with
| (b, n) :: rs' =>
    if is_zero n then pop_runs rs' t
    else if posb n then
      Some (b, ((if is_one n then rs' else (sneg b, LF (N.pred (lc n)) (lv n)) :: rs'), t))
… +3 lines
L96new
24Definitionpop
Definition pop (s : sd) : option (Sym * sd) := pop_runs (fst s) (snd s).
L106new
25Definitionpush
Definition push (w : Sym) (s : sd) : sd :=
match s with
| ((b0, n0) :: rs, t) =>
    if seqb w b0 then ((w, lf_one) :: (b0, n0) :: rs, t)
    else ((w, lf_S n0) :: rs, t)
| ([], t) => ([(w, lf_one)], t)
… +1 lines
L108new
26Definitionafterb
Definition afterb (c : Sym) (n : lf) : Sym := if N.eqb (N.modulo (lc n) 2) 0 then c else sneg c.
L117new
27Definitionpush_run
Definition push_run (c : Sym) (n : lf) (s : sd) : sd :=
match s with
| ((b0, n0) :: rs, t) =>
    if seqb (afterb c n) b0 then ((c, lf_add n n0) :: rs, t)
    else ((c, n) :: (b0, n0) :: rs, t)
| ([], t) => ([(c, n)], t)
… +1 lines
L119new
28DefinitioncR_st
Definition cR_st (i : nat) : Q :=
match i mod 4 with 0 => B | 1 => C | 2 => A | _ => B end.
L128new
29DefinitioncR_bt
Definition cR_bt (i : nat) : Sym :=
match i mod 4 with 0 => S0 | 1 => S1 | 2 => S0 | _ => S1 end.
L130new
30DefinitioncR_idx
Definition cR_idx (q : Q) (b : Sym) : option nat :=
match q, b with
| B, S0 => Some 0 | C, S1 => Some 1 | A, S0 => Some 2 | B, S1 => Some 3
| _, _ => None
end.
L132new
31DefinitioncL_st
Definition cL_st (i : nat) : Q :=
match i mod 4 with 0 => D | 1 => D | 2 => E | _ => C end.
L137new
32DefinitioncL_bt
Definition cL_bt (i : nat) : Sym :=
match i mod 4 with 0 => S1 | 1 => S0 | 2 => S1 | _ => S0 end.
L139new
33DefinitioncL_idx
Definition cL_idx (q : Q) (b : Sym) : option nat :=
match q, b with
| D, S1 => Some 0 | D, S0 => Some 1 | E, S1 => Some 2 | C, S0 => Some 3
| _, _ => None
end.
L141new
34Definitionlastb
Definition lastb (c : Sym) (n : lf) : Sym := if N.eqb (N.modulo (lc n) 2) 0 then sneg c else c.
L148new
35Inductivecfg
Inductive cfg := Rc (q : Q) (l r : sd) | Lc (q : Q) (l r : sd).
L150new
36Definitionev_cfg
Definition ev_cfg nu sg (c : cfg) : Q * tape :=
match c with
| Rc q l r => (ev_sd nu sg l) {{q}}> (ev_sd nu sg r)
| Lc q l r => (ev_sd nu sg l) <{{q}} (ev_sd nu sg r)
end.
L152new
37Definitionsingle
Definition single (c : cfg) : option cfg :=
match c with
| Rc q l r =>
  match pop r with
  | Some (s, r') =>
    match tm (q, s) with
… +17 lines
L158new
38Definitiontag
Definition tag (o : option cfg) : option (cfg * bool) :=
match o with Some c => Some (c, true) | None => None end.
L182new
39Definitionsstep
Definition sstep (c : cfg) : option (cfg * bool) :=
match c with
| Rc q l ((b, n) :: rs, t) =>
    if is_zero n then Some (Rc q l (rs, t), false) else
    match cR_idx q b with
    | Some i =>
… +16 lines
L185new
40Fixpointrunp
Fixpoint runp (p : positive) (c : cfg) : option (cfg * bool) :=
match p with
| xH => sstep c
| xO p' =>
    match runp p' c with
    | Some (c1, b1) => match runp p' c1 with Some (c2, b2) => Some (c2, orb b1 b2) | None => None end
… +12 lines
L209new
41Lemmasneg_neq
Lemma sneg_neq a b : seqb a b = false -> b = sneg a.
L232new
42Lemmaseqb_eq
Lemma seqb_eq a b : seqb a b = true -> a = b.
L235new
43Lemmasneg_sneg
Lemma sneg_sneg a : sneg (sneg a) = a.
L238new
44Lemmadot_zadd
Lemma dot_zadd a b nu : dot (zadd a b) nu = (dot a nu + dot b nu)%N.
L241new
45Lemmaev_add
Lemma ev_add nu a b : ev nu (lf_add a b) = ev nu a + ev nu b.
L247new
46Lemmaev_S
Lemma ev_S nu a : ev nu (lf_S a) = S (ev nu a).
L250new
47Lemmaallz_dot
Lemma allz_dot vs nu : allz vs = true -> dot vs nu = 0%N.
L253new
48Lemmaall4_dot
Lemma all4_dot vs nu : all4 vs = true -> exists k, dot vs nu = (4 * k)%N.
L259new
49Lemmaev_zero
Lemma ev_zero nu a : is_zero a = true -> ev nu a = 0.
L268new
50Lemmaev_one
Lemma ev_one nu a : is_one a = true -> ev nu a = 1.
L274new
51Lemmaev_pos
Lemma ev_pos nu a : posb a = true -> ev nu a = S (ev nu (LF (N.pred (lc a)) (lv a))).
L280new
52Lemmaev_mod4
Lemma ev_mod4 nu a : all4 (lv a) = true -> exists k, ev nu a = N.to_nat (lc a) + 4 * k.
L285new
53Lemmaev_runs_app
Lemma ev_runs_app nu rs1 rs2 s : ev_runs nu (rs1 ++ rs2) s = ev_runs nu rs1 (ev_runs nu rs2 s).
L291new
54Lemmapop_runs_spec
Lemma pop_runs_spec nu sg rs t b s' :
pop_runs rs t = Some (b, s') -> ev_runs nu rs (ev_tl sg t) = b >> ev_sd nu sg s'.
L294new
55Lemmapop_spec
Lemma pop_spec nu sg s b s' : pop s = Some (b, s') -> ev_sd nu sg s = b >> ev_sd nu sg s'.
L308new
56Lemmapush_spec
Lemma push_spec nu sg w s : ev_sd nu sg (push w s) = w >> ev_sd nu sg s.
L311new
57Definitionafterb_nat
Definition afterb_nat (c : Sym) (n : nat) : Sym := if Nat.eqb (n mod 2) 0 then c else sneg c.
L318new
58Lemmaafterb_nat_S
Lemma afterb_nat_S c m : afterb_nat c (S m) = afterb_nat (sneg c) m.
L320new
59Lemmaalt_add
Lemma alt_add c m k : alt c (m + k) = alt c m ++ alt (afterb_nat c m) k.
L327new
60Lemmaafterb_ev
Lemma afterb_ev nu c n : all4 (lv n) = true -> afterb c n = afterb_nat c (ev nu n).
L334new
61Lemmapush_run_spec
Lemma push_run_spec nu sg c n s :
all4 (lv n) = true -> ev_sd nu sg (push_run c n s) = alt c (ev nu n) *> ev_sd nu sg s.
L341new
62Definitionlastb_nat
Definition lastb_nat (c : Sym) (m : nat) : Sym := if Nat.eqb (m mod 2) 0 then sneg c else c.
L351new
63Lemmalastb_ev
Lemma lastb_ev nu c n : all4 (lv n) = true -> lastb c n = lastb_nat c (ev nu n).
L353new
64Lemmarev_alt
Lemma rev_alt b m (l : side) :
alt (sneg (lastb_nat b (S m))) (S m) *> l = alt (sneg (lastb_nat (sneg b) m)) m *> (sneg b >> l).
L360new
65LemmacR_cases
Lemma cR_cases i : (i mod 4 = 0 /\ S i mod 4 = 1) \/ (i mod 4 = 1 /\ S i mod 4 = 2) \/
(i mod 4 = 2 /\ S i mod 4 = 3) \/ (i mod 4 = 3 /\ S i mod 4 = 0).
L369new
66LemmacR_tm
Lemma cR_tm i : tm (cR_st i, cR_bt i) = Some (sneg (cR_bt i), R, cR_st (S i)).
L373new
67LemmacR_bt_S
Lemma cR_bt_S i : cR_bt (S i) = sneg (cR_bt i).
L379new
68LemmacL_tm
Lemma cL_tm i : tm (cL_st i, cL_bt i) = Some (sneg (cL_bt i), L, cL_st (S i)).
L385new
69LemmacL_bt_S
Lemma cL_bt_S i : cL_bt (S i) = sneg (cL_bt i).
L391new
70LemmaaccR_step
Lemma accR_step i l X :
(l {{cR_st i}}> (cR_bt i >> X)) --> ((sneg (cR_bt i) >> l) {{cR_st (S i)}}> X).
L397new
71LemmaaccL_step
Lemma accL_step i r X :
((cL_bt i >> X) <{{cL_st i}} r) --> (X <{{cL_st (S i)}} (sneg (cL_bt i) >> r)).
L401new
72LemmaaccR
Lemma accR m : forall i l r,
(l {{cR_st i}}> (alt (cR_bt i) m *> r)) -->*
((alt (sneg (lastb_nat (cR_bt i) m)) m *> l) {{cR_st (i + m)}}> r).
L405new
73LemmaaccR_S
Lemma accR_S m i l r :
(l {{cR_st i}}> (alt (cR_bt i) (S m) *> r)) -->+
((alt (sneg (lastb_nat (cR_bt i) (S m))) (S m) *> l) {{cR_st (i + S m)}}> r).
L416new
74LemmaaccL
Lemma accL m : forall i l r,
((alt (cL_bt i) m *> l) <{{cL_st i}} r) -->*
(l <{{cL_st (i + m)}} (alt (sneg (lastb_nat (cL_bt i) m)) m *> r)).
L425new
75LemmaaccL_S
Lemma accL_S m i l r :
((alt (cL_bt i) (S m) *> l) <{{cL_st i}} r) -->+
(l <{{cL_st (i + S m)}} (alt (sneg (lastb_nat (cL_bt i) (S m))) (S m) *> r)).
L436new
76Lemmasingle_spec
Lemma single_spec nu sg c c' : single c = Some c' -> ev_cfg nu sg c --> ev_cfg nu sg c'.
L445new
77DefinitionRel
Definition Rel (b : bool) (c c' : Q * tape) : Prop := if b then c -->+ c' else c -->* c'.
L462new
78LemmaRel_trans
Lemma Rel_trans b1 b2 c c' c'' : Rel b1 c c' -> Rel b2 c' c'' -> Rel (orb b1 b2) c c''.
L464new
79Lemmatag_spec
Lemma tag_spec nu sg c o c' b : o = single c -> tag o = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
L473new
80LemmacR_idx_spec
Lemma cR_idx_spec q b i : cR_idx q b = Some i -> q = cR_st i /\ b = cR_bt i.
L479new
81LemmacL_idx_spec
Lemma cL_idx_spec q b i : cL_idx q b = Some i -> q = cL_st i /\ b = cL_bt i.
L482new
82LemmacR_st_mod
Lemma cR_st_mod i k : cR_st (i + N.to_nat (N.modulo k 4)) = cR_st (i + N.to_nat k).
L485new
83LemmacL_st_mod
Lemma cL_st_mod i k : cL_st (i + N.to_nat (N.modulo k 4)) = cL_st (i + N.to_nat k).
L491new
84LemmacR_st_add4
Lemma cR_st_add4 i a k : cR_st (i + (a + 4 * k)) = cR_st (i + a).
L497new
85LemmacL_st_add4
Lemma cL_st_add4 i a k : cL_st (i + (a + 4 * k)) = cL_st (i + a).
L500new
86Lemmasstep_spec
Lemma sstep_spec nu sg c c' b : sstep c = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
L503new
87Lemmarunp_spec
Lemma runp_spec nu sg p : forall c c' b, runp p c = Some (c', b) -> Rel b (ev_cfg nu sg c) (ev_cfg nu sg c').
L538new
88Fixpointstrip0
Fixpoint strip0 (vs : list N) : list N :=
match vs with
| [] => []
| v :: vs' => match strip0 vs' with [] => if N.eqb v 0 then [] else [v] | w => v :: w end
end.
L558new
89FixpointlistN_eqb
Fixpoint listN_eqb (a b : list N) : bool :=
match a, b with
| [], [] => true
| x :: a', y :: b' => andb (N.eqb x y) (listN_eqb a' b')
| _, _ => false
end.
L564new
90Definitionlf_eqb
Definition lf_eqb (a b : lf) : bool := andb (N.eqb (lc a) (lc b)) (listN_eqb (strip0 (lv a)) (strip0 (lv b))).
L571new
91Definitionruns_eqb
Definition runs_eqb (a b : list run) : bool :=
(fix f (a b : list run) := match a, b with
 | [], [] => true
 | (x, n) :: a', (y, m) :: b' => andb (andb (seqb x y) (lf_eqb n m)) (f a' b')
 | _, _ => false end) a b.
L573new
92Definitiontl_eqb
Definition tl_eqb (a b : tl_) : bool :=
match a, b with T0, T0 => true | TV i, TV j => Nat.eqb i j | _, _ => false end.
L579new
93Definitionsd_eqb
Definition sd_eqb (a b : sd) : bool := andb (runs_eqb (fst a) (fst b)) (tl_eqb (snd a) (snd b)).
L582new
94Definitionq_eqb
Definition q_eqb (a b : Q) : bool :=
match a, b with A, A | B, B | C, C | D, D | E, E | F, F => true | _, _ => false end.
L584new
95Definitioncfg_eqb
Definition cfg_eqb (a b : cfg) : bool :=
match a, b with
| Rc q l r, Rc q' l' r' => andb (q_eqb q q') (andb (sd_eqb l l') (sd_eqb r r'))
| Lc q l r, Lc q' l' r' => andb (q_eqb q q') (andb (sd_eqb l l') (sd_eqb r r'))
| _, _ => false
end.
L587new
96Lemmadot_strip0
Lemma dot_strip0 vs nu : dot (strip0 vs) nu = dot vs nu.
L594new
97LemmalistN_eqb_eq
Lemma listN_eqb_eq a b : listN_eqb a b = true -> a = b.
L604new
98Lemmalf_eqb_ev
Lemma lf_eqb_ev nu a b : lf_eqb a b = true -> ev nu a = ev nu b.
L610new
99Lemmaruns_eqb_ev
Lemma runs_eqb_ev nu a b s : runs_eqb a b = true -> ev_runs nu a s = ev_runs nu b s.
L617new
100Lemmasd_eqb_ev
Lemma sd_eqb_ev nu sg a b : sd_eqb a b = true -> ev_sd nu sg a = ev_sd nu sg b.
L624new
101Lemmaq_eqb_eq
Lemma q_eqb_eq a b : q_eqb a b = true -> a = b.
L633new
102Lemmacfg_eqb_ev
Lemma cfg_eqb_ev nu sg a b : cfg_eqb a b = true -> ev_cfg nu sg a = ev_cfg nu sg b.
L636new
103Definitionrstep
Definition rstep (tgt : cfg) (st : cfg * bool * bool) : cfg * bool * bool :=
let '(c, pr, dn) := st in
if dn then st else
match sstep c with
| Some (c', b) => (c', orb pr b, cfg_eqb c' tgt)
| None => st
… +1 lines
L644new
104Definitionreach
Definition reach (fuel : positive) (c tgt : cfg) : bool :=
let '(c', pr, dn) := Pos.iter (rstep tgt) (c, false, false) fuel in andb pr dn.
L653new
105Lemmareach_spec
Lemma reach_spec fuel c tgt : reach fuel c tgt = true ->
forall nu sg, ev_cfg nu sg c -->+ ev_cfg nu sg tgt.
L656new
106Definitioncn
Definition cn (n : N) : lf := LF n [].
L675new
107Fixpointmkruns
Fixpoint mkruns (b : Sym) (ns : list lf) : list run :=
match ns with [] => [] | n :: ns' => (b, n) :: mkruns (lastb b n) ns' end.
L681new
108Definitionvt
Definition vt c := LF c [4;0;0;0]%N.
L685new
109Definitionvs
Definition vs c := LF c [0;4;0;0]%N.
L686new
110Definitionva
Definition va c := LF c [0;0;4;0]%N.
L687new
111Definitionvl
Definition vl c := LF c [0;0;0;4]%N.
L688new
112Inductivelab
Inductive lab := U0 | U1 | U2 | W0 | W1 | D0 | D1 | D2.
L690new
113Definitionlens
Definition lens (s : lab) : list lf :=
match s with
| U0 => [cn 3; vt 4; vs 4; va 1; vl 2]
| U1 => [cn 3; vt 4; vs 4; va 2; vl 1]
| U2 => [cn 3; vt 4; vs 4; va 3; vl 0]
| W0 => [cn 3; vt 1; vs 6; va 4; vl 0]
… +5 lines
L692new
114Definitionblk
Definition blk (s : lab) : list run := mkruns S0 (lens s).
L703new
115Definitionrlens
Definition rlens (s : lab) : list lf :=
match s with
| D0 => [vl 0; va 4; vs 4; vt 3; cn 3]
| _  => [vl 0; va 3; vs 4; vt 4; cn 3]
end%N.
L706new
116Definitionrblk
Definition rblk (s : lab) : list run := mkruns S0 (rlens s).
L711new
117Inductivelab1
Inductive lab1 := P0 | P1 | PD0 | PD1 | PD2.
L714new
118Definitionlens1
Definition lens1 (s : lab1) : list lf :=
match s with
| P0 => [cn 3; cn 1; cn 3] | P1 => [cn 3; cn 2; cn 2] | PD0 => [cn 3; cn 3; cn 1]
| PD1 => [cn 2; cn 4; cn 1] | PD2 => [cn 1; cn 5; cn 1]
end%N.
L715new
119Definitionblk1
Definition blk1 (s : lab1) : list run := mkruns S0 (lens1 s).
L720new
120Definitionrblk1
Definition rblk1 : list run := mkruns S1 [cn 1; cn 3; cn 3]%N.
L721new
121Definitionstp
Definition stp (p : bool) : Q := if p then A else B.
L724new
122Definitionturn
Definition turn (s : lab) : option (lab * bool) :=
match s with
| U0 => Some (U1, true) | U1 => Some (U2, true) | W0 => Some (W1, true) | W1 => Some (D0, true)
| D1 => Some (D0, false) | D2 => Some (D1, false) | _ => None
end.
L726new
123Definitionreset
Definition reset (s : lab) (p : bool) : option (lab * bool) :=
match s, p with
| U2, true => Some (U0, true) | U2, false => Some (W0, true) | D0, false => Some (D2, false)
| _, _ => None
end.
L731new
124Definitionturn1
Definition turn1 (s : lab1) : option (lab1 * bool) :=
match s with
| P0 => Some (P1, true) | P1 => Some (PD0, true) | PD1 => Some (PD0, false) | PD2 => Some (PD1, false)
| PD0 => None
end.
L736new
125Definitionsg2
Definition sg2 (L R : side) : nat -> side := fun k => match k with O => L | _ => R end.
L742new
126Lemmareach_LR
Lemma reach_LR fuel q q' l l' nu L R :
reach fuel (Lc q (l, TV 0) ([], TV 1)) (Rc q' (l', TV 0) ([], TV 1)) = true ->
ev_runs nu l L <{{q}} R -->+ ev_runs nu l' L {{q'}}> R.
L744new
127Lemmareach_LL
Lemma reach_LL fuel q q' l r' nu L R :
reach fuel (Lc q (l, TV 0) ([], TV 1)) (Lc q' ([], TV 0) (r', TV 1)) = true ->
ev_runs nu l L <{{q}} R -->+ L <{{q'}} ev_runs nu r' R.
L749new
128Lemmareach_RR
Lemma reach_RR fuel q q' r l' nu L R :
reach fuel (Rc q ([], TV 0) (r, TV 1)) (Rc q' (l', TV 0) ([], TV 1)) = true ->
L {{q}}> ev_runs nu r R -->+ ev_runs nu l' L {{q'}}> R.
L754new
129Lemmablk_turn
Lemma blk_turn s s' p nu L R : turn s = Some (s', p) ->
ev_runs nu (blk s) L <{{D}} R -->+ ev_runs nu (blk s') L {{stp p}}> R.
L759new
130Lemmablk_pass
Lemma blk_pass s nu L R : turn s = None ->
ev_runs nu (blk s) L <{{D}} R -->+ L <{{D}} ev_runs nu (rblk s) R.
L766new
131Lemmablk_reset
Lemma blk_reset s p s' p' nu L R : reset s p = Some (s', p') ->
L {{stp p}}> ev_runs nu (rblk s) R -->+ ev_runs nu (blk s') L {{stp p'}}> R.
L772new
132Lemmablk1_turn
Lemma blk1_turn s s' p L R : turn1 s = Some (s', p) ->
ev_runs [] (blk1 s) L <{{D}} R -->+ ev_runs [] (blk1 s') L {{stp p}}> R.
L779new
133Lemmablk1_pass
Lemma blk1_pass L R : ev_runs [] (blk1 PD0) L <{{D}} R -->+ L <{{E}} ev_runs [] rblk1 R.
L786new
134Lemmablk1_back
Lemma blk1_back L R : L {{B}}> ev_runs [] rblk1 R -->+ ev_runs [] (blk1 PD2) L {{B}}> R.
L789new
135Definitiondgr
Definition dgr (v : nat) : list run :=
match v with
| O => [(S0, cn 1); (S0, cn 5)]
| S O => [(S0, cn 2); (S1, cn 4)]
| _ => [(S0, cn 3); (S0, cn 3)]
end%N.
L797new
136Definitionlw
Definition lw (i : nat) : list run :=
if Nat.ltb i 81 then
  [(S1, cn 3); (S1, cn 4)] ++ dgr (i mod 3) ++ dgr (i / 3 mod 3) ++ dgr (i / 9 mod 3) ++ dgr (i / 27 mod 3)
    ++ [(S0, cn 2)]
else [(S0, cn 6); (S1, cn 4)] ++ dgr 0 ++ dgr 0 ++ dgr 0 ++ dgr 0 ++ [(S0, cn 2)].
L804new
137DefinitionLWs
Definition LWs (i : nat) : side := ev_runs [] (lw i) (const S0).
L810new
138Lemmareach_T0
Lemma reach_T0 fuel q q' l l' (Y : side) :
reach fuel (Lc q (l, T0) ([], TV 0)) (Rc q' (l', T0) ([], TV 0)) = true ->
ev_runs [] l (const S0) <{{q}} Y -->+ ev_runs [] l' (const S0) {{q'}}> Y.
L812new
139Definitionlw_ok
Definition lw_ok (i : nat) : bool := reach 1000 (Lc E (lw i, T0) ([], TV 0)) (Rc B (lw (S i), T0) ([], TV 0)).
L817new
140Lemmalw_all
Lemma lw_all : forallb lw_ok (seq 0 81) = true.
L819new
141Lemmalw_ok_spec
Lemma lw_ok_spec i Y : lw_ok i = true ->
ev_runs [] (lw i) (const S0) <{{E}} Y -->+ ev_runs [] (lw (S i)) (const S0) {{B}}> Y.
L822new
142Lemmalw_ok_lt
Lemma lw_ok_lt i : i < 81 -> lw_ok i = true.
L826new
143Lemmalw_ep
Lemma lw_ep i Y : i < 81 -> LWs i <{{E}} Y -->+ LWs (S i) {{B}}> Y.
L829new
144Fixpointchs
Fixpoint chs (ls : list lab) (nus : list (list N)) (L : side) : side :=
match ls, nus with
| s :: ls', nu :: nus' => ev_runs nu (blk s) (chs ls' nus' L)
| _, _ => L
end.
L837new
145Fixpointrchs
Fixpoint rchs (ls : list lab) (nus : list (list N)) (R : side) : side :=
match ls, nus with
| s :: ls', nu :: nus' => rchs ls' nus' (ev_runs nu (rblk s) R)
| _, _ => R
end.
L843new
146Fixpointvisit3
Fixpoint visit3 (ls : list lab) : option (list lab * bool) :=
match ls with
| [] => None
| s :: ls' =>
  match turn s with
  | Some (s', p) => Some (s' :: ls', p)
… +7 lines
L849new
147Fixpointcb
Fixpoint cb (ls : list lab) (p : bool) : option (list lab * bool) :=
match ls with
| [] => Some ([], p)
| s :: ls' =>
  match cb ls' p with
  | Some (ls'', p') => match reset s p' with Some (s'', p'') => Some (s'' :: ls'', p'') | None => None end
… +3 lines
L863new
148Definitionfullb
Definition fullb (s : lab) : bool := match turn s with None => true | Some _ => false end.
L873new
149Lemmavisit3_spec
Lemma visit3_spec ls : forall ls' p nus L R, visit3 ls = Some (ls', p) -> length ls = length nus ->
chs ls nus L <{{D}} R -->+ chs ls' nus L {{stp p}}> R.
L875new
150Lemmapass_spec
Lemma pass_spec ls : forall nus L R, forallb fullb ls = true -> length ls = length nus ->
chs ls nus L <{{D}} R -->* L <{{D}} rchs ls nus R.
L891new
151Lemmacb_spec
Lemma cb_spec ls : forall p ls' p' nus L R, cb ls p = Some (ls', p') -> length ls = length nus ->
L {{stp p}}> rchs ls nus R -->* chs ls' nus L {{stp p'}}> R.
L904new
152Lemmavisit3_len
Lemma visit3_len ls : forall ls' p, visit3 ls = Some (ls', p) -> length ls' = length ls.
L918new
153Lemmacb_len
Lemma cb_len ls : forall p ls' p', cb ls p = Some (ls', p') -> length ls' = length ls.
L927new
154Definitionvst
Definition vst : Type := (list lab * lab1 * nat)%type.
L939new
155Definitionlab1_eqb
Definition lab1_eqb (a b : lab1) : bool :=
match a, b with P0, P0 | P1, P1 | PD0, PD0 | PD1, PD1 | PD2, PD2 => true | _, _ => false end.
L941new
156Definitionvis
Definition vis (st : vst) : option (vst * bool) :=
let '(ls, b, i) := st in
match visit3 ls with
| Some (ls', p) => Some ((ls', b, i), p)
| None =>
  if forallb fullb ls then
… +9 lines
L944new
157Definitionb1s
Definition b1s (b : lab1) (X : side) : side := ev_runs [] (blk1 b) X.
L960new
158DefinitionGc
Definition Gc (st : vst) (nus : list (list N)) (R : side) : Q * tape :=
let '(ls, b, i) := st in chs ls nus (b1s b (LWs i)) <{{D}} R.
L962new
159DefinitionGx
Definition Gx (st : vst) (nus : list (list N)) (p : bool) (R : side) : Q * tape :=
let '(ls, b, i) := st in chs ls nus (b1s b (LWs i)) {{stp p}}> R.
L964new
160Definitionvlen
Definition vlen (st : vst) : nat := let '(ls, _, _) := st in length ls.
L967new
161Lemmalab1_eqb_eq
Lemma lab1_eqb_eq a b : lab1_eqb a b = true -> a = b.
L969new
162Lemmavis_spec
Lemma vis_spec st st' p nus R : vis st = Some (st', p) -> vlen st = length nus ->
Gc st nus R -->+ Gx st' nus p R /\ vlen st' = vlen st.
L972new
163DefinitionEp
Definition Ep (p : bool) (R R' : side) : Prop := forall l, l {{stp p}}> R -->* l <{{D}} R'.
L1002new
164FixpointEpSeq
Fixpoint EpSeq (ps : list bool) (R R' : side) : Prop :=
match ps with
| [] => R = R'
| p :: ps' => exists R1, Ep p R R1 /\ EpSeq ps' R1 R'
end.
L1004new
165Fixpointrunv
Fixpoint runv (n : nat) (st : vst) : option (vst * list bool) :=
match n with
| O => Some (st, [])
| S n' =>
  match vis st with
  | Some (st1, p) => match runv n' st1 with Some (st2, ps) => Some (st2, p :: ps) | None => None end
… +3 lines
L1010new
166Lemmarunv_spec
Lemma runv_spec n : forall st st' ps nus R R', runv n st = Some (st', ps) -> vlen st = length nus ->
EpSeq ps R R' -> Gc st nus R -->* Gc st' nus R'.
L1020new
167Lemmarunv_add
Lemma runv_add a : forall b st st1 ps1 st2 ps2,
runv a st = Some (st1, ps1) -> runv b st1 = Some (st2, ps2) -> runv (a + b) st = Some (st2, ps1 ++ ps2).
L1041new
168Lemmarunv_one
Lemma runv_one st st' p : vis st = Some (st', p) -> runv 1 st = Some (st', [p]).
L1051new
169Lemmavis3
Lemma vis3 ls ls' p b i : visit3 ls = Some (ls', p) -> vis (ls, b, i) = Some ((ls', b, i), p).
L1054new
170Lemmarepeat_add
Lemma repeat_add {X} (x : X) n m : repeat x (n + m) = repeat x n ++ repeat x m.
L1057new
171Lemmarepeat_snoc
Lemma repeat_snoc {X} (x : X) n l : repeat x n ++ x :: l = repeat x (S n) ++ l.
L1060new
172Lemmapow3_pos
Lemma pow3_pos j : 1 <= 3 ^ j.
L1063new
173Lemmavisit3_U2
Lemma visit3_U2 j X X' : visit3 X = Some (X', true) -> visit3 (repeat U2 j ++ X) = Some (repeat U0 j ++ X', true).
L1066new
174Lemmacb_U2
Lemma cb_U2 j X p X' : cb X p = Some (X', true) -> cb (repeat U2 j ++ X) p = Some (repeat U0 j ++ X', true).
L1069new
175Lemmavisit3_full
Lemma visit3_full ls : forallb fullb ls = true -> visit3 ls = None.
L1072new
176Lemmafullb_U2
Lemma fullb_U2 j : forallb fullb (repeat U2 j) = true.
L1079new
177Lemmafullb_D0
Lemma fullb_D0 j : forallb fullb (repeat D0 j) = true.
L1082new
178Lemmafullb_app
Lemma fullb_app a b : forallb fullb a = true -> forallb fullb b = true -> forallb fullb (a ++ b) = true.
L1085new
179Lemmarep_app
Lemma rep_app {X} (x : X) a b : repeat x a ++ repeat x b = repeat x (a + b).
L1088new
180LemmaCU
Lemma CU j : forall rest b i,
runv (3 ^ j - 1) (repeat U0 j ++ rest, b, i) = Some ((repeat U2 j ++ rest, b, i), repeat true (3 ^ j - 1)).
L1092new
181LemmaCW
Lemma CW j : forall rest b i,
runv (3 ^ S j - 1) (repeat U0 j ++ W0 :: rest, b, i) =
  Some ((repeat U2 j ++ D0 :: rest, b, i), repeat true (3 ^ S j - 1)).
L1115new
182Fixpointtc
Fixpoint tc (j : nat) : nat :=
match j with
| O => 0
| S O => 2
| S j' => 3 ^ j + tc j'
end.
L1136new
183Lemmatc_closed
Lemma tc_closed j : 2 * tc (S j) + 5 = 3 ^ S (S j).
L1143new
184LemmaS3
Lemma S3 j : forall d d' rest b i, turn d = Some (d', false) ->
runv (tc (S j) + 1) (repeat U0 j ++ W0 :: d :: rest, b, i) =
  Some ((D2 :: repeat D1 j ++ d' :: rest, b, i), repeat true (tc (S j)) ++ [false]).
L1150new
185DefinitionisD
Definition isD (s : lab) : bool := match s with D0 | D1 | D2 => true | _ => false end.
L1176new
186Definitiondv
Definition dv (s : lab) : nat := match s with D1 => 1 | D0 => 2 | _ => 0 end.
L1177new
187Fixpointdval
Fixpoint dval (ls : list lab) : nat := match ls with [] => 0 | s :: ls' => dv s + 3 * dval ls' end.
L1178new
188Definitiondv1
Definition dv1 (b : lab1) : nat := match b with PD1 => 1 | PD0 => 2 | _ => 0 end.
L1179new
189DefinitionisD1
Definition isD1 (b : lab1) : bool := match b with PD0 | PD1 | PD2 => true | _ => false end.
L1180new
190Lemmadval_lt
Lemma dval_lt ls : forallb isD ls = true -> dval ls < 3 ^ length ls.
L1182new
191Lemmadval_max
Lemma dval_max ls : forallb isD ls = true -> dval ls + 1 = 3 ^ length ls -> ls = repeat D0 (length ls).
L1188new
192Lemmavisit3_D
Lemma visit3_D ls : forallb isD ls = true -> dval ls + 1 < 3 ^ length ls ->
exists ls', visit3 ls = Some (ls', false) /\ forallb isD ls' = true /\ dval ls' = dval ls + 1 /\
  length ls' = length ls.
L1195new
193Lemmacb_D0
Lemma cb_D0 j : cb (repeat D0 j) false = Some (repeat D2 j, false).
L1209new
194LemmaisD_D2
Lemma isD_D2 j : forallb isD (repeat D2 j) = true.
L1212new
195Lemmadval_D2
Lemma dval_D2 j : dval (repeat D2 j) = 0.
L1215new
196Lemmadval_D1
Lemma dval_D1 j : 2 * dval (repeat D1 j) + 1 = 3 ^ j.
L1218new
197LemmaisD_D1
Lemma isD_D1 j : forallb isD (repeat D1 j) = true.
L1221new
198Lemmavis_b1
Lemma vis_b1 ls b b' p1 ls' p i : forallb fullb ls = true -> turn1 b = Some (b', p1) -> cb ls p1 = Some (ls', p) ->
vis (ls, b, i) = Some ((ls', b', i), p).
L1224new
199Lemmavis_co
Lemma vis_co ls ls' p i : forallb fullb ls = true -> i < 80 -> cb ls false = Some (ls', p) ->
vis (ls, PD0, i) = Some ((ls', PD2, S i), p).
L1228new
200LemmaallD
Lemma allD n : forall ls b i, forallb isD ls = true -> isD1 b = true ->
dval ls + 3 ^ length ls * dv1 b + n + 1 = 3 ^ S (length ls) ->
runv n (ls, b, i) = Some ((repeat D0 (length ls), PD0, i), repeat false n).
L1235new
201Lemmacyc
Lemma cyc m i : i < 80 ->
runv (3 ^ S m) (repeat D0 m, PD0, i) = Some ((repeat D0 m, PD0, S i), repeat false (3 ^ S m)).
L1257new
202Lemmacycs
Lemma cycs c : forall m i, i + c <= 80 ->
runv (c * 3 ^ S m) (repeat D0 m, PD0, i) = Some ((repeat D0 m, PD0, i + c), repeat false (c * 3 ^ S m)).
L1267new
203Lemmarep_app_cons
Lemma rep_app_cons {X} (x : X) a b l : repeat x a ++ (repeat x b ++ l) = repeat x (a + b) ++ l.
L1276new
204Lemmaodd_pow3
Lemma odd_pow3 j : exists k, 3 ^ j = 2 * k + 1.
L1279new
205Lemmahalf9
Lemma half9 j : 2 * ((9 * 3 ^ j + 1) / 2) = 9 * 3 ^ j + 1.
L1282new
206Lemmainterval
Lemma interval m : 2 <= m ->
exists T, 2 * T + 5 = 3 ^ S (S m) /\
runv (81 * 3 ^ S m - 1) (repeat U0 m, P0, 0) =
  Some ((repeat D0 m, PD0, 80), repeat true T ++ repeat false (81 * 3 ^ S m - 1 - T)).
L1289new
207Lemmainterval_tm
Lemma interval_tm m nus R R' : 2 <= m -> length nus = m ->
(forall T, 2 * T + 5 = 3 ^ S (S m) -> EpSeq (repeat true T ++ repeat false (81 * 3 ^ S m - 1 - T)) R R') ->
Gc (repeat U0 m, P0, 0) nus R -->* Gc (repeat D0 m, PD0, 80) nus R'.
L1363new
208Lemmarecord_visit
Lemma record_visit m nus R : length nus = m ->
Gc (repeat D0 m, PD0, 80) nus R -->+ chs (repeat D2 m) nus (b1s PD2 (LWs 81)) {{B}}> R.
L1372new
209Fixpointurun
Fixpoint urun (p : positive) (c : cfg) : cfg * bool :=
match p with
| xH => match sstep c with Some (c', _) => (c', false) | None => (c, true) end
| xO p' => let '(c1, s1) := urun p' c in if s1 then (c1, true) else urun p' c1
| xI p' =>
  match sstep c with
… +4 lines
L1388new
210Lemmasstep_ev
Lemma sstep_ev nu sg c c' b : sstep c = Some (c', b) -> ev_cfg nu sg c -->* ev_cfg nu sg c'.
L1399new
211Lemmaurun_spec
Lemma urun_spec p : forall c nu sg, ev_cfg nu sg c -->* ev_cfg nu sg (fst (urun p c)).
L1404new
212DefinitiontgtD
Definition tgtD (c : cfg) : option (list run) :=
match c with
| Lc D ([], TV O) (rr, T0) => Some rr
| _ => None
end.
L1419new
213LemmatgtD_spec
Lemma tgtD_spec c rr : tgtD c = Some rr -> c = Lc D ([], TV 0) (rr, T0).
L1425new
214DefinitionevR
Definition evR (nu : list N) (rr : list run) : side := ev_runs nu rr (const S0).
L1433new
215Definitionep_run
Definition ep_run (p : bool) (rr : list run) : option (list run) :=
tgtD (fst (urun 50000 (Rc (stp p) ([], TV 0) (rr, T0)))).
L1436new
216Lemmaep_run_spec
Lemma ep_run_spec p rr rr' : ep_run p rr = Some rr' -> forall nu, Ep p (evR nu rr) (evR nu rr').
L1439new
217Fixpointeps
Fixpoint eps (ps : list bool) (rr : list run) : option (list run) :=
match ps with
| [] => Some rr
| p :: ps' => match ep_run p rr with Some rr' => eps ps' rr' | None => None end
end.
L1447new
218Lemmaeps_spec
Lemma eps_spec ps : forall rr rr', eps ps rr = Some rr' -> forall nu, EpSeq ps (evR nu rr) (evR nu rr').
L1453new
219LemmaEpSeq_app
Lemma EpSeq_app a : forall b R R1 R2, EpSeq a R R1 -> EpSeq b R1 R2 -> EpSeq (a ++ b) R R2.
L1461new
220DefinitionevN
Definition evN (nu : list N) (a : lf) : N := (lc a + dot (lv a) nu)%N.
L1470new
221Lemmadot_zadd2
Lemma dot_zadd2 v : forall a b, dot v (zadd a b) = (dot v a + dot v b)%N.
L1472new
222Definitionvscale
Definition vscale (k : N) (w : list N) : list N := map (N.mul k) w.
L1478new
223Lemmadot_vscale
Lemma dot_vscale v : forall k w, dot v (vscale k w) = (k * dot v w)%N.
L1480new
224Lemmaev_runs_dot
Lemma ev_runs_dot nu nu' T X : (forall v, dot v nu = dot v nu') -> ev_runs nu T X = ev_runs nu' T X.
L1483new
225Definitionsubst_lf
Definition subst_lf (w : list N) (a : lf) : lf := LF (lc a + dot (lv a) w) (lv a).
L1488new
226Definitionsubst_runs
Definition subst_runs (w : list N) (T : list run) : list run := map (fun r => (fst r, subst_lf w (snd r))) T.
L1489new
227Lemmaev_runs_subst
Lemma ev_runs_subst nu w T X : ev_runs nu (subst_runs w T) X = ev_runs (zadd nu w) T X.
L1491new
228Definitionlf_scale
Definition lf_scale (k : N) (a : lf) : lf := LF (k * lc a) (map (N.mul k) (lv a)).
L1497new
229Lemmadot_scale_l
Lemma dot_scale_l vs : forall k nu, dot (map (N.mul k) vs) nu = (k * dot vs nu)%N.
L1499new
230LemmaevN_add
Lemma evN_add nu a b : evN nu (lf_add a b) = (evN nu a + evN nu b)%N.
L1502new
231LemmaevN_scale
Lemma evN_scale nu k a : evN nu (lf_scale k a) = (k * evN nu a)%N.
L1505new
232Fixpointcomp_aux
Fixpoint comp_aux (vs : list N) (sg : list lf) : lf :=
match vs, sg with
| v :: vs', s :: sg' => lf_add (lf_scale v s) (comp_aux vs' sg')
| _, _ => LF 0 []
end.
L1508new
233Definitioncompose_lf
Definition compose_lf (sg : list lf) (a : lf) : lf := lf_add (LF (lc a) []) (comp_aux (lv a) sg).
L1513new
234Definitioncomp_runs
Definition comp_runs (sg : list lf) (T : list run) : list run := map (fun r => (fst r, compose_lf sg (snd r))) T.
L1514new
235LemmaevN_comp_aux
Lemma evN_comp_aux nu vs : forall sg, evN nu (comp_aux vs sg) = dot vs (map (evN nu) sg).
L1516new
236LemmaevN_compose
Lemma evN_compose nu sg a : evN nu (compose_lf sg a) = evN (map (evN nu) sg) a.
L1522new
237Lemmaev_runs_comp
Lemma ev_runs_comp nu sg T X : ev_runs nu (comp_runs sg T) X = ev_runs (map (evN nu) sg) T X.
L1525new
238Lemmajump_lemma
Lemma jump_lemma T p dec inc :
(forall nu, EpSeq [p; p; p; p] (evR nu (subst_runs dec T)) (evR nu (subst_runs inc T))) ->
forall k nu, EpSeq (repeat p (4 * k)) (evR (zadd nu (vscale (N.of_nat k) dec)) T)
                                      (evR (zadd nu (vscale (N.of_nat k) inc)) T).
L1534new
239Definitionuvar
Definition uvar (i : nat) (c : N) : lf := LF c (repeat 0%N i ++ [4%N]).
L1564new
240Fixpointzsub
Fixpoint zsub (a b : list N) : list N :=
match a, b with
| x :: a', y :: b' => (x - y)%N :: zsub a' b'
| _, [] => a
| [], _ => []
end.
L1566new
241Fixpointmk_jump
Fixpoint mk_jump (i : nat) (rr rr4 : list run) (c : lf) : option (list run * list N * list N * list lf) :=
match rr, rr4 with
| [], [] => Some ([], [], [], [])
| (b, a) :: rr', (b4, a4) :: rr4' =>
  if negb (seqb b b4) then None else
  if negb (listN_eqb (strip0 (lv a)) (strip0 (lv a4))) then None else
… +19 lines
L1573new
242Fixpointmapadd
Fixpoint mapadd (c : lf) (sg : list lf) (w : list N) : list lf :=
match sg, w with
| s :: sg', x :: w' => lf_add s (lf_scale x c) :: mapadd c sg' w'
| _, _ => []
end.
L1599new
243Lemmamapadd_ev
Lemma mapadd_ev nu c sg : forall w, length sg = length w ->
map (evN nu) (mapadd c sg w) = zadd (map (evN nu) sg) (vscale (evN nu c) w).
L1605new
244Definitioncyc4
Definition cyc4 (p : bool) : list bool := [p; p; p; p].
L1613new
245Definitionjump_run
Definition jump_run (p : bool) (c : lf) (rr : list run) : option (list run) :=
match eps (cyc4 p) rr with
| None => None
| Some rr4 =>
  match mk_jump 0 rr rr4 c with
  | None => None
… +11 lines
L1615new
246Lemmajump_run_spec
Lemma jump_run_spec p c rr rr' : jump_run p c rr = Some rr' ->
forall nu, EpSeq (repeat p (4 * ev nu c)) (evR nu rr) (evR nu rr').
L1633new
247Inductiveinstr
Inductive instr := ISingle (p : bool) | IJump (p : bool) (c : lf).
L1656new
248Definitionseg
Definition seg : Type := (bool * lf)%type.
L1658new
249Fixpointsegs_ev
Fixpoint segs_ev (nu : list N) (ss : list seg) : list bool :=
match ss with [] => [] | (p, n) :: ss' => repeat p (ev nu n) ++ segs_ev nu ss' end.
L1660new
250Fixpointexec
Fixpoint exec (prog : list instr) (rr : list run) : option (list run * list seg) :=
match prog with
| [] => Some (rr, [])
| ISingle p :: prog' =>
  match ep_run p rr with
  | Some rr1 => match exec prog' rr1 with Some (rr2, ss) => Some (rr2, (p, cn 1) :: ss) | None => None end
… +8 lines
L1663new
251Lemmaev_scale4
Lemma ev_scale4 nu c : ev nu (lf_scale 4 c) = 4 * ev nu c.
L1678new
252Lemmaexec_spec
Lemma exec_spec prog : forall rr rr' ss, exec prog rr = Some (rr', ss) ->
forall nu, EpSeq (segs_ev nu ss) (evR nu rr) (evR nu rr').
L1682new
253Fixpointsum_ph
Fixpoint sum_ph (p : bool) (ss : list seg) : lf :=
match ss with
| [] => LF 0 []
| (q, n) :: ss' => if Bool.eqb p q then lf_add n (sum_ph p ss') else sum_ph p ss'
end.
L1699new
254Fixpointsplit_ok
Fixpoint split_ok (seen_false : bool) (ss : list seg) : bool :=
match ss with
| [] => true
| (true, _) :: ss' => andb (negb seen_false) (split_ok false ss')
| (false, _) :: ss' => split_ok true ss'
end.
L1704new
255Lemmaev_lf_add
Lemma ev_lf_add nu a b : ev nu (lf_add a b) = ev nu a + ev nu b.
L1711new
256Lemmasplit_false
Lemma split_false ss nu : split_ok true ss = true -> segs_ev nu ss = repeat false (ev nu (sum_ph false ss)).
L1714new
257Lemmasum_false_true
Lemma sum_false_true ss : split_ok true ss = true -> sum_ph true ss = LF 0 [] \/ True.
L1721new
258Lemmasplit_spec
Lemma split_spec ss nu : split_ok false ss = true ->
segs_ev nu ss = repeat true (ev nu (sum_ph true ss)) ++ repeat false (ev nu (sum_ph false ss)).
L1724new
259Definitionprog_check
Definition prog_check (prog : list instr) (rs re : list run) (T F : lf) : bool :=
match exec prog rs with
| Some (re', ss) =>
  andb (andb (runs_eqb re' re) (split_ok false ss)) (andb (lf_eqb (sum_ph true ss) T) (lf_eqb (sum_ph false ss) F))
| None => false
end.
L1737new
260Lemmaprog_check_spec
Lemma prog_check_spec prog rs re T F : prog_check prog rs re T F = true ->
forall nu, EpSeq (repeat true (ev nu T) ++ repeat false (ev nu F)) (evR nu rs) (evR nu re).
L1744new
261Definitiontl1
Definition tl1 (c a : N) : lf := LF c [a].
L1759new
262DefinitionRs_r5
Definition Rs_r5 : list run := mkruns S0 [tl1 224492 1796256; tl1 673559 5388768; cn 8; tl1 9836 78732; tl1 1942069 15536448]%N.
L1760new
263Definitionprog_r5
Definition prog_r5 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 13 ++ [IJump false (tl1 43462 347733)] ++ repeat (ISingle false) 7.
L1761new
264DefinitionRs_r0
Definition Rs_r0 : list run := mkruns S0 [tl1 74804 598752; tl1 224495 1796256; tl1 673560 5388768; tl1 2020752 16166304; cn 4; tl1 521610 4172796; cn 1]%N.
L1762new
265Definitionprog_r0
Definition prog_r0 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 9 ++ [IJump false (tl1 43463 347733)] ++ repeat (ISingle false) 7.
L1763new
266DefinitionRs_r1
Definition Rs_r1 : list run := mkruns S0 [tl1 2020748 16166304; cn 7; tl1 551120 4408992; tl1 1564809 12518388; cn 2]%N.
L1764new
267Definitionprog_r1
Definition prog_r1 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 5 ++ [IJump false (tl1 130398 1043199)] ++ repeat (ISingle false) 4.
L1765new
268DefinitionRs_r2
Definition Rs_r2 : list run := mkruns S0 [tl1 8276 66528; tl1 24911 199584; tl1 74808 598752; tl1 224496 1796256; tl1 673559 5388768; tl1 2020751 16166304; cn 8; tl1 29514 236196; tl1 5826224 46609344; cn 2]%N.
L1766new
269Definitionprog_r2
Definition prog_r2 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 817 6561)] ++ repeat (ISingle true) 6 ++ repeat (ISingle false) 8 ++ [IJump false (tl1 43464 347733)] ++ repeat (ISingle false) 4.
L1767new
270DefinitionRs_r3
Definition Rs_r3 : list run := mkruns S0 [tl1 224492 1796256; tl1 673559 5388768; tl1 2020752 16166304; tl1 6062328 48498912; cn 4; tl1 1564810 12518388]%N.
L1768new
271Definitionprog_r3
Definition prog_r3 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 9 ++ [IJump false (tl1 130397 1043199)] ++ repeat (ISingle false) 4.
L1769new
272DefinitionRs_r4
Definition Rs_r4 : list run := mkruns S0 [tl1 74804 598752; tl1 224495 1796256; tl1 673560 5388768; tl1 2020752 16166304; tl1 6062327 48498912; cn 7; tl1 1653368 13226976; tl1 4694422 37555164; cn 1]%N.
L1770new
273Definitionprog_r4
Definition prog_r4 : list instr := repeat (ISingle true) 4 ++ [IJump true (tl1 2457 19683)] ++ repeat (ISingle true) 7 ++ repeat (ISingle false) 6 ++ [IJump false (tl1 130397 1043199)] ++ repeat (ISingle false) 7.
L1771new
274DefinitionRe_r5
Definition Re_r5 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673560 5388768); (S0, tl1 2020752 16166304); (S1, cn 4); (S0, tl1 521602 4172796)]%N.
L1772new
275Lemmaint_r5
Lemma int_r5 : prog_check prog_r5 Rs_r5 Re_r5 (tl1 3278 26244) (tl1 173868 1390932) = true.
L1773new
276DefinitionRe_r0
Definition Re_r0 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, tl1 2020751 16166304); (S1, cn 7); (S1, tl1 551120 4408992); (S0, tl1 1564798 12518388); (S1, cn 1)]%N.
L1775new
277Lemmaint_r0
Lemma int_r0 : prog_check prog_r0 Rs_r0 Re_r0 (tl1 3278 26244) (tl1 173868 1390932) = true.
L1776new
278DefinitionRe_r1
Definition Re_r1 : list run := [(S0, tl1 2020748 16166304); (S1, cn 8); (S0, tl1 29521 236196); (S0, tl1 5826161 46609344); (S0, cn 2)]%N.
L1778new
279Lemmaint_r1
Lemma int_r1 : prog_check prog_r1 Rs_r1 Re_r1 (tl1 9839 78732) (tl1 521601 4172796) = true.
L1779new
280DefinitionRe_r2
Definition Re_r2 : list run := [(S0, tl1 8276 66528); (S1, tl1 24912 199584); (S0, tl1 74808 598752); (S1, tl1 224495 1796256); (S1, tl1 673559 5388768); (S1, tl1 2020752 16166304); (S0, tl1 6062328 48498912); (S1, cn 3); (S1, tl1 1564801 12518388); (S1, cn 1)]%N.
L1781new
281Lemmaint_r2
Lemma int_r2 : prog_check prog_r2 Rs_r2 Re_r2 (tl1 3278 26244) (tl1 173868 1390932) = true.
L1782new
282DefinitionRe_r3
Definition Re_r3 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673560 5388768); (S0, tl1 2020752 16166304); (S1, tl1 6062327 48498912); (S1, cn 7); (S1, tl1 1653368 13226976); (S0, tl1 4694397 37555164); (S0, cn 2)]%N.
L1784new
283Lemmaint_r3
Lemma int_r3 : prog_check prog_r3 Rs_r3 Re_r3 (tl1 9839 78732) (tl1 521601 4172796) = true.
L1785new
284DefinitionRe_r4
Definition Re_r4 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, tl1 2020751 16166304); (S1, tl1 6062327 48498912); (S1, cn 7); (S1, tl1 88573 708588); (S1, tl1 17478488 139828032); (S0, cn 2)]%N.
L1787new
285Lemmaint_r4
Lemma int_r4 : prog_check prog_r4 Rs_r4 Re_r4 (tl1 9839 78732) (tl1 521601 4172796) = true.
L1788new
286Definitionrtop
Definition rtop (qs : list (list N)) (z : N) : N :=
match qs with [] => z | q :: _ => nth 0 q 0%N end.
L1796new
287Fixpointrshift
Fixpoint rshift (qs : list (list N)) (z : N) : list (list N) :=
match qs with
| [] => []
| q :: qs' => [nth 1 q 0; nth 2 q 0; nth 3 q 0; rtop qs' z]%N :: rshift qs' z
end.
L1799new
288Lemmashift_len
Lemma shift_len qs z : length (rshift qs z) = length qs.
L1805new
289Lemmadot4
Lemma dot4 (a b c d : N) q :
dot [a; b; c; d] q = (a * nth 0 q 0 + b * nth 1 q 0 + c * nth 2 q 0 + d * nth 3 q 0)%N.
L1808new
290Lemmaalt_split
Lemma alt_split b m k : Nat.eqb (m mod 2) 0 = true -> alt b (m + k) = alt b m ++ alt b k.
L1812new
291Lemmaev_q
Lemma ev_q nu c a : ev nu (LF c a) = N.to_nat (c + dot a nu).
L1817new
292Lemmaregroup
Lemma regroup qs : forall z X X',
X = alt S0 1 *> (alt S0 (2 + 4 * N.to_nat z) *> X') ->
chs (repeat D2 (length qs)) qs X =
  alt S0 1 *> (alt S0 (2 + 4 * N.to_nat (rtop qs z)) *> chs (repeat U0 (length qs)) (rshift qs z) X').
L1820new
293Lemmaregroup_b1
Lemma regroup_b1 : b1s PD2 (LWs 81) = alt S0 1 *> (alt S0 (2 + 4 * N.to_nat 0) *> b1s P0 (LWs 0)).
L1849new
294Lemmadrop_step
Lemma drop_step L Re Rs nu X' :
reach 100000 (Rc B (L, TV 0) (Re, T0)) (Lc D ([], TV 0) (Rs, T0)) = true ->
ev_runs nu L X' {{B}}> evR nu Re -->+ X' <{{D}} evR nu Rs.
L1856new
295DefinitionW5t
Definition W5t (t : N) : N := (18701 + 149688 * t)%N.
L1861new
296DefinitionW5s
Definition W5s (t : N) : N := (6227 + 49896 * t)%N.
L1862new
297DefinitionW5a
Definition W5a (t : N) : N := (2069 + 16632 * t)%N.
L1863new
298Lemmarec_r5_ok
Lemma rec_r5_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 74806 598752)], TV 0) (Re_r5, T0)) (Lc D ([], TV 0) (Rs_r0, T0)) = true.
L1865new
299Lemmastep_r5
Lemma step_r5 t f1 deep :
chs (repeat D2 (S (length deep))) ([W5t t; W5s t; W5a t; f1] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r5 -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r0).
L1868new
300Lemmapow_K0
Lemma pow_K0 k0 e : 2 <= e -> 3 ^ (k0 + 2 * e) = 3 ^ (k0 + 4) * 9 ^ (e - 2).
L1880new
301LemmaS_r5
Lemma S_r5 e t f1 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
Gc (repeat U0 (S (length deep)), P0, 0) ([W5t t; W5s t; W5a t; f1] :: deep) (evR [t] Rs_r5) -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([W5s t; W5a t; f1; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r0).
L1887new
302Definitionwv
Definition wv (c a t : N) : N := (c + a * t)%N.
L1909new
303LemmaevN_tl1
Lemma evN_tl1 c a t : evN [t] (tl1 c a) = wv c a t.
L1911new
304Lemmatake_step
Lemma take_step L first4 Re' Rs nu sg X' :
reach 100000 (Rc B (L, TV 0) (first4, TV 1)) (Rc A (comp_runs sg (blk U0), TV 0) ([], TV 1)) = true ->
ep_run true Re' = Some Rs ->
ev_runs nu L X' {{B}}> ev_runs nu first4 (evR nu Re') -->+
  ev_runs (map (evN nu) sg) (blk U0) X' <{{D}} evR nu Rs.
L1914new
305Lemmasplit4
Lemma split4 nu r1 r2 r3 b c v rest X :
ev_runs nu (r1 :: r2 :: r3 :: (b, LF (3 + c) v) :: rest) X =
ev_runs nu [r1; r2; r3; (b, cn 3)] (ev_runs nu ((sneg b, LF c v) :: rest) X).
L1927new
306DefinitionW0t
Definition W0t := wv 6227 49896.
L1941new
307DefinitionW0s
Definition W0s := wv 2069 16632.
L1942new
308DefinitionW1t
Definition W1t := wv 168389 1347192.
L1943new
309DefinitionW1s
Definition W1s := wv 56123 449064.
L1944new
310DefinitionW1a
Definition W1a := wv 18701 149688.
L1945new
311DefinitionW1I
Definition W1I := wv 6227 49896.
L1946new
312DefinitionW1u
Definition W1u := wv 2069 16632.
L1947new
313Definitionsig01
Definition sig01 : list lf := [tl1 168389 1347192; tl1 56123 449064; tl1 18701 149688; tl1 6227 49896]%N.
L1949new
314Definitionf4_r0
Definition f4_r0 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, cn 3)]%N.
L1950new
315DefinitionRp_r0
Definition Rp_r0 : list run := [(S0, tl1 2020748 16166304); (S1, cn 7); (S1, tl1 551120 4408992); (S0, tl1 1564798 12518388); (S1, cn 1)]%N.
L1951new
316Lemmarec_r0a
Lemma rec_r0a : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 24910 199584)], TV 0) (f4_r0, TV 1))
(Rc A (comp_runs sig01 (blk U0), TV 0) ([], TV 1)) = true.
L1953new
317Lemmarec_r0b
Lemma rec_r0b : ep_run true Rp_r0 = Some Rs_r1.
L1956new
318Lemmasplit_r0
Lemma split_r0 t : evR [t] Re_r0 = ev_runs [t] f4_r0 (evR [t] Rp_r0).
L1959new
319Lemmastep_r0
Lemma step_r0 t f1 f2 deep :
chs (repeat D2 (S (length deep))) ([W0t t; W0s t; f1; f2] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r0 -->+
Gc (repeat U0 (S (S (length deep))), P0, 0)
   ([W1t t; W1s t; W1a t; W1I t] :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r1).
L1965new
320DefinitionW3t
Definition W3t := wv 18701 149688.
L1985new
321Lemmarec_r3_ok
Lemma rec_r3_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 74806 598752)], TV 0) (Re_r3, T0)) (Lc D ([], TV 0) (Rs_r4, T0)) = true.
L1987new
322Lemmastep_r3
Lemma step_r3 t f1 f2 f3 deep :
chs (repeat D2 (S (length deep))) ([W3t t; f1; f2; f3] :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r3 -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r4).
L1990new
323Definitionsig12
Definition sig12 : list lf := [tl1 56123 449064; tl1 18701 149688; tl1 6227 49896; tl1 2069 16632]%N.
L2004new
324Lemmarec_r1_ok
Lemma rec_r1_ok : reach 100000 (Rc B ([(S0, cn 1); (S0, tl1 673558 5388768)] ++ comp_runs sig12 (blk U0), TV 0) (Re_r1, T0))
(Lc D ([], TV 0) (Rs_r2, T0)) = true.
L2006new
325Lemmastep_r1
Lemma step_r1 t f1 f2 f3 deep :
chs (repeat D2 (S (S (length deep)))) ([W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep) (b1s PD2 (LWs 81))
  {{B}}> evR [t] Re_r1 -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r2).
L2010new
326Definitionxv
Definition xv : lf := LF 2 [0; 4]%N.
L2030new
327Definitionsig23
Definition sig23 : list lf := [tl1 18701 149688; tl1 6227 49896; tl1 2069 16632; LF 0 [0; 1]]%N.
L2031new
328Definitionf4_r2
Definition f4_r2 : list run := [(S0, tl1 8276 66528); (S1, tl1 24912 199584); (S0, tl1 74808 598752); (S1, cn 3)]%N.
L2032new
329DefinitionRp_r2
Definition Rp_r2 : list run := [(S0, tl1 224492 1796256); (S1, tl1 673559 5388768); (S1, tl1 2020752 16166304);
(S0, tl1 6062328 48498912); (S1, cn 3); (S1, tl1 1564801 12518388); (S1, cn 1)]%N.
L2033new
330Lemmarec_r2a
Lemma rec_r2a : reach 100000 (Rc B ([(S0, cn 1); (S0, xv)], TV 0) (f4_r2, TV 1))
(Rc A (comp_runs sig23 (blk U0), TV 0) ([], TV 1)) = true.
L2036new
331Lemmarec_r2b
Lemma rec_r2b : ep_run true Rp_r2 = Some Rs_r3.
L2039new
332Lemmasplit_r2
Lemma split_r2 nu : evR nu Re_r2 = ev_runs nu f4_r2 (evR nu Rp_r2).
L2042new
333Lemmastep_r2
Lemma step_r2 t q deep :
chs (repeat D2 (S (length deep))) (q :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r2 -->+
Gc (repeat U0 (S (S (length deep))), P0, 0)
   ([W3t t; wv 6227 49896 t; wv 2069 16632 t; nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [t] Rs_r3).
L2048new
334Definitionsub9_lf
Definition sub9_lf (l : lf) : lf := match lv l with [a] => LF (lc l + a) [9 * a] | _ => l end%N.
L2071new
335Definitionsub9
Definition sub9 (rs : list run) : list run := map (fun r => (fst r, sub9_lf (snd r))) rs.
L2072new
336Lemmaev_runs_sub9
Lemma ev_runs_sub9 t rs X : forallb (fun r => Nat.leb (length (lv (snd r))) 1) rs = true ->
ev_runs [t] (sub9 rs) X = ev_runs [(1 + 9 * t)%N] rs X.
L2074new
337LemmaevR_sub9_r5
Lemma evR_sub9_r5 t : evR [t] (sub9 Rs_r5) = evR [(1 + 9 * t)%N] Rs_r5.
L2082new
338Definitionsig45
Definition sig45 : list lf := [tl1 168389 1347192; tl1 56123 449064; tl1 18701 149688; LF 0 [0; 1]]%N.
L2085new
339Definitionf4_r4
Definition f4_r4 : list run := [(S0, tl1 74804 598752); (S1, tl1 224496 1796256); (S0, tl1 673560 5388768); (S1, cn 3)]%N.
L2086new
340DefinitionRp_r4
Definition Rp_r4 : list run := [(S0, tl1 2020748 16166304); (S1, tl1 6062327 48498912); (S1, cn 7);
(S1, tl1 88573 708588); (S1, tl1 17478488 139828032); (S0, cn 2)]%N.
L2087new
341Lemmarec_r4a
Lemma rec_r4a : reach 100000 (Rc B ([(S0, cn 1); (S0, xv)], TV 0) (f4_r4, TV 1))
(Rc A (comp_runs sig45 (blk U0), TV 0) ([], TV 1)) = true.
L2090new
342Lemmarec_r4b
Lemma rec_r4b : ep_run true Rp_r4 = Some (sub9 Rs_r5).
L2093new
343Lemmasplit_r4
Lemma split_r4 nu : evR nu Re_r4 = ev_runs nu f4_r4 (evR nu Rp_r4).
L2096new
344Lemmastep_r4
Lemma step_r4 t q deep :
chs (repeat D2 (S (length deep))) (q :: deep) (b1s PD2 (LWs 81)) {{B}}> evR [t] Re_r4 -->+
Gc (repeat U0 (S (S (length deep))), P0, 0)
   ([W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); nth 0 q 0%N] :: rshift (q :: deep) 0%N)
   (evR [(1 + 9 * t)%N] Rs_r5).
L2102new
345LemmaS_r0
Lemma S_r0 e t f1 f2 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
Gc (repeat U0 (S (length deep)), P0, 0) ([W0t t; W0s t; f1; f2] :: deep) (evR [t] Rs_r0) -->+
Gc (repeat U0 (S (S (length deep))), P0, 0) ([W1t t; W1s t; W1a t; W1I t] :: [W0s t; f1; f2; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r1).
L2125new
346LemmaS_r1
Lemma S_r1 e t f1 f2 f3 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
Gc (repeat U0 (S (S (length deep))), P0, 0) ([W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep) (evR [t] Rs_r1) -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r2).
L2147new
347LemmaS_r2
Lemma S_r2 e t q deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 1 + 2 * e ->
Gc (repeat U0 (S (length deep)), P0, 0) (q :: deep) (evR [t] Rs_r2) -->+
Gc (repeat U0 (S (S (length deep))), P0, 0) ([W3t t; wv 6227 49896 t; wv 2069 16632 t; nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [t] Rs_r3).
L2169new
348LemmaS_r3
Lemma S_r3 e t f1 f2 f3 deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 2 + 2 * e ->
Gc (repeat U0 (S (length deep)), P0, 0) ([W3t t; f1; f2; f3] :: deep) (evR [t] Rs_r3) -->+
Gc (repeat U0 (S (length deep)), P0, 0) ([f1; f2; f3; rtop deep 0%N] :: rshift deep 0%N) (evR [t] Rs_r4).
L2191new
349LemmaS_r4
Lemma S_r4 e t q deep : 2 <= e -> 1 + 8 * N.to_nat t = 9 ^ (e - 2) -> length deep = 2 + 2 * e ->
Gc (repeat U0 (S (length deep)), P0, 0) (q :: deep) (evR [t] Rs_r4) -->+
Gc (repeat U0 (S (S (length deep))), P0, 0) ([W5t (1 + 9 * t); W5s (1 + 9 * t); W5a (1 + 9 * t); nth 0 q 0%N] :: rshift (q :: deep) 0%N) (evR [(1 + 9 * t)%N] Rs_r5).
L2213new
350Definitioncfg28
Definition cfg28 : cfg :=
Rc B
  ([(S0, cn 74808); (S1, cn 24912); (S0, cn 8277); (S0, cn 2737); (S0, cn 972); (S1, cn 36);
    (S0, cn 37); (S0, cn 37); (S0, cn 44); (S1, cn 24); (S0, cn 13); (S0, cn 9);
    (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5);
    (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 6); (S1, cn 4); (S0, cn 1);
… +2 lines
L2239new
351Definitionmkc
Definition mkc (rc : bool) (q : Q) (l r : list (Sym * N)) : cfg :=
let f := map (fun x : Sym * N => (fst x, cn (snd x))) in
if rc then Rc q (f l, T0) (f r, T0) else Lc q (f l, T0) (f r, T0).
L2250new
352Definitionb28_0
Definition b28_0 : cfg := mkc true A [] [].
L2253new
353Definitionb28_1
Definition b28_1 : cfg := mkc true F [(S0, 1%N); (S0, 5003%N); (S0, 9%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 21%N); (S0, 17%N); (S0, 8%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 34783%N); (S0, 2%N)].
L2254new
354Definitionb28_2
Definition b28_2 : cfg := mkc false C [(S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S0, 2734%N); (S1, 8280%N); (S0, 24912%N); (S1, 74807%N); (S1, 7%N); (S1, 20408%N); (S0, 18958%N); (S1, 1%N)].
L2255new
355Definitionb28_3
Definition b28_3 : cfg := mkc false E [(S0, 24913%N); (S0, 8280%N); (S1, 2736%N); (S0, 969%N); (S0, 37%N); (S0, 40%N); (S1, 36%N); (S0, 41%N); (S0, 25%N); (S0, 16%N); (S1, 8%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 74805%N); (S1, 8%N); (S0, 15237%N); (S0, 102601%N); (S0, 2%N)].
L2256new
356Definitionb28_4
Definition b28_4 : cfg := mkc true B [(S1, 8%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 16%N); (S1, 23%N); (S1, 43%N); (S1, 36%N); (S0, 40%N); (S1, 35%N); (S1, 971%N); (S1, 2736%N); (S0, 8280%N); (S1, 24911%N); (S1, 74807%N); (S1, 8%N); (S0, 2576%N); (S1, 203893%N)].
L2257new
357Definitionb28_5
Definition b28_5 : cfg := mkc false D [(S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 23%N); (S0, 15%N); (S0, 8%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 4%N); (S0, 47814%N); (S1, 1%N)].
L2258new
358Definitionb28_6
Definition b28_6 : cfg := mkc false D [(S1, 55470%N); (S0, 61233%N); (S0, 7%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
L2259new
359Definitionb28_7
Definition b28_7 : cfg := mkc true B [(S1, 61232%N); (S0, 5%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 126903%N); (S1, 1%N)].
L2260new
360Definitionb28_8
Definition b28_8 : cfg := mkc true A [(S0, 204457%N); (S0, 58637%N); (S0, 9%N); (S0, 224494%N); (S1, 74808%N); (S0, 24912%N); (S1, 8280%N); (S0, 2735%N); (S0, 971%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
L2261new
361Definitionb28_9
Definition b28_9 : cfg := mkc true B [(S1, 45980%N); (S0, 9%N); (S0, 224494%N); (S1, 74808%N); (S0, 24912%N); (S1, 8280%N); (S0, 2734%N); (S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 7%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N); (S1, 305726%N); (S0, 2%N)].
L2262new
362Definitionb28_10
Definition b28_10 : cfg := mkc true B [(S1, 40%N); (S0, 34%N); (S1, 44%N); (S0, 24%N); (S1, 16%N); (S0, 5%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S0, 36%N); (S1, 971%N); (S1, 2735%N); (S1, 8280%N); (S0, 24912%N); (S1, 74807%N); (S1, 224495%N); (S1, 8%N); (S0, 33320%N); (S1, 407005%N)].
L2263new
363Definitionb28_11
Definition b28_11 : cfg := mkc true B [(S0, 20664%N); (S1, 8%N); (S0, 224495%N); (S0, 74807%N); (S0, 24912%N); (S1, 8280%N); (S0, 2734%N); (S1, 972%N); (S0, 36%N); (S1, 40%N); (S0, 33%N); (S0, 45%N); (S0, 24%N); (S1, 16%N); (S0, 6%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 508270%N); (S0, 2%N)].
L2264new
364Definitionb28_12
Definition b28_12 : cfg := mkc false D [(S1, 8%N); (S0, 224493%N); (S0, 74809%N); (S0, 24912%N); (S1, 8280%N); (S0, 2733%N); (S0, 973%N); (S0, 36%N); (S1, 40%N); (S0, 33%N); (S0, 45%N); (S0, 24%N); (S1, 16%N); (S0, 7%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 8001%N); (S0, 609553%N); (S0, 2%N)].
L2265new
365Definitionb28_13
Definition b28_13 : cfg := mkc true B [(S1, 224496%N); (S0, 74805%N); (S0, 24913%N); (S0, 8280%N); (S1, 2736%N); (S0, 970%N); (S1, 36%N); (S0, 40%N); (S1, 36%N); (S0, 41%N); (S0, 25%N); (S0, 16%N); (S1, 8%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 673560%N); (S1, 4%N); (S0, 22085%N); (S0, 2%N)].
L2266new
366Definitionb28_14
Definition b28_14 : cfg := mkc false D [(S0, 74806%N); (S1, 24912%N); (S0, 8280%N); (S1, 2736%N); (S0, 971%N); (S0, 35%N); (S0, 40%N); (S1, 36%N); (S0, 43%N); (S0, 23%N); (S0, 16%N); (S1, 8%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 224496%N); (S0, 673560%N); (S1, 3%N); (S1, 82093%N); (S1, 1%N)].
L2267new
367Definitionb28_15
Definition b28_15 : cfg := mkc false A [(S0, 1%N); (S0, 24911%N); (S0, 8280%N); (S1, 2736%N); (S0, 970%N); (S1, 36%N); (S0, 40%N); (S1, 36%N); (S0, 43%N); (S0, 23%N); (S0, 16%N); (S1, 8%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 74805%N); (S1, 224496%N); (S0, 673560%N); (S1, 4%N); (S0, 142098%N); (S1, 1%N)].
L2268new
368Definitionb28_16
Definition b28_16 : cfg := mkc false D [(S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S0, 21909%N); (S0, 2%N)].
L2269new
369Definitionb28_17
Definition b28_17 : cfg := mkc true B [(S1, 93339%N); (S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24910%N); (S1, 8280%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [].
L2270new
370Definitionb28_18
Definition b28_18 : cfg := mkc false A [(S0, 1%N); (S0, 164770%N); (S1, 183704%N); (S0, 6%N); (S1, 673560%N); (S0, 224496%N); (S1, 74808%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
L2271new
371Definitionb28_19
Definition b28_19 : cfg := mkc true B [(S0, 5%N); (S0, 673561%N); (S0, 224496%N); (S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 183703%N); (S1, 236201%N); (S1, 1%N)].
L2272new
372Definitionb28_20
Definition b28_20 : cfg := mkc false D [(S1, 307633%N); (S1, 183704%N); (S0, 7%N); (S0, 673559%N); (S0, 224496%N); (S1, 74808%N); (S0, 24909%N); (S0, 8281%N); (S0, 2736%N); (S1, 972%N); (S0, 34%N); (S1, 40%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N)].
L2273new
373Definitionb28_21
Definition b28_21 : cfg := mkc false D [(S1, 74808%N); (S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S0, 224496%N); (S1, 673559%N); (S1, 7%N); (S1, 183704%N); (S0, 379066%N); (S1, 1%N)].
L2274new
374Definitionb28_22
Definition b28_22 : cfg := mkc true B [(S0, 7%N); (S0, 673559%N); (S0, 224496%N); (S1, 74808%N); (S0, 24910%N); (S1, 8280%N); (S0, 2736%N); (S1, 972%N); (S0, 33%N); (S0, 41%N); (S0, 36%N); (S1, 44%N); (S0, 22%N); (S1, 16%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 183703%N); (S1, 450497%N); (S1, 1%N)].
L2275new
375Definitionb28_23
Definition b28_23 : cfg := mkc false D [(S0, 24911%N); (S0, 8279%N); (S0, 2736%N); (S1, 972%N); (S0, 35%N); (S0, 39%N); (S0, 36%N); (S1, 44%N); (S0, 21%N); (S0, 17%N); (S0, 8%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 6%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 74808%N); (S0, 224496%N); (S1, 673559%N); (S1, 7%N); (S1, 183704%N); (S0, 521925%N); (S0, 2%N)].
L2276new
376Definitionb28_24
Definition b28_24 : cfg := mkc false D [(S1, 1%N); (S1, 611006%N); (S0, 176219%N); (S0, 9%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
L2277new
377Definitionb28_25
Definition b28_25 : cfg := mkc true B [(S1, 712274%N); (S0, 163560%N); (S1, 8%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 1%N)].
L2278new
378Definitionb28_26
Definition b28_26 : cfg := mkc true B [(S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [(S1, 24912%N); (S0, 74808%N); (S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 150901%N); (S0, 813545%N); (S0, 2%N)].
L2279new
379Definitionb28_27
Definition b28_27 : cfg := mkc true B [(S0, 914810%N); (S1, 138244%N); (S0, 9%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N)] [].
L2280new
380Definitionb28_28
Definition b28_28 : cfg := mkc true B [(S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 125586%N); (S1, 1016072%N); (S0, 2%N)].
L2281new
381Definitionb28_29
Definition b28_29 : cfg := mkc true B [(S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 8%N); (S0, 112925%N); (S0, 1117353%N); (S0, 2%N)].
L2282new
382Definitionb28_30
Definition b28_30 : cfg := mkc false A [(S0, 1%N); (S0, 7%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N); (S1, 100267%N); (S1, 1218616%N); (S0, 2%N)].
L2283new
383Definitionb28_31
Definition b28_31 : cfg := mkc true C [(S1, 1%N); (S1, 1319886%N); (S0, 87610%N); (S1, 8%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [].
L2284new
384Definitionb28_32
Definition b28_32 : cfg := mkc false A [(S0, 1%N); (S0, 1421144%N); (S1, 74952%N); (S0, 9%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N)] [(S1, 1%N)].
L2285new
385Definitionb28_33
Definition b28_33 : cfg := mkc false D [(S1, 1522415%N); (S1, 62293%N); (S1, 8%N); (S0, 673558%N); (S1, 224496%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 2%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 1%N)].
L2286new
386Definitionb28_34
Definition b28_34 : cfg := mkc false E [(S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 37%N); (S0, 37%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 673557%N); (S1, 8%N); (S0, 49634%N); (S1, 1623688%N); (S0, 2%N)].
L2287new
387Definitionb28_35
Definition b28_35 : cfg := mkc true B [(S0, 36974%N); (S1, 8%N); (S0, 673559%N); (S0, 224495%N); (S0, 74808%N); (S1, 24912%N); (S0, 8279%N); (S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 15%N); (S0, 7%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1724965%N)].
L2288new
388Definitionb28_36
Definition b28_36 : cfg := mkc false D [(S1, 1826223%N); (S1, 24317%N); (S1, 8%N); (S0, 673557%N); (S0, 224497%N); (S0, 74808%N); (S1, 24912%N); (S0, 8278%N); (S1, 2736%N); (S0, 972%N); (S1, 36%N); (S0, 39%N); (S0, 35%N); (S0, 44%N); (S1, 24%N); (S0, 13%N); (S0, 9%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 1%N); (S0, 5%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 1%N); (S1, 1%N)].
L2289new
389Definitionb28_37
Definition b28_37 : cfg := mkc false D [(S0, 2735%N); (S0, 972%N); (S1, 36%N); (S0, 38%N); (S1, 36%N); (S0, 44%N); (S1, 24%N); (S0, 14%N); (S1, 8%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 2%N); (S1, 4%N); (S0, 4%N); (S1, 4%N); (S0, 1%N); (S0, 5%N); (S0, 4%N); (S1, 4%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 3%N); (S0, 2%N)] [(S1, 8279%N); (S1, 24912%N); (S0, 74808%N); (S1, 224495%N); (S1, 673559%N); (S1, 8%N); (S0, 11658%N); (S1, 1927496%N); (S0, 2%N)].
L2290new
390Lemmack_0
Lemma ck_0 : runp 500000 b28_0 = Some (b28_1, true).
L2291new
391Lemmack_1
Lemma ck_1 : runp 500000 b28_1 = Some (b28_2, true).
L2293new
392Lemmack_2
Lemma ck_2 : runp 500000 b28_2 = Some (b28_3, true).
L2295new
393Lemmack_3
Lemma ck_3 : runp 500000 b28_3 = Some (b28_4, true).
L2297new
394Lemmack_4
Lemma ck_4 : runp 500000 b28_4 = Some (b28_5, true).
L2299new
395Lemmack_5
Lemma ck_5 : runp 500000 b28_5 = Some (b28_6, true).
L2301new
396Lemmack_6
Lemma ck_6 : runp 500000 b28_6 = Some (b28_7, true).
L2303new
397Lemmack_7
Lemma ck_7 : runp 500000 b28_7 = Some (b28_8, true).
L2305new
398Lemmack_8
Lemma ck_8 : runp 500000 b28_8 = Some (b28_9, true).
L2307new
399Lemmack_9
Lemma ck_9 : runp 500000 b28_9 = Some (b28_10, true).
L2309new
400Lemmack_10
Lemma ck_10 : runp 500000 b28_10 = Some (b28_11, true).
L2311new
401Lemmack_11
Lemma ck_11 : runp 500000 b28_11 = Some (b28_12, true).
L2313new
402Lemmack_12
Lemma ck_12 : runp 500000 b28_12 = Some (b28_13, true).
L2315new
403Lemmack_13
Lemma ck_13 : runp 500000 b28_13 = Some (b28_14, true).
L2317new
404Lemmack_14
Lemma ck_14 : runp 500000 b28_14 = Some (b28_15, true).
L2319new
405Lemmack_15
Lemma ck_15 : runp 500000 b28_15 = Some (b28_16, true).
L2321new
406Lemmack_16
Lemma ck_16 : runp 500000 b28_16 = Some (b28_17, true).
L2323new
407Lemmack_17
Lemma ck_17 : runp 500000 b28_17 = Some (b28_18, true).
L2325new
408Lemmack_18
Lemma ck_18 : runp 500000 b28_18 = Some (b28_19, true).
L2327new
409Lemmack_19
Lemma ck_19 : runp 500000 b28_19 = Some (b28_20, true).
L2329new
410Lemmack_20
Lemma ck_20 : runp 500000 b28_20 = Some (b28_21, true).
L2331new
411Lemmack_21
Lemma ck_21 : runp 500000 b28_21 = Some (b28_22, true).
L2333new
412Lemmack_22
Lemma ck_22 : runp 500000 b28_22 = Some (b28_23, true).
L2335new
413Lemmack_23
Lemma ck_23 : runp 500000 b28_23 = Some (b28_24, true).
L2337new
414Lemmack_24
Lemma ck_24 : runp 500000 b28_24 = Some (b28_25, true).
L2339new
415Lemmack_25
Lemma ck_25 : runp 500000 b28_25 = Some (b28_26, true).
L2341new
416Lemmack_26
Lemma ck_26 : runp 500000 b28_26 = Some (b28_27, true).
L2343new
417Lemmack_27
Lemma ck_27 : runp 500000 b28_27 = Some (b28_28, true).
L2345new
418Lemmack_28
Lemma ck_28 : runp 500000 b28_28 = Some (b28_29, true).
L2347new
419Lemmack_29
Lemma ck_29 : runp 500000 b28_29 = Some (b28_30, true).
L2349new
420Lemmack_30
Lemma ck_30 : runp 500000 b28_30 = Some (b28_31, true).
L2351new
421Lemmack_31
Lemma ck_31 : runp 500000 b28_31 = Some (b28_32, true).
L2353new
422Lemmack_32
Lemma ck_32 : runp 500000 b28_32 = Some (b28_33, true).
L2355new
423Lemmack_33
Lemma ck_33 : runp 500000 b28_33 = Some (b28_34, true).
L2357new
424Lemmack_34
Lemma ck_34 : runp 500000 b28_34 = Some (b28_35, true).
L2359new
425Lemmack_35
Lemma ck_35 : runp 500000 b28_35 = Some (b28_36, true).
L2361new
426Lemmack_36
Lemma ck_36 : runp 500000 b28_36 = Some (b28_37, true).
L2363new
427Lemmack_37
Lemma ck_37 : runp 71896 b28_37 = Some (cfg28, true).
L2365new
428Lemmack_ev
Lemma ck_ev p c c' : runp p c = Some (c', true) ->
ev_cfg [] (fun _ => const S0) c -->* ev_cfg [] (fun _ => const S0) c'.
L2367new
429Lemmainit28
Lemma init28 : c0 -->* ev_cfg [] (fun _ => const S0) cfg28.
L2371new
430Inductivecls
Inductive cls := C5 | C0 | C1 | C2 | C3 | C4.
L2419new
431DefinitionRs
Definition Rs (r : cls) : list run :=
match r with C5 => Rs_r5 | C0 => Rs_r0 | C1 => Rs_r1 | C2 => Rs_r2 | C3 => Rs_r3 | C4 => Rs_r4 end.
L2421new
432Definitionist
Definition ist : Type := (cls * nat * N * list (list N))%type.
L2424new
433DefinitioncfgI
Definition cfgI (s : ist) : Q * tape :=
let '(r, e, t, nus) := s in Gc (repeat U0 (length nus), P0, 0) nus (evR [t] (Rs r)).
L2426new
434Definitionwin
Definition win (r : cls) (e : nat) (t : N) (nus : list (list N)) : Prop :=
match r with
| C5 => exists f1 deep, nus = [W5t t; W5s t; W5a t; f1] :: deep /\ length deep = 1 + 2 * e
| C0 => exists f1 f2 deep, nus = [W0t t; W0s t; f1; f2] :: deep /\ length deep = 1 + 2 * e
| C1 => exists f1 f2 f3 deep, nus = [W1t t; W1s t; W1a t; W1I t] :: [W1u t; f1; f2; f3] :: deep /\
          length deep = 1 + 2 * e
… +4 lines
L2429new
435DefinitionInv
Definition Inv (s : ist) : Prop :=
let '(r, e, t, nus) := s in 2 <= e /\ 1 + 8 * N.to_nat t = 9 ^ (e - 2) /\ win r e t nus.
L2440new
436Lemmainv_step
Lemma inv_step s : Inv s -> exists s', cfgI s -->+ cfgI s' /\ Inv s'.
L2443new
437DefinitionL28
Definition L28 : list run :=
[(S0, cn 74808); (S1, cn 24912); (S0, cn 8277); (S0, cn 2737); (S0, cn 972); (S1, cn 36);
 (S0, cn 37); (S0, cn 37); (S0, cn 44); (S1, cn 24); (S0, cn 13); (S0, cn 9);
 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5);
 (S0, cn 4); (S1, cn 4); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 6); (S1, cn 4); (S0, cn 1);
 (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 1); (S0, cn 5); (S0, cn 2)]%N.
L2486new
438DefinitionR28
Definition R28 : list run := [(S0, cn 224492); (S1, cn 673559); (S1, cn 7); (S1, cn 9841); (S1, cn 1942040); (S0, cn 2)]%N.
L2492new
439Definitionnus28
Definition nus28 : list (list N) :=
[[18701; 6227; 2069; 683]; [242; 8; 9; 8]; [10; 5; 3; 1]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]]%N.
L2494new
440Lemmainv28
Lemma inv28 : Inv (C5, 2, 0%N, nus28).
L2497new
441Lemmasplit1
Lemma split1 nu b c v rest X :
ev_runs nu ((b, LF (3 + c) v) :: rest) X = ev_runs nu [(b, cn 3)] (ev_runs nu ((sneg b, LF c v) :: rest) X).
L2503new
442Lemmab28a
Lemma b28a : reach 1000 (Rc B (L28, T0) ([(S1, cn 3)], TV 1)) (Rc A ((S0, cn 3) :: L28, T0) ([], TV 1)) = true.
L2511new
443Lemmab28b
Lemma b28b : ep_run true R28 = Some (map (fun r => (fst r, cn (evN [0%N] (snd r)))) Rs_r5).
L2514new
444Lemmab28_chain
Lemma b28_chain : ev_runs [] ((S0, cn 3) :: L28) (const S0) = chs (repeat U0 6) nus28 (b1s P0 (LWs 0)).
L2517new
445Lemmab28_right
Lemma b28_right : evR [] (map (fun r => (fst r, cn (evN [0%N] (snd r)))) Rs_r5) = evR [0%N] Rs_r5.
L2520new
446Lemmabase28
Lemma base28 :
ev_runs [] L28 (const S0) {{B}}> ev_runs [] ((S1, cn 224495) :: tl R28) (const S0) -->*
cfgI (C5, 2, 0%N, nus28).
L2523new
447Lemmanonhalt
Lemma nonhalt : ~ halts tm c0.
L2542adapted
4What a maintainer readsCheck: the rule table below is what the .v proves, and proof.md / README read cleanly for a maintainer.
submission/proof.md line 161: 2.2 The eight rules

At a defect e the head sees d = (e - φ) mod 4. Here ^ is symmetric difference.

head d = 0 d = 1 d = 2 d = 3
moving left pass, φ+1 turn right; D ^= {e-1, e} turn right; D ^= {e-1, e} pass, φ-1
moving right turn left; D ^= {e, e+1} wiggle; D ^= {e, e+2}, then pass, φ+1 pass, φ-1 pass, φ+1

Turns keep φ. A turn moves the defect by one cell, a wiggle by two.

Each rule is a run of two to five transitions at the defect. The state on the near cell follows from the phase. The far cell holds the same symbol as the near one, which breaks the cycle:

head d near cell transitions what breaks the cycle
left 0 C0 on e+1 C0, D0 nothing: D0 is in the left cycle at the new phase
left 1 E1 on e+1 E1, C1 C1 = 0RA turns the head right
left 2 D0 on e+1 D0, E0 E0 = 1RB turns the head right
left 3 D1 on e+1 D1, D1 nothing
right 0 B0 on e B0, C0 C0 = 1LD turns the head left
right 1 C1 on e C1, A1, F0, A0, B1 A1 = 0RF; F reads cell e+2
right 2 A0 on e A0, B0 nothing
right 3 B1 on e B1, B1 nothing

Halting. The machine halts only through F reading 1, and F is entered only by A1, which occurs only in the wiggle. There F reads cell e+2, and cell e+2 holds 1 exactly when e+1 is also a defect.

So the machine halts exactly when the head moves right, sees d = 1, and e+1 is also a defect.

Collisions. A turn or wiggle whose toggled edge is already a defect makes two defects cancel. This does happen, inside some right-region episodes (4.3 works out an example). The rules above already cover it, since a toggle is a symmetric difference.

So the proof does not assume that defects never cancel. Only the halting case has to be ruled out.

5FamilyCheck: related machines are killed together or have a reason to be left open.

3 machines, 3 killed, 0 not. Family links: status.json parent, same transition table with another start (tools/dashboard.py), targeting.md follow-on rows, ledger "= twin" notes. A machine string named in a .v header / proof.md / notes.md is listed but does not make a family.

whomachinestatusrelation to this kill
W4-3 kill 201RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---✓Killed: never haltsthis kill
W4-3b kill 211RB0RA_1LC0RE_1LD0LC_1RA0LB_1RA0RF_1LE---✓Killed: never haltsparent link; = W4-3's table, run from state B; named in W4-3b's .v header; named in W4-3b's proof.md; named in W4-3b's notes.md; named in W4-3's proof.md; named in W4-3's notes.md · review · same machine as this kill? (same table, started in W4-3's B; trajectory twin; tables, pictures and numbers side by side)
W4-3c kill 221RB---_1LC0LA_1LD0LC_1RE0LB_1RF0RE_1LC0RD✓Killed: never haltsparent link; = W4-3's table mirrored, run from state F; named in W4-3c's .v header; named in W4-3c's proof.md; named in W4-3c's notes.md; named in W4-3's proof.md; named in W4-3's notes.md · review · same machine as this kill? (same table mirrored, started in W4-3's F; different orbit; tables, pictures and numbers side by side)
Named in a file but not linked (not counted as family)
#3 kill 41RB0LD_1RC0RA_1RD1RF_1LA0LE_1RE1LD_0RB---✓Killed: never haltsnamed in W4-3's proof.md · review · mechanism
#11 kill 31RB0LE_1RC0RC_1LD0RB_1LA0LE_1LD1LF_1LD---✓Killed: never haltsnamed in W4-3's proof.md; named in W4-3's notes.md · review · mechanism
6ChecklistCheck: every ✓ is computed; the two ○ are yours to decide; an amber ! is an optional check that did not finish.
  • ✓
    Machine string exact
    the .v literal == holdout list line 363 byte for byte
  • ✓
    Statement is ~halts tm c0
    parsed from the .v and confirmed by check_kill (theorem_text, theorem_rocq)
  • ✓
    No axioms beyond baseline
    0 assumption(s); tools/assumptions_baseline.txt allows only functional_extensionality_dep
  • ✓
    coqchk finished (optional)
    coqchk pass in 1743.06 s
  • ✓
    .v hash matches the checked hash
    .v = checked sha256 13db03a7aa9a…; submission/ copy = checked sha256 13db03a7aa9a…
  • ✓
    No repo-local paths in the .v
    comments name no path of ours (vendor/, machines/, tools/, rocq/, scripts/, reports/, atlas/, data/, journal/, /home/); busycoq's own verify/X.v is fine: none in the .v or the submission/ copy
  • ✓
    Public write-up is clean
    tools/writeup_lint.py on submission/proof.md: 0 error(s)
  • ○
    proof.md reviewed by Dennis (Checkpoint B)
    no Checkpoint B note from Dennis found
    • notes.md L509: - **Open:** a referee read of proof.md (Checkpoint B). Then a decision on formalization: a busycoq proof needs mod-4 gap counters, the 81-entry table as lemmas, the chain lemma by induction on the word, the symbolic inte
    • notes.md L551: - Checkpoint B (Dennis, non-blocking). For a referee: Lemma C's composition step, the residue argument behind Lemma R
    • notes.md L596: Open: Checkpoint B (Dennis, non-blocking). Formalization as in proof.md section 10 (several stages).
    • notes.md L618: check_kill. A coqchk that finishes would need a cheaper base case (e.g. start the induction earlier). Checkpoint B on
    • notes.md L662: - Open, unchanged: Checkpoint B (Dennis); independent re-verification of the two sibling kills (their status.json);
    • proof.md L1341: - **Checkpoint B (Dennis):** pending, non-blocking.
  • ○
    Family posted together?
    2 other kill(s) in the family: W4-3b, W4-3c; the Discord draft names 2 of them

Generated by tools/killreview.py at 2026-10-16 13:29 PDT in 0.1 s from the files linked above; nothing in this review is hand-written except the box “How we proved it never halts” (above), which quotes how_proved.md. Re-run: python3 -B tools/killreview.py 1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---

Files

machines/<tm>/: 16 entries · raw notes, status, scripts, images

namesizechanged
notes.md ↓66 KB2026-10-12 21:31
proof.md ↓82 KB2026-10-12 21:31
how_proved.md ↓1.6 KB2026-10-14 10:51
status.json ↓1.4 KB2026-10-14 09:08
observe.json ↓11 KB2026-10-10 23:41
deepen.json ↓19 KB2026-10-12 12:06
1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---.v ↓138 KB2026-10-13 18:01
check_kill.txt ↓11 KB2026-10-14 14:57
decisions/4 items2026-10-12 16:33
img/4 items2026-10-10 23:39
rocq/21 items2026-10-12 21:04
scripts/8 items2026-10-12 17:52
submission/6 items2026-10-14 10:21
work/11 items2026-10-10 23:38
check_proof.out ↓12 KB2026-10-12 21:31
check_proof.py ↓72 KB2026-10-12 18:16
status.json in full
{
 "tm": "1RB0RF_1RC0RB_1LD0RA_1LE0LD_1RB0LC_1LA---",
 "label": "W4-3",
 "status": "KILLED_NONHALT",
 "stage": "done",
 "updated": "2026-10-13",
 "reason": "check_kill PASS, independently re-verified",
 "check_kill": {
  "result": "PASS",
  "mode": "nonhalt",
  "sha256": "64d69ff2169f03a6e866c97a9b45310d1ec17b754e400249a006dddeef50fe86",
  "compile_s": 68.9,
  "coqchk": "timeout",
  "coqchk_cap_s": 600,
  "assumptions": [],
  "log": "submission/check_kill.txt",
  "checked_at": "2026-10-13T16:17:47Z"
 },
 "siblings": [
  "1RB0RA_1LC0RE_1LD0LC_1RA0LB_1RA0RF_1LE---",
  "1RB---_1LC0LA_1LD0LC_1RE0LB_1RF0RE_1LC0RD"
 ],
 "siblings_note": "Same table from other starts (512: our B; 588: our F, mirrored). Both formalized separately in Class 2 close-out stage 2 (2026-10-12): this kill file with the table as tmP, a new base case (record exit 28 from B / F) and busycoq's Perm/Flip; check_kill PASS / PASS (see their status.json). This .v proves only this string.",
 "funded": {
  "option": "sync_stage",
  "date": "2026-10-12",
  "campaign": "class2_closeout",
  "stage": 3
 },
 "pr": "https://github.com/ccz181078/busycoq/pull/17",
 "pr_state": "merged",
 "pr_comments": 0,
 "posted": "2026-10-13 (bbchallenge Discord, by Dennis)",
 "pr_file": "verify/Skelet1LikeC2_1RB0RF_1RC0RB.v",
 "pr_merged_at": "2026-10-14T06:20:18Z",
 "pr_merged_by": "ccz181078",
 "pr_merge_commit": "a036ccd"
}
observe.json contract (tools/README-card.md):
2 contract warnings
  • rank: missing
  • mechanism: 6 bullets (max 3; the card folds them under the summary)