Skip to content

Commit b599f67

Browse files
Fix Lean guard verifier negation parsing (#1315)
* fix lean guard verifier negation parsing * ci: allow Lean runtime lane to finish --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
1 parent 84f95c2 commit b599f67

4 files changed

Lines changed: 57 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jobs:
200200
lean:
201201
name: Lean Runtime
202202
runs-on: ubuntu-latest
203-
timeout-minutes: 20
203+
timeout-minutes: 30
204204
steps:
205205
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
206206
with:

benchmarks/datasets/mathematical-benchmarks-v1/lean-guard-scope-assurance/tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.12-slim@sha256:57cd7c3a7a273101a6485ba99423ee568157882804b1124b4dd04266317710de
22
RUN python -m pip install --no-cache-dir attrs==26.1.0 jsonschema==4.26.0 jsonschema-specifications==2025.9.1 referencing==0.37.0 rpds-py==2026.6.3 typing-extensions==4.16.0
3-
LABEL jacobian.checksum="ee7fce1e17e0ff36dc68add1648233edeafcef6ae67f567bc7d93c2fb6ce2e7d"
3+
LABEL jacobian.checksum="095a8c611a726fb7cac8964c0f85fd3db12ec89b9549c8398bb9b948215ef3ab"
44
LABEL jacobian.task="jacobian/lean-guard-scope-assurance"
55
COPY expected.json input.json test.sh verifier.py verifier_support.py public_contract.json /tests/
66
COPY input.json /app/input.json

benchmarks/datasets/mathematical-benchmarks-v1/lean-guard-scope-assurance/tests/verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _result_item_ok(item, case):
9595
reason_text,
9696
)
9797
or re.search(
98-
r"\b(?:no|not)\b[^.;\n]{0,40}\b(?:division|divisor)\b",
98+
r"\b(?:no|not)\b[^.;\n]{0,40}\bdivision\s+by\s+zero\b",
9999
reason_text,
100100
)
101101
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from __future__ import annotations
2+
3+
import importlib.util
4+
import sys
5+
from pathlib import Path
6+
7+
ROOT = Path(__file__).parents[3]
8+
TASK = (
9+
ROOT / "benchmarks/datasets/mathematical-benchmarks-v1/lean-guard-scope-assurance"
10+
)
11+
12+
13+
def _module():
14+
sys.path.insert(0, str(TASK / "tests"))
15+
spec = importlib.util.spec_from_file_location(
16+
"lean_guard_scope_assurance_verifier", TASK / "tests/verifier.py"
17+
)
18+
assert spec and spec.loader
19+
module = importlib.util.module_from_spec(spec)
20+
spec.loader.exec_module(module)
21+
return module
22+
23+
24+
def _allzero_bad_guard_case() -> dict[str, object]:
25+
return {
26+
"id": "allzero_bad_lt_guard",
27+
"ofnat_zero_equals_one": True,
28+
"lt_is_universal": True,
29+
}
30+
31+
32+
def test_accepts_negated_guard_strength_with_positive_zero_divisor_finding() -> None:
33+
module = _module()
34+
item = {
35+
"id": "allzero_bad_lt_guard",
36+
"findings": ["DIVISION_BY_ZERO"],
37+
"reason": (
38+
"The universal order guard does not supply a sound nonzero divisor "
39+
"fact, so the divisor remains semantically zero."
40+
),
41+
}
42+
43+
assert module._result_item_ok(item, _allzero_bad_guard_case())
44+
45+
46+
def test_rejects_reason_that_denies_division_by_zero() -> None:
47+
module = _module()
48+
item = {
49+
"id": "allzero_bad_lt_guard",
50+
"findings": ["DIVISION_BY_ZERO"],
51+
"reason": "There is not division by zero because the divisor is safe.",
52+
}
53+
54+
assert not module._result_item_ok(item, _allzero_bad_guard_case())

0 commit comments

Comments
 (0)