--- issue: 30 status: done --- # Even parity by an explicit linear-time machine For S-9, `Problems/PVersusNP/Examples/Parity.lean` proves `Millennium.Examples.Parity.evenTrueCount_in_P`: `InPolynomialTime (fin_encoding_string Bool) evenTrueCount`, where `evenTrueCount inp` is `inp.count true % 2 = 0`. There is no composition hypothesis or other unproved hypothesis. This is an elementary example in the fixed model, and says nothing about which answer to P vs NP holds. ## What changed and why The explicit two-stack machine keeps an even-parity flag and whether its last pop found an input symbol. It consumes one Boolean per step, toggles its flag exactly on `true`, then writes that flag, resets its state and halts. `run` proves an `EvalsToInTime` bound of `inp.length + 1`, for any initial flag and existing output stack. `parityAfter_eq` relates the flag invariant to the recursive answer; `evenParity_eq_true_iff` relates that answer to the count predicate. `parityDecider` packages the run with polynomial `X + 1`. The model is the constant-false machine in the fixed `Sanity.lean`; neither fixed file, the checker, dependencies, nor build configuration was edited. The existing `Problems.+` glob includes the new module. ## What happened The first push (`715fa0d`) claimed #30 before implementation. No Lean or Lake was installed locally, and none was installed for this work. The default Python challenge attempt failed before inspection because it lacked tomllib; the already installed Python 3.12 runs it successfully. The first Lean build, [job 1484](https://shoal.club/shoal/p-vs-np/jobs/1484), failed on Boolean-negation precedence and decider elaboration. Parenthesizing the Boolean argument fixed the first. Direct `simpa` still failed at `11e1faa`; temporary diagnostic commits `becf2af` and `42cd9a5` exposed the remaining mismatch (the former also misplaced a declaration option). The final proof rewrites the output of a separately named run before weakening its time bound. This removes the final decider elaboration error. Diagnostic options were removed. All failures remain in branch history. ## Verification and reproduction The proof-bearing commit is [`4c9d27d9df2a5fbe5c21f90ab5ec90166c2a410c`](https://shoal.club/shoal/p-vs-np/commit/4c9d27d9df2a5fbe5c21f90ab5ec90166c2a410c). [Challenge job 1492](https://shoal.club/shoal/p-vs-np/jobs/1492) passed on it, checking 4 Lean files / 2,436 lines. [Build job 1493](https://shoal.club/shoal/p-vs-np/jobs/1493) passed on this same commit, explicitly compiling `Problems.PVersusNP.Examples.Parity` and reporting `ok: lake build passes with no sorry`. Its `#print axioms` reports `[propext, Classical.choice, Quot.sound]` for `evenTrueCount_in_P`. These checks judged the new module, not merely the claim commit. See [RERUN.md](RERUN.md) for the dated build record. On a machine with the pinned Lean and Mathlib, run `lake build Problems Tests`. For the file-only challenge here: ```sh /Users/wang-thumac/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3.12 checks/challenge.py . ``` Documentation-only commits after the proof-bearing commit carry its check verdicts; they do not rerun Lean. No Comparator configuration judges P vs NP in this project, and this example makes no claim about its answer. ## Next The maintainer should review the new example and decide whether to merge [PR #80](https://shoal.club/shoal/p-vs-np/pull/80) for #30. The source contribution is complete and the site's two gating checks pass on the proof-bearing commit.