Commit graph

55 commits

Author SHA1 Message Date
Markus Himmel
9402c307fe
chore: reorganize Init imports around strings (#10289)
This PR reorganizes the import hierarchy so that
`Init.Data.String.Basic` can import `Init.Data.UInt.Bitwise` and
`Init.Data.Array.Lemmas`.
2025-09-07 17:09:14 +00:00
Marc Huisinga
7ba0ae1f72
feat: improve auto-completion performance (#10249)
This PR speeds up auto-completion by a factor of ~3.5x through various
performance improvements in the language server. On one machine, with
`import Mathlib`, completing `i` used to take 3200ms and now instead
yields a result in 920ms.

Specifically, the following improvements are made:
- The watchdog process no longer de-serializes and re-serializes most
messages from the file worker before passing them on to the user - a
fast partial de-serialization procedure is now used to determine whether
the message needs to be de-serialized in full or not.
- `escapePart` is optimized to perform better on ASCII strings that do
not need escaping.
- `Json.compress` is optimized to allocate fewer objects.
- A faster JSON compression specifically for completion responses is
implemented that skips allocating `Json` altogether.
- The JSON compression has been moved to the task where we convert a
request response to `Json` so that converting to a string won't block
the output task of the FileWorker and so the `Json` value is not marked
as multi-threaded when we compress is, which drastically increases the
cost of reference-counting.
- The JSON representation of the `data?` field of each completion item
is optimized.
- Both the completion kind and the set of completion tags for each
imported completion item is now cached.
- The filtering of duplicate completion items is optimized.

Other adjustments:
- `LT UInt8` and `LE UInt8` are moved to Prelude so that they can be
used in `Init.Meta` for the name part escaping fast path.
- `Array.usize` is exposed since it was marked as `@[simp]`.
2025-09-05 08:55:49 +00:00
Sebastian Ullrich
09a5b34931
feat: make private the default in module (#9044)
This PR adjusts the experimental module system to make `private` the
default visibility modifier in `module`s, introducing `public` as a new
modifier instead. `public section` can be used to revert the default for
an entire section, though this is more intended to ease gradual adoption
of the new semantics such as in `Init` (and soon `Std`) where they
should be replaced by a future decl-by-decl re-review of visibilities.
2025-06-28 16:30:53 +00:00
Sebastian Ullrich
569e46033b
feat: do not export private declarations (#8337)
This PR adjusts the experimental module system to not export any private
declarations from modules.

Fixes #5002
2025-06-02 08:01:08 +00:00
Sebastian Ullrich
01dbbeed99
feat: do not export def bodies by default (#8221)
This PR adjusts the experimental module system to not export the bodies
of `def`s unless opted out by the new attribute `@[expose]` on the `def`
or on a surrounding `section`.

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
2025-05-15 12:16:54 +00:00
Sebastian Ullrich
7feb583b9e
feat: enable experimental module system in Init (#8047) 2025-04-23 17:21:33 +00:00
Rob23oba
575e0307bf
chore: fix naming of several theorems (#7499)
This PR fixes the spelling of several theorems to adhere to the naming
convention.

Note: The changes here were found using [a
tool](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/automatic.20spelling.20generation.20.26.20comparison/with/505770987).
2025-04-04 10:52:52 +00:00
David Thrane Christiansen
fa2d28e2da
doc: docstring details (#7711)
This PR adds the last few missing docstrings that appear in the manual.
2025-03-28 22:30:53 +00:00
Mac Malone
a8656c5812
feat: generalize panic to Sort (#6333)
This PR generalizes the panic functions to a type of `Sort u` rather
than `Type u`. This better supports universe polymorphic types and
avoids confusing errors.

An minimal (but somewhat contrived) example of such a confusing error
is:

```lean
/-
stuck at solving universe constraint
  ?u.59+1 =?= max 1 ?u.7
while trying to unify
  Subtype.{?u.7} P : Sort (max 1 ?u.7)
with
  Subtype.{?u.7} P : Sort (max 1 ?u.7)
-/
def assertSubtype! {P : α → Prop} [Inhabited (Subtype P)] (a : α) [Decidable (P a)] : Subtype P := -- errors on :=
  if h : P a then 
    ⟨a, h⟩ 
  else 
    panic! "Property not satisified"
```
2024-12-15 21:36:45 +00:00
Sebastian Ullrich
86f303774a
chore: harden markPersistent uses (#6257)
This API may or may not have been a footgun, better to be safe than
`sorry`
2024-11-29 14:33:33 +00:00
Sebastian Ullrich
5f1ff42a15
fix: Runtime.markPersistent is unsafe (#6209)
This PR documents under which conditions `Runtime.markPersistent` is
unsafe and adjusts the elaborator accordingly
2024-11-27 13:32:05 +00:00
Leonardo de Moura
f60721bfbd
feat: add some low level helper APIs (#4778) 2024-07-17 20:12:05 +00:00
Joe Hendrix
0963f3476c
chore: extend GetElem with getElem! and getElem? (#3694)
This makes changes to the `GetElem` class so that it does not lead to
unnecessary overhead in container like `RBMap`.

The changes are to:
1. Make `getElem?` and `getElem!` part of the `GetElem` class so they
can be overridden in instances.
2. Introduce a `LawfulGetElem` class that contains correctness theorems
for `getElem?` and `getElem!` using the original definitions.
3. Reorganize definitions (e.g, by moving `GetElem` out of
`Init.Prelude`) so that the `GetElem` changes are feasible.
4. Provide `LawfulGetElem` instances to complement all existing
`GetElem` instances in Lean core.

To reduce the size of the PR, this doesn't do the work of providing new
`GetElem` instances for `RBMap`, `HashMap` etc. That will be done in a
separate PR (#3688) that depends on this.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-03-28 01:42:00 +00:00
Sebastian Ullrich
2f35651308 perf: leak environments not freed before process exit 2023-11-14 17:33:04 +01:00
Sebastian Ullrich
62dc8d7308 feat: Runtime.markMultiThreaded/Persistent 2023-11-14 17:33:04 +01:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
Leonardo de Moura
81abf49196 chore: avoid many copies of the panic message "index out of bounds" 2022-10-13 18:42:52 -07:00
Sebastian Ullrich
af7f5aa2a0 feat: dbgStackTrace 2022-08-26 20:52:51 -07:00
E.W.Ayers
f52a1bd37c doc: JSON-RPC 2022-08-26 20:49:57 -07:00
E.W.Ayers
5611620d3a dov: explanation of why pointers aren't sound. 2022-08-26 20:49:57 -07:00
Leonardo de Moura
16d6f13eed chore: fix warnings 2022-08-04 16:05:09 -07:00
Leonardo de Moura
5df588cbbf chore: remove unnecessary annotations 2022-08-02 05:42:53 -07:00
Leonardo de Moura
0156b59ef1 chore: enforce naming convention 2022-08-01 09:58:11 -07:00
Mario Carneiro
f6211b1a74
chore: convert doc/mod comments from /- to /--//-! (#1354) 2022-07-22 12:05:31 -07:00
Gabriel Ebner
eda3eae18e perf: implement Expr.update* in Lean 2022-07-19 05:55:13 -07:00
Leonardo de Moura
881589fc46 chore: remove parser workarounds 2022-07-09 16:42:39 -07:00
Leonardo de Moura
e4b358a01e refactor: prepare to elaborate a[i] notation using typeclasses 2022-07-09 15:24:22 -07:00
Sebastian Ullrich
897a5de6ac chore: revert some questionable signature changes 2022-06-07 16:37:45 -07:00
Sebastian Ullrich
ae7b895f7a refactor: unname some unused variables 2022-06-07 16:37:45 -07:00
Leonardo de Moura
a821dcbff2 chore: enforce naming convention for theorems
see issue #402

fix: `ElabTerm.lean`
2021-08-07 12:48:38 -07:00
Leonardo de Moura
f4a7ffd8c8 chore: fix codebase and tests 2021-06-29 17:14:52 -07:00
Leonardo de Moura
cca3bad0bb feat: add Prelude.lean
`Prelude.lean` has no dependencies, and
at the end of `Prelude`, the `syntax` and `macro` commands are operational.
2020-11-10 18:08:18 -08:00
Leonardo de Moura
7f364feeb5 chore: add Classical.lean, Equivalence, and cleanup 2020-11-10 14:55:34 -08:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
7e244686e9 chore: remove old notation 2020-10-26 09:16:51 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
7030dc91f2 chore: move to new frontend 2020-10-23 12:50:03 -07:00
Leonardo de Moura
749e2063cf feat: add interpolated string for toString 2020-10-09 14:38:24 -07:00
Leonardo de Moura
ba4fdce508 feat: expand helper macros 2020-09-10 14:25:07 -07:00
Sebastian Ullrich
0f7f49aa06 feat: dbgTraceVal 2020-08-06 09:26:48 -07:00
Leonardo de Moura
33a10130cf chore: fix stdlib 2020-05-12 15:02:03 -07:00
Leonardo de Moura
6ad0c2cc18 feat: simplify unsafeCast 2020-03-14 13:10:56 -07:00
Leonardo de Moura
b379bca28b chore: rename PtrEqResult.yes ==> PtrEqResult.yesEqual 2020-03-02 08:29:49 -08:00
Leonardo de Moura
0f8b59eed7 fix: typo Prop => Type 2020-02-29 11:22:17 -08:00
Leonardo de Moura
684554e979 feat: add PtrEqResult 2020-02-29 11:00:50 -08:00
Leonardo de Moura
94cfcbbefe chore: withPtrEqSubsingleton ==> withPtrEqResult 2020-02-29 10:12:06 -08:00
Leonardo de Moura
d511ddfa9e feat: add SemiDeciable and withPtrEqSubsingleton 2020-02-29 09:50:31 -08:00
Leonardo de Moura
cca90b5f9f chore: simplify withPtrEqDecEq 2020-02-27 11:45:02 -08:00
Leonardo de Moura
1c8baa0198 feat: add withPtrEqDecEq (version of withPtrEq for implementing decidable equality)
cc @dselsam
2020-02-15 16:12:09 -08:00
Leonardo de Moura
3ebb4e76ee feat: more general withPtrEq 2020-02-15 15:53:30 -08:00