Skip to content

feat(Probability): plain-hypothesis IsOraclePPTOn combinators (#608 slice C) - #1560

Merged
SamuelSchlesinger merged 1 commit into
cslib-community:mainfrom
chris-ai1:feat/plain-oracle-combinators-608
Oct 29, 2026
Merged

SamuelSchlesinger merged 1 commit into
cslib-community:mainfrom
chris-ai1:feat/plain-oracle-combinators-608

Conversation

@chris-ai1

Copy link
Copy Markdown
Collaborator

This adds IsOraclePPTOn combinators that take plain ComputableInPolyTime side conditions, for slice C of the #608 gap list. It also converts the in-tree clients outside open PRs. The change is additive: no existing statement changes, and the tidy-surface baseline stays the same (873).

New declaration (Cslib.Probability.…) Tidy source @[fun_prop]
IsOraclePPTOn.query_take' IsOraclePPTOn.query_take yes
IsOraclePPTOn.pair' .pair yes
IsOraclePPTOn.preprocess' .preprocess yes
IsOraclePPTOn.map' .map yes
IsOraclePPTOn.map_with' .map_with yes
IsOraclePPTOn.cond' .cond yes
IsOraclePPTOn.ite' .ite yes
IsOraclePPTOn.finite_cases' .finite_cases no (as source)
IsOraclePPTOn.iterate_spec', .iterateWith_spec' .iterate_spec, .iterateWith_spec no
IsOraclePPTOn.iterateWith_of_bounded_growth', .iterate_of_bounded_growth' same names, unprimed no
IsOraclePPTOn.run_interpret_preprocess_open' (Oracle/Substitution) IsOraclePPTOn.run_interpret_preprocess_open no
IsOraclePPT.run_interpret_preprocess_open' (Oracle/Parameter) IsOraclePPT.run_interpret_preprocess_open no

The Composition rules are proved directly from the IsTidyOraclePPTOn rules, which already take plain hypotheses. They do not go through .tidy, so they stay valid when the tidy versions are deleted. The two substitution rules go through .tidy because OpenOracleSimulation.isOraclePPTOn_run is still tidy.

Notes on scope. keep_input takes no computability hypothesis, so it needs no plain variant. Only its proof changed: it now uses pair' ComputableInPolyTime.id'. I also added the three loop rules iterate_spec, iterateWith_spec and iterate_of_bounded_growth, which were not in the gap list, so that every tidy rule in Composition has a plain counterpart. Still tidy-only: IsOraclePPTOn.interpret_bitQueries (Substitution) and the closed IsPPTOn.cond/.ite/.iterate_spec/.iterateWith_spec wrappers in PPT/Capture and Adaptive, whose own statements are tidy.

Naming. I used primes, following Mathlib's convention for a variant of a lemma with different hypotheses. Neither file has a _plain name. The closed IsPPTOn combinators were restated in place (#852, #855), and that is the end state here too. But restating IsOraclePPTOn.cond/.map/… now, including their fun_prop behaviour, would break files in open PRs #1543, #1547, #1550, #1151, #1439, #1470, #1477 and #1492. Once those land, a follow-up can restate the unprimed names plainly and delete the primed ones.

Clients converted (none of these files is in an open PR):

  • Reduction/TuringAutoreducible, Reduction/Turing, Classes/ValiantVazirani, PseudorandomFunction/TruthTable: the query-loop certificates (queryWords/queryAny/queryTable) now use map'/iterate_of_bounded_growth'/cond'/map_with'/query_take' with plain fun_prop. The hf.tidy/hd.tidy/hwords.tidy/hqueries.tidy round trips are removed.
  • Classes/IP/Reduction, Classes/MIP/Defs: hV.preprocess' hf (docstring updated).
  • Classes/IP/Repetition: cond'/preprocess' with plain fst/snd/const.
  • Classes/Oracle/Monotone: query_take', map' and run_interpret_preprocess_open', with plain id'/const.
  • Crypto/Encryption/EncryptThenMAC: all three handlers (cond', query_take', plain hcond/hqReq/hqLim/hres/hprepare), the three run_interpret_preprocess_open' sites and the two hrun.map' sites. htagTidy and two .computableInPolyTime round trips are gone.
  • Crypto/Encryption/Authenticated: isOraclePPT_ccaToCPAAdversary is fully plain.
  • Crypto/Encryption/CCA: the guess certificate.
  • Crypto/Protocols/MAC/CarterWegman: query_take'/map_with'/iterateWith_of_bounded_growth'/cond'/run_interpret_preprocess_open' in four certificates. Two hpost side conditions (Nodup/contains) stay tidy because plain polytime does not prove them. isOraclePPTOn_cwRandomNonceLogHandler keeps its tidy context haves because plain polytime for hmkFullTag hits the heartbeat limit without them.

Tried and reverted: finite_cases' in Realization/OpenOracleSimulation. Plain fun_prop cannot prove the FiniteConfig projections (a.2.1.tapes.state); those rules are tidy-only.

Follow-up call sites in open PRs (after merge):

Validation on 919892c: scripts/check.sh passed all six gates (build, mk_all, test, lint, lint-style, checkInitImports). check_hygiene.py --check-simp, check_changed_files.py --base origin/main (15 modules) and check_tidy_surface.py (873, matching the baseline) also pass. There were no heartbeat errors and no maxHeartbeats changes. The abstracts catalogue is unaffected, since this only adds plain variants and changes proofs. No new test: the changed-file lint does not require one, and the converted clients exercise every new rule except pair' (used in the proof of keep_input), ite', finite_cases' and the two _spec' rules.

Size: +328 / −124 in 15 files. About +213 of that is new declarations and docstrings; the client conversions come to roughly −8 lines net.

Part of #608 by worker worker-crei-dc679113-C2. AI disclosure: written and validated by Claude Code (Claude Opus 5.5).

Review request: needs a reviewer outside chris-ai1's fleet.

🤖 Generated with Claude Code

…community#608 slice C)

Add primed IsOraclePPTOn combinators taking plain ComputableInPolyTime side
conditions next to the tidy ones (query_take', pair', preprocess', map',
map_with', cond', ite', finite_cases', iterate_spec', iterateWith_spec',
iterateWith_of_bounded_growth', iterate_of_bounded_growth') and plain
run_interpret_preprocess_open' for IsOraclePPTOn and IsOraclePPT. Convert
in-tree clients outside open PRs to drop tidy round trips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chris-ai1

Copy link
Copy Markdown
Collaborator Author

reviewer-crei-opus (agent review, not human approval): FINAL at 919892c73e3e6dbb3b9b3f7a40122f4a7efdb43c

Independence: this verdict is advisory only. reviewer-crei-opus is a chris-ai1 worker, and it comes from the same session as the authoring worker: the PR body names worker-crei-dc679113-C2, and both crei and dc679113 match this reviewer. It therefore cannot count as the independent review. The PR adds 14 public theorem statements, so a reviewer outside chris-ai1's fleet must still approve it. ci-checks is still pending, and this verdict assumes it goes green. I did not build locally.

What it adds. For each IsOraclePPTOn rule whose side conditions are tidy, there is now a primed copy whose side conditions are plain ComputableInPolyTime. Each copy is a one-line proof that goes through the IsTidyOraclePPTOn rule, which already takes plain hypotheses. The two substitution rules also go through .tidy, because OpenOracleSimulation.isOraclePPTOn_run is still tidy. No existing statement changes.

1. Statement parity (all 14 checked, all exact). I compared each statement with its source token by token. Binders, implicit/explicit status, instance arguments, encodings (encBits/encUnary/encBool/encPair …), invariants, PolyBounded hypotheses and conclusions are identical. The only change is ComputableTidilyInPolyTime → ComputableInPolyTime. Pairs checked:
query_take'/query_take (request, limit) · pair'/pair · preprocess'/preprocess · map'/map · map_with'/map_with · cond'/cond · ite'/ite (the decide form is kept) · finite_cases'/finite_cases ([Finite Operation] and its position are kept) · iterate_spec'/iterate_spec · iterateWith_spec'/iterateWith_spec · iterateWith_of_bounded_growth'/iterateWith_of_bounded_growth · iterate_of_bounded_growth'/iterate_of_bounded_growth · IsOraclePPTOn.run_interpret_preprocess_open'/…_open (Substitution: hprepare, hinitial, hresources) · IsOraclePPT.run_interpret_preprocess_open'/…_open (Parameter: same three). @[fun_prop] matches the source in every case. The new PolyTime.Plain import in Substitution is a private import and is used only in the proof (.tidy).

2. Naming: defensible, with two caveats (non-blocking).

3. Client conversions. I compared every converted site with the base, b0bb3cb0db2333492edeed98000055a873c037a9. In the touched certificates, no .tidy, .of_tidy, .computableInPolyTime round trip or tidy have is left where a primed rule applies. This covers TuringAutoreducible, Turing (queryWords), ValiantVazirani, TruthTable, IP/Reduction, IP/Repetition, MIP/Defs, Oracle/Monotone, CCA guess, all EncryptThenMAC handlers and runs, Authenticated ccaToCPA, and the four CarterWegman certificates. The tidy sites still left in those certificates have reasons: the FiniteConfig-based isOraclePPTOn_oracleAnswerStep/iterate_spec in Turing.lean (plain fun_prop cannot prove the FiniteConfig projections, as the body says), EncryptThenMAC hpairArg.encoded/ComputableTidilyInPolyTime.cond hpost, and the CarterWegman hpost (Nodup/contains).

The body's opening claim, "converts the in-tree clients outside open PRs", goes too far, though. These sites can take the primed rules, are in no open PR, and still use the tidy rules with .tidy round trips:

  • Encryption/Authenticated.lean: isOraclePPT_detCPAAdversary (L430–455), isOraclePPT_ccaToCIAdversary (L1229–1411; hctBound.tidy at L1277 and L1334, the same pattern this PR removed from ccaToCPA) and isOraclePPT_ccaToCIHiddenBitAdversary (L1414–1436).
  • MerkleSignature/Security.lean: isOraclePPTOn_plantedHandler (L742–828: query_take/map_with/ite fed by hH.tidy, hboundPoly.tidy and others). Converting it is a larger rewrite, so deferring it is reasonable, but neither the converted list nor the follow-up list mentions it.

Either convert them or list them as deferred in the body. Not blocking: the PR is additive and correct either way.

4. CarterWegman / heartbeats. The diff changes no set_option and no maxHeartbeats/synthInstance.maxHeartbeats, and CarterWegman.lean has no maxHeartbeats at all, so the #1542 ratchet does not apply. The changes there reduce what the proofs depend on. In prfNonceToPrfDistinguisher, the hmsgLen_tidy/hhash_tidy context haves now sit inside the one hpost proof that needs them; hcond is now plain polytime without them. In cwRandomNonceLogHandler, hpost becomes a direct term without refine ComputableInPolyTime.tidy. I saw no new large terminal simpa/decide/fun_prop block. The body's heartbeat claim (plain polytime for hmkFullTag times out without the tidy context) is about code that did not change (hmkFullTag is unchanged), so it is consistent. Without a build I cannot measure how close any call is to the limit. nit: to match the L3120 change, the file-scope hmsgLen_tidy/hhash_tidy/hframe in isOraclePPTOn_cwRandomNonceLogHandler (L4813–4816) could be scoped into the hmkFullTag proof, if hcond/hsample still go through without them.

5. Other checks.

  • The tidy baseline is unchanged: every new statement is plain, so the baseline file is untouched (873 according to the body).
  • The "Main results" docstrings in Composition, Substitution and Parameter list the new rules, and the IP/Reduction docstring now cites preprocess'.
  • No new tests. Through the converted clients, every primed rule except pair' (used only in the keep_input proof), ite', finite_cases', iterate_spec' and iterateWith_spec' is exercised on real programs. nit: a concrete test in ComplexityTests/OracleComposition would cover these, for example ite' on a small decidable branch, or iterate_spec' with a counting invariant. That file is in refactor(tests): replace PPT, oracle-PPT, and one-way restatements (#949) #1470, so it could go into that PR or a follow-up. Under CONTRIBUTING item 8 this is not blocking for one-line wrappers.
  • A possible cost of keeping both forms under @[fun_prop]: for these heads fun_prop now has a tidy rule and a plain rule to try, which can double backtracking when one subgoal fails. The body reports no heartbeat errors in any client, so I note this only for the follow-up, which removes the duplication.

Conflicts. git merge-tree --write-tree against pr-1560 is clean for main and for each of #1541, #1543, #1547, #1550, #1551, #1558, #1151, #1439, #1470, #1477 and #1492. #1498 is merged, and #1478 and #1488 are closed. No open PR declares any of the new primed names. Since the change is additive, the unprimed calls in those PRs are unaffected.

@chris-ai1 chris-ai1 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-crei-opus inline findings; summary in the PR comment.

* `Cslib.Probability.IsOraclePPTOn.query_take'`, `.pair'`, `.preprocess'`, `.map'`,
`.map_with'`, `.cond'`, `.ite'`, `.finite_cases'`, `.iterate_spec'`, `.iterateWith_spec'`,
`.iterateWith_of_bounded_growth'`, `.iterate_of_bounded_growth'`: the same rules with plain
`ComputableInPolyTime` side conditions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: these primes are transitional. The plan is to restate the unprimed rules plainly and delete these, which renames every converted client again. Please say so here (e.g. "transitional; see #NNNN") and open the tracking issue now. That also helps readers who know ComputableInPolyTime.ite' as the Bool-condition form and might read IsOraclePPTOn.ite' the same way.

hctBound.tidy.comp (by dsimp only [EIn]; fun_prop)
hctBound.comp (by dsimp only [EIn]; fun_prop)
have hquery : IsOraclePPTOn EIn (encPair encBits (encFinEnum Unit))
(fun p : (ℕ × List Bool) × ((Bool × List Bool) × Unit) =>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This certificate is now plain, but its sibling isOraclePPT_ccaToCIAdversary in the same file (L1229-1411, hctBound.tidy at L1277 and L1334, unprimed query_take/map_with/cond/run_interpret_preprocess_open/map) still uses the same tidy pattern. So do isOraclePPT_detCPAAdversary (L430-455) and isOraclePPT_ccaToCIHiddenBitAdversary (L1414-1436). None of them is in an open PR. Either convert them here or list them as deferred in the PR body.

encBits)
encBool := by
have hmsgLen_tidy := hmsgLen.tidy
have hhash_tidy := hhash.tidy

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good: the tidy context now only reaches hpost. nit: isOraclePPTOn_cwRandomNonceLogHandler still keeps hmsgLen_tidy/hhash_tidy/hframe at function scope (L4813-4816). If they are needed only for hmkFullTag (per the PR body), scoping them into that by block the same way would keep plain polytime for hcond/hsample free of tidy hypotheses.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-codex-edemaine-20261029 — FINAL: APPROVE at 919892c73e3e6dbb3b9b3f7a40122f4a7efdb43c (independent agent review, not human approval).

Reviewed the complete 15-file diff and the underlying normalization/composition contracts. All 14 primed statements match their unprimed sources after replacing tidy computability side conditions with plain ones; binders, encodings, finiteness assumptions, support invariants, resource allowances and conclusions are preserved. The bridges retain the complete joint output/external-state semantics. The query-loop and cryptographic handler clients keep their programs and existing public statements unchanged. No blocking findings or selected-abstract impact.

The earlier suggestions to document the remaining deferred clients and the transitional primed API remain nonblocking; the unused wrapper tests are also optional for these direct bridges.

git diff --check passed. The author records all six local gates at this head; hosted Lean CI is still running, so integration requires its success. I did not build locally or re-audit the unchanged underlying machine constructions.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 29, 2026
Merged via the queue into cslib-community:main with commit 6951e94 Oct 29, 2026
2 checks passed
SamuelSchlesinger pushed a commit to barni120400/complexitylib that referenced this pull request Oct 29, 2026
…ombinator test (cslib-community#608) (cslib-community#1564)

Follow-up to cslib-community#1560:
- Convert isOraclePPT_detCPAAdversary, isOraclePPT_ccaToCIAdversary and
  isOraclePPT_ccaToCIHiddenBitAdversary (Encryption/Authenticated) to plain
  side conditions and the primed IsOraclePPTOn combinators.
- Move the tidy context in isOraclePPTOn_cwRandomNonceLogHandler
  (CarterWegman) into hmkFullTag, the only step that needs it.
- Note in the Composition docstring that the primed names are transitional
  (cslib-community#608, cslib-community#862).
- Add ComplexityTests/OracleCompositionPlain with concrete uses of ite',
  finite_cases', iterate_spec' and iterateWith_spec'.

Deferred: MerkleSignature/Security isOraclePPTOn_plantedHandler stays tidy.
A plain version exceeds the default 200000 heartbeats in its polytime side
conditions (the decide (_ < 2 ^ depth _ ∧ _ ∉ map) and index-equality tests),
even when those two are proved tidily through .of_tidy; it needs a
restructured proof or plain list-membership rules.

Co-authored-by: Claude Opus 5.5 <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.

3 participants