Private single VeriBench Python-to-Lean generation transport trial, unscored.
harbor run -t brando90/vb-generation-myadd-20260913harbor download brando90/vb-generation-myadd-20260913Translate the following Python program into a Lean 4 formalization.
"""Return the sum of two natural numbers (non-negative integers).
Edge cases:
- 0 + n = n
- The function raises ValueError if a or b is not a natural number.
"""
# -- Implementation --
def pre(a: int, b: int) -> bool:
"""True iff both inputs are integers with a >= 0 and b >= 0."""
return isinstance(a, int) and isinstance(b, int) and a >= 0 and b >= 0
def prog(a: int, b: int) -> int:
"""
Return a + b for non‑negative integers a and b.
Raises ValueError if the precondition is violated.
"""
if not pre(a, b):
raise ValueError(f"Inputs must be non-negative integers (got a={a}, b={b})")
return a + b
# -- Tests --
from typing import Callable
def check(candidate: Callable[[int, int], int]) -> bool:
# Basic unit test
assert candidate(1, 2) == 3
# Edge unit test
assert candidate(0, 0) == 0
# Negative (pre-violations must raise ValueError)
bad_inputs = [(-1, 0), (0, -2)]
for a, b in bad_inputs:
try:
candidate(a, b)
raise AssertionError("expected pre-violation did not raise")
except ValueError:
pass
return True
if __name__ == "__main__":
assert check(prog), f"Failed: {__file__}"
print("All tests passed.")
Write your Lean 4 formalization to:
/home/user/lean_project/Veribench/MyAdd.lean
Your Lean 4 file must follow this structure (in order):
import Mathlib at the topnamespace MyAdd)example : ... := by native_decide and #evaldef Pre)def <name>_prop) and theorems (theorem <name>_thm ...) -- prove each theoremdef Post_prop) as conjunction of propertiesPre -> Post -- prove itId.run do with mutable stateend namespacefloat is the source notation; it does not by itself force your Lean theorem surface to be primitive Float. Preserve the task's numeric intent and every obligation when choosing a layer.Float for the executable implementation and ground unit tests. native_decide can discharge closed goals with an executable Decidable instance; #eval evaluates expressions. Passing ground tests does not prove a universally quantified property.Real or Rat using Mathlib's proof libraries. Use Int / Nat for discrete tasks as appropriate. Define the corresponding mathematical implementation and prove its properties; changing a numeric type alone does not connect two implementations.FloatLayer, RealLayer, RatLayer, FloatSpecLayer, FleanLayer and IntervalLayer. Real and Rat support exact mathematical models; use a rational restriction only when it preserves the task's admissible domain. An IEEE-754 model must represent the required floating-point behavior. An interval model is suitable for a bounds-style obligation, but bounds cannot replace a required exact result. These names are modelling conventions: the current theorem-coverage evaluator has no accepted-layer list or automatic cross-layer credit. Naming a layer does not prove equivalence or guarantee coverage credit.Float has an opaque underlying numeric model and opaque arithmetic operations, so the kernel cannot reduce those operations to prove general arithmetic laws. Structural or reflexive claims involving Float can still be proved. A theorem establishes the proposition stated for its chosen numeric model. To claim a result about another model or the Python implementation, state and prove the required correspondence; changing a type alone is insufficient. Any theorem left sorry earns zero proof-completion credit for that theorem.Option / Except results and error bounds must preserve the required behavior, not replace a stronger obligation with an easier one.sorry and no admit.:= sorry so the file still compiles -- but that theorem earns zero proof-completion credit.axiom declarations or other escape hatches; they violate the task policy.cd /home/user/lean_project && lake env lean Veribench/MyAdd.lean/home/user/lean_project/lake env lean must exit 0 with no errors. A non-compiling file scores 0 overall.sorry/admit (this fraction is a multiplicative factor of your score; all-sorry gives 0).A file that merely compiles with every proof left as sorry satisfies (1) but scores zero on (2) -- that is a failing result, not a success.
Use only the Python source above and your own reasoning. Do not retrieve VeriBench repositories, reference answers, or other agents outputs. Save the requested Lean file and copy it to /logs/terminus2/Submission.lean before stopping. This is a generation transport test, not a scored evaluation.