Skip to content

feat: add 12 CS algorithm implementations with correctness proofs#383

Open
brando90 wants to merge 12 commits intoleanprover:mainfrom
brando90:feat/graph-dfs
Open

feat: add 12 CS algorithm implementations with correctness proofs#383
brando90 wants to merge 12 commits intoleanprover:mainfrom
brando90:feat/graph-dfs

Conversation

@brando90
Copy link

@brando90 brando90 commented Mar 2, 2026

Summary

Adds 12 formally verified CS algorithm implementations ported from the VeriBench benchmark to CSLiB format. All proofs are complete (zero sorry), all tests use decide (not native_decide). All files pass lake build, lint-style, and mk_all.

Sorting (6 files)

  • InsertionSort: sorted, permutation, length proofs
  • BubbleSort: permutation, length, fixed-point proofs
  • SelectionSort: sorted, permutation, length proofs
  • QuickSort: sorted, permutation, length proofs (fuel-based with partition)
  • CountingSort: sorted, permutation, length proofs (via count characterization)
  • HeapSort: permutation, length proofs (fuel-based with findLargest/heapify)

Graph (3 files)

  • DFS: reachability soundness and completeness proofs
  • BFS: shortest-path soundness proof
  • Dijkstra: self-distance theorem, weighted path definition

Search (1 file)

  • BinarySearch: found-element soundness proof

Dynamic Programming (2 files)

  • LCS: sublist proofs, length bounds, self-LCS
  • EditDistance: reflexivity, nil cases, upper bound

Test plan

  • All 12 files compile with lake build
  • All decide tests pass
  • lake exe lint-style passes
  • lake exe mk_all --module succeeds

🤖 Generated with Claude Code

…eteness proofs

Add depth-first search on directed adjacency-list graphs with:
- `dfsAux`/`dfs` implementation with fuel-based termination
- `Reachable` inductive predicate for graph reachability
- `dfs_soundness`: dfs returns true → target is reachable
- `ReachableAvoiding` + `dfsAux_complete_avoiding`: completeness for simple paths
- Unit tests on small graphs verified via `decide`

Adapted from the VeriBench benchmark.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
brando90 and others added 11 commits March 1, 2026 23:31
Add breadth-first search on directed adjacency-list graphs with:
- `bfsAux`/`bfs` returning shortest distance as `Option Nat`
- `IsPath` inductive predicate for directed walks with path list
- `IsPath.trans`/`IsPath.snoc` for path composition
- `bfs_soundness`: BFS returns `some d` → a path of length `d` exists
- Queue invariant `QueueInv` tracking path witnesses through BFS loop
- Unit tests verified via `decide`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- `binarySearchAux`/`binarySearch` with fuel-based termination
- `binarySearch_found`: returned index points to target element
- `binarySearch_bounds`: returned index is within array bounds
- Unit tests verified via `decide`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oofs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves sorted output, permutation preservation, and length preservation
via extractMin properties (minimum bound, permutation, length decrease).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves sorted output, permutation preservation, and length preservation
via partition properties (element bounds, permutation, length).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves sorted output, permutation preservation (via count equality),
and length preservation using buildSorted and findMax properties.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves sublist of both inputs, length bounds, and self-LCS identity
via fuel-based induction on the LCS computation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proves reflexivity (self-distance is 0), empty list properties,
and upper bound (distance ≤ sum of lengths) via fuel-based induction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oofs

Implements fuel-based Dijkstra's algorithm on weighted adjacency-list graphs.
Includes extractMin, dijkstraAux, dijkstra, IsWeightedPath inductive definition,
weighted_path_refl, and dijkstra_start_self theorem. All proofs complete (no sorry).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements fuel-based heap sort on lists of natural numbers with findLargest,
heapify, buildMaxHeap, and heapSortAux. Proves swap_perm via count_set,
heapSort_perm and heapSort_length. All proofs complete (no sorry).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@brando90 brando90 changed the title feat(Algorithms): add DFS graph reachability with soundness and completeness proofs feat: add 12 CS algorithm implementations with correctness proofs Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant