Commit graph

256 commits

Author SHA1 Message Date
Sebastian Ullrich
425bebe99e
chore: further split libleanshared on Windows to avoid symbol limit (#10136)
Co-authored-by: Markus Himmel <markus@himmel-villmar.de>
2025-08-26 16:01:57 +00:00
Cameron Zwarich
b8fa6f17ee
fix: make lcAny-producing arrow types lower to tobj rather than obj (#9972)
This PR fixes an issue when running Mathlib's `FintypeCat` as code,
where an erased type former is passed to a polymorphic function. We were
lowering the arrow type to`object`, which conflicts with the runtime
representation of an erased value as a tagged scalar.
2025-08-18 22:18:26 +00:00
Kim Morrison
6e06978961
chore: remove >6 month old deprecations (#9640) 2025-08-05 02:29:15 +00:00
Cameron Zwarich
81740da50a
fix: avoid caching uses of never_extract constants in toLCNF (#8956)
This PR changes `toLCNF` to stop caching translations of expressions
upon seeing an expression marked `never_extract`. This is more
coarse-grained than it needs to be, but it is difficult to do any
better, as the new compiler's `Expr` cache is based on structural
identity (rather than the pointer identity of the old compiler).

The newly added `tests/compiler/never_extract.lean` is also converted
into a `run` tests, because during development I found the order of the
output to `stderr` to be a bit finicky. The reason for making it a
`compiler` test in the first place is that closed term decls work
slightly differently between native code and the interpreter, and it
would be good to test both, but we already have separate tests for
`never_extract` and closed term extraction.

Fixes #8944.
2025-06-24 02:04:56 +00:00
Cameron Zwarich
24cbd4efbe
fix: correctly handle never_extract attribute in LCNF CSE (#8952)
This PR fixes the handling of the `never_extract` attribute in the
compiler's CSE pass. There is an interesting debate to be had about
exactly how hard the compiler should try to avoid duplicating anything
that transitively uses `never_extract`, but this is the simplest form
and roughly matches the check in the old compiler (although due to
different handling of local function decls in the two compilers, the
consequences might be slightly different).

This gets half of the way to #8944.
2025-06-23 23:03:10 +00:00
Cameron Zwarich
8019c6cc32
chore: add .dSYM files (Mac debug symbols) to tests .gitignore files (#8771) 2025-06-13 15:27:46 +00:00
Cameron Zwarich
3ccc9ca7ac
fix: remove incorrect strictOr/strictAnd optimizations (#8594)
This PR removes incorrect optimizations for strictOr/strictAnd from the
old compiler, along with deleting an incorrect test. In order to do
these optimizations correctly, nontermination analysis is required.
Arguably, the correct way to express these optimizations is by exposing
the implementation of strictOr/strictAnd to a nontermination-aware phase
of the compiler, and then having them follow from more general
transformations.
2025-06-02 16:14:56 +00:00
Cameron Zwarich
575b4786f9
feat: optimize lean_nat_shiftr for scalars (#8268)
This PR optimizes lean_nat_shiftr for scalar operands. The new compiler
converts Nat divisions into right shifts, so this now shows up as hot in
some profiles.
2025-05-11 01:39:59 +00:00
Henrik Böving
8e9da7a1bc
feat: wait on dedicated tasks after main is finished (#7958)
This PR ensures that after `main` is finished we still wait on dedicated
tasks instead of exiting forcefully. If users wish to violently kill
their dedicated tasks at the end of main instead they can run
`IO.Process.exit` at the end of `main` instead.
2025-04-14 11:53:54 +00:00
Kim Morrison
1ce7047bf5
feat: cleanup of get and back functions on List/Array (#7059)
This PR moves away from using `List.get` / `List.get?` / `List.get!` and
`Array.get!`, in favour of using the `GetElem` mediated getters. In
particular it deprecates `List.get?`, `List.get!` and `Array.get?`. Also
adds `Array.back`, taking a proof, matching `List.getLast`.
2025-02-17 01:43:45 +00:00
Leonardo de Moura
27df5e968a
feat: Simp.Config.implicitDefEqProofs (#4595)
This PR implements `Simp.Config.implicitDefEqsProofs`. When `true`
(default: `true`), `simp` will **not** create a proof term for a
rewriting rule associated with an `rfl`-theorem. Rewriting rules are
provided by users by annotating theorems with the attribute `@[simp]`.
If the proof of the theorem is just `rfl` (reflexivity), and
`implicitDefEqProofs := true`, `simp` will **not** create a proof term
which is an application of the annotated theorem.

The default setting does change the existing behavior. Users can use
`simp -implicitDefEqProofs` to force `simp` to create a proof term for
`rfl`-theorems. This can positively impact proof checking time in the
kernel.

This PR also fixes an issue in the `split` tactic that has been exposed
by this feature. It was looking for `split` candidates in proofs and
implicit arguments. See new test for issue exposed by the previous
feature.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-11-29 22:29:27 +00:00
Kim Morrison
ea221f3283
feat: Nat.(fold|foldRev|any|all)M? take a function which sees the upper bound (#6139)
This PR modifies the signature of the functions `Nat.fold`,
`Nat.foldRev`, `Nat.any`, `Nat.all`, so that the function is passed the
upper bound. This allows us to change runtime array bounds checks to
compile time checks in many places.
2024-11-22 03:05:51 +00:00
Sebastian Ullrich
7fbe8e3b36
fix: Inhabited Float produced a bogus run-time value (#6136)
This PR fixes the run-time evaluation of `(default : Float)`.
2024-11-20 10:43:59 +00:00
TomasPuverle
994cfa4c74
doc: update documentation and tests for toUIntX functions (#5497)
Update documentation on functions to reflect actual behavior.
Add tests to ensure said behavior is as documented.

Closes #5483
2024-09-29 08:11:04 +00:00
euprunin
4b47a10bef
chore: fix spelling mistakes in tests (#5439)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-24 03:22:53 +00:00
Kim Morrison
e41e305479 chore: rename Array.data to Array.toList 2024-09-10 15:24:23 +10:00
Sebastian Ullrich
adc799584c fix: split libleanshared on Windows to avoid symbol limit 2024-08-12 14:14:42 +02:00
Leonardo de Moura
de269060d1 chore: fix tests 2024-06-19 20:21:34 +02:00
David Thrane Christiansen
8fef03d1cc
feat: support Lake for building Lean core oleans (#3886)
This is from a ~~pair~~triple programming session with @tydeu and
@mhuisi.

If stage 1 is built with `-DUSE_LAKE=ON`, the CMake run will generate
`lakefile.toml` files for the root, `src`, and `tests`. These Lake
configuration files can then be used to build core oleans. While they do
not yet allow Lake to be used to build the Lean binaries. they do allow
Lake to be used for working interactively with the Lean source. In our
preliminary experiments, this allowed updates to `Init.Data.Nat` to be
noticed automatically when reloading downstream files, rather than
requiring a full manual compiler rebuild. This will make it easier to
work on the system.

As part of this change, Lake is added to stage 0. This allows Lake to
function in `src`, which uses the stage 0 toolchain.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-06-13 16:18:24 +00:00
Sebastian Ullrich
3b4b2cc89d
fix: do not dllexport symbols in core static libraries (#3601)
On Windows, we now compile all core `.o`s twice, once with and without
`dllexport`, for use in the shipped dynamic and static libraries,
respectively. On other platforms, we export always as before to avoid
the duplicate work.

---------

Co-authored-by: tydeu <tydeu@hatpress.net>
2024-03-15 11:58:34 +00:00
Sebastian Ullrich
8193af33e3
fix: split libInit_shared out of libleanshared (#3421)
Avoids hitting the Windows limit on symbols per shared library soon
2024-02-22 19:16:32 +00:00
Leonardo de Moura
75d7bc0ef1
chore: disable test to fix build failure on Windows (#3410) 2024-02-19 15:15:26 -08:00
Leni Aniva
ab36ed477e
feat: allow trailing comma in tuples, lists, and tactics (#2643) 2023-11-17 13:31:41 +01:00
Sebastian Ullrich
dbe1c7f459 fix: make ^ a right action, add NatPow and HomogeneousPow 2023-11-12 16:57:51 +11:00
Joachim Breitner
995725b256 test: C trigraph
add a test file that checks that C trigraphs in string literals are not
miscompiled.
2023-11-06 16:31:05 +01:00
Siddharth Bhat
f165414e13 fix: use -O3 for LLVM tests in common.sh
This is the same flag that the C test uses. Previously this was hidden
in the Lean compiler itself but now that the optimization pass is phased
out of the compiler we need to put it here.

Co-authored-by: Henrik Böving <hargonix@gmail.com>
2023-11-02 23:21:47 +01:00
Joachim Breitner
b2d668c340
perf: Use flat ByteArrays in Trie (#2529) 2023-09-20 13:22:37 +02:00
Siddharth Bhat
146296b5fa feat: enable LLVM in stage1+ compiler 2023-08-14 13:33:46 +02:00
Sebastian Ullrich
d991f5efe0 fix: ship libLake.a 2023-07-21 09:19:19 +02:00
Siddharth Bhat
0900aa1348 feat: implement unreachable codegen for LLVM
Also add a test case that exercises `unreachable` code
generation.
2023-01-12 09:17:41 +01:00
Siddharth
5615ba6606
feat: implement uset for LLVM (#2025)
Fixes #1958.
2023-01-09 12:25:37 +00:00
Siddharth
a0a0463451
fix: codegen initUnboxed correctly in LLVM backend (#2015)
Closes #2004.

In porting the bugfix from
6eb852e28f,
I noticed that the LLVM backend was incorrectly generating declaration
initializers (in `callIODeclInitFn`), by assuming the return type of the
initializer is the return type of the declaration. Rather, it must be be
`lean_object`, since the initializer returns an `IO a` value which must be unpacked.

TODO: stop using the `getOrCreateFunction` pattern pervasively.
  perform the `create` at the right location, and the `get`
  at the correct location.
2023-01-07 16:26:53 +01:00
Gabriel Ebner
905d3204ae chore: correctly comment out initUnboxed test 2023-01-03 18:28:24 -08:00
Gabriel Ebner
c1dca61fae hack: temporarily disable initUnboxed test 2023-01-03 18:10:05 -08:00
Leonardo de Moura
6eb852e28f fix: fixes #1998 2023-01-03 16:01:27 -08:00
Siddharth
b6eb780144
feat: LLVM backend (#1837) 2022-12-30 12:45:30 +01:00
Gabriel Ebner
a67a5080e9 chore: fix tests after hash change 2022-12-01 20:18:14 -08:00
Leonardo de Moura
5a151ca64c chore: fix tests 2022-11-30 17:52:37 -08:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Mario Carneiro
85119ba9d1 chore: move Std.* data structures to Lean.* 2022-09-26 05:46:04 -07:00
Mario Carneiro
ebb5b97d73 chore: move Bootstrap.Data -> Lean.Data 2022-08-31 11:48:57 -07:00
Mario Carneiro
0efbc0bc03 chore: remove BinomialHeap, DList, Stack, Queue
These are moving to std4.
2022-08-29 07:07:53 -07:00
Mario Carneiro
bf89c5a0f5 chore: move Std -> Bootstrap 2022-08-29 01:26:12 -07:00
Fynn Schmitt-Ulms
064ab16791
feat: Float.abs function (#1514) 2022-08-25 18:45:46 -07:00
Mario Carneiro
9de477ecf9 feat: add more float functions 2022-08-12 13:12:59 -07:00
Mario Carneiro
94f85ae649 fix: don't show NaN sign info in Float.toString 2022-08-12 08:21:47 -07:00
Mario Carneiro
d8c6c827fe fix: use saturating casts in lean_float_to_uint8 to avoid UB 2022-08-11 13:30:22 -07:00
Sebastian Ullrich
c11bd6fa97 test: fix foreign function signatures 2022-07-29 14:10:15 +02:00
Gabriel Ebner
a7e8a82e89 chore: require @[computedField] attribute 2022-07-11 12:26:53 -07:00
Gabriel Ebner
6fe3e36804 feat: support extern computed fields 2022-07-11 12:26:53 -07:00