RFC: ir: splice recorded post-proof state to fix mid-proof segment init#231
Open
ike-mulder-aws wants to merge 1 commit into
Open
RFC: ir: splice recorded post-proof state to fix mid-proof segment init#231ike-mulder-aws wants to merge 1 commit into
ike-mulder-aws wants to merge 1 commit into
Conversation
ike-mulder-aws
commented
May 15, 2026
When a theory is built with record_theories=true AND parallel proofs enabled, Toplevel.element_result forks each lemma body via Proof.future_proof, which rewrites the goal's after_qed to a stub that does NOT call Local_Theory.notes_kind. Every segment recorded inside that future captures the stubbed Proof.state, so initing a REPL at a mid-proof segment and stepping through qed fails to register the theorem (AutoCorrode#230). The fix introduces a per-REPL "segment_proof_splicer": at init we stash the recorded state of the next segment that exits the proof. When the user's stepping crosses the proof-exit boundary via a non-oops finisher, we splice that recorded state in for the post-state. oops disarms the splicer without firing, preserving "abandon proof, no theorem" semantics. The splicer is correctly re-armed across truncate, edit, and replay. Locale/context/experiment state is preserved through both splice (qed) and disarm (oops) paths. Detection of oops is keyword-based via Keyword.is_qed_global, which is brittle: keyword classification is decoupled from semantic effects, and custom declared keywords might break this (see the comment on splice_step in ir.ML for details). Stock Pure/HOL ships only `oops` as qed_global, so these limitations are deemed acceptable. Tests cover the original regression (segment_init_mid_proof_qed), oops behavior (segment_init_mid_proof_oops, _deep_oops), nested sub-proofs, splicer re-arming on truncate and on replay-via-edit, and locale preservation through both finishers. Signed-off-by: Ike Mulder <ikemul@amazon.com>
473bfb7 to
e0047f2
Compare
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.
Issue #, if available: #230
Description of changes:
When a theory is built with record_theories=true AND parallel proofs enabled, Toplevel.element_result forks each lemma body via Proof.future_proof, which rewrites the goal's after_qed to a stub that does NOT call Local_Theory.notes_kind. Every segment recorded inside that future captures the stubbed Proof.state, so initing a REPL at a mid-proof segment and stepping through qed fails to register the theorem (#230).
The fix introduces a per-REPL "segment_proof_splicer": at init we stash the recorded state of the next segment that exits the proof. When the user's stepping crosses the proof-exit boundary via a non-oops finisher, we splice that recorded state in for the post-state. oops disarms the splicer without firing, preserving "abandon proof, no theorem" semantics. The splicer is correctly re-armed across truncate, edit, and replay. Locale/context/experiment state is preserved through both splice (qed) and disarm (oops) paths.
Detection of oops is keyword-based via Keyword.is_qed_global, which is brittle: keyword classification is decoupled from semantic effects, and custom declared keywords might break this (see the comment on splice_step in ir.ML for details). Stock Pure/HOL ships only
oopsas qed_global, so these limitations are deemed acceptable.Tests cover the original regression (segment_init_mid_proof_qed), oops behavior (segment_init_mid_proof_oops, _deep_oops), nested sub-proofs, splicer re-arming on truncate and on replay-via-edit, and locale preservation through both finishers.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.