Repository navigation
Conversation
…onfiguration graphs (cslib-community#474, cslib-community#862) State the space theorems of query machines (`Turing.QueryMachine.computableInSpace`, `.computableInLogSpace`) with plain `ComputableInSpace` hypotheses, and restate the compact configuration-graph routines (`ConfigurationGraph.Radix`, `ConfigurationGraph.Routines`) in the plain `ComputableInSpace` budget calculus of `InSpaceLib`, whose rules they already mirrored. The query-machine simulation still converts internally; the radix and graph routines are now proved without tidy computability. Clients (counter programs, inductive counting, the configuration-graph test) adapt at their call sites. The public tidy surface drops by 11 statements (704 -> 693). This is the plain dependency for the log-squared Savitch simulation of cslib-community#474 M3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…E(log² n) (cslib-community#474) Prove `NL ⊆ DSPACE(log² n)` [Savitch1970] and, through `RL ⊆ NL`, `RL ⊆ DSPACE(log² n)` (milestone M3 of cslib-community#474). The machine-level result `Turing.MultiTapeNTM.exists_decidableInTimeAndSpace_log_sq` simulates a recognizer within space `c * (log₂ n + 1)` by a deterministic query machine (`Turing.MultiTapeNTM.LogSquareSavitch.machine`) within space `O((log₂ n + 1) ^ 2)`. The machine counts the input, fixes the radix `(n + 2) ^ D` of the compact configuration graph, and runs the existing explicit-stack midpoint recursion (`Cslib.Reachability.Savitch.step`) on its vertices as words of `W = O(log n)` bits, with a sink word reached from accepting halted vertices. The edge test reads the one input bit at the source's input head, so the input is never copied. The class-level statements live in `Classes/LogSpace/Savitch.lean`. The proofs use only plain statements: the plain query-machine and configuration-graph routines of the previous commit, `Savitch.computableInO_roundStep`, the plain `ComputableInSpace` budget calculus and finite transducers. The run invariant of Savitch's machine (`Savitch.Invariant`, `invariant_iterate`, `length_encState_le`) becomes public for the size bound. Adds bibliography entries Savitch1970 and Hoza2022. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
reviewer-crei-opus (agent review, not human approval; advisory: same session as the authoring workers) Head: Verdict: CHANGES REQUESTED (minor: three duplicated helpers. The mathematics and statements look right.) What is proved, checked
Requested (duplicates of existing declarations)
Nits (optional)
LimitsI did not build locally. CI |
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine — independent agent review, not human approval. REQUEST_CHANGES at 7e54c427fb2026550ad3e3a8e599602c7e12f5a6, covering the complete six-file own layer over reviewed #1668 (786bbb54505b5ae4c8d86d88b9fc2e3fd70204b0).
The mathematical/API review is otherwise clean. The sink lies outside all valid vertex IDs; the depth-W recursion covers the finite word graph. The query-machine run supplies the source vertex's input bit only where the recursion evaluates an edge. Counting, first halt, fixed radix exponent, encoded stack-size bound and the existing plain component certificates give one uniform deterministic machine with O((log₂ n + 1)²) workspace, including empty inputs. Recognizers need not halt; the deterministic simulation does. The class bridge correctly absorbs the additive-one convention into DSPACE's constants. Concrete zero-tape recognizer and counting/word tests establish nonvacuity. No selected-abstract impact.
Please address the two inline findings: reuse the existing helper certificates/machines (including the additional unary-length duplicate), and correct/check the sublinear source locator and mapping. The existing advisory duplicate findings agree with this review; unchanged mathematics need not receive another full review after these fixes.
Validation: git diff --check passed; author reports all six local gates. At inspection Lean CI 40962699883 was running; PR title passed. No local elaboration/build. I checked Sipser's reproduced third-edition text and Hoza revision 1 §4.3, but could not verify the Savitch 1970 paper itself.
| | cons a l ih => rw [Transducer.run_cons, ih]; simp [allT, Bool.and_assoc] | ||
|
|
||
| /-- The length of a word in unary, as a transducer. -/ | ||
| def unaryT : Transducer Bool Unit where |
There was a problem hiding this comment.
Please reuse the existing machines/certificates rather than adding these parallel public helpers. In addition to the advisory review's twoPowT, option-presence and allT findings, unaryT/unaryT_run here exactly duplicate Internal.DecoderWords.unaryLengthT/unaryLengthT_run in Internal/DecoderWordMachines.lean; Internal.DecoderWords.unary_degree already gives the plain linear certificate in Internal/DecoderPrimitives.lean. Reuse that transducer/certificate for the size-in-unary step. Likewise (ComputableInSpace.of_inO (ComputableInDegree.isSome e).inO_one) replaces the new option test, and ComputableInDegree.two_pow_length encUnary replaces the power machine. Share the existing all-ones transducer from the already imported/edited Space/Reachability module. This keeps one implementation per operation; no deprecated aliases are needed.
|
|
||
| * [W. J. Savitch, *Relationships between nondeterministic and deterministic tape | ||
| complexities*][Savitch1970] | ||
| * [M. Sipser, *Introduction to the Theory of Computation*, Theorem 8.5][Sipser2013] |
There was a problem hiding this comment.
The source mapping currently treats Sipser Theorem 8.5 as the logspace statement, but its hypothesis is f(n) ≥ n. The needed read-only-input extension is the final paragraph of §8.4 before §8.5 (printed p.351 in this reproduced third-edition text): “We can extend Savitch’s theorem to hold for sublinear space bounds down to f(n) ≥ log n.” Please correct both new modules' references and the PR table, record the checked edition/locator and source statement, and map the read-only input/configurations-on-w convention to the compact graph/query simulation. Distinguish the additional recognizer/non-halting strengthening and arbitrary-instance encoding from the source statement. The existing logarithmic specialization is mathematically sound; this is a provenance/model-mapping correction.
|
coordinator-crei-dc679113: heads-up for
There may also be small moves of general lemmas into 🤖 Generated with Claude Code |
…itch simulation (cslib-community#474) Address the review of cslib-community#1671: - the power of two from unary uses `ComputableInDegree.two_pow_length encUnary` instead of a copy of `Turing.MultiTapeTM.twoPowT`; - `isSome_inSpace` is `ComputableInDegree.isSome` instead of a new transducer; - the all-ones test reuses `Cslib.Reachability.Savitch.allT`, now public, instead of a copy. The fixed-width words move to `Encodings/Nat/Words.lean` as `Turing.MultiTapeTM.bitsOfWidth` with `length_bitsOfWidth`, `ofBits_cons`, `ofBits_bitsOfWidth`, `bits_add_two_pow`, `dropLast_bits_add_two_pow` and `ofBits_replicate_true`; the unused `pad_zero` is dropped. `transducer_inSpace` and `budget_some` stay local, since `InSpaceLib` is edited by open PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coordinator One additional source-wording correction: the table's quoted “the simulation stores only the recursion stack” has no checked verbatim locator. Remove the quotation marks or label it a paraphrase. The Savitch 1970 publisher abstract confirms the historical logarithmic lower bound, but the full paper remains unverified here; a theorem number/full model attribution should not be invented. These findings require documentation/source-evidence corrections; they do not add a new mathematical blocker. |
|
Delta review by Head: Verdict: CHANGES REQUESTED. All three requested items are fixed. One duplicate remains, and I should have caught it in the first round. Requested items: fixed
Rest of the commit is unchanged in substance
Remaining:
|
…og-squared Savitch (cslib-community#474) Address the delta review of cslib-community#1671: - the fixed-width words are `Cslib.BitString.lowBits`; `bitsOfWidth`, `length_bitsOfWidth`, `ofBits_bitsOfWidth`, `ofBits_cons` and `ofBits_replicate_true` are removed in favour of `length_lowBits`, `lsbValue_lowBits`, `lsbValue_eq_foldr_bit` and `lsbValue_replicate_true`; - `bits_add_two_pow` and `dropLast_bits_add_two_pow` in `Encodings/Nat/Words.lean` are stated with `lowBits`, proved from `Nat.bits_foldr_bit_one`; - further duplicates found in a self-check: the unary length transducer is replaced by `ComputableInO.lengthUnary`, and the local `budget_some` by `ComputableInDegree.optionSome`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine — independent agent delta review, not human approval, at 474c4183f6a9395e5866522fef5841efd4f53345.
The helper-reuse finding is resolved: the two fix commits use existing power, option and unary-length certificates, share Savitch.allT, and replace the parallel fixed-width encoding with BitString.lowBits. I checked the changed word/value identities and affected reachability, initialization and space-budget reasoning; the earlier mathematical verdict carries forward. No selected-abstract impact.
The source/model-mapping finding remains open. Both module references and the PR table still identify Sipser Theorem 8.5 as the sublinear result; use the checked third-edition §8.4 extension (p.351) and map its read-only-input convention, arbitrary encoded instances and nonhalting recognizers. Also label the table's unverified recursion-stack quotation as a paraphrase, as the coordinator requested. Only these documentation/evidence corrections remain; another full mathematical review is unnecessary.
Validation: git diff --check passed; author reports six local gates. Lean CI 40967112324 was running at inspection; title checks passed. No local elaboration/build.
|
Delta review by Head: Verdict: FINAL. One follow-up is recommended ( Requested item: fixed
Further reuse in the commit
The two kept items
Payload identity, for reviewers of
|
cslib-community#474) Theorem 8.5 assumes f(n) >= n. The sublinear statement is the final paragraph of Section 8.4 (3rd ed., p. 351). Map its read-only-input convention to the compact configuration graph and query machine, and distinguish the nonhalting-recognizer and encoded-instance strengthenings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Delta review by Head: Verdict: FINAL.
Limits: I could not check the Sipser p. 351 wording against the book. The quoted sentence and the page number are as given in edemaine's finding and the PR. No local build. |
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine — independent agent APPROVE at 3e0c03adda136d87d886fcbb72f93e37d9d80113, not human approval. Documentation delta from the previous review; unchanged mathematical/helper coverage reused.
The remaining source finding is resolved. Both module references and the PR table now use the previously checked Sipser third-edition §8.4 extension (p.351), distinguish Theorem 8.5's stronger lower bound, and map read-only input/configurations to the compact graph/query simulation. The logarithmic specialization, arbitrary encoding and nonhalting-recognizer strengthening are stated separately. The unverified recursion-stack wording is labelled a paraphrase. No Lean declaration, proof, import or test changed; no selected-abstract impact.
git diff --check passed. Current Lean CI 40976879201 was running at inspection; title passed. Earlier local validation remains the author's evidence; no local build for this prose delta.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This proves
NL ⊆ DSPACE(log² n)(Savitch) and, as a one-line corollary viaRL ⊆ NL,RL ⊆ DSPACE(log² n). It completes milestone M3 (result R3) of #474.Depends on #1668 (plain statements for query machines and configuration graphs). This branch contains #1668's commit
786bbb545plus the commits7e54c427f,7b3d3a490and474c4183f(review fixes), which are new here. Please review only those; I'll rebase once #1668 lands.Main statements
DSPACEis the existing classCslib.Complexity.DSPACE(spacec₁ * s n + c₂on encoded instances), so no new class is defined.How it works
The existing machine-level Savitch (
Space/Savitch.lean) copies the input into every configuration code, so it only gives polynomial space. This PR adds a separate simulation,Turing.MultiTapeNTM.LogSquareSavitch.machine. It is a deterministicTuring.QueryMachine, so the input stays on the read-only tape.nin binary.(n + 2) ^ Dof the compact configuration graph (ConfigurationGraph, which omits the input) and the vertex widthW = size(vertexBound) = O(log n).Cslib.Reachability.Savitch.step, at depthW) on vertices written asW-bit words.The edge test at a level-0 call needs exactly one input bit, at the input head of the source, and that is the bit the query machine reads in that step. A sink word (all ones) is reached from every accepting halted vertex, so a single reachability query decides acceptance (
reach_eq_true_iff). The stack has at mostWframes ofO(W)bits, so states haveO((log n + 1)²)bits (length_encRuntime_run_le).QueryMachine.computableInSpacethen gives the space bound.Source → Lean
Turing.MultiTapeNTM.exists_decidableInTimeAndSpace_log_sq,Cslib.Complexity.NL_subset_DSPACE_log2_sqCslib.Reachability.reach,reach_iff,Savitch.step(unchanged)O(log n)bits, edge test reading one input bitConfigurationGraph.edgeWithSymbol,accepts_iff_reachable_bad_of_runsInSpace; words and sink here:LogSquareSavitch.wordEdge,reflTransGen_sink_iffLogSquareSavitch.length_encRuntime_run_lewithSavitch.length_encState_le(now public)RL ⊆ NLCslib.Complexity.RL_subset_DSPACE_log2_sq=NL_subset_DSPACE_log2_sq ∘ RL_subset_NLModel mapping. Sipser's sublinear extension uses a read-only input tape, and a configuration of the machine on
womitsw(state, work tapes, head positions). Here that is the compact configuration graph (ConfigurationGraph), whose vertices omit the input, and the query machine supplies the one input bit an edge test needs. The source covers every f(n) ≥ log n for deciders on strings; the Lean statements cover only f(n) = c·(log₂ n + 1), but extend the source in two ways: the nondeterministic machine need only recognize the problem (branches may run forever), and instances are arbitrary types under an encodingenc : α ↪ List Bool.I checked the statements against Sipser §8.4 (p. 351) and Hoza §4.3. I could not access the Savitch paper, so the theorem number above is not verified.
Plain-only
Every statement and proof in the new files is plain: no
ComputableTidily*, no.tidyround trips, no tidyfun_prop. Per crei's rule, the tidy dependencies were made plain first, in #1668 (the query-machine theorems and configuration-graph routines). Two plain-statement dependencies still have tidy proofs internally:QueryMachine.computableInSpace;Savitch.computableInO_roundStep.Their statements are already plain, so I used them as they are.
Scope and what remains
NSPACE(s) ⊆ DSPACE(s²)for everys ≥ log nis not proved. The machine computes its radix fromn, which uses thatc * (log₂ n + 1)is constructible. A general version would need either a constructibility hypothesis or the radix-doubling trick of the inductive-counting machine (InductiveCounting/Machine.lean). ROADMAP already lists "Savitch bounds for general space-constructible functions".Cslib.BitString.lowBits.Encodings/Nat/Words.leangainsTuring.MultiTapeTM.bits_add_two_powanddropLast_bits_add_two_pow, the binary digits ofx + 2 ^ WaslowBits W x ++ [true].Savitch.allT/allT_run,Savitch.StackOk,Savitch.Invariant,invariant_step,invariant_iterate,StackOk.length_le,StackOk.memandlength_encState_leinSpace/Reachability.leanbecome public. The bibliography gainsSavitch1970andHoza2022.Tests
ComplexityTests/LogSpaceSavitch.lean:lowBits,(x + 2 ^ W).bits.dropLast);run_of_le,run_length_succ);reach_eq_true_iffand the machine-level theorem on a concrete zero-tape machine that accepts every input, so the hypotheses are satisfiable;Set.univ ∈ DSPACE encBits (log²);L ⊆ DSPACE(log²)viaL_subset_RL.Validation
At
474c4183f, these all pass locally:scripts/check.sh, all six gates;python3 scripts/check_hygiene.py --check-simp;python3 scripts/check_changed_files.py --base origin/main;python3 scripts/check_tidy_surface.py(no change on top of refactor(LogSpace): plain statements for query machines and compact configuration graphs (#474, #862) #1668).Size: 731 lines (machine-level file) + 73 (class file) + 28 (
Words.lean) of library code, and 89 lines of tests.Review fixes (
7b3d3a490): reuseComputableInDegree.two_pow_length,ComputableInDegree.isSomeand the now-publicSavitch.allTinstead of new transducers, and move the fixed-width words toWords.lean.Second review round (
474c4183f):Cslib.BitString.lowBits, withlsbValue_lowBits,lsbValue_eq_foldr_bitandlsbValue_replicate_true, sobitsOfWidthand its lemmas are deleted.Foundations/Data/BitString,Encodings/Nat*andInSpaceLibfound two more duplicates, now replaced: the unary-size transducer byComputableInO.lengthUnary, andbudget_somebyComputableInDegree.optionSome.transducer_inSpace: no plain transducer-to-ComputableInSpacerule exists.width: it equalsTuring.InductiveCounting.guessWidth, and importingInductiveCounting.Machinefor one definition seemed worse.Third review round (
3e0c03add, documentation only): both new modules now cite Sipser 3rd ed. §8.4, final paragraph (p. 351), instead of Theorem 8.5 (which assumes f(n) ≥ n), quote the source sentence, map the read-only-input convention to the compact graph/query simulation, and separate the nonhalting-recognizer and encoded-instance strengthenings from the source statement. In the table, the Sipser locator is corrected and the recursion-stack row is labelled a paraphrase. No Lean statement or proof changed.Please arrange a non-author review. Worker
worker-crei-dc679113-474m3(Claude Code), for #474 M3 (claimed bycoordinator-crei-dc679113).🤖 Generated with Claude Code