Commit graph

62 commits

Author SHA1 Message Date
Sebastian Ullrich
ddfeca1b1b
fix: do not allow access to private primitives in public scope (#9890)
This PR addresses a missing check in the module system where private
names that remain in the public environment map for technical reasons
(e.g. inductive constructors generated by the kernel and relied on by
the code generator) accidentally were accessible in the public scope.
2025-08-14 15:34:54 +00:00
Cameron Zwarich
6300329057
perf: consider functions with ordinary implicit arguments of instance type to be template-like (#9536)
This extends the specialization behavior of functions taking instance
implicits to ordinary implicit arguments that are of instance type. The
choice between the two is often made for subtle inference-related
reasons. It also affects visibility of these functions, because the
module system makes template-like decls visible to the compiler in other
modules.
2025-07-25 16:03:30 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Sebastian Ullrich
e28569f2a1
perf: minimize exported codegen data (#9356)
To be documented
2025-07-22 09:05:49 +00:00
Sebastian Ullrich
de2d6ba37e
perf: do not import non-template IR for codegen (#8666)
This PR adjusts the experimental module system to not import the IR of
non-`meta` declarations. It does this by replacing such IR with opaque
foreign declarations on export and adjusting the new compiler
accordingly.

This PR should not be merged before the new compiler.

Based on #8664.
2025-06-30 15:52:56 +00:00
Cameron Zwarich
567280cb41
chore: remove outdated comment (#9002) 2025-06-25 22:16:36 +00:00
Cameron Zwarich
27080dca35
chore: use FVarIdHashSet in LCNF collectUsed (#8778) 2025-06-13 22:55:15 +00:00
Cameron Zwarich
9ea4946560
feat: add support for USize literals in LCNF (#8456)
This PR adds support for primitive USize literals in LCNF.
2025-05-23 17:22:31 +00:00
Cameron Zwarich
fc8f290347
feat: support native literals of size unsigned integer types (#8409)
This PR adds support to LCNF for native UInt8/UInt16/UInt32/UInt64
literals.
2025-05-20 00:38:38 +00:00
Cameron Zwarich
fbac0d2ddb
chore: use LitValue.toExpr instead of duplicating its definition (#8398) 2025-05-19 01:33:47 +00:00
Cameron Zwarich
ca037ded0d
chore: rename LitValue.natVal/strVal to .nat/str (#8394) 2025-05-18 22:10:58 +00:00
Cameron Zwarich
006d2925ba
chore: rename LetValue.value to .lit (#8393) 2025-05-18 21:12:35 +00:00
Rob23oba
b8c941d39a
chore: use mutual inductives for data structures in the new compiler (#8332)
This PR changes the types `AltCore`, `FunDeclCore` and `CasesCore` used
in the IRs of the new compiler into the mutual inductives `Alt`,
`FunDecl` and `Cases`.
2025-05-14 18:04:49 +00:00
Cameron Zwarich
d1ed57e92a
fix: support borrowed params in the new compiler (#8127)
This PR adds support for borrowed params in the new compiler, which
requires adding support for .mdata expressions to LCNF type handling.
2025-04-28 17:02:47 +00:00
Cameron Zwarich
bf1d253764
feat: add support for extern LCNF decls (#6429)
This PR adds support for extern LCNF decls, which is required for parity
with the existing code generator.
2024-12-20 21:20:56 +00:00
Kim Morrison
f85c66789d
feat: Array.insertIdx/eraseIdx take a tactic-provided proof (#6133)
This PR replaces `Array.feraseIdx` and `Array.insertAt` with
`Array.eraseIdx` and `Array.insertIdx`, both of which take a `Nat`
argument and a tactic-provided proof that it is in bounds. We also have
`eraseIdxIfInBounds` and `insertIdxIfInBounds` which are noops if the
index is out of bounds. We also provide a `Fin` valued version of
`Array.findIdx?`. Together, these quite ergonomically improve the array
indexing safety at a number of places in the compiler/elaborator.
2024-11-20 09:52:38 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
int-y1
8d7520b36f chore: fix typos in comments 2023-10-08 10:46:05 +02:00
Leonardo de Moura
b4d13a8946 refactor: LetExpr => LetValue
We use "let value" in many other places in the code base.
2022-11-07 18:51:07 -08:00
Leonardo de Moura
ea8e7d5c99 chore: port ReduceArity.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
0c58913cf1 chore: port SimpValue.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
4bf2df563d fix: typo 2022-11-07 16:18:36 -08:00
Leonardo de Moura
7e2c476a77 chore: port more files to new LCNF 2022-11-07 16:18:36 -08:00
Leonardo de Moura
5c53656d46 chore: port LCNF/InferType.lean 2022-11-07 16:18:35 -08:00
Leonardo de Moura
6d46829599 chore: new LCNF representation
This is the first of a series of commits to change the LCNF representation.
2022-11-07 16:18:35 -08:00
Gabriel Ebner
fa9538ffa6 perf: use old instantiateLevelParams in compiler 2022-10-24 12:23:13 -07:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Leonardo de Moura
359dc77664 refactor: move isTemplateLike to LCNF/Basic.lean 2022-10-15 08:51:20 -07:00
Leonardo de Moura
af99715a58 feat: store inline attribute at LCNF declarations
This commit also adds support for inheriting the inline attribute when
the compiler lambda lifts local functions from instances.
2022-10-13 02:06:35 -07:00
Henrik Böving
eaab29712d feat: extend join point context pass 2022-10-03 17:03:22 -07:00
Leonardo de Moura
4c2c6931f4 feat: add flag at LCNF Decl indicating whether the original Lean declaration was declared using partial or unsafe 2022-09-30 19:28:05 -07:00
Leonardo de Moura
fd5f3a5bad feat: track recursively inlining
closes #1657
see #1646

https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/inline.20codegen.20crash/near/301099703
2022-09-27 16:26:49 -07:00
Leonardo de Moura
35ca2b203c refactor: split Simp.lean 2022-09-26 07:04:20 -07:00
Leonardo de Moura
fd1ae3118c feat: replace isCasesOnCases? with simpJpCases?
It addresses the code explosion issue with the old optimization.
For example, the resulting size for `Lean.Json.Parser.escapedChar`
went from 31593 to 361.
2022-09-25 20:57:24 -07:00
Leonardo de Moura
abe1f7f6f9 feat: dependency collector for the code specializer 2022-09-15 19:55:37 -07:00
Leonardo de Moura
82bba1c63b feat: add Code.forM 2022-09-14 13:58:57 -07:00
Leonardo de Moura
1350a57a03 refactor: remove pure field from LCNF.LetDecl
We decide that in phase 3 we will assume everything is impure, and
this kind of fine-grain tracking is not worth it.
2022-09-12 19:13:43 -07:00
Leonardo de Moura
613523e1f6 feat: store borrow flag at Param
It is more robust that using `Expr.mdata`, and we save the information at `toLCNF`.
2022-09-11 20:19:44 -07:00
Henrik Böving
d2f7e724ac feat: findJoinPoints pass 2022-09-08 14:09:14 -07:00
Leonardo de Moura
3e210d9f26 chore: helper functions, missing instance 2022-09-05 19:20:31 -07:00
Leonardo de Moura
1c41a750ed feat: add ReduceJpArity compiler pass 2022-09-05 06:58:32 -07:00
Leonardo de Moura
df16c5a0e7 feat: add Code.collectUsed and FunDecl.collectUsed 2022-09-04 13:05:48 -07:00
Henrik Böving
32157f0e42 feat: Basic compiler testing framework 2022-09-03 19:55:53 -07:00
Leonardo de Moura
d5dcd5e856 feat: eta-expand local function declarations that are not being inlined 2022-09-02 05:22:41 -07:00
Leonardo de Moura
0ed46003c6 feat: add CodeDecl helper type 2022-09-01 20:52:08 -07:00
Leonardo de Moura
30c75b4b88 feat: add simpCasesOnCtor 2022-09-01 20:52:08 -07:00
Leonardo de Moura
9874ef3c66 feat: check whether LetDecl and FunDecl match their values in the LCNF local context 2022-09-01 07:05:07 -07:00
Leonardo de Moura
25447af13c feat: new code inliner 2022-08-31 18:10:32 -07:00
Leonardo de Moura
2fc38fb118 feat: instantiateTypeLevelParams and instantiateValueLevelParams for LCNF.Decl 2022-08-30 20:20:39 -07:00