Commit 1d4e263
committed
proofs(Layer 1.0): close slash-slash inductive case via mutual recursion (#113)
Closes the open obligation left by PR #111 (issue #113). Two substantive
corrections + the closure proof:
(1) FIXES SEMANTIC BUG in PR #111's model. The previous
stripLineCommentBody returned 'nl :: rest' where rest was the
ORIGINAL TAIL — meaning only the FIRST comment in the input was
stripped. The Rust pass at src/assail/analyzer.rs:931 strips ALL
comments. New model uses mutual recursion: stripLineCommentBody
calls back into stripLineComments at each preserved newline, so
the entire input is processed in one pass.
(2) PROVES IDEMPOTENCE FOR ALL CASES (including slash-slash) via the
closure lemma bodyIsFixedPoint:
stripLineComments (stripLineCommentBody cs)
= stripLineCommentBody cs
Proved by mutual induction with the main theorem
stripLineCommentsIdempotent. The two cases of bodyIsFixedPoint:
* c == nl: body returns nl :: stripLineComments rest. Outer strip
on that = nl :: stripLineComments (stripLineComments rest)
= nl :: stripLineComments rest [by main IH on rest]
= body output. ✓
* c /= nl: body returns sp :: stripLineCommentBody rest. Outer
strip on that = sp :: stripLineComments (stripLineCommentBody rest)
= sp :: stripLineCommentBody rest [by body IH on rest]
= body output. ✓
(3) NO believe_me / assert_total / holes. Idris2's totality checker
validates the mutual recursion: both functions consume strictly-
smaller inputs on each call.
NEW sanity-check sanityTwoComments specifically exercises the case
PR #111's broken model would have failed: two comments separated by a
newline, both correctly stripped.
PROOF-NEEDS.md updated:
- 'Completed Proofs' row for Stripping.idr updated to reflect the
multi-comment correction + slash-slash Qed.
- 'What Still Needs Proving' Layer-1.0 row collapsed: the
stripIsIdentityOnStrippedBody item is now Qed; only the
block / strings / composition / position-preservation slice
remains, recorded under issue #114.
Refs: PROOF-PROGRAMME.md row 1 (Layer 1.0); PR #111 (the foundation
this closes); issue #113 (the obligation); issue #114 (the next
Layer-1.0 slice — block + strings + composition + position-
preservation).1 parent 2fc73bd commit 1d4e263
2 files changed
Lines changed: 188 additions & 190 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| |||
0 commit comments