Skip to content

feat(Classes): define the polynomial hierarchy - #18

Draft
BoltonBailey wants to merge 16 commits into
SamuelSchlesinger:devfrom
BoltonBailey:feat/polynomial-hierarchy
Draft

feat(Classes): define the polynomial hierarchy#18
BoltonBailey wants to merge 16 commits into
SamuelSchlesinger:devfrom
BoltonBailey:feat/polynomial-hierarchy

Conversation

@BoltonBailey

@BoltonBailey BoltonBailey commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

This is an in-progress PR to add the definition of the Polynomial Time hierarchy.

Depends on #21

🤖 Generated with Claude Code

BoltonBailey and others added 12 commits July 24, 2026 12:53
Define certificate quantifiers over the pair codec (polyExistsLang /
polyForallLang and their class operators), the levels SigmaP / PiP by
the standard recursion through complement classes, and PH as their
union. Prove quantifier and class-level complement duality,
monotonicity, the recursion laws, and level inclusions, the latter
conditional on the single machine-engineering seam `pairFst ∈ FP`
(first-component pair decoding), isolated as a hypothesis following the
WitnessNTMConstruction pattern. Ported from leanprover/cslib#192,
re-proved against this library's machine model and Set-based languages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	Complexitylib/Models/RoseTreeMachine/Data.lean
`dev` de-exposed `Encoding/DataEncode.lean` as part of the module-interface
minimization, but this branch adds `bitstringEncode` together with
`bitstringEncode_def` and `bitstringEncode_injective`, both of which need
the definition's body to typecheck. Expose the single definition rather
than re-exposing the whole module.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`dev` gained commit 60118c9 ("revert encoding stuff") via the SamuelSchlesinger#23 merge,
which deleted Complexitylib/Encoding.lean and Encoding/Delimit.lean and
inlined the delimiting logic back into Encoding/Pairing.lean. That is the
exact refactor this branch performs, so the merge conflicts on both files.

Resolved in favour of this branch's extraction: keep Encoding.lean and
Encoding/Delimit.lean, and restore this branch's Encoding/Pairing.lean
(`pair x y = delimit x ++ y`). No declaration is lost — every declaration
in dev's Pairing.lean is present in this branch's Pairing.lean plus
Delimit.lean. Also restore the `Complexitylib.Encoding` import in
Complexitylib.lean, which the merge dropped because dev deleted the line.

The two `pair`s produce the same bitstring but associate differently
(`(A ++ sep) ++ y` here vs `A ++ (sep ++ y)` on dev), so five consumer
proofs needed the shape realigned:

- SAT/ThreeSAT/Verifier: unfold `delimit` in the `foldl_append` chain
- TuringMachine/Subroutines/PairEmit/Internal: add `delimit` to `simpa`
- TuringMachine/UTM/Internal/Init: add `delimit` to `simp`
- Classes/NP/Internal/PairBuildTM: drop now-unused `List.append_assoc`
- Classes/PPoly/Advice: drop now-unused `List.append_assoc`

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ncoding

# Conflicts:
#	Complexitylib/Encoding/Data.lean
#	Complexitylib/Models.lean
@BoltonBailey
BoltonBailey force-pushed the feat/polynomial-hierarchy branch from 5ac1219 to e88f6f8 Compare August 14, 2026 05:05
BoltonBailey and others added 3 commits August 16, 2026 09:00
Revert the incidental docstring rewording and the `@[expose]` widening of
`Encoding/Data.lean` introduced by this branch, keeping the diff against dev
limited to substantive changes. Docstrings for newly added declarations are
retained.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant