lsc check accepts added requires/ensures lines in .dfy, so a proof file can make obligations vacuous
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start with additionsOnly in tools/src/dafny-commands.ts, which currently rejects only deleted lines when .dfy is compared with .dfy.gen. Reproduce the two cases from the issue: an added requires in a generated header, and an added assume or {:axiom} declaration, both passing lsc check. Done means these additions are rejected or explicitly configured, while legitimate appended lemmas still pass. The issue leaves the exact rule open, so agree on it with maintainers first.
Written by the indexing model from the issue text.
Description
Summary
lsc check treats any line that appears in foo.dfy but not in foo.dfy.gen as an allowed proof addition. additionsOnly in tools/src/dafny-commands.ts (checked on main at 566df0d) rejects only deleted lines. An added requires, assume, or {:axiom} passes the check. Each of these weakens what is proved while lsc check still reports success.
Reproduction
Observed with lemmascript 0.6.8 and Dafny 4.11.0. The code involved is unchanged on main.
-
Write a function with a guard in its contract and run
lsc gen, so thatcounter.dfyandcounter.dfy.genboth contain:function increment(c: Counter): Counter requires inRange(c) && belowMaximum(c) -
Remove
belowMaximum(context)from the TypeScript//@ requires(or from the guard in the body) and runlsc genagain.counter.dfy.genis regenerated without the clause.counter.dfyis left as it was. -
Run
lsc check. It reports all obligations verified. The diff from.dfy.gento.dfyshows the stalerequires ... && belowMaximum(c)line as an addition, so the check accepts it and Dafny verifies the old, stronger-precondition model instead of the current source.
The same check accepts lines added inside a generated header. Adding two lines to a generated contract lemma:
lemma increment_ensures(context: Context)
requires inRange(context)
requires belowMaximum(context)
requires false // added
ensures false // added
ensures inRange(increment(context))
and running lsc check --backend=dafny quantityCounter.ts regenerates .dfy.gen, passes the diff check, and prints Dafny program verifier finished with 11 verified, 0 errors, including the proof of ensures false. It also accepts new declarations that use assume or {:axiom}, which a proof addition can then rely on. Putting {:axiom} on an existing generated line does count as a modification and is rejected.
Expected
Proof additions should not be able to change what the generated declarations claim. Possible rules:
- Reject added lines that fall inside a generated declaration's header (
requires,ensures,decreases,reads, attributes). Allow new declarations and lemma bodies. - Reject
assumeand{:axiom}in proof additions unless explicitly allowed by configuration. - Optionally, have
lsc checkwarn when.dfypredates the latest.dfy.genand the regen merge was not run.
Context
We work around this in a downstream runner by requiring the generated text to appear byte-for-byte in the proof file, allowing only appended declarations and lemma calls, and refusing assume and attributes. We would prefer to rely on lsc check for this. Related, closed: #280 (regen merge conflicts), #192 (a translation that verified the wrong model).
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 13
- Avg merge
- 15h 35m
- Merged PRs (30d)
- 56
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 midspiral/LemmaScript
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midspiral/LemmaScript#355 · 1 comment ·
Maintainers usually reply within 1 day
-
In a pure function body, a `const` declared inside an `if` branch stays in scope after the `if`, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
midspiral/LemmaScript#362 ·
Maintainers usually reply within 1 day
-
A `const` or `let` inside a bare `{ }` block stays in scope after the block, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
midspiral/LemmaScript#361 ·
Maintainers usually reply within 1 day
-
A closure declared before a same-name `const` or `let` in its block reads the outer variable, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 18/100
midspiral/LemmaScript#360 ·
Maintainers usually reply within 1 day
-
An assignment used as an expression, such as `(x = 7);` or `const y = (x = 7)`, is extracted as an equality test, so a false `ensures` can verifyPossibly taken @namin claimed this today. Open
Difficulty 3/5 Half a day Newbie friendliness 30/100
midspiral/LemmaScript#356 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in midspiral/LemmaScript
Similar issues
-
bug done
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neavo/LinguaGacha#1124 ·
Maintainers usually reply within 1 day
-
[fullsend] E2E: backstage-microsoft-auth — catalogQuery missing error handler for network errorsPossibly taken @fullsend-ai-coder claimed this today. Opene2e-failure ready-to-code
Difficulty 2/5 Under an hour Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#4821 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
brylie/mission-island#225 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30412 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day