Commit graph

31 commits

Author SHA1 Message Date
Markus Himmel
cf8ffc28d3
chore: kernel changes ahead of String redefinition (#10330)
This PR changes the defeq algorithm to perform `whnf` on the `String.mk`
expression it creates for string literals.

This is currently a no-op, but will no longer be one once `String` is
redefined so that `String.mk` is a regular function instead of a
constructor.
2025-09-17 09:12:07 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Markus Himmel
7dd5e957da
feat: ToExpr IntX (#7268)
This PR implements `Lean.ToExpr` for finite signed integers.
2025-02-28 09:32:30 +00:00
Kyle Miller
8f5ce3a356
feat: upstream ToExpr deriving handler from Mathlib (#6473)
This PR adds a deriving handler for the `ToExpr` class. It can handle
mutual and nested inductive types, however it falls back to creating
`partial` instances in such cases. This is upstreamed from the Mathlib
deriving handler written by @kmill, but has fixes to handle autoimplicit
universe level variables.

This is a followup to #6285 (adding the `ToLevel` class). This PR
supersedes #5906.

Co-authored-by: Alex Keizer <alex@keizer.dev>

---------

Co-authored-by: Alex Keizer <alex@keizer.dev>
2024-12-31 15:11:53 +00:00
Alex Keizer
1400b95ffb
feat: upstream ToLevel from mathlib (#6285)
This PR upstreams the `ToLevel` typeclass from mathlib and uses it to
fix the existing `ToExpr` instances so that they are truly universe
polymorphic (previously it generated malformed expressions when the
universe level was nonzero). We improve on the mathlib definition of
`ToLevel` to ensure the class always lives in `Type`, irrespective of
the universe parameter.

This implements part one of the plan to upstream a derive handler for
`ToExpr`, as discussed in #5906 and #5909.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-12-05 05:50:32 +00:00
Henrik Böving
19e06acc65
refactor: redefine unsigned fixed width integers in terms of BitVec (#5323)
I made a few choices so far that can probably be discussed:
- got rid of `modn` on `UInt`, nobody seems to use it apart from the
definition of `shift` which can use normal `mod`
- removed the previous defeq optimized definition of `USize.size` in
favor for a normal one. The motivation was to allow `OfNat` to work
which doesn't seem to be necessary anymore afaict.
- Minimized uses of `.val`, should we maybe mark it deprecated?
- Mostly got rid of `.val` in basically all theorems as the proper next
level of API would now be `.toBitVec`. We could probably re-prove them
but it would be more annoying given the change of definition.
- Did not yet redefine `log2` in terms of `BitVec` as this would require
a `log2` in `BitVec` as well, do we want this?
- I added a couple of theorems around the relation of `<` on `UInt` and
`Nat`. These were previously not needed because defeq was used all over
the place to save us. I did not yet generalize these to all types as I
wasn't sure if they are the appropriate lemma that we want to have.
2024-10-16 07:28:23 +00:00
Kim Morrison
c209d0d745 chore: upstream Zero and NeZero 2024-09-10 19:30:09 +10:00
Kim Morrison
811c1e3685
chore: upstream ToExpr FilePath and compile_time_search_path% (#4453) 2024-07-08 15:41:03 +00:00
Mario Carneiro
00cf5771f3
feat: support idents in auto tactics (#3328)
This is still experimental, but it implements identifier support in auto
tactics "in the obvious way". It also converts `quoteAutoTactic` to
generate Expr directly instead of going via syntax (this doesn't have
any effect other than increasing compile cost AFAICT).
2024-05-03 04:37:07 +00:00
Leonardo de Moura
66be8b9d4c fix: ToExpr instance for Fin 2024-02-24 16:08:07 -08:00
Leonardo de Moura
c48d020255 feat: add ToExpr instances for UInt?? types 2024-02-23 15:16:12 -08:00
Leonardo de Moura
f7e74320df feat: add ToExpr instance for BitVec 2024-02-23 15:16:12 -08:00
Leonardo de Moura
72f90bff9d feat: add ToExpr instance for Fin 2024-02-23 15:16:12 -08:00
Scott Morrison
5a32473f66
feat: replace ToExpr Int (#3472)
The current `ToExpr Int` instance produces `@Int.ofNat (@OfNat.ofNat Nat
i ...)` for nonnegative `i` and `@Int.negSucc (@OfNat.ofNat Nat (-i+1)
...)` for negative `i`.

However it should be producing `@OfNat.ofNat Int i ...` for nonnegative
`i`, and `@Neg.neg ... (@OfNat.ofNat Int (-i) ...)` for negative `i`.
2024-02-23 02:30:05 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Leonardo de Moura
61a76a814f
feat: delaborator for Char literals (#3381) 2024-02-17 12:19:40 -08:00
Joe Hendrix
06e21faecd
chore: upstream Std.Data.Int.Init modules (#3364)
This is pretty big PR that upstreams all of Std.Data.Int.Init in one go.

So far lemmas have seen minimal changes needed to adapt to Lean core
environment.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-16 03:58:23 +00:00
Leonardo de Moura
7ed4d1c432 feat: add builtin simproc support 2024-01-09 12:57:15 +01:00
Leonardo de Moura
676d2b1462 feat: new ToExpr Name
`Quote Name` was already using the optimized `Syntax.mkNameLit`
2022-09-29 17:27:45 -07:00
Leonardo de Moura
ee70805c35 feat: add LCNF missing cases 2022-08-06 20:23:29 -07:00
Leonardo de Moura
a489bdb107 doc: some doc strings 2022-07-30 21:18:50 -07:00
Gabriel Ebner
23113501f4 chore: prepare for Name refactoring 2022-07-11 14:19:41 -07:00
Leonardo de Moura
cbd36e897b chore: remove ToExpr Expr 2021-08-14 06:16:46 -07:00
Leonardo de Moura
6c63780a81 chore: use double quote
This commit also fixes a typo at `Option.cons`
2021-01-20 17:07:01 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
f17e226638 chore: naming convention
Example: `mkNameStr` => `Name.mkStr`

cc @Kha
2020-11-11 10:08:55 -08:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
82ee2e361b chore: cleanup 2020-10-21 18:43:47 -07:00
Leonardo de Moura
f8971200af chore: move to new frontend 2020-10-20 17:01:29 -07:00
Leonardo de Moura
249bda16c0 chore: remove prelude commands from Lean package 2020-06-25 11:21:17 -07:00
Leonardo de Moura
4ccc3fef52 chore: move Init.Lean files to Lean package 2020-05-26 15:04:35 -07:00
Renamed from src/Init/Lean/ToExpr.lean (Browse further)