Lean 4 fork for HoTT-compatible kernel extensions (Path types, transport, HITs). Maintained against upstream leanprover/lean4.
This PR is a follow up to #8055 and implements a Selector for `Std.Channel` in order to allow multiplexing using channels. There is one subtlety to the implementation: Suppose we are in a situation where we run `select` in a loop on two channels. One of the channels is always quiet while the other has data available occasionally (however not always as this would trigger the `tryFn` fast path and hide the issue). In this situation the select receivers that are enqueued on the silent channel would usually just remain there indefinitely as nothing ever happens, causing a memleak. To avoid this we want to make a channel select clean up after itself, even if it fails. In an imperative programming language we could implement the receive queue as a doubly linked list and simply make each receive select maintain a pointer to its element in the queue and then remove itself in `O(1)` upon failure. As that is not possible in Lean trivially we decided to go for another approach for now: simply filter the queue for selects that have failed in `unregisterFn`. While this approach is `O(n)` we expect the amount of receivers enqueued on a channel to not be terribly large and thus this to be a reasonably fast operation compared to the remaining overhead. If it ever ends up becoming an issue, we could switch to an approach that uses a `TreeMap` with numbered receivers instead at a certain wait queue size and go to `O(log(n))`. |
||
|---|---|---|
| .github | ||
| doc | ||
| images | ||
| nix | ||
| releases_drafts | ||
| script | ||
| src | ||
| stage0 | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .gitpod.Dockerfile | ||
| .gitpod.yml | ||
| .ignore | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| CODEOWNERS | ||
| CONTRIBUTING.md | ||
| flake.lock | ||
| flake.nix | ||
| lean-toolchain | ||
| lean.code-workspace | ||
| LICENSE | ||
| LICENSES | ||
| README.md | ||
| RELEASES.md | ||
This is the repository for Lean 4.
About
- Quickstart
- Homepage
- Theorem Proving Tutorial
- Functional Programming in Lean
- Documentation Overview
- Language Reference
- Release notes starting at v4.0.0-m3
- Examples
- External Contribution Guidelines
- FAQ
Installation
See Setting Up Lean.
Contributing
Please read our Contribution Guidelines first.
Building from Source
See Building Lean (documentation source: doc/make/index.md).