tools/rebuild_pages.sh rebuilds the site within 5 minutes of a change; by hand: python3 -B tools/site.py.1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC
How we proved it never halts
Each epoch's cleanup costs only about the square root of its budget
Left of the head the tape reads 110 110 … 110 0 011 011 … 011: used blocks, a 0 marker, and budget blocks. Right of the head is a binary counter. On each bounce the head runs into the counter to add 1, comes back, and moves the marker one block right, usually turning a budget block into a used one. When one budget block is left, the machine eats the counter's lowest digit; sometimes that buys more budget, otherwise the head sweeps left and a new epoch starts with a larger budget, set by the length of the used run.
The eat leaves the counter messy, and the first bounces of the next epoch tidy it up. The tidying is recursive: at some digits a single bounce runs a whole mini-epoch on the rest of the counter, leaving its own mess one level deeper. The missing table entry (state D reading 0) can only come up if the budget runs out while the counter is still messy.
The key estimate: tidying a counter of k digit blocks costs about 2^(k/2) bounces, while the budget is at least about 2^(k+3), so the cleanup needs only about the square root of the budget. The proof bounds the cost with a weighted score over the counter's digits and carries an invariant from epoch to epoch, which works once the budget reaches 17,705. The 691 epochs before that (epochs 3 to 694, ending at budget 17,713) are computed exactly.
The Rocq proof checks every rule as an exact machine run, the cost bounds and the invariant from budget 17,705 up, and the opening by verified simulation. A verified model of the rules computes the 691 epochs, and a soundness proof turns that computation into a real machine run.

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.
Overview
In one sentence
Marker bounce feeds a 3-cell binary counter; the bell eats only its low digit, so residue seeds the next epoch
Submitted mechanism A marker bounce feeding a counter. The hub is 0^inf (110)^a 0 (011)^b C> X 0^inf. Each bounce moves the 0 marker one block to the right, adds 1 to the counter word X and spends one 011 of the budget b. X is binary, LSB first: 3-cell blocks d01 (001)^e separated by 000, ending in a 4-stage tail. (submission/README.md, Mechanism)
- Upstream
- Kill claimed · PR #25merged 2026-10-16 07:08 UTC by ccz181078 ·
PR_BEC.v · TM4· on Submissions → - Rocq proof
- check_kill PASS · first Oct 10 18:311,726 lines · 86 KB .v · compile 15.5 s · coqchk pass · 0 axioms · PASS Oct 10 18:31· the .v file
- Automatic review
- 6 of 6 checks passtemplate: verify/FractalBEC.v (adapted from) · details in Proof →
- Class
- Bell eats counterours: Bell eats counter (sheet) · ours adds: partial eat with residue (sibling of #10) · med confidence
- On the list
- not on
BB6_holdouts_663.txt(line 710 of the previous list) · historical 740 line 710
Your calls on file 2
- 2026-10-10 · deepen
- Fund one deepen stage on #30 (exact digestion rules, abstract epoch map checked against the TM, and a proof idea for 'eat after digestion'), or park it as STUCK next to #10? (auto-applied: Claude's recommendation, under Dennis's standing instruction 'do your recommendations and continuously orchestrate' (2026-10-10, while he was at lunch). Override any time.)
- 2026-10-10 · nest
- Fund one more stage on #30's D6 nesting step (exact recursive rule plus a proof of the doubling law for digestion), or park it as STUCK? (auto-applied: Claude's recommendation, under Dennis's standing instruction 'do your recommendations and continuously orchestrate' (2026-10-10, while he was away). Override any time.)
Mechanism
What to check here: the pictures show the mechanism that the rule table describes.
How it works: 3 notes
- Hub K(a,b,X) = (110)^a 0 (011)^b C> X: each bounce moves the 0-marker one block and adds 1 to counter X.
- Clean counter D(k,s,v): digits ?01 split by 001000, 4-stage tail; when b runs out only the low digit is eaten (E1/E2).
- The rest seeds the next epoch as residue; forcing an eat during its digestion can halt, so we need eat time > digestion time.
Figures for Checkpoint A
The site's view. Find the diagonal stripes inside the bell and the busy right edge.
Each down-right diagonal is one epoch (the 0-marker crossing the blocks); the counter is the right-edge strip.
Rows are bounces. Compare the left strip's colour with the grey wedge: where does red appear?
More figures (4)Fig 4–7: Left and right records to 100M steps · Blaze, 10 million steps · Digestion share per epoch to 1e11 steps · Digestion cost / sqrt(N), model orbit
One row per new edge cell. The left edge moves 2 cells per epoch; the right edge carries the counter.
The bell's outline over 1e7 steps; no chaotic edge.
Dots sit far below the yellow budget line and under the blue curve, and they sink as N grows.
Green dots are TM-checked epochs, white ones the model beyond. Compare their height with the blue line.
Rules (6/7 validated)exact tape rewrites the proof will formalize, each re-checked by simulation
| rule | from ⟶ to | cases | steps | checked |
|---|---|---|---|---|
| R restart | 0∞ <A 101 (001)k 000 Y 0∞ ⟶ 0∞ 110 0 (011)k+1 C> Y 0∞ | any Y not starting with 011; k <= 3000 | 3k+7 | ✓600/600 |
| B bounce | 0∞ (110)a 0 (011)b+1 C> X 0∞ ⟶ 0∞ (110)a+1 0 (011)b+d C> inc(X) 0∞ | b >= 1; X = any of 9,730 orbit hub words; inc(X), d in {0,1} and c(X) do not depend on a, b | 8b+c(X) | ✓600/600 |
| W clean counter | 0∞ (110)a 0 (011)b+1 C> D(n) 0∞ ⟶ 0∞ (110)a+1 0 (011)b+[n=3] C> D(n+1) 0∞ | D(n) = (v0 01 001000)...(v_(k-1) 01) tail_s, n = 2^(k+2)-4+s*2^k+v, tails '',0001,000010001,000110001; D(1..3)=1,010001,110001; n <= 1e5 | — | ✓600/600 |
| E2 odd eat | 0∞ (110)a 0 011 C> 101 E(j,s,u) 0∞ ⟶ 0∞ <A 101 (001)a 000 11 E(j,s,u+1) 0∞ | E(0,s,0)=tail_s, E(j,s,u)=001000 D(j,s,u); u+1=2^j overflows to s+1; j <= 9 | — | ✓600/600 |
| E1 even eat | 0∞ (110)a 0 011 C> (001)i 000 Y 0∞ ⟶ 0∞ (110)a+2 0 (011)i C> Y 0∞ | i >= 1 (i <= 40 tested), Y random / orbit / clean words not starting with 011 | — | ✓600/600 |
| E0 empty | 0∞ (110)a 0 011 C> 0∞ ⟶ 0∞ <A 101 (001)a+1 0001 0∞ | a <= 3000 | — | ✓200/200 |
| digestion (open) | 0∞ 110 0 (011)N C> 11 E(j,s,u) 0∞ ⟶ clean counter after O(len) bounces | not exact yet: inc on words with extra 001 groups; forced eats halt at 1-2 bounce counts inside this window | — | –untested |
Compressed historythe tape as 0∞ <A 101 (001)k T 0∞ at 40 moments: where the rules are read off
| step | k (left record; next epoch has b = k+1) | len T (residue cells) | T (residue word) |
|---|---|---|---|
| 28 | 1 | 4 | 1 |
| 124 | 2 | 13 | 1,000,010,001 |
| 304 | 7 | 9 | 10,001 |
| 888 | 15 | 4 | 1 |
| 2,458 | 17 | 18 | 1.1·1014 |
| 4,898 | 31 | 4 | 1 |
| 10,190 | 33 | 23 | 1.1·1019 |
| 17,496 | 44 | 23 | 1.1·1019 |
| 28,266 | 47 | 39 | 000110010010010010010... |
| 123,064 | 93 | 27 | 000110010000010010001... |
| 361,032 | 141 | 32 | 000110010000010010001... |
| 860,624 | 191 | 65 | 000110010010010010010... |
| 1,681,596 | 254 | 32 | 000110010001010010001... |
| 3,011,456 | 315 | 45 | 000110010001010010001... |
| 5,070,530 | 381 | 66 | 000110010010010010010... |
| 7,976,352 | 449 | 65 | 000110010010010010010... |
| 11,910,016 | 523 | 47 | 000110010010010001010... |
| 17,123,688 | 604 | 50 | 000110010001010010000... |
| 23,784,450 | 665 | 96 | 000110010010010010010... |
| 32,098,260 | 748 | 84 | 000110010010010010010... |
| 42,062,398 | 812 | 89 | 000110010010010010010... |
| 54,178,782 | 897 | 74 | 000110010010010010010... |
| 68,368,956 | 959 | 101 | 000110010010010010010... |
| 84,929,740 | 1,039 | 83 | 000110010010010010000... |
| 104,187,542 | 1,138 | 50 | 000110010001010010001... |
| 126,702,144 | 1,213 | 101 | 000110010010010010010... |
| 152,598,718 | 1,314 | 45 | 000110010001010010001... |
| 182,046,336 | 1,377 | 129 | 000110010010010010010... |
| 215,153,620 | 1,484 | 45 | 000110010000010010000... |
| 252,476,678 | 1,547 | 111 | 000110010010010010010... |
| 293,968,094 | 1,662 | 32 | 000110010001010010001... |
| 340,352,894 | 1,717 | 143 | 000110010010010010010... |
| 391,125,562 | 1,828 | 59 | 000110010000010010000... |
| 447,163,912 | 1,889 | 125 | 000110010010010010010... |
| 508,490,566 | 1,983 | 101 | 000110010010010010010... |
| 575,132,558 | 2,085 | 68 | 000110010000010010000... |
| 648,268,766 | 2,165 | 119 | 000110010010010010010... |
| 728,156,308 | 2,261 | 128 | 000110010010010010010... |
| 814,752,418 | 2,375 | 50 | 000110010001010010000... |
| 908,922,682 | 2,466 | 74 | 000110010010010001010... |
k (left record; next epoch has b = k+1)last 2,466len T (residue cells)last 74T (residue word)last 000110010010010001010...Template comparisonFractalBEC.v: partly applies · the nearest solved proof, what carries over, and the transitions that differ
| 0 | 1 | |
|---|---|---|
| A | 1RB | 0RF |
| B | 1RC | 1RF |
| C | 1LD | 0REtpl 1RB |
| D | --- | 0LE |
| E | 1LA | 0LE |
| F | 0RA | 0LC |
differs from the template
- file
FractalBEC.v:269- module
- —
- machine
1RB0RF_1RC1RF_1LD1RB_---0LE_1LA0LE_0RA0LC(1 transition apart)- diff
C1: template (tm10 mirrored) 1RB, ours 0RE; #10 has 1RA- note
- RInc (marker bounce) = our B. LInc (2-cell counter) and Ov/P0 (whole counter eaten, fractal doubling k -> 2k+3) do not hold: our counter has 3-cell digits + 4-stage tail and the eat is partial (E1/E2), leaving residue. Same hub as #10 (STUCK on Lemma X).
Proof strategy & riskshow the formal proof will go · 3 risks to watch
Deepen: exact rules for digestion and for counters with extra 001 groups, then an abstract epoch map (N, residue) -> (N', residue') checked against the TM, then prove 'digestion < N' as an inductive size invariant; proof shaped like FractalBEC/BECv7.
- ▲Digestion may not close into a short rule list (as #10's Lemma X).
- ▲Safety is not regular (random eat times halt), so no CTL shortcut.
- ▲Non-clean counters (75/138 eats) may hide further cases.
Stats & provenance109 steps simulated · 7,720 cells · the status in full · files
- simulated
- 109 steps
- tape
- 7,720 cells · 4,642 nonzeros
- growth
- left edge +2 cells/epoch; 137 epochs to 1e9; k = 2,497 at step 983,786,092; right edge ~t^0.36
- status now
- check_kill PASS, independently re-verified (status.json, 2026-10-10)
- observer's note
- Rules R/B/W/E0/E1/E2 exact and validated; residue digestion and the size invariant (eat after digestion) are open, so confidence med.
- files
- observe.json · notes.md · proof.md · how_proved.md · status.json · 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v
Proof & checks
Kill 15 · Bell eats counter · the kill file 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v: 1726 lines, 219 items · the package submission/
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).
1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LCsha256 93a493f553118578…
| ✓ | 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v | 93a493f553118578… = checked |
| ✓ | submission/1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v | 93a493f553118578… = checked |
All 17 check_kill checks with their one-line results
| ✓ | args | 6x2 machine, framework module Individual62, mode nonhalt |
| ✓ | input | 88034 bytes, 1726 lines, 2012 sentences |
| ✓ | framework | HEAD 0940bb9cf434ba68f0c025dabfde45a219999973 == pin; no tracked changes under verify/ |
| ✓ | framework_build | 13 needed framework .vo files present and fresh, with native code no older than the .vo |
| ✓ | forbidden | none of 30 forbidden patterns occur (ground rule 1's words: anywhere; command words: outside comments and strings; comments never split a token) |
| ✓ | structure | 5 Require name(s) allowed; no top-level Variable/Context; no shadowing; Module/Section balanced |
| ✓ | tm_text | line 33: TM_from_str "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC" == <tm> (41 bytes) |
| ✓ | theorem_text | line 1706: nonhalt : ~halts tm c0 |
| ✓ | coq | coqc 8.20.1 ([local working file] |
| ✓ | names | halts, c0, TM_from_str resolved inside Individual62 |
| ✓ | compile | compiled in 15.5s with all appended checks |
| ✓ | tm_rocq | BB6Kill.Candidate.tm = BusyCoq.Individual62.TM_from_str "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC" by eq_refl (in-file and isolated) |
| ✓ | theorem_rocq | nonhalt : ~ halts (TM_from_str "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC") c0 with absolute names (in-file and isolated) |
| ✓ | isolation | only stock proof plugins loaded; guard/positivity/universe checking on, definitional UIP off |
| ✓ | assumptions | 0 assumption(s), all in the baseline |
| ✓ | coqchk | coqchk -norec BB6Kill.Candidate ok (67.7s); its context summary lists nothing of the file's own |
| ✓ | integrity | input 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).
Adapted from busycoq's verify/FractalBEC.v, tm10 (1LB0LF_1LC1LF_1RD1LB_---0RE_1RA0RE_0LA0RC). Mirrored, tm10 differs from this machine only in C1 (1RB there, 0RE here).
- Kept: tm10's marker bounce
RInc, mirrored, as the region passRP0/RP1;esfor every finite run;multistep_nonhaltfrom an exact start. - Changed: tm10's counter (
LInc, 2-cell digits) and its whole-counter eat (Ov) do not occur here, and neither does its induction on the epoch number withprogress_nonhalt_simple. Everything above the bounce is new: the word syntax,LP/Phiwith the nested sub-epoch, counter words and their potentials, the epoch invariant withprogress_nonhalt_cond, and the fuel model for the finite part.
The file has 1,726 lines, every lemma top level, and imports only Individual62 from busycoq.
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.
Template-only names: BinaryCounter_0_full, L, R, Incs, f, P0, P1, nxtP1, P0nxt, P0_0, P0_spec, config, config_S, Cert, tm1, nonhalt1, tm2, nonhalt2, tm3, nonhalt3, tm4, nonhalt4, tm5, nonhalt5, tm6, nonhalt6, tm7, nonhalt7, tm8, nonhalt8, tm9, nonhalt9, tm10, nonhalt10, tm11, nonhalt11
Side-by-side diff: template (228 lines) vs ours (1511 lines), 1655 lines differ; runs of identical lines and long template-only runs folded
| template | ours | ||
|---|---|---|---|
| 1 | From BusyCoq Require Import Individual62. | 27 | From BusyCoq Require Import Individual62. |
| 2 | Require Import Lia. | 28 | Require Import Lia. |
| 3 | Require Import ZArith. | ||
| 4 | Require Import String. | 29 | Require Import String. |
| 5 | From BusyCoq Require Import BinaryCounter. | ||
| 30 | Require Import List. | ||
| 6 | From BusyCoq Require Import BinaryCounterFull. | ||
| 31 | Require Import Arith. | ||
| 8 | Open Scope list. | ||
| 33 | Definition tm := Eval compute in (TM_from_str "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC"). | ||
| 10 | Ltac er := execute_with_rotate. | ||
| 35 | Notation "c --> c'" := (c -[ tm ]-> c') (at level 40). | ||
| 11 | Ltac sr := use_shift_rule; simpl_rotate. | ||
| 13 | Ltac es := | ||
| ⋯ 20 template-only lines (template 14–35), not in ours | |||
| 36 | Hypothesis QL QR:Q. | ||
| 37 | Hypothesis qL qR d1 w1 w0:list sym. | ||
| 39 | Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40). | 36 | Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40). |
| 40 | Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40). | 37 | Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40). |
| 42 | Notation "l <| r" := | ||
| 39 | Open Scope list. | ||
| 43 | (l <{{QL}} qL *> r) (at level 30). | ||
| 41 | (* ===================================================================== *) | ||
| 45 | Notation "l |> r" := | ||
| 42 | (* Section 1. Finite runs (write-up 3.1-3.7), each one plain es. *) | ||
| 46 | (l <* qR {{QR}}> r) (at level 30). | ||
| 43 | (* Left sides are written nearest-cell-first (<[...] reverses a literal). *) | ||
| 48 | Definition L n := BinaryCounter_0 d1 n. | ||
| 44 | (* ===================================================================== *) | ||
| 50 | Definition R n m r := w1^^n *> w0 *> w1^^m *> r. | ||
| 46 | (* LP0: 011 C> 0 r -> <A 100 1 r *) | ||
| 52 | Hypothesis LInc: | ||
| 47 | Lemma LP0 l r : l <* <[0;1;1] {{C}}> [0] *> r -->+ l <{{A}} [1;0;0;1] *> r. | ||
| 53 | forall r n, | ||
| 48 | Proof. es. Qed. | ||
| 54 | L n <| r -->+ | ||
| 50 | Lemma LP0z l : l <* <[0;1;1] {{C}}> 0inf -->+ l <{{A}} [1;0;0;1] *> 0inf. | ||
| 55 | L (N.succ n) |> r. | ||
| 51 | Proof. es. Qed. | ||
| 57 | Hypothesis RInc: | ||
| 53 | (* LP11: 011 C> 110 r -> <A 101 000 r *) | ||
| 58 | forall l r n m, | ||
| 54 | Lemma LP11 l r : l <* <[0;1;1] {{C}}> [1;1;0] *> r -->+ l <{{A}} [1;0;1;0;0;0] *> r. | ||
| 59 | l |> R (1+n) m r -->+ | ||
| 55 | Proof. es. Qed. | ||
| 60 | l <| R n (1+m) r. | ||
| 57 | (* LPC (carry), right pass: 011 C> 101 (001)^e 000 r -> 011 111 (011)^e 011 C> r *) | ||
| 62 | Lemma Incs k n m r: | ||
| 58 | Lemma LPCr l e r : l <* <[0;1;1] {{C}}> [1;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+ | ||
| 63 | L (N.of_nat k) <| R n m r -->+ | ||
| 59 | l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <* <[0;1;1] {{C}}> r. | ||
| 64 | L (N.of_nat (1+k+n)) |> R 0 (n+m) r. | ||
| 60 | Proof. es. Qed. | ||
| 62 | (* LPC, left pass after an exit with d = 0 / d = 1 *) | ||
| 63 | Lemma LPCl0 l e r : l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;0] *> r -->+ | ||
| 64 | l <{{A}} [1;0;0;0;0;1] *> [0;0;1]^^e *> [0;0;0] *> r. | ||
| 65 | Proof. es. Qed. | ||
| 67 | Lemma LPCl1 l e r : l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;1;0;0;0] *> r -->+ | ||
| 68 | l <{{A}} [1;0;0;0;0;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | ||
| 69 | Proof. es. Qed. | ||
| 71 | (* LP5 (D5): 011 C> 10 001 (001)^e 000 r -> 011 11 (011)^(e+1) 011 C> r, and back *) | ||
| 72 | Lemma LP5r l e r : l <* <[0;1;1] {{C}}> [1;0;0;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+ | ||
| 73 | l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <* <[0;1;1] {{C}}> r. | ||
| 74 | Proof. es. Qed. | ||
| 76 | Lemma LP5l0 l e r : l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <{{A}} [1;0;0] *> r -->+ | ||
| 77 | l <{{A}} [1;0;0;0;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | ||
| 78 | Proof. es. Qed. | ||
| 80 | Lemma LP5l1 l e r : l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <{{A}} [1;0;1;0;0;0] *> r -->+ | ||
| 81 | l <{{A}} [1;0;0;0;1] *> [0;0;1]^^(S (S e)) *> [0;0;0] *> r. | ||
| 82 | Proof. es. Qed. | ||
| 84 | (* LP6 (D6), right pass: builds the sub-hub 011 1 . 110 0 (011)^(e+1) C> r *) | ||
| 85 | Lemma LP6r l e r : l <* <[0;1;1] {{C}}> [1;0;1;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+ | ||
| 86 | l <* <[0;1;1;1] <* <[1;1;0] <* [0] <* <[0;1;1]^^(S e) {{C}}> r. | ||
| 87 | Proof. es. Qed. | ||
| 89 | (* W10, the D6 exit: 011 E> 1 r -> <A 100 0 r *) | ||
| 90 | Lemma W10 l r : l <* <[0;1;1;1] <{{E}} r -->+ l <{{A}} [1;0;0;0] *> r. | ||
| 91 | Proof. es. Qed. | ||
| 93 | (* RP0 / RP1: the region pass (FractalBEC's RInc) *) | ||
| 94 | Lemma RP0 l n r : l <* [0] <* <[0;1;1]^^(S n) <{{A}} [1;0;0] *> r -->+ | ||
| 95 | l <* <[1;1;0] <* [0] <* <[0;1;1]^^(S n) {{C}}> r. | ||
| 96 | Proof. es. Qed. | ||
| 98 | Lemma RP1 l n r : l <* [0] <* <[0;1;1]^^(S n) <{{A}} [1;0;1;0;0;0] *> r -->+ | ||
| 99 | l <* <[1;1;0] <* [0] <* <[0;1;1]^^(S (S n)) {{C}}> r. | ||
| 100 | Proof. es. Qed. | ||
| 102 | (* Eats at b = 1 *) | ||
| 103 | Lemma E1r l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [0;0;1]^^(S e) *> [0;0;0] *> r -->+ | ||
| 104 | l <* <[1;1;0]^^(S (S a)) <* [0] <* <[0;1;1]^^(S e) {{C}}> r. | ||
| 105 | Proof. es. Qed. | ||
| 107 | Lemma E2l0 l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;0] *> r -->+ | ||
| 108 | l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;1] *> [0;0;1]^^e *> [0;0;0] *> r. | ||
| 109 | Proof. es. Qed. | ||
| 111 | Lemma E2l1 l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;1;0;0;0] *> r -->+ | ||
| 112 | l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | ||
| 113 | Proof. es. Qed. | ||
| 115 | Lemma Et0 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> 0inf -->+ | ||
| 116 | l <{{E}} [0;1] *> [0;0;1]^^(S a) *> [0;0;0;1] *> 0inf. | ||
| 117 | Proof. es. Qed. | ||
| 119 | Lemma Et1 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [1] *> 0inf -->+ | ||
| 120 | l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | ||
| 121 | Proof. es. Qed. | ||
| 123 | Lemma Et2 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [0;1;0;0;0;1] *> 0inf -->+ | ||
| 124 | l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | ||
| 125 | Proof. es. Qed. | ||
| 127 | Lemma Et3 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [1;1;0;0;0;1] *> 0inf -->+ | ||
| 128 | l <* <[1;1;0]^^(S a) <* [0] <* <[0;1;1] {{C}}> [0;0;1] *> 0inf. | ||
| 129 | Proof. es. Qed. | ||
| 131 | (* Restart from a pre-record (write-up 3.7, plus the step L' -> L) *) | ||
| 132 | Lemma Rst k r : const 0 <{{E}} [0;1] *> [0;0;1]^^k *> [0;0;0] *> r -->+ | ||
| 133 | const 0 <* <[1;1;0] <* [0] <* <[0;1;1]^^(S k) {{C}}> r. | ||
| 134 | Proof. rewrite (const_unfold _ S0) at 1. es. Qed. | ||
| 136 | (* LPT: the constant end words *) | ||
| 137 | Lemma LPT1 l : l <* <[0;1;1] {{C}}> [1] *> 0inf -->+ l <{{A}} [1;0;0;0;1;0;0;0;1] *> 0inf. | ||
| 138 | Proof. es. Qed. | ||
| 140 | Lemma LPT2 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;0;1] *> 0inf -->+ | ||
| 141 | l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | ||
| 142 | Proof. es. Qed. | ||
| 144 | Lemma LPT3 l : l <* <[0;1;1] {{C}}> [1;0;1;1;0;0;0;1] *> 0inf -->+ | ||
| 145 | l <{{A}} [1;0;0] *> [0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | ||
| 146 | Proof. es. Qed. | ||
| 148 | Lemma LPT4 l : l <* <[0;1;1] {{C}}> [1;0;0;0;0;1;0;0;0;1] *> 0inf -->+ | ||
| 149 | l <{{A}} [1;0;0] *> [0;1;0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | ||
| 150 | Proof. es. Qed. | ||
| 152 | Lemma LPT5 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf -->+ | ||
| 153 | l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | ||
| 154 | Proof. es. Qed. | ||
| 156 | Lemma LPT6 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;1;0;0;0;1] *> 0inf -->+ | ||
| 157 | l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | ||
| 158 | Proof. es. Qed. | ||
| 160 | Lemma z3 : [0;0;0] *> const 0 = const 0. | ||
| 161 | Proof. cbn. rewrite <- !const_unfold. reflexivity. Qed. | ||
| 163 | (* ===================================================================== *) | ||
| 164 | (* Section 2. Words, the local pass LP and the epoch map Phi. *) | ||
| 165 | (* ===================================================================== *) | ||
| 167 | (* blk d e w = d01 (001)^e 000 w; p11 x w = 11 (001)^x 000 w; p01 x w = 01 (001)^x 000 w; | ||
| 168 | p00 w = 00 w; p10 w = 10 w; tails t0 = '', t1 = 1, t2 = 010001, t3 = 110001. *) | ||
| 169 | Inductive word : Type := | ||
| 170 | | t0 | t1 | t2 | t3 | ||
| 171 | | blk (d : bool) (e : nat) (w : word) | ||
| 172 | | p11 (x : nat) (w : word) | ||
| 173 | | p01 (x : nat) (w : word) | ||
| 174 | | p00 (w : word) | ||
| 175 | | p10 (w : word). | ||
| 177 | Definition dsym (d : bool) : Sym := if d then S1 else S0. | ||
| 179 | Fixpoint enc (w : word) : side := | ||
| 180 | match w with | ||
| 181 | | t0 => const 0 | ||
| 182 | | t1 => [1] *> const 0 | ||
| 183 | | t2 => [0;1;0;0;0;1] *> const 0 | ||
| 184 | | t3 => [1;1;0;0;0;1] *> const 0 | ||
| 185 | | blk d e w => [dsym d; 0; 1] *> [0;0;1]^^e *> [0;0;0] *> enc w | ||
| 186 | | p11 x w => [1;1] *> [0;0;1]^^x *> [0;0;0] *> enc w | ||
| 187 | | p01 x w => [0;1] *> [0;0;1]^^x *> [0;0;0] *> enc w | ||
| 188 | | p00 w => [0;0] *> enc w | ||
| 189 | | p10 w => [1;0] *> enc w | ||
| 190 | end. | ||
| 192 | Definition addb (e : nat) (d : bool) : nat := if d then S e else e. | ||
| 194 | (* LP w w' d: the local pass maps w to w', d = true if it absorbs one 011 block. | ||
| 195 | Phi a b w k y: the epoch map from the hub (110)^a 0 (011)^b C> w to the pre-record | ||
| 196 | E> . 01 (001)^k 000 y (write-up 3.8). *) | ||
| 197 | Inductive LP : word -> word -> bool -> Prop := | ||
| 198 | | LP_a e w : LP (blk false e w) (blk true e w) false | ||
| 199 | | LP_b e w w' d : LP w w' d -> LP (blk true e w) (blk false (addb e d) w') false | ||
| 200 | | LP_t0 : LP t0 t1 false | ||
| 201 | | LP_t1 : LP t1 t2 false | ||
| 202 | | LP_t2 : LP t2 t3 false | ||
| 203 | | LP_t3 : LP t3 (blk false 0 t0) true | ||
| 204 | | LP_11S x w : LP (p11 (S x) w) (p01 x w) true | ||
| 205 | | LP_110 w : LP (p11 0 w) (p00 w) true | ||
| 206 | | LP_01 x w : LP (p01 x w) (p11 x w) false | ||
| 207 | | LP_00 w : LP (p00 w) (p10 w) false | ||
| 208 | | LP_5 e w w' d : LP w w' d -> LP (p10 (blk false e w)) (p01 (S (addb e d)) w') false | ||
| 209 | | LP_6 e w k y : Phi 1 (S e) w k y -> LP (p10 (blk true e w)) (blk false k y) false | ||
| 210 | | LP_T2 : LP (p10 t2) (p01 1 (p01 1 t1)) false | ||
| 211 | | LP_T3 : LP (p10 t3) (p00 (p01 0 t2)) false | ||
| 212 | | LP_T4 : LP (p10 (p00 t2)) (p01 0 (p01 1 t1)) false | ||
| 213 | | LP_T5 : LP (p10 (p01 0 t2)) (p01 1 (p10 (p00 t2))) false | ||
| 214 | | LP_T6 : LP (p10 (p01 1 t1)) (p01 2 (p10 (p00 t2))) false | ||
| 215 | | LP_eq w1 w2 w' d : enc w1 = enc w2 -> LP w2 w' d -> LP w1 w' d | ||
| 216 | with Phi : nat -> nat -> word -> nat -> word -> Prop := | ||
| 217 | | Phi_B a b w w' d k y : LP w w' d -> Phi (S a) (addb (S b) d) w' k y -> Phi a (S (S b)) w k y | ||
| 218 | | Phi_E1 a e w k y : Phi (S (S a)) (S e) w k y -> Phi a 1 (blk false e w) k y | ||
| 219 | | Phi_E2 a e w w' d : LP w w' d -> Phi a 1 (blk true e w) a (p11 (addb e d) w') | ||
| 220 | | Phi_E0 a : Phi a 1 t0 (S a) t1 | ||
| 221 | | Phi_Et1 a : Phi a 1 t1 a (p01 1 t1) | ||
| 222 | | Phi_Et2 a : Phi a 1 t2 a (p10 (p00 t2)) | ||
| 223 | | Phi_Et3 a k y : Phi (S a) 1 (blk false 0 t0) k y -> Phi a 1 t3 k y | ||
| 224 | | Phi_eq a b w1 w2 k y : enc w1 = enc w2 -> Phi a b w2 k y -> Phi a b w1 k y. | ||
| 226 | Scheme LP_mind := Induction for LP Sort Prop | ||
| 227 | with Phi_mind := Induction for Phi Sort Prop. | ||
| 228 | Combined Scheme LP_Phi_mind from LP_mind, Phi_mind. | ||
| 230 | Definition outp (d : bool) (r : side) : side := | ||
| 231 | if d then [1;0;1;0;0;0] *> r else [1;0;0] *> r. | ||
| 233 | Definition LPspec (w w' : word) (d : bool) : Prop := | ||
| 234 | forall l, l <* <[0;1;1] {{C}}> enc w -->+ l <{{A}} outp d (enc w'). | ||
| 236 | Definition Phispec (a b : nat) (w : word) (k : nat) (y : word) : Prop := | ||
| 237 | forall l, l <* <[1;1;0]^^a <* [0] <* <[0;1;1]^^b {{C}}> enc w -->+ | ||
| 238 | l <{{E}} [0;1] *> [0;0;1]^^k *> [0;0;0] *> enc y. | ||
| 240 | Lemma enc_a0 : enc (blk false 0 t0) = [0;0;1] *> const 0. | ||
| 241 | Proof. cbn [enc]. rewrite z3. reflexivity. Qed. | ||
| 243 | (* ===================================================================== *) | ||
| 244 | (* Section 3. Soundness: every LP / Phi derivation is a TM run. *) | ||
| 245 | (* ===================================================================== *) | ||
| 247 | Theorem sound : | ||
| 248 | (forall w w' d, LP w w' d -> LPspec w w' d) /\ | ||
| 249 | (forall a b w k y, Phi a b w k y -> Phispec a b w k y). | ||
| 65 | Proof. | 250 | Proof. |
| 66 | follow10 LInc. | ||
| 251 | apply LP_Phi_mind; unfold LPspec, Phispec. | ||
| 67 | gen k m. | ||
| 252 | - (* LP_a *) intros e w l. exact (LP0 l ([0;1] *> [0;0;1]^^e *> [0;0;0] *> enc w)). | ||
| 68 | induction n; intros. | ||
| 253 | - (* LP_b *) intros e w w' d H IH l. destruct d. | ||
| 69 | - finish. | ||
| 254 | + eapply progress_trans. { exact (LPCr l e (enc w)). } | ||
| 70 | - follow100 RInc. | ||
| 255 | eapply progress_trans. { exact (IH (l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e)). } | ||
| 71 | follow100 LInc. | ||
| 256 | exact (LPCl1 l e (enc w')). | ||
| 72 | follow (IHn (1+k) (1+m)). | ||
| 257 | + eapply progress_trans. { exact (LPCr l e (enc w)). } | ||
| 73 | finish. | ||
| 258 | eapply progress_trans. { exact (IH (l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e)). } | ||
| 259 | exact (LPCl0 l e (enc w')). | ||
| 260 | - (* LP_t0 *) intros l. exact (LP0z l). | ||
| 261 | - (* LP_t1 *) intros l. exact (LPT1 l). | ||
| 262 | - (* LP_t2 *) intros l. exact (LP0 l ([1;0;0;0;1] *> const 0)). | ||
| 263 | - (* LP_t3 *) intros l. unfold outp. rewrite enc_a0. exact (LP11 l ([0;0;1] *> const 0)). | ||
| 264 | - (* LP_11S *) intros x w l. exact (LP11 l ([0;1] *> [0;0;1]^^x *> [0;0;0] *> enc w)). | ||
| 265 | - (* LP_110 *) intros w l. exact (LP11 l ([0;0] *> enc w)). | ||
| 266 | - (* LP_01 *) intros x w l. exact (LP0 l ([1] *> [0;0;1]^^x *> [0;0;0] *> enc w)). | ||
| 267 | - (* LP_00 *) intros w l. exact (LP0 l ([0] *> enc w)). | ||
| 268 | - (* LP_5 *) intros e w w' d H IH l. destruct d. | ||
| 269 | + eapply progress_trans. { exact (LP5r l e (enc w)). } | ||
| 270 | eapply progress_trans. { exact (IH (l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e))). } | ||
| 271 | exact (LP5l1 l e (enc w')). | ||
| 272 | + eapply progress_trans. { exact (LP5r l e (enc w)). } | ||
| 273 | eapply progress_trans. { exact (IH (l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e))). } | ||
| 274 | exact (LP5l0 l e (enc w')). | ||
| 275 | - (* LP_6 *) intros e w k y H IH l. | ||
| 276 | eapply progress_trans. { exact (LP6r l e (enc w)). } | ||
| 277 | eapply progress_trans. { exact (IH (l <* <[0;1;1;1])). } | ||
| 278 | exact (W10 l ([0;1] *> [0;0;1]^^k *> [0;0;0] *> enc y)). | ||
| 279 | - (* LP_T2 *) intros l. exact (LPT2 l). | ||
| 280 | - (* LP_T3 *) intros l. exact (LPT3 l). | ||
| 281 | - (* LP_T4 *) intros l. exact (LPT4 l). | ||
| 282 | - (* LP_T5 *) intros l. exact (LPT5 l). | ||
| 283 | - (* LP_T6 *) intros l. exact (LPT6 l). | ||
| 284 | - (* LP_eq *) intros w1 w2 w' d E H IH l. rewrite E. apply IH. | ||
| 285 | - (* Phi_B *) intros a b w w' d k y H IH H2 IH2 l. destruct d. | ||
| 286 | + eapply progress_trans. { exact (IH (l <* <[1;1;0]^^a <* [0] <* <[0;1;1]^^(S b))). } | ||
| 287 | eapply progress_trans. { exact (RP1 (l <* <[1;1;0]^^a) b (enc w')). } | ||
| 288 | exact (IH2 l). | ||
| 289 | + eapply progress_trans. { exact (IH (l <* <[1;1;0]^^a <* [0] <* <[0;1;1]^^(S b))). } | ||
| 290 | eapply progress_trans. { exact (RP0 (l <* <[1;1;0]^^a) b (enc w')). } | ||
| 291 | exact (IH2 l). | ||
| 292 | - (* Phi_E1 *) intros a e w k y H IH l. | ||
| 293 | eapply progress_trans. { exact (E1r l a e (enc w)). } | ||
| 294 | exact (IH l). | ||
| 295 | - (* Phi_E2 *) intros a e w w' d H IH l. destruct d. | ||
| 296 | + eapply progress_trans. { exact (LPCr (l <* <[1;1;0]^^a <* [0]) e (enc w)). } | ||
| 297 | eapply progress_trans. { exact (IH (l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e)). } | ||
| 298 | exact (E2l1 l a e (enc w')). | ||
| 299 | + eapply progress_trans. { exact (LPCr (l <* <[1;1;0]^^a <* [0]) e (enc w)). } | ||
| 300 | eapply progress_trans. { exact (IH (l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e)). } | ||
| 301 | exact (E2l0 l a e (enc w')). | ||
| 302 | - (* Phi_E0 *) intros a l. exact (Et0 l a). | ||
| 303 | - (* Phi_Et1 *) intros a l. exact (Et1 l a). | ||
| 304 | - (* Phi_Et2 *) intros a l. exact (Et2 l a). | ||
| 305 | - (* Phi_Et3 *) intros a k y H IH l. | ||
| 306 | eapply progress_trans. { exact (Et3 l a). } | ||
| 307 | specialize (IH l). rewrite enc_a0 in IH. exact IH. | ||
| 308 | - (* Phi_eq *) intros a b w1 w2 k y E H IH l. rewrite E. apply IH. | ||
| 74 | Qed. | 309 | Qed. |
| 76 | Hypothesis Ov: | ||
| 311 | (* ===================================================================== *) | ||
| 77 | forall r n m, | ||
| 312 | (* Section 4. Epochs and the start. *) | ||
| 78 | L (Npos (pow2' n)) |> R 0 m r -->* | ||
| 313 | (* ===================================================================== *) | ||
| 79 | const 0 <| (w0^^n *> w1^^(2+m) *> r). | ||
| 315 | Definition K (N : nat) (y : word) : Q * tape := | ||
| 81 | Definition f i := | ||
| 316 | const 0 <* <[1;1;0] <* [0] <* <[0;1;1]^^N {{C}}> enc y. | ||
| 82 | (N.to_nat (Npos (pow2' i) - 1)). | ||
| 318 | Lemma epoch_tm N y k y' : Phi 1 N y k y' -> K N y -->+ K (S k) y'. | ||
| 84 | Definition P0 i := | ||
| 85 | forall r, | ||
| ⋯ 7 template-only lines (template 86–94), not in ours | |||
| 95 | P0 i -> | ||
| 96 | P1 i. | ||
| 97 | Proof. | 319 | Proof. |
| 98 | unfold P0,P1,f. | ||
| 320 | intros H. eapply progress_trans. | ||
| 99 | intros HP0 r. | ||
| 321 | - exact (proj2 sound _ _ _ _ _ H (const 0)). | ||
| 100 | remember (N.to_nat (N.pos (pow2' i) - 1)) as n. | ||
| 322 | - apply Rst. | ||
| 101 | follow10 (Incs 0 n 0 r). | ||
| 102 | replace (N.of_nat (1+0+n)) with (Npos (pow2' i)) by lia. | ||
| ⋯ 5 template-only lines (template 103–107), not in ours | |||
| 108 | simpl_tape. | ||
| 109 | finish. | ||
| 110 | Qed. | 323 | Qed. |
| 112 | Lemma P0nxt i: | ||
| 325 | (* The blank tape reaches L(7, 000 010001) at step 304, then the restart gives K(1,8,t2). *) | ||
| 113 | P0 i -> | ||
| 326 | Lemma init : c0 -->* K 8 t2. | ||
| 114 | P0 (1+i). | ||
| 327 | Proof. unfold K. cbn. solve_init. Qed. | ||
| 329 | (* ===================================================================== *) | ||
| 330 | (* Section 5. A computable model (fuel), sound for LP / Phi. *) | ||
| 331 | (* ===================================================================== *) | ||
| 333 | Fixpoint lpf (n : nat) (w : word) {struct n} : option (word * bool) := | ||
| 334 | match n with | ||
| 335 | | O => None | ||
| 336 | | S n' => | ||
| 337 | match w with | ||
| 338 | | t0 => Some (t1, false) | ||
| 339 | | t1 => Some (t2, false) | ||
| 340 | | t2 => Some (t3, false) | ||
| 341 | | t3 => Some (blk false 0 t0, true) | ||
| 342 | | blk false e w => Some (blk true e w, false) | ||
| 343 | | blk true e w => | ||
| 344 | match lpf n' w with Some (w', d) => Some (blk false (addb e d) w', false) | None => None end | ||
| 345 | | p11 (S x) w => Some (p01 x w, true) | ||
| 346 | | p11 O w => Some (p00 w, true) | ||
| 347 | | p01 x w => Some (p11 x w, false) | ||
| 348 | | p00 w => Some (p10 w, false) | ||
| 349 | | p10 w => | ||
| 350 | match w with | ||
| 351 | | t0 => Some (t2, false) | ||
| 352 | | t1 => Some (blk false 0 t1, false) | ||
| 353 | | t2 => Some (p01 1 (p01 1 t1), false) | ||
| 354 | | t3 => Some (p00 (p01 0 t2), false) | ||
| 355 | | blk false e w => | ||
| 356 | match lpf n' w with Some (w', d) => Some (p01 (S (addb e d)) w', false) | None => None end | ||
| 357 | | blk true e w => | ||
| 358 | match phif n' 1 (S e) w with Some (k, y) => Some (blk false k y, false) | None => None end | ||
| 359 | | p00 t0 => Some (t2, false) | ||
| 360 | | p00 t1 => Some (p01 1 t1, false) | ||
| 361 | | p00 t2 => Some (p01 0 (p01 1 t1), false) | ||
| 362 | | p01 0 t2 => Some (p01 1 (p10 (p00 t2)), false) | ||
| 363 | | p01 1 t1 => Some (p01 2 (p10 (p00 t2)), false) | ||
| 364 | | p10 (p00 t2) => Some (blk false 0 t3, false) | ||
| 365 | | _ => None | ||
| 366 | end | ||
| 367 | end | ||
| 368 | end | ||
| 369 | with phif (n : nat) (a b : nat) (w : word) {struct n} : option (nat * word) := | ||
| 370 | match n with | ||
| 371 | | O => None | ||
| 372 | | S n' => | ||
| 373 | match b with | ||
| 374 | | O => None | ||
| 375 | | S O => | ||
| 376 | match w with | ||
| 377 | | blk false e w => phif n' (S (S a)) (S e) w | ||
| 378 | | blk true e w => | ||
| 379 | match lpf n' w with Some (w', d) => Some (a, p11 (addb e d) w') | None => None end | ||
| 380 | | t0 => Some (S a, t1) | ||
| 381 | | t1 => Some (a, p01 1 t1) | ||
| 382 | | t2 => Some (a, p10 (p00 t2)) | ||
| 383 | | t3 => phif n' (S a) 1 (blk false 0 t0) | ||
| 384 | | p10 t0 => Some (a, p01 1 t1) | ||
| 385 | | p10 t1 => Some (a, p11 0 t1) | ||
| 386 | | p00 t0 => Some (S a, t1) | ||
| 387 | | p00 t1 => phif n' (S (S a)) 1 t0 | ||
| 388 | | _ => None | ||
| 389 | end | ||
| 390 | | S (S b') => | ||
| 391 | match lpf n' w with | ||
| 392 | | Some (w', d) => phif n' (S a) (addb (S b') d) w' | ||
| 393 | | None => None | ||
| 394 | end | ||
| 395 | end | ||
| 396 | end. | ||
| 398 | Lemma enc_p10t0 : enc (p10 t0) = enc t1. | ||
| 399 | Proof. cbn. rewrite <- const_unfold. reflexivity. Qed. | ||
| 401 | Lemma enc_p10t1 : enc (p10 t1) = enc (blk true 0 t0). | ||
| 402 | Proof. cbn [enc lpow dsym]. rewrite z3. reflexivity. Qed. | ||
| 404 | Lemma enc_p00t0 : enc (p00 t0) = enc t0. | ||
| 405 | Proof. cbn. rewrite <- !const_unfold. reflexivity. Qed. | ||
| 407 | Lemma enc_p00t1 : enc (p00 t1) = enc (blk false 0 t0). | ||
| 408 | Proof. cbn [enc lpow dsym]. rewrite z3. reflexivity. Qed. | ||
| 410 | Lemma enc_p10p00t0 : enc (p10 (p00 t0)) = enc t1. | ||
| 411 | Proof. cbn. rewrite <- !const_unfold. reflexivity. Qed. | ||
| 413 | Lemma enc_p10p00t1 : enc (p10 (p00 t1)) = enc (p10 (blk false 0 t0)). | ||
| 414 | Proof. cbn [enc lpow dsym]. rewrite z3. reflexivity. Qed. | ||
| 416 | Lemma model_sound n : | ||
| 417 | (forall w w' d, lpf n w = Some (w', d) -> LP w w' d) /\ | ||
| 418 | (forall a b w k y, phif n a b w = Some (k, y) -> Phi a b w k y). | ||
| 115 | Proof. | 419 | Proof. |
| 116 | unfold P0. | ||
| 420 | induction n as [|n [IHl IHp]]; [split; intros; discriminate|]. | ||
| 117 | intros HP0 r. | ||
| 421 | split. | ||
| 118 | replace (1+i) with (i+1) by lia. | ||
| 422 | - intros w w' d H. cbn [lpf] in H. | ||
| 119 | rewrite lpow_add,Str_app_assoc. | ||
| 423 | destruct w as [| | | |[|] e w|[|x] w|x w|w|w]; try (inversion H; subst; constructor; fail). | ||
| 120 | follow HP0. | ||
| 424 | + destruct (lpf n w) as [[w1 d1]|] eqn:E; inversion H; subst. constructor. apply IHl, E. | ||
| 121 | pose proof (nxtP1 i HP0) as HP1. | ||
| 425 | + destruct w as [| | | |[|] e w|[|x] w|x w|w|w]; try discriminate. | ||
| 122 | unfold P1 in HP1. | ||
| 426 | * inversion H; subst. eapply LP_eq; [apply enc_p10t0 | constructor]. | ||
| 123 | simpl_tape. | ||
| 427 | * inversion H; subst. eapply LP_eq; [apply enc_p10t1 | ]. apply (LP_b 0 t0 t1 false). constructor. | ||
| 124 | follow100 HP1. | ||
| 428 | * inversion H; subst. constructor. | ||
| 125 | finish. | ||
| 429 | * inversion H; subst. constructor. | ||
| 430 | * destruct (phif n 1 (S e) w) as [[k y]|] eqn:E; inversion H; subst. constructor. apply IHp, E. | ||
| 431 | * destruct (lpf n w) as [[w1 d1]|] eqn:E; inversion H; subst. constructor. apply IHl, E. | ||
| 432 | * destruct x as [|[|x]]; try discriminate; destruct w; try discriminate; | ||
| 433 | inversion H; subst; constructor. | ||
| 434 | * destruct w; try discriminate; inversion H; subst. | ||
| 435 | -- eapply LP_eq; [apply enc_p10p00t0 | constructor]. | ||
| 436 | -- eapply LP_eq; [apply enc_p10p00t1 | ]. apply (LP_5 0 t0 t1 false). constructor. | ||
| 437 | -- constructor. | ||
| 438 | * destruct w; try discriminate. destruct w; try discriminate. inversion H; subst. | ||
| 439 | apply (LP_eq _ (blk true 0 t2)); [reflexivity | ]. apply (LP_b 0 t2 t3 false). constructor. | ||
| 440 | - intros a b w k y H. cbn [phif] in H. | ||
| 441 | destruct b as [|[|b]]; try discriminate. | ||
| 442 | + destruct w as [| | | |[|] e w|[|x] w|x w|w|w]; try discriminate. | ||
| 443 | * inversion H; subst. constructor. | ||
| 444 | * inversion H; subst. constructor. | ||
| 445 | * inversion H; subst. constructor. | ||
| 446 | * constructor. apply IHp, H. | ||
| 447 | * destruct (lpf n w) as [[w1 d1]|] eqn:E; inversion H; subst. constructor. apply IHl, E. | ||
| 448 | * constructor. apply IHp, H. | ||
| 449 | * destruct w; try discriminate; inversion H; subst. | ||
| 450 | -- eapply Phi_eq; [apply enc_p00t0 | constructor]. | ||
| 451 | -- eapply Phi_eq; [apply enc_p00t1 | ]. constructor. apply IHp, H. | ||
| 452 | * destruct w; try discriminate; inversion H; subst. | ||
| 453 | -- eapply Phi_eq; [apply enc_p10t0 | constructor]. | ||
| 454 | -- eapply Phi_eq; [apply enc_p10t1 | ]. apply (Phi_E2 _ 0 t0 t1 false). constructor. | ||
| 455 | + destruct (lpf n w) as [[w1 d1]|] eqn:E; try discriminate. | ||
| 456 | eapply Phi_B; [apply IHl, E | apply IHp, H]. | ||
| 126 | Qed. | 457 | Qed. |
| 128 | Lemma P0_0: | ||
| 460 | (* ===================================================================== *) | ||
| 129 | P0 0. | ||
| 461 | (* Section 6. Counter words G, their value, and the counting phase. *) | ||
| 462 | (* ===================================================================== *) | ||
| 464 | Open Scope nat_scope. | ||
| 466 | Definition tl_of (s : nat) : word := | ||
| 467 | match s with O => t0 | 1 => t1 | 2 => t2 | _ => t3 end. | ||
| 469 | Fixpoint gw (bs : list (bool * nat)) (s : nat) : word := | ||
| 470 | match bs with [] => tl_of s | (d, e) :: bs => blk d e (gw bs s) end. | ||
| 472 | Fixpoint ginc (bs : list (bool * nat)) (s : nat) : list (bool * nat) * nat * bool := | ||
| 473 | match bs with | ||
| 474 | | [] => match s with O => ([], 1, false) | 1 => ([], 2, false) | 2 => ([], 3, false) | ||
| 475 | | _ => ([(false, 0)], O, true) end | ||
| 476 | | (false, e) :: bs => ((true, e) :: bs, s, false) | ||
| 477 | | (true, e) :: bs => let '(bs', s', d) := ginc bs s in ((false, addb e d) :: bs', s', false) | ||
| 478 | end. | ||
| 480 | Fixpoint gval (bs : list (bool * nat)) (s : nat) : nat := | ||
| 481 | match bs with [] => 4 + s | (d, _) :: bs => (if d then 1 else 0) + 2 * gval bs s end. | ||
| 483 | Fixpoint gsum (bs : list (bool * nat)) : nat := | ||
| 484 | match bs with [] => O | (_, e) :: bs => e + gsum bs end. | ||
| 486 | Lemma ginc_LP bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> LP (gw bs s) (gw bs' s') d. | ||
| 130 | Proof. | 487 | Proof. |
| 131 | unfold P0. | ||
| 488 | intros Hs. induction bs as [|[[|] e] bs IH]; intros bs' s' d E; cbn in E. | ||
| 132 | es. | ||
| 489 | - destruct s as [|[|[|[|s]]]]; inversion E; subst; cbn; try constructor; lia. | ||
| 490 | - destruct (ginc bs s) as [[b1 s1] d1] eqn:E1. inversion E; subst. cbn. constructor. apply IH; reflexivity. | ||
| 491 | - inversion E; subst. constructor. | ||
| 133 | Qed. | 492 | Qed. |
| 135 | Lemma P0_spec i: | ||
| 494 | Lemma ginc_val bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> | ||
| 136 | P0 i. | ||
| 495 | gval bs' s' = S (gval bs s) /\ s' <= 3 /\ | ||
| 496 | gsum bs' + length bs + (if d then 1 else 0) = gsum bs + length bs' /\ | ||
| 497 | (d = true -> bs = []) /\ length bs <= length bs'. | ||
| 137 | Proof. | 498 | Proof. |
| 138 | induction i. | ||
| 499 | intros Hs. induction bs as [|[[|] e] bs IH]; intros bs' s' d E; cbn in E. | ||
| 139 | - apply P0_0. | ||
| 500 | - destruct s as [|[|[|[|s]]]]; inversion E; subst; cbn; repeat split; try lia; auto. | ||
| 140 | - apply P0nxt,IHi. | ||
| 501 | - destruct (ginc bs s) as [[b1 s1] d1] eqn:E1. inversion E; subst. | ||
| 502 | destruct (IH _ _ _ eq_refl) as (H1 & H2 & H3 & H4 & H5). cbn. | ||
| 503 | destruct d1; cbn [addb]; [specialize (H4 eq_refl); subst bs; cbn in *|]; repeat split; try lia; discriminate. | ||
| 504 | - inversion E; subst. cbn. repeat split; try lia; discriminate. | ||
| 141 | Qed. | 505 | Qed. |
| 143 | Definition config i := | ||
| 507 | Lemma gval_ge bs s : 4 <= gval bs s. | ||
| 144 | const 0 <| w1^^f i *> const 0. | ||
| 508 | Proof. induction bs as [|[d e] bs IH]; cbn; lia. Qed. | ||
| 146 | Hypothesis w0_all0: | ||
| 510 | Lemma gval_len bs s : length bs <= gval bs s. | ||
| 147 | w0 *> const 0 = const 0. | ||
| 511 | Proof. induction bs as [|[d e] bs IH]; cbn; [lia|]. pose proof (gval_ge bs s). lia. Qed. | ||
| 149 | Lemma config_S i: | ||
| 513 | (* Psi = value + budget + sum of exponents - number of blocks: no bounce raises it, every | ||
| 150 | config i -->+ config (S i). | ||
| 514 | E1g lowers it by value - 1 >= 3. So every counting phase ends (gcount below; cf. the | ||
| 515 | write-up's D.0). *) | ||
| 516 | Definition Psi (bs : list (bool * nat)) (s b : nat) : nat := gval bs s + b + gsum bs - length bs. | ||
| 518 | Import ListNotations. | ||
| 520 | (* ===================================================================== *) | ||
| 521 | (* Section 7. The epoch map on counter words, multi-step LP, digestion. *) | ||
| 522 | (* ===================================================================== *) | ||
| 524 | Definition blks := list (bool * nat). | ||
| 525 | Definition b2n (d : bool) : nat := if d then 1 else 0. | ||
| 526 | Lemma addb_b2n e d : addb e d = e + b2n d. | ||
| 527 | Proof. destruct d; cbn; lia. Qed. | ||
| 529 | Inductive GRes : Type := RE2 (k x : nat) (bs : blks) (s : nat) | RSp (k : nat) (y : word). | ||
| 530 | Definition rk (r : GRes) : nat := match r with RE2 k _ _ _ => k | RSp k _ => k end. | ||
| 531 | Definition ry (r : GRes) : word := match r with RE2 _ x bs s => p11 x (gw bs s) | RSp _ y => y end. | ||
| 533 | (* GPhi a b bs s r: the epoch map Phi on a counter word, bounce by bounce (write-up 3.6, 3.8). *) | ||
| 534 | Inductive GPhi : nat -> nat -> blks -> nat -> GRes -> Prop := | ||
| 535 | | GB a b bs s bs' s' d r : ginc bs s = (bs', s', d) -> GPhi (S a) (addb (S b) d) bs' s' r -> | ||
| 536 | GPhi a (S (S b)) bs s r | ||
| 537 | | GE1 a e bs s r : GPhi (S (S a)) (S e) bs s r -> GPhi a 1 ((false, e) :: bs) s r | ||
| 538 | | GE2 a e bs s bs' s' d : ginc bs s = (bs', s', d) -> | ||
| 539 | GPhi a 1 ((true, e) :: bs) s (RE2 a (addb e d) bs' s') | ||
| 540 | | GE0 a : GPhi a 1 [] 0 (RSp (S a) t1) | ||
| 541 | | GEt1 a : GPhi a 1 [] 1 (RSp a (p01 1 t1)) | ||
| 542 | | GEt2 a : GPhi a 1 [] 2 (RSp a (p10 (p00 t2))) | ||
| 543 | | GEt3 a r : GPhi (S a) 1 [(false, 0)] 0 r -> GPhi a 1 [] 3 r. | ||
| 545 | Lemma ginc_s3 bs s bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> s' <= 3. | ||
| 546 | Proof. intros Hs E. destruct (ginc_val bs s Hs _ _ _ E) as (_ & H & _). exact H. Qed. | ||
| 548 | Lemma GPhi_sound a b bs s r : GPhi a b bs s r -> s <= 3 -> Phi a b (gw bs s) (rk r) (ry r). | ||
| 151 | Proof. | 549 | Proof. |
| 152 | unfold config. | ||
| 550 | induction 1; intros Hs; cbn [gw rk ry tl_of] in *. | ||
| 153 | epose proof (nxtP1 i (P0_spec i) (const 0)) as HP1. | ||
| 551 | - eapply Phi_B. { apply (ginc_LP bs s Hs _ _ _ H). } apply IHGPhi. eapply ginc_s3; eauto. | ||
| 154 | rewrite w0_all0 in HP1. | ||
| 552 | - apply Phi_E1. apply IHGPhi. exact Hs. | ||
| 155 | follow10 HP1. | ||
| 553 | - apply Phi_E2. apply (ginc_LP bs s Hs _ _ _ H). | ||
| 156 | finish. | ||
| 554 | - apply Phi_E0. | ||
| 555 | - apply Phi_Et1. | ||
| 556 | - apply Phi_Et2. | ||
| 557 | - apply Phi_Et3. apply IHGPhi. lia. | ||
| 157 | Qed. | 558 | Qed. |
| 159 | Hypothesis init: | ||
| 560 | Lemma GPhi_s3 a b bs s r : GPhi a b bs s r -> s <= 3 -> | ||
| 160 | c0 -->* | ||
| 561 | match r with RE2 _ _ _ s2 => s2 <= 3 | RSp _ y => y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2) end. | ||
| 161 | config 0. | ||
| 163 | Lemma nonhalt:~halts tm c0. | ||
| 164 | Proof. | 562 | Proof. |
| 165 | eapply multistep_nonhalt. | ||
| 563 | induction 1; intros Hs; auto; try (apply IHGPhi; first [lia | eapply ginc_s3; eauto]). | ||
| 166 | 1: apply init. | ||
| 564 | eapply ginc_s3; eauto. | ||
| 167 | eapply progress_nonhalt_simple. | ||
| 168 | intro i. eexists. | ||
| 169 | apply config_S. | ||
| 170 | Qed. | 565 | Qed. |
| 172 | End FractalBEC. | ||
| 567 | Lemma GPhi_rk a b bs s r : GPhi a b bs s r -> a + b <= S (rk r). | ||
| 175 | Inductive Cert := | ||
| 568 | Proof. induction 1; try destruct d; cbn [rk addb] in *; lia. Qed. | ||
| 176 | | cert1 | ||
| 570 | Lemma gcount : forall P bs s a b, s <= 3 -> 1 <= b -> Psi bs s b <= P -> exists r, GPhi a b bs s r. | ||
| 177 | (QL QR : Q) | ||
| 571 | Proof. | ||
| 178 | (qL qR d1 w1 w0 : list Sym). | ||
| 572 | induction P as [P IHP] using lt_wf_ind. | ||
| 180 | Ltac solve_cert cert := | ||
| 573 | intros bs s a b. revert bs s a. induction b as [b IHb] using lt_wf_ind. intros bs s a Hs Hb HP. | ||
| 181 | match cert with | ||
| 574 | destruct b as [|[|b]]; [lia| |]. | ||
| 182 | (cert1 | ||
| 575 | - destruct bs as [|[[|] e] bs]. | ||
| 183 | ?QL ?QR | ||
| 576 | + destruct s as [|[|[|[|s]]]]; try lia. | ||
| 184 | ?qL ?qR ?d1 ?w1 ?w0) => | ||
| 577 | * eexists. apply GE0. | ||
| 185 | eapply (nonhalt _ | ||
| 578 | * eexists. apply GEt1. | ||
| 186 | QL QR | ||
| 579 | * eexists. apply GEt2. | ||
| 187 | qL qR d1 w1 w0); | ||
| 580 | * eexists. apply GEt3. apply (GE1 _ 0 []). apply GE0. | ||
| 188 | [ intros; | ||
| 581 | + destruct (ginc bs s) as [[b1 s1] d1] eqn:E1. eexists. eapply GE2. exact E1. | ||
| 189 | apply LInc_0; | ||
| 582 | + assert (Hlt : Psi bs s (S e) < P). | ||
| 190 | try (es; fail) | ||
| 583 | { unfold Psi in *. cbn [gval gsum length] in HP. pose proof (gval_ge bs s). pose proof (gval_len bs s). lia. } | ||
| 191 | | unfold R; | ||
| 584 | destruct (IHP _ Hlt bs s (S (S a)) (S e) Hs ltac:(lia) (le_n _)) as (r & H). | ||
| 192 | intros; | ||
| 585 | exists r. apply GE1, H. | ||
| 193 | try (es; fail) | ||
| 586 | - destruct (ginc bs s) as [[b1 s1] d1] eqn:E1. | ||
| 194 | | intros; | ||
| 587 | destruct (ginc_val bs s Hs _ _ _ E1) as (V1 & S1 & M1 & D1 & L1). | ||
| 195 | unfold L,R; | ||
| 588 | destruct d1. | ||
| 196 | rewrite BinaryCounter_0_full; | ||
| 589 | + specialize (D1 eq_refl). subst bs. cbn in E1. | ||
| 197 | try (es; fail) | ||
| 590 | destruct s as [|[|[|[|s]]]]; inversion E1; subst; try lia. | ||
| 198 | | solve_const0_eq | ||
| 591 | assert (Hlt : S b < S (S b)) by lia. | ||
| 199 | | unfold config,f; | ||
| 592 | destruct (IHb _ Hlt [(true, 0)] 0 (S (S a)) ltac:(lia) ltac:(lia)) as (r & H). | ||
| 200 | cbn; | ||
| 593 | { unfold Psi in *. cbn in HP |- *. lia. } | ||
| 201 | try (es; fail) | ||
| 594 | exists r. eapply GB. { exact E1. } | ||
| 202 | ] | ||
| 595 | cbn [addb]. eapply GB. { reflexivity. } exact H. | ||
| 596 | + assert (Hlt : S b < S (S b)) by lia. | ||
| 597 | destruct (IHb _ Hlt b1 s1 (S a) S1 ltac:(lia)) as (r & H). | ||
| 598 | { unfold Psi in *. lia. } | ||
| 599 | exists r. eapply GB. { exact E1. } exact H. | ||
| 600 | Qed. | ||
| 602 | (* Multi-step local pass: n LP steps, c absorptions. *) | ||
| 603 | Inductive LPs : word -> word -> nat -> nat -> Prop := | ||
| 604 | | LPs_eq w w' : enc w = enc w' -> LPs w w' 0 0 | ||
| 605 | | LPs_step w w1 w2 d n c : LP w w1 d -> LPs w1 w2 n c -> LPs w w2 (S n) (c + b2n d). | ||
| 607 | Lemma LPs_step' w w1 w2 d n c c' : LP w w1 d -> LPs w1 w2 n c -> c' = c + b2n d -> LPs w w2 (S n) c'. | ||
| 608 | Proof. intros H1 H2 ->. econstructor; eauto. Qed. | ||
| 610 | Lemma LPs_eql w0 w1 w2 n c : enc w0 = enc w1 -> LPs w1 w2 n c -> LPs w0 w2 n c. | ||
| 611 | Proof. | ||
| 612 | intros E H. inversion H; subst. | ||
| 613 | - apply LPs_eq. congruence. | ||
| 614 | - eapply LPs_step; [apply (LP_eq _ _ _ _ E); eassumption | eassumption]. | ||
| 615 | Qed. | ||
| 617 | Lemma LPs_trans w1 w2 w3 n c n' c' : LPs w1 w2 n c -> LPs w2 w3 n' c' -> LPs w1 w3 (n + n') (c + c'). | ||
| 618 | Proof. | ||
| 619 | intros H. revert n' c' w3. induction H; intros n' c' w3 H'. | ||
| 620 | - cbn. eapply LPs_eql; eassumption. | ||
| 621 | - eapply LPs_step'; [eassumption | apply IHLPs, H' | ]. destruct d; cbn; lia. | ||
| 622 | Qed. | ||
| 624 | Lemma LPs_cn w w' n c : LPs w w' n c -> c <= n. | ||
| 625 | Proof. induction 1; [lia | destruct d; cbn; lia]. Qed. | ||
| 627 | Lemma LPs_hub w w' n c : LPs w w' n c -> forall a B k y, n + 2 <= B + c -> | ||
| 628 | Phi (a + n) (B + c - n) w' k y -> Phi a B w k y. | ||
| 629 | Proof. | ||
| 630 | induction 1 as [w w' E | w w1 w2 d n c H1 H2 IH]; intros a B k y Hb HP. | ||
| 631 | - rewrite Nat.add_0_r in HP. replace (B + 0 - 0) with B in HP by lia. eapply Phi_eq; eassumption. | ||
| 632 | - pose proof (LPs_cn _ _ _ _ H2) as Hc. | ||
| 633 | destruct B as [|[|B]]; [destruct d; cbn in Hb; lia | destruct d; cbn in Hb; lia |]. | ||
| 634 | eapply Phi_B; [exact H1|]. apply IH. | ||
| 635 | + rewrite addb_b2n. destruct d; unfold b2n in *; lia. | ||
| 636 | + rewrite addb_b2n. replace (S a + n) with (a + S n) by lia. | ||
| 637 | replace (S B + b2n d + c - n) with (S (S B) + (c + b2n d) - S n) by (destruct d; unfold b2n; lia). | ||
| 638 | exact HP. | ||
| 639 | Qed. | ||
| 641 | Lemma LPs_nest y y' n c : LPs y y' n c -> forall k, LPs (blk false k y) (blk false (k + c) y') (2 * n) 0. | ||
| 642 | Proof. | ||
| 643 | induction 1 as [y y' E | y y1 y2 d n c H1 H2 IH]; intros k. | ||
| 644 | - rewrite Nat.add_0_r. apply LPs_eq. cbn [enc]. rewrite E. reflexivity. | ||
| 645 | - replace (2 * S n) with (S (S (2 * n))) by lia. | ||
| 646 | replace (k + (c + b2n d)) with (addb k d + c) by (rewrite addb_b2n; lia). | ||
| 647 | eapply LPs_step'; [apply LP_a | eapply LPs_step'; [apply (LP_b k y y1 d H1) | apply IH | reflexivity] | reflexivity]. | ||
| 648 | Qed. | ||
| 650 | (* The end words of a digestion (the end words of write-up 3.4), as explicit finite chains. *) | ||
| 651 | Inductive DigE : word -> nat -> nat -> blks -> nat -> Prop := | ||
| 652 | | DE0 : DigE (p10 t0) 0 0 [] 1 | ||
| 653 | | DE1 : DigE (p10 t1) 0 0 [(true, 0)] 0 | ||
| 654 | | DE2 : DigE (p10 t2) 13 5 [(false, 0)] 2 | ||
| 655 | | DE3 : DigE (p10 t3) 7 2 [(false, 0)] 2 | ||
| 656 | | DEs0 : DigE t1 0 0 [] 1 | ||
| 657 | | DEs1 : DigE (p01 1 t1) 2 1 [] 2 | ||
| 658 | | DEs2 : DigE (p10 (p00 t2)) 11 4 [(false, 0)] 2. | ||
| 660 | Ltac lps := first [ apply LPs_eq; first [reflexivity | apply enc_p10t0 | apply enc_p10t1] | ||
| 661 | | eapply LPs_step'; [ constructor | lps | reflexivity ] ]. | ||
| 663 | Lemma DigE_sound y n c bs s : DigE y n c bs s -> LPs y (gw bs s) n c. | ||
| 664 | Proof. destruct 1; cbn [gw tl_of]; lps. Qed. | ||
| 666 | Lemma DigE_props y n c bs s : DigE y n c bs s -> | ||
| 667 | n <= 13 /\ c <= 5 /\ length bs <= 1 /\ s <= 3 /\ Forall (fun e => e = 0) (map snd bs). | ||
| 668 | Proof. destruct 1; cbn; repeat split; auto; lia. Qed. | ||
| 670 | (* Digestion of a residue: DigP x bs s = digestion of 11 (001)^x 000 W, DigT = of 10 W, with W the | ||
| 671 | counter word gw bs s. n LP steps (own level), c absorptions, result gw bsp sp. A b-block runs a | ||
| 672 | sub-epoch (GPhi) and the next level is nested inside the new block (LPs_nest). *) | ||
| 673 | Inductive DigP : nat -> blks -> nat -> nat -> nat -> blks -> nat -> Prop := | ||
| 674 | | DP x bs s n c bsp sp : DigT bs s n c bsp sp -> DigP x bs s (2 * x + 2 + n) (S x + c) bsp sp | ||
| 675 | with DigT : blks -> nat -> nat -> nat -> blks -> nat -> Prop := | ||
| 676 | | DTa e bs s bs' s' d n c bsp sp : ginc bs s = (bs', s', d) -> | ||
| 677 | DigP (S (addb e d)) bs' s' n c bsp sp -> DigT ((false, e) :: bs) s (S (S n)) c bsp sp | ||
| 678 | | DTb e bs s k x bs2 s2 n c bsp sp : GPhi 1 (S e) bs s (RE2 k x bs2 s2) -> | ||
| 679 | DigP x bs2 s2 n c bsp sp -> DigT ((true, e) :: bs) s (S (2 * n)) 0 ((false, k + c) :: bsp) sp | ||
| 680 | | DTs e bs s k y n c bsp sp : GPhi 1 (S e) bs s (RSp k y) -> | ||
| 681 | DigE y n c bsp sp -> DigT ((true, e) :: bs) s (S (2 * n)) 0 ((false, k + c) :: bsp) sp | ||
| 682 | | DTt s n c bsp sp : DigE (p10 (tl_of s)) n c bsp sp -> DigT [] s n c bsp sp. | ||
| 684 | Scheme DigP_mind := Induction for DigP Sort Prop | ||
| 685 | with DigT_mind := Induction for DigT Sort Prop. | ||
| 686 | Combined Scheme Dig_mind from DigP_mind, DigT_mind. | ||
| 688 | Lemma prefix_LPs x w : LPs (p11 x w) (p10 w) (2 * x + 2) (S x). | ||
| 689 | Proof. | ||
| 690 | induction x as [|x IH]. | ||
| 691 | - eapply LPs_step'; [apply LP_110 | eapply LPs_step'; [apply LP_00 | apply LPs_eq; reflexivity | reflexivity] | reflexivity]. | ||
| 692 | - replace (2 * S x + 2) with (S (S (2 * x + 2))) by lia. | ||
| 693 | eapply LPs_step'; [apply LP_11S | eapply LPs_step'; [apply LP_01 | exact IH | reflexivity] | cbn; lia]. | ||
| 694 | Qed. | ||
| 696 | Lemma Dig_sound : | ||
| 697 | (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> LPs (p11 x (gw bs s)) (gw bsp sp) n c) /\ | ||
| 698 | (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> LPs (p10 (gw bs s)) (gw bsp sp) n c). | ||
| 699 | Proof. | ||
| 700 | apply Dig_mind. | ||
| 701 | - intros x bs s n c bsp sp H IH Hs. | ||
| 702 | exact (LPs_trans _ _ _ _ _ _ _ (prefix_LPs x (gw bs s)) (IH Hs)). | ||
| 703 | - intros e bs s bs' s' d n c bsp sp E H IH Hs. cbn [gw]. | ||
| 704 | eapply LPs_step'; [apply LP_5, (ginc_LP bs s Hs _ _ _ E) | | ||
| 705 | eapply LPs_step'; [apply LP_01 | apply IH; eapply ginc_s3; eauto | reflexivity] | cbn; lia]. | ||
| 706 | - intros e bs s k x bs2 s2 n c bsp sp HG H IH Hs. cbn [gw]. | ||
| 707 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hs2. cbn in Hs2. | ||
| 708 | eapply LPs_step'; [apply LP_6; exact (GPhi_sound _ _ _ _ _ HG Hs) | | ||
| 709 | exact (LPs_nest _ _ _ _ (IH Hs2) k) | reflexivity]. | ||
| 710 | - intros e bs s k y n c bsp sp HG H Hs. cbn [gw]. | ||
| 711 | eapply LPs_step'; [apply LP_6; exact (GPhi_sound _ _ _ _ _ HG Hs) | | ||
| 712 | exact (LPs_nest _ _ _ _ (DigE_sound _ _ _ _ _ H) k) | reflexivity]. | ||
| 713 | - intros s n c bsp sp H Hs. cbn [gw]. exact (DigE_sound _ _ _ _ _ H). | ||
| 714 | Qed. | ||
| 716 | Lemma Dig_sp : | ||
| 717 | (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> sp <= 3) /\ | ||
| 718 | (forall bs s n c bsp sp, DigT bs s n c bsp sp -> sp <= 3). | ||
| 719 | Proof. | ||
| 720 | apply Dig_mind; intros; auto; eapply DigE_props; eassumption. | ||
| 721 | Qed. | ||
| 723 | (* One epoch from an ordinary residue: digestion (n bounces), then counting (GPhi). *) | ||
| 724 | Lemma epoch_ord N x bs s n c bsp sp r : s <= 3 -> DigP x bs s n c bsp sp -> n + 2 <= N -> | ||
| 725 | GPhi (1 + n) (N + c - n) bsp sp r -> Phi 1 N (p11 x (gw bs s)) (rk r) (ry r). | ||
| 726 | Proof. | ||
| 727 | intros Hs HD Hn HG. | ||
| 728 | apply (LPs_hub _ _ _ _ (proj1 Dig_sound _ _ _ _ _ _ _ HD Hs) 1 N); [lia|]. | ||
| 729 | apply GPhi_sound; [exact HG | exact (proj1 Dig_sp _ _ _ _ _ _ _ HD)]. | ||
| 730 | Qed. | ||
| 732 | Lemma epoch_spec N y n c bsp sp r : DigE y n c bsp sp -> n + 2 <= N -> | ||
| 733 | GPhi (1 + n) (N + c - n) bsp sp r -> Phi 1 N y (rk r) (ry r). | ||
| 734 | Proof. | ||
| 735 | intros HD Hn HG. | ||
| 736 | apply (LPs_hub _ _ _ _ (DigE_sound _ _ _ _ _ HD) 1 N); [lia|]. | ||
| 737 | apply GPhi_sound; [exact HG | apply (DigE_props _ _ _ _ _ HD)]. | ||
| 738 | Qed. | ||
| 740 | (* ===================================================================== *) | ||
| 741 | (* Section 8. Positions and potentials (write-up D.0, Lemma C, D.7). *) | ||
| 742 | (* ===================================================================== *) | ||
| 744 | Definition exs (bs : blks) : list nat := map snd bs. | ||
| 746 | Fixpoint bumpl (l : list nat) : list nat := | ||
| 747 | match l with [] => [] | e :: l' => match l' with [] => [S e] | _ => e :: bumpl l' end end. | ||
| 749 | Lemma length_bumpl l : length (bumpl l) = length l. | ||
| 750 | Proof. induction l as [|e l IH]; [reflexivity|]. destruct l; cbn in *; [reflexivity|]. rewrite IH. reflexivity. Qed. | ||
| 752 | Lemma length_exs bs : length (exs bs) = length bs. | ||
| 753 | Proof. apply length_map. Qed. | ||
| 755 | (* inc on G: the exponents stay, or (overflow) the last one gets +1 and a new 0 is appended. *) | ||
| 756 | Lemma ginc_exps bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> | ||
| 757 | (exs bs' = exs bs /\ d = false) \/ | ||
| 758 | (exs bs' = bumpl (exs bs) ++ [0] /\ d = match bs with [] => true | _ => false end). | ||
| 759 | Proof. | ||
| 760 | intros Hs. induction bs as [|[[|] e] bs IH]; intros bs' s' d E; cbn in E. | ||
| 761 | - destruct s as [|[|[|[|s]]]]; inversion E; subst; cbn; auto; lia. | ||
| 762 | - destruct (ginc bs s) as [[b1 s1] d1] eqn:E1. inversion E; subst. | ||
| 763 | destruct (IH _ _ _ eq_refl) as [[H1 H2] | [H1 H2]]; subst; unfold exs in *; cbn [map snd]. | ||
| 764 | + left. rewrite H1. auto. | ||
| 765 | + right. rewrite H1. destruct bs as [|b bs]; cbn in *; subst; cbn; auto. | ||
| 766 | - inversion E; subst. left. auto. | ||
| 767 | Qed. | ||
| 769 | (* ---------- the Q potential: bounds the number of positions ---------- *) | ||
| 771 | Fixpoint qsum (l : list nat) : nat := match l with [] => 0 | e :: l => S e + 2 * qsum l end. | ||
| 772 | Definition Qp (f : nat) (bs : blks) (s p : nat) : nat := 2 ^ f * (gval bs s + 2 * qsum (exs bs) + p). | ||
| 773 | Definition QI (Q0 f : nat) (bs : blks) (s p : nat) : Prop := Qp f bs s p <= Q0 + 3 * 2 ^ (f + length bs). | ||
| 775 | Lemma qsum_app0 l : qsum (l ++ [0]) = qsum l + 2 ^ length l. | ||
| 776 | Proof. induction l as [|e l IH]; cbn [qsum app length]; [reflexivity|]. rewrite IH. cbn. lia. Qed. | ||
| 778 | Lemma qsum_bumpl l : l <> [] -> 2 * qsum (bumpl l) = 2 * qsum l + 2 ^ length l. | ||
| 779 | Proof. | ||
| 780 | induction l as [|e l IH]; intros Hne; [congruence|]. | ||
| 781 | destruct l as [|e' l]; [cbn; lia|]. | ||
| 782 | change (bumpl (e :: e' :: l)) with (e :: bumpl (e' :: l)). | ||
| 783 | cbn [qsum length]. rewrite Nat.pow_succ_r'. specialize (IH ltac:(discriminate)). cbn [qsum length] in IH. lia. | ||
| 784 | Qed. | ||
| 786 | Lemma gval_lb bs s : 4 * 2 ^ length bs <= gval bs s. | ||
| 787 | Proof. induction bs as [|[d e] bs IH]; cbn [gval length]; [cbn; lia|]. rewrite Nat.pow_succ_r'. lia. Qed. | ||
| 789 | Lemma gval_ub bs s : s <= 3 -> gval bs s < 8 * 2 ^ length bs. | ||
| 790 | Proof. intros Hs. induction bs as [|[d e] bs IH]; cbn [gval length]; [cbn; lia|]. rewrite Nat.pow_succ_r'. destruct d; lia. Qed. | ||
| 792 | Lemma QI_low Q0 f bs s p : QI Q0 f bs s p -> 2 ^ (f + length bs) <= Q0. | ||
| 793 | Proof. | ||
| 794 | unfold QI, Qp. intros H. pose proof (gval_lb bs s) as G. rewrite Nat.pow_add_r in *. | ||
| 795 | assert (2 ^ f * (4 * 2 ^ length bs) <= 2 ^ f * (gval bs s + 2 * qsum (exs bs) + p)) by (apply Nat.mul_le_mono_l; lia). | ||
| 796 | lia. | ||
| 797 | Qed. | ||
| 799 | Lemma QI_Ps Q0 Ps f bs s p : QI Q0 f bs s p -> Q0 < 2 ^ (Ps + 1) -> f + length bs <= Ps. | ||
| 800 | Proof. | ||
| 801 | intros H HP. apply QI_low in H. destruct (Nat.le_gt_cases (f + length bs) Ps) as [|Hc]; [assumption|]. | ||
| 802 | assert (2 ^ (Ps + 1) <= 2 ^ (f + length bs)) by (apply Nat.pow_le_mono_r; lia). lia. | ||
| 803 | Qed. | ||
| 805 | Lemma QI_drop Q0 f bs s p : QI Q0 f bs s p -> QI Q0 f bs s 0. | ||
| 806 | Proof. unfold QI, Qp. intros H. assert (2 ^ f * (gval bs s + 2 * qsum (exs bs) + 0) <= 2 ^ f * (gval bs s + 2 * qsum (exs bs) + p)) by (apply Nat.mul_le_mono_l; lia). lia. Qed. | ||
| 808 | Lemma QI_cons Q0 f dd e bs s p : QI Q0 f ((dd, e) :: bs) s 0 -> p <= S e -> QI Q0 (S f) bs s p. | ||
| 809 | Proof. | ||
| 810 | unfold QI, Qp, exs. cbn [map snd qsum gval length]. intros H Hp. | ||
| 811 | replace (S f + length bs) with (f + S (length bs)) by lia. | ||
| 812 | rewrite Nat.pow_succ_r'. | ||
| 813 | set (F := 2 ^ f) in *. set (G := gval bs s) in *. set (Q := qsum (map snd bs)) in *. | ||
| 814 | assert (F * p <= F * S e) by (apply Nat.mul_le_mono_l; lia). | ||
| 815 | assert (E1 : 2 * F * (G + 2 * Q + p) = 2 * (F * G) + 4 * (F * Q) + 2 * (F * p)) by ring. | ||
| 816 | assert (E2 : F * ((if dd then 1 else 0) + 2 * G + 2 * (S e + 2 * Q) + 0) = | ||
| 817 | F * (if dd then 1 else 0) + 2 * (F * G) + 2 * (F * S e) + 4 * (F * Q)) by ring. | ||
| 818 | rewrite E1. rewrite E2 in H. lia. | ||
| 819 | Qed. | ||
| 821 | Lemma QI_inc Q0 f bs s p bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> | ||
| 822 | QI Q0 f bs s (S p) -> QI Q0 f bs' s' (p + b2n d). | ||
| 823 | Proof. | ||
| 824 | intros Hs E H. unfold QI, Qp in *. | ||
| 825 | destruct (ginc_val bs s Hs _ _ _ E) as (V & _). | ||
| 826 | destruct (ginc_exps bs s Hs _ _ _ E) as [[E1 E2] | [E1 E2]]; subst d. | ||
| 827 | - assert (L : length bs' = length bs) by (rewrite <- !length_exs, E1; reflexivity). | ||
| 828 | rewrite E1, V, L. cbn [b2n]. replace (S (gval bs s) + 2 * qsum (exs bs) + (p + 0)) with | ||
| 829 | (gval bs s + 2 * qsum (exs bs) + S p) by lia. exact H. | ||
| 830 | - assert (L : length bs' = S (length bs)) | ||
| 831 | by (rewrite <- !length_exs, E1, length_app, length_bumpl; cbn; lia). | ||
| 832 | rewrite E1, V, L, qsum_app0, length_bumpl, length_exs. | ||
| 833 | replace (f + S (length bs)) with (S (f + length bs)) by lia. | ||
| 834 | rewrite Nat.pow_succ_r'. rewrite Nat.pow_add_r in *. | ||
| 835 | destruct bs as [|b bs0]. | ||
| 836 | + cbn [bumpl exs map qsum length b2n] in *. rewrite Nat.pow_0_r in *. | ||
| 837 | rewrite !Nat.mul_add_distr_l in *. lia. | ||
| 838 | + cbn [b2n]. pose proof (qsum_bumpl (exs (b :: bs0)) ltac:(cbn; discriminate)) as QB. | ||
| 839 | rewrite length_exs in QB. | ||
| 840 | set (F := 2 ^ f) in *. set (X := 2 ^ length (b :: bs0)) in *. | ||
| 841 | set (G := gval (b :: bs0) s) in *. set (Q := qsum (exs (b :: bs0))) in *. | ||
| 842 | set (Q' := qsum (bumpl (exs (b :: bs0)))) in *. | ||
| 843 | rewrite !Nat.mul_add_distr_l in *. | ||
| 844 | assert (F * (2 * (Q' + X)) = 2 * (F * Q) + 3 * (F * X)) by nia. | ||
| 845 | lia. | ||
| 846 | Qed. | ||
| 848 | Lemma QI_et3 Q0 f : QI Q0 f [] 3 0 -> QI Q0 f [(false, 0)] 0 0. | ||
| 849 | Proof. unfold QI, Qp. cbn. rewrite !Nat.add_0_r. rewrite Nat.add_1_r, Nat.pow_succ_r'. lia. Qed. | ||
| 851 | (* ---------- generic weighted potentials over positions ---------- *) | ||
| 853 | Fixpoint wpot (v : nat -> nat) (al be f : nat) (l : list nat) : nat := | ||
| 854 | match l with [] => 0 | e :: l => v f * (al * e + be) + wpot v al be (S f) l end. | ||
| 856 | Fixpoint vsum (v : nat -> nat) (f m : nat) : nat := | ||
| 857 | match m with 0 => 0 | S m => v f + vsum v (S f) m end. | ||
| 859 | Definition Pot (v : nat -> nat) (al be ga Ps f : nat) (l : list nat) : nat := | ||
| 860 | wpot v al be f l + ga * vsum v (f + length l) (Ps - (f + length l)). | ||
| 862 | Definition mono (v : nat -> nat) : Prop := forall i j, i <= j -> v i <= v j. | ||
| 864 | Lemma Pot_cons v al be ga Ps f e l : | ||
| 865 | Pot v al be ga Ps f (e :: l) = v f * (al * e + be) + Pot v al be ga Ps (S f) l. | ||
| 866 | Proof. unfold Pot. cbn [wpot length]. replace (f + S (length l)) with (S f + length l) by lia. lia. Qed. | ||
| 868 | Lemma wpot_app1 v al be f l x : wpot v al be f (l ++ [x]) = wpot v al be f l + v (f + length l) * (al * x + be). | ||
| 869 | Proof. | ||
| 870 | revert f. induction l as [|e l IH]; intros f; cbn [wpot app length]. | ||
| 871 | - rewrite !Nat.add_0_r. reflexivity. | ||
| 872 | - rewrite IH. replace (S f + length l) with (f + S (length l)) by lia. lia. | ||
| 873 | Qed. | ||
| 875 | Lemma wpot_bumpl v al be f l : mono v -> wpot v al be f (bumpl l) <= wpot v al be f l + al * v (f + length l). | ||
| 876 | Proof. | ||
| 877 | intros Hv. revert f. induction l as [|e l IH]; intros f; [cbn; lia|]. | ||
| 878 | destruct l as [|e' l]. | ||
| 879 | - cbn [bumpl wpot length]. pose proof (Hv f (f + 1) ltac:(lia)). nia. | ||
| 880 | - change (bumpl (e :: e' :: l)) with (e :: bumpl (e' :: l)). cbn [wpot length]. | ||
| 881 | specialize (IH (S f)). cbn [wpot length] in IH. replace (S f + S (length l)) with (f + S (S (length l))) in IH by lia. | ||
| 882 | lia. | ||
| 883 | Qed. | ||
| 885 | Lemma Pot_ov v al be ga Ps f l : mono v -> al + be + 1 <= ga -> f + length l + 1 <= Ps -> | ||
| 886 | Pot v al be ga Ps f (bumpl l ++ [0]) + v (f + length l) <= Pot v al be ga Ps f l. | ||
| 887 | Proof. | ||
| 888 | intros Hv Hg HP. unfold Pot. rewrite wpot_app1, length_app, length_bumpl. cbn [length]. | ||
| 889 | pose proof (wpot_bumpl v al be f l Hv) as B. | ||
| 890 | replace (Ps - (f + length l)) with (S (Ps - (f + (length l + 1)))) by lia. | ||
| 891 | cbn [vsum]. replace (S (f + length l)) with (f + (length l + 1)) by lia. | ||
| 892 | set (V := v (f + length l)) in *. set (R := vsum v (f + (length l + 1)) (Ps - (f + (length l + 1)))). | ||
| 893 | assert ((al + be + 1) * V <= ga * V) by (apply Nat.mul_le_mono_r; lia). | ||
| 894 | rewrite Nat.mul_0_r, Nat.add_0_l, Nat.mul_add_distr_l. rewrite !Nat.mul_add_distr_r in *. lia. | ||
| 895 | Qed. | ||
| 897 | Lemma Pot_inc v al be ga Ps Q0 f bs s p bs' s' d : mono v -> al + be + 1 <= ga -> Q0 < 2 ^ (Ps + 1) -> s <= 3 -> | ||
| 898 | ginc bs s = (bs', s', d) -> QI Q0 f bs s (S p) -> | ||
| 899 | Pot v al be ga Ps f (exs bs') + b2n d * v f <= Pot v al be ga Ps f (exs bs). | ||
| 900 | Proof. | ||
| 901 | intros Hv Hg HP Hs E HQ. | ||
| 902 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ) as HQ'. apply (QI_Ps _ Ps) in HQ'; [|exact HP]. | ||
| 903 | destruct (ginc_exps bs s Hs _ _ _ E) as [[E1 E2] | [E1 E2]]; subst. | ||
| 904 | - rewrite E1. cbn. lia. | ||
| 905 | - rewrite E1. assert (length bs' = S (length bs)) as L | ||
| 906 | by (rewrite <- !length_exs, E1, length_app, length_bumpl; cbn; lia). | ||
| 907 | pose proof (Pot_ov v al be ga Ps f (exs bs) Hv Hg) as O. rewrite length_exs in O. | ||
| 908 | specialize (O ltac:(lia)). destruct bs; cbn [b2n] in *; [rewrite Nat.add_0_r in O; lia | lia]. | ||
| 909 | Qed. | ||
| 911 | (* The epoch map consumes positions from the front; the potential pays for each one. *) | ||
| 912 | Lemma GPhi_pot v al be ga Ps Q0 : mono v -> al + be + 1 <= ga -> 1 <= al -> 2 <= be -> Q0 < 2 ^ (Ps + 1) -> | ||
| 913 | forall a b bs s r, GPhi a b bs s r -> s <= 3 -> forall f U, QI Q0 f bs s (b - 1) -> | ||
| 914 | (forall q, f <= q -> U <= v q) -> | ||
| 915 | match r with | ||
| 916 | | RE2 k x bs2 s2 => exists h, QI Q0 (f + S h) bs2 s2 0 /\ | ||
| 917 | U * k + Pot v al be ga Ps (f + S h) (exs bs2) + v (f + h) * (al * x + be) <= | ||
| 918 | Pot v al be ga Ps f (exs bs) + U * (a + b - 1) + al * v (f + h) | ||
| 919 | | RSp k y => U * k <= Pot v al be ga Ps f (exs bs) + U * (a + b) | ||
| 203 | end. | 920 | end. |
| 206 | Definition tm1 := Eval compute in (TM_from_str "1LB0LF_1LC0LE_1RD1LB_1RA0RD_1LA---_0LA0RB"). | ||
| 207 | Lemma nonhalt1: ~halts tm1 c0. | ||
| 208 | Proof. | 921 | Proof. |
| 209 | solve_cert (cert1 B D [1] [0] [0;1] [1;0;1] [0;0]). | ||
| 922 | intros Hv Hg Ha Hb HP. | ||
| 923 | induction 1 as [a b bs s bs' s' d r E H IH | a e bs s r H IH | a e bs s bs' s' d E | a | a | a | a r H IH]; | ||
| 924 | intros Hs f U HQ HU. | ||
| 925 | - (* bounce *) | ||
| 926 | replace (S (S b) - 1) with (S b) in HQ by lia. | ||
| 927 | pose proof (Pot_inc v al be ga Ps Q0 f bs s b bs' s' d Hv Hg HP Hs E HQ) as PI. | ||
| 928 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ) as HQ'. | ||
| 929 | specialize (IH (ginc_s3 _ _ _ _ _ Hs E) f U). | ||
| 930 | rewrite addb_b2n in IH. replace (S b + b2n d - 1) with (b + b2n d) in IH by lia. | ||
| 931 | specialize (IH HQ' HU). pose proof (HU f (le_n _)) as Uf. | ||
| 932 | destruct r as [k x bs2 s2 | k y]. | ||
| 933 | + destruct IH as (h & H1 & H2). exists h. split; [exact H1|]. | ||
| 934 | assert (U * b2n d <= b2n d * v f) by (destruct d; cbn; lia). nia. | ||
| 935 | + assert (U * b2n d <= b2n d * v f) by (destruct d; cbn; lia). nia. | ||
| 936 | - (* E1g *) | ||
| 937 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ'. | ||
| 938 | specialize (IH Hs (S f) U). replace (S e - 1) with e in IH by lia. specialize (IH HQ'). | ||
| 939 | specialize (IH (fun q Hq => HU q ltac:(lia))). pose proof (HU f (le_n _)) as Uf. | ||
| 940 | change (exs ((false, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 941 | assert (U * (e + 2) <= v f * (al * e + be)). | ||
| 942 | { apply (Nat.le_trans _ (v f * (e + 2))); [apply Nat.mul_le_mono_r; exact Uf|]. | ||
| 943 | apply Nat.mul_le_mono_l. assert (e <= al * e) by nia. lia. } | ||
| 944 | destruct r as [k x bs2 s2 | k y]. | ||
| 945 | + destruct IH as (h & H1 & H2). exists (S h). | ||
| 946 | replace (f + S (S h)) with (S f + S h) by lia. replace (f + S h) with (S f + h) by lia. | ||
| 947 | split; [exact H1|]. | ||
| 948 | replace (S (S a) + S e - 1) with (a + (e + 2)) in H2 by lia. rewrite (Nat.mul_add_distr_l U a (e + 2)) in H2. | ||
| 949 | replace (a + 1 - 1) with a by lia. lia. | ||
| 950 | + replace (S (S a) + S e) with ((a + 1) + (e + 2)) in IH by lia. rewrite (Nat.mul_add_distr_l U (a + 1) (e + 2)) in IH. lia. | ||
| 951 | - (* E2g *) | ||
| 952 | exists 0. pose proof (QI_cons _ _ _ _ _ _ 1 HQ ltac:(lia)) as HQ1. | ||
| 953 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ1) as HQ2. | ||
| 954 | pose proof (Pot_inc v al be ga Ps Q0 (S f) bs s 0 bs' s' d Hv Hg HP Hs E HQ1) as PI. | ||
| 955 | replace (f + 1) with (S f) by lia. rewrite Nat.add_0_r. | ||
| 956 | split; [eapply QI_drop; exact HQ2|]. | ||
| 957 | change (exs ((true, e) :: bs)) with (e :: exs bs). rewrite Pot_cons, addb_b2n. | ||
| 958 | assert (v f * (al * (e + b2n d) + be) <= v f * (al * e + be) + al * v f) by (destruct d; cbn; nia). | ||
| 959 | replace (a + 1 - 1) with a by lia. lia. | ||
| 960 | - nia. | ||
| 961 | - nia. | ||
| 962 | - nia. | ||
| 963 | - (* Et3 *) | ||
| 964 | pose proof (QI_et3 _ _ HQ) as HQ'. | ||
| 965 | pose proof (QI_Ps _ Ps _ _ _ _ HQ' HP) as HPs. cbn [length] in HPs. | ||
| 966 | pose proof (Pot_ov v al be ga Ps f [] Hv Hg ltac:(cbn; lia)) as O. cbn [bumpl app length] in O. | ||
| 967 | rewrite Nat.add_0_r in O. | ||
| 968 | specialize (IH ltac:(lia) f U HQ' HU). pose proof (HU f (le_n _)) as Uf. | ||
| 969 | destruct r as [k x bs2 s2 | k y]. | ||
| 970 | + destruct IH as (h & H1 & H2). exists h. split; [exact H1|]. cbn [exs map snd] in *. | ||
| 971 | replace (S a + 1 - 1) with (a + 1) in H2 by lia. rewrite (Nat.mul_add_distr_l U a 1) in H2. | ||
| 972 | replace (a + 1 - 1) with a by lia. lia. | ||
| 973 | + cbn [exs map snd] in *. replace (S a + 1) with (a + 1 + 1) in IH by lia. | ||
| 974 | rewrite (Nat.mul_add_distr_l U (a + 1) 1) in IH. lia. | ||
| 210 | Qed. | 975 | Qed. |
| 213 | Definition tm2 := Eval compute in (TM_from_str "1RB0LF_1LC---_1RE0LD_0LC1LF_0RE1RA_0LA0RC"). | ||
| 977 | (* ===================================================================== *) | ||
| 214 | Lemma nonhalt2: ~halts tm2 c0. | ||
| 978 | (* Section 9. Digestion bounds: cost, merged exponents, length; existence. *) | ||
| 979 | (* ===================================================================== *) | ||
| 981 | Definition w (q : nat) : nat := 2 ^ ((q + 1) / 2). | ||
| 983 | Lemma w_mono : mono w. | ||
| 984 | Proof. intros i j H. unfold w. apply Nat.pow_le_mono_r; [lia|]. apply Nat.Div0.div_le_mono; lia. Qed. | ||
| 986 | Lemma w_lev l q : 2 * l <= q -> 2 ^ l <= w q. | ||
| 215 | Proof. | 987 | Proof. |
| 216 | solve_cert (cert1 D A [0;1] [1;0] [0;1] [1;0;1] [0;0]). | ||
| 988 | intros H. unfold w. apply Nat.pow_le_mono_r; [lia|]. | ||
| 989 | replace l with ((2 * l) / 2) at 1 by (rewrite Nat.mul_comm, Nat.div_mul; lia). | ||
| 990 | apply Nat.Div0.div_le_mono; lia. | ||
| 217 | Qed. | 991 | Qed. |
| 220 | Definition tm3 := Eval compute in (TM_from_str "1LB0LC_1RB1LC_0LA0RD_1RF1LE_1LD---_1RA0RF"). | ||
| 993 | Lemma w_lev1 l q : 2 * l + 1 <= q -> 2 ^ S l <= w q. | ||
| 221 | Lemma nonhalt3: ~halts tm3 c0. | ||
| 222 | Proof. | 994 | Proof. |
| 223 | solve_cert (cert1 D A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 995 | intros H. unfold w. apply Nat.pow_le_mono_r; [lia|]. | ||
| 996 | replace (S l) with ((2 * S l) / 2) at 1 by (rewrite Nat.mul_comm, Nat.div_mul; lia). | ||
| 997 | apply Nat.Div0.div_le_mono; lia. | ||
| 224 | Qed. | 998 | Qed. |
| 227 | Definition tm4 := Eval compute in (TM_from_str "1LB0LE_1LC1LE_1RD1LB_1RA0RD_0LA0RF_1RD---"). | ||
| 1000 | Lemma GPhi_QI Q0 Ps a b bs s k x bs2 s2 f : Q0 < 2 ^ (Ps + 1) -> GPhi a b bs s (RE2 k x bs2 s2) -> s <= 3 -> | ||
| 228 | Lemma nonhalt4: ~halts tm4 c0. | ||
| 1001 | QI Q0 f bs s (b - 1) -> exists h, QI Q0 (f + S h) bs2 s2 0. | ||
| 229 | Proof. | 1002 | Proof. |
| 230 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1003 | intros HP HG Hs HQ. | ||
| 1004 | pose proof (GPhi_pot (fun _ => 0) 1 2 4 Ps Q0 ltac:(intros ? ? ?; lia) ltac:(lia) ltac:(lia) ltac:(lia) HP | ||
| 1005 | _ _ _ _ _ HG Hs f 0 HQ ltac:(intros; lia)) as G. | ||
| 1006 | destruct G as (h & G & _). eauto. | ||
| 231 | Qed. | 1007 | Qed. |
| 234 | Definition tm5 := Eval compute in (TM_from_str "1LB0LE_1LC1LE_1RD0LF_1RA0RD_0LA0RC_0RA---"). | ||
| 1009 | Lemma Dig_cost Q0 Ps : Q0 < 2 ^ (Ps + 1) -> | ||
| 235 | Lemma nonhalt5: ~halts tm5 c0. | ||
| 1010 | (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1011 | 2 ^ l * n <= Pot w 2 8 11 Ps f (exs bs) + 2 ^ l * (2 * x + 2) + 13 * w Ps) /\ | ||
| 1012 | (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1013 | 2 ^ l * n <= Pot w 2 8 11 Ps f (exs bs) + 13 * w Ps). | ||
| 236 | Proof. | 1014 | Proof. |
| 237 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1015 | intros HP. apply Dig_mind. | ||
| 1016 | - intros x bs s n c bsp sp H IH Hs l f Hl HQ. specialize (IH Hs l f Hl HQ). | ||
| 1017 | rewrite Nat.mul_add_distr_l. lia. | ||
| 1018 | - intros e bs s bs' s' d n c bsp sp E H IH Hs l f Hl HQ. | ||
| 1019 | pose proof (QI_cons _ _ _ _ _ _ 1 HQ ltac:(lia)) as HQ1. | ||
| 1020 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ1) as HQ2. apply QI_drop in HQ2. | ||
| 1021 | specialize (IH (ginc_s3 _ _ _ _ _ Hs E) l (S f) ltac:(lia) HQ2). | ||
| 1022 | pose proof (Pot_inc w 2 8 11 Ps Q0 (S f) bs s 0 bs' s' d w_mono ltac:(lia) HP Hs E HQ1) as PI. | ||
| 1023 | change (exs ((false, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1024 | pose proof (w_lev l f Hl) as Wf. set (L := 2 ^ l) in *. | ||
| 1025 | assert (E1 : L * S (S n) = L * n + 2 * L) by ring. | ||
| 1026 | assert (E2 : L * (2 * S (addb e d) + 2) + 2 * L <= w f * (2 * e + 8)). | ||
| 1027 | { rewrite addb_b2n. assert (L * (2 * S (e + b2n d) + 2) + 2 * L <= L * (2 * e + 8)) by (destruct d; cbn [b2n]; nia). | ||
| 1028 | assert (L * (2 * e + 8) <= w f * (2 * e + 8)) by (apply Nat.mul_le_mono_r; exact Wf). lia. } | ||
| 1029 | lia. | ||
| 1030 | - intros e bs s k x bs2 s2 n c bsp sp HG H IH Hs l f Hl HQ. | ||
| 1031 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ1. | ||
| 1032 | pose proof (GPhi_pot w 2 8 11 Ps Q0 w_mono ltac:(lia) ltac:(lia) ltac:(lia) HP _ _ _ _ _ HG Hs (S f) 0) as G. | ||
| 1033 | replace (S e - 1) with e in G by lia. specialize (G HQ1 (fun _ _ => Nat.le_0_l _)). | ||
| 1034 | destruct G as (h & G1 & G2). | ||
| 1035 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hs2. cbn in Hs2. | ||
| 1036 | specialize (IH Hs2 (S l) (S f + S h) ltac:(lia) G1). | ||
| 1037 | change (exs ((true, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1038 | pose proof (w_lev l f Hl) as Wf. pose proof (w_lev1 l (S f + h) ltac:(lia)) as Wh. | ||
| 1039 | rewrite Nat.pow_succ_r' in IH, Wh. set (L := 2 ^ l) in *. set (W' := w (S f + h)) in *. | ||
| 1040 | assert (E1 : L * S (2 * n) = L + 2 * L * n) by ring. | ||
| 1041 | assert (E2 : 2 * L * (2 * x + 2) <= W' * (2 * x + 2)) by (apply Nat.mul_le_mono_r; exact Wh). | ||
| 1042 | assert (E3 : W' * (2 * x + 8) = W' * (2 * x + 2) + 6 * W') by ring. | ||
| 1043 | assert (E4 : L <= w f * (2 * e + 8)) by nia. | ||
| 1044 | rewrite Nat.mul_0_l in G2. lia. | ||
| 1045 | - intros e bs s k y n c bsp sp HG H Hs l f Hl HQ. | ||
| 1046 | destruct (DigE_props _ _ _ _ _ H) as (Hn & _). | ||
| 1047 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in HPs. | ||
| 1048 | change (exs ((true, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1049 | pose proof (w_lev l f Hl) as Wf. pose proof (w_lev1 l Ps ltac:(lia)) as Wh. | ||
| 1050 | rewrite Nat.pow_succ_r' in Wh. set (L := 2 ^ l) in *. | ||
| 1051 | assert (E1 : L * S (2 * n) = L + 2 * L * n) by ring. | ||
| 1052 | assert (E2 : 2 * L * n <= 13 * w Ps) by nia. | ||
| 1053 | assert (E4 : L <= w f * (2 * e + 8)) by nia. | ||
| 1054 | lia. | ||
| 1055 | - intros s n c bsp sp H Hs l f Hl HQ. | ||
| 1056 | destruct (DigE_props _ _ _ _ _ H) as (Hn & _). | ||
| 1057 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in HPs. | ||
| 1058 | pose proof (w_lev l Ps ltac:(lia)) as Wf. nia. | ||
| 238 | Qed. | 1059 | Qed. |
| 241 | Definition tm6 := Eval compute in (TM_from_str "1LB0LE_1LC1LE_1RD1LF_1RA0RD_0LA0RC_1LC---"). | ||
| 1061 | Fixpoint MO (u : nat -> nat) (l : nat) (es : list nat) : nat := | ||
| 242 | Lemma nonhalt6: ~halts tm6 c0. | ||
| 1062 | match es with [] => 0 | e :: es => u l * e + MO u (S l) es end. | ||
| 1064 | Definition pu (u : nat -> nat) (l : nat) : nat := match l with 0 => 0 | S l' => u l' end. | ||
| 1066 | Lemma pu_le u l : mono u -> pu u l <= u l. | ||
| 1067 | Proof. intros Hu. destruct l; cbn; [lia | apply Hu; lia]. Qed. | ||
| 1069 | Lemma MO_zero u l es : Forall (fun e => e = 0) es -> MO u l es = 0. | ||
| 1070 | Proof. intros H. revert l. induction H as [|e es He H IH]; intros l; cbn; [reflexivity|]. rewrite IH, He. lia. Qed. | ||
| 1072 | (* The merged blocks (write-up D.3): any level weights u that the position weights v dominate. *) | ||
| 1073 | Lemma Dig_mass u v Q0 Ps : mono v -> mono u -> (forall l q, 2 * l <= q -> u l <= v q) -> Q0 < 2 ^ (Ps + 1) -> | ||
| 1074 | (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1075 | pu u l * c + MO u l (exs bsp) <= Pot v 1 3 5 Ps f (exs bs) + pu u l * S x + 6 * v Ps) /\ | ||
| 1076 | (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1077 | pu u l * c + MO u l (exs bsp) <= Pot v 1 3 5 Ps f (exs bs) + 6 * v Ps). | ||
| 243 | Proof. | 1078 | Proof. |
| 244 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1079 | intros Hv Hu Huv HP. apply Dig_mind. | ||
| 1080 | - intros x bs s n c bsp sp H IH Hs l f Hl HQ. specialize (IH Hs l f Hl HQ). | ||
| 1081 | rewrite Nat.mul_add_distr_l. lia. | ||
| 1082 | - intros e bs s bs' s' d n c bsp sp E H IH Hs l f Hl HQ. | ||
| 1083 | pose proof (QI_cons _ _ _ _ _ _ 1 HQ ltac:(lia)) as HQ1. | ||
| 1084 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ1) as HQ2. apply QI_drop in HQ2. | ||
| 1085 | specialize (IH (ginc_s3 _ _ _ _ _ Hs E) l (S f) ltac:(lia) HQ2). | ||
| 1086 | pose proof (Pot_inc v 1 3 5 Ps Q0 (S f) bs s 0 bs' s' d Hv ltac:(lia) HP Hs E HQ1) as PI. | ||
| 1087 | change (exs ((false, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1088 | pose proof (Nat.le_trans _ _ _ (pu_le u l Hu) (Huv l f Hl)) as Pf. | ||
| 1089 | assert (pu u l * S (S (addb e d)) <= v f * (1 * e + 3)). | ||
| 1090 | { rewrite addb_b2n. apply Nat.mul_le_mono; [exact Pf | destruct d; cbn; lia]. } | ||
| 1091 | lia. | ||
| 1092 | - intros e bs s k x bs2 s2 n c bsp sp HG H IH Hs l f Hl HQ. | ||
| 1093 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ1. | ||
| 1094 | pose proof (GPhi_pot v 1 3 5 Ps Q0 Hv ltac:(lia) ltac:(lia) ltac:(lia) HP _ _ _ _ _ HG Hs (S f) (u l)) as G. | ||
| 1095 | replace (S e - 1) with e in G by lia. specialize (G HQ1 (fun q Hq => Huv l q ltac:(lia))). | ||
| 1096 | destruct G as (h & G1 & G2). | ||
| 1097 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hs2. cbn in Hs2. | ||
| 1098 | specialize (IH Hs2 (S l) (S f + S h) ltac:(lia) G1). cbn [pu] in IH. | ||
| 1099 | change (exs ((true, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1100 | change (exs ((false, k + c) :: bsp)) with ((k + c) :: exs bsp). cbn [MO]. | ||
| 1101 | pose proof (Huv l f Hl) as Uf. pose proof (Huv l (S f + h) ltac:(lia)) as Uh. | ||
| 1102 | set (U := u l) in *. set (V' := v (S f + h)) in *. | ||
| 1103 | assert (E1 : U * S x <= V' * (x + 2)) by (apply Nat.mul_le_mono; lia). | ||
| 1104 | assert (E2 : V' * (1 * x + 3) = V' * (x + 2) + V') by ring. | ||
| 1105 | assert (E3 : U * (1 + S e - 1) <= v f * (1 * e + 3)) by (apply Nat.mul_le_mono; lia). | ||
| 1106 | assert (E4 : U * (k + c) = U * k + U * c) by ring. | ||
| 1107 | rewrite Nat.mul_0_r. lia. | ||
| 1108 | - intros e bs s k y n c bsp sp HG H Hs l f Hl HQ. | ||
| 1109 | destruct (DigE_props _ _ _ _ _ H) as (_ & Hc & _ & _ & Hz). | ||
| 1110 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ1. | ||
| 1111 | pose proof (GPhi_pot v 1 3 5 Ps Q0 Hv ltac:(lia) ltac:(lia) ltac:(lia) HP _ _ _ _ _ HG Hs (S f) (u l)) as G. | ||
| 1112 | replace (S e - 1) with e in G by lia. specialize (G HQ1 (fun q Hq => Huv l q ltac:(lia))). cbn beta iota in G. | ||
| 1113 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in HPs. | ||
| 1114 | change (exs ((true, e) :: bs)) with (e :: exs bs). rewrite Pot_cons. | ||
| 1115 | change (exs ((false, k + c) :: bsp)) with ((k + c) :: exs bsp). cbn [MO]. rewrite (MO_zero _ _ _ Hz). | ||
| 1116 | pose proof (Huv l f Hl) as Uf. pose proof (Huv l Ps ltac:(lia)) as Up. | ||
| 1117 | set (U := u l) in *. | ||
| 1118 | assert (E3 : U * (1 + S e) <= v f * (1 * e + 3)) by (apply Nat.mul_le_mono; lia). | ||
| 1119 | assert (E4 : U * (k + c) = U * k + U * c) by ring. | ||
| 1120 | assert (E5 : U * c <= 6 * v Ps) by nia. | ||
| 1121 | rewrite Nat.mul_0_r. lia. | ||
| 1122 | - intros s n c bsp sp H Hs l f Hl HQ. | ||
| 1123 | destruct (DigE_props _ _ _ _ _ H) as (_ & Hc & _ & _ & Hz). rewrite (MO_zero _ _ _ Hz). | ||
| 1124 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in HPs. | ||
| 1125 | pose proof (Nat.le_trans _ _ _ (pu_le u l Hu) (Huv l Ps ltac:(lia))) as Pf. nia. | ||
| 245 | Qed. | 1126 | Qed. |
| 248 | Definition tm7 := Eval compute in (TM_from_str "1LB0LF_0RC1LF_1RE1LD_1LC---_1RA0RE_0LA0RC"). | ||
| 1128 | Lemma Dig_len Q0 Ps : Q0 < 2 ^ (Ps + 1) -> | ||
| 249 | Lemma nonhalt7: ~halts tm7 c0. | ||
| 1129 | (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1130 | 2 * (l + length bsp) <= Ps + 3) /\ | ||
| 1131 | (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> | ||
| 1132 | 2 * (l + length bsp) <= Ps + 3). | ||
| 250 | Proof. | 1133 | Proof. |
| 251 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1134 | intros HP. apply Dig_mind. | ||
| 1135 | - intros x bs s n c bsp sp H IH Hs l f Hl HQ. exact (IH Hs l f Hl HQ). | ||
| 1136 | - intros e bs s bs' s' d n c bsp sp E H IH Hs l f Hl HQ. | ||
| 1137 | pose proof (QI_cons _ _ _ _ _ _ 1 HQ ltac:(lia)) as HQ1. | ||
| 1138 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ1) as HQ2. apply QI_drop in HQ2. | ||
| 1139 | exact (IH (ginc_s3 _ _ _ _ _ Hs E) l (S f) ltac:(lia) HQ2). | ||
| 1140 | - intros e bs s k x bs2 s2 n c bsp sp HG H IH Hs l f Hl HQ. | ||
| 1141 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ1. | ||
| 1142 | destruct (GPhi_QI Q0 Ps _ _ _ _ _ _ _ _ (S f) HP HG Hs ltac:(replace (S e - 1) with e by lia; exact HQ1)) as (h & G1). | ||
| 1143 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hs2. cbn in Hs2. | ||
| 1144 | specialize (IH Hs2 (S l) (S f + S h) ltac:(lia) G1). cbn [length]. lia. | ||
| 1145 | - intros e bs s k y n c bsp sp HG H Hs l f Hl HQ. | ||
| 1146 | destruct (DigE_props _ _ _ _ _ H) as (_ & _ & Hb & _). | ||
| 1147 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in *. lia. | ||
| 1148 | - intros s n c bsp sp H Hs l f Hl HQ. | ||
| 1149 | destruct (DigE_props _ _ _ _ _ H) as (_ & _ & Hb & _). | ||
| 1150 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [length] in *. lia. | ||
| 252 | Qed. | 1151 | Qed. |
| 255 | Definition tm8 := Eval compute in (TM_from_str "1LB0LF_0LC1LF_1RD0LB_0RD0RE_1RA---_0LA0RC"). | ||
| 1153 | Lemma pow_gt_self n : n < 2 ^ (n + 1). | ||
| 256 | Lemma nonhalt8: ~halts tm8 c0. | ||
| 1154 | Proof. induction n as [|n IH]; cbn; [lia|]. rewrite Nat.add_0_r. lia. Qed. | ||
| 1156 | Lemma DigE_ex y : y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2) -> exists n c bsp sp, DigE y n c bsp sp. | ||
| 1157 | Proof. intros [-> | [-> | ->]]; do 4 eexists; constructor. Qed. | ||
| 1159 | (* Every residue 11 (001)^x 000 W with W a counter word has a digestion. *) | ||
| 1160 | Lemma DigT_exists Q0 : forall D f bs s, s <= 3 -> QI Q0 f bs s 0 -> Q0 + 1 - 2 ^ f <= D -> | ||
| 1161 | exists n c bsp sp, DigT bs s n c bsp sp. | ||
| 257 | Proof. | 1162 | Proof. |
| 258 | solve_cert (cert1 C A [0;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1163 | induction D as [D IHD] using lt_wf_ind. intros f bs s Hs HQ HD. | ||
| 1164 | pose proof (pow_gt_self Q0) as HP. | ||
| 1165 | destruct bs as [|[[|] e] bs]. | ||
| 1166 | - destruct s as [|[|[|[|s]]]]; try lia; do 4 eexists; apply DTt; constructor. | ||
| 1167 | - destruct (gcount (Psi bs s (S e)) bs s 1 (S e) Hs ltac:(lia) (le_n _)) as (r & HG). | ||
| 1168 | pose proof (QI_cons _ _ _ _ _ _ e HQ (le_S _ _ (le_n _))) as HQ1. | ||
| 1169 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hr. | ||
| 1170 | destruct r as [k x bs2 s2 | k y]. | ||
| 1171 | + destruct (GPhi_QI Q0 Q0 _ _ _ _ _ _ _ _ (S f) HP HG Hs ltac:(replace (S e - 1) with e by lia; exact HQ1)) as (h & G1). | ||
| 1172 | pose proof (QI_low _ _ _ _ _ G1) as L1. rewrite Nat.pow_add_r in L1. | ||
| 1173 | assert (2 ^ f < 2 ^ (S f + S h)) by (apply Nat.pow_lt_mono_r; lia). | ||
| 1174 | assert (1 <= 2 ^ length bs2) by (apply Nat.neq_0_lt_0, Nat.pow_nonzero; lia). | ||
| 1175 | assert (2 ^ (S f + S h) <= Q0) by nia. | ||
| 1176 | destruct (IHD (Q0 + 1 - 2 ^ (S f + S h)) ltac:(lia) (S f + S h) bs2 s2 Hr G1 (le_n _)) as (n & c & bsp & sp & HT). | ||
| 1177 | do 4 eexists. eapply DTb; [exact HG | apply DP; exact HT]. | ||
| 1178 | + destruct (DigE_ex y Hr) as (n & c & bsp & sp & HE). | ||
| 1179 | do 4 eexists. eapply DTs; [exact HG | exact HE]. | ||
| 1180 | - destruct (ginc bs s) as [[bs' s'] d] eqn:E. | ||
| 1181 | pose proof (QI_cons _ _ _ _ _ _ 1 HQ ltac:(lia)) as HQ1. | ||
| 1182 | pose proof (QI_inc _ _ _ _ _ _ _ _ Hs E HQ1) as HQ2. apply QI_drop in HQ2. | ||
| 1183 | pose proof (QI_low _ _ _ _ _ HQ2) as L1. rewrite Nat.pow_add_r in L1. | ||
| 1184 | assert (2 ^ f < 2 ^ S f) by (apply Nat.pow_lt_mono_r; lia). | ||
| 1185 | assert (1 <= 2 ^ length bs') by (apply Nat.neq_0_lt_0, Nat.pow_nonzero; lia). | ||
| 1186 | assert (2 ^ S f <= Q0) by nia. | ||
| 1187 | destruct (IHD (Q0 + 1 - 2 ^ S f) ltac:(lia) (S f) bs' s' (ginc_s3 _ _ _ _ _ Hs E) HQ2 (le_n _)) | ||
| 1188 | as (n & c & bsp & sp & HT). | ||
| 1189 | do 4 eexists. eapply DTa; [exact E | apply DP; exact HT]. | ||
| 259 | Qed. | 1190 | Qed. |
| 262 | Definition tm9 := Eval compute in (TM_from_str "1LB0LF_1LC1LE_1RD1LB_1RA0RD_0LA---_0LA0RC"). | ||
| 1192 | (* ---------- the counting phase: exponents and value ---------- *) | ||
| 263 | Lemma nonhalt9: ~halts tm9 c0. | ||
| 1194 | Definition Rel (orig cur : list nat) : Prop := | ||
| 1195 | (forall i, S i < length cur -> nth i cur 0 <= nth i orig 0 + 1) /\ | ||
| 1196 | (forall i, length cur <= S i -> nth i cur 0 <= nth i orig 0). | ||
| 1198 | Lemma nth_bumpl l i : nth i (bumpl l) 0 = nth i l 0 + (if Nat.eqb (S i) (length l) then 1 else 0). | ||
| 264 | Proof. | 1199 | Proof. |
| 265 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1200 | revert i. induction l as [|e l IH]; intros i; [destruct i; reflexivity|]. | ||
| 1201 | destruct l as [|e' l]. | ||
| 1202 | - destruct i as [|[|i]]; cbn; lia. | ||
| 1203 | - change (bumpl (e :: e' :: l)) with (e :: bumpl (e' :: l)). | ||
| 1204 | destruct i as [|i]; cbn [nth length]; [cbn; lia|]. rewrite IH. reflexivity. | ||
| 266 | Qed. | 1205 | Qed. |
| 269 | Definition tm10 := Eval compute in (TM_from_str "1LB0LF_1LC1LF_1RD1LB_---0RE_1RA0RE_0LA0RC"). | ||
| 1207 | Lemma nth_app0 l i : nth i (l ++ [0]) 0 = nth i l 0. | ||
| 270 | Lemma nonhalt10: ~halts tm10 c0. | ||
| 1208 | Proof. revert i. induction l as [|e l IH]; intros [|i]; cbn; auto. destruct i; reflexivity. Qed. | ||
| 1210 | Lemma Rel_ov orig l : Rel orig l -> Rel orig (bumpl l ++ [0]). | ||
| 271 | Proof. | 1211 | Proof. |
| 272 | solve_cert (cert1 C A [1;1;0] [1;0;0] [1;0] [1;1;0] [0;0]). | ||
| 1212 | intros [R1 R2]. unfold Rel. rewrite length_app, length_bumpl. cbn [length]. split; intros i Hi; rewrite nth_app0, nth_bumpl. | ||
| 1213 | - destruct (Nat.eqb_spec (S i) (length l)). | ||
| 1214 | + specialize (R2 i ltac:(lia)). lia. | ||
| 1215 | + destruct (Nat.lt_ge_cases (S i) (length l)) as [H|H]; [specialize (R1 i H); lia|]. | ||
| 1216 | rewrite nth_overflow by lia. lia. | ||
| 1217 | - destruct (Nat.eqb_spec (S i) (length l)); [lia|]. rewrite nth_overflow by lia. lia. | ||
| 273 | Qed. | 1218 | Qed. |
| 276 | Definition tm11 := Eval compute in (TM_from_str "1LB1LF_1RC1LA_0RD0RC_1RE---_0LA0LF_0LE0RB"). | ||
| 1220 | Lemma Rel_inc orig bs s bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> Rel orig (exs bs) -> Rel orig (exs bs'). | ||
| 277 | Lemma nonhalt11: ~halts tm11 c0. | ||
| 278 | Proof. | 1221 | Proof. |
| 279 | solve_cert (cert1 B E [1;0;0] [1;0;0] [1;0] [1;0;0] [0;0]). | ||
| 1222 | intros Hs E R. destruct (ginc_exps bs s Hs _ _ _ E) as [[E1 _] | [E1 _]]; rewrite E1; [exact R|]. | ||
| 1223 | apply Rel_ov, R. | ||
| 280 | Qed. | 1224 | Qed. |
| 1226 | Lemma Rel_tl orig cur : Rel orig cur -> Rel (tl orig) (tl cur). | ||
| 1227 | Proof. | ||
| 1228 | intros [R1 R2]. split; intros i Hi. | ||
| 1229 | - destruct cur as [|c cur]; cbn in Hi; [lia|]. specialize (R1 (S i) ltac:(cbn; lia)). | ||
| 1230 | destruct orig as [|o orig]; destruct i; cbn in *; lia. | ||
| 1231 | - destruct cur as [|c cur]; [destruct i; cbn; lia|]. cbn [length tl] in Hi |- *. | ||
| 1232 | specialize (R2 (S i) ltac:(cbn; lia)). | ||
| 1233 | destruct orig as [|o orig]; destruct i; cbn in *; lia. | ||
| 1234 | Qed. | ||
| 1236 | Lemma Rel_refl l : Rel l l. | ||
| 1237 | Proof. split; intros; lia. Qed. | ||
| 1239 | Lemma GPhi_rel a b bs s r : GPhi a b bs s r -> s <= 3 -> forall orig, Rel orig (exs bs) -> | ||
| 1240 | match r with | ||
| 1241 | | RE2 k x bs2 s2 => exists h, Rel (skipn (S h) orig) (exs bs2) /\ x <= nth h orig 0 + 1 | ||
| 1242 | | RSp _ _ => True | ||
| 1243 | end. | ||
| 1244 | Proof. | ||
| 1245 | induction 1 as [a b bs s bs' s' d r E H IH | a e bs s r H IH | a e bs s bs' s' d E | a | a | a | a r H IH]; | ||
| 1246 | intros Hs orig R; auto. | ||
| 1247 | - apply IH; [eapply ginc_s3; eauto | eapply Rel_inc; eauto]. | ||
| 1248 | - specialize (IH Hs (tl orig) (Rel_tl _ _ R)). destruct r as [k x bs2 s2|]; [|exact I]. | ||
| 1249 | destruct IH as (h & R1 & R2). exists (S h). split. | ||
| 1250 | + destruct orig; [destruct h|]; exact R1. | ||
| 1251 | + destruct orig; cbn in *; [destruct h|]; auto. | ||
| 1252 | - exists 0. split. | ||
| 1253 | + apply (Rel_inc _ bs s bs' s' d Hs E). exact (Rel_tl _ _ R). | ||
| 1254 | + destruct R as [R1 R2]. destruct (ginc_exps bs s Hs _ _ _ E) as [[_ ->] | [_ Ed]]. | ||
| 1255 | * cbn [addb]. destruct bs as [|b bs]. | ||
| 1256 | -- specialize (R2 0 ltac:(cbn; lia)). cbn in R2. lia. | ||
| 1257 | -- specialize (R1 0 ltac:(cbn; lia)). cbn in R1. lia. | ||
| 1258 | * destruct bs as [|b bs]; subst d; cbn [addb]. | ||
| 1259 | -- specialize (R2 0 ltac:(cbn; lia)). cbn in R2. lia. | ||
| 1260 | -- specialize (R1 0 ltac:(cbn; lia)). cbn in R1. lia. | ||
| 1261 | - apply IH; [lia|]. destruct R as [R1 R2]. split; intros i Hi; cbn in Hi; [lia|]. | ||
| 1262 | destruct i as [|[|i]]; cbn; apply Nat.le_0_l. | ||
| 1263 | Qed. | ||
| 1265 | Lemma GPhi_val a b bs s r : GPhi a b bs s r -> s <= 3 -> | ||
| 1266 | match r with RE2 k x bs2 s2 => 2 * gval bs2 s2 + a <= gval bs s + k + 2 | RSp _ _ => True end. | ||
| 1267 | Proof. | ||
| 1268 | induction 1 as [a b bs s bs' s' d r E H IH | a e bs s r H IH | a e bs s bs' s' d E | a | a | a | a r H IH]; | ||
| 1269 | intros Hs; auto. | ||
| 1270 | - destruct (ginc_val bs s Hs _ _ _ E) as (V & S1 & _). specialize (IH S1). destruct r; [rewrite V in IH; lia | exact I]. | ||
| 1271 | - specialize (IH Hs). destruct r; [cbn [gval]; lia | exact I]. | ||
| 1272 | - destruct (ginc_val bs s Hs _ _ _ E) as (V & _). cbn [gval]. rewrite V. lia. | ||
| 1273 | - specialize (IH ltac:(lia)). destruct r; [cbn [gval] in *; lia | exact I]. | ||
| 1274 | Qed. | ||
| 1276 | (* ===================================================================== *) | ||
| 1277 | (* Section 10. Weights, masses, the threshold, the orbit invariant. *) | ||
| 1278 | (* ===================================================================== *) | ||
| 1280 | Definition v2 (q : nat) : nat := 2 ^ (q / 2). | ||
| 1281 | Definition p2 (q : nat) : nat := 2 ^ S q. | ||
| 1282 | Definition cst1 (q : nat) : nat := 1. | ||
| 1283 | Definition u1 (l : nat) : nat := match l with 0 => 0 | S l' => 2 * w l' end. | ||
| 1284 | Definition u2 (l : nat) : nat := match l with 0 => 0 | S l' => 2 ^ S l' end. | ||
| 1286 | Lemma v2_mono : mono v2. | ||
| 1287 | Proof. intros i j H. unfold v2. apply Nat.pow_le_mono_r; [lia|]. apply Nat.Div0.div_le_mono; lia. Qed. | ||
| 1288 | Lemma p2_mono : mono p2. | ||
| 1289 | Proof. intros i j H. unfold p2. apply Nat.pow_le_mono_r; lia. Qed. | ||
| 1290 | Lemma cst1_mono : mono cst1. | ||
| 1291 | Proof. intros i j H. unfold cst1. lia. Qed. | ||
| 1292 | Lemma v2_le_w q : v2 q <= w q. | ||
| 1293 | Proof. unfold v2, w. apply Nat.pow_le_mono_r; [lia|]. apply Nat.Div0.div_le_mono; lia. Qed. | ||
| 1294 | Lemma cst1_le_w q : cst1 q <= w q. | ||
| 1295 | Proof. unfold cst1, w. apply Nat.neq_0_lt_0, Nat.pow_nonzero. lia. Qed. | ||
| 1297 | Lemma u1_mono : mono u1. | ||
| 1298 | Proof. intros [|i] [|j] H; cbn [u1]; try lia. pose proof (w_mono i j ltac:(lia)). lia. Qed. | ||
| 1299 | Lemma u1_w l q : 2 * l <= q -> u1 l <= w q. | ||
| 1300 | Proof. | ||
| 1301 | destruct l as [|l]; intros H; cbn [u1]; [lia|]. | ||
| 1302 | pose proof (w_lev1 l q ltac:(lia)) as W. unfold w at 1. | ||
| 1303 | rewrite <- Nat.pow_succ_r'. | ||
| 1304 | apply (Nat.le_trans _ (2 ^ S l)); [|exact W]. | ||
| 1305 | apply Nat.pow_le_mono_r; [lia|]. | ||
| 1306 | destruct l as [|l]; [cbn; lia|]. | ||
| 1307 | assert ((S l + 1) / 2 <= (2 * S l) / 2) by (apply Nat.Div0.div_le_mono; lia). | ||
| 1308 | rewrite (Nat.mul_comm 2 (S l)), Nat.div_mul in H0 by lia. lia. | ||
| 1309 | Qed. | ||
| 1310 | Lemma u2_mono : mono u2. | ||
| 1311 | Proof. intros [|i] [|j] H; cbn [u2]; try lia. apply Nat.pow_le_mono_r; lia. Qed. | ||
| 1312 | Lemma u2_v2 l q : 2 * l <= q -> u2 l <= v2 q. | ||
| 1313 | Proof. | ||
| 1314 | destruct l as [|l]; intros H; cbn [u2]; [lia|]. unfold v2. apply Nat.pow_le_mono_r; [lia|]. | ||
| 1315 | replace (S l) with ((2 * S l) / 2) at 1 by (rewrite Nat.mul_comm, Nat.div_mul; lia). | ||
| 1316 | apply Nat.Div0.div_le_mono; lia. | ||
| 1317 | Qed. | ||
| 1319 | Lemma MO_u1 l es : MO u1 (S l) es = 2 * wpot w 1 0 l es. | ||
| 1320 | Proof. revert l. induction es as [|e es IH]; intros l; cbn [MO wpot]; [reflexivity|]. rewrite IH. cbn [u1]. lia. Qed. | ||
| 1321 | Lemma MO_u1_0 es : MO u1 0 es = 2 * wpot w 1 0 0 (tl es). | ||
| 1322 | Proof. destruct es as [|e es]; cbn [MO tl]; [reflexivity|]. rewrite MO_u1. cbn [u1]. lia. Qed. | ||
| 1323 | Lemma MO_u2 l es : MO u2 (S l) es = wpot p2 1 0 l es. | ||
| 1324 | Proof. revert l. induction es as [|e es IH]; intros l; cbn [MO wpot]; [reflexivity|]. rewrite IH. cbn [u2]. unfold p2. lia. Qed. | ||
| 1325 | Lemma MO_u2_0 es : MO u2 0 es = wpot p2 1 0 0 (tl es). | ||
| 1326 | Proof. destruct es as [|e es]; cbn [MO tl]; [reflexivity|]. rewrite MO_u2. cbn [u2]. lia. Qed. | ||
| 1327 | Lemma nth_le_MO h es : forall l, nth h es 0 <= MO cst1 l es. | ||
| 1328 | Proof. | ||
| 1329 | revert h. induction es as [|e es IH]; intros h l; [destruct h; cbn; lia|]. | ||
| 1330 | destruct h as [|h]; cbn [nth MO]; unfold cst1 at 1; [lia|]. specialize (IH h (S l)). lia. | ||
| 1331 | Qed. | ||
| 1333 | Lemma wpot_shift v al be f f' l : mono v -> f <= f' -> wpot v al be f l <= wpot v al be f' l. | ||
| 1334 | Proof. | ||
| 1335 | intros Hv. revert f f'. induction l as [|e l IH]; intros f f' H; cbn [wpot]; [lia|]. | ||
| 1336 | pose proof (Hv f f' H). specialize (IH (S f) (S f') ltac:(lia)). | ||
| 1337 | assert (v f * (al * e + be) <= v f' * (al * e + be)) by (apply Nat.mul_le_mono_r; lia). lia. | ||
| 1338 | Qed. | ||
| 1339 | Lemma wpot_drop v al be f h l : wpot v al be (f + h) (skipn h l) <= wpot v al be f l. | ||
| 1340 | Proof. | ||
| 1341 | revert f l. induction h as [|h IH]; intros f l; [rewrite Nat.add_0_r; reflexivity|]. | ||
| 1342 | destruct l as [|e l]; cbn [skipn wpot]; [lia|]. specialize (IH (S f) l). | ||
| 1343 | replace (f + S h) with (S f + h) by lia. lia. | ||
| 1344 | Qed. | ||
| 1345 | Lemma wpot_skipn_tl v h l : mono v -> wpot v 1 0 0 (skipn (S h) l) <= wpot v 1 0 0 (tl l). | ||
| 1346 | Proof. | ||
| 1347 | intros Hv. replace (skipn (S h) l) with (skipn h (tl l)) by (destruct l; [destruct h|]; reflexivity). | ||
| 1348 | apply (Nat.le_trans _ (wpot v 1 0 (0 + h) (skipn h (tl l)))); [apply wpot_shift; [exact Hv | lia]|]. | ||
| 1349 | apply wpot_drop. | ||
| 1350 | Qed. | ||
| 1351 | Lemma wpot_le_nth v l1 : mono v -> forall l2 f, (forall i, nth i l1 0 <= nth i l2 0 + 1) -> | ||
| 1352 | wpot v 1 0 f l1 <= wpot v 1 0 f l2 + vsum v f (length l1). | ||
| 1353 | Proof. | ||
| 1354 | intros Hv. induction l1 as [|e1 l1 IH]; intros l2 f H; cbn [wpot length vsum]; [lia|]. | ||
| 1355 | destruct l2 as [|e2 l2]. | ||
| 1356 | - assert (H' : forall i, nth i l1 0 <= nth i [] 0 + 1) by (intros i; specialize (H (S i)); destruct i; cbn in *; lia). | ||
| 1357 | specialize (IH [] (S f) H'). cbn [wpot] in IH |- *. | ||
| 1358 | pose proof (H 0) as H0. cbn in H0. assert (v f * (1 * e1 + 0) <= v f) by nia. lia. | ||
| 1359 | - specialize (IH l2 (S f) (fun i => H (S i))). cbn [wpot]. | ||
| 1360 | pose proof (H 0) as H0. cbn in H0. assert (v f * (1 * e1 + 0) <= v f * (1 * e2 + 0) + v f) by nia. lia. | ||
| 1361 | Qed. | ||
| 1362 | Lemma Rel_nth orig cur : Rel orig cur -> forall i, nth i cur 0 <= nth i orig 0 + 1. | ||
| 1363 | Proof. intros [R1 R2] i. destruct (Nat.lt_ge_cases (S i) (length cur)); [apply R1 | specialize (R2 i)]; lia. Qed. | ||
| 1364 | Lemma wpot_split v al be f l : wpot v al be f l = wpot v al 0 f l + be * vsum v f (length l). | ||
| 1365 | Proof. revert f. induction l as [|e l IH]; intros f; cbn [wpot vsum length]; [lia|]. rewrite IH. ring. Qed. | ||
| 1366 | Lemma wpot_scale2 v f l : wpot v 2 0 f l = 2 * wpot v 1 0 f l. | ||
| 1367 | Proof. revert f. induction l as [|e l IH]; intros f; cbn [wpot]; [lia|]. rewrite IH. ring. Qed. | ||
| 1368 | Lemma wpot_le_v v v' al be f l : (forall q, v q <= v' q) -> wpot v al be f l <= wpot v' al be f l. | ||
| 1369 | Proof. | ||
| 1370 | intros H. revert f. induction l as [|e l IH]; intros f; cbn [wpot]; [lia|]. | ||
| 1371 | specialize (IH (S f)). assert (v f * (al * e + be) <= v' f * (al * e + be)) by (apply Nat.mul_le_mono_r, H). lia. | ||
| 1372 | Qed. | ||
| 1373 | Lemma vsum_add v f m m' : vsum v f (m + m') = vsum v f m + vsum v (f + m) m'. | ||
| 1374 | Proof. revert f. induction m as [|m IH]; intros f; cbn [vsum Nat.add]; [rewrite Nat.add_0_r; lia|]. rewrite IH. replace (S f + m) with (f + S m) by lia. lia. Qed. | ||
| 1375 | Lemma vsum_mono_m v f m m' : m <= m' -> vsum v f m <= vsum v f m'. | ||
| 1376 | Proof. intros H. replace m' with (m + (m' - m)) by lia. rewrite vsum_add. lia. Qed. | ||
| 1377 | Lemma vsum_cst1 f m : vsum cst1 f m = m. | ||
| 1378 | Proof. revert f. induction m as [|m IH]; intros f; cbn; [reflexivity|]. rewrite IH. unfold cst1. lia. Qed. | ||
| 1379 | Lemma vsum_p2 f m : vsum p2 f m + 2 ^ S f = 2 ^ S (f + m). | ||
| 1380 | Proof. | ||
| 1381 | revert f. induction m as [|m IH]; intros f; cbn [vsum]; [rewrite Nat.add_0_r; lia|]. | ||
| 1382 | specialize (IH (S f)). replace (f + S m) with (S f + m) by lia. unfold p2 in *. rewrite (Nat.pow_succ_r' 2 (S f)) in IH. lia. | ||
| 1383 | Qed. | ||
| 1384 | Lemma wpot_p2_S f l : wpot p2 1 0 (S f) l = 2 * wpot p2 1 0 f l. | ||
| 1385 | Proof. revert f. induction l as [|e l IH]; intros f; cbn [wpot]; [lia|]. rewrite IH. unfold p2. rewrite (Nat.pow_succ_r' 2 (S f)). ring. Qed. | ||
| 1386 | Lemma qsum_p2 l : 2 * qsum l + 2 = 2 ^ S (length l) + wpot p2 1 0 0 l. | ||
| 1387 | Proof. | ||
| 1388 | induction l as [|e l IH]; cbn [qsum length wpot]; [cbn; lia|]. rewrite wpot_p2_S. | ||
| 1389 | change (p2 0) with 2. rewrite (Nat.pow_succ_r' 2 (S (length l))). lia. | ||
| 1390 | Qed. | ||
| 1391 | Lemma wpot_zero v f l : Forall (fun e => e = 0) l -> wpot v 1 0 f l = 0. | ||
| 1392 | Proof. intros H. revert f. induction H as [|e l He H IH]; intros f; cbn; [reflexivity|]. rewrite IH, He. lia. Qed. | ||
| 1393 | Lemma Pot_top v al be ga Ps l : be <= ga -> length l <= Ps -> | ||
| 1394 | Pot v al be ga Ps 0 l <= wpot v al 0 0 l + ga * vsum v 0 Ps. | ||
| 1395 | Proof. | ||
| 1396 | intros Hb Hl. unfold Pot. rewrite wpot_split. cbn [Nat.add]. | ||
| 1397 | pose proof (vsum_add v 0 (length l) (Ps - length l)) as E. replace (length l + (Ps - length l)) with Ps in E by lia. | ||
| 1398 | cbn [Nat.add] in E. rewrite E. | ||
| 1399 | assert (be * vsum v 0 (length l) <= ga * vsum v 0 (length l)) by (apply Nat.mul_le_mono_r; lia). | ||
| 1400 | rewrite Nat.mul_add_distr_l. lia. | ||
| 1401 | Qed. | ||
| 1403 | (* ---------- the bound functions (all nondecreasing in kappa) ---------- *) | ||
| 1405 | Definition Ws (P : nat) : nat := vsum w 0 P. | ||
| 1406 | Definition V2s (P : nat) : nat := vsum v2 0 P. | ||
| 1407 | Definition Pf (k : nat) : nat := Nat.max 12 (k + 3). | ||
| 1408 | Definition Af (k : nat) : nat := 5 * Ws (Pf k) + 6 * w (Pf k) + 2 * Ws k. | ||
| 1409 | Definition Bf (k : nat) : nat := Af k + 5 * V2s (Pf k) + 6 * v2 (Pf k) + 2 ^ (k + 1). | ||
| 1410 | Definition Xf (k : nat) : nat := Af k + 5 * Pf k + 7. | ||
| 1411 | Definition Costf (k : nat) : nat := 2 * Xf k + 2 + 2 * Af k + 11 * Ws (Pf k) + 13 * w (Pf k). | ||
| 1412 | Definition Nlo (k : nat) : nat := 2 ^ (k + 3) - 8 * 2 ^ ((Pf k + 3) / 2). | ||
| 1413 | Definition Nstar : nat := 17705. | ||
| 1415 | Lemma Pf_mono k k' : k <= k' -> Pf k <= Pf k'. | ||
| 1416 | Proof. unfold Pf. lia. Qed. | ||
| 1417 | Lemma Ws_mono P P' : P <= P' -> Ws P <= Ws P'. | ||
| 1418 | Proof. apply vsum_mono_m. Qed. | ||
| 1419 | Lemma V2s_mono P P' : P <= P' -> V2s P <= V2s P'. | ||
| 1420 | Proof. apply vsum_mono_m. Qed. | ||
| 1421 | Lemma Af_mono k k' : k <= k' -> Af k <= Af k'. | ||
| 1422 | Proof. | ||
| 1423 | intros H. unfold Af. pose proof (Pf_mono _ _ H). | ||
| 1424 | pose proof (Ws_mono _ _ H0). pose proof (w_mono _ _ H0). pose proof (Ws_mono _ _ H). lia. | ||
| 1425 | Qed. | ||
| 1427 | Lemma w_SS q : w (S (S q)) = 2 * w q. | ||
| 1428 | Proof. | ||
| 1429 | unfold w. replace (S (S q) + 1) with ((q + 1) + 1 * 2) by lia. rewrite Nat.div_add by lia. | ||
| 1430 | rewrite Nat.pow_add_r. cbn. lia. | ||
| 1431 | Qed. | ||
| 1432 | Lemma v2_SS q : v2 (S (S q)) = 2 * v2 q. | ||
| 1433 | Proof. | ||
| 1434 | unfold v2. replace (S (S q)) with (q + 1 * 2) by lia. rewrite Nat.div_add by lia. | ||
| 1435 | rewrite Nat.pow_add_r. cbn. lia. | ||
| 1436 | Qed. | ||
| 1437 | Lemma vsum_SS_w f m : vsum w (S (S f)) m = 2 * vsum w f m. | ||
| 1438 | Proof. revert f. induction m as [|m IH]; intros f; cbn [vsum]; [lia|]. rewrite w_SS, IH. lia. Qed. | ||
| 1439 | Lemma vsum_SS_v2 f m : vsum v2 (S (S f)) m = 2 * vsum v2 f m. | ||
| 1440 | Proof. revert f. induction m as [|m IH]; intros f; cbn [vsum]; [lia|]. rewrite v2_SS, IH. lia. Qed. | ||
| 1441 | Lemma Ws_SS P : Ws (S (S P)) = 2 * Ws P + 3. | ||
| 1442 | Proof. unfold Ws. cbn [vsum]. rewrite vsum_SS_w. cbn. lia. Qed. | ||
| 1443 | Lemma V2s_SS P : V2s (S (S P)) = 2 * V2s P + 2. | ||
| 1444 | Proof. unfold V2s. cbn [vsum]. rewrite vsum_SS_v2. cbn. lia. Qed. | ||
| 1445 | Lemma Pf_big k : 9 <= k -> Pf k = k + 3. | ||
| 1446 | Proof. unfold Pf. lia. Qed. | ||
| 1447 | Lemma Af_SS k : 9 <= k -> Af (S (S k)) = 2 * Af k + 21. | ||
| 1448 | Proof. | ||
| 1449 | intros H. unfold Af. rewrite !Pf_big by lia. | ||
| 1450 | replace (S (S k) + 3) with (S (S (k + 3))) by lia. rewrite !Ws_SS, w_SS. lia. | ||
| 1451 | Qed. | ||
| 1453 | Definition gB (k : nat) : nat := Af k + 5 * V2s (k + 3) + 6 * v2 (k + 3). | ||
| 1454 | Lemma gB_SS k : 9 <= k -> gB (S (S k)) = 2 * gB k + 31. | ||
| 1455 | Proof. | ||
| 1456 | intros H. unfold gB. rewrite Af_SS by lia. | ||
| 1457 | replace (S (S k) + 3) with (S (S (k + 3))) by lia. rewrite V2s_SS, v2_SS. lia. | ||
| 1458 | Qed. | ||
| 1460 | Lemma gB_all m : gB (10 + 2 * m) + 31 < 7 * 2 ^ (10 + 2 * m) /\ gB (11 + 2 * m) + 31 < 7 * 2 ^ (11 + 2 * m). | ||
| 1461 | Proof. | ||
| 1462 | induction m as [|m [IH1 IH2]]. | ||
| 1463 | - split; apply Nat.ltb_lt; vm_compute; reflexivity. | ||
| 1464 | - replace (10 + 2 * S m) with (S (S (10 + 2 * m))) by lia. | ||
| 1465 | replace (11 + 2 * S m) with (S (S (11 + 2 * m))) by lia. | ||
| 1466 | rewrite !gB_SS by lia. rewrite !(Nat.pow_succ_r' 2 (S _)), !Nat.pow_succ_r'. lia. | ||
| 1467 | Qed. | ||
| 1469 | Lemma gB_ge k : 10 <= k -> gB k + 31 < 7 * 2 ^ k. | ||
| 1470 | Proof. | ||
| 1471 | intros H. destruct (Nat.Even_or_Odd (k - 10)) as [[m Hm] | [m Hm]]. | ||
| 1472 | - replace k with (10 + 2 * m) by lia. exact (proj1 (gB_all m)). | ||
| 1473 | - replace k with (11 + 2 * m) by lia. exact (proj2 (gB_all m)). | ||
| 1474 | Qed. | ||
| 1476 | (* (N1) the Q potential fits below 2^(Pf+1): created positions stay below Pf. *) | ||
| 1477 | Lemma N1 k : 7 * 2 ^ k + Bf k < 2 ^ (Pf k + 1). | ||
| 1478 | Proof. | ||
| 1479 | destruct (le_lt_dec k 11) as [Hk|Hk]. | ||
| 1480 | - assert (H : forallb (fun k => 7 * 2 ^ k + Bf k <? 2 ^ (Pf k + 1)) (seq 0 12) = true) by (vm_compute; reflexivity). | ||
| 1481 | rewrite forallb_forall in H. specialize (H k (proj2 (in_seq 12 0 k) ltac:(lia))). apply Nat.ltb_lt, H. | ||
| 1482 | - pose proof (gB_ge k ltac:(lia)) as G. unfold Bf. fold (gB k) in *. | ||
| 1483 | unfold gB in G. rewrite Pf_big in * by lia. unfold gB in *. | ||
| 1484 | replace (k + 3 + 1) with (k + 4) by lia. rewrite (Nat.pow_add_r 2 k 4), (Nat.pow_add_r 2 k 1). | ||
| 1485 | cbn [Nat.pow]. lia. | ||
| 1486 | Qed. | ||
| 1488 | Lemma Costf_SS k : 9 <= k -> Costf (S (S k)) + 10 * (k + 3) = 2 * Costf k + 121. | ||
| 1489 | Proof. | ||
| 1490 | intros H. unfold Costf, Xf. rewrite Af_SS by lia. rewrite !Pf_big by lia. | ||
| 1491 | replace (S (S k) + 3) with (S (S (k + 3))) by lia. rewrite Ws_SS, w_SS. generalize (Af k) (Ws (k + 3)) (w (k + 3)). intros. lia. | ||
| 1492 | Qed. | ||
| 1494 | Lemma Nlo_SS k : 9 <= k -> Nlo (S (S k)) = 4 * 2 ^ (k + 3) - 16 * 2 ^ ((k + 6) / 2) /\ | ||
| 1495 | Nlo k = 2 ^ (k + 3) - 8 * 2 ^ ((k + 6) / 2). | ||
| 1496 | Proof. | ||
| 1497 | intros H. unfold Nlo. rewrite !Pf_big by lia. split. | ||
| 1498 | - replace ((S (S k) + 3 + 3) / 2) with ((k + 6) / 2 + 1) | ||
| 1499 | by (replace (S (S k) + 3 + 3) with ((k + 6) + 1 * 2) by lia; rewrite Nat.div_add by lia; lia). | ||
| 1500 | replace (S (S k) + 3) with (k + 3 + 2) by lia. | ||
| 1501 | rewrite (Nat.pow_add_r 2 (k + 3) 2), (Nat.pow_add_r 2 ((k + 6) / 2) 1). | ||
| 1502 | generalize (2 ^ (k + 3)) (2 ^ ((k + 6) / 2)). intros. cbn. lia. | ||
| 1503 | - replace (k + 3 + 3) with (k + 6) by lia. reflexivity. | ||
| 1504 | Qed. | ||
| 1506 | Lemma D_all m : Costf (12 + 2 * m) + 123 <= Nlo (12 + 2 * m) /\ Costf (13 + 2 * m) + 123 <= Nlo (13 + 2 * m). | ||
| 1507 | Proof. | ||
| 1508 | induction m as [|m [IH1 IH2]]. | ||
| 1509 | - split; apply Nat.leb_le; vm_compute; reflexivity. | ||
| 1510 | - replace (12 + 2 * S m) with (S (S (12 + 2 * m))) by lia. | ||
| 1511 | replace (13 + 2 * S m) with (S (S (13 + 2 * m))) by lia. | ||
| 1512 | pose proof (Costf_SS (12 + 2 * m) ltac:(lia)). pose proof (Costf_SS (13 + 2 * m) ltac:(lia)). | ||
| 1513 | destruct (Nlo_SS (12 + 2 * m) ltac:(lia)) as [E1 E2]. destruct (Nlo_SS (13 + 2 * m) ltac:(lia)) as [E3 E4]. | ||
| 1514 | rewrite E1, E3. rewrite E2 in IH1. rewrite E4 in IH2. lia. | ||
| 1515 | Qed. | ||
| 1517 | (* (N2) the digestion cost fits in the budget: below N* for kappa <= 11, below Nlo above. *) | ||
| 1518 | Lemma N2 k : Costf k + 2 <= Nstar \/ Costf k + 2 <= Nlo k. | ||
| 1519 | Proof. | ||
| 1520 | destruct (le_lt_dec k 11) as [Hk|Hk]. | ||
| 1521 | - left. assert (H : forallb (fun k => Costf k + 2 <=? Nstar) (seq 0 12) = true) by (vm_compute; reflexivity). | ||
| 1522 | rewrite forallb_forall in H. specialize (H k (proj2 (in_seq 12 0 k) ltac:(lia))). apply Nat.leb_le, H. | ||
| 1523 | - right. destruct (Nat.Even_or_Odd (k - 12)) as [[m Hm] | [m Hm]]. | ||
| 1524 | + replace k with (12 + 2 * m) by lia. pose proof (proj1 (D_all m)). lia. | ||
| 1525 | + replace k with (13 + 2 * m) by lia. pose proof (proj2 (D_all m)). lia. | ||
| 1526 | Qed. | ||
| 1528 | (* ===================================================================== *) | ||
| 1529 | (* Section 11. The orbit invariant, one epoch, the finite part, nonhalt. *) | ||
| 1530 | (* ===================================================================== *) | ||
| 1532 | Lemma Nstar_ge : 15 <= Nstar. | ||
| 1533 | Proof. apply Nat.leb_le. vm_compute. reflexivity. Qed. | ||
| 1535 | Ltac opq t := let x := fresh "o" in set (x := t) in *; clearbody x. | ||
| 1537 | Definition Mw (bs : blks) : nat := wpot w 1 0 0 (exs bs). | ||
| 1538 | Definition M2 (bs : blks) : nat := wpot p2 1 0 0 (exs bs). | ||
| 1540 | (* Inv k N y: epoch K(1,N,y), k bounds the number of blocks seen so far (write-up D.6). *) | ||
| 1541 | Definition Inv (k N : nat) (y : word) : Prop := | ||
| 1542 | Nstar <= N /\ Nlo k <= N /\ | ||
| 1543 | ((exists x bs s, y = p11 x (gw bs s) /\ s <= 3 /\ length bs <= k /\ | ||
| 1544 | Mw bs <= Af k /\ M2 bs <= Bf k /\ x <= Xf k) | ||
| 1545 | \/ y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2)). | ||
| 1547 | Lemma next_inv k N n c bsp sp r : | ||
| 1548 | GPhi (1 + n) (N + c - n) bsp sp r -> sp <= 3 -> n + 2 <= N -> Nstar <= N -> Nlo k <= N -> | ||
| 1549 | MO u1 0 (exs bsp) <= Af k + 5 * Ws (Pf k) + 6 * w (Pf k) -> | ||
| 1550 | MO u2 0 (exs bsp) <= Af k + 5 * V2s (Pf k) + 6 * v2 (Pf k) -> | ||
| 1551 | MO cst1 0 (exs bsp) + 1 <= Xf k -> | ||
| 1552 | 2 * length bsp <= Pf k + 3 -> | ||
| 1553 | exists k', Inv k' (S (rk r)) (ry r). | ||
| 1554 | Proof. | ||
| 1555 | intros HG Hs Hn HN HL H1 H2 H3 H4. | ||
| 1556 | pose proof (GPhi_rk _ _ _ _ _ HG) as Hrk. | ||
| 1557 | pose proof (GPhi_s3 _ _ _ _ _ HG Hs) as Hr. | ||
| 1558 | pose proof (GPhi_rel _ _ _ _ _ HG Hs (exs bsp) (Rel_refl _)) as HR. | ||
| 1559 | pose proof (GPhi_val _ _ _ _ _ HG Hs) as HV. | ||
| 1560 | destruct r as [kk x bs2 s2 | kk y]; cbn [rk ry] in *. | ||
| 1561 | - destruct HR as (h & R1 & R2). | ||
| 1562 | exists (Nat.max k (length bs2)). | ||
| 1563 | assert (Hk : k <= Nat.max k (length bs2)) by lia. | ||
| 1564 | assert (Hk2 : length bs2 <= Nat.max k (length bs2)) by lia. | ||
| 1565 | set (k' := Nat.max k (length bs2)) in *. | ||
| 1566 | split; [lia|]. split. | ||
| 1567 | + destruct (le_lt_dec (length bs2) k) as [Hle|Hgt]. | ||
| 1568 | * replace k' with k by lia. lia. | ||
| 1569 | * replace k' with (length bs2) by lia. | ||
| 1570 | pose proof (gval_lb bs2 s2). pose proof (gval_ub bsp sp Hs). | ||
| 1571 | assert (2 ^ length bsp <= 2 ^ ((Pf (length bs2) + 3) / 2)). | ||
| 1572 | { apply Nat.pow_le_mono_r; [lia|]. pose proof (Pf_mono k (length bs2) ltac:(lia)). | ||
| 1573 | apply Nat.div_le_lower_bound; lia. } | ||
| 1574 | unfold Nlo. rewrite Nat.pow_add_r. | ||
| 1575 | generalize dependent (2 ^ length bs2). generalize dependent (2 ^ length bsp). | ||
| 1576 | generalize dependent (2 ^ ((Pf (length bs2) + 3) / 2)). intros. cbn [Nat.pow] in *. lia. | ||
| 1577 | + left. exists x, bs2, s2. split; [reflexivity|]. split; [exact Hr|]. split; [lia|]. | ||
| 1578 | pose proof (Pf_mono _ _ Hk) as HPf. | ||
| 1579 | split; [|split]. | ||
| 1580 | * unfold Mw. | ||
| 1581 | pose proof (wpot_le_nth w (exs bs2) w_mono _ 0 (Rel_nth _ _ R1)) as A1. rewrite length_exs in A1. | ||
| 1582 | pose proof (wpot_skipn_tl w h (exs bsp) w_mono) as A2. | ||
| 1583 | rewrite MO_u1_0 in H1. | ||
| 1584 | pose proof (Ws_mono _ _ Hk2). pose proof (Ws_mono _ _ Hk). pose proof (Ws_mono _ _ HPf). | ||
| 1585 | pose proof (w_mono _ _ HPf). | ||
| 1586 | unfold Af in *. fold (Ws (length bs2)) in A1. | ||
| 1587 | generalize dependent (wpot w 1 0 0 (exs bs2)). generalize dependent (wpot w 1 0 0 (skipn (S h) (exs bsp))). | ||
| 1588 | generalize dependent (wpot w 1 0 0 (tl (exs bsp))). intros. lia. | ||
| 1589 | * unfold M2. | ||
| 1590 | pose proof (wpot_le_nth p2 (exs bs2) p2_mono _ 0 (Rel_nth _ _ R1)) as A1. rewrite length_exs in A1. | ||
| 1591 | pose proof (wpot_skipn_tl p2 h (exs bsp) p2_mono) as A2. | ||
| 1592 | rewrite MO_u2_0 in H2. | ||
| 1593 | pose proof (vsum_p2 0 (length bs2)) as A3. cbn [Nat.add] in A3. | ||
| 1594 | assert (2 ^ S (length bs2) <= 2 ^ (k' + 1)) by (apply Nat.pow_le_mono_r; lia). | ||
| 1595 | pose proof (Af_mono _ _ Hk). pose proof (V2s_mono _ _ HPf). pose proof (v2_mono _ _ HPf). | ||
| 1596 | unfold Bf. | ||
| 1597 | generalize dependent (wpot p2 1 0 0 (exs bs2)). generalize dependent (wpot p2 1 0 0 (skipn (S h) (exs bsp))). | ||
| 1598 | generalize dependent (wpot p2 1 0 0 (tl (exs bsp))). intros. lia. | ||
| 1599 | * pose proof (nth_le_MO h (exs bsp) 0). | ||
| 1600 | assert (Xf k <= Xf k') by (unfold Xf; pose proof (Af_mono _ _ Hk); lia). lia. | ||
| 1601 | - exists k. split; [lia|]. split; [lia|]. right. exact Hr. | ||
| 1602 | Qed. | ||
| 1604 | Lemma inv_step k N y : Inv k N y -> exists kk y', Phi 1 N y kk y' /\ exists k', Inv k' (S kk) y'. | ||
| 1605 | Proof. | ||
| 1606 | intros (HN & HL & Hy). | ||
| 1607 | pose proof (N2 k) as HC. | ||
| 1608 | destruct Hy as [(x & bs & s & -> & Hs & Hk & HM & HM2 & Hx) | Hsp]. | ||
| 1609 | - set (Ps := Pf k). | ||
| 1610 | set (Q0 := Qp 0 bs s 0 - 3 * 2 ^ length bs). | ||
| 1611 | assert (HQ0 : 4 * 2 ^ length bs <= Qp 0 bs s 0). | ||
| 1612 | { unfold Qp. rewrite Nat.pow_0_r. pose proof (gval_lb bs s). lia. } | ||
| 1613 | assert (HQ : QI Q0 0 bs s 0). | ||
| 1614 | { unfold QI, Q0. cbn [Nat.add]. clear - HQ0. lia. } | ||
| 1615 | assert (HP : Q0 < 2 ^ (Ps + 1)). | ||
| 1616 | { pose proof (N1 k) as N1k. unfold Q0, Qp. rewrite Nat.pow_0_r, Nat.mul_1_l. | ||
| 1617 | pose proof (qsum_p2 (exs bs)) as QP. rewrite length_exs in QP. pose proof (gval_ub bs s Hs). | ||
| 1618 | assert (2 ^ length bs <= 2 ^ k) by (apply Nat.pow_le_mono_r; lia). unfold M2 in HM2. | ||
| 1619 | rewrite Nat.pow_succ_r' in QP. fold Ps in N1k. lia. } | ||
| 1620 | destruct (DigT_exists Q0 (Q0 + 1) 0 bs s Hs HQ ltac:(lia)) as (n0 & c0 & bsp & sp & HT). | ||
| 1621 | pose proof (DP x _ _ _ _ _ _ HT) as HD. | ||
| 1622 | set (n := 2 * x + 2 + n0) in *. set (c := S x + c0) in *. | ||
| 1623 | pose proof (proj1 (Dig_cost Q0 Ps HP) _ _ _ _ _ _ _ HD Hs 0 0 (le_n _) HQ) as Hcost. | ||
| 1624 | rewrite Nat.pow_0_r, !Nat.mul_1_l in Hcost. | ||
| 1625 | pose proof (QI_Ps _ Ps _ _ _ _ HQ HP) as HPs. cbn [Nat.add] in HPs. | ||
| 1626 | assert (HPs' : length (exs bs) <= Ps) by (rewrite length_exs; exact HPs). | ||
| 1627 | pose proof (Pot_top w 2 8 11 Ps (exs bs) ltac:(lia) HPs') as PT. rewrite wpot_scale2 in PT. | ||
| 1628 | assert (Hn : n + 2 <= N). | ||
| 1629 | { unfold Costf in HC. fold Ps in HC. unfold Mw in HM. fold (Ws Ps) in PT. | ||
| 1630 | opq (w Ps). opq (Ws Ps). opq (Pot w 2 8 11 Ps 0 (exs bs)). opq (wpot w 1 0 0 (exs bs)). lia. } | ||
| 1631 | pose proof (proj1 Dig_sp _ _ _ _ _ _ _ HD) as Hsp. | ||
| 1632 | destruct (gcount (Psi bsp sp (N + c - n)) bsp sp (1 + n) (N + c - n) Hsp ltac:(lia) (le_n _)) as (r & HG). | ||
| 1633 | exists (rk r), (ry r). split; [exact (epoch_ord N x bs s n c bsp sp r Hs HD Hn HG)|]. | ||
| 1634 | apply (next_inv k N n c bsp sp r HG Hsp Hn HN HL). | ||
| 1635 | + pose proof (proj1 (Dig_mass u1 w Q0 Ps w_mono u1_mono u1_w HP) _ _ _ _ _ _ _ HD Hs 0 0 (le_n _) HQ) as Hm. | ||
| 1636 | cbn [pu] in Hm. pose proof (Pot_top w 1 3 5 Ps (exs bs) ltac:(lia) HPs') as PT1. | ||
| 1637 | unfold Mw in HM. fold Ps. fold (Ws Ps) in PT1. | ||
| 1638 | opq (w Ps). opq (Ws Ps). opq (Pot w 1 3 5 Ps 0 (exs bs)). opq (wpot w 1 0 0 (exs bs)). opq (MO u1 0 (exs bsp)). lia. | ||
| 1639 | + pose proof (proj1 (Dig_mass u2 v2 Q0 Ps v2_mono u2_mono u2_v2 HP) _ _ _ _ _ _ _ HD Hs 0 0 (le_n _) HQ) as Hm. | ||
| 1640 | cbn [pu] in Hm. pose proof (Pot_top v2 1 3 5 Ps (exs bs) ltac:(lia) HPs') as PT1. | ||
| 1641 | pose proof (wpot_le_v v2 w 1 0 0 (exs bs) v2_le_w). | ||
| 1642 | unfold Mw in HM. fold Ps. fold (V2s Ps) in PT1. | ||
| 1643 | opq (v2 Ps). opq (V2s Ps). opq (Pot v2 1 3 5 Ps 0 (exs bs)). opq (wpot w 1 0 0 (exs bs)). | ||
| 1644 | opq (wpot v2 1 0 0 (exs bs)). opq (MO u2 0 (exs bsp)). lia. | ||
| 1645 | + pose proof (proj1 (Dig_mass cst1 cst1 Q0 Ps cst1_mono cst1_mono ltac:(intros; unfold cst1; lia) HP) | ||
| 1646 | _ _ _ _ _ _ _ HD Hs 0 0 (le_n _) HQ) as Hm. | ||
| 1647 | cbn [pu] in Hm. pose proof (Pot_top cst1 1 3 5 Ps (exs bs) ltac:(lia) HPs') as PT1. | ||
| 1648 | rewrite vsum_cst1 in PT1. pose proof (wpot_le_v cst1 w 1 0 0 (exs bs) cst1_le_w). | ||
| 1649 | unfold Mw in HM. unfold Xf. fold Ps. unfold cst1 at 3 in Hm. | ||
| 1650 | opq (Pot cst1 1 3 5 Ps 0 (exs bs)). opq (wpot w 1 0 0 (exs bs)). opq (wpot cst1 1 0 0 (exs bs)). | ||
| 1651 | opq (MO cst1 0 (exs bsp)). lia. | ||
| 1652 | + pose proof (proj1 (Dig_len Q0 Ps HP) _ _ _ _ _ _ _ HD Hs 0 0 (le_n _) HQ). fold Ps. lia. | ||
| 1653 | - destruct (DigE_ex y Hsp) as (n & c & bsp & sp & HE). | ||
| 1654 | destruct (DigE_props _ _ _ _ _ HE) as (Hn13 & Hc5 & Hb1 & Hs3 & Hz). | ||
| 1655 | assert (Hn : n + 2 <= N) by (pose proof Nstar_ge; lia). | ||
| 1656 | destruct (gcount (Psi bsp sp (N + c - n)) bsp sp (1 + n) (N + c - n) Hs3 ltac:(lia) (le_n _)) as (r & HG). | ||
| 1657 | exists (rk r), (ry r). split; [exact (epoch_spec N y n c bsp sp r HE Hn HG)|]. | ||
| 1658 | apply (next_inv k N n c bsp sp r HG Hs3 Hn HN HL); rewrite ?(MO_zero _ _ _ Hz); unfold Xf, Pf; lia. | ||
| 1659 | Qed. | ||
| 1661 | (* ---------- the finite part: the computable model from K(1,8,t2) to epoch 694 ---------- *) | ||
| 1663 | Fixpoint orbit (f n N : nat) (y : word) : option (nat * word) := | ||
| 1664 | match n with | ||
| 1665 | | O => Some (N, y) | ||
| 1666 | | S n => match phif f 1 N y with Some (k, y') => orbit f n (S k) y' | None => None end | ||
| 1667 | end. | ||
| 1669 | Lemma orbit_sound f n : forall N y N' y', orbit f n N y = Some (N', y') -> K N y -->* K N' y'. | ||
| 1670 | Proof. | ||
| 1671 | induction n as [|n IH]; intros N y N' y' H; cbn [orbit] in H. | ||
| 1672 | - inversion H; subst. apply evstep_refl. | ||
| 1673 | - destruct (phif f 1 N y) as [[k y1]|] eqn:E; [|discriminate]. | ||
| 1674 | eapply evstep_trans; [apply progress_evstep, epoch_tm, (proj2 (model_sound f) _ _ _ _ _ E) | exact (IH _ _ _ _ H)]. | ||
| 1675 | Qed. | ||
| 1677 | Definition B694 : blks := [(false, 17); (true, 1); (true, 1); (true, 1); (true, 1); | ||
| 1678 | (false, 1); (false, 1); (false, 1); (true, 1); (false, 0)]. | ||
| 1679 | Definition Y694 : word := p11 7 (gw B694 0). | ||
| 1681 | Lemma fin694 : orbit 100000 691 8 t2 = Some (17713, Y694). | ||
| 1682 | Proof. vm_compute. reflexivity. Qed. | ||
| 1684 | Lemma inv694 : Inv 10 17713 Y694. | ||
| 1685 | Proof. | ||
| 1686 | unfold Inv. split; [apply Nat.leb_le; vm_compute; reflexivity|]. split; [apply Nat.leb_le; vm_compute; reflexivity|]. | ||
| 1687 | left. exists 7, B694, 0. split; [reflexivity|]. split; [lia|]. split; [cbn; lia|]. | ||
| 1688 | split; [|split]; [apply Nat.leb_le; vm_compute; reflexivity | apply Nat.leb_le; vm_compute; reflexivity |]. | ||
| 1689 | apply Nat.leb_le; vm_compute; reflexivity. | ||
| 1690 | Qed. | ||
| 1692 | Lemma nonhalt_from N0 y0 (P : nat -> word -> Prop) : | ||
| 1693 | c0 -->* K N0 y0 -> P N0 y0 -> | ||
| 1694 | (forall N y, P N y -> exists k y', Phi 1 N y k y' /\ P (S k) y') -> | ||
| 1695 | ~ halts tm c0. | ||
| 1696 | Proof. | ||
| 1697 | intros H0 HP0 Hstep. | ||
| 1698 | eapply multistep_nonhalt. { exact H0. } | ||
| 1699 | apply (progress_nonhalt_cond tm (nat * word) (N0, y0) (fun i => K (fst i) (snd i)) | ||
| 1700 | (fun i => P (fst i) (snd i))); [| exact HP0]. | ||
| 1701 | intros [N y] HP. cbn in HP. | ||
| 1702 | destruct (Hstep N y HP) as (k & y' & HPhi & HP'). | ||
| 1703 | exists (S k, y'). split; [apply epoch_tm, HPhi | exact HP']. | ||
| 1704 | Qed. | ||
| 1706 | Lemma nonhalt: ~halts tm c0. | ||
| 1707 | Proof. | ||
| 1708 | apply (nonhalt_from 17713 Y694 (fun N y => exists k, Inv k N y)). | ||
| 1709 | - eapply evstep_trans; [exact init | exact (orbit_sound _ _ _ _ _ _ fin694)]. | ||
| 1710 | - exists 10. exact inv694. | ||
| 1711 | - intros N y [k Hk]. destruct (inv_step k N y Hk) as (kk & y' & H1 & H2). exists kk, y'. split; [exact H1 | exact H2]. | ||
| 1712 | Qed. | ||
| 1714 | (* | ||
| 1715 | 0 1 | ||
| 1716 | A 1RB 0RF | ||
| 1717 | B 1RC 1RF | ||
| 1718 | C 1LD 0RE | ||
| 1719 | D --- 0LE | ||
| 1720 | E 1LA 0LE | ||
| 1721 | F 0RA 0LC | ||
| 1723 | hub K(a,b,X) = 0^inf (110)^a 0 (011)^b C> X 0^inf | ||
| 1724 | pre-record L'(k,T) = 0^inf E> 0 01 (001)^k T 0^inf (E0 = 1LA, then the restart) | ||
| 1725 | start c0 -->* K(1,8,010001) | ||
| 1726 | *) | ||
3Proof outlineCheck: the new items (green) carry the argument; the names read like the proof.md rules.
219 items in 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v (1726 lines): 158 Lemma, 41 Definition, 12 Fixpoint, 7 Inductive, 1 Theorem. 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.
| # | kind | name | statement (no proof body) | line | vs template |
|---|---|---|---|---|---|
| 1 | Definition | tm | Definition tm := Eval compute in (TM_from_str "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC"). | L33 | new |
| 2 | Lemma | LP0 | Lemma LP0 l r : l <* <[0;1;1] {{C}}> [0] *> r -->+ l <{{A}} [1;0;0;1] *> r. | L47 | new |
| 3 | Lemma | LP0z | Lemma LP0z l : l <* <[0;1;1] {{C}}> 0inf -->+ l <{{A}} [1;0;0;1] *> 0inf. | L50 | new |
| 4 | Lemma | LP11 | Lemma LP11 l r : l <* <[0;1;1] {{C}}> [1;1;0] *> r -->+ l <{{A}} [1;0;1;0;0;0] *> r. | L54 | new |
| 5 | Lemma | LPCr | Lemma LPCr l e r : l <* <[0;1;1] {{C}}> [1;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+
l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <* <[0;1;1] {{C}}> r. | L58 | new |
| 6 | Lemma | LPCl0 | Lemma LPCl0 l e r : l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;0] *> r -->+
l <{{A}} [1;0;0;0;0;1] *> [0;0;1]^^e *> [0;0;0] *> r. | L63 | new |
| 7 | Lemma | LPCl1 | Lemma LPCl1 l e r : l <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;1;0;0;0] *> r -->+
l <{{A}} [1;0;0;0;0;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | L67 | new |
| 8 | Lemma | LP5r | Lemma LP5r l e r : l <* <[0;1;1] {{C}}> [1;0;0;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+
l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <* <[0;1;1] {{C}}> r. | L72 | new |
| 9 | Lemma | LP5l0 | Lemma LP5l0 l e r : l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <{{A}} [1;0;0] *> r -->+
l <{{A}} [1;0;0;0;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | L76 | new |
| 10 | Lemma | LP5l1 | Lemma LP5l1 l e r : l <* <[0;1;1;1;1] <* <[0;1;1]^^(S e) <{{A}} [1;0;1;0;0;0] *> r -->+
l <{{A}} [1;0;0;0;1] *> [0;0;1]^^(S (S e)) *> [0;0;0] *> r. | L80 | new |
| 11 | Lemma | LP6r | Lemma LP6r l e r : l <* <[0;1;1] {{C}}> [1;0;1;0;1] *> [0;0;1]^^e *> [0;0;0] *> r -->+
l <* <[0;1;1;1] <* <[1;1;0] <* [0] <* <[0;1;1]^^(S e) {{C}}> r. | L85 | new |
| 12 | Lemma | W10 | Lemma W10 l r : l <* <[0;1;1;1] <{{E}} r -->+ l <{{A}} [1;0;0;0] *> r. | L90 | new |
| 13 | Lemma | RP0 | Lemma RP0 l n r : l <* [0] <* <[0;1;1]^^(S n) <{{A}} [1;0;0] *> r -->+
l <* <[1;1;0] <* [0] <* <[0;1;1]^^(S n) {{C}}> r. | L94 | new |
| 14 | Lemma | RP1 | Lemma RP1 l n r : l <* [0] <* <[0;1;1]^^(S n) <{{A}} [1;0;1;0;0;0] *> r -->+
l <* <[1;1;0] <* [0] <* <[0;1;1]^^(S (S n)) {{C}}> r. | L98 | new |
| 15 | Lemma | E1r | Lemma E1r l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [0;0;1]^^(S e) *> [0;0;0] *> r -->+
l <* <[1;1;0]^^(S (S a)) <* [0] <* <[0;1;1]^^(S e) {{C}}> r. | L103 | new |
| 16 | Lemma | E2l0 | Lemma E2l0 l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;0] *> r -->+
l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;1] *> [0;0;1]^^e *> [0;0;0] *> r. | L107 | new |
| 17 | Lemma | E2l1 | Lemma E2l1 l a e r : l <* <[1;1;0]^^a <* [0] <* <[0;1;1;1;1;1] <* <[0;1;1]^^e <{{A}} [1;0;1;0;0;0] *> r -->+
l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;1] *> [0;0;1]^^(S e) *> [0;0;0] *> r. | L111 | new |
| 18 | Lemma | Et0 | Lemma Et0 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> 0inf -->+
l <{{E}} [0;1] *> [0;0;1]^^(S a) *> [0;0;0;1] *> 0inf. | L115 | new |
| 19 | Lemma | Et1 | Lemma Et1 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [1] *> 0inf -->+
l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | L119 | new |
| 20 | Lemma | Et2 | Lemma Et2 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [0;1;0;0;0;1] *> 0inf -->+
l <{{E}} [0;1] *> [0;0;1]^^a *> [0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | L123 | new |
| 21 | Lemma | Et3 | Lemma Et3 l a : l <* <[1;1;0]^^a <* [0] <* <[0;1;1] {{C}}> [1;1;0;0;0;1] *> 0inf -->+
l <* <[1;1;0]^^(S a) <* [0] <* <[0;1;1] {{C}}> [0;0;1] *> 0inf. | L127 | new |
| 22 | Lemma | Rst | Lemma Rst k r : const 0 <{{E}} [0;1] *> [0;0;1]^^k *> [0;0;0] *> r -->+
const 0 <* <[1;1;0] <* [0] <* <[0;1;1]^^(S k) {{C}}> r. | L132 | new |
| 23 | Lemma | LPT1 | Lemma LPT1 l : l <* <[0;1;1] {{C}}> [1] *> 0inf -->+ l <{{A}} [1;0;0;0;1;0;0;0;1] *> 0inf. | L137 | new |
| 24 | Lemma | LPT2 | Lemma LPT2 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;0;1] *> 0inf -->+
l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | L140 | new |
| 25 | Lemma | LPT3 | Lemma LPT3 l : l <* <[0;1;1] {{C}}> [1;0;1;1;0;0;0;1] *> 0inf -->+
l <{{A}} [1;0;0] *> [0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | L144 | new |
| 26 | Lemma | LPT4 | Lemma LPT4 l : l <* <[0;1;1] {{C}}> [1;0;0;0;0;1;0;0;0;1] *> 0inf -->+
l <{{A}} [1;0;0] *> [0;1;0;0;0;0;1;0;0;1;0;0;0;1] *> 0inf. | L148 | new |
| 27 | Lemma | LPT5 | Lemma LPT5 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf -->+
l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | L152 | new |
| 28 | Lemma | LPT6 | Lemma LPT6 l : l <* <[0;1;1] {{C}}> [1;0;0;1;0;0;1;0;0;0;1] *> 0inf -->+
l <{{A}} [1;0;0] *> [0;1;0;0;1;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;1] *> 0inf. | L156 | new |
| 29 | Lemma | z3 | Lemma z3 : [0;0;0] *> const 0 = const 0. | L160 | new |
| 30 | Inductive | word | Inductive word : Type := | t0 | t1 | t2 | t3 | blk (d : bool) (e : nat) (w : word) | p11 (x : nat) (w : word) | p01 (x : nat) (w : word) | p00 (w : word) … +1 lines | L169 | new |
| 31 | Definition | dsym | Definition dsym (d : bool) : Sym := if d then S1 else S0. | L177 | new |
| 32 | Fixpoint | enc | Fixpoint enc (w : word) : side := match w with | t0 => const 0 | t1 => [1] *> const 0 | t2 => [0;1;0;0;0;1] *> const 0 | t3 => [1;1;0;0;0;1] *> const 0 … +6 lines | L179 | new |
| 33 | Definition | addb | Definition addb (e : nat) (d : bool) : nat := if d then S e else e. | L192 | new |
| 34 | Inductive | LP | Inductive LP : word -> word -> bool -> Prop := | LP_a e w : LP (blk false e w) (blk true e w) false | LP_b e w w' d : LP w w' d -> LP (blk true e w) (blk false (addb e d) w') false | LP_t0 : LP t0 t1 false | LP_t1 : LP t1 t2 false | LP_t2 : LP t2 t3 false … +22 lines | L197 | new |
| 35 | Definition | outp | Definition outp (d : bool) (r : side) : side := if d then [1;0;1;0;0;0] *> r else [1;0;0] *> r. | L230 | new |
| 36 | Definition | LPspec | Definition LPspec (w w' : word) (d : bool) : Prop :=
forall l, l <* <[0;1;1] {{C}}> enc w -->+ l <{{A}} outp d (enc w'). | L233 | new |
| 37 | Definition | Phispec | Definition Phispec (a b : nat) (w : word) (k : nat) (y : word) : Prop :=
forall l, l <* <[1;1;0]^^a <* [0] <* <[0;1;1]^^b {{C}}> enc w -->+
l <{{E}} [0;1] *> [0;0;1]^^k *> [0;0;0] *> enc y. | L236 | new |
| 38 | Lemma | enc_a0 | Lemma enc_a0 : enc (blk false 0 t0) = [0;0;1] *> const 0. | L240 | new |
| 39 | Theorem | sound | Theorem sound : (forall w w' d, LP w w' d -> LPspec w w' d) /\ (forall a b w k y, Phi a b w k y -> Phispec a b w k y). | L247 | new |
| 40 | Definition | K | Definition K (N : nat) (y : word) : Q * tape :=
const 0 <* <[1;1;0] <* [0] <* <[0;1;1]^^N {{C}}> enc y. | L315 | new |
| 41 | Lemma | epoch_tm | Lemma epoch_tm N y k y' : Phi 1 N y k y' -> K N y -->+ K (S k) y'. | L318 | new |
| 42 | Lemma | init | Lemma init : c0 -->* K 8 t2. | L326 | new |
| 43 | Fixpoint | lpf | Fixpoint lpf (n : nat) (w : word) {struct n} : option (word * bool) :=
match n with
| O => None
| S n' =>
match w with
| t0 => Some (t1, false)
… +58 lines | L333 | new |
| 44 | Lemma | enc_p10t0 | Lemma enc_p10t0 : enc (p10 t0) = enc t1. | L398 | new |
| 45 | Lemma | enc_p10t1 | Lemma enc_p10t1 : enc (p10 t1) = enc (blk true 0 t0). | L401 | new |
| 46 | Lemma | enc_p00t0 | Lemma enc_p00t0 : enc (p00 t0) = enc t0. | L404 | new |
| 47 | Lemma | enc_p00t1 | Lemma enc_p00t1 : enc (p00 t1) = enc (blk false 0 t0). | L407 | new |
| 48 | Lemma | enc_p10p00t0 | Lemma enc_p10p00t0 : enc (p10 (p00 t0)) = enc t1. | L410 | new |
| 49 | Lemma | enc_p10p00t1 | Lemma enc_p10p00t1 : enc (p10 (p00 t1)) = enc (p10 (blk false 0 t0)). | L413 | new |
| 50 | Lemma | model_sound | Lemma model_sound n : (forall w w' d, lpf n w = Some (w', d) -> LP w w' d) /\ (forall a b w k y, phif n a b w = Some (k, y) -> Phi a b w k y). | L416 | new |
| 51 | Definition | tl_of | Definition tl_of (s : nat) : word := match s with O => t0 | 1 => t1 | 2 => t2 | _ => t3 end. | L466 | new |
| 52 | Fixpoint | gw | Fixpoint gw (bs : list (bool * nat)) (s : nat) : word := match bs with [] => tl_of s | (d, e) :: bs => blk d e (gw bs s) end. | L469 | new |
| 53 | Fixpoint | ginc | Fixpoint ginc (bs : list (bool * nat)) (s : nat) : list (bool * nat) * nat * bool :=
match bs with
| [] => match s with O => ([], 1, false) | 1 => ([], 2, false) | 2 => ([], 3, false)
| _ => ([(false, 0)], O, true) end
| (false, e) :: bs => ((true, e) :: bs, s, false)
| (true, e) :: bs => let '(bs', s', d) := ginc bs s in ((false, addb e d) :: bs', s', false)
… +1 lines | L472 | new |
| 54 | Fixpoint | gval | Fixpoint gval (bs : list (bool * nat)) (s : nat) : nat := match bs with [] => 4 + s | (d, _) :: bs => (if d then 1 else 0) + 2 * gval bs s end. | L480 | new |
| 55 | Fixpoint | gsum | Fixpoint gsum (bs : list (bool * nat)) : nat := match bs with [] => O | (_, e) :: bs => e + gsum bs end. | L483 | new |
| 56 | Lemma | ginc_LP | Lemma ginc_LP bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> LP (gw bs s) (gw bs' s') d. | L486 | new |
| 57 | Lemma | ginc_val | Lemma ginc_val bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> gval bs' s' = S (gval bs s) /\ s' <= 3 /\ gsum bs' + length bs + (if d then 1 else 0) = gsum bs + length bs' /\ (d = true -> bs = []) /\ length bs <= length bs'. | L494 | new |
| 58 | Lemma | gval_ge | Lemma gval_ge bs s : 4 <= gval bs s. | L507 | new |
| 59 | Lemma | gval_len | Lemma gval_len bs s : length bs <= gval bs s. | L510 | new |
| 60 | Definition | Psi | Definition Psi (bs : list (bool * nat)) (s b : nat) : nat := gval bs s + b + gsum bs - length bs. | L516 | new |
| 61 | Definition | blks | Definition blks := list (bool * nat). | L524 | new |
| 62 | Definition | b2n | Definition b2n (d : bool) : nat := if d then 1 else 0. | L525 | new |
| 63 | Lemma | addb_b2n | Lemma addb_b2n e d : addb e d = e + b2n d. | L526 | new |
| 64 | Inductive | GRes | Inductive GRes : Type := RE2 (k x : nat) (bs : blks) (s : nat) | RSp (k : nat) (y : word). | L529 | new |
| 65 | Definition | rk | Definition rk (r : GRes) : nat := match r with RE2 k _ _ _ => k | RSp k _ => k end. | L530 | new |
| 66 | Definition | ry | Definition ry (r : GRes) : word := match r with RE2 _ x bs s => p11 x (gw bs s) | RSp _ y => y end. | L531 | new |
| 67 | Inductive | GPhi | Inductive GPhi : nat -> nat -> blks -> nat -> GRes -> Prop :=
| GB a b bs s bs' s' d r : ginc bs s = (bs', s', d) -> GPhi (S a) (addb (S b) d) bs' s' r ->
GPhi a (S (S b)) bs s r
| GE1 a e bs s r : GPhi (S (S a)) (S e) bs s r -> GPhi a 1 ((false, e) :: bs) s r
| GE2 a e bs s bs' s' d : ginc bs s = (bs', s', d) ->
GPhi a 1 ((true, e) :: bs) s (RE2 a (addb e d) bs' s')
… +4 lines | L534 | new |
| 68 | Lemma | ginc_s3 | Lemma ginc_s3 bs s bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> s' <= 3. | L545 | new |
| 69 | Lemma | GPhi_sound | Lemma GPhi_sound a b bs s r : GPhi a b bs s r -> s <= 3 -> Phi a b (gw bs s) (rk r) (ry r). | L548 | new |
| 70 | Lemma | GPhi_s3 | Lemma GPhi_s3 a b bs s r : GPhi a b bs s r -> s <= 3 -> match r with RE2 _ _ _ s2 => s2 <= 3 | RSp _ y => y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2) end. | L560 | new |
| 71 | Lemma | GPhi_rk | Lemma GPhi_rk a b bs s r : GPhi a b bs s r -> a + b <= S (rk r). | L567 | new |
| 72 | Lemma | gcount | Lemma gcount : forall P bs s a b, s <= 3 -> 1 <= b -> Psi bs s b <= P -> exists r, GPhi a b bs s r. | L570 | new |
| 73 | Inductive | LPs | Inductive LPs : word -> word -> nat -> nat -> Prop := | LPs_eq w w' : enc w = enc w' -> LPs w w' 0 0 | LPs_step w w1 w2 d n c : LP w w1 d -> LPs w1 w2 n c -> LPs w w2 (S n) (c + b2n d). | L603 | new |
| 74 | Lemma | LPs_step' | Lemma LPs_step' w w1 w2 d n c c' : LP w w1 d -> LPs w1 w2 n c -> c' = c + b2n d -> LPs w w2 (S n) c'. | L607 | new |
| 75 | Lemma | LPs_eql | Lemma LPs_eql w0 w1 w2 n c : enc w0 = enc w1 -> LPs w1 w2 n c -> LPs w0 w2 n c. | L610 | new |
| 76 | Lemma | LPs_trans | Lemma LPs_trans w1 w2 w3 n c n' c' : LPs w1 w2 n c -> LPs w2 w3 n' c' -> LPs w1 w3 (n + n') (c + c'). | L617 | new |
| 77 | Lemma | LPs_cn | Lemma LPs_cn w w' n c : LPs w w' n c -> c <= n. | L624 | new |
| 78 | Lemma | LPs_hub | Lemma LPs_hub w w' n c : LPs w w' n c -> forall a B k y, n + 2 <= B + c -> Phi (a + n) (B + c - n) w' k y -> Phi a B w k y. | L627 | new |
| 79 | Lemma | LPs_nest | Lemma LPs_nest y y' n c : LPs y y' n c -> forall k, LPs (blk false k y) (blk false (k + c) y') (2 * n) 0. | L641 | new |
| 80 | Inductive | DigE | Inductive DigE : word -> nat -> nat -> blks -> nat -> Prop := | DE0 : DigE (p10 t0) 0 0 [] 1 | DE1 : DigE (p10 t1) 0 0 [(true, 0)] 0 | DE2 : DigE (p10 t2) 13 5 [(false, 0)] 2 | DE3 : DigE (p10 t3) 7 2 [(false, 0)] 2 | DEs0 : DigE t1 0 0 [] 1 … +2 lines | L651 | new |
| 81 | Lemma | DigE_sound | Lemma DigE_sound y n c bs s : DigE y n c bs s -> LPs y (gw bs s) n c. | L663 | new |
| 82 | Lemma | DigE_props | Lemma DigE_props y n c bs s : DigE y n c bs s -> n <= 13 /\ c <= 5 /\ length bs <= 1 /\ s <= 3 /\ Forall (fun e => e = 0) (map snd bs). | L666 | new |
| 83 | Inductive | DigP | Inductive DigP : nat -> blks -> nat -> nat -> nat -> blks -> nat -> Prop :=
| DP x bs s n c bsp sp : DigT bs s n c bsp sp -> DigP x bs s (2 * x + 2 + n) (S x + c) bsp sp
with DigT : blks -> nat -> nat -> nat -> blks -> nat -> Prop :=
| DTa e bs s bs' s' d n c bsp sp : ginc bs s = (bs', s', d) ->
DigP (S (addb e d)) bs' s' n c bsp sp -> DigT ((false, e) :: bs) s (S (S n)) c bsp sp
| DTb e bs s k x bs2 s2 n c bsp sp : GPhi 1 (S e) bs s (RE2 k x bs2 s2) ->
… +4 lines | L673 | new |
| 84 | Lemma | prefix_LPs | Lemma prefix_LPs x w : LPs (p11 x w) (p10 w) (2 * x + 2) (S x). | L688 | new |
| 85 | Lemma | Dig_sound | Lemma Dig_sound : (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> LPs (p11 x (gw bs s)) (gw bsp sp) n c) /\ (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> LPs (p10 (gw bs s)) (gw bsp sp) n c). | L696 | new |
| 86 | Lemma | Dig_sp | Lemma Dig_sp : (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> sp <= 3) /\ (forall bs s n c bsp sp, DigT bs s n c bsp sp -> sp <= 3). | L716 | new |
| 87 | Lemma | epoch_ord | Lemma epoch_ord N x bs s n c bsp sp r : s <= 3 -> DigP x bs s n c bsp sp -> n + 2 <= N -> GPhi (1 + n) (N + c - n) bsp sp r -> Phi 1 N (p11 x (gw bs s)) (rk r) (ry r). | L724 | new |
| 88 | Lemma | epoch_spec | Lemma epoch_spec N y n c bsp sp r : DigE y n c bsp sp -> n + 2 <= N -> GPhi (1 + n) (N + c - n) bsp sp r -> Phi 1 N y (rk r) (ry r). | L732 | new |
| 89 | Definition | exs | Definition exs (bs : blks) : list nat := map snd bs. | L744 | new |
| 90 | Fixpoint | bumpl | Fixpoint bumpl (l : list nat) : list nat := match l with [] => [] | e :: l' => match l' with [] => [S e] | _ => e :: bumpl l' end end. | L746 | new |
| 91 | Lemma | length_bumpl | Lemma length_bumpl l : length (bumpl l) = length l. | L749 | new |
| 92 | Lemma | length_exs | Lemma length_exs bs : length (exs bs) = length bs. | L752 | new |
| 93 | Lemma | ginc_exps | Lemma ginc_exps bs s : s <= 3 -> forall bs' s' d, ginc bs s = (bs', s', d) -> (exs bs' = exs bs /\ d = false) \/ (exs bs' = bumpl (exs bs) ++ [0] /\ d = match bs with [] => true | _ => false end). | L756 | new |
| 94 | Fixpoint | qsum | Fixpoint qsum (l : list nat) : nat := match l with [] => 0 | e :: l => S e + 2 * qsum l end. | L771 | new |
| 95 | Definition | Qp | Definition Qp (f : nat) (bs : blks) (s p : nat) : nat := 2 ^ f * (gval bs s + 2 * qsum (exs bs) + p). | L772 | new |
| 96 | Definition | QI | Definition QI (Q0 f : nat) (bs : blks) (s p : nat) : Prop := Qp f bs s p <= Q0 + 3 * 2 ^ (f + length bs). | L773 | new |
| 97 | Lemma | qsum_app0 | Lemma qsum_app0 l : qsum (l ++ [0]) = qsum l + 2 ^ length l. | L775 | new |
| 98 | Lemma | qsum_bumpl | Lemma qsum_bumpl l : l <> [] -> 2 * qsum (bumpl l) = 2 * qsum l + 2 ^ length l. | L778 | new |
| 99 | Lemma | gval_lb | Lemma gval_lb bs s : 4 * 2 ^ length bs <= gval bs s. | L786 | new |
| 100 | Lemma | gval_ub | Lemma gval_ub bs s : s <= 3 -> gval bs s < 8 * 2 ^ length bs. | L789 | new |
| 101 | Lemma | QI_low | Lemma QI_low Q0 f bs s p : QI Q0 f bs s p -> 2 ^ (f + length bs) <= Q0. | L792 | new |
| 102 | Lemma | QI_Ps | Lemma QI_Ps Q0 Ps f bs s p : QI Q0 f bs s p -> Q0 < 2 ^ (Ps + 1) -> f + length bs <= Ps. | L799 | new |
| 103 | Lemma | QI_drop | Lemma QI_drop Q0 f bs s p : QI Q0 f bs s p -> QI Q0 f bs s 0. | L805 | new |
| 104 | Lemma | QI_cons | Lemma QI_cons Q0 f dd e bs s p : QI Q0 f ((dd, e) :: bs) s 0 -> p <= S e -> QI Q0 (S f) bs s p. | L808 | new |
| 105 | Lemma | QI_inc | Lemma QI_inc Q0 f bs s p bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> QI Q0 f bs s (S p) -> QI Q0 f bs' s' (p + b2n d). | L821 | new |
| 106 | Lemma | QI_et3 | Lemma QI_et3 Q0 f : QI Q0 f [] 3 0 -> QI Q0 f [(false, 0)] 0 0. | L848 | new |
| 107 | Fixpoint | wpot | Fixpoint wpot (v : nat -> nat) (al be f : nat) (l : list nat) : nat := match l with [] => 0 | e :: l => v f * (al * e + be) + wpot v al be (S f) l end. | L853 | new |
| 108 | Fixpoint | vsum | Fixpoint vsum (v : nat -> nat) (f m : nat) : nat := match m with 0 => 0 | S m => v f + vsum v (S f) m end. | L856 | new |
| 109 | Definition | Pot | Definition Pot (v : nat -> nat) (al be ga Ps f : nat) (l : list nat) : nat := wpot v al be f l + ga * vsum v (f + length l) (Ps - (f + length l)). | L859 | new |
| 110 | Definition | mono | Definition mono (v : nat -> nat) : Prop := forall i j, i <= j -> v i <= v j. | L862 | new |
| 111 | Lemma | Pot_cons | Lemma Pot_cons v al be ga Ps f e l : Pot v al be ga Ps f (e :: l) = v f * (al * e + be) + Pot v al be ga Ps (S f) l. | L864 | new |
| 112 | Lemma | wpot_app1 | Lemma wpot_app1 v al be f l x : wpot v al be f (l ++ [x]) = wpot v al be f l + v (f + length l) * (al * x + be). | L868 | new |
| 113 | Lemma | wpot_bumpl | Lemma wpot_bumpl v al be f l : mono v -> wpot v al be f (bumpl l) <= wpot v al be f l + al * v (f + length l). | L875 | new |
| 114 | Lemma | Pot_ov | Lemma Pot_ov v al be ga Ps f l : mono v -> al + be + 1 <= ga -> f + length l + 1 <= Ps -> Pot v al be ga Ps f (bumpl l ++ [0]) + v (f + length l) <= Pot v al be ga Ps f l. | L885 | new |
| 115 | Lemma | Pot_inc | Lemma Pot_inc v al be ga Ps Q0 f bs s p bs' s' d : mono v -> al + be + 1 <= ga -> Q0 < 2 ^ (Ps + 1) -> s <= 3 -> ginc bs s = (bs', s', d) -> QI Q0 f bs s (S p) -> Pot v al be ga Ps f (exs bs') + b2n d * v f <= Pot v al be ga Ps f (exs bs). | L897 | new |
| 116 | Lemma | GPhi_pot | Lemma GPhi_pot v al be ga Ps Q0 : mono v -> al + be + 1 <= ga -> 1 <= al -> 2 <= be -> Q0 < 2 ^ (Ps + 1) ->
forall a b bs s r, GPhi a b bs s r -> s <= 3 -> forall f U, QI Q0 f bs s (b - 1) ->
(forall q, f <= q -> U <= v q) ->
match r with
| RE2 k x bs2 s2 => exists h, QI Q0 (f + S h) bs2 s2 0 /\
U * k + Pot v al be ga Ps (f + S h) (exs bs2) + v (f + h) * (al * x + be) <=
… +3 lines | L912 | new |
| 117 | Definition | w | Definition w (q : nat) : nat := 2 ^ ((q + 1) / 2). | L981 | new |
| 118 | Lemma | w_mono | Lemma w_mono : mono w. | L983 | new |
| 119 | Lemma | w_lev | Lemma w_lev l q : 2 * l <= q -> 2 ^ l <= w q. | L986 | new |
| 120 | Lemma | w_lev1 | Lemma w_lev1 l q : 2 * l + 1 <= q -> 2 ^ S l <= w q. | L993 | new |
| 121 | Lemma | GPhi_QI | Lemma GPhi_QI Q0 Ps a b bs s k x bs2 s2 f : Q0 < 2 ^ (Ps + 1) -> GPhi a b bs s (RE2 k x bs2 s2) -> s <= 3 -> QI Q0 f bs s (b - 1) -> exists h, QI Q0 (f + S h) bs2 s2 0. | L1000 | new |
| 122 | Lemma | Dig_cost | Lemma Dig_cost Q0 Ps : Q0 < 2 ^ (Ps + 1) -> (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> 2 ^ l * n <= Pot w 2 8 11 Ps f (exs bs) + 2 ^ l * (2 * x + 2) + 13 * w Ps) /\ (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> 2 ^ l * n <= Pot w 2 8 11 Ps f (exs bs) + 13 * w Ps). | L1009 | new |
| 123 | Fixpoint | MO | Fixpoint MO (u : nat -> nat) (l : nat) (es : list nat) : nat := match es with [] => 0 | e :: es => u l * e + MO u (S l) es end. | L1061 | new |
| 124 | Definition | pu | Definition pu (u : nat -> nat) (l : nat) : nat := match l with 0 => 0 | S l' => u l' end. | L1064 | new |
| 125 | Lemma | pu_le | Lemma pu_le u l : mono u -> pu u l <= u l. | L1066 | new |
| 126 | Lemma | MO_zero | Lemma MO_zero u l es : Forall (fun e => e = 0) es -> MO u l es = 0. | L1069 | new |
| 127 | Lemma | Dig_mass | Lemma Dig_mass u v Q0 Ps : mono v -> mono u -> (forall l q, 2 * l <= q -> u l <= v q) -> Q0 < 2 ^ (Ps + 1) -> (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> pu u l * c + MO u l (exs bsp) <= Pot v 1 3 5 Ps f (exs bs) + pu u l * S x + 6 * v Ps) /\ (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> pu u l * c + MO u l (exs bsp) <= Pot v 1 3 5 Ps f (exs bs) + 6 * v Ps). | L1073 | new |
| 128 | Lemma | Dig_len | Lemma Dig_len Q0 Ps : Q0 < 2 ^ (Ps + 1) -> (forall x bs s n c bsp sp, DigP x bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> 2 * (l + length bsp) <= Ps + 3) /\ (forall bs s n c bsp sp, DigT bs s n c bsp sp -> s <= 3 -> forall l f, 2 * l <= f -> QI Q0 f bs s 0 -> 2 * (l + length bsp) <= Ps + 3). | L1128 | new |
| 129 | Lemma | pow_gt_self | Lemma pow_gt_self n : n < 2 ^ (n + 1). | L1153 | new |
| 130 | Lemma | DigE_ex | Lemma DigE_ex y : y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2) -> exists n c bsp sp, DigE y n c bsp sp. | L1156 | new |
| 131 | Lemma | DigT_exists | Lemma DigT_exists Q0 : forall D f bs s, s <= 3 -> QI Q0 f bs s 0 -> Q0 + 1 - 2 ^ f <= D -> exists n c bsp sp, DigT bs s n c bsp sp. | L1160 | new |
| 132 | Definition | Rel | Definition Rel (orig cur : list nat) : Prop := (forall i, S i < length cur -> nth i cur 0 <= nth i orig 0 + 1) /\ (forall i, length cur <= S i -> nth i cur 0 <= nth i orig 0). | L1194 | new |
| 133 | Lemma | nth_bumpl | Lemma nth_bumpl l i : nth i (bumpl l) 0 = nth i l 0 + (if Nat.eqb (S i) (length l) then 1 else 0). | L1198 | new |
| 134 | Lemma | nth_app0 | Lemma nth_app0 l i : nth i (l ++ [0]) 0 = nth i l 0. | L1207 | new |
| 135 | Lemma | Rel_ov | Lemma Rel_ov orig l : Rel orig l -> Rel orig (bumpl l ++ [0]). | L1210 | new |
| 136 | Lemma | Rel_inc | Lemma Rel_inc orig bs s bs' s' d : s <= 3 -> ginc bs s = (bs', s', d) -> Rel orig (exs bs) -> Rel orig (exs bs'). | L1220 | new |
| 137 | Lemma | Rel_tl | Lemma Rel_tl orig cur : Rel orig cur -> Rel (tl orig) (tl cur). | L1226 | new |
| 138 | Lemma | Rel_refl | Lemma Rel_refl l : Rel l l. | L1236 | new |
| 139 | Lemma | GPhi_rel | Lemma GPhi_rel a b bs s r : GPhi a b bs s r -> s <= 3 -> forall orig, Rel orig (exs bs) -> match r with | RE2 k x bs2 s2 => exists h, Rel (skipn (S h) orig) (exs bs2) /\ x <= nth h orig 0 + 1 | RSp _ _ => True end. | L1239 | new |
| 140 | Lemma | GPhi_val | Lemma GPhi_val a b bs s r : GPhi a b bs s r -> s <= 3 -> match r with RE2 k x bs2 s2 => 2 * gval bs2 s2 + a <= gval bs s + k + 2 | RSp _ _ => True end. | L1265 | new |
| 141 | Definition | v2 | Definition v2 (q : nat) : nat := 2 ^ (q / 2). | L1280 | new |
| 142 | Definition | p2 | Definition p2 (q : nat) : nat := 2 ^ S q. | L1281 | new |
| 143 | Definition | cst1 | Definition cst1 (q : nat) : nat := 1. | L1282 | new |
| 144 | Definition | u1 | Definition u1 (l : nat) : nat := match l with 0 => 0 | S l' => 2 * w l' end. | L1283 | new |
| 145 | Definition | u2 | Definition u2 (l : nat) : nat := match l with 0 => 0 | S l' => 2 ^ S l' end. | L1284 | new |
| 146 | Lemma | v2_mono | Lemma v2_mono : mono v2. | L1286 | new |
| 147 | Lemma | p2_mono | Lemma p2_mono : mono p2. | L1288 | new |
| 148 | Lemma | cst1_mono | Lemma cst1_mono : mono cst1. | L1290 | new |
| 149 | Lemma | v2_le_w | Lemma v2_le_w q : v2 q <= w q. | L1292 | new |
| 150 | Lemma | cst1_le_w | Lemma cst1_le_w q : cst1 q <= w q. | L1294 | new |
| 151 | Lemma | u1_mono | Lemma u1_mono : mono u1. | L1297 | new |
| 152 | Lemma | u1_w | Lemma u1_w l q : 2 * l <= q -> u1 l <= w q. | L1299 | new |
| 153 | Lemma | u2_mono | Lemma u2_mono : mono u2. | L1310 | new |
| 154 | Lemma | u2_v2 | Lemma u2_v2 l q : 2 * l <= q -> u2 l <= v2 q. | L1312 | new |
| 155 | Lemma | MO_u1 | Lemma MO_u1 l es : MO u1 (S l) es = 2 * wpot w 1 0 l es. | L1319 | new |
| 156 | Lemma | MO_u1_0 | Lemma MO_u1_0 es : MO u1 0 es = 2 * wpot w 1 0 0 (tl es). | L1321 | new |
| 157 | Lemma | MO_u2 | Lemma MO_u2 l es : MO u2 (S l) es = wpot p2 1 0 l es. | L1323 | new |
| 158 | Lemma | MO_u2_0 | Lemma MO_u2_0 es : MO u2 0 es = wpot p2 1 0 0 (tl es). | L1325 | new |
| 159 | Lemma | nth_le_MO | Lemma nth_le_MO h es : forall l, nth h es 0 <= MO cst1 l es. | L1327 | new |
| 160 | Lemma | wpot_shift | Lemma wpot_shift v al be f f' l : mono v -> f <= f' -> wpot v al be f l <= wpot v al be f' l. | L1333 | new |
| 161 | Lemma | wpot_drop | Lemma wpot_drop v al be f h l : wpot v al be (f + h) (skipn h l) <= wpot v al be f l. | L1339 | new |
| 162 | Lemma | wpot_skipn_tl | Lemma wpot_skipn_tl v h l : mono v -> wpot v 1 0 0 (skipn (S h) l) <= wpot v 1 0 0 (tl l). | L1345 | new |
| 163 | Lemma | wpot_le_nth | Lemma wpot_le_nth v l1 : mono v -> forall l2 f, (forall i, nth i l1 0 <= nth i l2 0 + 1) -> wpot v 1 0 f l1 <= wpot v 1 0 f l2 + vsum v f (length l1). | L1351 | new |
| 164 | Lemma | Rel_nth | Lemma Rel_nth orig cur : Rel orig cur -> forall i, nth i cur 0 <= nth i orig 0 + 1. | L1362 | new |
| 165 | Lemma | wpot_split | Lemma wpot_split v al be f l : wpot v al be f l = wpot v al 0 f l + be * vsum v f (length l). | L1364 | new |
| 166 | Lemma | wpot_scale2 | Lemma wpot_scale2 v f l : wpot v 2 0 f l = 2 * wpot v 1 0 f l. | L1366 | new |
| 167 | Lemma | wpot_le_v | Lemma wpot_le_v v v' al be f l : (forall q, v q <= v' q) -> wpot v al be f l <= wpot v' al be f l. | L1368 | new |
| 168 | Lemma | vsum_add | Lemma vsum_add v f m m' : vsum v f (m + m') = vsum v f m + vsum v (f + m) m'. | L1373 | new |
| 169 | Lemma | vsum_mono_m | Lemma vsum_mono_m v f m m' : m <= m' -> vsum v f m <= vsum v f m'. | L1375 | new |
| 170 | Lemma | vsum_cst1 | Lemma vsum_cst1 f m : vsum cst1 f m = m. | L1377 | new |
| 171 | Lemma | vsum_p2 | Lemma vsum_p2 f m : vsum p2 f m + 2 ^ S f = 2 ^ S (f + m). | L1379 | new |
| 172 | Lemma | wpot_p2_S | Lemma wpot_p2_S f l : wpot p2 1 0 (S f) l = 2 * wpot p2 1 0 f l. | L1384 | new |
| 173 | Lemma | qsum_p2 | Lemma qsum_p2 l : 2 * qsum l + 2 = 2 ^ S (length l) + wpot p2 1 0 0 l. | L1386 | new |
| 174 | Lemma | wpot_zero | Lemma wpot_zero v f l : Forall (fun e => e = 0) l -> wpot v 1 0 f l = 0. | L1391 | new |
| 175 | Lemma | Pot_top | Lemma Pot_top v al be ga Ps l : be <= ga -> length l <= Ps -> Pot v al be ga Ps 0 l <= wpot v al 0 0 l + ga * vsum v 0 Ps. | L1393 | new |
| 176 | Definition | Ws | Definition Ws (P : nat) : nat := vsum w 0 P. | L1405 | new |
| 177 | Definition | V2s | Definition V2s (P : nat) : nat := vsum v2 0 P. | L1406 | new |
| 178 | Definition | Pf | Definition Pf (k : nat) : nat := Nat.max 12 (k + 3). | L1407 | new |
| 179 | Definition | Af | Definition Af (k : nat) : nat := 5 * Ws (Pf k) + 6 * w (Pf k) + 2 * Ws k. | L1408 | new |
| 180 | Definition | Bf | Definition Bf (k : nat) : nat := Af k + 5 * V2s (Pf k) + 6 * v2 (Pf k) + 2 ^ (k + 1). | L1409 | new |
| 181 | Definition | Xf | Definition Xf (k : nat) : nat := Af k + 5 * Pf k + 7. | L1410 | new |
| 182 | Definition | Costf | Definition Costf (k : nat) : nat := 2 * Xf k + 2 + 2 * Af k + 11 * Ws (Pf k) + 13 * w (Pf k). | L1411 | new |
| 183 | Definition | Nlo | Definition Nlo (k : nat) : nat := 2 ^ (k + 3) - 8 * 2 ^ ((Pf k + 3) / 2). | L1412 | new |
| 184 | Definition | Nstar | Definition Nstar : nat := 17705. | L1413 | new |
| 185 | Lemma | Pf_mono | Lemma Pf_mono k k' : k <= k' -> Pf k <= Pf k'. | L1415 | new |
| 186 | Lemma | Ws_mono | Lemma Ws_mono P P' : P <= P' -> Ws P <= Ws P'. | L1417 | new |
| 187 | Lemma | V2s_mono | Lemma V2s_mono P P' : P <= P' -> V2s P <= V2s P'. | L1419 | new |
| 188 | Lemma | Af_mono | Lemma Af_mono k k' : k <= k' -> Af k <= Af k'. | L1421 | new |
| 189 | Lemma | w_SS | Lemma w_SS q : w (S (S q)) = 2 * w q. | L1427 | new |
| 190 | Lemma | v2_SS | Lemma v2_SS q : v2 (S (S q)) = 2 * v2 q. | L1432 | new |
| 191 | Lemma | vsum_SS_w | Lemma vsum_SS_w f m : vsum w (S (S f)) m = 2 * vsum w f m. | L1437 | new |
| 192 | Lemma | vsum_SS_v2 | Lemma vsum_SS_v2 f m : vsum v2 (S (S f)) m = 2 * vsum v2 f m. | L1439 | new |
| 193 | Lemma | Ws_SS | Lemma Ws_SS P : Ws (S (S P)) = 2 * Ws P + 3. | L1441 | new |
| 194 | Lemma | V2s_SS | Lemma V2s_SS P : V2s (S (S P)) = 2 * V2s P + 2. | L1443 | new |
| 195 | Lemma | Pf_big | Lemma Pf_big k : 9 <= k -> Pf k = k + 3. | L1445 | new |
| 196 | Lemma | Af_SS | Lemma Af_SS k : 9 <= k -> Af (S (S k)) = 2 * Af k + 21. | L1447 | new |
| 197 | Definition | gB | Definition gB (k : nat) : nat := Af k + 5 * V2s (k + 3) + 6 * v2 (k + 3). | L1453 | new |
| 198 | Lemma | gB_SS | Lemma gB_SS k : 9 <= k -> gB (S (S k)) = 2 * gB k + 31. | L1454 | new |
| 199 | Lemma | gB_all | Lemma gB_all m : gB (10 + 2 * m) + 31 < 7 * 2 ^ (10 + 2 * m) /\ gB (11 + 2 * m) + 31 < 7 * 2 ^ (11 + 2 * m). | L1460 | new |
| 200 | Lemma | gB_ge | Lemma gB_ge k : 10 <= k -> gB k + 31 < 7 * 2 ^ k. | L1469 | new |
| 201 | Lemma | N1 | Lemma N1 k : 7 * 2 ^ k + Bf k < 2 ^ (Pf k + 1). | L1477 | new |
| 202 | Lemma | Costf_SS | Lemma Costf_SS k : 9 <= k -> Costf (S (S k)) + 10 * (k + 3) = 2 * Costf k + 121. | L1488 | new |
| 203 | Lemma | Nlo_SS | Lemma Nlo_SS k : 9 <= k -> Nlo (S (S k)) = 4 * 2 ^ (k + 3) - 16 * 2 ^ ((k + 6) / 2) /\ Nlo k = 2 ^ (k + 3) - 8 * 2 ^ ((k + 6) / 2). | L1494 | new |
| 204 | Lemma | D_all | Lemma D_all m : Costf (12 + 2 * m) + 123 <= Nlo (12 + 2 * m) /\ Costf (13 + 2 * m) + 123 <= Nlo (13 + 2 * m). | L1506 | new |
| 205 | Lemma | N2 | Lemma N2 k : Costf k + 2 <= Nstar \/ Costf k + 2 <= Nlo k. | L1518 | new |
| 206 | Lemma | Nstar_ge | Lemma Nstar_ge : 15 <= Nstar. | L1532 | new |
| 207 | Definition | Mw | Definition Mw (bs : blks) : nat := wpot w 1 0 0 (exs bs). | L1537 | new |
| 208 | Definition | M2 | Definition M2 (bs : blks) : nat := wpot p2 1 0 0 (exs bs). | L1538 | new |
| 209 | Definition | Inv | Definition Inv (k N : nat) (y : word) : Prop :=
Nstar <= N /\ Nlo k <= N /\
((exists x bs s, y = p11 x (gw bs s) /\ s <= 3 /\ length bs <= k /\
Mw bs <= Af k /\ M2 bs <= Bf k /\ x <= Xf k)
\/ y = t1 \/ y = p01 1 t1 \/ y = p10 (p00 t2)). | L1541 | new |
| 210 | Lemma | next_inv | Lemma next_inv k N n c bsp sp r : GPhi (1 + n) (N + c - n) bsp sp r -> sp <= 3 -> n + 2 <= N -> Nstar <= N -> Nlo k <= N -> MO u1 0 (exs bsp) <= Af k + 5 * Ws (Pf k) + 6 * w (Pf k) -> MO u2 0 (exs bsp) <= Af k + 5 * V2s (Pf k) + 6 * v2 (Pf k) -> MO cst1 0 (exs bsp) + 1 <= Xf k -> 2 * length bsp <= Pf k + 3 -> … +1 lines | L1547 | new |
| 211 | Lemma | inv_step | Lemma inv_step k N y : Inv k N y -> exists kk y', Phi 1 N y kk y' /\ exists k', Inv k' (S kk) y'. | L1604 | new |
| 212 | Fixpoint | orbit | Fixpoint orbit (f n N : nat) (y : word) : option (nat * word) := match n with | O => Some (N, y) | S n => match phif f 1 N y with Some (k, y') => orbit f n (S k) y' | None => None end end. | L1663 | new |
| 213 | Lemma | orbit_sound | Lemma orbit_sound f n : forall N y N' y', orbit f n N y = Some (N', y') -> K N y -->* K N' y'. | L1669 | new |
| 214 | Definition | B694 | Definition B694 : blks := [(false, 17); (true, 1); (true, 1); (true, 1); (true, 1); (false, 1); (false, 1); (false, 1); (true, 1); (false, 0)]. | L1677 | new |
| 215 | Definition | Y694 | Definition Y694 : word := p11 7 (gw B694 0). | L1679 | new |
| 216 | Lemma | fin694 | Lemma fin694 : orbit 100000 691 8 t2 = Some (17713, Y694). | L1681 | new |
| 217 | Lemma | inv694 | Lemma inv694 : Inv 10 17713 Y694. | L1684 | new |
| 218 | Lemma | nonhalt_from | Lemma nonhalt_from N0 y0 (P : nat -> word -> Prop) : c0 -->* K N0 y0 -> P N0 y0 -> (forall N y, P N y -> exists k y', Phi 1 N y k y' /\ P (S k) y') -> ~ halts tm c0. | L1692 | new |
| 219 | Lemma | nonhalt | Lemma nonhalt: ~halts tm c0. | L1706 | adapted |
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 · informal proof (submitted copy)
- submission/README.md · the package README
- submission/discord.md · Discord draft (not posted)
- proof.md (working copy) · differs from the submitted copy
3.1 Window rules (finite runs; each is one es)
In each rule, every executed transition reads a cell inside the shown window. So each rule holds in every context.
| # | statement | steps |
|---|---|---|
| W1 | 1 F> 1 → 1 1 F> |
5 |
| W2 | F> 001 → 011 F> |
3 |
| W3 | F> 000 → 011 C> |
3 |
| W4 | C> 101 → 111 F> |
9 |
| W5 | 011 E> 0 → E> 0 010 |
5 |
| W6 | 0 E> 0 → 1 1 F> (marker turn) |
3 |
| W7 | F> 01 → 00 F> |
2 |
| W8 | 011 <A 100 → E> 001 000 |
4 |
| W9 | 011 <A 101 → E> 001 001 |
4 |
| W10 | 011 E> 1 → <A 100 0 (D6 exit) |
4 |
| W11 | C> 10 → 11 F> |
4 |
3.2 Shift rules (induction on n, one IH use each)
| # | statement | steps | proof |
|---|---|---|---|
| S1 (SL) | (011)^n E> 0 → E> 0 (010)^n |
5n | ind n: [W5, IH] |
| S2 (SR) | F> (001)^n → (011)^n F> |
3n | ind n: [W2, IH] |
| S3 | 1 F> 1^n → 1^(n+1) F> |
5n | ind n: [W1, IH] |
3.3 Region pass (any left context l)
| # | statement | domain | steps | proof |
|---|---|---|---|---|
| RP0 | l 0 (011)^n <A 100 X → l 110 0 (011)^n C> X |
n ≥ 1, any l, X | 8n+4 | W8, S1(n−1), W6, W7, S2(n−1), W3 |
| RP1 | l 0 (011)^n <A 101 000 X → l 110 0 (011)^(n+1) C> X |
n ≥ 1 | 8n+7 | W9, S1(n−1), W6, W7, S2(n), W3 |
The region pass reads nothing to the left of the marker. That is why a bounce works in any left context (used in D6).
3.4 Local pass LP
Definition. LP(X) is the run from 011 C> X 0^inf until the head first enters the cell left of that 011, which is cell x0-4. LP never reads cell x0-4 or anything to its left. Every rule below ends in one of two exit forms:
- d = 0:
<A 100 X'; - d = 1:
<A 101 000 X'.
We write LP(X) = (X', d).
| # | statement | domain | steps | proof |
|---|---|---|---|---|
| LP0 | 011 C> 0 r → <A 100 1 r |
any r (incl. X = '') | 4 | C0, D1, E1, E0 |
| LP11 | 011 C> 110 r → <A 101 000 r |
any r | 8 | C1, E1, E0, A1, F1, C0, D1, E0 |
| LPC (carry) | 011 C> 101 a^e z R → <A 100 001 a^(e+d_R) z R' with (R', d_R) = LP(R) |
e ≥ 0, R with an LP rule (R = '' allowed) | s(R)+8e+20 | right (3e+12): W4, S2(e), W3; then LP(R), whose exit reads the last cell of (011)^e or of 111; left (5e+8): for e ≥ 1, W8 or W9, S1(e−1), then 9 fixed steps through 111 and the old 011; for e = 0, 8 fixed steps |
| LP5 (D5) | 011 C> 10 001 a^e z R → <A 100 01 001 a^(e+d) z inc R |
R ∈ G (R = '' allowed) | by execution | right: 4 + W1-type step + S2; LP(R) = GI; left as in LPC |
| LP6 (D6) | 011 C> 10 101 a^e z R → <A 100 a^(k+1) z Y, where Φ(1, e+1, R) = L'(k, 000 Y) |
R ∈ G (R = '' allowed) | (3e+14) + sub-epoch + 4 | section 3.8 |
| LPT | six constant words, by execution (steps in brackets): 1 → 010001 [18]; 10010001 → 01001000010010001 [70]; 10110001 → 0001000010001 [44]; 1000010001 → 01000010010001 [40]; 1001000010001 → 010010001000010001 [62]; 10010010001 → 010010010001000010001 [100] (all d = 0) |
— | 18–100 | es |
GI (inc on G) is a corollary. Write inc W for the LP result on a G word. It is a binary +1, LSB first:
- An a-block toggles to a b-block (LP0).
- A b-block carries (LPC): it becomes an a-block, and the rest is incremented.
- Tails step
'' → 1 → 010001 → 110001(LP0, LPT, LP0). 110001 → 001with d = 1 (LP11). This is an overflow: a new block, and the absorbed001goes into the block in front of it (LPC withd_R = 1), or into the hub when the word is a bare tail.
G is closed under inc. For a word with at least one block, inc returns d = 0. Positions are stable: inc changes digits, and on an overflow it adds +1 to the last block and appends a new last block with e = 0. It never changes any other exponent.
Other names used below:
- HT (toggle), D2 (
'01' V → '11' V), D4 ('00' V → '10' V) and the tail steps are LP0. - D1 (
'11' a V → '01' V, d = 1), D3 ('11' z V → '00' V, d = 1) and'11' → ''are LP11. - HC (carry into a nested word) is LPC with any rest that has an LP rule.
- D5 is LP5, D6 is LP6, and T is LPT.
End words E is the closure of the LPT outputs and of 010010001 under LP until G (23 words, computed by direct enumeration). Its largest own-level cost until G is τ = 13* bounces.
3.5 Bounce
B. K(a, b+1, X) → K(a+1, b+d, X') for b ≥ 1, a ≥ 0 and LP(X) = (X', d). Steps: s_LP(X) + 8b + 4 (d = 0) or + 8b + 7 (d = 1).
- Proof: LP(X), then RP0 or RP1 with
n = b. - The run never reads left of the marker, so B also holds with any
lin place of0^inf (110)^a.
3.6 Eats (b = 1; the LP exit then meets the marker, A reads 0)
| # | statement | context fact |
|---|---|---|
| E1g | K(a, 1, a^(e+1) z R) → K(a+2, e+1, R), R ∈ G |
never reads left of the marker |
| E2g | K(a, 1, 101 a^e z R) →* L'(a, 000 11 a^(e+d') z R'), (R', d') = inc R, R ∈ G |
the sweep 110 → 010 through (110)^a reaches cell first−1 only at the last step |
| E0 | K(a, 1, '') →* L'(a+1, 0001) |
same |
| Et1 | K(a, 1, 1) →* L'(a, 000 01 a z 1) |
same |
| Et2 | K(a, 1, 010001) →* L'(a, 000 10 00 010001) |
same |
| Et3 | K(a, 1, 110001) → K(a+1, 1, 001), then E1g gives K(a+3, 1, ''), then E0 |
never reads left of the marker |
These cover every G word at b = 1. A G word is '', a tail, an a-block first, or a b-block first. Here first is the first cell of (110)^a. L'(k,T) → L(k,T) takes one step (E0 = 1LA on a blank).
3.7 Restart
R. L(k, 000 Y) → K(1, k+1, Y) in 3k + 7 steps, for any Y. The run never moves left of the A cell.
3.8 D6, the nested bounce
Epoch map. For N ≥ 1 and a word R, Φ(a, N, R) is the deterministic sequence:
- B while b ≥ 2;
- the eats of 3.6 at b = 1;
- it stops at the first pre-record
L'(k, T).
Φ is defined when every eat it meets is at a G word. Inside D6 this holds: R ∈ G and G is closed under inc and under E1g.
Φ terminates for every R ∈ G (D.0, Lemma P): only E1g moves the front, finitely many positions are ever created, and between two eats the budget falls by 1 per bounce except for at most one bare-tail absorption. So Φ reaches E2g, E0, Et1, Et2 or the Et3 chain after finitely many steps, and LP6 below is a total rule. The same argument shows that the counting phase of every epoch (after its digestion) ends.
LP6 proof. Write x0 for the first cell of X.
- Right pass (
3e + 14steps). It goes W11 (C> 10 → 11 F>), then W1, then F0 and A1, then S2(e), then W3: - from011 C> 10 101 a^e z R- to011 1 · 110 0 (011)^(e+1) C> R.
The part after · is the hub K(1, e+1, R) whose 0^inf has been replaced by … 011 1. Its first cell is x0+1, so first−1 = x0 holds a 1.
2. Sub-epoch. By 3.5 and 3.6, every bounce and every E1g of Φ(1, e+1, R) reads only cells at or right of its marker. Its final eat (E2g, E0, Et1, Et2, or the Et3 chain) reaches cell first−1 for the first time in state E, exactly when the standalone run reaches L'(k, T). So, cell for cell, the run in context equals the standalone run up to that moment, except that cell first−1 holds 1 instead of 0.
3. Exit (W10, 4 steps). 011 E> 1 01 (001)^k T → <A 100 0 01 (001)^k T = <A 100 a^(k+1) T. Every pre-record has T = 000 Y, so X' = a^(k+1) z Y and d = 0.
The sub-residue Y is one of:
'11' a^x z W'withW' ∈ G(from E2g);'1'(from E0 and from the Et3 chain);'01' a z 1(from Et1);'10 00 010001'(from Et2).
All of these are in O ∪ G.
5FamilyCheck: related machines are killed together or have a reason to be left open.
6 machines, 3 killed, 3 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.
| who | machine | status | relation to this kill |
|---|---|---|---|
| #30 kill 15 | 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC | ✓Killed: never halts | this kill |
| #7 kill 16 | 1RB0RA_1LC0LD_1LE1LD_0LB0RE_1RF0LA_---0RA | ✓Killed: never halts | parent link; = #30's table mirrored, run from state E; named in #30's notes.md; named in #7's .v header; named in #7's proof.md; named in #7's notes.md · review · same machine as this kill? (same table mirrored, started in #30's E; different orbit; tables, pictures and numbers side by side) · mechanism |
| #31 kill 17 | 1RB1RF_1LC0RD_---0LD_1LE0LD_1RA0RF_0RE0LB | ✓Killed: never halts | parent link; = #30's table, run from state B; named in #30's notes.md; named in #31's .v header; named in #31's proof.md; named in #31's notes.md · review · same machine as this kill? (same table, started in #30's B; different orbit; tables, pictures and numbers side by side) · mechanism |
| #10 | 1RB0RF_1RC1RF_1LD1RA_---0LE_1LA0LE_0RA0LC | ⚠Cryptid candidate | targeting: follow-on to #10; named in #30's notes.md · mechanism |
| #15 | 1RB1RF_1LC1RE_---0LD_1LE0LD_1RA0RF_0RE0LB | ⚠Cryptid candidate | via #31: targeting: follow-on to #15 · mechanism |
| #28 | 1RB0RA_1LC0LD_1LE1LD_0LB0RE_1RF1LB_---0RA | ⚠Cryptid candidate | via #7: targeting: follow-on to #7 · mechanism |
6ChecklistCheck: every ✓ is computed; the two ○ are yours to decide; an amber ! is an optional check that did not finish.
- ✓Machine string exactthe .v literal == holdout list line 748 byte for byte
- ✓Statement is
~halts tm c0parsed from the .v and confirmed by check_kill (theorem_text, theorem_rocq) - ✓No axioms beyond baseline0 assumption(s); tools/assumptions_baseline.txt allows only functional_extensionality_dep
- ✓coqchk finished (optional)coqchk pass in 67.68 s
- ✓.v hash matches the checked hash.v = checked sha256 93a493f55311…; submission/ copy = checked sha256 93a493f55311…
- ✓No repo-local paths in the .vcomments name no path of ours (vendor/, machines/, tools/, rocq/, scripts/, reports/, atlas/, data/, journal/, /home/); busycoq's own
verify/X.vis fine: none in the .v or the submission/ copy - ✓Public write-up is cleantools/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 L241: ## Checkpoint B, skeptic round 1 (2026-10-10)
- notes.md L267: - proof.md: a public write-up built by `rocq/submission_src/build.py` (`python3 -B rocq/submission_src/build.py proof.md rocq/submission_src submission/proof.md`; header + working §0-§7 with 17 one-match asserted scrubs
- notes.md L277: - No Checkpoint A or B notes from Dennis were on file when this was packaged. If he adds any, fold them into proof.md and the submission copy first.
- proof.md L259: - A deep trigger with a large exponent in front of a short all-ones suffix can push c to about `log2(excess)`. This is the effect of the Checkpoint B examples, which reach c = 2 to 6 inside the old invariant.
- proof.md L518: - **Adversarial residues (Checkpoint B round 1):** 1,504 per seed, plus 2 × 12,004 in a stand-alone stress run (`check_proof.py --adv N`, seeds 11 and 12; `data/check_proof_adv_seed{11,12}.txt`). Two thirds come from ins
- proof.md L538: - Confidence: high for sections 3–4 and for the mechanism; **medium-high** for Lemma D as written (one open link, and the D.3/D.4 bookkeeping deserves a careful second read at Checkpoint B).
- ○Family posted together?2 other kill(s) in the family: #7, #31; the Discord draft names 0 of them; 3 member(s) not killed: #10, #15, #28
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_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC
Files
machines/<tm>/: 21 entries · raw notes, status, scripts, images
| name | size | changed |
|---|---|---|
| notes.md ↓ | 32 KB | 2026-10-11 00:36 |
| proof.md ↓ | 43 KB | 2026-10-10 16:50 |
| how_proved.md ↓ | 1.6 KB | 2026-10-14 10:51 |
| status.json ↓ | 575 B | 2026-10-16 10:28 |
| observe.json ↓ | 15 KB | 2026-10-10 15:19 |
| deepen.json ↓ | 5.9 KB | 2026-10-10 15:19 |
| 1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC.v ↓ | 86 KB | 2026-10-10 18:17 |
| data/ | 32 items | 2026-10-10 16:50 |
| decisions/ | 2 items | 2026-10-10 15:19 |
| img/ | 9 items | 2026-10-10 15:04 |
| rocq/ | 8 items | 2026-10-10 18:41 |
| scripts/ | 20 items | 2026-10-10 15:18 |
| submission/ | 6 items | 2026-10-15 15:49 |
| work/ | 1 item | 2026-10-10 18:43 |
| check_proof.py ↓ | 43 KB | 2026-10-10 16:50 |
| compress_track.txt ↓ | 2.4 KB | 2026-10-10 13:03 |
| data_val_rules_1.json ↓ | 359 B | 2026-10-10 13:11 |
| data_val_rules_2.json ↓ | 359 B | 2026-10-10 13:11 |
| qsim.err ↓ | 0 B | 2026-10-10 13:03 |
| qsim.jsonl ↓ | 5.7 KB | 2026-10-10 13:03 |
| sim_1e9.jsonl ↓ | 149 B | 2026-10-10 12:55 |
status.json in full
{
"tm": "1RB0RF_1RC1RF_1LD0RE_---0LE_1LA0LE_0RA0LC",
"status": "KILLED_NONHALT",
"stage": "done",
"updated": "2026-10-10",
"reason": "check_kill PASS, independently re-verified",
"pr": "https://github.com/ccz181078/busycoq/pull/25",
"pr_state": "merged",
"pr_file": "verify/M_1RB0RF_1RC1RF_1LD0RE_HHH0LE_1LA0LE_0RA0LC.v",
"pr_opened": "2026-10-15T22:46:50Z",
"pr_comments": 0,
"pr_head_sha": "b5060df30aabdde3b1eacd4a2cfa932557b0b53d",
"posted": "2026-10-15 (Discord; user confirmed sent)",
"pr_merged_at": "2026-10-16T07:08:02Z",
"pr_merged_by": "ccz181078"
}3 contract warnings
- diagrams: 7 (want 3-5)
- diagrams[5].window: not "cells A..B, 1 px = k cells"
- diagrams[6].window: not "cells A..B, 1 px = k cells"






