Conversation
Markers passed in theorem lists (AC, Cong, Excl, ExclSF, FRAG, Req0, ReqD, Once/Ntimes, NoAsms, IgnAsm, Abbr, labels) had no single definition: simpLib restated the AC/Cong head tests, markerLib's dest_tacmarked knew only the tactic-level ones, and a directive a consumer did not know fell through silently as a rewrite. In particular SIMP_CONV/SIMP_RULE with a Req0/ReqD argument returned a theorem carrying the marker$ hypothesis. markerLib now exports `datatype directive` with typed payloads and dest_directive/is_directive; dest_tacmarked is a projection of it. simpLib.process_tags dispatches over the datatype: requirement directives are refused (every tactic strips them first), assumption policy directives are dropped (FULL_SIMP_TAC legitimately lets them reach SIMP_RULE), bounded rewrites pass through. A consumer's `case` now warns at compile time when a constructor is added. Also fix BoundedRewrites.DEST_BOUNDED, which raised on any non-application hypothesis, so `Once (ASSUME p)` was silently treated as unbounded and its BOUNDED hypothesis leaked into results. Selftests pin every constructor's identity and payload, the wrapper ordering, the simpset-layer refuse/drop policy, and the bounded fix. Claude-Session: https://claude.ai/code/session_013o5UrJvx41wyuKGSpa32WP
Member
|
Very appealing; thanks! Please fix merge conflicts. |
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
Theorems passed in a tactic's or simpset's theorem list can be
directives rather than facts:
AC,Cong,Excl,ExclSF,FRAG,Req0,ReqD,Once/Ntimes,NoAsms,IgnAsm,Abbrand labelreferences.
markerLibconstructs most of them but offered no way toenumerate or classify them. Each consumer restated the part of the
vocabulary it happened to know:
simpLib.process_tagshad its ownis_AC/is_Conghead tests plustwo hand-rolled extraction loops for
Excl/ExclSFandFRAG.markerLib.dest_tacmarkedknew only the tactic-level directives(
NoAsms,IgnAsm,Abbr, labels).mk_require_tacknew onlyReq0/ReqD.Nothing tied these together, and a directive that reached a consumer
which did not know it was not rejected: it fell through as an ordinary
rewrite. The failure is silent and directional. Concretely, on
develop:SIMP_CONV bool_ss [Req0 (ASSUME “q”)] “q”; (* [q, marker$Req0] |- q <=> T *)The
marker$Req0hypothesis is carried into the result and nothingever discharges it.
SIMP_RULEbehaves the same way.NoAsmsandIgnAsmbecame vacuous rewrites (NoAsms <=> T). Every tactic entrypoint strips these markers before the simpset layer, so the leak only
shows up at the conversion/rule level, but there it is undetectable
without inspecting hypotheses.
A second, independent instance surfaced while pinning the fix:
BoundedRewrites.DEST_BOUNDEDsearched the hypothesis set withaconv bounded_tm o rator, which raises on any hypothesis that is notan application. So for a theorem with a variable hypothesis,
was silently treated as unbounded by the rewriter and its
BOUNDEDhypothesis leaked into every rewrite result.
Adding a directive obliged nobody to touch any list, so nothing
detected either omission at compile time. A downstream branch
(
isabelle-tactics) already hit the classical-rule variant of this,where an unrecognised directive is added to a claset as a logical rule.
Fix
markerLibnow owns the vocabulary as a closed datatype:Hypothesis-carried wrappers (
Req0,ReqD, bounds) are reported beforethe payload's own head, so consumers strip them first.
dest_tacmarkedis now a projection ofdest_directive, so there is asingle recogniser.
simpLib.process_tagsbecomes one fold over the datatype with anexplicit policy for every constructor:
Cong/AC/Excl/ExclSF/FRAG: honoured as before.Req0/ReqD: refused with aprocess_tagserror. Every tacticstrips them via
mk_require_tacbefore reaching here, so one thatarrives can only corrupt the result.
NoAsms/IgnAsm/Abbr/labels: dropped. These are the tacticlayer's, but
FULL_SIMP_TAClegitimately lets them reachSIMP_RULEfor the assumptions, so they cannot be errors.
Once/Ntimes: passed through; the rewriter honours them.Because the type is closed, a consumer that dispatches with
casegets a non-exhaustive-match warning when a constructor is added, which
is the compile-time check that was missing.
simpLib's privateis_AC,is_Cong,extract_exclsandextract_fragsare removed.DEST_BOUNDEDnow testsis_combbefore taking the rator.Tests
src/marker/selftest.sml: every constructor is recognised with theidentity and payload its consumer needs; wrapper ordering
(
Req0 (Cong th)); five non-directives (including a plain reflexiveequation and an equation over a
marker$constant) are rejected.src/simp/src/selftest.sml:SIMP_CONVrefusesReq0/ReqDandleaves the term unchanged for
NoAsms/IgnAsm.src/1/selftest.sml:DEST_BOUNDEDfinds the bound past a variablehypothesis (fails against the old code).