Repository navigation
fix: recognizer branches depend on constants they never require (3/4) - #9
Merged
Merged
Conversation
Every arithmetic branch built Nat and Bool literals, and depended on other primitives' semantics, without requiring any of them present in the environment. Each was implied by a later checkType, but only recoverable by inverting "type checking succeeded" -- and the translation witnesses the isDefEq specification demands cannot be built before that inversion is available. They are now explicit env.contains guards. The guards are provably redundant as *checks*, so no previously accepted declaration is now rejected; they exist so the postcondition can be proved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
Split out of #2, as requested. 3 of 4. Independent of the siblings; applies
to pristine
master.The bug
Every arithmetic branch builds
NatandBoolliterals, and depends on otherprimitives' semantics, without requiring any of them to be in the
environment:
Nat.sub,mul,pow,mod,div,gcd,shiftLeft,shiftRight,land,lor,xorbuildNat.zero/Nat.succwithout requiringNat;land/lor/xorbuildBoolliterals without requiringBool;mod/divneedNat.ble's semantics (viaCondition.natLE) but neverrequire
Nat.ble;bitwiseneedsNat.add/Nat.div/Nat.mod/Nat.beqbut requires none ofthem;
Nat.gcdpath needsBoolinsideunfoldNatWellFounded.Each was implied by a later
checkTypein the same branch — but onlyrecoverable by inverting "type checking succeeded, therefore this constant is
present". And that inversion comes too late: the
TrExprSwitnesses theisDefEqspecification demands cannot be built without those containments,so the obligations are needed before the inversion is available.
This is a different failure from the sibling PRs. Nothing unsound was accepted;
the postcondition was simply unprovable in the order the proof has to go.
The fix
Explicit
env.containsguards, in the house style of the branches that alreadyhad them.
They reject nothing new. Every guard is forced by a
checkTypeorisDefEqlater in the same branch, so any declaration that previously passed still
passes — confirmed by the arena and by
Verify/Soundness.lean's build-timestdPrelude accepted by addDecl ✓check. They exist so the postcondition can beproved, not to change the decision.
Testing
lake build lean4leangreen, including therun_metaself-test over all 24entries of
Environment.primitives.On the arena: the combined change of all four splits was arena-verified at
185 correct / 6 either / 0 incorrect, the baseline. Each split is a subset of
that strictness, so none can reject anything the combined version accepted.
divergences.mdis updated in #7, which carries the note for the whole series.🤖 Generated with Claude Code