`ptrEqThen`'s compiled implementation disagrees with its definition when `beq` is not reflexive
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- backend-api-design
Research direction
Read src/verso/Verso/BEq.lean, especially the definitions of ptrEqThen and ptrBEq, and reproduce the examples with native_decide and the NaN list. Compare the existing API contract with the documented constraints on withPtrEqUnsafe in Lean core; the issue leaves the choice of fix open. Done means the compiled implementations no longer disagree with their stated contract, with regression coverage for non-reflexive equality.
Written by the indexing model from the issue text.
Description
Verso.BEq.ptrEqThen beq x y is defined as beq x y, but its implemented_by replacement unsafePtrEqThen returns true whenever x and y are pointer-equal. The two agree only if beq is reflexive, and neither the signature nor the docstring requires that. With a non-reflexive beq, native_decide proves False:
import Verso.BEq
open Verso.BEq
def p (a _ : Nat) : Bool := decide (a < 1)
theorem logical : ptrEqThen p 1 1 = false := by simp [ptrEqThen, p]
theorem compiled : ptrEqThen p 1 1 = true := by native_decide
theorem ptrEqThen_false : False := by
have h := logical.symm.trans compiled
cases h
#print axioms ptrEqThen_false
-- 'ptrEqThen_false' depends on axioms: [propext, compiled._native.native_decide.ax_1_1]
ptrBEq has the same gap for any BEq instance that is not reflexive. With xs : List Float := [Float.ofBits 0x7ff8000000000000] (a NaN), #eval xs == xs prints false and #eval ptrBEq xs xs prints true.
Checked at 58b5db4989f67235d1fffb0e0bc4a02bdcc87412 (current main) with Lean 4.36.0-rc2.
This relies on native_decide, so it is not a kernel inconsistency. Verso's own call sites compare with derived or structural BEqs, and I did not find one whose result changes, so this is about the API contract and about proofs that use native_decide.
Possible fixes are to document that beq must be reflexive, or to take a proof argument as withPtrEq did. The docstring of withPtrEqUnsafe in Lean core explains why core no longer provides a polymorphic safe version, so a reflexivity hypothesis alone may not be enough for every α.
- Dominant language
- Lean
- Stars
- 420
- Forks
- 134
- Avg merge
- 1d 9m
- Merged PRs (30d)
- 46
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from leanprover/verso
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
leanprover/verso#972 ·
Maintainers usually reply within 1 day
-
`"&"` in docstring of `Html.text` is not rendered literallyMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
leanprover/verso#898 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
leanprover/verso#1133 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
leanprover/verso#1125 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 55/100
leanprover/verso#1107 ·
Maintainers usually reply within 1 day
All issues in leanprover/verso
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
bug documentation queries
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cs#815 ·
Maintainers usually reply within 1 day
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day