Repository navigation
Description
What you did
bend PROOF.bend # bend2 only
bend PROOF.bend --verdict # bend2, then the BendTT kernel
bend PROOF.bend -o PROOF.bendtt # the kernel's input
~/.bend/bendtt/<hash>/bendtt PROOF.bendtt<hash> is 57dc4b2aa41362ae, the kernel --verdict builds from 2.0.36's bendtt.lean.
What happened
bend2 accepts the law. The kernel runs out of fuel on it, and --verdict reports that as a mismatch, without the def or the reason:
$ bend PROOF.bend
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bend PROOF.bend --verdict
SOME PROOFS FAIL
Sorry - this is a mismatch between the TypeScript implementation, and the formalized BendTT kernel. Your proofs may or may not be correct, and we cannot validate them yet. This will be addressed in a future update. Meanwhile, feel free to open an issue to report this bug.
$ bend PROOF.bend -o PROOF.bendtt && ~/.bend/bendtt/57dc4b2aa41362ae/bendtt PROOF.bendtt
SOME PROOFS FAIL
In LAWS.copy_long:
out of fuel
main (0e14aa8b) prints the same.
The kernel says which def failed and why, but --verdict drops both:
kernel_checkreads the kernel's output, then returns only a boolean.cli_verdictthen prints the fixed notice.
Running out of fuel isn't a mismatch: the kernel stopped before it reached a verdict on the def. Because the notice asks for an issue, every such case looks like a soundness bug until someone runs the kernel by hand. #1193 and #1322 both had to do that. #1322 suggests this change in passing.
Expected
Under SOME PROOFS FAIL, --verdict prints the kernel's own message: the def's name and the reason.
SOME PROOFS FAIL
In LAWS.copy_long:
out of fuel
The mismatch notice could then be kept for the kernel's expected: / observed: failures, where bend2 and the kernel really disagree.
A def the translation leaves out of scope reaches the same notice too, because safe_check returns false; #1483 shows one. -o already lists such defs with their reasons, so --verdict could print those lines as well.
The file
LAWS.bend:
import Base
# h then r, or r alone when cut
def push(h: Char, r: String, cut: Bool) -> String:
match cut:
case True{}:
r
case False{}:
SCon{h, r}
# copies s through push, one char at a time
def copy(s: String) -> String:
match s:
case SNil{}:
SNil{}
case SCon{h, t}:
push(h, copy(t), False{})
# LAW: copy keeps a long string
law copy_long:
{copy(String.repeat("ab", 1000n)) == String.repeat("ab", 1000n) : String}PROOF.bend:
import Base
import ./LAWS.bend as Laws
def Laws.copy_long():
{==}Why this law runs out of fuel
This is background for the case above, not a second request.
bend PROOF.bend takes 0.1 s. The kernel's time grows with the square of the string's length:
"ab" repeated |
kernel |
|---|---|
| 200n | passes, 0.5 s |
| 400n | passes, 2.0 s |
| 600n | passes, 4.6 s |
| 800n | out of fuel, 4.7 s |
The cause is how push is translated. Its r is Data, and both arms of the match use it, so it gets a q=2 λ:
LAWS.push : ∀x0 : Char -> ∀x1 : String -> ∀x2 : Bool -> String =
λx0 => λ+x1 => λ{(,): λ{.True: λ{(): x1; λ{}}; λ{.False: λ{(): (.SCon, (x0, (x1, ()))); λ{}}; λ{}}}}
On a closed term, Term.val takes a q=2 argument to normal form before binding it, and walks the whole value even when it's already normal. Here r is copy(t), the rest of the string, so each char walks the whole tail again.
Matching the first parameter avoids this: def push(cut: Bool, h: Char, r: String), called as push(False{}, h, copy(t)). Then r is a plain λ inside each arm, and the kernel checks the same law at 1000n in 0.06 s.
bend --version
bend 2.0.36 (bend --version isn't an option in this release).
uname -sm
Darwin arm64
clang --version (the first line)
Apple clang version 21.0.0 (clang-2100.1.1.101)
Activity
fix(verdict): show the kernel's why under the mismatch notice (bendla…
fix(verdict): show kernel failure details (#1535) (#1536)