Cameron Zwarich
05c1ba291d
fix: erase dependencies on let-bound fvars in internalizeCode ( #9922 )
...
This PR changes `internalizeCode` to replace all substitutions with
non-param-bound fvars in `Expr`s (which are all types) with `lcAny`,
preserving the invariant that there are no such dependencies. The
violation of this invariant across files caused test failures in a
pending PR, but it is difficult to write a direct test for it. In the
future, we should probably change the LCNF checker to detect this.
This change also speeds up some compilation-heavy benchmarks much more
than I would've expected, which is a pleasant surprise. This indicates
we might get more speedups from reducing the amount of type information
we preserve in LCNF.
2025-08-15 01:52:47 +00:00
Cameron Zwarich
361ca788a7
refactor: split the LCNF pass list into separate base/mono lists ( #9816 )
...
This will make it easier to run the two phases in parallel.
2025-08-10 04:23:19 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean ( #9330 )
2025-07-25 12:02:51 +00:00
Cameron Zwarich
85e061bed5
chore: remove unused impure LCNF Phase ( #8924 )
...
The `.impure` LCNF `Phase` is not currently used, but was intended for a
potential future where the current `IR` passes (which operate on a
highly impure representation) were rewritten to operate on LCNF instead.
For several reasons, I don't think this is very likely to happen, and
instead we are more likely to remove some of the unnecessary differences
between LCNF and IR while keeping them distinct.
2025-06-22 05:38:16 +00:00
Cameron Zwarich
a7af9f7d5f
chore: fix a typo in a doc comment ( #8731 )
2025-06-11 20:41:32 +00:00
Cameron Zwarich
39cbe04946
fix: use Arg in LCNF FVarSubst rather than Expr ( #8729 )
...
This PR changes LCNF's `FVarSubst` to use `Arg` rather than `Expr`. This
enforces the requirements on substitutions, which match the requirements
on `Arg`.
2025-06-11 18:08:30 +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
Sebastian Ullrich
8b1caa3bc2
fix: make new codegen async realization-compatible ( #7316 )
...
Follow-up to #7247
2025-04-01 15:55:14 +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
Markus Himmel
4bac74c4ac
chore: switch to Std.HashMap and Std.HashSet almost everywhere
2024-08-07 18:24:42 +02:00
Henrik Böving
23e49eb519
perf: add prelude to all Lean modules
2024-02-18 14:55:17 -08:00
Leonardo de Moura
5654d8465d
fix: fixes #1822
2022-11-13 18:13:29 -08:00
Leonardo de Moura
c147059fd7
fix: fixes #1812
2022-11-10 08:58:09 -08: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
eaade5abde
chore: port LambdaLifting.lean
2022-11-07 16:18:36 -08:00
Leonardo de Moura
e6232b67b6
chore: add helper functions
2022-11-07 16:18:36 -08:00
Leonardo de Moura
123aed11ca
chore: port InlineCandidate.lean
2022-11-07 16:18:36 -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
Mario Carneiro
583e023314
chore: snake-case attributes (part 2)
2022-10-19 09:28:08 -07:00
Leonardo de Moura
53b995386d
fix: avoid [anonymous] at LCNF binder names
2022-10-15 11:56:52 -07:00
Leonardo de Moura
3f076fc836
perf: missing annotations and helper instances
2022-10-14 08:42:50 -07:00
Leonardo de Moura
8fe4b75c48
feat: do not inline definitions occurring in instances at the base phase
2022-10-12 16:24:16 -07:00
Leonardo de Moura
aa845dee98
feat: cache lambda lifted functions
2022-10-11 21:28:03 -07:00
Leonardo de Moura
f61ec4929f
chore: add low-level normExprCore
2022-10-09 12:10:11 -07:00
Leonardo de Moura
dc6f635f41
refactor: add LCNF/Internalize.lean
2022-10-03 09:18:11 -07:00
Leonardo de Moura
8cca2ea24e
fix: refresh LCNF parameter binder names
2022-09-29 12:46:53 -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
Mario Carneiro
85119ba9d1
chore: move Std.* data structures to Lean.*
2022-09-26 05:46:04 -07:00
Leonardo de Moura
ce12ecfe13
fix: free variable collision at LCNF/Specialize.lean
2022-09-24 18:51:32 -07:00
Leonardo de Moura
5969dc2694
feat: beta-reduce at LCNF normExpr
2022-09-24 18:26:34 -07:00
Leonardo de Moura
2be8cb93ac
feat: store phase at CompilerM context
2022-09-23 16:30:51 -07:00
Leonardo de Moura
5db452cfe7
doc: add note at LCNF internalizer
...
We should also new tests that expose the problem.
2022-09-22 20:19:01 -07:00
Leonardo de Moura
990b031871
feat: add translator attribute to MonadFVarSubst class
...
See new comments.
2022-09-20 16:58:27 -07:00
Leonardo de Moura
4c19fdbb97
fix: normFVarImp bug
2022-09-19 21:41:18 -07:00
Leonardo de Moura
9dede6f632
feat: add mkSpecDecl
2022-09-17 17:30:57 -07:00
Leonardo de Moura
483234f30c
refactor: rename Internalize.M
2022-09-17 16:46:44 -07:00
Leonardo de Moura
c1b7accd12
refactor: LCNF local context
...
The previous implementation had a few issues:
- Function (and join point) declarations were being inserted into two different hashmaps.
- `borrow` information was not available for parameters.
- No proper erase functions.
2022-09-14 19:25:16 -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
Leonardo de Moura
e0197b4e09
feat: add bindCases
...
It is similar to `Code.bind` but has special support for `inlineMatcher`
2022-09-04 19:04:21 -07:00
Leonardo de Moura
bc88b0307e
feat: cases on cases for new LCNF simplifier
2022-09-03 07:54:19 -07:00
Leonardo de Moura
30c75b4b88
feat: add simpCasesOnCtor
2022-09-01 20:52:08 -07:00
Leonardo de Moura
255d34d2ac
feat: add simpValue? back
2022-09-01 20:52:08 -07:00
Leonardo de Moura
c201133d4d
feat: LCNF local context dead variable checker
...
This commit also fixes a few local declaration leaks.
2022-08-31 21:07:21 -07:00
Leonardo de Moura
ddab48a154
fix: erase dead variables
2022-08-31 20:43:13 -07:00
Leonardo de Moura
ba0835e387
feat: refresh binder names during internalization
2022-08-31 18:10:32 -07:00
Leonardo de Moura
25447af13c
feat: new code inliner
2022-08-31 18:10:32 -07:00
Leonardo de Moura
c451bf0c91
feat: add simpFunDecl
2022-08-30 11:45:05 -07:00