Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
14eb04d
Fix C1/C5/C7 audit issues: integer types, PEwrapI operator, PEundef o…
septract Feb 9, 2026
c69c1aa
Implement C2: CN pointer algebraic datatype in SMT encoding (42/46)
septract Feb 9, 2026
f8ffc6a
Fix C3 unit encoding, add pointer arithmetic elaboration (42→43/46)
septract Feb 9, 2026
e1f4600
Implement C4: struct SMT support, resource unpacking/repacking, tag r…
septract Feb 9, 2026
7f28e11
H4 fall-through defaults, H1 structMember type inference, C6 overflow…
septract Feb 9, 2026
f0f91f2
M2 representable/aligned constraints, H7 sym_eqs, SmtLib representabl…
septract Feb 9, 2026
883c438
Phase 7: Add 36 new CN tests (054-089) from CN suite, cn-tutorial, an…
septract Feb 9, 2026
cc283a2
Phase 7b: optional resource types, bitwise ops, CN builtins, % rem fi…
septract Feb 11, 2026
a38314e
CN test performance: add --nolibc/--libc-only flags, rename libc tests
septract Feb 11, 2026
e5911cf
Fix SmtLib for sizeof/structOffsets Except return types after rebase
septract Feb 11, 2026
5a47876
Normalize test_cn.sh output: one-line-per-test format, match test_int…
septract Feb 11, 2026
2458e79
H5: Inline SMT solver during type checking, with CN-aligned review fixes
septract Feb 12, 2026
c23763a
Switch SMT solver from Z3 to cvc5, fix inline solver parameter declar…
septract Feb 14, 2026
226445f
Fix nested struct resource repacking, add DIVERGES-FROM-CN/FIXME conv…
septract Feb 14, 2026
3ce7320
CN audit Wave 1: SMT fixes, simplification, derived constraints, alph…
septract Feb 19, 2026
b86e2b2
CN audit Wave 2: pointer memops, pexpr cases, ghost parameters
septract Feb 19, 2026
e950a7c
Implement SeqRMW type checking with lazy muCore param slot handling
septract Feb 19, 2026
9da903b
Ghost statement detection + symbol resolution + SMT preamble fix
septract Feb 20, 2026
4342960
CN audit Wave 3: loop invariants, global accesses, ghost params, arra…
septract Feb 20, 2026
86be956
CN audit Wave 4: ghost extract/focus, QPredicate alpha-renaming, simp…
septract Feb 21, 2026
b7b43e2
CN audit Wave 5: pointer ops, SMT completeness, representable/good (9…
septract Feb 21, 2026
bb089a5
CN audit Wave 6-7: alpha-renaming fix, 13 new tests (103/103)
septract Feb 21, 2026
4171618
CN audit Phase 2: fix 14 bugs, close 13 gaps, 11 quality improvements…
septract Feb 21, 2026
693b517
CN audit Phase 2b: simplifier context, fresh IDs, QPredicate coverage…
septract Feb 21, 2026
82daf38
Fail-never-guess audit: fix 8 silent error swallowing violations (102…
septract Feb 27, 2026
5bb8e5d
Fix loop invariant SMT bug: resolve constraints against output symbol…
septract Feb 27, 2026
350621a
WIP: uncommitted working-tree state at pre-wipe backup
septract Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,17 @@ cd lean && .lake/build/bin/cerblean_memtest # Run directly

**CN Verification Tests** (`make test-cn`):
```bash
make test-cn # Run integration tests on tests/cn/
make test-cn # Run all CN integration tests (nolibc + libc)
make test-cn-nolibc # Run integration tests (fast, --nolibc)
make test-cn-libc # Run libc-only tests (*.libc.* files)
make test-cn-unit # Run unit tests only (fast, no Cerberus)
./scripts/test_cn.sh --nolibc # Run tests without libc (skips *.libc.* tests)
./scripts/test_cn.sh # Run all tests in tests/cn/
./scripts/test_cn.sh /path/to/test.c # Run a specific test
./scripts/test_cn.sh --unit # Run unit tests only
```

CN test file conventions: `NNN-description.c` (pass), `NNN-description.fail.c` (expected fail), `NNN-description.smt-fail.c` (SMT-level fail). The `.fail.c` and `.smt-fail.c` suffixes auto-pass `--expect-fail`.
CN test file conventions: `NNN-description.c` (pass), `NNN-description.fail.c` (expected fail), `NNN-description.libc.fail.c` (expected-fail requiring libc, skipped with --nolibc), `NNN-description.smt-fail.c` (SMT-level fail). The `.fail.c` and `.smt-fail.c` suffixes auto-pass `--expect-fail`.

**Cerberus OCaml Code Coverage** (`scripts/test_coverage.sh`):
```bash
Expand Down Expand Up @@ -329,6 +332,58 @@ The ONLY acceptable reasons to modify a test:

**Backwards compatibility with previous versions of our own code is an ANTI-GOAL.** The ONLY source of truth is Cerberus and CN. If our implementation diverges, it is WRONG and must be fixed, even if it breaks tests, changes behavior, or invalidates proofs. Fix it immediately. There is no "deprecation period" for incorrect semantics.

### Marking Known Divergences: `DIVERGES-FROM-CN`

When our implementation intentionally diverges from CN or Cerberus (e.g., missing padding handling, simplified rollback), mark the code with a `DIVERGES-FROM-CN` comment. This makes divergences greppable and ensures they get revisited.

**Format**:
```lean
-- DIVERGES-FROM-CN: <short description of what CN does differently>
```

**Rules**:
- Every `DIVERGES-FROM-CN` must explain what CN does and how we differ
- The divergence must be **intentional and justified** (e.g., internally consistent simplification, feature not yet needed). If it's not justified, fix it instead of marking it
- Divergences that would cause **incorrect results** are NOT acceptable — those must be fixed immediately. `DIVERGES-FROM-CN` is only for cases where our behavior is correct but less complete than CN
- Periodically grep for `DIVERGES-FROM-CN` to audit and close gaps

**Example**:
```lean
-- DIVERGES-FROM-CN: CN's unpack_owned (pack.ml:113-124) also produces padding
-- resources (Owned<char[N]>(Uninit) at padding offsets). We only produce member
-- resources. Internally consistent since tryRepackStruct also skips padding.
let fieldResources := fields.filterMap fun (field : FieldDef) =>
```

### Marking Bugs Found During Audit: `FIXME`

When you spot a bug or incorrect behavior during an audit but can't fix it on the spot, mark it with `FIXME`. This is for things that are **actually wrong** — not intentional simplifications (use `DIVERGES-FROM-CN` for those).

**Format**:
```lean
-- FIXME: <what's wrong and why it matters>
```

**Rules**:
- `FIXME` means the code produces or could produce **incorrect results**. Fix ASAP
- Must explain what's wrong, not just flag the line
- If you can fix it now, fix it instead of tagging it
- Periodically grep for `FIXME` — the count should trend toward zero

**Distinction from `DIVERGES-FROM-CN`**:

| Tag | Meaning | Correct? | Action |
|-----|---------|----------|--------|
| `DIVERGES-FROM-CN` | Intentional, behavior correct but incomplete | Yes | Revisit when needed |
| `FIXME` | Bug or incorrect behavior | No | Fix ASAP |

**Example**:
```lean
-- FIXME: we compare Sym by id only, but CN uses digest+id (Sym.equal).
-- This could match the wrong symbol if two syms share an id but differ in digest.
if sym1.id == sym2.id then
```

### Always Use Build Targets for Testing
**Always use Makefile targets** (`make test`, `make test-cn`, etc.) rather than invoking test binaries directly.

Expand Down
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# C-to-Lean Project Makefile

.PHONY: all lean cerberus cerberus-setup cerberus-coverage cerberus-coverage-setup clean \
test test-unit test-memory test-cn test-cn-unit \
test test-unit test-memory test-cn test-cn-nolibc test-cn-libc test-cn-unit \
test-interp test-interp-full test-interp-ci test-interp-seq \
test-parser test-pp test-parser-quick test-pp-quick \
test-genproof test-verified verified-programs test-one \
Expand Down Expand Up @@ -96,9 +96,8 @@ clean:
# so most test targets don't need `lean` or `cerberus` as prerequisites.
# ------------------------------------------------------------------------------

# Run all quick tests (unit + memory + interp + genproof)
# NOTE: test-cn is excluded because CN is a prototype with known failures
test: test-unit test-memory test-interp test-interp-seq test-genproof
# Run all tests (unit, memory, interpreter in both modes, genproof, CN)
test: test-unit test-memory test-cn-unit test-interp test-interp-seq test-genproof test-cn

# Run exactly what CI runs (for local verification before pushing)
ci: test test-verified
Expand Down Expand Up @@ -139,6 +138,9 @@ test-genproof:
./scripts/test_genproof.sh --nolibc tests/minimal/001-return-literal.c
@echo "✓ GenProof pipeline test passed"

# TODO: add test-interp-libc target to run *.libc.c tests with libc in CI
# (currently only test-interp-full runs them, but it's not in the CI test target)

# Interpreter Tests (fast mode with --nolibc, skips *.libc.c tests)
test-interp:
./scripts/test_interp.sh --nolibc tests/minimal
Expand All @@ -165,10 +167,17 @@ test-interp-seq:
test-coverage: cerberus-coverage
./scripts/test_coverage.sh --no-build

# CN Tests
# test-cn: run integration tests on tests/cn/*.c (requires Cerberus)
# CN Tests (run both nolibc and libc-only, fail if either fails)
test-cn:
./scripts/test_cn.sh
$(MAKE) test-cn-nolibc; nolibc=$$?; $(MAKE) test-cn-libc; libc=$$?; exit $$(( nolibc || libc ))

# CN Tests (fast mode with --nolibc, skips *.libc.* tests)
test-cn-nolibc:
./scripts/test_cn.sh --nolibc

# CN Tests (with libc — runs only *.libc.* tests)
test-cn-libc:
./scripts/test_cn.sh --libc-only

# test-cn-unit: run unit tests only (fast, no Cerberus)
test-cn-unit:
Expand Down
Loading
Loading