Skip to content

--verdict fails on proofs bend checks in 0.06 s; the kernel copies terms without sharing, and running out of fuel is reported as a mismatch #1593

Closed as duplicate

Description

@GunnarZarncke

What you did

bend tests/proof/kernel_copy_shared.bend --verdict

What happened

SOME PROOFS FAIL
In doubles:
out of fuel
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.

The file

import Base

type P is Data:
  P{a: U32}

def step(s: P) -> P:
  match s:
    case P{+a}:
      P{U32.add(a, a)}

def run(+n: Nat, s: P) -> P:
  match n:
    case 0n:
      s
    case 1n+p:
      run(p, step(s))

def get(s: P) -> U32:
  match s:
    case P{+a}:
      a

def twice(+y: U32) -> U32:
  U32.add(y, y)

def dbl(+n: Nat, x: U32) -> U32:
  match n:
    case 0n:
      x
    case 1n+p:
      twice(dbl(p, x))

law doubles:
  for +x: U32
  {get(run(24n, P{x})) == dbl(24n, x) : U32}

def doubles(x):
  {==}

bend --version

bend 2.0.37 (main at d2aeefc)

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.1.1.101)

Activity

  1. added
    bug
    on Oct 15, 2026
  2. GunnarZarncke commented on Oct 15, 2026

    @GunnarZarncke
    Author

    bend checks this file in 0.06 s; --verdict runs out of fuel on it. Both sides name a value twice, n levels deep. bend shares that value, so its cost grows linearly with n. The BendTT kernel copies it each time instead, so its cost doubles with every level:

    n bend --check-only --verdict
    16 0.06 s 0.34 s, checks
    20 0.07 s 4.2 s, checks
    22 0.06 s 8.8 s, out of fuel
    60 0.06 s —

    Nothing warns about this until --verdict runs. I ran into it proving an ARM64 trap handler correct by running its machine code symbolically: a state where each step reads the previous one. Written the obvious way, the kernel got 5 steps in before using 13 GB. The 80-step paths ended up cut into 154 segments of at most 8 steps, joined by a composition lemma, and the full kernel check took about 7 minutes (demos/hypervisor/SPEC.md §14 on my fork's hypervisor branch).

    Possible fixes: the kernel evaluates a copied argument once and reuses it, or bend warns when a definition's unshared size would exceed the kernel's fuel. (#1535 already made the "out of fuel" reason visible; thanks.)

    A test for it: main...GunnarZarncke:bend:kernel-copies-unshared. Its program prints its #| line on every lane, so gates/test.ts passes it, and gates/safe.ts should classify it as a false reject.

  3. Lorenzobattistela commented on Oct 16, 2026

    @Lorenzobattistela
    Collaborator

    Closing as a duplicate of #1193 (same cause: the kernel copies a shared value at every use). I've moved the repro, scaling table, test branch and fix ideas over there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions