Repository navigation
Conversation
The file content is now byte-identical to the locally built and tested Qq/Macro.lean (git hash-object 22335cd).
…th master Upstream master bumped the toolchain past this branch (v4.36.0-rc2 -> v4.36.0 -> v4.37.0-rc1 in leanprover-community#179/leanprover-community#180), conflicting with the rc1->rc2 bump this branch carried from the fork's merge-base. Setting the branch's toolchain to master's makes the merge clean; the PR diff relative to the merge result is unchanged. Verified locally on leanprover/lean4:v4.37.0-rc1 (upstream master ad0c9f8 + this branch, toolchain conflict resolved to master's version): `lake build --wfail` passes (31 jobs, no warnings) and `lake test` passes (exit 0, incl. QqTest.levelExplicitUnivAntiquot).
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.
Fixes #16.
Problem
Inside
q(·), an antiquotated level variable works in some positions (Sort $u) but not in explicit universe annotations:Root cause
floatExprAntiquot'(Qq/Macro.lean) special-casesType $l/Sort $l, routing the level throughfloatLevelAntiquot', but has no case forx.{u, ...}(Lean.Parser.Term.explicitUniv) nodes. The generic traversal then treats a level antiquotation$uinside.{}as an expression antiquotation, turning it into the identifier$uin level position, which level elaboration rejects withunknown universe level '«$u»'.A first attempt to simply reuse
floatLevelAntiquot'for the level list (floatinglet u' : Level := u, as forType/Sort) fixed the parse error but producedSort uvsSort u✝type mismatches: the floated binding becomes a fresh level parameter.param u', while antiquotations like$Trefer to.param u— universe parameters compare by name, so the term-levellet u' := ucannot mediate. (ForType $u/Sort $uthe fresh parameter never needs to be compared with the original, which is why floating works there.)Fix
New
floatExplicitUnivLevel'used for the level list (argument 2) ofexplicitUnivnodes at quotation depth 0:$uis replaced by the bare levelu, behaving exactly like writingx.{u}— the level name is linked back to the localLevelvariable by the existingunquoteLevelLCtx/withLevelNamesmachinery;x.{$(u+1)}) are floated into aletbinding as before (same support level asType/Sorttoday);q(q(...))) the generic traversal is unchanged, so inner quotations' antiquotations are preserved.Tests
New
QqTest/levelExplicitUnivAntiquot.lean(picked up by theQqTest.+glob):q(@id.{$u} $T $t) = q(@id.{u} $T $t)byrfl, pinning that$uanduproduce the same quotation;@Prod.mk.{$u, $v},@Function.const.{$u, $v});variable, with a#guard_msgs#check.On unmodified
masterthe new file fails with the issue's exact error (unknown universe level '«$u»', 9 errors); with this fix it builds cleanly.Verification
On the pinned toolchain (
leanprover/lean4:v4.36.0-rc2, masterb025662):lake build --wfail— passes (30 jobs, no warnings)lake test— passes (exit 0; fullQqTestsuite, 59 jobs, including the new file)Qq/Macro.leantomastermakes the new regression file fail as described above.sorry/admitintroduced; the change is confined toQq/Macro.lean(meta-only) plus the new test file.git hash-object) to the locally built and tested sources:Qq/Macro.lean=22335cd3ed5841ec9fddff25746c477207abe422,QqTest/levelExplicitUnivAntiquot.lean=2af9a9318c6cde7ec001fc561062de1a15ee0b78. (Two commits because the initial push had transcription slips in unrelated lines — caught by the hash check and fully corrected in the second commit; feel free to squash.)Branch note: the branch is based on my fork's master (
859a214), whose tree is identical to upstreamb025662(verified via the identicalQq/Macro.leanblob80dd267), so the PR diff is exactly the two files above.Known limitation (pre-existing, unchanged): a composite level antiquotation such as
q(@id.{$(u+1)} $T $t)still cannot be defeq-matched againstT : Q(Sort (u+1)), since the floated binding introduces a fresh level parameter — the same limitationType $(u+1)has today.