Repository navigation
Conversation
Bring `enc_structure` and its tests over from #2184, and migrate hand-written structure encodings to it, removing the rules it generates. The command also generates polynomial-time rules, accepts parameters and binders, supports `noncomputable` and `global`, and no longer marks `_apply` as `simp`, because the migrated clients need these. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
enc_structureand uses it for 14 hand-written structure encodings in 9 files, as the "structure encodings are boilerplate" row of #2209. It's refactoring and infrastructure, with no mathematical progress.This is a draft and needs a design decision before review. It is the generated-encoding request from #1656. crei asked Samuel on #2184 what he thinks of it, and no answer is recorded yet.
This replaces Boosting's
State.encoding, its injectivity proof, and its hand-written field and constructor rules:/-- Reuse the standard Boolean, unary, and list encodings. -/ global enc_structure encoding : State where stopped : encBool, threshold : encUnary, predictors : (encList encBits)Lines. Clients are net −396 (+135, −531). The tool is 206 lines and its tests 120, plus one line in
Complexity.lean, so the repository is net −69.Migrated:
Encoded.EdgeandEncoded.Graph(PCP), BoostingStateandParameters,SavedPrediction.Description, the TQBFFrameandState, the SavitchFrameandState,LocalCfgandIntervalData, the inductive-countingRuntime, the RAMFiniteState, andMINKT.Instance.Changes to the command from #2184, each needed by a client here. #2184 should take this version when rebased.
eS_f_polyTimeandeS_mk_polyTime. Most clients wrote these by hand; theComputableInDegreeandComputableInOrules alone would have replaced almost nothing.Edge C) and binders. Explicit binders stay explicit oneSand become implicit in rules with hypotheses.noncomputable enc_structurecovers encodings built onencFinite.global enc_structuregives ordinaryfun_proprules. PCP and Boosting clients use these rules across many files, and one of those files is in an open PR, soopen scopedeverywhere was worse._applyis no longer@[simp]. Assimpit unfoldedDescription.encodingbeforedecode_encodingcould fire, which brokeSavedPrediction.Universal/Complexity.leanalready passeseCfg_applyexplicitly in its one use I checked, but refactor(Universal): assemble the step complexity with fun_prop #2184 must recheck the rest.MINKTand the RAMFiniteStatekeep the attribute with oneattribute [simp]line each.Public changes. Encoded words are unchanged, so no bound or curated abstract statement changes, and no abstract source mentions these encodings. The definitions are now
@[expose]and built with.trans.State.isPolyTime_{mk,stopped,threshold,predictors},Parameters.isPolyTime_{mk,confidence,densityNumerator,densityBound,rateBound,codeBound},Edge.isPolyTime_{mk,src,dst,constraint}andGraph.isPolyTime_{mk,vertices,edges}becomeencoding_mk_polyTimeandencoding_<field>_polyTime.IntervalData.computableInPolyTime_mkbecomesencIntervalData_mk_polyTime.Frame.fieldsandState.fieldsin TQBF,Frame.fieldsin Savitch,LocalCfg.equivProd,IntervalData.equivProd.h, and its functiong, in place of names such ashedgeandedge.MINKT.enc_applyandFiniteState.encoding_applykeep their names; they now stateencFields, which is a reducible abbreviation of the oldencPairterm.Left as they are:
TM2/EncodingencCfg: its rules are inTM2/Simulation.lean, changed by refactor(resources): replace plain linear computability with degree 1/1 #2177.QueryReplaySpaceandTreeEval/Ary/IterativeEncoding(feat(ExactTriangle): bound initialized native ET by natural subcubic time #2154),ReplacementDesignBuilder,StepMachineCompandChildCursor(refactor(BigO): assemble computability proofs with fun_prop #2215),MPC/PolyTime(refactor(Crypto): replace projection chains across MPC, GMW, and SigmaProtocol modules (#1764) #2011).DescribedNetwork.encDescribed:DirectContraction.lean, in refactor(BigO): assemble computability proofs with fun_prop #2215, uses itsequivProd.MINcKT.encandPacketCtx.enc: their tuples nest differently, and matching them would change the encoded words.TreeEval/ReaderFrame: part of its tuple goes throughencFinEnum.ComputableInSpacefield rules inInductiveCounting/Callbacks.leanremain. Replacing them needs a space-level rule in the command.Universal/is untouched (#2184), and sum types are #2217.Validation. At
bec86df63, based on62ca5c214:scripts/check.shpassed all six gates (lake build --wfail --iofail,mk_all --check,lake test --wfail --iofail,lake lint,lint-style,checkInitImports).scripts/check_hygiene.py --check-simp,scripts/check_tidy_surface.pyandscripts/check_changed_files.py --base origin/mainpassed on the same build. NomaxHeartbeatschanged. Hosted CI should cover the merge with the latestmain.Tracks #2209. Related: #1656, #2184.
AI assistance: Claude Code (Opus 5.5) extended the command, migrated the clients and wrote this description. The original command is crei's, from #2184. This needs independent non-author review once the design is decided.
🤖 Generated with Claude Code