Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
e8c772b
add files
BoltonBailey Jan 14, 2026
efa6880
refactor
BoltonBailey Jan 14, 2026
946f4a3
remove listblank content
BoltonBailey Jan 14, 2026
0c3b432
clean up
BoltonBailey Jan 17, 2026
630ce61
claude build/switch to reduces API
BoltonBailey Jan 17, 2026
4587a74
claude: remove sorries
BoltonBailey Jan 17, 2026
35558b8
delete evals junk
BoltonBailey Jan 17, 2026
1ef6182
clean whitespace
BoltonBailey Jan 17, 2026
6a2d234
TM0 -> SingleTapeTM
BoltonBailey Jan 17, 2026
68c6ae4
generalize alphabet
BoltonBailey Jan 17, 2026
6cb8c86
move blowuplemma earlier
BoltonBailey Jan 17, 2026
33d74e8
Stmt API
BoltonBailey Jan 17, 2026
24bd6de
clean up reduction
BoltonBailey Jan 17, 2026
21fe238
More comments
BoltonBailey Jan 22, 2026
9b61c24
Merge branch 'main' of github.com:leanprover/cslib into single-tape-t…
BoltonBailey Jan 23, 2026
ed9474b
rename to `BiTape` and `StackTape`
BoltonBailey Jan 23, 2026
99d9df6
clean up docs
BoltonBailey Jan 23, 2026
e69b48e
Merge branch 'main' of github.com:leanprover/cslib into single-tape-t…
BoltonBailey Jan 23, 2026
6aee1d9
lake exe mk_all --module
BoltonBailey Jan 23, 2026
4b0e241
update StackTape description
BoltonBailey Jan 23, 2026
7092768
clean up bitape file
BoltonBailey Jan 23, 2026
0711013
use relatesInSteps API
BoltonBailey Jan 23, 2026
a6a1c23
revert ReductionSystem/Basic
BoltonBailey Jan 23, 2026
7d8557b
refactor computer
BoltonBailey Jan 23, 2026
b1384f7
improve variable names
BoltonBailey Jan 23, 2026
faca3ff
claude refactor out time from composition functionality
BoltonBailey Jan 23, 2026
435971c
add private to lemmas
BoltonBailey Jan 23, 2026
6426bc5
rename helper lemmas
BoltonBailey Jan 23, 2026
50b6131
Merge branch 'main' into single-tape-turing-machines
BoltonBailey Jan 23, 2026
bacefc5
claude: uniformize the helper lemmas
BoltonBailey Jan 23, 2026
664f62c
Merge branch 'single-tape-turing-machines' of github.com:BoltonBailey…
BoltonBailey Jan 23, 2026
1576498
clean up helpers
BoltonBailey Jan 23, 2026
e348d76
further trim helpers
BoltonBailey Jan 23, 2026
c5231d9
remove vanilla computable
BoltonBailey Jan 23, 2026
b191ee9
rename fields
BoltonBailey Jan 23, 2026
c9ac367
public import Cslib.Init
BoltonBailey Jan 23, 2026
9286128
add note
BoltonBailey Jan 23, 2026
2ab4751
correct cons and provide API
BoltonBailey Jan 25, 2026
ccd4034
clean up tape apis
BoltonBailey Jan 25, 2026
ba47f4f
add docstrings
BoltonBailey Jan 25, 2026
a387696
more doc linter
BoltonBailey Jan 25, 2026
1a77e7c
imrove docs
BoltonBailey Jan 25, 2026
3d639c2
revert whitespace
BoltonBailey Jan 25, 2026
d14d5ee
clean up lines
BoltonBailey Jan 25, 2026
8b06d4a
use variables
BoltonBailey Jan 25, 2026
f7b6bbb
golfs
BoltonBailey Jan 25, 2026
19ebc8c
more golfs
BoltonBailey Jan 26, 2026
1361553
add movement lemmas
BoltonBailey Jan 26, 2026
4335852
golf
BoltonBailey Jan 26, 2026
4da0154
more line golfing
BoltonBailey Jan 26, 2026
f220ae0
clean up docstring
BoltonBailey Jan 26, 2026
aad3692
namespaces
BoltonBailey Jan 26, 2026
36615f3
Update Cslib/Computability/Machines/SingleTapeTuring/Basic.lean
BoltonBailey Jan 30, 2026
90e6ac4
fix typeclass arg names
BoltonBailey Jan 30, 2026
f5b92e7
remove unneeded parens
BoltonBailey Jan 30, 2026
78733a8
use notation
BoltonBailey Jan 30, 2026
d7f384c
more bundled instances
BoltonBailey Jan 30, 2026
f5d0cfe
Update Cslib/Computability/Machines/SingleTapeTuring/Basic.lean
BoltonBailey Jan 30, 2026
b5e035f
golf
BoltonBailey Jan 30, 2026
c3858fe
reorder args
BoltonBailey Jan 30, 2026
e6a2746
move args before :=
BoltonBailey Jan 30, 2026
0746a77
Update Cslib/Computability/Machines/SingleTapeTuring/Basic.lean
BoltonBailey Jan 30, 2026
e356245
reorder proof
BoltonBailey Jan 30, 2026
9a08b4e
Update Cslib/Computability/Machines/SingleTapeTuring/Basic.lean
BoltonBailey Jan 30, 2026
9a2190e
Merge branch 'single-tape-turing-machines' of github.com:BoltonBailey…
BoltonBailey Jan 30, 2026
3329685
Stmt becomes structure
BoltonBailey Jan 30, 2026
76e7c6e
clean up docs
BoltonBailey Jan 30, 2026
f45d40e
add doc
BoltonBailey Jan 30, 2026
1c251fb
add comment
BoltonBailey Jan 30, 2026
82ed427
add documentation on design
BoltonBailey Jan 30, 2026
a03c551
Merge branch 'main' of github.com:leanprover/cslib into single-tape-t…
BoltonBailey Jan 30, 2026
5516a25
ipossilbe instances removed
BoltonBailey Jan 30, 2026
4944e7a
lake exe mk_all
BoltonBailey Jan 30, 2026
97308fa
lake exe mk_all --module
BoltonBailey Jan 30, 2026
7c097a6
grind annotations
BoltonBailey Jan 30, 2026
600e016
some more grind lemmas
BoltonBailey Jan 30, 2026
b4704d1
more grind annotations
BoltonBailey Jan 31, 2026
ee79f80
scoped grind
BoltonBailey Jan 31, 2026
de5ca7d
Multi-tape Turing machine.
crei Feb 2, 2026
f07cb72
define eval
crei Feb 2, 2026
27dd827
relates_eq_some
crei Feb 2, 2026
4fc2c1c
simplify
crei Feb 2, 2026
363a31c
Merge remote-tracking branch 'origin/main' into multi-tape-turing-mac…
crei Feb 2, 2026
9782a33
Finish eval proof
crei Feb 2, 2026
c3226c0
move_right_nth
crei Feb 2, 2026
9840eb6
move_int
crei Feb 2, 2026
be76f0f
move until
crei Feb 2, 2026
e0b12b6
progress
crei Feb 2, 2026
65c4a32
stacktape_ext
crei Feb 2, 2026
df08110
move_int_move_int
crei Feb 3, 2026
a59a09c
sorry proof
crei Feb 3, 2026
dacb2eb
Merge remote-tracking branch 'origin/main' into multi-tape-turing-mac…
crei Feb 20, 2026
0d0d604
Allow warnings.
crei Feb 20, 2026
89fc03e
Fix imports.
crei Feb 20, 2026
269ed49
Addition and multiplication routines
crei Feb 21, 2026
949a0ef
feat: add background and orientation information on how to contribute…
fmontesi Feb 20, 2026
6fc3949
feat: generalize `TimeM` to arbitrary cost types providing `AddZero` …
eric-wieser Feb 21, 2026
e4c2347
Simplify semantics of succ.
crei Feb 24, 2026
d693e99
Always-halting Turing machines.
crei Feb 24, 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
4 changes: 2 additions & 2 deletions .github/workflows/lean_action_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: leanprover/lean-action@v1
with:
build-args: "--wfail --iofail"
# with:
# build-args: "--iofail"
- name: "lake exe mk_all --check --module"
run: |
set -e
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ jobs:
with:
script: |
const msg = context.payload.pull_request? context.payload.pull_request.title : context.payload.merge_group.head_commit.message;
console.log(`Message: ${msg}`)
if (!/^(ci|feat|fix|doc|style|refactor|test|chore|perf)(\(.*\))?: .*[^.]($|\n\n)/.test(msg)) {
core.setFailed('PR title does not follow the Commit Convention (https://leanprover.github.io/lean4/doc/dev/commit_convention.html).');
}
252 changes: 251 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
**Table of Contents**

- [Contributing to CSLib](#contributing-to-cslib)
- [Contribution model](#contribution-model)
- [Style and documentation](#style-and-documentation)
- [Variable names](#variable-names)
- [Proof style and golfing :golf:](#proof-style-and-golfing-golf)
- [Notation](#notation)
- [Documentation](#documentation)
- [Design principles](#design-principles)
- [Reuse](#reuse)
- [Continuous Integration](#continuous-integration)
- [Pull Request Titles](#pull-request-titles)
- [Testing](#testing)
- [Linting](#linting)
- [Imports](#imports)
- [Getting started](#getting-started)
- [Before you start: coordination to avoid rework](#before-you-start-coordination-to-avoid-rework)
- [Finding tasks](#finding-tasks)
- [Working groups](#working-groups)
- [Proposing a new working group](#proposing-a-new-working-group)
- [Examples of welcome contributions](#examples-of-welcome-contributions)
- [Pillar 1: Formalising Computer Science in Lean](#pillar-1-formalising-computer-science-in-lean)
- [Algorithms and Data Structures](#algorithms-and-data-structures)
- [Verified data structures with time complexity (Batteries + Time Monad)](#verified-data-structures-with-time-complexity-batteries--time-monad)
- [Graph algorithms and graph foundations](#graph-algorithms-and-graph-foundations)
- [APIs for algorithmic paradigms](#apis-for-algorithmic-paradigms)
- [Programming Languages, Models of Computation and Interaction](#programming-languages-models-of-computation-and-interaction)
- [Logics](#logics)
- [Semantics and program equivalences](#semantics-and-program-equivalences)
- [Semantic frameworks](#semantic-frameworks)
- [Program equivalences](#program-equivalences)
- [Pillar 2: Code reasoning](#pillar-2-code-reasoning)
- [Contributing Boole examples](#contributing-boole-examples)
- [Boole specifications](#boole-specifications)
- [Issue labels for Boole](#issue-labels-for-boole)
- [Front ends for Boole](#front-ends-for-boole)
- [Back ends for Boole](#back-ends-for-boole)
- [Implementing verification paradigms](#implementing-verification-paradigms)
- [Lean automation](#lean-automation)
- [The role of AI](#the-role-of-ai)


# Contributing to CSLib

It's great that you're interested in contributing to CSLib! :tada:
Expand All @@ -12,9 +55,11 @@ Each PR needs to be approved by at least one relevant maintainer. You can read t

If you are adding something new to CSLib and are in doubt about it, you are very welcome to contact us on the [Lean prover Zulip chat](https://leanprover.zulipchat.com/).

If you are unfamiliar with CSLib as a whole and want to understand how to get started, please see [Getting started](#getting-started).

# Style and documentation

We generally follow the [mathlib style for coding and documentation](https://leanprover-community.github.io/contribute/style.html), so please read that as well. Some things worth mentioning and conventions specific to this library are explained next.
We generally follow the [mathlib style for coding and documentation](https://leanprover-community.github.io/contribute/style.html), so please read that as well. Some things worth mentioning and conventions specific to CSLib are explained next.

## Variable names

Expand Down Expand Up @@ -79,3 +124,208 @@ CSLib uses a number of linters, mostly inherited from Batteries and Mathlib. The

There is a also a test that [Cslib.lean](/Cslib.lean) imports all files. You can ensure this by
running `lake exe mk_all --module` locally, which will make the required changes.

# Getting started

CSLib is a community effort. To understand its scope and vision, please read the [CSLib whitepaper](https://arxiv.org/abs/2602.04846).
For an overview of its technical approach to reuse, continuous integration, and proof automation, please read the [Computer Science as Infrastructure paper](https://arxiv.org/abs/2602.15078).

Key project links include:

- Website: https://www.cslib.io/
- GitHub issues + PRs: https://github.com/leanprover/cslib
- Open contribution board: https://github.com/leanprover/cslib/projects?query=is%3Aopen
- Community discussion (Lean Community Zulip): https://leanprover.zulipchat.com/
- CSLib channels are the recommended place to coordinate and ask questions.

## Before you start: coordination to avoid rework

Most contributions are welcome as straightforward PRs. However, **for any major development**, it is strongly recommended to discuss first on Zulip (or via a GitHub issue) so that the scope, dependencies, and placement in the library are aligned.

Examples of work that should be discussed first:

- New cross-cutting abstractions / typeclasses / notation schemes.
- New foundational frameworks.
- Major refactorings.
- New frontend or backend components for CSLib's verification infrastructure.
- Proposals for new working groups (see below).

## Finding tasks

If you are looking for a concrete starting point, please look at:

- The CSLib Zulip channels.
- Our [GitHub issues](https://github.com/leanprover/cslib/issues).


## Working groups

CSLib is structured to support multiple topic-focused efforts. We organise sustained work via **working groups** (informal or formal), which typically have a topic scope and a Zulip topic/channel for coordination.

If you want to **join** a working group, start by posting on the relevant CSLib Zulip channel describing your background and what you want to contribute.

### Proposing a new working group

If you want to propose a new working group, write a short proposal (Zulip message or GitHub issue is fine) that includes:

- **Topic**: What do you want to do?
- **Execution plan**: What is your execution plan?
- **Collaborators**: If some group or people are already planning to work on the topic, write them.

The goal is to keep proposals lightweight while ensuring CSLib remains coherent and reusable.

## Examples of welcome contributions

Here you can find some (non-exhaustive) examples of topics looking for contributions.

### Pillar 1: Formalising Computer Science in Lean

Pillar 1 is about the formalisation of Computer Science as reusable infrastructure. This includes, but is not limited to, models of computation, semantics, logics, algorithms, data structures, metatheory, and supporting mathematics.

#### Algorithms and Data Structures

##### Verified data structures with time complexity (Batteries + Time Monad)

A concrete and high-impact track is to verify implementations and time complexity bounds for [data structures from Batteries](https://github.com/leanprover-community/batteries/tree/main/Batteries/Data).

Examples of candidate targets:

- List and Array developments
- Binary heap
- Binomial heap
- Union find
- Red-black trees

##### Graph algorithms and graph foundations

- Foundational definitions (directed/undirected simple graphs, etc.)
- Core algorithms and their correctness proofs:
- DFS, topological sorting, SCC
- shortest paths, APSP
- max-flow
- minimum spanning tree
- spanners
- Gomory–Hu trees

##### APIs for algorithmic paradigms

Reusable APIs that support many concrete algorithms.

- Divide-and-conquer
- Master theorem
- Dynamic programming
- generic DP API patterns
- quadrangle inequality (Yao ’80)
- SMAWK algorithm

#### Programming Languages, Models of Computation and Interaction

- Automata (on finite and infinite words)
- Choreographic languages
- Lambda calculi
- Petri Nets
- Process calculi, like CCS and pi-calculus
- Frameworks for language encodings (compilers, etc.).
- Proof techniques for the correctness of encodings.

#### Logics

We aim at formalising a number of logics of different kinds, including linear logic, modal logics, etc.

We welcome proofs of logical equivalences and metatheoretical results such as identity expansion, cut elimiation, etc.

Examples of interesting logics include:
- Linear logic
- Temporal logic
- Separation logic

#### Semantics and program equivalences

##### Semantic frameworks
- Denotational semantics
- Operational semantics, including results on labelled transition systems and reduction systems

##### Program equivalences

- Bisimulation
- May/Must testing
- Trace equivalence

### Pillar 2: Code reasoning

Pillar 2 is about infrastructure for reasoning about code in mainstream programming languages via intermediate representations, VC generation, and automation.

We are interested in collecting a large number of programs in Boole (see the [CSLib whitepaper](https://arxiv.org/abs/2602.04846) for Boole's vision).

You can try the Boole sandbox examples at <https://github.com/leanprover/cslib/tree/Boole-sandbox/Cslib/Languages/Boole>.

#### Contributing Boole examples

We are interested in collecting a large number of programs in Boole.

If you'd like to contribute examples, please propose and coordinate on the [Zulip channel for code reasoning](https://leanprover.zulipchat.com/#narrow/channel/563135-CSLib.3A-Code-Reasoning) first (especially if the example requires new features).

We separate Boole examples into two directories:

- examples that work with the current Boole back end
- examples that are broken or contain features not yet implemented

Contributions to both sets are valuable: working examples demonstrate capabilities; 'broken' examples identify missing features and bottlenecks.

#### Boole specifications

Currently, Boole specifications are based on Strata Core: <https://strata-org.github.io/Strata/>

A key long-term goal is to support specifications that reference arbitrary Lean concepts, especially those formalised as part of CSLib Pillar 1. Designing this cleanly within the Strata framework is a challenging and valuable project.

#### Issue labels for Boole

If you have feature requests for Boole, file an issue with title `feat(Boole): <feature request title here>`.

For bugs, errors, or other issues, file an issue with label `Boole`.

#### Front ends for Boole

We are interested in developing translations from real-world programming languages to Boole.

- Prototype translations are welcome to explore feasibility and identify design constraints.
- If you want to propose a translation for inclusion in CSLib, coordinate on Zulip.

We expect initial translations will be ad hoc and trusted. The eventual goal is to formalize the semantics of front ends and prove (as a Lean metatheorem) that translations preserve semantics.

#### Back ends for Boole

We are interested in building Boole back ends that take as input Boole programs with formal specifications and construct proof obligations in Lean, which, if proved, ensure that the program meets its specification.

- A prototype translation based on a deep embedding in Strata exists, but is not fully foundational.
- A major long-term goal is to prove Lean meta-theorems showing that proving the verification conditions ensures correctness of the Boole program.

Alternative directions are welcome, e.g.:

- Exploring a shallow embedding approach
- Leveraging Loom for more foundational pipelines

A back end for **time complexity analysis** is also of interest.

#### Implementing verification paradigms

The formal methods community has a wide range of verification techniques that could be valuable in the Boole ecosystem, e.g.:

- proof by refinement
- techniques for program equivalence
- other deductive verification paradigms

#### Lean automation

Since Boole back ends reduce correctness questions to Lean conjectures, automation is central.

We already rely on key techniques such as `grind` and `lean-smt`. Additional work on automation for conjectures generated from Boole is welcome, including domain-specific automation that remains performant and readable.

#### The role of AI

There are two primary areas where generative AI can help:

- generating/refining specifications (at the front-end or Boole level)
- helping to prove Lean conjectures

Other creative uses of AI are welcome, but contributions should remain reviewable and maintainable.
22 changes: 22 additions & 0 deletions Cslib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ public import Cslib.Computability.Languages.Language
public import Cslib.Computability.Languages.OmegaLanguage
public import Cslib.Computability.Languages.OmegaRegularLanguage
public import Cslib.Computability.Languages.RegularLanguage
public import Cslib.Computability.Machines.MultiTapeTuring.AddRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.Basic
public import Cslib.Computability.Machines.MultiTapeTuring.CopyRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.EqualRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.GraphReachability
public import Cslib.Computability.Machines.MultiTapeTuring.HeadStats
public import Cslib.Computability.Machines.MultiTapeTuring.IsZeroRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.IteCombinator
public import Cslib.Computability.Machines.MultiTapeTuring.ListEncoding
public import Cslib.Computability.Machines.MultiTapeTuring.LoopCombinator
public import Cslib.Computability.Machines.MultiTapeTuring.MoveRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.MulRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.PopRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.PushRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.SequentialCombinator
public import Cslib.Computability.Machines.MultiTapeTuring.SuccRoutine
public import Cslib.Computability.Machines.MultiTapeTuring.TapeExtension
public import Cslib.Computability.Machines.MultiTapeTuring.WhileCombinator
public import Cslib.Computability.Machines.MultiTapeTuring.WithTapes
public import Cslib.Computability.Machines.SingleTapeTuring.Basic
public import Cslib.Computability.URM.Basic
public import Cslib.Computability.URM.Computable
public import Cslib.Computability.URM.Defs
Expand All @@ -39,6 +59,7 @@ public import Cslib.Foundations.Combinatorics.InfiniteGraphRamsey
public import Cslib.Foundations.Control.Monad.Free
public import Cslib.Foundations.Control.Monad.Free.Effects
public import Cslib.Foundations.Control.Monad.Free.Fold
public import Cslib.Foundations.Data.BiTape
public import Cslib.Foundations.Data.FinFun
public import Cslib.Foundations.Data.HasFresh
public import Cslib.Foundations.Data.Nat.Segment
Expand All @@ -50,6 +71,7 @@ public import Cslib.Foundations.Data.OmegaSequence.Temporal
public import Cslib.Foundations.Data.RelatesInSteps
public import Cslib.Foundations.Data.Relation
public import Cslib.Foundations.Data.Set.Saturation
public import Cslib.Foundations.Data.StackTape
public import Cslib.Foundations.Lint.Basic
public import Cslib.Foundations.Semantics.FLTS.Basic
public import Cslib.Foundations.Semantics.FLTS.FLTSToLTS
Expand Down
10 changes: 5 additions & 5 deletions Cslib/Algorithms/Lean/MergeSort/MergeSort.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public import Mathlib.Data.Nat.Log
# MergeSort on a list

In this file we introduce `merge` and `mergeSort` algorithms that returns a time monad
over the list `TimeM (List α)`. The time complexity of `mergeSort` is the number of comparisons.
over the list `TimeM (List α)`. The time complexity of `mergeSort` is the number of comparisons.

--
## Main results
Expand All @@ -34,8 +34,8 @@ namespace Cslib.Algorithms.Lean.TimeM
variable {α : Type} [LinearOrder α]

/-- Merges two lists into a single list, counting comparisons as time cost.
Returns a `TimeM (List α)` where the time represents the number of comparisons performed. -/
def merge : List α → List α → TimeM (List α)
Returns a `TimeM (List α)` where the time represents the number of comparisons performed. -/
def merge : List α → List α → TimeM (List α)
| [], ys => return ys
| xs, [] => return xs
| x::xs', y::ys' => do
Expand All @@ -48,8 +48,8 @@ def merge : List α → List α → TimeM (List α)
return (y :: rest)

/-- Sorts a list using the merge sort algorithm, counting comparisons as time cost.
Returns a `TimeM (List α)` where the time represents the total number of comparisons. -/
def mergeSort (xs : List α) : TimeM (List α) := do
Returns a `TimeM (List α)` where the time represents the total number of comparisons. -/
def mergeSort (xs : List α) : TimeM (List α) := do
if xs.length < 2 then return xs
else
let half := xs.length / 2
Expand Down
Loading