Compare commits

...

5054 Commits

Author SHA1 Message Date
Kim Morrison
06c955902c import all 2024-12-01 19:12:25 +11:00
Kim Morrison
c94934e2ae Merge remote-tracking branch 'origin/master' into array_perm 2024-12-01 19:10:53 +11:00
Kim Morrison
77ad0769fb feat: Array.swap_perm 2024-12-01 19:10:26 +11:00
Kim Morrison
819cb879e1 chore: upstream Vector lemmas (#6271)
This PR upstreams existing lemmas about `Vector` from Batteries.

Thanks to @fgdorais for preparing these in
https://github.com/leanprover-community/batteries/pull/1062. Further
contributions to the `Vector` API welcome via PR here.
2024-12-01 06:44:14 +00:00
Kim Morrison
3ee2842e77 feat: remove runtime bounds checks and partial from qsort (#6241)
This PR refactors `Array.qsort` to remove runtime array bounds checks,
and avoids the use of `partial`. We use the `Vector` API, along with
auto_params, to avoid having to write any proofs. The new code
benchmarks indistinguishably from the old.
2024-12-01 06:26:00 +00:00
Kyle Miller
7b8504cf06 chore: post-stage0 cleanup for #6165 (#6268)
This PR puts code in terms of syntax quotations now that there has been
a stage0 update. Fixes a lingering bug in StructInst where some
intermediate syntax was malformed, but this had no observable effects
outside of some debug messages.
2024-12-01 00:20:59 +00:00
Lean stage0 autoupdater
ca96922b4b chore: update stage0 2024-11-30 21:22:30 +00:00
Kyle Miller
a1c3a36433 feat: parity between structure instance notation and where notation (#6165)
This PR modifies structure instance notation and `where` notation to use
the same notation for fields. Structure instance notation now admits
binders, type ascriptions, and equations, and `where` notation admits
full structure lvals. Examples of these for structure instance notation:
```lean
structure PosFun where
  f : Nat → Nat
  pos : ∀ n, 0 < f n

def p : PosFun :=
  { f n := n + 1
    pos := by simp }

def p' : PosFun :=
  { f | 0 => 1
      | n + 1 => n + 1
    pos := by rintro (_|_) <;> simp }
```
Just like for the structure `where` notation, a field `f x y z : ty :=
val` expands to `f := fun x y z => (val : ty)`. The type ascription is
optional.

The PR also is setting things up for future expansion. Pending some
discussion, in the future structure/`where` notation could have have
embedded `where` clauses; rather than `{ a := { x := 1, y := z } }` one
could write `{ a where x := 1; y := z }`.
2024-11-30 20:27:25 +00:00
Lean stage0 autoupdater
734ea3071d chore: update stage0 2024-11-30 12:58:59 +00:00
Kyle Miller
f3f00451c8 feat: add structInstFieldDecl syntax category (#6265)
This PR is preparation for changes to structure instance notation in
#6165. It adds a syntax category that will be used for field syntax.
2024-11-30 12:12:53 +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
Lean stage0 autoupdater
3752241edd chore: update stage0 2024-11-29 21:32:14 +00:00
Marc Huisinga
39bffb6fda fix: don't walk full project file tree on every file save (#6246)
This PR fixes a performance issue where the Lean language server would
walk the full project file tree every time a file was saved, blocking
the processing of all other requests and notifications and significantly
increasing overall language server latency after saving.

This issue was originally reported at
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Compiling.20too.20slow/near/484386515
and uncovered in a lengthy investigation. The performance bug that
causes the Lean language server to walk the full project file tree when
the file watcher for .ilean files is triggered was introduced when the
.ileans were first introduced, whereas the specific issue of file saving
also triggering the walk was introduced by #3247 in 4.8.0 and the use of
the file watcher for .lean files, which would then also trigger the
directory walk. Combining this with VS Code's auto-save feature causes
the language server to walk the full project file tree on every change
of the document.

It somehow hasn't really been much of an issue until now, but we still
do way too much work in the watchdog main loop. I'll look into resolving
that more general issue in the future.
2024-11-29 15:34:44 +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
d97af36867 feat: simpler trace timing annotation logic (#6259)
This PR ensures that nesting trace nodes are annotated with timing
information iff `trace.profiler` is active.

The previous connection to the otherwise unrelated `profiler` option was
a remnant from before `trace.profiler` existed; if users want to
annotate explicitly activated trace classes only, they can instead
increase `trace.profiler.threshold`.
2024-11-29 14:03:01 +00:00
Mac Malone
27cc0c8039 feat: USize.reduceToNat (#6190)
This PR adds the builtin simproc `USize.reduceToNat` which reduces the
`USize.toNat` operation on literals less than `UInt32.size` (i.e.,
`4294967296`).
2024-11-29 08:24:40 +00:00
Mac Malone
c9ee66fb1f chore: lake: fix typo in materialize error (#6250) 2024-11-29 06:20:51 +00:00
Kim Morrison
5c7e027b03 chore: cleanup of List/Array lemmas (#6249)
This PR performs further cleanup of `List/Lemmas.lean` and
`Array/Lemmas.lean`, trying to make them more parallel.

Still a long way to go.
2024-11-29 06:12:38 +00:00
Mac Malone
4969ec9cdb feat: more UInt lemmas (#6205)
This PR upstreams some UInt theorems from Batteries and adds more
`toNat`-related theorems. It also adds the missing `UInt8` and `UInt16`
to/from `USize` conversions so that the the interface is uniform across
the UInt types.

**Summary of all changes:**

* Upstreamed and added `toNat` constructors lemmas: `toNat_mk`,
`ofNat_toNat`, `toNat_ofNat`, `toNat_ofNatCore`, and
`USize.toNat_ofNat32`
* Upstreamed and added `toNat` canonicalization; `val_val_eq_toNat` and
`toNat_toBitVec_eq_toNat`
* Added injectivity iffs: `toBitVec_inj`, `toNat_inj`, and `val_inj`
* Added inequality iffs: `le_iff_toNat_le` and `lt_iff_toNat_lt`
* Upstreamed antisymmetry lemmas: `le_antisymm` and `le_antisymm_iff`
* Upstreamed missing `toNat` lemmas on arithmetic operations:
`toNat_add`, `toNat_sub`, `toNat_mul`
* Upstreamed and added missing conversion lemmas: `toNat_toUInt*` and
`toNat_USize`
* Added missing `USize` conversions: `USize.toUInt8`, `UInt8.toUSize`,
`USize.toUInt16`, `UInt16.toUSize`
2024-11-29 02:08:52 +00:00
Mac Malone
827062f807 feat: System.Platform.numBits inequalities (#6247)
This PR adds the theorems `numBits_pos`, `le_numBits`, `numBits_le` ,
which make proving inequalities about `System.Platform.numBits` easier.
2024-11-28 21:20:47 +00:00
Kim Morrison
6d495586a1 chore: deprecate Fin.ofNat (replaced by Fin.ofNat', subsequently to be renamed) (#6242)
This PR deprecates `Fin.ofNat` in favour of `Fin.ofNat'` (which takes an
`[NeZero]` instance, rather than returning an element of `Fin (n+1)`).

After leaving the deprecation warning in place for some time, we will
then rename `ofNat'` back to `ofNat`.
2024-11-28 05:23:23 +00:00
Kim Morrison
10d1d2cc25 chore: cleanup in Array/Lemmas (#6243) 2024-11-28 03:50:41 +00:00
Wojciech Nawrocki
2325f5c7b9 doc: explain abstraction order (#6239)
This PR explains the order in which `Expr.abstract` introduces de Bruijn
indices.
2024-11-28 01:37:30 +00:00
Sofia Rodrigues
88e3a2b1ab fix: improve directory fallback on Linux and trim local time identifier (#6221)
This PR fixes:
- Problems in other linux distributions that the default `tzdata`
directory is not the same as previously defined by ensuring it with a
fallback behavior when directory is missing.
- Trim unnecessary characters from local time identifier.
2024-11-27 14:52:35 +00:00
Lean stage0 autoupdater
b378fe98a7 chore: update stage0 2024-11-27 14:20:47 +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
Jens Petersen
30d01f7a9a fix: add cmake COPY_CADICAL option to allow turning off install copy (#5931)
This PR adds a cmake knob to allow turning off installing a copy of
`cadical`.
This can be useful for custom builds/installs where cadical is already
available in the system.

Closes: #5603
2024-11-27 13:21:20 +00:00
Sebastian Ullrich
81b85d8e2f fix: reparsing may need to backtrack two commands (#6236)
This PR fixes an issue where edits to a command containing a nested
docstring fail to reparse the entire command.

Fixes #6227
2024-11-27 13:06:57 +00:00
Sebastian Ullrich
5982a6d230 chore: default parseQuotWithCurrentStage to true in stage 0 (#6212)
Use the default that solves bootstrapping issues in exchange for an
insignificant(?) perf overhead
2024-11-27 12:58:44 +00:00
Mac Malone
ac1197ff59 feat: Lean.loadPlugin (#6130)
This PR adds `Lean.loadPlugin` which exposes functionality similar to
the `lean` executable's `--plugin` option to Lean code.

This will allow custom Lean frontends (e.g., Lake, the Lean language
server) to also load plugins.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-11-27 09:56:31 +00:00
Kim Morrison
609346f5e0 feat: relate Nat.fold/foldRev/any/all to List.finRange (#6235)
This PR relates that operations `Nat.fold`/`foldRev`/`any`/`all` to the
corresponding List operations over `List.finRange`.
2024-11-27 05:38:18 +00:00
Mac Malone
04f80a1f9f feat: lake: detailed Reservoir fetch error (#6231)
This PR improves the errors Lake produces when it fails to fetch a
dependency from Reservoir. If the package is not indexed, it will
produce a suggestion about how to require it from GitHub.

Closes #5330.
2024-11-27 05:07:09 +00:00
Kim Morrison
7e9dd5668b feat: upstream List.finRange from Batteries (#6234)
This PR upstreams the definition and basic lemmas about `List.finRange`
from Batteries.

Thanks for contributors to Batteries and Mathlib who've previously
worked on this material. Further PRs are welcome here. I'll be adding
more API later.
2024-11-27 04:27:22 +00:00
Kim Morrison
79f050b816 feat: upstream Vector lemmas (#6233)
This PR upstreams lemmas about `Vector` from Batteries.

I'll be adding more soon, and PRs are welcome, particularly from those
who have previously contributed to `Vector` in Batteries.
2024-11-27 04:19:30 +00:00
Siddharth
af4a3f2251 feat: BitVec.toInt_abs (#6154)
This PR implements `BitVec.toInt_abs`.


The absolute value of `x : BitVec w` is naively a case split on the sign
of `x`.
However, recall that when `x = intMin w`, `-x = x`.
Thus, the full value of `abs x` is computed by the case split:
- If `x : BitVec w` is `intMin`, then its absolute value is also `intMin
w`, and
  thus `toInt` will equal `intMin.toInt`.
- Otherwise, if `x` is negative, then `x.abs.toInt = (-x).toInt`.
- Finally, when `x` is nonnegative, then `x.abs.toInt = x.toInt`.

```lean
theorem toInt_abs {x : BitVec w} :
  x.abs.toInt =
    if x = intMin w then (intMin w).toInt
    else if x.msb then -x.toInt
    else x.toInt
```

We also provide a variant of `toInt_abs` that
hides the case split for `x` being positive or negative by using
`natAbs`.
```lean
theorem toInt_abs_eq_natAbs {x : BitVec w} : x.abs.toInt =
    if x = intMin w then (intMin w).toInt else x.toInt.natAbs
```

Supercedes https://github.com/leanprover/lean4/pull/5787

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
2024-11-27 03:50:55 +00:00
Siddharth
7692343720 feat: BitVec.toNat BitVec.signExtend (#6155)
This PR adds `toNat` theorems for `BitVec.signExtend.`

Sign extending to a larger bitwidth depends on the msb. If the msb is
false, then the result equals the original value. If the msb is true,
then we add a value of `(2^v - 2^w)`, which arises from the sign
extension.

```lean
theorem toNat_signExtend (x : BitVec w) {v : Nat} :
    (x.signExtend v).toNat = (x.setWidth v).toNat + if x.msb then 2^v - 2^w else 0
```

Co-authored-by: Harun Khan <harun19@stanford.edu>
2024-11-27 03:50:15 +00:00
Luisa Cicolini
597ef8cfee feat: add Nat.mod_eq_sub and fix dependencies from Nat.sub_mul_eq_mod_of_lt_of_le (#6160)
This PR adds theorem `mod_eq_sub`, makes theorem
`sub_mul_eq_mod_of_lt_of_le` not private anymore and moves its location
within the `rotate*` section to use it in other proofs.
2024-11-27 03:48:59 +00:00
Kim Morrison
321e148f51 feat: Array fold lemmas (#6230)
This PR copies some lemmas about `List.foldX` to `Array`.
2024-11-27 02:09:41 +00:00
Kyle Miller
ce692436f4 feat: expose diff at "synthesized type class instance is not definitionally equal" error (#6213)
This PR exposes the difference in "synthesized type class instance is
not definitionally equal" errors.
2024-11-27 00:52:58 +00:00
Mac Malone
23bec25fce feat: Nat.lt_pow_self (#6200)
This PR upstreams `Nat.lt_pow_self` and `Nat.lt_two_pow` from Mathlib
and uses them to prove the simp theorem `Nat.mod_two_pow`.

This simplifies expressions like `System.Platform.numBits % 2 ^
System.Platform.numBits = System.Platform.numBits`, which is needed for
#6188.
2024-11-26 23:42:23 +00:00
Mac Malone
3d511a582a feat: USize.size inequalities (#6203)
This PR adds the theorems `le_usize_size` and `usize_size_le`, which
make proving inequalities about `USize.size` easier.

It also deprecates `usize_size_gt_zero` in favor of `usize_size_pos` (as
that seems more consistent with our naming covention) and adds
`USize.toNat_ofNat_of_lt_32` for dealing with small USize literals.

It also moves `USize.ofNat32` and `USize.toUInt64` to
`Init.Data.UInt.Basic` as neither are used in `Init.Prelude` anymore.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-11-26 23:42:15 +00:00
Mac Malone
51015bf5c0 fix: lake: eager logging when materializing deps (#6225)
This PR makes `lake build` also eagerly print package materialization
log lines. Previously, only a `lake update` performed eager logging.
2024-11-26 22:11:23 +00:00
Mac Malone
3ece36de9d feat: GitHub cloud releases do not clobber prebuilt artifacts (#6218)
This PR makes Lake no longer automatically fetch GitHub cloud releases
if the package build directory is already present (mirroring the
behavior of the Reservoir cache). This prevents the cache from
clobbering existing prebuilt artifacts. Users can still manually fetch
the cache and clobber the build directory by running `lake build
<pkg>:release`.
2024-11-26 22:10:42 +00:00
Leonardo de Moura
54c48363ca feat: proper let_fun support in simp (#6220)
This PR adds proper support for `let_fun` in `simp`.
2024-11-26 21:42:08 +00:00
Markus Himmel
0a22f8fa6f chore: improve consistency & documentation for hash table insert and insertMany (#6222)
This PR changes the definition of `HashSet.insertMany` and
`HashSet.Raw.insertMany` so that it is equivalent to repeatedly calling
`HashSet.insert`/`HashSet.Raw.insert`. It also clarifies the docstrings
of all the `insert` and `insertMany` functions.

---------

Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
2024-11-26 11:22:23 +00:00
Kim Morrison
f70b7e5722 feat: @[deprecated] requires a replacement identifier or message, and a since field (#6112)
This PR makes stricter requirements for the `@[deprecated]` attribute,
requiring either a replacement identifier as `@[deprecated bar]` or
suggestion text `@[deprecated "Past its use by date"]`, and also
requires a `since := "..."` field.
2024-11-26 08:45:54 +00:00
Kim Morrison
9a17919ef1 feat: missing lemmas about List's BEq (#6217)
This PR adds `simp` lemmas about `List`'s `==` operation.
2024-11-25 22:55:03 +00:00
Kyle Miller
606aeddf06 feat: make dot notation be affected by export/open (#6189)
This PR changes how generalized field notation ("dot notation") resolves
the function. The new resolution rule is that if `x : S`, then `x.f`
resolves the name `S.f` relative to the root namespace (hence it now
affected by `export` and `open`). Breaking change: aliases now resolve
differently. Before, if `x : S`, and if `S.f` is an alias for `S'.f`,
then `x.f` would use `S'.f` and look for an argument of type `S'`. Now,
it looks for an argument of type `S`, which is more generally useful
behavior. Code making use of the old behavior should consider defining
`S` or `S'` in terms of the other, since dot notation can unfold
definitions during resolution.

This also fixes a bug in explicit-mode generalized field notation
(`@x.f`) where `x` could be passed as the wrong argument. This was not a
bug for explicit-mode structure projections.

Closes #3031. Addresses the `Function` namespace issue in #1629.
2024-11-25 18:38:17 +00:00
Kyle Miller
0eca3bd55d feat: add a coercion from List Nat to Lean.Meta.Occurrences (#6206)
This PR makes it possible to write `rw (occs := [1,2]) ...` instead of
`rw (occs := .pos [1,2]) ...` by adding a coercion from `List.Nat` to
`Lean.Meta.Occurrences`.
2024-11-25 13:19:23 +00:00
Kim Morrison
43dfc2a25f chore: fix Vector.indexOf? (#6208)
Just a better defeq.
2024-11-25 10:47:58 +00:00
Mac Malone
935fcfb6ec feat: non-opaque UInt64.toUSize (#6202)
This PR makes `USize.toUInt64` a regular non-opaque definition. 

It also moves it to `Init.Data.UInt.Basic`, as it is not actually used
in `Init.Prelude` anymore.
2024-11-25 08:33:53 +00:00
Kim Morrison
20acc72a29 feat: ensure Fin.foldl/r are semireducible (#6207)
This PR ensures the `Fin.foldl` and `Fin.foldr` are semireducible.
Without this the defeq `example (f : Fin 3 → ℕ) : List.ofFn f = [f 0, f
1, f 2] := rfl` was failing.

Thanks @eric-wieser and @digama0 for diagnosing on
[Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/.60List.2EfinRange.60.20in.20Mathlib/near/484191814).
2024-11-25 03:21:36 +00:00
Kim Morrison
c3948cba24 feat: upstream definition of Vector from Batteries (#6197)
This PR upstreams the definition of `Vector` from Batteries, along with
the basic functions.
2024-11-24 23:01:32 +00:00
Kim Morrison
4e885be96d feat: rename Array.setD to setIfInBounds (#6195)
This PR renames `Array.setD` to `Array.setIfInBounds`.
2024-11-24 08:54:19 +00:00
Kim Morrison
42e98bd3c9 feat: Array.swap takes Nat arguments, with tactic provided proofs (#6194)
This PR changes the signature of `Array.swap`, so it takes `Nat`
arguments with tactic provided bounds checking. It also renames
`Array.swap!` to `Array.swapIfInBounds`.
2024-11-24 07:59:57 +00:00
Kim Morrison
884a9ea2ff feat: remove partial keyword and runtime bounds checks from Array.binSearch (#6193)
This PR completes the TODO in `Init.Data.Array.BinSearch`, removing the
`partial` keyword and converting runtime bounds checks to compile time
bounds checks.
2024-11-24 06:08:16 +00:00
Kyle Miller
2f5c7d0465 fix: structures with copied parents can now use other parents as instances (#6175)
This PR fixes a bug with the `structure`/`class` command where if there
are parents that are not represented as subobjects but which used other
parents as instances, then there would be a kernel error. Closes #2611.

Note: there is still the limitation that parents that are not
represented as subobjects do not themselves provide instances to other
parents.
2024-11-24 04:22:39 +00:00
Kim Morrison
a5ffef7e13 feat: Array.zipWithAll (#6191)
This PR adds `Array.zipWithAll`, and the basic lemmas relating it to
`List.zipWithAll`.
2024-11-24 03:49:57 +00:00
Kim Morrison
442c3d5097 chore: missing deprecations for Lean.HashMap (#6192)
This PR adds deprecations for `Lean.HashMap` functions which did not
receive deprecation attributes initially.

(Requested on
[zulip](https://leanprover.zulipchat.com/#narrow/channel/348111-batteries/topic/Unifying.20.60Batteries.2EHashMap.60.20and.20.60Std.2EHashMap.60.2E/near/484113660).)

Note that I've used the original deprecation date of 2024-08-08, when
the type itself was deprecated; this will not delay removal.
2024-11-24 03:29:48 +00:00
Joachim Breitner
bf13b24692 doc: refine kernel code comments (#6150)
I just spent too much time being confused about the kernel type checker
until I noticed that `lazy_delta_reduction` modifies its arguments.
2024-11-23 17:13:51 +00:00
Andrii Kurdiumov
51d1cc61d7 fix: remove obsolete sentence in doc-string (#6185)
Even if this sentence is technically true, it do not add anything to the
explanation of typechecker and code.
2024-11-23 07:56:31 +00:00
Siddharth
107a2e8b2e feat: BitVec.toInt BitVec.signExtend (#6157)
This PR adds toInt theorems for BitVec.signExtend.

If the current width `w` is larger than the extended width `v`,
then the value when interpreted as an integer is truncated,
and we compute a modulo by `2^v`.

```lean
theorem toInt_signExtend_of_le (x : BitVec w) (hv : v ≤ w) :
    (x.signExtend v).toInt = Int.bmod (x.toNat) (2^v)
```

Co-authored-by: Siddharth Bhat <siddu.druid@gmail.com>
Co-authored-by: Harun Khan <harun19@stanford.edu>


Stacked on top of #6155

---------

Co-authored-by: Harun Khan <harun19@stanford.edu>
2024-11-23 07:29:08 +00:00
Kim Morrison
c4b0b94c91 chore: use Array.findFinIdx? where it is better than findIdx? (#6184)
This PR uses `Array.findFinIdx?` in preference to `Array.findIdx?` where
it allows converting a runtime bounds check to a compile time bounds
check.

(and some other minor cleanup)
2024-11-23 07:22:31 +00:00
Kyle Miller
ba3f2b3ecf fix: make sure #check id heeds pp.raw (#6181)
This PR fixes a bug where the signature pretty printer would ignore the
current setting of `pp.raw`. This fixes an issue where `#check ident`
would not heed `pp.raw`. Closes #6090.
2024-11-23 00:39:58 +00:00
Leonardo de Moura
4a69643858 fix: nontermination while generating equation lemmas for match-expressions (#6180)
This PR fixes a non-termination bug that occurred when generating the
match-expression equation theorems. The bug was triggered when the proof
automation for the equation theorem repeatedly applied `injection(` to
the same local declaration, as it could not be removed due to forward
dependencies. See issue #6067 for an example that reproduces this issue.

closes #6067
2024-11-23 00:06:34 +00:00
Kyle Miller
b6a0d63612 feat: have "motive is not type correct" come with an explanation (#6168)
This PR extends the "motive is not type correct" error message for the
rewrite tactic to explain what it means. It also pretty prints the
type-incorrect motive and reports the type error.

Suggested [on
Zulip](https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/tactic.20'rewrite'.20failed.2C.20motive.20is.20not.20type.20correct/near/483545154).
2024-11-22 23:56:17 +00:00
Kyle Miller
5145030ff4 chore: refactor Elab.StructInst to use mutual for its structures/inductives (#6174)
Making use of #6125.
2024-11-22 19:17:48 +00:00
Kyle Miller
d3cb812fb6 chore: add test for recursive structures (#6173)
Closes #6140. This was fixed by #6125.
2024-11-22 18:53:59 +00:00
Lean stage0 autoupdater
e066c17a65 chore: update stage0 2024-11-22 18:29:01 +00:00
Sebastian Ullrich
38cff08888 feat: creation and reporting for asynchronous elaboration tasks (#6170)
This PR adds core metaprogramming functions for forking off background
tasks from elaboration such that their results are visible to reporting
and the language server
2024-11-22 17:12:30 +00:00
David Thrane Christiansen
3388fc8d06 doc: fix typo and make docstring more precise (#6009)
This PR fixes a typo in the docstring for prec and makes the text
slightly more precise.
2024-11-22 16:30:01 +00:00
Eric Wieser
5adcd520fa fix: make the stack handling more robust to sanitizers and -O3 (#6143)
This PR should make lean better-behaved around sanitizers, per
https://github.com/google/sanitizers/issues/1688.
As far as I can tell,
https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#algorithm
replaces local variables with heap allocations, and so taking the
address of a local is not effective at producing a monotonic measure of
stack usage.

The approach used here is the same as the one used by clang.
2024-11-22 15:10:20 +00:00
David Thrane Christiansen
1126407d9b feat: create temporary directories (#6148)
This PR adds a primitive for creating temporary directories, akin to the
existing functionality for creating temporary files.
2024-11-22 12:24:32 +00:00
Kyle Miller
a19ff61e15 feat: allow structure in mutual blocks (#6125)
This PR adds support for `structure` in `mutual` blocks, allowing
inductive types defined by `inductive` and `structure` to be mutually
recursive. The limitations are (1) that the parents in the `extends`
clause must be defined before the `mutual` block and (2) mutually
recursive classes are not allowed (a limitation shared by `class
inductive`). There are also improvements to universe level inference for
inductive types and structures. Breaking change: structure parents now
elaborate with the structure in scope (fix: use qualified names or
rename the structure to avoid shadowing), and structure parents no
longer elaborate with autoimplicits enabled.

Internally, this is a large refactor of both the `inductive` and
`structure` commands. Common material is now in
`Lean.Elab.MutualInductive`, and each command plugs into this mutual
inductive elaboration framework with the logic specific to the
respective command. For example, `structure` has code to add projections
after the inductive types are added to the environment.

Closes #4182
2024-11-22 09:20:07 +00:00
Lean stage0 autoupdater
6202461a21 chore: update stage0 2024-11-22 04:42:45 +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
Kyle Miller
7c50d597c3 feat: add builtin attribute to support elaboration of mutual inductives/structures (#6166)
This PR is a prerequisite for #6125.
2024-11-22 01:48:37 +00:00
Tony Beta Lambda
99031695bd feat: display coercions with a type ascription (#6119)
This PR adds a new delab option `pp.coercions.types` which, when
enabled, will display all coercions with an explicit type ascription.

[Link to Zulip
discussion](https://leanprover.zulipchat.com/#narrow/channel/239415-metaprogramming-.2F-tactics/topic/Roundtripping.20delaboration.20involving.20coercions)

Towards #4315
2024-11-21 23:02:47 +00:00
JovanGerb
b7248d5295 fix: revert creates natural metavariable goal (#6145)
This PR fixes the `revert` tactic so that it creates a `syntheticOpaque`
metavariable as the new goal, instead of a `natural` metavariable

I reported it on
[Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/.60revert.60.20gives.20natural.20metavariable.20goal/near/483388096)
2024-11-21 23:00:57 +00:00
Tobias Grosser
7f2e7e56d2 feat: BitVec.getMsbD_[ofNatLt|allOnes|not] (#6149)
This PR completes the elementwise accessors for `ofNatLt`, `allOnes`,
and `not` by adding their implementations of `getMsbD`.
2024-11-21 22:13:09 +00:00
Tobias Grosser
1fe66737ad feat: BitVec.toInt_[or|and|xor|not] (#6151)
This PR completes the `toInt` interface for `BitVec` bitwise operations.
2024-11-21 22:10:33 +00:00
Bhavik Mehta
765eb02279 doc: adjust file reference in Data.Sum (#6158)
This file was upstreamed from batteries; I just got bitten by the
invalid reference and it took quite a while to figure out that this one
had been moved!
2024-11-21 21:48:27 +00:00
Henrik Böving
a101377054 perf: speed up reflection of if in bv_decide (#6162)
This PR adds a slight performance improvement to reflection of `if`
statements that I noticed by profiling Leanwuzla against SMTCOMP's
`non-incremental/QF_BV/fft/Sz256_6616.smt2`.

In particular:
1. The profile showed about 4 percent of the total run time were spent
constructing these decidable instances in reflection of `if` statements.
We can construct them much quicker by hand as they always have the same
structure
2. This delays construction of these statements until we actually
generate the reflection proof that we wish to submit to the kernel. Thus
if we encounter a SAT instad of an UNSAT problem we will not spend time
generating these expressions anymore.

```
baseline
  Time (mean ± σ):     31.236 s ±  0.258 s
  Range (min … max):   30.899 s … 31.661 s    10 runs

after
  Time (mean ± σ):     30.671 s ±  0.288 s
  Range (min … max):   30.350 s … 31.156 s    10 runs
```
2024-11-21 19:40:14 +00:00
Kyle Miller
aca9929d84 fix: make sure whitespace is printed before tactic configuration (#6161)
This PR ensures whitespace is printed before `+opt` and `-opt`
configuration options when pretty printing, improving the experience of
tactics such as `simp?`.

Reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Minor.20simp.3F.20annoyances/near/483736310)
2024-11-21 19:21:59 +00:00
Sebastian Ullrich
19a701e5c9 refactor: one more recursive structure (#6159) 2024-11-21 18:30:28 +00:00
Leonardo de Moura
fc4305ab15 fix: nontermination when generating the match-expression splitter theorem (#6146)
This PR fixes a non-termination bug that occurred when generating the
match-expression splitter theorem. The bug was triggered when the proof
automation for the splitter theorem repeatedly applied `injection` to
the same local declaration, as it could not be removed due to forward
dependencies. See issue #6065 for an example that reproduces this issue.

closes #6065
2024-11-21 17:20:33 +00:00
Kim Morrison
9cf83706e7 chore: add changelog-* labels via comment (#6147)
This PR enables contributors to modify `changelog-*` labels simply by
writing a comment with the desired label.
2024-11-21 07:23:13 +00:00
Tobias Grosser
459c6e2a46 feat: BitVec.getElem_[sub|neg|sshiftRight'|abs] (#6126)
This PR adds lemmas for extracting a given bit of a `BitVec` obtained
via `sub`/`neg`/`sshiftRight'`/`abs`.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-11-21 07:01:11 +00:00
Kim Morrison
72e952eadc chore: avoid runtime array bounds checks (#6134)
This PR avoids runtime array bounds checks in places where it can
trivially be done at compile time.

None of these changes are of particular consequence: I mostly wanted to
learn how much we do this, and what the obstacles are to doing it less.
2024-11-21 05:04:52 +00:00
damiano
56a80dec1b doc: doc-strings to module docs in Data/Array/Lemmas (#6144)
This PR converts 3 doc-string to module docs since it seems that this is
what they were intended to be!
2024-11-21 05:04:09 +00:00
JovanGerb
b894464191 fix: type occurs check bug (#6128)
This PR does the same fix as #6104, but such that it doesn't break the
test/the file in `Plausible`. This is done by not creating unused let
binders in metavariable types that are made by `elimMVar`. (This is also
a positive thing for users looking at metavariable types, for example in
error messages)

We get rid of `skipAtMostNumBinders`. This function was originally
defined for the purpose of making this test work, but it is a hack
because it allows cycles in the metavariable context.

It would make sense to split these changes into 2 PRs, but I combined
them here to show that the combination of them closes #6013 without
breaking anything

Closes #6013
2024-11-21 00:28:36 +00:00
Sebastian Ullrich
b30903d1fc refactor: make use of recursive structures in snapshot types (#6141) 2024-11-20 15:15:14 +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
Sebastian Ullrich
2fbc46641d fix: trace.profiler pretty-printing (#6138)
This PR fixes `trace.profiler.pp` not using the term pretty printer.

Fixes #5872
2024-11-20 10:21:02 +00:00
Sebastian Ullrich
17419aca7f feat: thread support for trace.profiler.output (#6137)
This PR adds support for displaying multiple threads in the trace
profiler output.

`TraceState.tid` needs to be adjusted for this purpose, which is not
done yet by the Lean elaborator as it is still single-threaded.
2024-11-20 10:02:39 +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
Kim Morrison
c8b4f6b511 feat: duplicate List.attach/attachWith/pmap API for Array (#6132)
This PR duplicates the verification API for
`List.attach`/`attachWith`/`pmap` over to `Array`.
2024-11-20 01:16:48 +00:00
Luisa Cicolini
3c7555168d feat: add BitVec.(msb, getMsbD)_(rotateLeft, rotateRight) (#6120)
This PR adds theorems `BitVec.(getMsbD, msb)_(rotateLeft, rotateRight)`.

We follow the same strategy taken for `getLsbD`, constructing the
necessary auxilliary theorems first (relying on different hypotheses)
and then generalizing.

---------

Co-authored-by: Siddharth <siddu.druid@gmail.com>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-11-19 23:04:14 +00:00
Kyle Miller
5eef3d27fb feat: have #print show precise fields of structures (#6096)
This PR improves the `#print` command for structures to show all fields
and which parents the fields were inherited from, hiding internal
details such as which parents are represented as subobjects. This
information is still present in the constructor if needed. The pretty
printer for private constants is also improved, and it now handles
private names from the current module like any other name; private names
from other modules are made hygienic.

Example output for `#print Monad`:
```
class Monad.{u, v} (m : Type u → Type v) : Type (max (u + 1) v)
number of parameters: 1
parents:
  Monad.toApplicative : Applicative m
  Monad.toBind : Bind m
fields:
  Functor.map : {α β : Type u} → (α → β) → m α → m β
  Functor.mapConst : {α β : Type u} → α → m β → m α
  Pure.pure : {α : Type u} → α → m α
  Seq.seq : {α β : Type u} → m (α → β) → (Unit → m α) → m β
  SeqLeft.seqLeft : {α β : Type u} → m α → (Unit → m β) → m α
  SeqRight.seqRight : {α β : Type u} → m α → (Unit → m β) → m β
  Bind.bind : {α β : Type u} → m α → (α → m β) → m β
constructor:
  Monad.mk.{u, v} {m : Type u → Type v} [toApplicative : Applicative m] [toBind : Bind m] : Monad m
resolution order:
  Monad, Applicative, Bind, Functor, Pure, Seq, SeqLeft, SeqRight
```

Suggested by Floris van Doorn [on
Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/.23print.20command.20for.20structures/near/482503637).
2024-11-19 21:54:45 +00:00
Leonardo de Moura
75d1504af2 fix: isDefEq for constants with different universe parameters (#6131)
This PR fixes a bug at the definitional equality test (`isDefEq`). At
unification constraints of the form `c.{u} =?= c.{v}`, it was not trying
to unfold `c`. This bug did not affect the kernel.

closes #6117
2024-11-19 21:39:13 +00:00
Mario Carneiro
a00cf6330f fix: add a missing case to Level.geq (#2689)
This PR adds a case to `Level.geq` that is present in the kernel's level
`is_geq` procedure, making them consistent with one another.

This came up during testing of `lean4lean`. Currently `Level.geq`
differs from `level::is_geq` in the case of `max u v >= imax u v`. The
elaborator function is overly pessimistic and yields `false` on this
while the kernel function yields true. This comes up concretely in the
`Trans` class:
```lean
class Trans (r : α → β → Sort u) (s : β → γ → Sort v) (t : outParam (α → γ → Sort w)) where
  trans : r a b → s b c → t a c
```
The type of this class is `Sort (max (max (max (max (max (max 1 u) u_1)
u_2) u_3) v) w)` (where `u_1 u_2 u_3` are the levels of `α β γ`), but if
you try writing that type explicitly then the `class` command fails.
Omitting the type leaves the `class` to infer the universe level (the
command assumes the level is correct, and the kernel agrees it is), but
including the type then the elaborator checks the level inequality with
`Level.geq` and fails.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-11-19 21:27:00 +00:00
Leonardo de Moura
1f32477385 fix: isDefEq when zetaDelta := false (#6129)
This PR fixes a bug at `isDefEq` when `zetaDelta := false`. See new test
for a small example that exposes the issue.
2024-11-19 21:22:02 +00:00
Thomas Köppe
91c14c7ee9 fix: only consider salient bytes in sharecommon eq, hash (#5840)
This PR changes `lean_sharecommon_{eq,hash}` to only consider the
salient bytes of an object, and not any bytes of any
unspecified/uninitialized unused capacity.

Accessing uninitialized storage results in undefined behaviour.

This does not seem to have any semantics disadvantages: If objects
compare equal after this change, their salient bytes are still equal. By
contrast, if the actual identity of allocations needs to be
distinguished, that can be done by just comparing pointers to the
storage.

If we wanted to retain the current logic, we would need initialize the
otherwise unused parts to some specific value to avoid the undefined
behaviour.

Closes #5831
2024-11-19 13:56:46 +00:00
Lean stage0 autoupdater
69530afdf9 chore: update stage0 2024-11-19 13:06:43 +00:00
Marc Huisinga
b7667c1604 fix: don't issue atomic id completions when there is a dangling dot (#5837)
This PR fixes an old auto-completion bug where `x.` would issue
nonsensical completions when `x.` could not be elaborated as a dot
completion.
2024-11-19 12:23:41 +00:00
Eric Wieser
d6f898001b chore: generalize List.get_mem (#6095)
This is syntactically more general than before, though up to eta
expansion it make no difference.
2024-11-19 11:08:10 +00:00
Marc Huisinga
a38566693b test: fix brittle structure instance completion test (#6127)
#5835 contains a brittle test that uses an FVar ID, which caused a
failure on master. This PR changes that test to use a declaration
instead.
2024-11-19 10:13:51 +00:00
Marc Huisinga
4bef3588b5 chore: update stage0 2024-11-19 09:26:58 +01:00
Marc Huisinga
64538cf6e8 chore: prepare for bootstrap
Co-Authored-By: Sebastian Ullrich <sebasti@nullri.ch>
2024-11-19 09:26:58 +01:00
Marc Huisinga
aadf3f1d2c feat: use new structInstFields parser to tag structure instance fields 2024-11-19 09:26:58 +01:00
Marc Huisinga
95bf45ff8b refactor: split Completion.lean 2024-11-19 09:26:58 +01:00
Marc Huisinga
2a02c121cf feat: structure auto-completion & partial InfoTrees 2024-11-19 09:26:58 +01:00
Mac Malone
4600bb16fc feat: use BaseIO at IO.rand (#6102)
This PR moves `IO.rand` and `IO.setRandSeed` to be in the `BaseIO`
monad.

This is their proper monad as neither can error.
2024-11-19 05:26:03 +00:00
Kim Morrison
7ccdfc30ff chore: turn off pp.mvars in apply? results (#6108)
Per request on
[zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/apply.3F.20using.20tombstones/near/482895588).
2024-11-19 02:02:32 +00:00
Kim Morrison
7f0bdefb6e chore: fix apply? error reporting when out of heartbeats (#6121) 2024-11-19 00:57:59 +00:00
Joachim Breitner
799b2b6628 fix: handle reordered indices in structural recursion (#6116)
This PR fixes a bug where structural recursion did not work when indices
of the recursive argument appeared as function parameters in a different
order than in the argument's type's definition.

Fixes #6015.
2024-11-18 11:28:02 +00:00
David Thrane Christiansen
b8d6e44c4f fix: liberalize rules for atoms by allowing leading '' (#6114)
This PR liberalizes atom rules by allowing `''` to be a prefix of an
atom, after #6012 only added an exception for `''` alone, and also adds
some unit tests for atom validation.
2024-11-18 10:19:20 +00:00
Kim Morrison
5a99cb326c chore: make Lean.Elab.Command.mkMetaContext public (#6113) 2024-11-18 06:14:34 +00:00
Kim Morrison
e10fac93a6 feat: lemmas for Array.findSome? and find? (#6111)
This PR fills in the API for `Array.findSome?` and `Array.find?`,
transferring proofs from the corresponding List statements.
2024-11-18 04:19:56 +00:00
Kyle Miller
62ae320e1c chore: document Lean.Elab.StructInst, refactor (#6110)
This PR does some mild refactoring of the `Lean.Elab.StructInst` module
while adding documentation.

Documentation is drawn from @thorimur's #1928.
2024-11-18 02:57:22 +00:00
Leonardo de Moura
98b1edfc1f fix: backtrack at injection failure (#6109)
This PR fixes an issue in the `injection` tactic. This tactic may
execute multiple sub-tactics. If any of them fail, we must backtrack the
partial assignment. This issue was causing the error: "`mvarId` is
already assigned" in issue #6066. The issue is not yet resolved, as the
equation generator for the match expressions is failing in the example
provided in this issue.
2024-11-18 02:26:06 +00:00
Leonardo de Moura
ab162b3f52 fix: isDefEq, whnf, simp caching and configuration (#6053)
This PR fixes the caching infrastructure for `whnf` and `isDefEq`,
ensuring the cache accounts for all relevant configuration flags. It
also cleans up the `WHNF.lean` module and improves the configuration of
`whnf`.
2024-11-18 01:17:26 +00:00
Kim Morrison
b8a13ab755 chore: fix naming of left/right injectivity lemmas (#6106)
We've been internally inconsistent on the naming of these lemmas in
Lean; this changes them to match Mathlib (which, moreover, I think is
correct).
2024-11-18 00:53:46 +00:00
Sebastian Ullrich
405593ea28 chore: avoid stack overflow in debug tests (#6103) 2024-11-17 14:54:49 +00:00
Kim Morrison
24f305c0e3 chore: fix canonicalizer handling over forall/lambda (#6082)
This PR changes how the canonicalizer handles `forall` and `lambda`,
replacing bvars with temporary fvars. Fixes a bug reported by @hrmacbeth
on
[zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Quantifiers.20in.20CanonM/near/482483448).
2024-11-17 07:34:45 +00:00
Leonardo de Moura
5d553d6369 fix: circular assignment at structure instance elaborator (#6105)
This PR fixes a stack overflow caused by a cyclic assignment in the
metavariable context. The cycle is unintentionally introduced by the
structure instance elaborator.

closes #3150
2024-11-17 00:56:52 +00:00
Sebastian Ullrich
a449e3fdd6 feat: IO.getTID (#6049)
This PR adds a primitive for accessing the current thread ID

To be used in a thread-aware trace profiler
2024-11-16 19:13:11 +00:00
Kyle Miller
764386734c fix: improvements to change tactic (#6022)
This PR makes the `change` tactic and conv tactic use the same
elaboration strategy. It works uniformly for both the target and local
hypotheses. Now `change` can assign metavariables, for example:
```lean
example (x y z : Nat) : x + y = z := by
  change ?a = _
  let w := ?a
  -- now `w : Nat := x + y`
```
2024-11-16 07:08:29 +00:00
Kyle Miller
7f1d7a595b fix: use Expr.equal instead of == in MVarId.replaceTargetDefEq and MVarId.replaceLocalDeclDefEq (#6098)
This PR modifies `Lean.MVarId.replaceTargetDefEq` and
`Lean.MVarId.replaceLocalDeclDefEq` to use `Expr.equal` instead of
`Expr.eqv` when determining whether the expression has changed. This is
justified on the grounds that binder names and binder infos are
user-visible and affect elaboration.
2024-11-16 02:03:16 +00:00
Leonardo de Moura
f13e5ca852 chore: naming convention and NaN normalization (#6097)
Changes:
- `Float.fromBits` => `Float.ofBits`
- NaN normalization
2024-11-16 00:14:28 +00:00
Leonardo de Moura
ecbaeff24b feat: add Float.toBits and Float.fromBits (#6094)
This PR adds raw transmutation of floating-point numbers to and from
`UInt64`. Floats and UInts share the same endianness across all
supported platforms. The IEEE 754 standard precisely specifies the bit
layout of floats. Note that `Float.toBits` is distinct from
`Float.toUInt64`, which attempts to preserve the numeric value rather
than the bitwise value.

closes #6071
2024-11-15 19:45:19 +00:00
Kyle Miller
691acde696 feat: pp.parens option to pretty print with all parentheses (#2934)
This PR adds the option `pp.parens` (default: false) that causes the
pretty printer to eagerly insert parentheses, which can be useful for
teaching and for understanding the structure of expressions. For
example, it causes `p → q → r` to pretty print as `p → (q → r)`.

Any notations with precedence greater than or equal to `maxPrec` do not
receive such discretionary parentheses, since this precedence level is
considered to be infinity.

This option was a feature in the Lean 3 community edition.
2024-11-15 19:11:54 +00:00
Kyle Miller
b1e0c1b594 chore: remove decide! tactic (#6016)
This PR removes the `decide!` tactic in favor of `decide +kernel`
(breaking change).
2024-11-15 17:49:33 +00:00
Joachim Breitner
93b4ec0351 refactor: use mkFreshUserName in ArgsPacker (#6093)
and other small refinements done while investigating an issue; not
actually user-visible.
2024-11-15 15:59:14 +00:00
JovanGerb
f06fc30c0b perf: remove @[specialize] from mkBinding (#6019)
This PR removes @[specilize] from `MkBinding.mkBinding`, which is a
function that cannot be specialized (as none of its arguments are
functions). As a result, the specializable function `Nat.foldRevM.loop`
doesn't get specialized, which leads to worse performing code.

As expected, the mathlib bench shows a very small improvement. About 95%
of files show a speedup.
(http://speed.lean-fro.org/mathlib4/compare/e7b27246-a3e6-496a-b552-ff4b45c7236e/to/6033df75-aa53-44d9-819d-51f93fc05e94?hash1=b28f0d7f7e9cc3949a9a3556a6b36513f37f690d)
2024-11-15 15:06:49 +00:00
Markus Himmel
64b35a8c19 perf: add LEAN_ALWAYS_INLINE to some functions (#6045)
Otherwise, clang refuses to inline them for large functions which leads
to a performance cliff.
2024-11-15 15:05:32 +00:00
Markus Himmel
688ee4c887 fix: constant folding for Nat.ble and Nat.blt (#6087)
This PR fixes a bug in the constant folding for the `Nat.ble` and
`Nat.blt` function in the old code generator, leading to a
miscompilation.

Closes #6086
2024-11-15 12:09:52 +00:00
Henrik Böving
9a3dd615e0 chore: bv_decide remove noop rewrites (#6080)
Merely removes rules that are actually just syntactic aliases but equal
at the `Expr` level.
2024-11-15 11:41:54 +00:00
Violeta Hernández
7e6363dc05 chore: join → flatten in docstring (#6040)
Update the docstring of `List.flatten`.
2024-11-15 10:11:42 +00:00
Kim Morrison
a074bd9a2b feat: implementation of Array.pmap (#6052)
This PR adds `Array.pmap`, as well as a `@[csimp]` lemma in terms of the
no-copy `Array.attachWith`.
2024-11-15 02:10:04 +00:00
Kyle Miller
498d41633b fix: pretty print .coeFun with terminfo of coercee (#6085)
This PR improves the term info for coercions marked with
`CoeFnType.coeFun` (such as `DFunLike.coe` in Mathlib), making "go to
definition" on the function name work. Hovering over such a coerced
function will show the coercee rather than the coercion expression. The
coercion expression can still be seen by hovering over the whitespace in
the function application.
2024-11-15 01:45:38 +00:00
Sofia Rodrigues
e0d7c3ac79 feat: add date and time functionality (#4904)
This PR introduces date and time functionality to the Lean 4 Std.

Breaking Changes:
- `Lean.Data.Rat` is now `Std.Internal.Rat` because it's used by the
DateTime library.

---------

Co-authored-by: Markus Himmel <markus@himmel-villmar.de>
Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-11-14 14:04:19 +00:00
Joachim Breitner
6a5b122b40 perf: use RArray in simp_arith meta code (#6068 part 2)
This PR makes `simp_arith` use `RArray` for the context of the
reflection proofs, which scales better when there are many variables.

On our synthetic benchmark:
```
simp_arith1               instructions    -25.1% (-4892.6 σ)
```

No effect on mathlib, though, guess it’s not used much on large goals there:
http://speed.lean-fro.org/mathlib4/compare/873b982b-2038-462a-9b68-0c0fc457f90d/to/56e66691-2f1f-4947-a922-37b80680315d
2024-11-14 14:08:48 +01:00
Joachim Breitner
bf9ddf2c74 chore: update stage0 2024-11-14 14:08:48 +01:00
Joachim Breitner
3f47871e73 perf: use RArray in simp_arith meta code (#6068 part 1)
This PR prepares #6068 by using the `RArray` data structure in
`simp_arith` the simp-arith meta code.

After the subsequent stage0 we can change the simp-arith theorems in
`Init`.
2024-11-14 14:08:48 +01:00
Joachim Breitner
85f25967ea feat: Lean.RArray (#6070)
This PR adds the Lean.RArray data structure.

This data structure is equivalent to `Fin n → α` or `Array α`, but
optimized for a fast kernel-reduction `get` operation.

It is not suitable as a general-purpose data structure. The primary
intended use case is the “denote” function of a typical proof by
reflection proof, where only the `get` operation is necessary, and where
using `List.get` unnecessarily slows down proofs with more than a
hand-full of atomic expressions.


There is no well-formedness invariant attached to this data structure,
to keep it concise; it's semantics is given through `RArray.get`. In
that way one can also view an `RArray` as a decision tree implementing
`Nat → α`.

In #6068 this data structure is used in `simp_arith`.
2024-11-14 10:56:50 +00:00
David Thrane Christiansen
8e1ddbc5aa fix: validate atoms modulo leading and trailing whitespace (#6012)
This PR improves the validation of new syntactic tokens. Previously, the
validation code had inconsistencies: some atoms would be accepted only
if they had a leading space as a pretty printer hint. Additionally,
atoms with internal whitespace are no longer allowed.

Closes #6011
2024-11-14 10:40:17 +00:00
Henrik Böving
e6e39f502f feat: add options to configure all of bv_decide's preprocessing (#6077)
This PR adds options to `bv_decide`'s configuration structure such that
all non mandatory preprocessing passes can be disabled.
2024-11-14 09:22:23 +00:00
Henrik Böving
debb82bc20 perf: make andFlattening work on deeply nested hyps in one pass (#6075)
No changelog as this PR improves performance of a feature that is not
yet released.
2024-11-14 09:09:25 +00:00
Violeta Hernández
9a85433477 refactor: allow Sort u in Squash (#6074)
Co-authored-by: Kim Morrison <kim@tqft.net>
2024-11-14 05:55:21 +00:00
Mac Malone
4616c0ac3e refactor: lake: avoid v! in builtin code (#6073)
Use of `v!` in Lake code can cause bootstrapping failures and is easily
avoided. It is perfectly safe in user code.
2024-11-14 05:00:02 +00:00
Leonardo de Moura
e55b681774 feat: add Context.setConfig (#6072)
This PR adds `Lean.Simp.Context.setConfig` function.
2024-11-14 00:32:13 +00:00
Kim Morrison
63132105ba feat: lemmas about for loops over Array (#6055)
This PR adds lemmas about for loops over `Array`, following the existing
lemmas for `List`.
2024-11-13 23:23:55 +00:00
Kim Morrison
350b36411c chore: upstream some NameMap functions (#6056) 2024-11-13 23:22:01 +00:00
Kim Morrison
1c30c76e72 chore: remove >6 month old deprecations (#6057) 2024-11-13 23:21:23 +00:00
Alissa Tung
d5adadc00e chore: add newline at end of file for lake new templates (#6026)
This PR adds a newline at end of each Lean file generated by `lake new`
templates.

I have tested it with a locally compiled Lean with this commit. I hope
these changes make `lake new`'s behavior more consistent with the Lean 4
plugins and libraries newlines convention.
2024-11-13 19:39:47 +00:00
Mac Malone
f08805e5c4 feat: message kinds (#5945)
This PR adds a new definition `Message.kind` which returns the top-level
tag of a message. This is serialized as the new field `kind` in
`SerialMessaege` so that i can be used by external consumers (e.g.,
Lake) to identify messages via `lean --json`.

The tag of trace messages has also been changed from `_traceMsg` to the
more friendly `trace`.
2024-11-13 18:05:52 +00:00
Joachim Breitner
256b49bda9 perf: optimize Nat.Linear.Poly.norm (#6064)
Not a huge benefit, but actually reduces the code complexity (no need
for the `.fuse` function), and can help with problems with many repeated
varibles.
2024-11-13 17:36:51 +00:00
Kyle Miller
28cf146d00 fix: make sure monad lift coercion elaborator has no side effects (#6024)
This PR fixes a bug where the monad lift coercion elaborator would
partially unify expressions even if they were not monads. This could be
taken advantage of to propagate information that could help elaboration
make progress, for example the first `change` worked because the monad
lift coercion elaborator was unifying `@Eq _ _` with `@Eq (Nat × Nat)
p`:
```lean
example (p : Nat × Nat) : p = p := by
  change _ = ⟨_, _⟩ -- used to work (yielding `p = (p.fst, p.snd)`), now it doesn't
  change ⟨_, _⟩ = _ -- never worked
```
As such, this is a breaking change; you may need to adjust expressions
to include additional implicit arguments.
2024-11-13 16:22:31 +00:00
Joachim Breitner
970261b1e1 perf: optimize Nat.Linear.Expr.toPoly (#6062) 2024-11-13 15:54:29 +00:00
Joachim Breitner
6b811f8c92 test: synthetic simp_arith benchmark (#6061)
This PR adds a simp_arith benchmark.

This benchmark highlights some improvable asymptotics in `Nat.Linear`,
which
will be fixed subsequently.
2024-11-13 15:49:52 +00:00
Henrik Böving
f721f94045 feat: Bool.to(U)IntX (#6060)
This PR implements conversion functions from `Bool` to all `UIntX` and
`IntX` types.

Note that `Bool.toUInt64` already existed in previous versions of Lean.
2024-11-13 15:49:16 +00:00
Sebastian Ullrich
86524d5c23 fix: line break in simp? output (#6048)
This PR fixes `simp?` suggesting output with invalid indentation 

Fixes #6006
2024-11-13 15:49:11 +00:00
Joachim Breitner
f18d9e04bc refactor: omega: avoid MVar machinery (#5991)
This PR simplifies the implementation of `omega`.

When constructing the proof, `omega` is using MVars only for the purpose
of doing case analysis on `Or`. We can simplify the implementation a
fair bit if we just produce the proof directly using `Or.elim`.

While it didn’t yield the performance benefits I was hoping for, this
still seems a worthwhile simplification, now that we already have it.
2024-11-13 15:49:03 +00:00
Joachim Breitner
fa33423c84 chore: pr-body: run as part of merge_group, but do not do anything (#6069) 2024-11-13 15:47:58 +00:00
Leonardo de Moura
1315266dd3 refactor: mark the Simp.Context constructor as private
motivation: this is the first step to fix the mismatch
between `isDefEq` and the discrimination tree indexing.
2024-11-13 14:12:55 +11:00
Leonardo de Moura
b1e52f1475 chore: mark Meta.Context.config as private (#6051)
Motivation: we want to modify the internal representation and improve
`isDefEq` caching.
This PR is preparing the stage for future modifications.
2024-11-13 13:30:06 +11:00
Kim Morrison
985600f448 chore: update stage0 2024-11-13 11:16:34 +11:00
Kim Morrison
ace6248e20 chore: deprecate Array.sequenceMap 2024-11-13 11:16:34 +11:00
Lean stage0 autoupdater
9f42368e1a chore: update stage0 2024-11-12 13:28:14 +00:00
Kim Morrison
a401368384 feat: various minor changes to List/Array API (#6044)
Minor emendations to the List/Array API, collected from other PRs that
are still in the pipeline.
2024-11-12 08:27:36 +00:00
Kim Morrison
5e01e628b2 chore: review Array operations argument order (#6041)
This PR modifies the order of arguments for higher-order `Array`
functions, preferring to put the `Array` last (besides positional
arguments with defaults). This is more consistent with the `List` API,
and is more flexible, as dot notation allows two different partially
applied versions.
2024-11-12 04:55:03 +00:00
Kim Morrison
3a408e0e54 feat: change Array.get to take a Nat and a proof (#6032)
This PR changes the signature of `Array.get` to take a Nat and a proof,
rather than a `Fin`, for consistency with the rest of the (planned)
Array API. Note that because of bootstrapping issues we can't provide
`get_elem_tactic` as an autoparameter for the proof. As users will
mostly use the `xs[i]` notation provided by `GetElem`, this hopefully
isn't a problem.

We may restore `Fin` based versions, either here or downstream, as
needed, but they won't be the "main" functions.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-11-12 03:30:46 +00:00
Kyle Miller
675d2d5a11 feat: only direct parents of classes create projections (#5920)
This PR changes the rule for which projections become instances. Before,
all parents along with all indirect ancestors that were represented as
subobject fields would have their projections become instances. Now only
projections for direct parents become instances.

Features:
- Only parents that are not ancestors of other parents get instances.
This allows "discretionary" indirect parents to be inserted for the
purpose of computing strict resolution orders when
`structure.strictResolutionOrder` is enabled, without having an impact
on typeclass synthesis.
- Non-subobject projections are now theorems if the parent is a
proposition. These are also no longer `@[reducible]`.

Closes #2905
2024-11-12 01:55:17 +00:00
Henrik Böving
281c07ca97 fix: bv_decide embedded constraint substitution changes models (#6037)
This PR fixes `bv_decide`'s embedded constraint substitution to generate
correct counter examples in the corner case where duplicate theorems are
in the local context.
2024-11-11 16:33:21 +00:00
Sebastian Ullrich
004430b568 fix: avoid new term info around def bodies (#6031)
This PR fixes a regression with go-to-definition and document highlight
misbehaving on tactic blocks.

We explicitly avoid creating term info nodes around `by` blocks, which
#5338 might accidentally do; as the new info is not relevant for the
server, it is instead moved into a custom info.

Reported at
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Go-to-def.20for.20tactics.20broken.20on.20v4.2E14.2E0-rc1.
2024-11-11 14:54:59 +00:00
Henrik Böving
61f7dcb36b feat: bv_decide and flattening (#6035)
This PR introduces the and flattening pre processing pass from Bitwuzla
to `bv_decide`. It splits hypotheses of the form `(a && b) = true` into
`a = true` and `b = true` which has synergy potential with the already
existing embedded constraint substitution pass.

Beyond this I also added some profiling infra structure for the passes.
2024-11-11 13:28:37 +00:00
Joachim Breitner
5c611f7814 fix: simp only [· ∈ ·] (#6030)
This PR fixes `simp only [· ∈ ·]` after #5020.

Fixes #5905
2024-11-11 10:03:27 +00:00
Siddharth
722cb73019 feat: BitVec normalization rule for udiv by twoPow (#6029)
This PR adds a normalization rule to `bv_normalize` (which is used by
`bv_decide`) that converts `x / 2^k` into `x >>> k` under suitable
conditions. This allows us to simplify the expensive division circuits
that are used for bitblasting into much cheaper shifting circuits.
Concretely, it allows for the following canonicalization:

```lean
example {x : BitVec 16} : x / (BitVec.twoPow 16 2) = x >>> 2 := by bv_normalize
example {x : BitVec 16} : x / (BitVec.ofNat 16 8) = x >>> 3 := by bv_normalize
```
2024-11-11 09:45:47 +00:00
Kim Morrison
258d3725e7 feat: change Array.set to take a Nat and a tactic provided bound (#5988)
This PR changes the signature of `Array.set` to take a `Nat`, and a
tactic-provided bound, rather than a `Fin`.

Corresponding changes (but without the auto-param) for `Array.get` will
arrive shortly, after which I'll go more pervasively through the Array
API.
2024-11-11 07:53:24 +00:00
Kim Morrison
456e6d2b79 chore: deprecate duplicated Fin.size_pos (#6025) 2024-11-11 04:06:13 +00:00
Kim Morrison
48e3d76173 feat: variants of List.forIn_eq_foldlM (#6023) 2024-11-11 02:30:40 +00:00
Siddharth
78fe92507c feat: BitVec lemmas for smtUDiv, smtSDiv when denominator is zero (#5616)
This PR is a follow-up to https://github.com/leanprover/lean4/pull/5609,
where we add lemmas characterizing `smtUDiv` and `smtSDiv`'s behavior
when the denominator is zero.

We build some `slt` theory, connecting it to `msb` for a clean proof. I
chose not to characterize `slt` in terms of `msb` a `simp` lemma, since
I anticipate use cases where we want to keep the arithmetic
interpretation of `slt`.
2024-11-10 22:08:43 +00:00
JovanGerb
811d8fb3c0 chore: cleanup (#6021)
This PR removes
- a duplicate `MonadMCtx` instance in `MetavarContext.lean`
- `:= return ←` that I had left there accidentally in a previous PR.
- the unnecessary application of `mapMetaM` in `withTransparency`.
2024-11-09 23:16:12 +00:00
Sebastian Ullrich
f55a9a71cb chore: CI: do not run check-pr-body in merge group 2024-11-09 12:58:53 +01:00
Henrik Böving
d12df6c2ad fix: bv_decide benchmarks (#6017)
This PR fixes the nightly build after bv_decide changed its options
2024-11-09 11:18:33 +00:00
Kyle Miller
d1a99d8d45 fix: avoid delaborating with field notation if object is a metavariable (#6014)
This PR prevents `Nat.succ ?_` from pretty printing as `?_.succ`, which
should make `apply?` be more usable.

Closes #5993
2024-11-08 20:57:37 +00:00
Kyle Miller
c10e4c2256 feat: prop instance yields theorems (#5856)
This PR adds a feature to the the mutual def elaborator where the
`instance` command yields theorems instead of definitions when the class
is a `Prop`.

Closes #5672
2024-11-08 18:18:10 +00:00
Kyle Miller
e3420c08f1 feat: decide +revert and improvements to native_decide (#5999)
This PR adds configuration options for
`decide`/`decide!`/`native_decide` and refactors the tactics to be
frontends to the same backend. Adds a `+revert` option that cleans up
the local context and reverts all local variables the goal depends on,
along with indirect propositional hypotheses. Makes `native_decide` fail
at elaboration time on failure without sacrificing performance (the
decision procedure is still evaluated just once). Now `native_decide`
supports universe polymorphism.

Closes #2072
2024-11-08 18:17:46 +00:00
Sebastian Ullrich
4f7aa8c3c8 chore: CI: exempt drafts from PR body check (#6002) 2024-11-08 15:53:48 +00:00
Sebastian Ullrich
dac73c15c8 perf: avoid negative environment lookup (#5429)
Avoids some `Environment.find?` lookup misses that become especially
expensive on the async branch
2024-11-08 15:37:39 +00:00
Marc Huisinga
cb40ddad69 fix: avoid max heartbeat error in completion (#5996)
This now occurs for some large completions downstream of `import
Mathlib`. I'd like to get rid of this `whnf` call entirely in the
future, but this is a decent quick mitigation.
2024-11-08 13:47:10 +00:00
Alex Keizer
fc0529b020 fix: ensure instantiateMVarsProfiling adds a trace node (#5501)
We add a new `Meta.instantiateMVars` trace node to the
`instantiateMVarsProfiling` definition used in `elabMutualDef`, and we
replace various uses of plain `instantiateMVars` with the profiled
version (which necessitated pulling up the definition to be higher in
the file).

This fixes a "time leak" when profiling large proofs, where
instantiating the goal metavariable can take a significant amount of
time, that previously would not be accounted for when using the trace
profiler.
2024-11-08 13:26:44 +00:00
Henrik Böving
837a67bedb feat: change bv_decide to an elaborated config (#6010)
This PR changes `bv_decide`'s configuration from lots of `set_option` to
an elaborated config like `simp` or `omega`. The notable exception is
`sat.solver` which is still a `set_option` such that users can configure
a custom SAT solver globally for an entire project or file. Additionally
it introduces the ability to set `maxSteps` for the simp preprocessing
run through the new config.

The latter feature was requested by people using `bv_decide` on SMTLIB
which has ginormous terms that exceed the default.
2024-11-08 13:15:04 +00:00
Kyle Miller
85f2213d5a fix: unset trailing for simpa? "try this" suggestion (#5907)
Closes #4581
2024-11-08 12:36:49 +00:00
Lukas Gerlach
9b167e2051 feat: verify keys method on HashMaps (#5866)
This PR verifies the `keys` function on `Std.HashMap`.

---

Initial discussions have already happend with @TwoFX and we are
collaborating on this matter.
This will remain a draft as long as not all desired results have been
added.

If we should still create an issue for the topic of this PR, let us
know.
Of course, any other feedback is appreciated as well :)

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
Co-authored-by: monsterkrampe <monsterkrampe@users.noreply.github.com>
Co-authored-by: jt0202 <johannes.tantow@gmail.com>
2024-11-08 07:24:58 +00:00
Kim Morrison
1870c003d0 chore: missing @[ext] attribute on monad transformer ext lemmas (#6008) 2024-11-08 06:53:49 +00:00
Kim Morrison
680177049f chore: List.modifyTailIdx naming fix (#6007) 2024-11-08 02:42:06 +00:00
Sebastian Ullrich
1b806c5535 chore: revert "CI: give Linux Debug unlimited test stack size" (#6001)
#5967 was the correct fix

Reverts leanprover/lean4#5953
2024-11-07 21:15:08 +00:00
Sebastian Ullrich
9b18262567 chore: new PR changelog template (#5976)
Enables us to auto-generate the changelog from the list of PRs for a
modicum of summarizing/categorizing work on PR creation.

Does not (yet) allow external contributors to set category labels by
themselves as this creates issues with triggering one workflow from
another, it is not clear whether they should be allowed to create new
categories, and the reviewer/triage team likely is in a better position
to do the categorization anyway.
2024-11-07 16:59:45 +00:00
Henrik Böving
d76d631856 feat: BitVec.sshiftRight' in bv_decide (#5995) 2024-11-07 15:23:45 +00:00
Henrik Böving
17e6f3b3c2 style: fix style in bv_decide normalizer (#5992)
Address comments by Markus in #5987
2024-11-07 11:56:12 +00:00
Sebastian Ullrich
5f7a40ae48 chore: fix test exclusion (#5990)
You cannot pass `-E` to `ctest` multiple times
2024-11-07 10:41:47 +00:00
Joachim Breitner
70435dfb5f refactor: name the default SizeOf instance (#5981)
This PR names the default SizeOf instance `instSizeOfDefault`

I regularly have to debug termination checking failures where I end up
hovering over some termination measure, and seeing `instSizeOfDefault`
is more likely to tell me that the default instance is used than
`instSizeOf`.
2024-11-07 09:21:32 +00:00
Henrik Böving
59ee47ad44 feat: BitVec.getMsbD in bv_decide (#5987)
Closes #5983.
2024-11-07 07:59:14 +00:00
Kim Morrison
ebc02fc6e8 feat: lemmas relating Array.findX and List.findX (#5985)
This PR relates the operations `findSomeM?`, `findM?`, `findSome?`, and
`find?` on `Array` with the corresponding operations on `List`, and also
provides simp lemmas for the `Array` operations `findSomeRevM?`,
`findRevM?`, `findSomeRev?`, `findRev?` (in terms of `reverse` and the
usual forward find operations).
2024-11-07 03:30:11 +00:00
Kim Morrison
05caf1bda9 feat: interactions between List.foldX and List.filterX (#5984)
This PR adds lemmas for `List` for the interactions between {`foldl`,
`foldr`, `foldlM`, `foldlrM`} and {`filter`, `filterMap`}.
2024-11-07 02:37:20 +00:00
Kim Morrison
b1dee4a42e chore: upstream List.insertIdx from Batteries, lemmas from Mathlib, and revise lemmas (#5969)
To follow, connecting this to `Array.insertAt` (and renaming).
2024-11-06 23:29:27 +00:00
Kim Morrison
a54226196d feat: minor lemmas about List.ofFn (#5982)
`List.ofFn` still has very incomplete API.
2024-11-06 23:05:42 +00:00
Henrik Böving
196b1e9250 feat: BitVec.twoPow in bv_decide (#5979) 2024-11-06 17:51:44 +00:00
Sebastian Ullrich
345ecd20c9 chore: tag prerelease builds with -pre (#5943) 2024-11-06 14:47:52 +00:00
dependabot[bot]
7f0fe20315 chore: CI: bump mymindstorm/setup-emsdk from 12 to 14 (#5963)
Bumps
[mymindstorm/setup-emsdk](https://github.com/mymindstorm/setup-emsdk)
from 12 to 14.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/mymindstorm/setup-emsdk/releases">mymindstorm/setup-emsdk's
releases</a>.</em></p>
<blockquote>
<h2>Version 14</h2>
<h1>Breaking Changes</h1>
<p>The default cache key naming scheme was changed from
<code>{Emscripten version}-{OS type}-${CPU architecture}-master</code>
to <code>{Github workflow name}-{Emscripten version}-{OS type}-${CPU
architecture}</code>. If <code>actions-cache-folder</code> is defined,
ensure that there are no conflicts with other caches to prevent
issues.</p>
<h1>Changelog</h1>
<ul>
<li>Add option to override cache key naming scheme (<a
href="https://redirect.github.com/mymindstorm/setup-emsdk/issues/20">#20</a>)</li>
<li>Add workflow name to cache key naming scheme (<a
href="https://redirect.github.com/mymindstorm/setup-emsdk/issues/20">#20</a>)</li>
<li>Updated dependencies to latest versions</li>
</ul>
<h2>Version 13</h2>
<ul>
<li>Updated to Node 20</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="6ab9eb1bda"><code>6ab9eb1</code></a>
v13 -&gt; v14</li>
<li><a
href="bb630c3bf4"><code>bb630c3</code></a>
Update all dependencies to latest versions</li>
<li><a
href="74881103d0"><code>7488110</code></a>
Add workflow ID to cache key and cache key override option (<a
href="https://redirect.github.com/mymindstorm/setup-emsdk/issues/40">#40</a>)</li>
<li><a
href="d233ac12b0"><code>d233ac1</code></a>
v13</li>
<li><a
href="1749b22b40"><code>1749b22</code></a>
npm audit fix + update runtime to node20</li>
<li>See full diff in <a
href="https://github.com/mymindstorm/setup-emsdk/compare/v12...v14">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=mymindstorm/setup-emsdk&package-manager=github_actions&previous-version=12&new-version=14)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-06 10:45:31 +00:00
Kim Morrison
1e98fd7f2d feat: add another List.find?_eq_some lemma (#5974)
Inspired by https://github.com/leanprover-community/mathlib4/pull/18593
2024-11-06 10:02:25 +00:00
Markus Himmel
76d32cbd2a chore: exclude leanruntest_task_test_io for now (#5973)
To be reenabled after investigation.
2024-11-06 09:40:20 +00:00
Kim Morrison
15139b6ef6 feat: relate Array.zipWith/zip/unzip with List versions (#5972) 2024-11-06 09:22:08 +00:00
Sebastian Ullrich
14c3d4b1a6 chore: CI: remove link checker for old manual
It started failing frequently after updating it and we're not actively working on this text anyway
2024-11-06 10:27:25 +01:00
Kim Morrison
910b20fb2c chore: consolidate decide_True and decide_true_eq_true (#5949) 2024-11-06 05:12:25 +00:00
Kim Morrison
4df71ed24f feat: relate Array.isPrefixOf with List.isPrefixOf (#5971) 2024-11-06 02:44:14 +00:00
Kyle Miller
406da78fc6 fix: arg conv tactic misreported number of arguments on error (#5968) 2024-11-06 02:13:24 +00:00
Kim Morrison
5d2bd1e2e4 chore: deprecate Array.split in favour of identical Array.partition (#5970) 2024-11-06 00:37:33 +00:00
Kyle Miller
c31daece6c chore: fix all_goals test, simulate the max rec depth error (#5967) 2024-11-05 20:09:06 +00:00
Markus Himmel
c157ddda11 fix: do not link statically against pthread/dl/rt (#5966) 2024-11-05 18:20:42 +00:00
Henrik Böving
c77b6a2c64 feat: define ISize and basic operations on it (#5961) 2024-11-05 15:08:19 +00:00
dependabot[bot]
c6e4947f4a chore: CI: bump dcarbone/install-jq-action from 1.0.1 to 2.1.0 (#5965)
Bumps
[dcarbone/install-jq-action](https://github.com/dcarbone/install-jq-action)
from 1.0.1 to 2.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/dcarbone/install-jq-action/releases">dcarbone/install-jq-action's
releases</a>.</em></p>
<blockquote>
<h2>v2.1.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Support running action inside containers by <a
href="https://github.com/TaxBusby"><code>@​TaxBusby</code></a> in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/10">dcarbone/install-jq-action#10</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/TaxBusby"><code>@​TaxBusby</code></a>
made their first contribution in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/10">dcarbone/install-jq-action#10</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dcarbone/install-jq-action/compare/v2.0.2...v2.1.0">https://github.com/dcarbone/install-jq-action/compare/v2.0.2...v2.1.0</a></p>
<h2>v2.0.2</h2>
<h2>What's Changed</h2>
<ul>
<li>use curl instead of wget to avoid download failure on macOS by <a
href="https://github.com/vaidyakhil"><code>@​vaidyakhil</code></a> in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/8">dcarbone/install-jq-action#8</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/vaidyakhil"><code>@​vaidyakhil</code></a> made
their first contribution in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/8">dcarbone/install-jq-action#8</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dcarbone/install-jq-action/compare/v2.0.1...v2.0.2">https://github.com/dcarbone/install-jq-action/compare/v2.0.1...v2.0.2</a></p>
<h2>v2.0.1</h2>
<h2>What's Changed</h2>
<ul>
<li>using macos as dl link os prefix in lieu of osx by <a
href="https://github.com/dcarbone"><code>@​dcarbone</code></a> in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/7">dcarbone/install-jq-action#7</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dcarbone/install-jq-action/compare/v2.0.0...v2.0.1">https://github.com/dcarbone/install-jq-action/compare/v2.0.0...v2.0.1</a></p>
<h2>v2.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>quick &amp; dirty 1.7 support by <a
href="https://github.com/dcarbone"><code>@​dcarbone</code></a> in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/4">dcarbone/install-jq-action#4</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/dcarbone"><code>@​dcarbone</code></a>
made their first contribution in <a
href="https://redirect.github.com/dcarbone/install-jq-action/pull/4">dcarbone/install-jq-action#4</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dcarbone/install-jq-action/compare/v1.0.1...v2.0.0">https://github.com/dcarbone/install-jq-action/compare/v1.0.1...v2.0.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8867ddb478"><code>8867ddb</code></a>
remove windows gubbins from container tests</li>
<li><a
href="945d84920f"><code>945d849</code></a>
Support running action inside containers (<a
href="https://redirect.github.com/dcarbone/install-jq-action/issues/10">#10</a>)</li>
<li><a
href="1090b8bd11"><code>1090b8b</code></a>
use curl instead of wget to fix failure on macOS runners (<a
href="https://redirect.github.com/dcarbone/install-jq-action/issues/8">#8</a>)</li>
<li><a
href="ff922c75b7"><code>ff922c7</code></a>
Update example-windows.yaml</li>
<li><a
href="7f4d6f4833"><code>7f4d6f4</code></a>
Update example-macos.yaml</li>
<li><a
href="bfb9fa8e7d"><code>bfb9fa8</code></a>
Update example-linux.yaml</li>
<li><a
href="c1548c666d"><code>c1548c6</code></a>
using macos as dl link os prefix in lieu of osx (<a
href="https://redirect.github.com/dcarbone/install-jq-action/issues/7">#7</a>)</li>
<li><a
href="f07422da1e"><code>f07422d</code></a>
fixing version</li>
<li><a
href="183bc8df0e"><code>183bc8d</code></a>
trying without stupid</li>
<li><a
href="f6b58bacfe"><code>f6b58ba</code></a>
its late.</li>
<li>Additional commits viewable in <a
href="https://github.com/dcarbone/install-jq-action/compare/v1.0.1...v2.1.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dcarbone/install-jq-action&package-manager=github_actions&previous-version=1.0.1&new-version=2.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 11:23:59 +00:00
dependabot[bot]
01814185a6 chore: CI: bump dawidd6/action-download-artifact from 2 to 6 (#5964)
Bumps
[dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact)
from 2 to 6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/dawidd6/action-download-artifact/releases">dawidd6/action-download-artifact's
releases</a>.</em></p>
<blockquote>
<h2>v6</h2>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v5...v6">https://github.com/dawidd6/action-download-artifact/compare/v5...v6</a></p>
<h2>v5</h2>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v4...v5">https://github.com/dawidd6/action-download-artifact/compare/v4...v5</a></p>
<h2>v4</h2>
<h2>What's Changed</h2>
<ul>
<li><strong>VERSIONING CHANGE</strong>: now there will only be major
releases of this action, e.g. v5, v6 and so on</li>
<li>build(deps): bump undici from 5.28.3 to 5.28.4 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/284">dawidd6/action-download-artifact#284</a></li>
<li>build(deps): bump <code>@​actions/artifact</code> from 2.1.4 to
2.1.5 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/285">dawidd6/action-download-artifact#285</a></li>
<li>build(deps): bump <code>@​actions/artifact</code> from 2.1.5 to
2.1.7 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/287">dawidd6/action-download-artifact#287</a></li>
<li>build(deps): bump adm-zip from 0.5.12 to 0.5.13 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/289">dawidd6/action-download-artifact#289</a></li>
<li>Set allow_forks to false by default by <a
href="https://github.com/timweri"><code>@​timweri</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/290">dawidd6/action-download-artifact#290</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/timweri"><code>@​timweri</code></a> made
their first contribution in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/290">dawidd6/action-download-artifact#290</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v3...v4">https://github.com/dawidd6/action-download-artifact/compare/v3...v4</a></p>
<h2>v3.1.4</h2>
<h2>What's Changed</h2>
<ul>
<li>build(deps): bump adm-zip from 0.5.10 to 0.5.12 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/282">dawidd6/action-download-artifact#282</a></li>
<li>build(deps): bump <code>@​actions/artifact</code> from 2.1.2 to
2.1.4 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/280">dawidd6/action-download-artifact#280</a></li>
<li>fix: accept expired artifacts with documentation url by <a
href="https://github.com/wdconinc"><code>@​wdconinc</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/283">dawidd6/action-download-artifact#283</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/wdconinc"><code>@​wdconinc</code></a>
made their first contribution in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/283">dawidd6/action-download-artifact#283</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v3...v3.1.4">https://github.com/dawidd6/action-download-artifact/compare/v3...v3.1.4</a></p>
<h2>v3.1.3</h2>
<h2>What's Changed</h2>
<ul>
<li>node_modules: upgrade by <a
href="https://github.com/dawidd6"><code>@​dawidd6</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/276">dawidd6/action-download-artifact#276</a></li>
<li>build(deps): bump <code>@​actions/artifact</code> from 2.1.1 to
2.1.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/277">dawidd6/action-download-artifact#277</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v3.1.2...v3.1.3">https://github.com/dawidd6/action-download-artifact/compare/v3.1.2...v3.1.3</a></p>
<h2>v3.1.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Read workflow_search input as a boolean by <a
href="https://github.com/klutchell"><code>@​klutchell</code></a> in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/273">dawidd6/action-download-artifact#273</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/klutchell"><code>@​klutchell</code></a>
made their first contribution in <a
href="https://redirect.github.com/dawidd6/action-download-artifact/pull/273">dawidd6/action-download-artifact#273</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/dawidd6/action-download-artifact/compare/v3.1.1...v3.1.2">https://github.com/dawidd6/action-download-artifact/compare/v3.1.1...v3.1.2</a></p>
<h2>v3.1.1</h2>
<h2>What's Changed</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="bf251b5aa9"><code>bf251b5</code></a>
node_modules: upgrade</li>
<li><a
href="93c6296611"><code>93c6296</code></a>
README: v5</li>
<li><a
href="deb3bb8325"><code>deb3bb8</code></a>
node_modules: upgrade</li>
<li><a
href="1d93f37db2"><code>1d93f37</code></a>
README: v4</li>
<li><a
href="854e2de939"><code>854e2de</code></a>
Set allow_forks to false by default (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/290">#290</a>)</li>
<li><a
href="436c9d3774"><code>436c9d3</code></a>
build(deps): bump adm-zip from 0.5.12 to 0.5.13 (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/289">#289</a>)</li>
<li><a
href="14040524bb"><code>1404052</code></a>
build(deps): bump <code>@​actions/artifact</code> from 2.1.5 to 2.1.7
(<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/287">#287</a>)</li>
<li><a
href="8a9be734dc"><code>8a9be73</code></a>
build(deps): bump <code>@​actions/artifact</code> from 2.1.4 to 2.1.5
(<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/285">#285</a>)</li>
<li><a
href="df593bbd04"><code>df593bb</code></a>
build(deps): bump undici from 5.28.3 to 5.28.4 (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/284">#284</a>)</li>
<li><a
href="09f2f74827"><code>09f2f74</code></a>
fix: accept expired artifacts with documentation url (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/283">#283</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/dawidd6/action-download-artifact/compare/v2...v6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dawidd6/action-download-artifact&package-manager=github_actions&previous-version=2&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 11:12:20 +00:00
dependabot[bot]
47d0060934 chore: CI: bump actions/github-script from 6 to 7 (#5962)
Bumps [actions/github-script](https://github.com/actions/github-script)
from 6 to 7.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/github-script/releases">actions/github-script's
releases</a>.</em></p>
<blockquote>
<h2>v7.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Add base-url option by <a
href="https://github.com/robandpdx"><code>@​robandpdx</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/429">actions/github-script#429</a></li>
<li>Expose async-function argument type by <a
href="https://github.com/viktorlott"><code>@​viktorlott</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/402">actions/github-script#402</a>,
see for details <a
href="https://github.com/actions/github-script#use-scripts-with-jsdoc-support">https://github.com/actions/github-script#use-scripts-with-jsdoc-support</a></li>
<li>Update dependencies and use Node 20 by <a
href="https://github.com/joshmgross"><code>@​joshmgross</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/425">actions/github-script#425</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/navarroaxel"><code>@​navarroaxel</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/285">actions/github-script#285</a></li>
<li><a href="https://github.com/robandpdx"><code>@​robandpdx</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/429">actions/github-script#429</a></li>
<li><a
href="https://github.com/viktorlott"><code>@​viktorlott</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/402">actions/github-script#402</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-script/compare/v6.4.1...v7.0.0">https://github.com/actions/github-script/compare/v6.4.1...v7.0.0</a></p>
<h2>v6.4.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Add <code>@​octokit/plugin-request-log</code>, to produce debug
output for requests by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/358">actions/github-script#358</a></li>
<li>fix input handling by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/357">actions/github-script#357</a></li>
<li>Remove unused dependencies by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/356">actions/github-script#356</a></li>
<li>Default debug to current runner debug state by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/363">actions/github-script#363</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/mjpieters"><code>@​mjpieters</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/358">actions/github-script#358</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-script/compare/v6.4.0...v6.4.1">https://github.com/actions/github-script/compare/v6.4.0...v6.4.1</a></p>
<h2>v6.4.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Bump json5 from 2.1.3 to 2.2.3 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/319">actions/github-script#319</a></li>
<li>Bump minimatch from 3.0.4 to 3.1.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/320">actions/github-script#320</a></li>
<li>Add node-fetch by <a
href="https://github.com/danmichaelo"><code>@​danmichaelo</code></a> in
<a
href="https://redirect.github.com/actions/github-script/pull/321">actions/github-script#321</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/jongwooo"><code>@​jongwooo</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/313">actions/github-script#313</a></li>
<li><a
href="https://github.com/austinvazquez"><code>@​austinvazquez</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/306">actions/github-script#306</a></li>
<li><a
href="https://github.com/danmichaelo"><code>@​danmichaelo</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/321">actions/github-script#321</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-script/compare/v6.3.3...v6.4.0">https://github.com/actions/github-script/compare/v6.3.3...v6.4.0</a></p>
<h2>v6.3.3</h2>
<h2>What's Changed</h2>
<ul>
<li>Update <code>@actions/glob</code> to 0.3.0 by <a
href="https://github.com/nineinchnick"><code>@​nineinchnick</code></a>
in <a
href="https://redirect.github.com/actions/github-script/pull/279">actions/github-script#279</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/nineinchnick"><code>@​nineinchnick</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-script/pull/279">actions/github-script#279</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-script/compare/v6.3.2...v6.3.3">https://github.com/actions/github-script/compare/v6.3.2...v6.3.3</a></p>
<h2>v6.3.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Update <code>@​actions/core</code> to 1.10.0 by <a
href="https://github.com/rentziass"><code>@​rentziass</code></a> in <a
href="https://redirect.github.com/actions/github-script/pull/295">actions/github-script#295</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="60a0d83039"><code>60a0d83</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/github-script/issues/440">#440</a>
from actions/joshmgross/v7.0.1</li>
<li><a
href="b7fb2001b4"><code>b7fb200</code></a>
Update version to 7.0.1</li>
<li><a
href="12e22ed06b"><code>12e22ed</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/github-script/issues/439">#439</a>
from actions/joshmgross/avoid-setting-base-url</li>
<li><a
href="d319f8f5b5"><code>d319f8f</code></a>
Avoid setting <code>baseUrl</code> to undefined when input is not
provided</li>
<li><a
href="e69ef5462f"><code>e69ef54</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/github-script/issues/425">#425</a>
from actions/joshmgross/node-20</li>
<li><a
href="ee0914b839"><code>ee0914b</code></a>
Update licenses</li>
<li><a
href="d6fc56f33b"><code>d6fc56f</code></a>
Use <code>@types/node</code> for Node 20</li>
<li><a
href="384d6cf581"><code>384d6cf</code></a>
Fix quotations in tests</li>
<li><a
href="84724927e3"><code>8472492</code></a>
Only validate GraphQL <code>previews</code></li>
<li><a
href="84903f5182"><code>84903f5</code></a>
Remove <code>node-fetch</code> from type</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/github-script/compare/v6...v7">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/github-script&package-manager=github_actions&previous-version=6&new-version=7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 11:06:39 +00:00
dependabot[bot]
b1c2d851e5 chore: CI: bump lycheeverse/lychee-action from 1.9.0 to 2.0.2 (#5959)
Bumps
[lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action)
from 1.9.0 to 2.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/lycheeverse/lychee-action/releases">lycheeverse/lychee-action's
releases</a>.</em></p>
<blockquote>
<h2>Version 2.0.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix a typos by <a
href="https://github.com/szepeviktor"><code>@​szepeviktor</code></a> in
<a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/257">lycheeverse/lychee-action#257</a></li>
<li>Document and use correct permissions in the GitHub workflows by <a
href="https://github.com/dscho"><code>@​dscho</code></a> in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/258">lycheeverse/lychee-action#258</a></li>
<li>Add security policy by <a
href="https://github.com/mondeja"><code>@​mondeja</code></a> in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/259">lycheeverse/lychee-action#259</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/szepeviktor"><code>@​szepeviktor</code></a>
made their first contribution in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/257">lycheeverse/lychee-action#257</a></li>
<li><a href="https://github.com/mondeja"><code>@​mondeja</code></a> made
their first contribution in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/259">lycheeverse/lychee-action#259</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/lycheeverse/lychee-action/compare/v2...v2.0.2">https://github.com/lycheeverse/lychee-action/compare/v2...v2.0.2</a></p>
<h2>Version 2.0.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Don't remove the lychee config file by <a
href="https://github.com/dmathieu"><code>@​dmathieu</code></a> in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/255">lycheeverse/lychee-action#255</a></li>
<li>Bump lycheeverse/lychee-action from 1 to 2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/252">lycheeverse/lychee-action#252</a></li>
<li>Fix variable name in docs by <a
href="https://github.com/kdeldycke"><code>@​kdeldycke</code></a> in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/253">lycheeverse/lychee-action#253</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/dmathieu"><code>@​dmathieu</code></a>
made their first contribution in <a
href="https://redirect.github.com/lycheeverse/lychee-action/pull/255">lycheeverse/lychee-action#255</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/lycheeverse/lychee-action/compare/v2...v2.0.1">https://github.com/lycheeverse/lychee-action/compare/v2...v2.0.1</a></p>
<h2>Version 2.0.0</h2>
<h2>Breaking Changes</h2>
<p><strong>Note:</strong> This release improves the action's robustness
by changing default behaviors. Changes are only required if you want to
opt out of the new failure conditions. Most users won't need to modify
their existing configurations.</p>
<h3>Fail pipeline on error by default</h3>
<p>We've changed the default behavior: pipelines will now fail on broken
links automatically. This addresses user feedback that not failing on
broken links was unexpected (see [issue <a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/71">#71</a>](<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/71">lycheeverse/lychee-action#71</a>)).</p>
<p><strong>What you need to do:</strong></p>
<ul>
<li>Update to version 2 of this action to apply this change.</li>
<li>Users of the <code>lychee-action@master</code> branch don't need to
make any changes, as <code>fail: true</code> has been the default there
for a while.</li>
<li>If you prefer the old behavior, explicitly set <code>fail</code> to
<code>false</code> when updating:</li>
</ul>
<pre lang="yaml"><code>- name: Link Checker
  id: lychee
  uses: lycheeverse/lychee-action@v2
  with:
    fail: false  # Don't fail action on broken links
</code></pre>
<h3>Fail pipeline if no links were found</h3>
<p>Similar to the above change, we now fail the pipeline if no links are
found during a run. This helps warn users about potential configuration
issues.</p>
<p><strong>What you need to do:</strong></p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="7cd0af4c74"><code>7cd0af4</code></a>
Merge commit from fork</li>
<li><a
href="8ad54d3568"><code>8ad54d3</code></a>
fix link</li>
<li><a
href="762333c189"><code>762333c</code></a>
Create SECURITY.md (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/259">#259</a>)</li>
<li><a
href="71a38a3bd7"><code>71a38a3</code></a>
Document and use correct permissions in the GitHub workflows (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/258">#258</a>)</li>
<li><a
href="f141760066"><code>f141760</code></a>
Fix a typos (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/257">#257</a>)</li>
<li><a
href="2bb232618b"><code>2bb2326</code></a>
don't remove the lychee config file (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/255">#255</a>)</li>
<li><a
href="731bf1a2af"><code>731bf1a</code></a>
Fix variable name (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/253">#253</a>)</li>
<li><a
href="e360f3c891"><code>e360f3c</code></a>
Bump lycheeverse/lychee-action from 1 to 2 (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/252">#252</a>)</li>
<li><a
href="f87f0a6299"><code>f87f0a6</code></a>
Update version to <code>lycheeverse/lychee-action@v2</code> in docs</li>
<li><a
href="7da8ec1fc4"><code>7da8ec1</code></a>
Test latest lychee version tag (<a
href="https://redirect.github.com/lycheeverse/lychee-action/issues/236">#236</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/lycheeverse/lychee-action/compare/v1.9.0...v2.0.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=lycheeverse/lychee-action&package-manager=github_actions&previous-version=1.9.0&new-version=2.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-11-05 10:41:16 +00:00
Sebastian Ullrich
970dc6f7aa chore: CI: give Linux Debug unlimited test stack size (#5953) 2024-11-05 10:06:53 +00:00
dependabot[bot]
8e2f92607f chore: CI: bump actions/stale from 8 to 9 (#5958)
Bumps [actions/stale](https://github.com/actions/stale) from 8 to 9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/stale/releases">actions/stale's
releases</a>.</em></p>
<blockquote>
<h2>v9.0.0</h2>
<h2>Breaking Changes</h2>
<ol>
<li>Action is now stateful: If the action ends because of <a
href="https://github.com/actions/stale#operations-per-run">operations-per-run</a>
then the next run will start from the first unprocessed issue skipping
the issues processed during the previous run(s). The state is reset when
all the issues are processed. This should be considered for scheduling
workflow runs.</li>
<li>Version 9 of this action updated the runtime to Node.js 20. All
scripts are now run with Node.js 20 instead of Node.js 16 and are
affected by any breaking changes between Node.js 16 and 20.</li>
</ol>
<h2>What Else Changed</h2>
<ol>
<li>Performance optimization that removes unnecessary API calls by <a
href="https://github.com/dsame"><code>@​dsame</code></a> <a
href="https://redirect.github.com/actions/stale/pull/1033/">#1033</a>
fixes <a
href="https://redirect.github.com/actions/stale/issues/792">#792</a></li>
<li>Logs displaying current github API rate limit by <a
href="https://github.com/dsame"><code>@​dsame</code></a> <a
href="https://redirect.github.com/actions/stale/pull/1032">#1032</a>
addresses <a
href="https://redirect.github.com/actions/stale/issues/1029">#1029</a></li>
</ol>
<p>For more information, please read the <a
href="https://github.com/actions/stale#readme">action documentation</a>
and its <a href="https://github.com/actions/stale#statefulness">section
about statefulness</a></p>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/jmeridth"><code>@​jmeridth</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/stale/pull/984">actions/stale#984</a></li>
<li><a
href="https://github.com/nikolai-laevskii"><code>@​nikolai-laevskii</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/stale/pull/1020">actions/stale#1020</a></li>
<li><a
href="https://github.com/dusan-trickovic"><code>@​dusan-trickovic</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/stale/pull/1056">actions/stale#1056</a></li>
<li><a
href="https://github.com/aparnajyothi-y"><code>@​aparnajyothi-y</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/stale/pull/1110">actions/stale#1110</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/stale/compare/v8...v9.0.0">https://github.com/actions/stale/compare/v8...v9.0.0</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/actions/stale/blob/main/CHANGELOG.md">actions/stale's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<h1>[7.0.0]</h1>
<p>⚠️ Breaking change ⚠️</p>
<ul>
<li>Allow daysBeforeStale options to be float by <a
href="https://github.com/irega"><code>@​irega</code></a> in <a
href="https://redirect.github.com/actions/stale/pull/841">actions/stale#841</a></li>
<li>Use cache in check-dist.yml by <a
href="https://github.com/jongwooo"><code>@​jongwooo</code></a> in <a
href="https://redirect.github.com/actions/stale/pull/876">actions/stale#876</a></li>
<li>fix print outputs step in existing workflows by <a
href="https://github.com/irega"><code>@​irega</code></a> in <a
href="https://redirect.github.com/actions/stale/pull/859">actions/stale#859</a></li>
<li>Update issue and PR templates, add/delete workflow files by <a
href="https://github.com/IvanZosimov"><code>@​IvanZosimov</code></a> in
<a
href="https://redirect.github.com/actions/stale/pull/880">actions/stale#880</a></li>
<li>Update how stale handles exempt items by <a
href="https://github.com/johnsudol"><code>@​johnsudol</code></a> in <a
href="https://redirect.github.com/actions/stale/pull/874">actions/stale#874</a></li>
</ul>
<h1>[6.0.1]</h1>
<p>Update <code>@​actions/core</code> to v1.10.0 (<a
href="https://redirect.github.com/actions/stale/pull/839">#839</a>)</p>
<h1>[6.0.0]</h1>
<p>⚠️ Breaking change ⚠️</p>
<p>Issues/PRs default <code>close-issue-reason</code> is now
<code>not_planned</code>(<a
href="https://redirect.github.com/actions/stale/issues/789">#789</a>)</p>
<h1>[5.1.0]</h1>
<p><a href="https://redirect.github.com/actions/stale/issues/696">Don't
process stale issues right after they're marked stale</a>
[Add close-issue-reason option]<a
href="https://redirect.github.com/actions/stale/pull/764">#764</a><a
href="https://redirect.github.com/actions/stale/pull/772">#772</a>
Various dependabot/dependency updates</p>
<h2><a
href="https://github.com/actions/stale/compare/v3.0.19...v4.1.0">4.1.0</a>
(2021-07-14)</h2>
<h2>Features</h2>
<ul>
<li><a
href="9912fa74d1">Ability
to exempt draft PRs</a></li>
</ul>
<h2><a
href="https://github.com/actions/stale/compare/v3.0.19...v4.0.0">4.0.0</a>
(2021-07-14)</h2>
<h3>Features</h3>
<ul>
<li><strong>options:</strong> simplify config by removing skip stale
message options (<a
href="https://redirect.github.com/actions/stale/issues/457">#457</a>)
(<a
href="6ec637d238">6ec637d</a>),
closes <a
href="https://redirect.github.com/actions/stale/issues/405">#405</a> <a
href="https://redirect.github.com/actions/stale/issues/455">#455</a></li>
<li><strong>output:</strong> print output parameters (<a
href="https://redirect.github.com/actions/stale/issues/458">#458</a>)
(<a
href="3e6d35b685">3e6d35b</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>dry-run:</strong> forbid mutations in dry-run (<a
href="https://redirect.github.com/actions/stale/issues/500">#500</a>)
(<a
href="f1017f33dd">f1017f3</a>),
closes <a
href="https://redirect.github.com/actions/stale/issues/499">#499</a></li>
<li><strong>logs:</strong> coloured logs (<a
href="https://redirect.github.com/actions/stale/issues/465">#465</a>)
(<a
href="5fbbfba142">5fbbfba</a>)</li>
<li><strong>operations:</strong> fail fast the current batch to respect
the operations limit (<a
href="https://redirect.github.com/actions/stale/issues/474">#474</a>)
(<a
href="5f6f311ca6">5f6f311</a>),
closes <a
href="https://redirect.github.com/actions/stale/issues/466">#466</a></li>
<li><strong>label comparison</strong>: make label comparison case
insensitive <a
href="https://redirect.github.com/actions/stale/pull/517">#517</a>,
closes <a
href="https://redirect.github.com/actions/stale/pull/516">#516</a></li>
<li><strong>filtering comments by actor could have strange
behavior</strong>: &quot;stale&quot; comments are now detected based on
if the message is the stale message not <em>who</em> made the comment(<a
href="https://redirect.github.com/actions/stale/pull/519">#519</a>),
fixes <a
href="https://redirect.github.com/actions/stale/pull/441">#441</a>, <a
href="https://redirect.github.com/actions/stale/pull/509">#509</a>, <a
href="https://redirect.github.com/actions/stale/pull/518">#518</a></li>
</ul>
<h3>Breaking Changes</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="28ca103628"><code>28ca103</code></a>
Upgrade Node to v20 (<a
href="https://redirect.github.com/actions/stale/issues/1110">#1110</a>)</li>
<li><a
href="b69b346013"><code>b69b346</code></a>
build(deps-dev): bump <code>@​types/node</code> from 18.16.18 to 20.5.1
(<a
href="https://redirect.github.com/actions/stale/issues/1079">#1079</a>)</li>
<li><a
href="88a6f4f6cb"><code>88a6f4f</code></a>
build(deps-dev): bump typescript from 5.1.3 to 5.2.2 (<a
href="https://redirect.github.com/actions/stale/issues/1083">#1083</a>)</li>
<li><a
href="796531a7b3"><code>796531a</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/stale/issues/1080">#1080</a>
from akv-platform/fix-delete-cache</li>
<li><a
href="8986f6218b"><code>8986f62</code></a>
Don not try to delete cache if it does not exists</li>
<li><a
href="cab99b362b"><code>cab99b3</code></a>
fix typo proceeded/processed</li>
<li><a
href="184e7afe93"><code>184e7af</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/stale/issues/1064">#1064</a>
from actions/dependabot/npm_and_yarn/typescript-esli...</li>
<li><a
href="523885cf3c"><code>523885c</code></a>
chore: update eslint-plugin, parser and eslint-plugin-jest</li>
<li><a
href="2487a1dc2b"><code>2487a1d</code></a>
build(deps-dev): bump
<code>@​typescript-eslint/eslint-plugin</code></li>
<li><a
href="60c722ee97"><code>60c722e</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/stale/issues/1063">#1063</a>
from actions/dependabot/npm_and_yarn/jest-29.6.2</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/stale/compare/v8...v9">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/stale&package-manager=github_actions&previous-version=8&new-version=9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 09:53:55 +00:00
dependabot[bot]
ee1fa6eeb7 chore: CI: bump raven-actions/actionlint from 1 to 2 (#5957)
Bumps
[raven-actions/actionlint](https://github.com/raven-actions/actionlint)
from 1 to 2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/raven-actions/actionlint/releases">raven-actions/actionlint's
releases</a>.</em></p>
<blockquote>
<h2>v2.0.0</h2>
<h2>🔄️ What's Changed</h2>
<ul>
<li>node20 support</li>
<li>ci(linter): add workflow permissions <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/24">#24</a>)</li>
<li>ci(deps): Bump actions/cache from 3 to 4 <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/20">#20</a>)</li>
</ul>
<h2>🚀 Features</h2>
<ul>
<li>feat: switch to pipx &amp; add github-token <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/23">#23</a>)</li>
</ul>
<h2>👥 Contributors</h2>
<p><a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>,
<a href="https://github.com/dependabot"><code>@​dependabot</code></a>
and <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</p>
<p>See details of all code changes: <a
href="https://github.com/raven-actions/actionlint/compare/v1.0.3...v2.0.0">https://github.com/raven-actions/actionlint/compare/v1.0.3...v2.0.0</a>
since previous release.</p>
<h2>v1.0.3</h2>
<h2>🔄️ What's Changed</h2>
<ul>
<li>chore: yamllint config and files lint <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/18">#18</a>)</li>
<li>⬆️ github-actions(deps): Bump actions/github-script from 6 to 7 <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/17">#17</a>)</li>
<li>⬆️ github-actions(deps): bump actions/checkout from 3 to 4 <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/12">#12</a>)</li>
</ul>
<h2>🚀 Features</h2>
<ul>
<li>Make yamllint happy <a
href="https://github.com/bhundven"><code>@​bhundven</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/16">#16</a>)</li>
<li>Fix debian install shellcheck <a
href="https://github.com/bhundven"><code>@​bhundven</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/15">#15</a>)</li>
</ul>
<h2>🐛 Bug Fixes</h2>
<ul>
<li>fix: user flags parser <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/19">#19</a>)</li>
<li>Fix debian install shellcheck <a
href="https://github.com/bhundven"><code>@​bhundven</code></a> (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/15">#15</a>)</li>
</ul>
<h2>👥 Contributors</h2>
<p><a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>,
<a href="https://github.com/bhundven"><code>@​bhundven</code></a>, <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> and
<a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</p>
<p>See details of all code changes: <a
href="https://github.com/raven-actions/actionlint/compare/v1.0.2...v1.0.3">https://github.com/raven-actions/actionlint/compare/v1.0.2...v1.0.3</a>
since previous release.</p>
<h2>v1.0.2</h2>
<h2>🔄️ What's Changed</h2>
<ul>
<li> feat(inputs): group-result <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/10">#10</a>)</li>
<li>👷 chore(github): ci adjustments <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/9">#9</a>)</li>
<li>👷 refactor(ci): change to debug action <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/7">#7</a>)</li>
<li>📝 chore: minor docs and CI adjustments <a
href="https://github.com/DariuszPorowski"><code>@​DariuszPorowski</code></a>
(<a
href="https://redirect.github.com/raven-actions/actionlint/issues/6">#6</a>)</li>
</ul>
<h2>👥 Contributors</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="01fce4f43a"><code>01fce4f</code></a>
ci(linter): add workflow permissions (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/24">#24</a>)</li>
<li><a
href="a30be5376b"><code>a30be53</code></a>
feat: switch to pipx &amp; add github-token (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/23">#23</a>)</li>
<li><a
href="ea4eb57846"><code>ea4eb57</code></a>
ci(deps): Bump actions/cache from 3 to 4 (<a
href="https://redirect.github.com/raven-actions/actionlint/issues/20">#20</a>)</li>
<li>See full diff in <a
href="https://github.com/raven-actions/actionlint/compare/v1...v2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=raven-actions/actionlint&package-manager=github_actions&previous-version=1&new-version=2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 09:49:23 +00:00
dependabot[bot]
9d2a017704 chore: CI: bump softprops/action-gh-release from 1 to 2 (#5955)
Bumps
[softprops/action-gh-release](https://github.com/softprops/action-gh-release)
from 1 to 2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/softprops/action-gh-release/releases">softprops/action-gh-release's
releases</a>.</em></p>
<blockquote>
<h2>v2.0.0</h2>
<ul>
<li>update actions.yml declaration to node20 to address warnings</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md">softprops/action-gh-release's
changelog</a>.</em></p>
<blockquote>
<h2>0.1.12</h2>
<ul>
<li>fix bug leading to empty strings subsituted for inputs users don't
provide breaking api calls <a
href="https://redirect.github.com/softprops/action-gh-release/pull/144">#144</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="e7a8f85e1c"><code>e7a8f85</code></a>
chore: release 2.0.9</li>
<li><a
href="04afa1392e"><code>04afa13</code></a>
chore(deps): bump actions/setup-node from 4.0.4 to 4.1.0 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/535">#535</a>)</li>
<li><a
href="894468a03c"><code>894468a</code></a>
chore(deps): bump actions/checkout from 4.2.1 to 4.2.2 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/534">#534</a>)</li>
<li><a
href="3bd23aa9ec"><code>3bd23aa</code></a>
chore(deps): bump <code>@​types/node</code> from 22.7.5 to 22.8.2 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/533">#533</a>)</li>
<li><a
href="21eb2f9554"><code>21eb2f9</code></a>
chore(deps): bump <code>@​types/jest</code> from 29.5.13 to 29.5.14 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/532">#532</a>)</li>
<li><a
href="cd8b57e572"><code>cd8b57e</code></a>
remove unused imports (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/521">#521</a>)</li>
<li><a
href="820a5adc43"><code>820a5ad</code></a>
chore(deps): bump actions/checkout from 4.2.0 to 4.2.1 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/522">#522</a>)</li>
<li><a
href="9d04f90cd8"><code>9d04f90</code></a>
chore(deps): bump <code>@​octokit/plugin-throttling</code> from 9.3.1 to
9.3.2 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/523">#523</a>)</li>
<li><a
href="aaf1d5f6d5"><code>aaf1d5f</code></a>
chore(deps): bump <code>@​actions/core</code> from 1.10.1 to 1.11.1 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/524">#524</a>)</li>
<li><a
href="7d33a7ecc3"><code>7d33a7e</code></a>
chore(deps): bump <code>@​types/node</code> from 22.5.5 to 22.7.5 (<a
href="https://redirect.github.com/softprops/action-gh-release/issues/525">#525</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/softprops/action-gh-release/compare/v1...v2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=softprops/action-gh-release&package-manager=github_actions&previous-version=1&new-version=2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 09:40:03 +00:00
dependabot[bot]
574b86c247 chore: CI: bump nwtgck/actions-netlify from 2.0 to 3.0 (#5956)
Bumps
[nwtgck/actions-netlify](https://github.com/nwtgck/actions-netlify) from
2.0 to 3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/nwtgck/actions-netlify/releases">nwtgck/actions-netlify's
releases</a>.</em></p>
<blockquote>
<h2>v3.0.0</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
<li>Updates the default runtime to node20</li>
</ul>
<h2>v2.1.0</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h3>Added</h3>
<ul>
<li>Add &quot;enable-github-deployment&quot; input <a
href="https://redirect.github.com/nwtgck/actions-netlify/pull/901">#901</a>
by <a href="https://github.com/a-tokyo"><code>@​a-tokyo</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/nwtgck/actions-netlify/blob/develop/CHANGELOG.md">nwtgck/actions-netlify's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<p>All notable changes to this project will be documented in this
file.</p>
<p>The format is based on <a
href="https://keepachangelog.com/en/1.0.0/">Keep a Changelog</a></p>
<h2>[Unreleased]</h2>
<h2>[3.0.0] - 2024-03-10</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
<li>Updates the default runtime to node20</li>
</ul>
<h2>[2.1.0] - 2023-08-18</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h3>Added</h3>
<ul>
<li>Add &quot;enable-github-deployment&quot; input <a
href="https://redirect.github.com/nwtgck/actions-netlify/pull/901">#901</a>
by <a href="https://github.com/a-tokyo"><code>@​a-tokyo</code></a></li>
</ul>
<h2>[2.0.0] - 2022-12-08</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
<li>Updates the default runtime to node16</li>
</ul>
<h2>[1.2.4] - 2022-10-14</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h2>[1.2.3] - 2021-12-20</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h2>[1.2.2] - 2021-05-08</h2>
<h3>Fixed</h3>
<ul>
<li>Fix GitHub deployment description</li>
</ul>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h2>[1.2.1] - 2021-05-05</h2>
<h3>Added</h3>
<ul>
<li>Add &quot;fails-without-credentials&quot; input to fail if the
credentials not provided <a
href="https://redirect.github.com/nwtgck/actions-netlify/pull/532">#532</a></li>
</ul>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
</ul>
<h2>[1.2.0] - 2021-04-29</h2>
<h3>Changed</h3>
<ul>
<li>Update dependencies</li>
<li>(breaking change for <code>overwrites-pull-request-comment:
true</code>): Support multiple app deploys in a single PR <a
href="https://redirect.github.com/nwtgck/actions-netlify/pull/484">#484</a>
by <a
href="https://github.com/kaisermann"><code>@​kaisermann</code></a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4cbaf4c08f"><code>4cbaf4c</code></a>
Merge branch 'release/3.0.0'</li>
<li><a
href="6b45669baf"><code>6b45669</code></a>
bump: 3.0.0</li>
<li><a
href="8d5d80bf73"><code>8d5d80b</code></a>
Merge pull request <a
href="https://redirect.github.com/nwtgck/actions-netlify/issues/1151">#1151</a>
from nwtgck/actions-build/nwtgck-dependabot/npm_and_...</li>
<li><a
href="85c2e8e35a"><code>85c2e8e</code></a>
build</li>
<li><a
href="ea3c314fcd"><code>ea3c314</code></a>
Build(deps): bump <code>@​actions/github</code> from 5.1.1 to 6.0.0</li>
<li><a
href="333815eadd"><code>333815e</code></a>
updates the default runtime to node20</li>
<li><a
href="06de7de77b"><code>06de7de</code></a>
Build(deps-dev): bump <code>@​vercel/ncc</code> from 0.36.1 to 0.38.1
(<a
href="https://redirect.github.com/nwtgck/actions-netlify/issues/1121">#1121</a>)</li>
<li><a
href="a7f64ad4e2"><code>a7f64ad</code></a>
deps: update</li>
<li><a
href="fee801f039"><code>fee801f</code></a>
Build(deps): bump actions/setup-node from 3 to 4 (<a
href="https://redirect.github.com/nwtgck/actions-netlify/issues/1124">#1124</a>)</li>
<li><a
href="e4998d22a0"><code>e4998d2</code></a>
README.md, sample workflow: bump to latest action versions (<a
href="https://redirect.github.com/nwtgck/actions-netlify/issues/1149">#1149</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/nwtgck/actions-netlify/compare/v2.0...v3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=nwtgck/actions-netlify&package-manager=github_actions&previous-version=2.0&new-version=3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 09:38:06 +00:00
Sebastian Ullrich
75602f7c29 chore: CI: adjust Dependabot prefix 2024-11-05 10:31:37 +01:00
Sebastian Ullrich
0fd90c1283 chore: CI: check for GitHub Actions updates once per month (#5954) 2024-11-05 10:20:23 +01:00
Kim Morrison
128b049904 feat: relate Array.eraseIdx with List.eraseIdx (#5952) 2024-11-05 06:13:29 +00:00
Kim Morrison
0e3f26e6df feat: relate Array.takeWhile with List.takeWhile (#5950) 2024-11-05 05:05:53 +00:00
Kim Morrison
1148e6e142 chore: remove @[simp] from BitVec.ofFin_sub and sub_ofFin (#5951)
Unused, and hurts confluence.
2024-11-05 04:56:21 +00:00
Violeta Hernández
02baaa42ff feat: add Option.or_some' (#5926)
`o.or (some a) = o.getD a`.

As discussed on
[Zulip](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/a.2Eor.20.28some.20b.29.20.3D.20a.2EgetD.20b/near/472785093).
2024-11-05 01:39:02 +00:00
Violeta Hernández
e573676db1 feat: List.pmap_eq_self (#5927)
This is a `pmap` analog of
[`List.map_id''`](https://leanprover-community.github.io/mathlib4_docs/Init/Data/List/Lemmas.html#List.map_id'').

As discussed on
[Zulip](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/.60pmap_eq_self.60/near/472496933).
2024-11-05 01:38:13 +00:00
Kim Morrison
4dab6a108c chore: port release notes for v4.13.0 to master (#5947) 2024-11-05 01:34:52 +00:00
Kyle Miller
a4d521cf96 fix: make all_goals admit goals on failure (#5934)
New behavior: when in recovery mode, if any tactic fails in `all_goals`
then the metacontext is restored and all goals are admitted.

Without this, it can leave partially-solved metavariables and incomplete
goal lists.
2024-11-04 21:12:59 +00:00
Mac Malone
99070bf304 feat: update toolchain on lake update (#5684)
Lake will now update a package's `lean-toolchain` file on `lake update`
if it finds the package's direct dependencies use a newer compatible
toolchain. To skip this step, use the `--keep-toolchain` CLI option.

Closes #2582. Closes #2752. Closes #5615.

### Toolchain update details

To determine "newest compatible" toolchain, Lake parses the toolchain
listed in the packages' `lean-toolchain` files into four categories:
release , nightly, PR, and other. For newness, release toolchains are
compared by semantic version (e.g., `"v4.4.0" < "v4.8.0"` and
`"v4.6.0-rc1" < "v4.6.0"`) and nightlies are compared by date (e.g.,
`"nightly-2024-01-10" < "nightly-2014-10-01"`). All other toolchain
types and mixtures are incompatible. If there is not a single newest
toolchain, Lake will print a warning and continue updating without
changing the toolchain.

If Lake does find a new toolchain, Lake updates the workspace's
`lean-toolchain` file accordingly and restarts the update process on the
new Lake. If Elan is detected, it will spawn the new Lake process via
`elan run` with the same arguments Lake was initially run with. If Elan
is missing, it will prompt the user to restart Lake manually and exit
with a special error code (4).

### Other changes

To implement this new logic, various other refactors were needed. Here
are some key highlights:

* Logs emitted during package and workspace loading are now eagerly
printed.
* The Elan executable used by Lake is now configurable by the `ELAN`
environment variable.
* The `--lean` CLI option was removed. Use the `LEAN` environment
variable instead.
* `Package.deps` / `Package.opaqueDeps` have been removed. Use
`findPackage?` with a dependency's name instead.
* The dependency resolver now uses a pure breadth-first traversal to
resolve dependencies. It also resolves dependencies in reverse order,
which is done for consistency with targets. Latter targets shadow
earlier ones and latter dependencies take precedence over earlier ones.
**These changes mean the order of dependencies in a Lake manifest will
change after the first `lake update` on this version of Lake.**
2024-11-04 14:31:40 +00:00
Henrik Böving
93dd6f2b36 feat: add Int16/Int32/Int64 (#5885)
This adds all fixed width integers with the exception of `ssize_t` so
the code is quick to review as everything just behaves the same.
2024-11-04 13:18:05 +00:00
Henrik Böving
c61ced3f15 feat: introduce synthetic atoms in bv_decide (#5942)
This introduces a notion of synthetic atoms into `bv_decide`'s
reflection framework. An atom can be declared synthetic if its behavior
is fully specified by additional lemmas that are added in the process of
creating it. This is for example useful in the code that handles `if` as
the entire `if` block is abstracted as an atom and then two lemmas to
describe either branch are added. Previously this had the effect of
creating error messages about potentially unsound counterexamples, now
the synthetic atoms get filtered from the counter example generation.
2024-11-04 10:14:51 +00:00
Kim Morrison
c779f3a039 feat: List.mapFinIdx, lemmas, relate to Array version (#5941) 2024-11-04 05:29:41 +00:00
Kim Morrison
fc17468f78 chore: upstream List.ofFn and relate to Array.ofFn (#5938) 2024-11-04 01:35:29 +00:00
Kim Morrison
8b7e3b8942 chore: upstream lemmas about Fin.foldX (#5937) 2024-11-04 00:52:59 +00:00
Kim Morrison
9129990833 chore: begin development cycle for v4.15 (#5936) 2024-11-03 23:25:03 +00:00
Kyle Miller
1659f3bfe2 fix: .. in patterns should not make use of optparams or autoparams (#5933)
In patterns, ellipsis should always fill in each remaining argument as
an implicit argument, even if it is an optparam or autoparam. This
prevents examples such as the one in #4555 from failing:
```lean
match e with
| .internal .. => sorry
| .error .. => sorry
```
The `internal` constructor has an optparam (`| internal (id :
InternalExceptionId) (extra : KVMap := {})`).

We may consider having ellipsis suppress optparams and autoparams in
general. We avoid doing so for now since it's possible to opt-out of
them individually (for example with `.internal (extra := _) ..`) but
it's not possible to opt-in, and it is plausible that `..` with
optparams is useful in contexts such as the `refine` tactic. With
patterns however, it is hard to imagine a use case that offsets the
inconvenience of optparams being eagerly supplied.

Closes #4555
2024-11-03 18:40:21 +00:00
Lean stage0 autoupdater
87d3f1f2c8 chore: update stage0 2024-11-03 17:21:54 +00:00
Kyle Miller
b75cc35db2 feat: update omega/solve_by_elim to use new tactic syntax, use new tactic syntax (#5932)
Following up #5928, updates the syntax for `omega` and `solve_by_elim`
and restores the syntax quotations in their implementations.

Following up #5898, uses the new tactic syntax in the library, replacing
all uses of `(config := ...)`.
2024-11-03 16:23:37 +00:00
Jens Petersen
3952689fb1 feat: add --short-version (-V) option to display short version (#5930)
This just adds a `--short-version` (`-V`) option to the lean command,
which is useful for external tooling, etc.

Closes #5929
2024-11-03 15:18:23 +00:00
Lean stage0 autoupdater
cd24e9dad4 chore: update stage0 2024-11-03 07:04:44 +00:00
Kyle Miller
0de925eafc chore: prepare omega and solve_by_elim for new tactic config syntax (#5928)
The tactic elaborators match a too-restrictive syntax for the migration
to the new configuration syntax. This generalizes what they accept, and
the code will return to using quotations after a stage0 update and
syntax change.
2024-11-03 06:20:15 +00:00
Mac Malone
79428827b8 feat: add text option for buildFile* utilities (#5924)
Adds an optional `text` argument to the `fetchFile*` and `buildFile*`
definitions that can be used to hash built files as text files (with
normalized line endings) instead of as binary files (the previous
default).

Separately, this change also significantly expands the documentation in
the `Lake.Build.Trace` module and preforms minor touchups of some build
job signatures.
2024-11-03 00:23:39 +00:00
Kyle Miller
3c15ab3c09 feat: make MapDeclarationExtension tolerate multiple insertions (#5911)
Simplifies the definition of `MapDeclarationExtension` so that it only
contains a `NameMap` without an additional `List (Name × α)`. Uses the
`NameMap`'s natural ordering during export rather than sorting.

This fixes issues from inserting into a `MapDeclarationExtension`
multiple times with the same key. Inside a module it appears that each
insertion overwrites the data, since those queries access the `NameMap`.
But across modules, only the first insertion is accessible, since each
insertion was actually pushed to the front of a `List`.

Mathlib needs this for a documentation extension feature, and [they are
considering a PR with a
workaround](https://github.com/leanprover-community/mathlib4/pull/17043)
that digs into the `MapDeclarationExtension` data structures.
2024-11-02 15:28:34 +00:00
Lean stage0 autoupdater
3f33cd6fcd chore: update stage0 2024-11-01 23:33:27 +00:00
David Thrane Christiansen
1f8d7561fa chore: remove unused deriving handler argument syntax (#5265)
As far as I can tell, the ability to pass a structure instance to a
deriving handler is not actually used in practice. It didn't seem to be
used in the test suite, at least.

Do we want to remove this, or do we want to use and document it? This PR
removes it, but that's not something I feel strongly about - but seeing
if it breaks Mathlib is a useful data point.
2024-11-01 22:41:38 +00:00
Alex
16e5e09ffd feat: better error message for invalid induction alternative name (#5888)
Closes #5887
2024-11-01 21:33:15 +00:00
Kyle Miller
5549e0509f feat: on "type mismatch" errors, expose differences in functions and pi types (#5922)
Example: Normally subtype notation pretty prints as `{ x // x > 0 }`,
but now the difference in domains is exposed:
```lean
example (h : {x : Int // x > 0}) : {x : Nat // x > 0} := h
/-
error: type mismatch
  h
has type
  { x : Int // x > 0 } : Type
but is expected to have type
  { x : Nat // x > 0 } : Type
-/
```
2024-11-01 18:42:14 +00:00
Kyle Miller
c7f5fd9a83 feat: make "type mismatch" error add numeric type ascriptions (#5919)
Example:
```lean
example : 0 = (0 : Nat) := by
  exact Eq.refl (0 : Int)
/-
error: type mismatch
  Eq.refl 0
has type
  (0 : Int) = 0 : Prop
but is expected to have type
  (0 : Nat) = 0 : Prop
-/
```
2024-11-01 16:44:52 +00:00
Henrik Böving
a4057d373e fix: bv_normalize loose mvars (#5918)
`bv_normalize` would just silently drop other goals if called while not
focused on a singular goal, for example:
```lean
theorem mvarid (x y : Bool) (h : x ∨ y) : y ∨ x := by
  cases h
  bv_normalize
  -- we want to write another bv_normalize here but all goals are gone
```
Would make the second subgoal disappear and then throw an error about
meta variables in the kernel.
2024-11-01 15:16:11 +00:00
Sebastian Ullrich
fd08c92060 chore: update src/library/module.cpp after update stage0
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Update src/library/module.cpp

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2024-11-01 22:48:49 +11:00
Kim Morrison
be6507fe5b chore: update stage0 2024-11-01 22:48:49 +11:00
Sebastian Ullrich
c723ae7f97 chore: CI: build 64-bit platforms consistently with GMP
fix

arm64?

try different fix

`uses_gmp` .olean bit, bump .olean version

add lean_version

make sure to use cache gmp on x86 Linux
2024-11-01 22:48:49 +11:00
Lean stage0 autoupdater
0973ba3e42 chore: update stage0 2024-11-01 03:36:00 +00:00
Kim Morrison
a75a03c077 feat: relate for loops over List with foldlM (#5913)
There are many more lemmas about `foldlM`, so this may be useful for
reasoning about for loops by transforming them into folds.

The transformation includes accounting for monad effects, but does have
a mild performance difference in that short-circuiting on
`ForInStep.done` is replaced by traversing the rest of the list with a
noop.
2024-11-01 02:41:05 +00:00
Kim Morrison
6922832327 chore: minor tweaks to Array lemmas (#5912) 2024-11-01 02:20:16 +00:00
Kyle Miller
f1707117f0 feat: conv arg now can access more arguments (#5894)
Specializes the congr lemma generated for the `arg` conv tactic to only
rewrite the chosen argument. This makes it much more likely that the
chosen argument is able to be accessed.

Lets `arg` access the domain and codomain of pi types via `arg 1` and
`arg 2` in more situations. Upstreams `pi_congr` for this from mathlib.

Adds a negative indexing option, where `arg -2` accesses the
second-to-last argument for example, making the behavior of `lhs`
available to `arg`. This works for `enter` as well.

Other improvement: when there is an error in the `enter [...]` tactic,
individual locations get underlined with the error. The tactic info now
also is like `rw`, so you can see the intermediate conv states.

Closes #5871
2024-11-01 02:12:14 +00:00
Kyle Miller
3b80d1eb1f feat: activate new tactic configuration syntax for most tactics (#5898)
PR #5883 added a new syntax for tactic configuration, and this PR
enables it in most tactics. Example: `simp +contextual`.

There will be followup PRs to modify the remaining ones.

Breaking change: Tactics that are macros for `simp` or other core
tactics need to adapt. The easiest way is to replace `(config)?` with
`optConfig` and then in the syntax quotations replace `$[$cfg]?` by
`$cfg:optConfig`. For tactics that manipulate the configuration, see
`erw` for an example:
```lean
macro "erw" c:optConfig s:rwRuleSeq loc:(location)? : tactic => do
  `(tactic| rw $[$(getConfigItems c)]* (transparency := .default) $s:rwRuleSeq $(loc)?)
```
Configuration options are processed left-to-right, so this forces the
`transparency` to always be `.default`.
2024-11-01 02:08:53 +00:00
Luisa Cicolini
7730ddd1a0 feat: add BitVec.(msb, getMsbD, getLsbD)_(neg, abs) (#5721)
Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Henrik Böving <hargonix@gmail.com>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
Co-authored-by: Marc Huisinga <mhuisi@protonmail.com>
Co-authored-by: Markus Himmel <markus@lean-fro.org>
Co-authored-by: FR <zhao.yu-yang@foxmail.com>
Co-authored-by: Aaron Tomb <aarontomb@gmail.com>
Co-authored-by: Arthur Adjedj <arthur.adjedj@gmail.com>
Co-authored-by: Yann Herklotz <git@yannherklotz.com>
Co-authored-by: Lean stage0 autoupdater <>
2024-11-01 01:27:34 +00:00
Kim Morrison
e4a2c3d8f0 feat: interim implementation of HashMap.modify/alter (#5880)
These implementations could be made more efficient by promoting them to
primitive operations, but I propose installing these in the meantime to
encourage users to avoid non-linearity problems.
2024-11-01 01:21:21 +00:00
Kim Morrison
c2391c45b9 chore: remove @[simp] from Sum.forall and Sum.exists (#5900) 2024-11-01 01:21:04 +00:00
Kyle Miller
465ed8af46 feat: resolve generalized field notation using all parents (#5770)
* Now `getPathToBaseStructure?` can navigate to all parent structures,
not just through subobjects.
* Adds a "resolution order" for methods. This is the order that
generalized field notation visits parent structures when trying to
resolve names. The algorithm to compute a resolution order is the
commonly used C3 (used for instance by Python). By default we use a
relaxed version of the algorithm that tolerates inconsistencies. Using
`set_option structure.strictResolutionOrder true` makes inconsistent
parent orderings into warnings.
* This makes generalized field notation be able to resolve names for all
parent structures, not just those that are embedded as subobjects.
Closes #3467. (And addresses side note in #1881.)
* Modifies `getAllParentStructures` to return *all* parents. This
improves dot completion in the editor.
2024-10-31 21:04:50 +00:00
Joachim Breitner
008537abbd fix: FunInd: unfold aux definitions more carefully (#5904)
fixes #5903
2024-10-31 18:04:36 +00:00
Kyle Miller
f8242fa965 fix: delta derived instances now have declaration ranges (#5899)
Fixes an issue where go-to definition on such instances does not work.

Reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/mystery.20guest/near/479820367)
2024-10-31 15:40:17 +00:00
Henrik Böving
844e7ae7eb chore: remove native code for UInt8.modn (#5901)
Closes #5818
2024-10-31 12:42:24 +00:00
Kim Morrison
218601009b chore: rename Array.back to back! (#5897) 2024-10-31 09:18:18 +00:00
Kim Morrison
4af93813f2 chore: move @[simp] from back_eq_back? to back_push (#5896) 2024-10-31 08:25:19 +00:00
Kim Morrison
34be25620f feat: LawfulBEq (Array α) ↔ LawfulBEq α (#5895) 2024-10-31 08:00:06 +00:00
Kim Morrison
a826de8a3d chore: remove duplicated ForIn instances (#5892)
I'd previously added an instance from `ForIn'` to `ForIn`, but this then
caused some non-defeq duplication. It seems fine to just remove the
concrete `ForIn` instances in cases where the `ForIn'` instance exists
too. We can even remove a number of type-specific lemmas in favour of
the general ones.
2024-10-31 07:40:09 +00:00
Kyle Miller
0fcee100e7 feat: enable recursive structure command (#5783)
Now that the elaborator supports primitive projections for recursive
inductive types (#5822), enable defining recursive inductive types with
the `structure` command, which was set up in #5842.

Example:
```lean
structure Tree where
  n : Nat
  children : Fin n → Tree

def Tree.size : Tree → Nat
  | {n, children} => Id.run do
    let mut s := 0
    for h : i in [0 : n] do
      s := s + (children ⟨i, h.2⟩).size
    pure s
```

Note for kernel re-implementors: recursive structures are exercising the
kernel feature where primitive projections are valid for one-constructor
inductive types in general, so long as the structure isn't a `Prop` and
doesn't have any non-`Prop` fields, not just ones that are non-indexed
and non-recursive.

Closes #2512
2024-10-31 05:23:12 +00:00
Kyle Miller
03c6e99ef7 fix: bring elaborator in line with kernel for primitive projections (#5822)
The kernel supports primitive projections for all inductive types with
one construtor. The elaborator was assuming primitive projections only
work for "structure-likes", non-recursive inductive types with no
indices.

Enables numeric projection notation for general one-constructor
inductives.

Extracted from #5783.
2024-10-31 03:16:52 +00:00
Lean stage0 autoupdater
0c8d28e9ba chore: update stage0 2024-10-31 02:11:42 +00:00
Kyle Miller
66d68484af fix: make structure parent info persist (#5890)
Modifies the `structureExt` from being a `SimplePersistentEnvExtension`
to a `PersistentEnvExtension`. The simple version contains a `List` of
all added entries, which we do not need since we already have a
`PersistentHashMap` of them in the state. The oversight was that this
`List` contained duplicate entries due to `setStructureParents`
re-adding entries.
2024-10-31 01:22:34 +00:00
Kim Morrison
5c70e5d845 chore: (belatedly) begin development cycle for v4.14.0 (#5889)
This hasn't affected release candidates or stables, but I realised that
I haven't been updating `LEAN_VERSION_MINOR` on `master` the last two
months, so it still says v4.12.0. This advances it to v4.14.0.
2024-10-30 23:48:02 +00:00
Kyle Miller
d4b1be094d feat: adds optConfig syntax for tactic configuration (#5883)
This PR adds a new syntax for tactic and command configurations. It also
updates the elaborator construction command to be able to process this
new syntax.

We do not update core tactics yet. Once tactics switch over to it,
rather than (for example) writing `simp (config := { contextual := true,
maxSteps := 22})`, one can write `simp +contextual (maxSteps := 22)`.
The new syntax is reverse compatible in the sense that `(config := ...)`
still sets the entire configuration.

Note to metaprogrammers: Use `optConfig` instead of `(config)?`. The
elaborator generated by `declare_config_elab` accepts both old and new
configurations. The elaborator has also been written to be tolerant to
null nodes, so adapting to `optConfig` should be as easy as changing
just the syntax for your tactics and deleting `mkOptionalNode`.

Breaking change: The new system is mostly reverse compatible, however
the type of the generated elaborator now lands in `TacticM` to make use
of the current recovery state. Commands that wish to elaborate
configurations should now use `declare_command_config_elab` instead of
`declare_config_elab` to get an elaborator landing in `CommandElabM`.
2024-10-30 23:31:34 +00:00
Kyle Miller
c3cbc92a0c feat: upstream and update #where command (#5065)
This command comes from Lean 3, which I had previously ported and
contributed to Batteries (née Std). In this new version, `#where`
produces actual command Syntax for all features of a top-level scope
(rather than splicing together strings), and it also now reports
included variables.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-10-30 18:00:08 +00:00
Joachim Breitner
0d12618539 fix: declareSimpLikeTactic macro to use mkSynthetic (#5838)
this fixes #5597
2024-10-30 14:27:56 +00:00
Henrik Böving
ac80e261bd feat: add embedded constraint substitution to bv_decide (#5886)
This adds the embedded constraint substitution preprocessing pass from
Bitwuzla to `bv_decide`.
It looks for hypotheses of the form `h : x = true` and then attempts to
find occurrences of
`x` within other hypotheses to replace them with true.
2024-10-30 11:43:40 +00:00
Kim Morrison
38c39482f4 chore: add missing deprecation dates (#5884) 2024-10-30 05:37:36 +00:00
Kyle Miller
09802e83cd chore: mention #version in bug report template (#5769) 2024-10-30 02:46:48 +00:00
Alex Keizer
b5bbc57059 feat: prove that intMin is indeed the smallest signed bitvector (#5778) 2024-10-30 02:45:16 +00:00
Mac Malone
4714f84fb9 fix: lake: do not delete path dependencies (#5878)
Fixes a serious issue where Lake would delete path dependencies when
attempting to cleanup a dependency required with an incorrect name.

Closes #5876. Originally part of #5684, but also independently
discovered by François.
2024-10-30 02:31:20 +00:00
Kim Morrison
5e7d02e4ea feat: Hashable (BitVec n) (#5881) 2024-10-30 02:26:18 +00:00
Kim Morrison
5357fd2369 chore: rename List.groupBy to splitBy (#5879)
This makes room for adding a function that returns a HashMap, parallel
to `Array.groupByKey` (which I may also rename to `Array.groupBy`.
2024-10-30 00:56:52 +00:00
えび (ebi_chan)
3450c2a8ac feat: add Nat.log2_two_pow (#5756) 2024-10-29 23:46:17 +00:00
Kyle Miller
95d3b4b58f chore: move MessageData.ofConstName earlier (#5877)
Makes `MessageData.ofConstName` available without needing to import the
pretty printer. Any code making use of `MessageData` can write `m!" ...
{.ofConstName n} ... "` to have the name print with hover information.
More error messages now have hover information.

* Now `.ofConstName` also has a boolean flag to make names print fully
qualified. Default: false.
* Now `.ofConstName` will sanitize names that aren't constants. It is OK
to use it in `"unknown constant '{.ofConstName constName}'"` errors.

Usability note: it is more user-friendly to have "has already been
declared" errors report the fully qualified name. For this, write
`m!"{.ofConstName n true} has already been declared"`.
2024-10-29 21:23:51 +00:00
Kyle Miller
cdbe29b46d feat: accurate binder names in signatures (like in output of #check) (#5827)
An important part of the interface of a function is the parameter names,
for making used of named arguments. This PR makes the parameter names
print in a reliable way. The parameters of the type now appear as
hygienic names if they cannot be used as named arguments.

Modifies the heuristic for how parameters are chosen to appear before or
after the colon. The rule is now that parameters start appearing after
the colon at the first non-dependent non-instance-implicit parameter
that has a name unusable as a named argument. This is a refinement of
#2846.

Fixes the issue where consecutive hygienic names pretty print without a
space separating them, so we now have `(x✝ y✝ : Nat)` rather than `(x✝y✝
: Nat)`.

Breaking change: `Lean.PrettyPrinter.Formatter.pushToken` now takes an
additional boolean `ident` argument, which should be `true` for
identifiers. Used to insert discretionary space between consecutive
identifiers.

Closes #5810
2024-10-29 16:43:11 +00:00
Xin Hao
0d471513c5 fix: init git only not inside git work tree (#5789)
Addresses part of #2758.
2024-10-29 13:37:11 +00:00
Lean stage0 autoupdater
d23a231908 chore: update stage0 2024-10-29 12:02:31 +00:00
Joachim Breitner
6514385bb9 feat: attribute [simp ←] (#5870)
This adds the ability to add the converse direction of a rewrite rule
not just in simp arguments `simp [← thm]`, but also as a global
attribute

```lean
attribute [simp ←] thm
```

This fixes #5828.

This can be undone with `attribute [-simp]`, although note that
`[-simp]` wins and cannot be undone at the moment (#5868).

Like `simp [← thm]` (see #4290), this will do an implicit `attribute
[-simp] thm` if the other direction is already defined.
2024-10-29 11:07:08 +00:00
Lean stage0 autoupdater
4ee44ceb1d chore: update stage0 2024-10-29 00:17:47 +00:00
Kyle Miller
1437033e69 fix: prevent addPPExplicitToExposeDiff from assigning metavariables (#5276)
Type mismatch errors have a nice feature where expressions are annotated
with `pp.explicit` to expose differences via `isDefEq` checking.
However, this procedure has side effects since `isDefEq` may assign
metavariables. This PR wraps the procedure with `withoutModifyingState`
to prevent assignments from escaping.

Assignments can lead to confusing behavior. For example, in the
following a higher-order unification fails, but the difference-finding
procedure unifies metavariables in a naive way, producing a baffling
error message:
```lean
theorem test {f g : Nat → Nat} (n : Nat) (hfg : ∀a, f (g a) = a) :
    f (g n) = n := hfg n

example {g2 : ℕ → ℕ} (n2 : ℕ) : (λx => x * 2) (g2 n2) = n2 := by
  with_reducible refine test n2 ?_
  /-
  type mismatch
    test n2 ?m.648
  has type
    (fun x ↦ x * 2) (g2 n2) = n2 : Prop
  but is expected to have type
    (fun x ↦ x * 2) (g2 n2) = n2 : Prop
  -/
```
With the change, it now says `has type ?m.153 (?m.154 n2) = n2`.

Note: this uses `withoutModifyingState` instead of `withNewMCtxDepth`
because we want to know something about where `isDefEq` failed — we are
trying to simulate a very basic version of `isDefEq` for function
applications, and we want the state at the point of failure to know
which argument is "at fault".
2024-10-28 22:51:41 +00:00
Kyle Miller
b308f2bb55 fix: let simp arguments elaborate with error recovery (#5863)
Modifies `simp` to elaborate all simp arguments without disabling error
recovery. Like in #4177, simp arguments with elaboration errors are not
added to the simp set. Error recovery is still disabled when `simp` is
used in combinators such as `first`.

This enables better term info and features like tab completion when
there are elaboration errors.

Also included is a fix to the `all_goals` and `<;>` tactic combinators.
Recall that `try`/`catch` for the Tactic monad restores the state on
failure. This meant that all messages were being cleared on tactic
failure. The fix is to use `Tactic.tryCatch` instead, which doesn't
restore state.

Part of addressing #3831

Closes #4888
2024-10-28 21:39:03 +00:00
Kyle Miller
9eded87462 fix: remove withoutRecover from apply elaboration (#5862)
The assumptions behind disabling error recovery for the `apply` tactic
no longer seem to hold, since tactic combinators like `first` themselves
disable error recovery when it makes sense.

This addresses part of #3831

Breaking change: `elabTermForApply` no longer uses `withoutRecover`.
Tactics using `elabTermForApply` should evaluate whether it makes sense
to wrap it with `withoutRecover`, which is generally speaking when it's
used to elaborate identifiers.
2024-10-28 21:27:14 +00:00
Kyle Miller
19bebfc22f feat: improved calc error messages (#5719)
Makes the error messages report on RHSs and LHSs that do not match the
expected values when the relations are defeq. If the relations are not
defeq, the error message now no longer mentions the value of the whole
`calc` expression.

Adds a field to `mkCoe` with an optional callback to use to generate
error messages.

Note: it is tempting to try to make use of expected types when
elaborating the `calc` expression, but this runs into issue #2073.

Closes #4318
2024-10-28 20:38:45 +00:00
Henrik Böving
c57d054b87 feat: support all the SMTLIB BitVec divison/remainder operations in bv_decide (#5869) 2024-10-28 16:37:06 +00:00
Luisa Cicolini
2f1dc878e4 feat: add BitVec.(msb, getMsbD)_concat (#5865) 2024-10-28 12:10:02 +00:00
Tobias Grosser
f558402ab8 feat: add BitVec.[zero_ushiftRight|zero_sshiftRight|zero_mul] and cle… (#5858)
…an up BVDecide

- Fix names

  shiftLeft_zero_eq -> shiftLeft_zero
  ushiftRight_zero_eq -> ushiftRight_zero

- Remove duplicate prefixes

  BitVec.mul_zero -> mul_zero
  BitVec.mul_add  -> mul_add

- Adapt BVDecide/Normalize/BitVec by reusing the following functions

  zero_add | add_zero
  and_self
  mul_zero | zero_mul
  shiftLeft_zero | zero_shiftLeft
  sshiftRight_zero | zero_sshiftRight
  ushiftRight_zero | zero_ushiftRight
2024-10-28 08:47:29 +00:00
Kyle Miller
62521f4f2d fix: let congr conv tactic handle "over-applied" functions (#5861)
Adds ability to chain congruence lemmas when a function's arity is less
than the number of supplied arguments. This improves `congr` as well as
all conv tactics implemented using `congr`, like `arg` and `enter`.

(The non-conv `congr` tactic still needs to be fixed.)

Toward #2942.
2024-10-28 07:34:33 +00:00
Kyle Miller
9847923f9b feat: record all structure parents in StructureInfo (#5853)
Followup to #5841. Makes the `structure` command populate the new
`parentInfo` field with all the structures in the `extends` clause.

This will require a stage0 update to fully take effect.

Breaking change: now it's a warning if a structure extends a parent
multiple times.

Breaking change: now `getParentStructures` is `getStructureSubobjects`.
Adds `getStructureParentInfo` for getting all the immediate parents.
Note that the set of subobjects is neither a subset nor a superset of
the immediate parents.

Closes #1881
2024-10-28 01:23:48 +00:00
Kyle Miller
709ea6cdf8 feat: make it possible to use dot notation in m! strings (#5857)
This default instance makes it possible to write things like `m!"the
constant is {.ofConstName n}"`.

Breaking change: This weakly causes terms to have a type of
`MessageData` if their type is otherwise unknown. For example:
* `m!"... {x} ..."` can cause `x` to have type `MessageData`, causing
the `let` definition of `x` to fail to elaborate. Fix: give `x` an
explicit type.
* Arithmetic expressions in `m!` strings may need a type ascription. For
example, if the type of `i` is unknown at the time the arithmetic
expression is elaborated, then `m!"... {i + 1} ..."` can fail saying
that it cannot find an `HAdd Nat Nat MessageData` instance. Two fixes:
either ensure that the type of `i` is known, or add a type ascription to
guide the `MessageData` coercion, like `m!"... {(i + 1 : Nat)} ..."`.
2024-10-27 22:55:29 +00:00
Henrik Böving
8c7f7484f9 feat: if support and more in bv_decide (#5855)
Using the same strategy as #5852 this provides `bv_decide` support for
`Bool` and `BitVec` ifs
this in turn instantly enables support for:
- `sdiv`
- `smod`
- `abs`

and thus closes our last discrepancies to QF_BV!
2024-10-27 08:40:38 +00:00
Kyle Miller
c50f04ace0 feat: add delaborators for <|>, <*>, >>, <*, and *> (#5854)
Closes #5668
2024-10-26 23:49:16 +00:00
Henrik Böving
8b5443eb22 feat: support BitVec.ofBool in bv_decide (#5852)
This is the first step towards fixing the issue of not having mutual
recursion between the `Bool` and `BitVec` fragment of `QF_BV` in
`bv_decide`. This PR adds support for `BitVec.ofBool` by doing the
following:
1. Introduce a new mechanism into the reification engine that allows us
to add additional lemmas to the top level on the fly as we are
traversing the expression tree.
2. If we encounter an expression `BitVec.ofBool boolExpr` we reify
`boolExpr` and then abstract `BitVec.ofBool boolExpr` as some atom `a`
3. We add two lemmas `boolExpr = true -> a = 1#1` and `boolExpr = false
-> a = 0#1`. This mirrors the full behavior of `BitVec.ofBool` and thus
makes our atom `a` correctly interpreted again.

In order to do the reification in step 2 mutual recursion in the
reification engine is required. For this reason I started pulling out
logic from the, now rather large, mutual block into other files and
document the invariants that they assume explicitly.
2024-10-26 19:08:07 +00:00
Luisa Cicolini
08c36e4306 feat: add (msb, getMsbD)_twoPow (#5851) 2024-10-26 17:27:37 +00:00
Joachim Breitner
8f0328b777 fix: deprecations in Init.Data.Array.Basic (#5848) 2024-10-26 10:33:47 +00:00
Joachim Breitner
38490a4ac7 refactor: Predefinition.Structural code cleanup (#5850)
useful bits from the shelved #5849
2024-10-26 10:21:47 +00:00
Kyle Miller
13036655e9 fix: reduce types when constructing default values in structure instance notation (#5844)
A step of expanding structure instances is to determine all the default
values, and part of this is reducing projections that appear in the
default values so that they get replaced with the user-provided values.
Binder types in foralls, lambdas, and lets have to be reduced too.

Closes #2186
2024-10-26 00:45:21 +00:00
Kyle Miller
4068cf00ee chore: remove unnecessary private Inhabited instance (#5846)
Since `partial` inhabitation is stronger in #5821, this private instance
is no longer needed.
2024-10-25 23:31:18 +00:00
Kyle Miller
abe6d5bca7 fix: declaration ranges changed after stage0 update (#5845)
Recently declaration ranges have changed slightly to include attribute
lists. Fixes a test that broke.
2024-10-25 21:38:06 +00:00
Lean stage0 autoupdater
f292184642 chore: update stage0 2024-10-25 20:35:09 +00:00
Kyle Miller
a310488b7f chore: refactor structure command, fixes (#5842)
Refactors the `structure` command to support recursive structures. These
are disabled for now, pending additional elaborator support in #5822.
This refactor is also a step toward `structure` appearing in `mutual`
blocks.

Error reporting is now more precise, and this fixes an issue where
general errors could appear on the last field. Adds "don't know how to
synthesize placeholder" errors for default values.

Closes #2512
2024-10-25 19:46:17 +00:00
Joachim Breitner
57a95c8b5f test: test case for #5836 (#5843) 2024-10-25 19:34:09 +00:00
Kyle Miller
266ae428dc feat: preliminary work for parent projections in StructureInfo (#5841)
This adds a `parentInfo` field to the `StructureInfo`, which will
eventually be populated with the actual parents of a structure. This is
work toward #1881. Also documents fields of the structure info data
structures.

Requires a stage0 update before the next steps.
2024-10-25 18:54:32 +00:00
Kim Morrison
4c0d12b3f1 chore: cleanup some deprecations in tests (#5834) 2024-10-25 11:11:22 +00:00
Sebastian Ullrich
748f0d6c15 fix: instantiateMVars slowdown in the language server (#5805)
Fixes #5614
2024-10-25 09:35:41 +00:00
Kim Morrison
07ea626560 feat: Array.forIn', and relate to List (#5833)
Adds support for `for h : x in my_array do`, and relates this to the
existing `List` version.
2024-10-25 07:24:39 +00:00
Henrik Böving
193b6f2bec feat: define Int8 (#5790) 2024-10-25 06:06:40 +00:00
Yann Herklotz
19ce2040a2 fix: wildcard generalize only generalizes visible theorems (#4846)
`generalize ... at *` sometimes will try to modify the recursive
hypothesis corresponding to the current theorem being defined, which may
not be the expected behaviour. It should only try to `generalize`
hypotheses that it can actually modify and are visible, not
implementation details. Otherwise this means that there are
discrepancies between `generalize ... at *` and `generalize ... at H`,
even though `H` is the only hypothesis in the context.

This commit uses `getLocalHyps` instead of `getFVarIds` to get the
current valid `FVarIds` in the context. This uses
`isImplementationDetail` to filter out `FVarIds` that are implementation
details in the context and are not visible to the user and should not be
manipulated by `generalize`.

Closes #4845
2024-10-25 05:09:28 +00:00
Kim Morrison
059674d967 chore: minor fixes in Array lemmas (#5832) 2024-10-25 04:28:41 +00:00
Arthur Adjedj
7150a0d538 fix: reduce let-bodies correctly in StructInst (#3152)
Closes #3146

Reduction doesn't trigger correctly on the bodies of `let`-expressions
in `StructInst`, leading some meta-variables to linger in the terms of
some fields. Because of this, default fields may try multiple times (and
fail) to be generated, leading to an unexpected error.

The solution implemented here is to modify the values of the introduced
variables in the local context so as to reduce them correctly.
2024-10-24 23:33:33 +00:00
Kyle Miller
0725cd39a2 fix: liftCommandElabM now carries more state over (#5800)
The `liftCommandElabM : CommandElabM α -> CoreM α` function now carries
over macro scopes, the name generator, info trees, and messages.

Adds a flag `throwOnError`, which is true by default. When it is true,
then if the messages contain an error message, it is converted into an
exception. In this case, the infotrees and messages are not carried
over; the motivation is that `throwOnError` is likely used for synthetic
syntax, and so the info and messages on errors will just be noise.
2024-10-24 23:19:06 +00:00
Kyle Miller
e07272a53a chore: review delaborators, make sure they respond to pp.explicit (#5830)
Rule: if an expression contains an implicit argument that the
delaborator would omit, only use the delaborator if `pp.explicit` is
false.
2024-10-24 22:56:47 +00:00
Sebastian Ullrich
9157c1f279 test: big_omega benchmark (#5817)
Extracted from #5614
2024-10-24 07:26:29 +00:00
Kim Morrison
09e1a05ee9 chore: cleanup imports (#5825) 2024-10-23 23:51:13 +00:00
Henrik Böving
8822b0fca7 feat: bv_decide BitVec.sdiv (#5823) 2024-10-23 21:10:27 +00:00
Kyle Miller
249530f3c1 feat: partial inhabitation uses local Inhabited instances created from parameters (#5821)
Rather than having a special pass where `mkInhabitantFor` uses the
`assumption` tactic, it creates `Inhabited` instances for each parameter
and just searches for an `Inhabited`/`Nonempty` instance for the return
type.

This makes examples like the following work:
```lean
partial def f (x : X) : Bool × X := ...
```

Removes the strategy where it looks for `Inhabited`/`Nonempty` instances
for every suffix of the signature.

This is a follow-up to #5780. Motivated [by
Zulip](https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/Why.20return.20type.20of.20partial.20function.20MUST.20.60inhabited.60.3F/near/477905312).
2024-10-23 18:15:31 +00:00
Sebastian Ullrich
174a5f345a refactor: nicer modifiers/ranges API (#5788)
Cleanup of #5650 

* default `Modifiers.stx` to missing
* rename and clarify `addDeclarationRangesFromSyntax` as the main
convenience function for user metaprograms
2024-10-23 09:21:50 +00:00
Aaron Tomb
45b1b367ca test: add a benchmark that is slow to elaborate (#5656)
Add an example Lean file that includes an unusually large definition
that takes a long time to elaborate.

It may be that it's difficult to process it more efficiently, but
perhaps someone will discover a way to improve it if it's in the
benchmark suite. Improved performance on this benchmark will likely make
some program analysis and verification tasks within Lean more feasible.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-10-23 08:20:15 +00:00
Kim Morrison
c1143d9432 feat: more lemmas for List.modify (#5816) 2024-10-23 06:45:20 +00:00
Kyle Miller
66dbad911e fix: improve error message for partial inhabitation and add delta deriving (#5780)
Example new output:
```text
failed to compile 'partial' definition 'checkMyList', could not prove that the type
  ListNode → Bool × ListNode
is nonempty.

This process uses multiple strategies:
- It looks for a parameter that matches the return type.
- It tries synthesizing 'Inhabited' and 'Nonempty' instances for the return type.
- It tries unfolding the return type.

If the return type is defined using the 'structure' or 'inductive' command, you can try
adding a 'deriving Nonempty' clause to it.
```
The inhabitation prover now also unfolds definitions when trying to
prove inhabitation. For example,
```lean
def T (α : Type) := α × α

partial def f (n : Nat) : T Nat := f n
```

Motivated [by
Zulip](https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/Why.20return.20type.20of.20partial.20function.20MUST.20.60inhabited.60.3F/near/477905312)
2024-10-23 06:32:11 +00:00
FR
fad57cf5a2 chore: remove redundant Decidable assumptions (#5812) 2024-10-23 04:52:54 +00:00
Kyle Miller
83129b7e3a fix: inductive elaboration should keep track of universe level parameters created in binders (#5814)
Refactors `inductive` elaborator to keep track of universe level
parameters created during elaboration of `variable`s and binders. This
fixes an issue in Mathlib where its `Type*` elaborator can result in
unexpected universe levels.

For example, in
```lean4
variable {F : Type*}
inductive I1 (A B : Type*) (x : F) : Type
```
before this change the signature would be
```
I1.{u_1, u_2} {F : Type u_1} (A : Type u_1) (B : Type u_2) (x : F) : Type
```
but now it is
```
I1.{u_1, u_2, u_3} {F : Type u_1} (A : Type u_2) (B : Type u_3) (x : F) : Type
```
Fixes this for the `axiom` elaborator too.

Adds more accurate universe level validation for mutual inductives.

Breaking change: removes `Lean.Elab.Command.expandDeclId`. Use
`Lean.Elab.Term.expandDeclId` from within `runCommandElabM`.
2024-10-23 04:07:40 +00:00
Kyle Miller
fa711253d6 feat: improved error message for unfold (#5815)
When `unfold` is trying to unfold a local variable that's not a local
definition, throws an error.

For issue from
[Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Unqualified.20unfold.20no.20longer.20works/near/478387250)
2024-10-23 03:35:15 +00:00
Joachim Breitner
eddbdd77b8 doc: refine rwa docstring (#5811)
fixes #5792
2024-10-22 16:02:39 +00:00
Markus Himmel
f0c190239a feat: compile against Windows SDK headers under Windows (#5753)
Breaking changes:

To build Lean from source on Windows, it is now necessary to install the
[Windows
SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/).
The build instructions have been updated to reflect this. Note that the
Windows SDK is **not** needed to compile Lean programs using a Lean
toolchain obtained using `elan`. The Windows SDK is only needed to build
Lean itself from source.

Furthermore, we are dropping support for Windows versions older than
Windows 10 1903 (released in May 2019).

No Windows version that is still supported by Microsoft as part of
mainstream support is affected by this.

The following Windows versions are still supported by Microsoft as part
of commercial extended support but are no longer supported by Lean:

- Windows 10 Enterprise LTSC 2015
- Windows 10 Enterprise LTSC 2016
- Windows 10 Enterprise LTSC 2019
- Windows Server 2019
2024-10-22 13:00:02 +00:00
Joachim Breitner
bab6aff173 chore: nix-ci.yml: fix test-results.xml path (#5804) 2024-10-22 11:18:40 +00:00
Joachim Breitner
5bea46deb0 fix: FunInd: withLetDecl and mkLetVar don’t mix (#5803)
Fixes: #5767
2024-10-22 10:15:14 +00:00
Marc Huisinga
462e52d0c0 feat: use "eureka!" icon for theorem completions (#5801)
It's difficult to distinguish theorems from regular definitions in the
completion menu, which is annoying when using completion for searching
one or the other. This PR makes theorem completions use the "Eureka!"
icon (![eureka
icon](https://code.visualstudio.com/assets/docs/editor/intellisense/symbol-event.svg))
to distinguish them more clearly from other completions.

NB: We are very limited in terms of which icons we can pick here since
[the completion kinds provided by LSP / VS
Code](https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions)
are optimized for object-oriented programming languages, but I think
this choice strikes a nice balance between being easy to identify,
having some visual connection to theorem proving and not being used a
lot in other languages and thus not clashing with pre-existing
associations.
2024-10-22 10:07:37 +00:00
Sebastian Ullrich
d0abe1d382 fix: restore synchronous fast-forwarding path in language processor (#5802)
Between #3106 and this, it was possible that reparsing the file up to
the current position was stuck waiting in the threadpool queue,
displaying a yellow bar and not displaying any info on the unchanged
prefix.
2024-10-22 09:50:30 +00:00
Eric Wieser
f752ce2db9 doc: stub for ellipsis notation (#5794)
This is certainly better than no documentation, though it's not obvious
to me whether the `_` insertion is greedy, lazy, or somewhere in
between.
2024-10-22 01:33:46 +00:00
Kim Morrison
07c09ee579 feat: relate Array.forIn and List.forIn (#5799) 2024-10-22 01:20:13 +00:00
Kim Morrison
919f64b2e6 chore: upstream List.modify, add lemmas, relate to Array.modify (#5798)
Note that the order of arguments still differs between `List.modify` and
`Array.modify`. I'll settle this later.
2024-10-22 01:01:32 +00:00
Kim Morrison
71122696a1 feat: rename Array.shrink to take, and relate to List.take (#5796) 2024-10-21 23:35:32 +00:00
Tobias Grosser
8d789f7b63 feat: add BitVec.toInt_sub, simplify BitVec.toInt_neg (#5772)
This also requires us to expand the theory of `Int.bmod`.

---------

Co-authored-by: Alex Keizer <alex@keizer.dev>
2024-10-21 22:38:29 +00:00
Leonardo de Moura
82d31a1793 perf: has_univ_mvar, has_univ_mvar, and has_fvar in C++ (#5793)
`instantiate_mvars` is now implemented in C/C++, and makes many calls to
`has_fvar`, `has_mvar`. The new C/C++ implementations are inlined and
avoid unnecessary RC inc/decs.
2024-10-21 16:56:30 +00:00
Joachim Breitner
76164b284b fix: RecursorVal.getInduct to return name of major argument’s type (#5679)
Previously `RecursorVal.getInduct` would return the prefix of the
recursor’s name, which is unlikely the right value for the “derived”
recursors in nested recursion. The code using `RecursorVal.getInduct`
seems to expect the name of the inductive type of major argument here.

If we return that name, this fixes #5661.

This bug becomes more visible now that we have structural mutual
recursion.

Also, to avoid confusion, renames the function to ``getMajorInduct`.
2024-10-21 08:45:18 +00:00
Kim Morrison
51377afd6c feat: simp lemmas for Array.isEqv and beq (#5786)
- [ ] depends on: #5785
2024-10-21 07:37:40 +00:00
Kim Morrison
6f642abe70 feat: Nat.forall_lt_succ and variants (#5785) 2024-10-21 06:51:23 +00:00
Kim Morrison
8151ac79d6 chore: Array cleanup (#5782)
More cleanup of Array API. More to come.
2024-10-21 06:00:37 +00:00
Kim Morrison
4f18c29cb4 chore: make 'while' available earlier (#5784) 2024-10-21 05:56:37 +00:00
Kim Morrison
5d155d8b02 chore: simplify signature of Array.mapIdx (#5749)
This PR simplifies the signature of `Array.mapIdx`, to take a function
`f : Nat \to \a \to \b` rather than a function `f : Fin as.size \to \a
\to \b`.

Lean doesn't actually use the extra generality anywhere (so in fact this
change *simplifies* all the call sites of `Array.mapIdx`, since we no
longer need to throw away the proof).

This change would make the function signature equivalent to
`List.mapIdx`, hence making it easier to write verification lemmas.

We keep the original behaviour as `Array.mapFinIdx`.
2024-10-21 05:48:42 +00:00
Henrik Böving
def81076de feat: bv_decide introduces uninterpreted symbols everywhere (#5781)
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-10-20 21:01:21 +00:00
Kyle Miller
46f1335b80 fix: have Lake not create core aliases into Lake namespace (#5688)
This replaces `export Lean (Name NameMap)` and `export System
(SearchPath FilePath)` with the relevant `open` commands. This fixes
docgen output so that it can refer to, for example, `Lean.Name` instead
of `Lake.Name`.

The reason for these `export`s was convenience: by doing `open Lake` you
could get these aliases for free. However, aliases affect pretty
printing, and the Lake aliases took precedence. We don't want to disable
pretty printing re-exported names because this can be a valid pattern
(names could incrementally get re-exported from namespace to parent
namespace).

In the future we might implement a feature to be able to `scoped open`
some names.

Breaking change: Lakefiles that refer to `FilePath` may need to change
this to `System.FilePath` or otherwise add `open System (FilePath)`.

Closes #2524
2024-10-20 18:40:44 +00:00
Kyle Miller
682173d7c0 feat: #version command (#5768)
Prints `Lean.versionString` and target/platform information. Example:
```
Lean 4.12.0, commit 8218940152
Target: arm64-apple-darwin23.5.0 macOS
```
2024-10-18 20:17:52 +00:00
Joachim Breitner
26df545598 fix: structural nested recursion confused when nested type appears first (#5766)
this fixes #5726
2024-10-18 19:41:24 +00:00
Sebastian Ullrich
11ae8bae42 fix: include references in attributes in call hierarchy (#5650)
By ensuring all `declModifiers` are included in `addDeclarationRanges`,
`implementedBy` references etc are included in the call hierarchy
2024-10-18 15:38:32 +00:00
Henrik Böving
a167860e3b chore: @hargoniX Std.Sat codeowner, fix Kim's user name (#5765) 2024-10-18 11:13:28 +00:00
Markus Himmel
cc76496050 chore: check-prelude also for Std (#5764) 2024-10-18 10:53:52 +00:00
Sebastian Ullrich
41b35baea2 fix: duplicate info trees from IO.processCommandsIncrementally (#5763)
As reported in https://github.com/leanprover-community/repl/pull/57
2024-10-18 10:17:30 +00:00
Kim Morrison
a6243f6076 chore: deprecation for Array.data (#5687) 2024-10-18 03:16:38 +00:00
Kyle Miller
fd15d8f9ed feat: Lean.Expr.name? (#5760)
Adds a recognizer for `Name` literal expressions. Handles `Name`
constructors as well as the `Lean.Name.mkStr*` functions.
2024-10-18 02:40:26 +00:00
Kyle Miller
1d66ff8231 fix: app unexpander for sorryAx (#5759)
Fixes a long-standing bug in the the `sorryAx` app unexpander that
prevented it from applying. Now `sorry` pretty prints as `sorry`.
2024-10-18 01:44:52 +00:00
Kim Morrison
51ab162a5a chore: upstream Array.reduceOption (#5758) 2024-10-18 00:41:09 +00:00
Kim Morrison
41797a78c3 chore: deprecate Nat.sum (#5746) 2024-10-18 00:03:36 +00:00
David Thrane Christiansen
d6a7eb3987 feat: add Hashable instance for Char (#5747)
I needed this in downstream code, and it seems to make the most sense to
just contribute it here.
2024-10-17 14:46:10 +00:00
Sebastian Ullrich
fc5e3cc66e fix: do not force snapshot tree too early (#5752)
This turns out to be the issue behind #5736, though really it is yet
another indicator of a general thread pool weakness.
2024-10-17 12:23:34 +00:00
Marc Huisinga
372f344155 fix: some goal state issues (#5677)
This PR resolves the following issues related to goal state display:
1. In a new line after a `case` tactic with a completed proof, the state
of the proof in the `case` would be displayed, not the proof state after
the `case`
1. In the range of `next =>` / `case' ... =>`, the state of the proof in
the corresponding case would not be displayed, whereas this is true for
`case`
1. In the `suffices ... by` tactic, the tactic state of the `by` block
was not displayed after the `by` and before the first tactic

The incorrect goal state after `case` was caused by `evalCase` adding a
`TacticInfo` with the full block proof state for the full range of the
`case` block that the goal state selection has no means of
distinguishing from the `TacticInfo` with the same range that contains
the state after the whole `case` block. Narrowing the range of this
`TacticInfo` to `case ... =>` fixed this issue.

The lack of a case proof state on `next =>` was caused by the `case`
syntax that `next` expands to receiving noncanonical synthetic
`SourceInfo`, which is usually ignored by the language server. Adding a
token antiquotation for `next` fixed this issue.

The lack of a case proof state on `case' ... =>` was caused by
`evalCase'` not adding a `TacticInfo` with the full block state to the
range of `case' ... =>`. Adding this `TacticInfo` fixed this issue.

The tactic state of the block not being displayed after the `by` was
caused by the macro expansion of `suffices` to `have` not transferring
the trailing whitespace of the `by`. Ensuring that this trailing
whitespace information is transferred fixed this issue.

Fixes #2881.
2024-10-17 12:09:54 +00:00
Sebastian Ullrich
f2ac0d03c6 perf: do not lint unused variables defined in tactics by default (#5338)
Should ensure we visit at most as many expr nodes as in the final expr
instead of many possibly overlapping mvar assignments. This is likely
the only way we can ensure acceptable performance in all cases.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-10-17 09:55:11 +00:00
Joachim Breitner
08d8a0873e doc: remove docstring from implicitDefEqProofs (#5751)
this option was added in fb97275dcb to
prepare for #4595, due to boostrapping issues, but #4595 has not landed
yet. This is be very confusing when people discover this option and try
to use it (as I did).

So let's clearly mark this as not yet implemented on `master`, and add
the
docstring only with #4595.
2024-10-17 09:38:52 +00:00
Sebastian Ullrich
68b0471de9 chore: remove SplitIf.ext cache (#5571)
Incompatible as is with parallelism; let's first check if it has any
impact at all
2024-10-17 09:36:00 +00:00
Kim Morrison
3a34a8e0d1 chore: move Array.mapIdx lemmas to new file (#5748) 2024-10-17 05:54:25 +00:00
Kim Morrison
6fa75e346a chore: upstream List.foldxM_map (#5697) 2024-10-17 04:30:08 +00:00
Eric Wieser
2669fb525f feat: change lake new math to use autoImplicit false (#5715)
The reality is that almost every math project uses this setting already,
even if it is not the default:

*
36b7d4a6d0/lakefile.lean (L7)
*
9ea3a96243/lakefile.lean (L45)
*
97755eaae3/lakefile.toml (L6)
*
fb92dbf97f/lakefile.lean (L7)
*
c8569b3d39/lakefile.toml (L6)
*
c7fae107fd/lakefile.lean (L8)
*
1d891c770d/lakefile.lean (L27)

The fact that MIL uses it is particularly notable, as it means that
newcomers have an unexpected surprise when they want to take on a brand
new project.

---

I don't know whether this is `chore`, `feat`, `fix`, `refactor`, or
something else.
2024-10-17 04:29:48 +00:00
Eric Wieser
8632b79023 doc: point out that OfScientific is called with raw literals (#5725) 2024-10-17 04:29:00 +00:00
Kim Morrison
e8970463d1 fix: change String.dropPrefix? signature (#5745) 2024-10-17 03:51:45 +00:00
Kim Morrison
69e8cd3d8a chore: cleanup in Array/Lemmas (#5744) 2024-10-17 03:36:26 +00:00
Kim Morrison
565ac23b78 chore: move Antisymm to Std.Antisymm (#5740) 2024-10-17 02:26:55 +00:00
Kim Morrison
c1750f4316 chore: upstream basic material on Sum (#5741) 2024-10-17 01:27:41 +00:00
Kim Morrison
092c87a70f chore: upstream ne_of_apply_ne (#5743) 2024-10-17 01:24:01 +00:00
Kim Morrison
b8fc6c593a chore: upstream ne_of_mem_of_not_mem (#5742) 2024-10-17 01:18:23 +00:00
Kim Morrison
7c2425605c chore: upstream material on Prod (#5739) 2024-10-16 23:03:44 +00:00
Kim Morrison
3f7854203a chore: rename List.pure to List.singleton (#5732) 2024-10-16 22:11:07 +00:00
Sebastian Ullrich
79583d63f3 fix: don't block on snapshot tree if tracing is not enabled (#5736)
While there appears to be an underlying issue of blocking tasks that
this specific PR is not resolving, it should alleviate the problems
described in
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/reliable.20file.20desync.20on.20Linux.20Mint
as it effectively reverts the relevant change introduced in 4.13.0-rc1
when the trace option is not set.
2024-10-16 13:12:42 +00:00
Henrik Böving
741040d296 feat: UIntX.[val_ofNat, toBitVec_ofNat] (#5735) 2024-10-16 12:39:41 +00:00
Luisa Cicolini
b69377cc42 feat: add BitVec.(getMSbD, msb)_(add, sub) and BitVec.getLsbD_sub (#5691)
Since `getMsbD_add`, `getMsbD_sub`, `getLsbD_sub`, `msb_sub` , `msb_add`
depend on `getLsbD_add` (which lives in`BitBlast.lean`) and on each
other, I put all of these in `BitBlast.lean`.
2024-10-16 11:47:20 +00:00
Kim Morrison
ef05bdc449 chore: rename List.bind and Array.concatMap to flatMap (#5731) 2024-10-16 11:30:49 +00:00
Lean stage0 autoupdater
50594aa932 chore: update stage0 2024-10-16 13:35:31 +02:00
Joachim Breitner
032c0257c3 feat: DiscrTree: index the domain of
It bothered me that inferring instances of the shape `Decidable (∀ (x : Fin _), _)`
will go linearly through all instances of that shape, even those that are
about `∀ (x : Nat), …`. And that  `Decidable (∃ (x : Fin _), _)` gets better
indexing than `Decidable (∀ (x : Fin _), _)`.

Judging from code comments, the discr tree used to index arrow types
with two arguments (domain and body), and that led to bugs due to the
dependency, so the arguments were removed. But it seems that indexing
the domain is completely simple and innocent.

So let’s see what happens…

Mostly only insignificant perf improvements, unfortunately (~Mathlib.Data.Matroid.IndepAxioms — instructions -11.4B, overall build instructions -0.097 %):
http://speed.lean-fro.org/mathlib4/compare/dd333cc1-fa26-42f2-96c6-b0e66047d0b6/to/6875ff8f-a17c-431d-8b8b-2f00799be794

This is just a small baby step compared to the more invasive improvements
done in the [`RefinedDiscrTree` by  J. W. Gerbscheid](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Tactic/FunProp/RefinedDiscrTree.html) in mathlib.
2024-10-16 13:35:31 +02:00
Joachim Breitner
a2d2977228 fix: ac_nf0, simp_arith: don't tempt the kernel to reduce atoms (#5708)
this fixes #5699 and fixes #5384.
2024-10-16 08:52:58 +00:00
Jerry Wu
b333de1a36 fix: make applyEdit optional in WorkspaceClientCapabilities of LSP (#5224)
The `applyEdit` field should be optional in
`WorkspaceClientCapabilities` by the LSP spec and some clients don't
populate it in requests

Closes #4541
2024-10-16 08:38:11 +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
a04b476431 chore: remove instBEqNat, which is redundant with instBEqOfDecidableEq but not defeq (#5694) 2024-10-16 04:42:22 +00:00
Kyle Miller
eea953b94f feat: push/pop tactic API (#5720)
Adds `pushGoal`/`pushGoals` and `popGoal` for manipulating the goal
state. These are an alternative to `replaceMainGoal` and `getMainGoal`,
and with them you don't need to worry about making sure nothing clears
assigned metavariables from the goal list between assigning the main
goal and using `replaceMainGoal`.

Modifies `closeMainGoalUsing`, which is like a `TacticM` version of
`liftMetaTactic`. Now the callback is run in a context where the main
goal is removed from the goal list, and the callback is free to modify
the goal list. Furthermore, the `checkUnassigned` argument has been
replaced with `checkNewUnassigned`, which checks whether the value
assigned to the goal has any *new* metavariables, relative to the start
of execution of the callback. This API is sufficient for the `exact`
tactic for example.

Modifies `withCollectingNewGoalsFrom` to take the `parentTag` argument
explicitly rather than indirectly via `getMainTag`. This is needed when
used under `closeMainGoalUsing`.

Modifies `elabTermWithHoles` to optionally take `parentTag?`. It
defaults to `getMainTag` if it is `none`.

Renames `Tactic.tryCatch` to `Tactic.tryCatchRestore`, and adds a
`Tactic.tryCatch` that doesn't do backtracking.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-10-16 03:54:58 +00:00
Kim Morrison
dec1262697 chore: upstream classical tactic (#5730) 2024-10-16 03:35:41 +00:00
Kim Morrison
487c2a937a feat: Expr helper functions (#5729)
`getNumHeadForalls` and `getNumHeadLambdas` were both duplicated
downstream with different names; I'll clean up those next.

Also adds `getAppNumArgs'`.
2024-10-16 03:07:34 +00:00
Kim Morrison
831fa0899f chore: upstream String.dropPrefix? (#5728)
Useful String helper functions widely used in tactic implementations.
2024-10-16 02:41:17 +00:00
Kim Morrison
94053c9b1b chore: make getIntrosize public (#5727)
This is the most popular target of `open private`, and seems a
reasonable part of the public API.
2024-10-16 02:35:12 +00:00
Joachim Breitner
94b1e512da fix: simpproc to reduce Fin literals consistently (#5632)
previously, it would not reduce `25 : Fin 25` to  `0 : Fin 25`.

fixes #5630
2024-10-15 15:59:50 +00:00
Joachim Breitner
5a87b104f6 refactor: remove mkRecursorInfoForKernelRec (#5681)
it seems to be unused, arguably even for kernel recursors their type
should be usable with `mkRecursorInfo`, and removing this will help
understand the impact of #5679.
2024-10-15 15:59:04 +00:00
Kim Morrison
dc83a607b2 fix: List.drop_drop addition order (#5716) 2024-10-15 10:14:02 +00:00
Tobias Grosser
7234ab79ed feat: add BitVec.sdiv_[zero|one|self] theorems (#5718)
Co-authored-by: Siddharth <siddu.druid@gmail.com>
2024-10-15 09:47:21 +00:00
Markus Himmel
c27e671036 chore: rename instDecidableEqQuotientOfDecidableEquiv to Quotient.decidableEq (#5722)
Mathlib has a duplicate of this instance as `Quotient.decidableEq` (with
the same implementation) and refers to it by name a few times, so let's
just rename our version to the mathlib name so that the copy in mathlib
can be dropped.
2024-10-15 09:46:25 +00:00
Alex Keizer
94dd1d61bd feat: bv_decide inequality regression tests (#5714)
This takes a few standalone bitvector problems, about inequalties, from
LNSym, and adds them as a benchmark to prevent further regressions with
bv_decide.

These problems are particularly interesting, because they've previously
had a bad interaction with bv_decides normalization pass, see
https://github.com/leanprover/lean4/issues/5664.

---------

Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-10-15 08:51:14 +00:00
Kim Morrison
4409e39c43 chore: upstream List.sum, planning to later deprecate Nat.sum (#5703) 2024-10-15 08:41:35 +00:00
Kim Morrison
0bfe1a8c1a chore: better default value for Array.swapAt! (#5705) 2024-10-15 01:18:51 +00:00
Kyle Miller
a026bc7edb feat: let dot notation see through CoeFun instances (#5692)
Projects like mathlib like to define projection functions with extra
structure, for example one could imagine defining `Multiset.card :
Multiset α →+ Nat`, which bundles the fact that `Multiset.card (m1 + m2)
= Multiset.card m1 + Multiset.card m2` for all `m1 m2 : Multiset α`. A
problem though is that so far this has prevented dot notation from
working: you can't write `(m1 + m2).card = m1.card + m2.card`.

With this PR, now you can. The way it works is that "LValue resolution"
will apply CoeFun instances when trying to resolve which argument should
receive the object of dot notation.

A contrived-yet-representative example:
```lean
structure Equiv (α β : Sort _) where
  toFun : α → β
  invFun : β → α

infixl:25 " ≃ " => Equiv

instance: CoeFun (α ≃ β) fun _ => α → β where
  coe := Equiv.toFun

structure Foo where
  n : Nat

def Foo.n' : Foo ≃ Nat := ⟨Foo.n, Foo.mk⟩

variable (f : Foo)
#check f.n'
-- Foo.n'.toFun f : Nat
```

Design note 1: While LValue resolution attempts to make use of named
arguments when positional arguments cannot be used, when we apply CoeFun
instances we disallow making use of named arguments. The rationale is
that argument names for CoeFun instances tend to be random, which could
lead dot notation randomly succeeding or failing. It is better to be
uniform, and so it uniformly fails in this case.

Design note 2: There is a limitation in that this will *not* make use of
the values of any of the provided arguments when synthesizing the CoeFun
instances (see the tests for an example), since argument elaboration
takes place after LValue resolution. However, we make sure that
synthesis will fail rather than choose the wrong CoeFun instance.

Performance note: Such instances will be synthesized twice, once during
LValue resolution, and again when applying arguments.

This also adds in a small optimization to the parameter list computation
in LValue resolution so that it lazily reduces when a relevant parameter
hasn't been found yet, rather than using `forallTelescopeReducing`. It
also switches to using `forallMetaTelescope` to make sure the CoeFun
synthesis will fail if multiple instances could apply.

Getting this to pretty print will be deferred to future work.

Closes #1910
2024-10-14 21:49:33 +00:00
Kyle Miller
36c2511b27 feat: options pp.mvars.anonymous and pp.mvars.levels (#5711)
Gives more control over pretty printing metavariables.

- When `pp.mvars.levels` is false, then universe level metavariables
pretty print as `_` rather than `?u.22`
- When `pp.mvars.anonymous` is false, then anonymous metavariables
pretty print as `?_` rather than `?m.22`. Named metavariables still
pretty print with their names. When this is false, it also sets
`pp.mvars.levels` to false, since every level metavariable is anonymous.
- When `pp.mvars` is false, then all metavariables pretty print as `?_`
or `_`.

Modifies TryThis to use `pp.mvars.anonymous` rather than doing a
post-delaboration modification. This incidentally improves TryThis since
it now prints universe level metavariables as `_` rather than `?u.22`.
2024-10-14 21:44:15 +00:00
Henrik Böving
adfbc56f91 chore: disable ac_nf by default (#5673)
We trust that the users read the error messages or tactic docs to
discover the option.
AWS problems have shown that this can be too eager of an operation to
do.
Given that we have the luxury of interactivity let's go for an approach
where the users
can optionally enable it.
2024-10-14 21:23:18 +00:00
Tobias Grosser
9f8ce47699 feat: add BitVec.[udiv|umod]_[zero|one|self] theorems (#5712)
Co-authored-by: Siddharth <siddu.druid@gmail.com>
2024-10-14 20:27:05 +00:00
Kyle Miller
3d175ab25f fix: the elaboration warning did not mention pp.maxSteps (#5710)
This also adds in the tip that hovering over `⋯` gives the option that
led to its presence.
2024-10-14 17:28:28 +00:00
Henrik Böving
9b6696be1d feat: use libuv for tempfiles (#5135)
This is currently broken because of linker issues. CC @TwoFX

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
2024-10-14 13:56:56 +00:00
Marc Huisinga
057482eb1c feat: denote deprecations in completion items (#5707)
This PR ensures that deprecated declarations are displayed with a
strikethrough markup in the completion popup of VS Code and that the
docstring of a completion item denotes the meta-data of the deprecation.
2024-10-14 13:05:16 +00:00
Kim Morrison
16e2a785aa chore: remove @[simp] from Option.isSome_eq_isSome (#5704) 2024-10-14 12:28:43 +00:00
Johan Commelin
2580694e26 chore: mark prefix_append_right_inj as simp lemma (#5706) 2024-10-14 11:49:38 +00:00
Kim Morrison
9ec29b4e3a chore: update stage0 2024-10-14 22:28:12 +11:00
Kim Morrison
aa2360a41d chore: rename List.join to List.flatten
one more

one more

one more

fix test
2024-10-14 22:28:12 +11:00
Siddharth
65637b7683 feat: lemmas about BitVector arithmetic inequalities (#5646)
These lemmas are peeled from `leanprover/lnsym`.
Moreover, note that these lemmas only hold when we do not have overflow
in their operands, and thus, we are able to treat the operands as if
they were 'regular' natural numbers.

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Kim Morrison <scott@tqft.net>
2024-10-14 08:14:11 +00:00
Kim Morrison
20ea855e50 feat: upstream List.mapIdx, and add lemmas (#5696) 2024-10-14 07:25:02 +00:00
Kim Morrison
225e08965d chore: import orphaned Lean.Replay (#5693)
As noticed on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.E2.9C.94.20Reverse.20FFI.20undefined.20reference.20for.20mathlib/near/475824204).
2024-10-14 01:29:03 +00:00
Tobias Grosser
7fd2aa04ae chore: move BitVec.udiv/umod/sdiv/smod after add/sub/mul/lt (#5623)
Divison proofs are more likely to depend on add/sub/mul proofs than the
other way around. This cleans up
https://github.com/leanprover/lean4/pull/5609, which added division
proofs that rely on negation to already be defined.
2024-10-13 20:11:31 +00:00
Luisa Cicolini
47e0430b07 feat: complete BitVec.[getMsbD|getLsbD|msb] for shifts (#5604)
Co-authored-by: Tobias Grosser <github@grosser.es>
2024-10-13 17:45:19 +00:00
Tobias Grosser
5d6553029c feat: expand relationship with BitVec and toFin (#5680) 2024-10-13 16:28:28 +00:00
James Oswald
1d8555fe0b fix: help message flags, removes -f flag and adds -g flag (#5685)
Closes #5682

- Removes the broken `-f` flag from the help message which doesn't
behave as expected as an alternative to `--features`.
- Adds the `-g` flag to the help message which is a working alternative
to the `--githash` flag.
2024-10-13 06:37:09 +00:00
Mac Malone
068208091f refactor: lake: restrict cache fetch to leanprover* (#5642)
Lake will now only automatically fetch Reservoir build caches for
package in the the `leanprover` and `leanprover-community`
organizations. We are not planning to expand the Reservoir build cache
to other packages until farther in the future.
2024-10-12 22:56:49 +00:00
Marc Huisinga
a3bc4d2359 fix: make IO-bound tasks dedicated (#5678)
This PR ensures that all I/O-bound tasks in the language server use
dedicated tasks.
2024-10-11 15:23:11 +00:00
Henrik Böving
087219bf5d feat: make bv_decide error when the LRAT proof is invalid (#5676) 2024-10-11 15:04:23 +00:00
Henrik Böving
e5bbda1c3d fix: context tracking in bv_decide counter example (#5675)
Closes #5674.
2024-10-11 08:57:06 +00:00
Kyle Miller
742ca6afa7 feat: support let rec in #eval (#5663)
Makes `#eval` use the `elabMutualDef` machinery to process all the `let
rec`s that might appear in the expression. This now works:
```lean
#eval
  let rec fact (n : Nat) : Nat :=
    match n with
    | 0 => 1
    | n' + 1 => n * fact n'
  fact 5
```

Closes #2374
2024-10-11 06:46:16 +00:00
Kyle Miller
fe0fbc6bf7 feat: decide! tactic for using kernel reduction (#5665)
The `decide!` tactic is like `decide`, but when it tries reducing the
`Decidable` instance it uses kernel reduction rather than the
elaborator's reduction.

The kernel ignores transparency, so it can unfold all definitions (for
better or for worse). Furthermore, by using kernel reduction we can
cache the result as an auxiliary lemma — this is more efficient than
`decide`, which needs to reduce the instance twice: once in the
elaborator to check whether the tactic succeeds, and once again in the
kernel during final typechecking.

While RFC #5629 proposes a `decide!` that skips checking altogether
during elaboration, with this PR's `decide!` we can use `decide!` as
more-or-less a drop-in replacement for `decide`, since the tactic will
fail if kernel reduction fails.

This PR also includes two small fixes:
- `blameDecideReductionFailure` now uses `withIncRecDepth`.
- `Lean.Meta.zetaReduce` now instantiates metavariables while zeta
reducing.

Some profiling:
```lean
set_option maxRecDepth 2000
set_option trace.profiler true
set_option trace.profiler.threshold 0

theorem thm1 : 0 < 1 := by decide!
theorem thm1' : 0 < 1 := by decide
theorem thm2 : ∀ x < 400, x * x ≤ 160000 := by decide!
theorem thm2' : ∀ x < 400, x * x ≤ 160000 := by decide
/-
[Elab.command] [0.003655] theorem thm1 : 0 < 1 := by decide!
[Elab.command] [0.003164] theorem thm1' : 0 < 1 := by decide
[Elab.command] [0.133223] theorem thm2 : ∀ x < 400, x * x ≤ 160000 := by decide!
[Elab.command] [0.252310] theorem thm2' : ∀ x < 400, x * x ≤ 160000 := by decide
-/
```

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-10-11 06:40:57 +00:00
Kyle Miller
8e88e8061a chore: deprecate := variants of inductive and structure (#5542)
Deprecates `inductive ... :=`, `structure ... :=`, and `class ... :=` in
favor of the `... where` variant. Currently this syntax produces a
warning, controlled by the `linter.deprecated` option.

Breaking change: modifies `Lean.Linter.logLintIf` to use
`Lean.Linter.getLinterValue` to determine if a linter value is set. This
means that the `linter.all` option now is taken into account when the
linter option is not set.

Part of #5236
2024-10-11 05:54:18 +00:00
Henrik Böving
96e996e16d feat: ~~~(-x) bv_decide (#5670)
Co-authored-by: Siddharth <siddu.druid@gmail.com>
2024-10-10 19:44:31 +00:00
Kyle Miller
4614b758e1 fix: make @[elab_as_elim] require at least one discriminant (#5671)
This is an oversight in `getElabElimExprInfo`. If there are no
discriminants, then there is no point in elaborating as an eliminator.
2024-10-10 17:20:35 +00:00
Marc Huisinga
3930100b67 feat: whitespace tactic completion & tactic completion docs (#5666)
This PR enables tactic completion in the whitespace of a tactic proof
and adds tactic docstrings to the completion menu.

Future work:
- A couple of broken tactic completions: This is due to tactic
completion now using @david-christiansen's `Tactic.Doc.allTacticDocs` to
obtain the tactic docstrings and should be fixed soon.
- Whitespace tactic completion in tactic combinators: This requires
changing the syntax of tactic combinators to produce a syntax node that
makes it clear that a tactic is expected at the given position.

Closes #1651.
2024-10-10 13:28:34 +00:00
Kyle Miller
d10d41bc07 fix: store local context for 'don't know how to synthesize implicit argument' errors (#5658)
When named arguments introduce eta arguments, the full application
contains fvars for these eta arguments, so `MVarErrorKind.implicitArg`
needs to keep a local context for its error messages. This is because
the local context of the mvar associated to the `MVarErrorKind` is not
sufficient, since when an eta argument come after an implicit argument,
the implicit argument's mvar doesn't contain the eta argument's fvar in
its local context.

Closes #5475
2024-10-09 08:40:21 +00:00
Kyle Miller
79930af11e feat: allow explicit mode with field notation (#5528)
Now one can write `@x.f`, `@(x).f`, `@x.1`, `@(x).1`, and so on.

This fixes an issue where structure instance update notation (like `{x
with a := a'}`) could fail if the field `a` had a type with implicit,
optional, or auto parameters.

Closes #5406
2024-10-09 07:03:46 +00:00
Eric Wieser
b814be6d6a fix: use MessageData.tagged to mark maxHeartbeat exceptions (#5566)
Fixes #5565, by using tags instead of trying to string match on a
`MessageData`. This ends up reverting some unwanted test output changes
from #4781 too.

This changes `isMaxRecDepth` for good measure too.

This was a regression in Lean 4.11.0, so may be worth backporting to
4.12.x, if not also 4.11.x.
2024-10-09 02:08:50 +00:00
Kyle Miller
feb8185a83 fix: upgrade instance synth order issues to hard errors (#5399)
Motivated [by a user's
question](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Confusing.20instance.20error/near/471539940),
this increases the severity of the "cannot find synthesization order"
message from a log error to throwing an exception. This saves some
confusion about whether the instance was added or not.
2024-10-08 23:29:59 +00:00
Mac Malone
7942b9eaae fix: lake: make package extraDep intransitive (#5641)
A Lake build of target within a a package will no longer build a
package's dependencies package-level extra targets dependencies. At the
technical level, a package's `extraDep` facet no longer transitively
builds its dependencies' `extraDep` facet.

Closes #5633.
2024-10-08 23:20:05 +00:00
Kyle Miller
15bb8a26d5 fix: have simpa ... using ... do exact-like checks (#5648)
Closes #5634. Before assigning the simplified `using` clause expression
to the goal, this adds a check that the expression has no new
metavariables. It also adjusts how new hypotheses are added to the goal
to prevent spurious "don't know how to synthesize placeholder" errors on
that goal metavariable. We also throw in an occurs check immediately
after elaboration to avoid some counterintuitive behavior when
simplifying such a term closes the goal.

Closes #4101. This also improves the type mismatch error message,
showing the elaborated `using` clause rather than `h✝`:
```lean
example : False := by
  simpa using (fun x : True => x)
/-
error: type mismatch, term
  fun x => x
after simplification has type
  True : Prop
but is expected to have type
  False : Prop
-/
```
2024-10-08 23:09:00 +00:00
Kyle Miller
a35e6f4af7 feat: infer Prop for inductive/structure when defining syntactic subsingletons (#5517)
A `Prop`-valued inductive type is a syntactic subsingleton if it has at
most one constructor and all the arguments to the constructor are in
`Prop`. Such types have large elimination, so they could be defined in
`Type` or `Prop` without any trouble, though users tend to expect that
such types define a `Prop` and need to learn to insert `: Prop`.

Currently, the default universe for types is `Type`. This PR adds a
heuristic: if a type is a syntactic subsingleton with exactly one
constructor, and the constructor has at least one parameter, then the
`inductive` command will prefer creating a `Prop` instead of a `Type`.
For `structure`, we ask for at least one field.

More generally, for mutual inductives, each type needs to be a syntactic
subsingleton, at least one type must have one constructor, and at least
one constructor must have at least one parameter. The motivation for
this restriction is that every inductive type starts with a zero
constructors and each constructor starts with zero fields, and
stubbed-out types shouldn't be `Prop`.

Thanks to @arthur-adjedj for the investigation in #2695 and to @digama0
for formulating the heuristic.

Closes #2690
2024-10-08 22:39:38 +00:00
Kyle Miller
fdd5aec172 feat: better #eval command (#5627)
This refactors and improves the `#eval` command, introducing some new
features.
* Now evaluated results can be represented using `ToExpr` and pretty
printing. This means **hoverable output**. If `ToExpr` fails, it then
tries `Repr` and then `ToString`. The `eval.pp` option controls whether
or not to try `ToExpr`.
* There is now **auto-derivation** of `Repr` instances, enabled with the
`pp.derive.repr` option (default to **true**). For example:
  ```lean
  inductive Baz
    | a | b

  #eval Baz.a
  -- Baz.a
  ```
It simply does `deriving instance Repr for Baz` when there's no way to
represent `Baz`. If core Lean gets `ToExpr` derive handlers, they could
be used here as well.
* The option `eval.type` controls whether or not to include the type in
the output. For now the default is false.
* Now things like `#eval do return 2` work. It tries using
`CommandElabM`, `TermElabM`, or `IO` when the monad is unknown.
* Now there is no longer `Lean.Eval` or `Lean.MetaEval`. These each used
to be responsible for both adapting monads and printing results. The
concerns have been split into two. (1) The `MonadEval` class is
responsible for adapting monads for evaluation (it is similar to
`MonadLift`, but instances are allowed to use default data when
initializing state) and (2) finding a way to represent results is
handled separately.
* Error messages about failed instance synthesis are now more precise.
Once it detects that a `MonadEval` class applies, then the error message
will be specific about missing `ToExpr`/`Repr`/`ToString` instances.
* Fixes a bug where `Repr`/`ToString` instances can't be found by
unfolding types "under the monad". For example, this works now:
  ```lean
  def Foo := List Nat
  def Foo.mk (l : List Nat) : Foo := l
  #eval show Lean.CoreM Foo from do return Foo.mk [1,2,3]
  ```
* Elaboration errors now abort evaluation. This eliminates some
not-so-relevant error messages.
* Now evaluating a value of type `m Unit` never prints a blank message.
* Fixes bugs where evaluating `MetaM` and `CoreM` wouldn't collect log
messages.

The `run_cmd`, `run_elab`, and `run_meta` commands are now frontends for
`#eval`.
2024-10-08 20:51:46 +00:00
Henrik Böving
81743d80e5 chore: reduce error on bv_check to warning (#5655) 2024-10-08 19:49:44 +00:00
Henrik Böving
248864c716 perf: benchmark for modulo on bv_decide (#5653)
This verifies a bit hack from here:
https://en.wikipedia.org/wiki/Lehmer_random_number_generator#Sample_C99_code

I previously ran the SMTLIB equivalent this with Bitwuzla in my crypto
class and got the following numbers:
- 22s with Bitwuzla
- Z3 and CVC5 don't yet terminate after > 2min

Now with`bv_decide` the overall timing is 33.7s, consisting of:
- 5s of checking the LRAT cert
- 5s of trimming the LRAT cert from 800k to 300k proof steps
- remainder actual solving time

So running `bv_decide` like a normal SMT solver without verifying the
result of the SAT solver would yield approximately ~24s.
2024-10-08 18:58:15 +00:00
Kyle Miller
bd46319aee feat: add option pp.mvars.delayed (#5643)
Where before we had
```lean
#check fun x : Nat => ?a
-- fun x ↦ ?m.7 x : (x : Nat) → ?m.6 x
```
Now by default we have
```lean
#check fun x : Nat => ?a
-- fun x => ?a : (x : Nat) → ?m.6 x
```
In particular, delayed assignment metavariables such as `?m.7` pretty
print using the name of the metavariable they are delayed assigned to,
suppressing the bound variables used in the delayed assignment (hence
`?a` rather than `?a x`). Hovering over `?a` shows `?m.7 x`.

The benefit is that users can see the user-provided name in local
contexts. A justification for this pretty printing choice is that `?m.7
x` is supposed to stand for `?a`, and furthermore it is just as opaque
to assignment in defeq as `?a` is (however, when synthetic opaque
metavariables are made assignable, delayed assignments can be a little
less assignable than true synthetic opaque metavariables).

The original pretty printing behavior can be recovered using `set_option
pp.mvars.delayed true`.

This PR also extends the documentation for holes and synthetic holes,
with some technical details about what delayed assignments are. This
likely should be moved to the reference manual, but for now it is
included in this docstring.

(This PR is a simplified version of #3494, which has a round-trippable
notation for delayed assignments. The pretty printing in this PR is
unlikely to round trip, but it is better than the current situation,
which is that delayed assignment metavariables never round trip, and
plus it does not require introducing a new notation.)
2024-10-08 17:48:52 +00:00
Kyle Miller
6cdede33fb fix: make sure name literals use escaping when pretty printing (#5639)
The app unexpanders for `Name.mkStr1` through `Name.mkStr8` weren't
respecting the escaping rules for names. For example, ``#check `«a.b»``
would show `` `a.b``.

This PR folds the unexpanders into the name literal delaborator, where
escaping is already handled.
2024-10-08 17:36:49 +00:00
Kyle Miller
f1d3527fe8 fix: have Lean.Meta.ppGoal use hard newlines (#5640)
This function uses soft newlines in many places where hard newlines are
more appropriate. Pointed out by @gebner in #1967.
2024-10-08 17:36:08 +00:00
Kyle Miller
b2b450d7cb fix: now linters in general do not run on #guard_msgs itself (#5644)
The `#guard_msgs` command runs the command it is attached to as if it
were a top-level command. This is because the top-level command
elaborator runs linters, and we are interested in capturing linter
warnings using `#guard_msgs`. However, the linters will run on
`#guard_msgs` itself, leading sometimes to duplicate warnings (like for
the unused variable linter).

Rather than special-casing `#guard_msgs` in every affected linter, this
PR special-cases it in the top-level command elaborator itself. **Now
linters are only run if the command doesn't contain `#guard_msgs`.**
This way, the linters are only run on the sub-command that `#guard_msgs`
runs itself. This rule also keeps linters from running multiple times in
cases such as `set_option pp.mvars false in /-- ... -/ #guard_msgs in
...`.
2024-10-08 17:35:07 +00:00
Henrik Böving
abae95e170 feat: support umod in bv_decide (#5652) 2024-10-08 12:47:03 +00:00
Henrik Böving
e9ea99f6c6 feat: support udiv in bv_decide (#5628)
Co-authored-by: Siddharth <siddu.druid@gmail.com>
2024-10-08 10:40:00 +00:00
Siddharth
2ed7924bae chore: define udiv normal form to be /, resp. umod and % (#5645)
This follows the norm for all other Bitvector operations, and makes the
symbols `/` and `%` the simp normal form.

I'd imagine that @hargonix would prefer that this be merged after
https://github.com/leanprover/lean4/pull/5628, so as to prevent churn
for his PR. I'm happy to rebase the PR once the other PR lands.

---------

Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-10-08 08:49:46 +00:00
Siddharth
4415a81f35 chore: add Siddharth to authors list of BitVec (#5647)
Add @bollu to the authors list of the BitVec files :)
2024-10-08 08:01:17 +00:00
Joachim Breitner
3e75d8f742 fix: FunInd: avoid over-eta-expanding in preprocessing step (#5619)
fixes #5602
2024-10-07 19:47:43 +00:00
Henrik Böving
f1ff9cebf2 feat: more getLsbD bitblaster theory (#5637) 2024-10-07 17:26:23 +00:00
Henrik Böving
99a9d9b381 doc: remarks about multiplication (#5636) 2024-10-07 17:25:22 +00:00
Henrik Böving
1914a2b3f2 feat: add auxiliary bitblasters for negation and subtraction (#5635) 2024-10-07 16:33:06 +00:00
Siddharth
6312787c30 feat: lemmas for Bitvector division when denominator is zero (#5609)
These lemmas explain what happens when the denominator is zero with
`udiv`, `umod`, `sdiv`, `smod`. A follow-up PR will show what happens
with `smtUDiv` and `smtSMod`, since these need some more bitvector
theory.
These lemmas will be used by `bv_decide` for bitblasting.

The theorems `{sdiv, smod}_zero` are located after `neg` theory has been
built for the purpose of writing terse proofs.

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-10-07 15:58:12 +00:00
Marc Huisinga
ec5f206d80 fix: shutdown deadlock and crash desync (#5340)
This PR fixes three problems:
- When the language server is being stopped in a non-normal way without
going through the regular LSP shutdown protocol (e.g. by closing VS
Code), it could sometimes happen that both the watchdog and the file
worker were not properly terminated and lingered around forever,
resulting in zombie processes (#5296)
- When the file worker crashes and the user restarts it by making a
change to the document, the file worker would produce incorrect
diagnostics for the document until the file is restarted.
- (Minor) When the file worker would crash during initialization, the
error diagnostic would be reported on stderr instead of stdout

The deadlock-induced termination issue from #5296 should be resolved by
the following measures:
- The watchdog main task is always terminated with `IO.Process.exit` to
ensure that it terminates even if some other tasks in the process are
still running.
- The file worker communication task in the watchdog no longer waits for
the file worker process to terminate when writing to the client fails,
only when reading from the file worker fails.
- When the watchdog shuts down (either as a result of an orderly or a
non-normal shutdown), instead of waiting for the file worker
communication tasks to complete, it kills the file worker process. The
rationale behind this is that the file worker currently should have no
essential work to complete if the server is being stopped anyways, and
so waiting for the communication task is not necessary.

The file worker diagnostic desync after a crash was caused by us
tracking changes to the document of a crashed file worker twice: Once as
part of the document, and once as part of the queued messages to the
file worker. This meant that when the file worker was restarted, it
would receive the changes made to the document while the file worker was
crashed twice, leading to a desynced document state.

(Probably) fixes #5296.
2024-10-07 14:10:42 +00:00
Markus Himmel
d835616573 chore: fix MSYS2 build instructions (#5617) 2024-10-07 12:42:37 +00:00
Siddharth
9dac514c2f feat: Document Bitblasting in a documentation comment (#5620)
As requested by @kim-em at
https://github.com/leanprover/lean4/pull/5281#issuecomment-2376102963.
We provide a high-level overview of the workflow for adding new
bitblasting theorems, by using the `BitVec.mul` as a prototypical
example.
2024-10-07 11:44:04 +00:00
Tobias Grosser
c0617da18d feat: support at in ac_nf and use it in bv_normalize (#5618)
... while at it also call `trivial` to close goals that can be trivially
closed.

---------

Co-authored-by: Siddharth <siddu.druid@gmail.com>
Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-10-07 11:37:17 +00:00
Sebastian Ullrich
a3ee11103c chore: update stage0 2024-10-07 13:26:07 +02:00
Sebastian Ullrich
13e3a3839c fix: Lake: brittle dependency on env ext name 2024-10-07 13:26:07 +02:00
Lean stage0 autoupdater
0178f2b70d chore: update stage0 2024-10-04 15:25:08 +00:00
Lean stage0 autoupdater
4f5f39294d chore: update stage0 2024-10-04 13:55:42 +00:00
Joachim Breitner
d4fdb5d7c0 fix: getFunInfo, inferType to use withAtLeastTransparency, not withTransparency (#5563)
when the transparency mode is `.all`, then one expects `getFunInfo` and
`inferType` to also work with that transparency mode.

Fixes #5562
Fixes #2975 
Fixes #2194
2024-10-04 13:04:35 +00:00
Siddharth
f9048c132d chore: add bv_toNat tag for toNat_ofInt (#5608)
These were missing from the `bv_toNat` simp-set,
discovered when refactoring LNSym's simp-set:
https://github.com/leanprover/LNSym/pull/208
2024-10-03 19:20:50 +00:00
Henrik Böving
53c5470200 perf: remove List.redLength (#5605) 2024-10-03 14:57:33 +00:00
Sebastian Ullrich
3584a62411 fix: call hierarchy into (builtin_)initialize (#5560)
While `initialize` pretended it had the declaration name of the constant
to be initialized, missing declaration ranges for the latter led call
hierarchy etc. to ignore the definition
2024-10-03 12:03:44 +00:00
Kim Morrison
a4fda010f3 feat: Array/Option.unattach (#5586)
More support for automatically removing `.attach`, for `Array` and
`Option`.
2024-10-03 07:29:00 +00:00
Kim Morrison
b7d6a4b222 feat: adding Insert/Singleton/Union instances for HashMap/Set.Raw (#5590)
These were missing from https://github.com/leanprover/lean4/pull/5581.
2024-10-03 06:26:21 +00:00
Lean stage0 autoupdater
341c64a306 chore: update stage0 2024-10-03 06:56:06 +00:00
Mac Malone
a01166f045 refactor: reduce Reservoir build fetch attempts & warnings (#5600)
Lake no longer attempts to fetch the Reservoir build cache if the build
directory is already present. Plus, failure of the automatic fetch now
only produces a trace message, not a warning.
2024-10-03 01:12:53 +00:00
Kim Morrison
14f80172bc chore: typo in fix-pr-release.yml (#5601) 2024-10-02 23:04:39 +00:00
euprunin
8f88d94d97 chore: fix spelling mistakes (#5599)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-10-02 21:32:22 +00:00
Markus Himmel
09dfe1c71c chore: induction-friendly List.min?_cons (#5594)
@kim-em, I'm happy to keep any subset of `foldl_min`, `foldl_min_right`,
`foldl_min_le`, `foldl_min_min_of_le` (should that one have been called
`foldl_min_le_of_le`?). Which ones do you like?
2024-10-02 14:10:15 +00:00
Kim Morrison
1b115eea42 feat: HashSet.Raw.all/any (#5591)
These were missing from #5582.
2024-10-02 06:04:59 +00:00
Kim Morrison
8da278e141 feat: variant of MVarId.tryClearMany (#5588)
Used in Aesop.
2024-10-02 05:26:40 +00:00
Kim Morrison
6a59a3a373 feat: allow MVarId.assertHypotheses to set BinderInfo/Kind (#5587)
This generalization of `assertHypotheses` is currently provided in
Batteries and used in Aesop.
2024-10-02 05:09:49 +00:00
Kim Morrison
1329a264c8 feat: HashSet.all/any (#5582)
I think the overhead (runtime/later proving) of using `for` is paid off
by being able to short-circuit.

These functions are needed downstream to switch over the Std.HashSet.
2024-10-02 04:23:27 +00:00
Kim Morrison
478a34f174 feat: Singleton/Insert/Union instances for HashMap/Set (#5581) 2024-10-02 04:23:17 +00:00
Mac Malone
952c086a92 fix: rm new shared libs before build for Windows (#5541)
On Windows, shared libraries must be removed before linking. Otherwise,
linking can fail with "Permission denied" when the libraries are in use.
This ensures such removal is done for the new `libLake_shared.dll` and
both parts of `libleanshared`.
2024-10-02 04:06:03 +00:00
Kim Morrison
9322d8d639 feat: List.unattach and simp lemmas (#5550)
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-10-02 02:42:54 +00:00
Mac Malone
9dcd2ad2a3 fix: --no-cache on server DependencyBuildMode.never (#5583)
Have the server disable Lake build cache fetches (via `--no-cache`) on
time-sensitive file opens (i.e.,, `DependencyBuildMode.never`).
2024-10-02 02:22:40 +00:00
Kim Morrison
e3811fd838 chore: cleanup unused variables (#5579)
This pulls changes to the standard library out of #5338.
2024-10-02 01:51:22 +00:00
Kim Morrison
867e67b9f3 chore: cleanup unused variables in bv_decide (#5578)
This pulls the changes to `bv_decide` out of #5338.
2024-10-02 01:48:43 +00:00
Kim Morrison
6cd80c28b7 chore: add missing simp to Array.size_feraseIdx (#5577) 2024-10-02 01:07:54 +00:00
Kim Morrison
f202469c8a chore: upstream Array.flatten lemmas (#5551)
Just the upstreaming part of #5535 while we wait on a naming decision.
2024-10-02 00:54:30 +00:00
Joachim Breitner
e417a2331c feat: expose Kernel.check for debugging purposes (#5412)
along `Kernel.isDefEq` and `Kernel.whnf`.
2024-10-01 21:28:02 +00:00
Mac Malone
5eb6c67a78 feat: lake: selective build cache fetch & display (#5572)
Lake no longer attempts to fetch Reservoir build caches (barrels) for
non-Reservoir dependencies, and it will only fetch them for Reservoir
dependencies in the presence of a known toolchain.

Also, optional build job failures are now only displayed in verbose
mode.
2024-10-01 21:18:08 +00:00
Henrik Böving
499c58796b feat: get bv_normalize up to date with the current BitVec rewrites (#5573) 2024-10-01 16:58:42 +00:00
Henrik Böving
863e9c073b feat: generalize the bv_normalize pipeline to support more general preprocessing passes (#5568)
Beyond what's in the title this also fixes: #5543
2024-10-01 15:28:39 +00:00
Joachim Breitner
60096e7d15 refactor: more idiomatic syntax for if h: (#5567)
https://github.com/leanprover/lean4/pull/5552 introduced a fair number
of `if h:`, but the slightly preferred style is `if h :`, with a space,
so here goes a quick `sed`.
2024-10-01 15:23:54 +00:00
Eric Wieser
e90c3cf15a fix: remove non-conforming size-0 arrays (#5564)
In C, these are supported only as a vendor extension; they should
instead use proper C99 flexible array members.

In C++, both `[]` and `[0]` are vendor extensions.

Co-authored-by: Thomas Köppe <tkoeppe@google.com>
2024-10-01 15:05:17 +00:00
Andrii Kurdiumov
d4195c2605 fix: make lean.h compile with MSVC (#5558)
Closes #5557
2024-10-01 13:49:22 +00:00
Joachim Breitner
4932dbc65d refactor: dead code AttributeExtensionOLeanEntry.decl (#5496)
The constructor `AttributeExtensionOLeanEntry.decl` and related code
seems to be unused, and has been unused since its introduction in
a77598f7cf three years ago. Probably worth
removing (and changing the now one-constructor inductive into a
structure).
2024-10-01 13:34:12 +00:00
Joachim Breitner
d0ee9d0127 feat: expand invalid projection type inference error (#5556)
hopefully this will make debugging meta code a bit easier
2024-10-01 13:09:08 +00:00
Luisa Cicolini
3e2bca7309 feat: add Bitvec.[add, sub, mul]_eq_xor and width_one_cases (#5554)
Co-authored-by: Tobias Grosser <github@grosser.es>
2024-10-01 11:57:14 +00:00
TomasPuverle
ddec5336e5 chore: switch obvious cases of array "bang"[]! indexing to rely on hypothesis (#5552)
Update certain uses of `arr[i]!` to use the "provably correct" version
`arr[i]`, in order to use "best practices".

Some motivation and discussion on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Lean.20compiler.2Felaborator.20development.20question/near/472934715)
2024-10-01 11:12:22 +00:00
Tobias Grosser
37baa89d9b feat: add ac_nf and test [ac_nf|ac_rfl] for BitVec (#5524)
ac_nf is a counterpart to ac_rfl, which normalizes bitvector expressions
with respect to associativity and commutativity.

While there, also add test coverage for ac_rfl and ac_nf for BitVec,
complementing the existing test coverage.
2024-10-01 05:59:29 +00:00
Kyle Miller
949feb25a4 chore: move @[simp] from exists_prop' to exists_prop (#5529)
The lemma `exists_const` already handles all real cases of `(∃ _ : α, p)
↔ p` for general types `α`. If there are no `Nonempty` instances and
this lemma cannot apply, it seems unlikely that simp could make more
progress with `(∃ _ : α, p) ↔ Nonempty α ∧ p`.

However, it is still worth simplifying `(∃ _ : p, q)` to `p ∧ q`.

Also adds a `Nonempty (Decidable a)` instance, which is used by Mathlib.
2024-10-01 05:38:18 +00:00
Tobias Grosser
bfb73c4a5e feat: add BitVec.getElem_[add|add_add_bool|mul|rotateLeft|rotateRight… (#5508)
…|twoPow|one|replicate]

... and mark `getElem_setWidth` as `@[simp]`.

`getElem_rotateLeft` and `getElem_rotateRight` have a non-trivial rhs
but we follow `getLsbD_[rotateLeft|rotateRight]`for consistency.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-10-01 05:37:51 +00:00
Kyle Miller
b22dee8816 chore: release notes for 4.12.0 (#5549) 2024-10-01 04:07:28 +00:00
Mac Malone
4771741fa2 doc: update README w/ Reservoir package options (#5546)
Adds the new Reservoir-related package configuration options to Lake's
README.
2024-10-01 00:29:00 +00:00
Mac Malone
ffb4c5becf feat: lake: Reservoir build cache (#5486)
Adds Reservoir as another possible source of build caches in addition to
GitHub releases. If a GitHub release is not configured for a Reservoir
dependency, it will attempt download a build cache from Reservoir. Like
with GitHub releases, failure will not stop the build and instead issue
a warning. Many of the Lake API calls related to these build caches were
refactored and renamed, with the old names remaining around as
deprecated aliases.

Build cache downloads (from Reservoir or GitHub) can now be disabled via
the `--no-cache` CLI option or the `LAKE_NO_CACHE` environment variable.
A disabled cache can be re-enable with the `--try-cache` CLI option.
2024-09-30 23:59:36 +00:00
Kyle Miller
d3f7ed434b fix: automatic instance names about types with hygienic names should be hygienic (#5530)
Macros sometimes create auxiliary types and instances about them, and
they rely on the instance name generate to create unique names in that
case.

This modifies the automatic name generator to add a fresh macro scope to
the generated name if any of the constants in the type of the instance
themselves have macro scopes.

Closes #2044
2024-09-30 16:06:36 +00:00
Kim Morrison
6bd0d9d73b chore: fix explicitness of Option.mem_toList (#5539) 2024-09-30 09:55:19 +00:00
David Thrane Christiansen
db79d9e5ce doc: backticks around Lean code in docstrings (#5538)
Minor docstrings tweaks on the basis of #5497
2024-09-30 08:59:01 +00:00
Kim Morrison
5e8718dff9 chore: fix Array.modify lemmas (#5536)
Generally works best to pick up the proofs by unification with the lhs.

pinging @hargoniX as this goes by, as it changes some proofs in
bv_decide (nothing interesting, just a bit simpler)
2024-09-30 06:31:10 +00:00
Kim Morrison
4f2c4c7bd1 chore: cleanup of Array GetElem lemmas (#5534) 2024-09-30 05:42:53 +00:00
Kim Morrison
56ba39d68a chore: more monadic simp lemmas (#5522) 2024-09-30 04:47:49 +00:00
Kim Morrison
1fca66b8c9 feat: Option.attach (#5532) 2024-09-30 04:13:27 +00:00
Kim Morrison
36c29bee31 chore: fix name of Array.length_toList (#5526) 2024-09-30 04:08:56 +00:00
Kyle Miller
cf14178929 fix: default values for structure fields can be noncomputable (#5531)
Closes #2710
2024-09-30 04:02:24 +00:00
Kim Morrison
a4dfa83af5 chore: reduce use of deprecated lemmas in Array (#5527) 2024-09-30 02:59:15 +00:00
Kim Morrison
c5fd652765 feat: support Int.toNat in omega (#5523)
Trivial to add and works nicely.
2024-09-29 22:23:29 +00:00
Kim Morrison
4cd4bcc9be chore: List simp fixes (#5521) 2024-09-29 13:28:19 +00:00
Kim Morrison
7d26a1604f chore: restore @[simp] on List.getElem_mem et al (#5520) 2024-09-29 13:28:13 +00:00
Kim Morrison
3a46fd0fde chore: unsimp BitVec.divRec_succ' (#5505)
@bollu, it would be good to have confirmation from you, but presumably
this was not meant to be `@[simp]`? It competes with `divRec_succ`, and
has a terrible RHS.
2024-09-29 11:38:54 +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
Joachim Breitner
cf3e7de143 feat: let simp apply rules with higher-order patterns (#5479)
after this change, `simp` will be able to discharge side-goals that,
after simplification, are of the form `∀ …, a = b` with `a =?= b`.

Usually these side-goals are solved by simplification using `eq_self`,
but that does not work when there are metavariables involved.

This enables us to have rewrite rules like
```
theorem List.foldl_subtype (p : α → Prop) (l : List (Subtype p)) (f : β → Subtype p → β)
  (g : β → α → β) (b : β)
  (hf : ∀ b x h, f b ⟨x, h⟩ = g b x) :
  l.foldl f b = (l.map (·.val)).foldl g b := by
```    
where the parameter `g` does not appear on the lhs, but can be solved
for using the `hf` equation. See `tests/lean/run/simpHigherOrder.lean`
for more examples.

The motivating use-case is that `simp` should be able to clean up the
usual
```
  l.attach.map (fun <x, _> => x)
```
idiom often seen in well-founded recursive functions with nested
recursion.

Care needs to be taken with adding such rules to the default simp set if
the lhs is very general, and thus causes them to be tried everywhere.

Performance impact of just this PR (no additional simp rules) on mathlib
is unsuspicious:
http://speed.lean-fro.org/mathlib4/compare/b5bc44c7-e53c-4b6c-9184-bbfea54c4f80/to/ae1d769b-2ff2-4894-940c-042d5a698353

I tried a few alternatives, e.g. letting `simp` apply `eq_self` without
bumping the mvar depth, or just solve equalities directly, but that
broke too much things, and adding code to the default discharger seemed
simpler.
2024-09-29 07:26:48 +00:00
Kim Morrison
2ace579438 chore: upstream List.fold lemmas (#5519) 2024-09-29 07:21:32 +00:00
Kyle Miller
40d6a6def0 fix: use breakable instead of unbreakable whitespace when formatting tokens (#5513)
The formatter was using `tk ++ " "` to separate tokens from tokens they
would merge with, but `" "` is not whitespace that could merge. This
affected large binder lists, which wouldn't pretty print with any line
breaks. Now they can be flowed across multiple lines.

Closes #5424
2024-09-29 06:33:39 +00:00
Kim Morrison
d96b7a7d98 chore: rename List.maximum? to max? (#5518)
More consistent with other API.
2024-09-29 06:23:24 +00:00
Kim Morrison
40e97bd566 chore: upstream Subarray.empty (#5516) 2024-09-29 05:53:12 +00:00
Kim Morrison
3bd01de384 feat: upstream Array.qsortOrd (#5515) 2024-09-29 05:50:25 +00:00
Kim Morrison
8835ab46ad feat: Array.eraseReps (#5514)
Just an `Array` version of `List.eraseReps`. These functions are for now
outside of scope for verification, so there's just a simple `example` in
the tests.
2024-09-29 05:44:14 +00:00
Kyle Miller
96adf04a62 fix: reduce parents in structure command (#5511)
Makes it possible to `extend` another structure through an abbreviation.
Also inserts a `withSynthesize` checkpoint for parents.

Closes #5417
2024-09-29 02:15:07 +00:00
Kyle Miller
0db6daa8f1 feat: actual implementation for #5283 (#5512)
I did a bad git rebase before merging #5283, which reverted it to an
earlier version. This PR has the actual implementation of RFC #5397.
2024-09-29 01:22:12 +00:00
Kyle Miller
130b465aaf feat: generalize elab_as_elim to allow arbitrary motive applications (#5510)
Now the elab-as-elim procedure allows eliminators whose result is an
arbitrary application of the motive. For example, the following is now
accepted. It will generalize `Int.natAbs _` from the expected type.
```lean
@[elab_as_elim]
theorem natAbs_elim {motive : Nat → Prop} (i : Int)
  (hpos : ∀ (n : Nat), i = n → motive n)
  (hneg : ∀ (n : Nat), i = -↑n → motive n) :
  motive (Int.natAbs i) := by sorry
```

This change simplifies the elaborator, since it no longer needs to keep
track of discriminants (which can easily be read off from the return
type of the eliminator) or the difference between "targets" and "extra
arguments" (which are now both "major arguments" that should be eagerly
elaborated).

Closes #4086
2024-09-28 22:30:14 +00:00
Lean stage0 autoupdater
ccdf07b6a1 chore: update stage0 2024-09-28 14:05:01 +00:00
Tobias Grosser
5605e0198a chore: BitVec.Lemmas - drop non-terminal simps (#5499)
`BitVec.Lemmas` contained a couple of non-terminal simps. We turn
non-terminal `simp$`, `simp [`, and `simp at` expressions into `simp
only` to improve code maintainability.
2024-09-28 10:23:28 +00:00
Henrik Böving
5f22ba7789 feat: bv_normalize handle -> False (#5507) 2024-09-28 10:05:16 +00:00
Henrik Böving
16a16898d5 feat: improve bv_normalize rules for Prop and == (#5506) 2024-09-28 09:21:48 +00:00
Mac Malone
4ea76aadd1 refactor: lake: switch new/init default to TOML (#5504)
Changes the default configuration for new Lake packages to TOML.

Closes #4106.
2024-09-28 06:28:50 +00:00
Kim Morrison
ef71f0beab chore: restore @[simp] to upstreamed Nat.lt_off_iff (#5503)
This was upstreamed from Mathlib in #5478, but leaving off the `@[simp]`
attribute, thereby breaking Mathlib. (We could of course add the simp
attribute back in Mathlib, but wherever it lives it should have been in
place at the time we merged -- this way I have to add it temporarily in
Mathlib and then remove it again once it is redundant.)
2024-09-28 04:55:15 +00:00
Kyle Miller
9f4075be72 fix: refine how named arguments suppress explicit arguments (#5283)
Recall that currently named arguments suppress all explicit parameters
that are dependencies. This PR limits this feature to only apply to true
structure projections, except in the case where it is triggered when
there are no more positional arguments. This preserves the primary
reason for generalizing this feature (issue #1851), while removing the
generalized feature, which has led to numerous confusions (issue #1867).
This also fixes a bug pointed out [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.40foo.20.28A.20.3A.3D.20bar.29.20_.20_/near/468564862)
where in `@` mode, instance implicit parameter dependencies to named
arguments would be suppressed unless the next positional argument was
`_`.

More detail:
* The `NamedArg` structure now has a `suppressDeps : Bool` field. It is
set to `true` for the `self` argument in structure projections. If there
is such a `NamedArg`, explicit parameters that are dependencies to the
named argument are turned into implicit arguments. The consequence is
that *all* structure projections are treated as if their type parameters
are implicit, even for class projections. This flag is *not* used for
generalized field notation.
* We preserve the suppression feature when there are no positional
arguments remaining. This feature pre-dates the fix to issue #1851, and
it is useful when combining named arguments and the eta expansion
feature, since dependencies of named arguments cannot be turned into eta
arguments. Plus, there are examples of the form `rw [lem (h := foo)]`
where `lem` has explicit arguments that `h` depends on.
* For instance implicit parameters in explicit mode, now `_` arguments
register terminfo and are hoverable.
* Now `..` is respected in explicit mode.

This implements RFC #5397. The `suppressDeps` flag suggests a future
possibility of a named argument syntax that can suppress dependencies.
2024-09-27 20:14:29 +00:00
Kyle Miller
1b6572726f feat: have autoparams report parameter/field on failure (#5474)
Adds a mechanism where when an autoparam tactic fails to synthesize a
parameter, the associated parameter name or field name for the autoparam
is reported in an error.

Examples:
```text
could not synthesize default value for parameter 'h' using tactics

could not synthesize default value for field 'inv' of 'S' using tactics
```

Notes:
* Autoparams now run their tactics without any error recovery or
error-to-sorry enabled. This enables catching the error and reporting
the contextual information. This is justified on the grounds that
autoparams are not interactive.
* Autoparams for applications now cleanup the autoParam annotation,
bringing it in line with autoparams for structure fields.
* This preserves the old behavior that autoparams leave terminfo, but we
will revisit this after some imminent improvements to the unused
variable linter.

Closes #2950
2024-09-27 19:00:59 +00:00
Joachim Breitner
56b78a0ed1 chore: pr-release.yml: fix bot’s username to look for (#5495)
This didn’t make it in with #5490, but seems to be needed, just as in
https://github.com/leanprover-community/mathlib4/pull/17182/files (the
code is duplicated in both repos, and should be the same).
2024-09-27 15:29:53 +00:00
Sebastian Ullrich
e28bfedae2 doc: remove inaccurate PersistentEnvExtension.setState/modifyState claim
Likely a copy-paste mistake

Fixes #3039
2024-09-27 15:59:36 +02:00
Sebastian Ullrich
e7691f37c6 fix: induction pre-tactic should be indented (#5494)
Fixes #2876
2024-09-27 12:43:42 +00:00
Luisa Cicolini
48711ce6eb feat: BitVec.(not_sshiftRight, not_sshiftRight_not, getMsb_not, msb_not) (#5492) 2024-09-27 10:36:17 +00:00
Tobias Grosser
0733273a78 feat: add BitVec.toNat_[abs|sdiv|smod] (#5491)
Co-authored-by: Luisa Cicolini <48860705+luisacicolini@users.noreply.github.com>
2024-09-27 10:35:41 +00:00
Henrik Böving
2221296d3c chore: delete unused code (#5493) 2024-09-27 09:36:56 +00:00
Eric Wieser
f22998edfe fix: collect level parameters in evalExpr (#3090)
`elabEvalUnsafe` already does something similar: it also instantiates
universe metavariables, but it is not clear to me whether that is
sensible here.
To be conservative, I leave it out of this PR.

See https://github.com/leanprover/lean4/pull/3090#discussion_r1432007590
for a comparison between `#eval` and `Meta.evalExpr`. This PR is not
trying to fully align them, but just to fix one particular misalignment
that I am impacted by.

Closes #3091
2024-09-27 11:55:33 +02:00
Kim Morrison
3817b16c35 chore: use separate secrets for commenting and branching in pr-release.yml (#5490)
Hopefully this will resolve the problem of duplicated comments when the
bots post about Mathlib CI status.
2024-09-27 07:27:55 +00:00
Kim Morrison
9eef726204 chore: commit lake-manifest.json when updating lean-pr-testing branches (#5489) 2024-09-27 06:52:24 +00:00
Siddharth
9460f79d28 feat: add sdiv_eq, smod_eq to allow sdiv/smod bitblasting (#5487)
We add lemmas to reduce `sdiv` to `udiv` and `smod` to `umod`, along
with `msb` comparisons which `bv_decide` understands.

We use the same implementation as Bitwuzla, as evidenced by the
following rewrite rules:
[sdiv](f229d64be7/src/rewrite/rewrites_bv.cpp (L3168C30-L3168C42)),
[smod](f229d64be7/src/rewrite/rewrites_bv.cpp (L3282C30-L3282C39)).
2024-09-27 04:46:00 +00:00
Kim Morrison
c38c07e1a1 chore: reverse simp direction for toArray_concat (#5485)
This is mistakenly pushing a `toArray` inwards rather than outwards.
2024-09-27 01:24:12 +00:00
Siddharth
062ecb5eae feat: add udiv/umod bitblasting for bv_decide (#5281)
This PR adds the theorems

```
@[simp]
theorem divRec_zero (qr : DivModState w) :
  divRec w w 0 n d qr  = qr

@[simp]
theorem divRec_succ' (wn : Nat) (qr : DivModState w) :
    divRec w wr (wn + 1) n d qr =
    let r' := shiftConcat qr.r (n.getLsbD wn)
    let input : DivModState w :=
      if r' < d then ⟨qr.q.shiftConcat false, r'⟩ else ⟨qr.q.shiftConcat true, r' - d⟩
    divRec w (wr + 1) wn n d input
```

The final statements may need some masasging to interoperate with
`bv_decide`. We prove the recurrence for unsigned division by building a
shift-subtract circuit, and then showing that this circuit obeys the
division algorithm's invariant.

--- 

A `DivModState` is lawful if the remainder width `wr` plus the dividend
width `wn` equals `w`,
and the bitvectors `r` and `n` have values in the bounds given by
bitwidths `wr`, resp. `wn`.
This is a proof engineering choice: An alternative world could have
`r : BitVec wr` and `n : BitVec wn`, but this required much more
dependent typing coercions.
Instead, we choose to declare all involved bitvectors as length `w`, and
then prove that
the values are within their respective bounds.

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Kim Morrison <scott@tqft.net>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-09-26 23:45:31 +00:00
Henrik Böving
13969ad667 fix: handling BitVec.ofNat with Nat fvars in bv_decide (#5484) 2024-09-26 21:38:18 +00:00
Alex Keizer
91a033488c chore: remove mention of Lean.withSeconds (#5481)
There's a comment on `withHeartbeats` that says "See also
Lean.withSeconds", but his definition does not seem to actually exist.
Hence, I've removed the comment.
2024-09-26 18:15:58 +00:00
Luisa Cicolini
1fb75b68ab feat: add BitVec.(shiftLeft_add_distrib, shiftLeft_ushiftRight) (#5478)
Moved some Nat theorems from Mathlib

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-09-26 15:51:13 +00:00
Joachim Breitner
26f508db87 test: check that recusive functions do not apply attriubutes twices (#5480)
I suspected a bug based on reading the code, but it seems there is no
bug.
2024-09-26 10:30:37 +00:00
Daniel Weber
3d1ac7cfa2 feat: add lemmas about List.IsPrefix (#5448)
Add iff version of `List.IsPrefix.getElem`, and `eq_of_length_le`
variants of `List.IsInfix.eq_of_length, List.IsPrefix.eq_of_length,
List.IsSuffix.eq_of_length`
2024-09-26 06:58:40 +00:00
Johan Commelin
0196bca784 doc: fix typo in docstring of computeSynthOrder (#5398) 2024-09-26 04:51:23 +00:00
L
b320dcfef9 doc: fix typo in BitVec.mul docstring (#5473)
Seems this was copy-pasted from `BitVec.neg`
2024-09-26 03:11:46 +00:00
Kim Morrison
5dea30f169 feat: @[simp] lemmas about List.toArray (#5472)
We make sure that we can pull `List.toArray` out through all operations
(well, for now "most" rather than "all"). As we also push `Array.toList`
inwards, this hopefully has the effect of them cancelling as they meet,
and `simp` naturally rewriting Array operations into List operations
wherever possible.

This is not at all complete yet.
2024-09-26 00:59:13 +00:00
Kim Morrison
90cb6e5da8 chore: fix typos in Lean.MetavarContext (#5476) 2024-09-26 00:25:03 +00:00
Joachim Breitner
a3ca15d2b2 refactor: back rfl tactic primarily via apply_rfl (#3718)
building upon #3714, this (almost) implements the second half of #3302.

The main effect is that we now get a better error message when `rfl`
fails. For
```lean
example : n+1+m = n + (1+m) := by rfl
```
instead of the wall of text
```
The rfl tactic failed. Possible reasons:
- The goal is not a reflexive relation (neither `=` nor a relation with a @[refl] lemma).
- The arguments of the relation are not equal.
Try using the reflexivity lemma for your relation explicitly, e.g. `exact Eq.refl _` or
`exact HEq.rfl` etc.
n m : Nat
⊢ n + 1 + m = n + (1 + m)
```
we now get
```
error: tactic 'rfl' failed, the left-hand side
  n + 1 + m
is not definitionally equal to the right-hand side
  n + (1 + m)
n m : Nat
⊢ n + 1 + m = n + (1 + m)
```

Unfortunately, because of very subtle differences in semantics (which
transparency setting is used when reducing the goal and whether the
“implicit lambda” feature applies) I could not make this simply the only
`rfl` implementation. So `rfl` remains a macro and is still expanded to
`eq_refl` (difference transparency setting) and `exact Iff.rfl` and
`exact HEq.rfl` (implicit lambda) to not break existing code. This can
be revised later, so this still closes: #3302.

A user might still be puzzled *why* to terms are not defeq. Explaining
that better (“reduced to… and reduces to… etc.”) would also be great,
but that’s not specific to `rfl`, so better left for some other time.
2024-09-25 10:34:42 +00:00
Kim Morrison
c2f6297554 feat: adjust simp attributes on monad lemmas (#5464) 2024-09-25 10:21:18 +00:00
Tobias Grosser
1defa2028f feat: add BitVec.toInt_[intMin|neg|neg_of_ne_intMin ] (#5450) 2024-09-25 10:04:21 +00:00
Joachim Breitner
78c40f380c doc: contradiction docstring indendation (#5470)
Just saw some bad markdown, thought I’ll quickly fix it.
2024-09-25 09:50:21 +00:00
Luisa Cicolini
3e2a465b13 feat: add BitVec.[not_not, allOnes_shiftLeft_or_shiftLeft, allOnes_shiftLeft_and_shiftLeft, one_shiftLeft_mul] (#5469)
Co-authored-by: Tobias Grosser <github@grosser.es>
2024-09-25 09:33:24 +00:00
Sebastian Ullrich
1ec0c64c7b test: remove flaky test (#5468) 2024-09-25 08:18:42 +00:00
Kim Morrison
604bcf50ef chore: upstream some monad lemmas (#5463) 2024-09-25 07:57:26 +00:00
Kim Morrison
145c9efb32 feat: Array.foldX lemmas (#5466) 2024-09-25 07:17:19 +00:00
Kim Morrison
e4f2de0a53 feat: improve Array GetElem lemmas (#5465)
This should be tested against Mathlib, but there are conflicts with the
`nightly-with-mathlib` branch right now, so I'll wait until tomorrow.
2024-09-25 07:17:13 +00:00
Mac Malone
7845a05cf1 chore: update src/lake/lakefie.toml (#5462)
Update the Lake-specific package configuration with the proper root for
the executable (after #5143).
2024-09-25 05:42:52 +00:00
Mac Malone
57679eeff5 fix: typo in run_new_frontend signature (#4685)
Fixes a mixed up between the parameter and global variable for
`json_output` the occurred during some name juggling in #3939.
2024-09-25 05:42:48 +00:00
Kim Morrison
974cc3306c chore: restore @[simp] on Array.swapAt!_def (#5461) 2024-09-25 01:33:53 +00:00
Kim Morrison
c7819bd6eb chore: missing List.set_replicate_self (#5460) 2024-09-25 01:15:24 +00:00
Kim Morrison
a4fb740d2f chore: missing BitVec lemmas (#5459) 2024-09-25 01:06:39 +00:00
Kyle Miller
ea75c924a1 feat: add heq_comm (#5456)
Requested [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/heq_comm/near/472516757).
2024-09-24 23:36:00 +00:00
Kim Morrison
65f4b92505 chore: cleanup of Array docstrings after refactor (#5458)
Sorry this is coming through in tiny pieces; I'm still hitting a
bootstrapping problem and getting things through piecemeal to localise
it.
2024-09-24 23:16:49 +00:00
Kim Morrison
a6f0112fc5 feat: refactor of Array (#5452)
This is a second attempt at #5446, first reverting parts of #5403.
2024-09-24 12:57:55 +00:00
Kim Morrison
eee0553318 chore: make some instance arguments implicit (#5454)
This was causing a few unnecessary `_` downstream.
2024-09-24 12:57:46 +00:00
Tobias Grosser
5d2c7fc1d9 feat: more of BitVec.getElem_* (#5404) 2024-09-24 08:04:39 +00:00
Kyle Miller
94de4ae964 fix: make Repr deriving instance handle explicit type parameters (#5432)
The `Repr` deriving instance was assuming that all type parameters are
implicit. However, if the parameter came from a type index that was
promoted to be a parameter, then it is explicit. The result was that
some explicit constructor arguments were not being represented.

Reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/.23eval.20removes.20indexes.20inductive.20.20object.20descriptions/near/472301282).
2024-09-24 05:37:36 +00:00
Kyle Miller
1129160d80 fix: make formatter use current token table (#5389)
Previously the formatter was using the builtin token table rather that
the one in the current environment. This could lead to round-tripping
failures for user-defined notations.

For an illustrative example, given the following notation
```lean
infixl:65 "+'" => Int.add
notation:65 a:65 "+'-" b:66 => Int.add a (id b)
```
then `5 +' -1` would parse as `Int.add 5 (-1)` and incorrectly pretty
print as `5+'-1`, which in turn would parse as `Int.add 5 (id 1)`. Now
it pretty prints as `5+' -1`.
2024-09-24 05:33:12 +00:00
Kyle Miller
8cc62940e0 feat: localize universe metavariable errors at let bindings and fun binders (#5402)
Modifies how the declaration command elaborator reports when there are
unassigned metavariables. The visible effects are that (1) now errors
like "don't know how to synthesize implicit argument" and "failed to
infer 'let' declaration type" take precedence over universe level
issues, (2) universe level metavariables are reported as metavariables
(rather than as `u_1`, `u_2`, etc.), and (3) if the universe level
metavariables appear in `let` binding types or `fun` binder types, the
error is localized there.

Motivation: Reporting unsolved expression metavariables is more
important than universe level issues (typically universe issues are from
unsolved expression metavariables). Furthermore, `let` and `fun` binders
can't introduce universe polymorphism, so we can "blame" such bindings
for universe metavariables, if possible.

Example 1: Now the errors are on `x` and `none` (reporting expression
metavariables) rather than on `example` (which reported universe level
metavariables).
```lean
example : IO Unit := do
  let x := none
  pure ()
```

Example 2: Now there is a "failed to infer universe levels in 'let'
declaration type" error on `PUnit`.
```lean
def foo : IO Unit := do
  let x : PUnit := PUnit.unit
  pure ()
```


In more detail:
* `elabMutualDef` used to turn all level mvars into fresh level
parameters before doing an analysis for "hidden levels". This analysis
turns out to be exactly the same as instead creating fresh parameters
for level mvars in only pre-definitions' types and then looking for
level metavariables in their bodies. With this PR, error messages refer
to the same level metavariables in the Infoview, rather than obscure
generated `u_1`, `u_2`, ... level parameters.
* This PR made it possible to push the "hidden levels" check into
`addPreDefinitions`, after the checks for unassigned expression mvars.
It used to be that if the "hidden levels" check produced an "invalid
occurrence of universe level" error it would suppress errors for
unassigned expression mvars, and now it is the other way around.
* There is now a list of `LevelMVarErrorInfo` objects in the `TermElabM`
state. These record expressions that should receive a localized error if
they still contain level metavariables. Currently `let` expressions and
binder types in general register such info. Error messages make use of a
new `exposeLevelMVars` function that adds pretty printer annotations
that try to expose all universe level metavariables.
* When there are universe level metavariables, for error recovery the
definition is still added to the environment after assigning each
metavariable to level 0.
* There's a new `Lean.Util.CollectLevelMVars` module for collecting
level metavariables from expressions.

Closes #2058
2024-09-24 05:30:42 +00:00
Kim Morrison
b612403980 chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
Kim Morrison
6b0d4e50c0 chore: update Pi instance names (#5447)
Override instance names for nonempty / inhabited / subsingleton arrows,
per
[zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Pi.20instance.20names.20in.20Lean.204.20core/near/466248246).
2024-09-24 04:12:51 +00:00
Siddharth
0cae7165aa feat: BitVec.toNat_{add,sub,mul_of_lt} for BitVector non-overflow reasoning (#5411)
These theorems are useful when one wants to simplify the goal state,
under knowledge that the bitvector operations don't overflow. This can
produce much smaller goal states that eventually allows `bv_omega` to
quickly close the goal.

Note that the LHS of the theorem is *not* in `simp` normal form, since
e.g. `(x + y).toNat` is normalized to `(x.toNat + y.toNat) % 2^w`. It's
not immediately clear to me what should be done about this.

Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
2024-09-24 03:54:50 +00:00
euprunin
ba43ce18c3 chore: remove repeated words (#5438)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
2024-09-24 03:40:11 +00:00
Tobias Grosser
3190be3058 feat: add LawCommIdentity + IdempotentOp for BitVec.[and|or|xor] (#5416)
As these instances seemingly require explicit arguments, this PR also
makes some arguments explicit.
2024-09-24 03:27:57 +00:00
TomasPuverle
a108644461 feat: implement To/FromJSON Empty (#5421)
Resolve cases when the `To/FromJSON` type classes are used with `Empty`,
e.g. in the following motivating example.

```
import Lean

structure Foo (α : Type) where
  y : Option α
deriving Lean.ToJson

#eval Lean.toJson (⟨none⟩ : Foo Empty) -- fails
```

This is a follow-up to this PR
https://github.com/leanprover/lean4/pull/5415, as suggested by
@eric-wieser. It expands on the original suggestion by also handling
`FromJSON`.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-09-24 03:27:23 +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
euprunin
2d5ebf3705 chore: fix spelling mistakes in RELEASES.md (#5440)
---

Correct some stray spelling mistakes. I think the typo count is
asymptotically approaching zero.

Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-24 03:20:13 +00:00
Kim Morrison
5017b2bfbf chore: Mathlib's lean-pr-testing-NNNN branches should use Batteries' lean-pr-testing-NNNN branches (#5444)
The problem here was that in Mathlib's `lean-pr-testing-NNNN` branches,
we were setting Batteries to a `nightly-testing-YYYY-MM-DD` branch. This
means that when we merge or rebase a new `nightly-with-mathlib` into a
Lean PR, the corresponding Mathlib testing branch would keep using an
old version of Batteries.

We also make sure to bump Batteries if Mathlib's `lean-pr-testing-NNNN`
branch already exists.
2024-09-24 01:33:38 +00:00
euprunin
1b4ee185e8 chore: fix spelling mistakes in src/Lean/Meta/ (#5436)
---
This is the final set of fixes of this kind. Thanks for your patience!

Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 23:09:14 +00:00
euprunin
27c4c366b4 chore: remove (syntactically) duplicate imports (#5437)
---

Related: https://github.com/leanprover-community/mathlib4/pull/16384
("feat: lint on (syntactically) duplicate imports")

Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 23:07:56 +00:00
euprunin
405b5aa047 chore: fix spelling mistakes in src/Lean/Elab/ (#5435)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 21:58:16 +00:00
euprunin
edf2327229 chore: fix spelling mistakes in examples (doc/examples/) (#5434)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 21:44:55 +00:00
euprunin
cda6733f97 chore: fix spelling mistakes in non-Lean files (#5430)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 21:11:20 +00:00
euprunin
624f1b9963 chore: fix spelling mistakes in src/Init/ (#5427)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 21:09:58 +00:00
euprunin
cf94f793a2 chore: fix spelling mistakes in src/Std/ (#5431)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 20:39:34 +00:00
Henrik Böving
9185955692 feat: present the bv_decide counter example at the API (#5433) 2024-09-23 20:29:39 +00:00
Sebastian Ullrich
9d583ab4ec fix: worker: make sure to always report some recent range as progress when waiting (#5428)
On a document edit, it may be the case that the first nontrivial
snapshot is e.g. for a macro-generated tactic call that does not have
range information. In that case, instead of just displaying nothing, we
should fall back to a previous range, in this case of the original
tactic macro.
2024-09-23 15:52:52 +00:00
euprunin
50339e38d9 chore: fix spelling mistakes in src/Lean/ (#5426)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 14:56:59 +00:00
euprunin
8b61dda964 chore: fix spelling mistakes in error messages/exceptions (#5425)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-23 13:19:05 +00:00
Leonardo de Moura
fc20b5dfb4 fix: must not reduce ite in the discriminant of match-expression when reducibility setting is .reducible (#5419)
closes #5388

See updated comment for additional details.
2024-09-23 12:26:53 +00:00
Kim Morrison
7fba7ed7b6 feat: decidable quantifers for BitVec (#5418) 2024-09-23 11:02:49 +00:00
Henrik Böving
2f2142ab37 feat: enhance the rewriting rules of bv_decide (#5423) 2024-09-23 09:22:19 +00:00
Kim Morrison
e551a366a0 feat: theorems about List.toArray (#5403) 2024-09-23 05:24:03 +00:00
Siddharth
f4afbc2f8b feat: BitVec analogues of Nat.{mul_two, two_mul, mul_succ, succ_mul} (#5410)
As requested by @hargoniX .
2024-09-23 04:37:04 +00:00
Kim Morrison
8c8585536c feat: refactor DecidableEq (Array α) (#5422) 2024-09-23 03:49:03 +00:00
Kim Morrison
c825b5a560 chore: reverse direction of List.set_map (#5405) 2024-09-23 03:44:11 +00:00
Kim Morrison
738435b90a chore: make Array functions either semireducible or use structural recursion (#5420)
Previously, it was not possible to use `decide` with most Array
functions (including `==`).

Later, we may replace some of these functions with defeqs that go via
the `List` operations, and use `csimp` lemmas for fast runtime
behaviour. In the meantime, this allows using `decide`.
2024-09-23 02:41:41 +00:00
TomasPuverle
1883c9b7eb feat: implement Repr Empty (#5415)
Given the derived `Repr` instance for types with parameters, the absence
of `Repr Empty` can cause `Repr` instance synthesis to fail. For
example, given
```lean
inductive Prim (special : Type) where
  | plus
  | other : special → Prim special
deriving Repr
```
this works:
```lean
#eval (Prim.plus : Prim Int)
```
but this fails:
```lean
#eval (Prim.plus : Prim Empty)
```

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2024-09-23 01:11:36 +00:00
Tobias Grosser
fc52015841 feat: add _self, _zero, and _allOnes for BitVec.[and|or|xor] (#5413)
The `xor_allOnes` theorems end up in the `not` section, as the relevant
simplification lemmas are otherwise not defined.
2024-09-22 10:10:54 +00:00
Henrik Böving
a6830f90ab chore: basic cleanups for bv_decide (#5408) 2024-09-20 11:47:35 +00:00
Lean stage0 autoupdater
eceba0faf4 chore: update stage0 2024-09-20 09:14:22 +00:00
Joachim Breitner
fc963ffceb feat: apply_rfl tactic: handle Eq, HEq, better error messages (#3714)
This implements the first half of #3302: It improves the extensible
`apply_rfl` tactic (the one that looks at `refl` attributes, part of
the `rfl` macro) to

* Check itself and ahead of time that the lhs and rhs are defEq, and
give
a nice consistent error message when they don't (instead of just passing
on
  the less helpful error message from `apply Foo.refl`), and using the 
machinery that `apply` uses to elaborate expressions to highlight diffs
  in implicit arguments.

* Also handle `Eq` and `HEq` (built in) and `Iff` (using the attribute)

Care is taken that, as before, the current transparency setting affects
comparing the lhs and rhs, but not the reduction of the relation

So before we had

```lean
opaque P : Nat → Nat → Prop
@[refl] axiom P.refl (n : Nat) : P n n

/--
error: tactic 'apply' failed, failed to unify
  P ?n ?n
with
  P 42 23
⊢ P 42 23
-/
#guard_msgs in
example : P 42 23 := by apply_rfl

opaque withImplicitNat {n : Nat} : Nat

/--
error: tactic 'apply' failed, failed to unify
  P ?n ?n
with
  P withImplicitNat withImplicitNat
⊢ P withImplicitNat withImplicitNat
-/
#guard_msgs in
example : P (@withImplicitNat 42) (@withImplicitNat 23) := by apply_rfl
```

and with this PR the messages we get are

```
error: tactic 'apply_rfl' failed, The lhs
  42
is not definitionally equal to rhs
  23
⊢ P 42 23
```
resp.
```
error: tactic 'apply_rfl' failed, The lhs
  @withImplicitNat 42
is not definitionally equal to rhs
  @withImplicitNat 23
⊢ P withImplicitNat withImplicitNat
```

A test file checks the various failure modes and error messages.

I believe this `apply_rfl` can serve as the only implementation of
`rfl`, which would then complete #3302, and actually expose these
improved
error messages to the user. But as that seems to require a
non-trivial bootstrapping dance, it’ll be separate.
2024-09-20 08:25:10 +00:00
Alex Keizer
d8e0fa425b feat: instance for Inhabited (TacticM α) (#5401)
Provide an instance `Inhabited (TacticM α)`, even when `α` is not known
to be inhabited.

The default value is just the default value of `TermElabM α`, which
already has a similar instance.
2024-09-20 06:07:02 +00:00
David Thrane Christiansen
e43664c405 doc: add Verso to release checklist process (#5372)
This will help downstream users of Verso who aren't tracking Lean
`master`.
2024-09-20 06:06:09 +00:00
Kim Morrison
c50bc845c2 feat: HashSet.ofArray (unverified) (#5369)
This is being added downstream (in Batteries, and then used by Aesop).
2024-09-20 06:05:21 +00:00
Kim Morrison
b41019e8e8 feat: HashSet.partition (unverified) (#5370)
`Aesop` is depending on (a custom-rolled) `Set` data structure with
`.partition`.
2024-09-20 06:05:10 +00:00
Leonardo de Moura
0a2d121e45 fix: modify projection instance binder info (#5376)
closes #5333

This PR tries to address issue #5333.

My conjecture is that the binder annotations for `C.toB` and
`Algebra.toSMul` are not ideal. `Algebra.toSMul` is one of declarations
where the new command `set_synth_order` was used. Both classes, `C` and
`Algebra`, are parametric over instances, and in both cases, the issue
arises due to projection instances: `C.toB` and `Algebra.toSMul`. Let's
focus on the binder annotations for `C.toB`. They are as follows:

```
C.toB [inst : A 20000] [self : @C inst] : @B ...
```

As a projection, it seems odd that `inst` is an instance-implicit
argument instead of an implicit one, given that its value is fixed by
`self`. We observe the same issue in `Algebra.toSMul`:

```
Algebra.toSMul {R : Type u} {A : Type v} [inst1 : CommSemiring R] [inst2 : Semiring A]
   [self : @Algebra R A inst1 inst2] : SMul R A
```

The PR changes the binder annotations as follows:

```
C.toB {inst : A 20000} [self : @C inst] : @B ...
```

and

```
Algebra.toSMul {R : Type u} {A : Type v} {inst1 : CommSemiring R} {inst2 : Semiring A}
    [self : @Algebra R A inst1 inst2] : SMul R A
```

In both cases, the `set_synth_order` is used to force `self` to be
processed first.

In the MWE, there is no instance for `C ...`, and `C.toB` is quickly
discarded. I suspect a similar issue occurs when trying to use
`Algebra.toSMul`, where there is no `@Algebra R A ... ...`, but Lean
spends unnecessary time trying to synthesize `CommSemiring R` and
`Semiring A` instances. I believe the new binder annotations make sense,
as if there is a way to synthesize `Algebra R A ... ...`, it will tell
us how to retrieve the instance-implicit arguments.

TODO: 
- Impact on Mathlib.
- Document changes.

---------

Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
Co-authored-by: Johan Commelin <johan@commelin.net>
2024-09-20 06:03:59 +00:00
Kim Morrison
152ca85fa9 chore: reorganization in Array/Basic (#5400)
Getting started on `Array`.
2024-09-20 02:01:52 +00:00
Kim Morrison
0ecf2a030a feat: List.fold relators (#5393) 2024-09-20 00:48:03 +00:00
David Thrane Christiansen
7b8f2fe54c doc: mark «tacticHave'_:=_» as an alternative form of have' (#5396)
This is to simplify the manual's cross-referencing.
2024-09-19 17:09:57 +00:00
Sebastian Ullrich
34f85bee02 fix: unused variable false positive when combining alias and non-lexical use (#5335)
We need to follow the fvar aliases registered by `match` in both
directions

Fixes #4714, fixes #2837

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-09-19 10:51:14 +00:00
Kim Morrison
590c725943 feat: lemmas about List.maximum? (#5394) 2024-09-19 09:23:11 +00:00
Kim Morrison
9193196208 feat: List.fold / attach lemmas (#5392) 2024-09-19 08:26:06 +00:00
Kim Morrison
c3f384d6a5 feat: review of List.erase / List.find lemmas (#5391) 2024-09-19 05:37:04 +00:00
Tobias Grosser
daf24ff6aa feat: add BitVec.ofBool_[and|or|xor]_ofBool theorems (#5385)
... and use them to simplify some proofs.
2024-09-18 21:59:09 +00:00
Henrik Böving
fa6afa85df refactor: remove the last use of Lean.(HashSet|HashMap) (#5362) 2024-09-18 18:20:51 +00:00
Henrik Böving
592e1dc6c2 feat: bv_decide diagnosis (#5365)
Fixes: #5326
2024-09-18 17:55:16 +00:00
David Thrane Christiansen
c4293f04ef feat: add Nonempty instances for products (#5374)
After #5270, `partial` functions that use products of sums no longer
compile with only `Nonempty` constraints on their arguments. These
instances allow the compilation to work.
2024-09-18 16:34:45 +00:00
Kim Morrison
e417ad8a70 feat: missing Fin @[simp] lemmas (#5380) 2024-09-18 10:06:35 +00:00
Kim Morrison
ddd471223c chore: cleaning up redundant simp lemmas (#5381)
Problems reported by the simpNF linter downstream.
2024-09-18 10:06:29 +00:00
Kim Morrison
4e5e2ad311 chore: fixes spurious omega error in #5315 (#5382) 2024-09-18 09:43:09 +00:00
Kim Morrison
dcff54edb5 chore: notation ^^ for Bool.xor (#5332)
Not sure why this had been missing. Precedence is slightly higher than
`||`, matching the precedence order we have for bitwise operators.
2024-09-18 08:59:11 +00:00
Kim Morrison
30e90a4dff chore: upstream map_mergeSort (#5377)
This incorporates contributions from @eric-wieser in
https://github.com/leanprover-community/mathlib4/pull/15952 and
@fgdorais in https://github.com/leanprover-community/batteries/pull/579
2024-09-18 08:19:42 +00:00
Jeremy Tan Jie Rui
988fc7b25a chore: ensure that the rfl tactic tries Iff.rfl (#5359)
Revert the removal of the macro containing `Iff.rfl` in #5329; it was
causing errors in leanprover-community/mathlib4#16839.
2024-09-18 08:01:41 +00:00
Kim Morrison
3872027d92 chore: update stage0 2024-09-18 18:20:06 +10:00
Tobias Grosser
d38dc72a54 chore: introduce BitVec.setWidth to unify zeroExtend and truncate
incomplete deprecations

chore: complete deprecations
2024-09-18 18:20:06 +10:00
Alex Keizer
4641ed8c96 feat: add bv_decide normalization rules for ofBool (a.getLsbD i) and ofBool a[i] (#5375)
In LNSym we often use the pattern `ofBool (a.getLsbD i)` to pick out a
specific bit (`i`) from a bitvector (`a`).

By adding a rewrite to `extractLsb` to `bv_decide`s normalization set,
we can still automatically close goals that have this pattern. In the
process, I also added a simp-lemma about the value of a `Fin 1`.
2024-09-18 07:04:30 +00:00
Kim Morrison
77cd700fa8 chore: remove some @[simp]s from Fin lemmas (#5379)
These were dubious simps, barely used, that hurt confluence.
2024-09-18 05:50:11 +00:00
Kim Morrison
a6a06a620f chore: modify signature of lemmas about mergeSort (#5378)
This slightly smooths the interaction with `Prop` based reasoning in
Mathlib. Still not totally happy here.
2024-09-18 01:49:15 +00:00
Kim Morrison
21d71de481 chore: fix name of List.length_mergeSort (#5373) 2024-09-17 12:43:39 +00:00
Eric Wieser
b74f85accd fix: do not ban .. with a . on the next line (#4768)
Without this change,
```lean
example : True := by
  refine' trivial ..
  . trivial
```
is a parse error.
2024-09-17 09:57:35 +00:00
Eric Wieser
46b16b6df1 doc: explain the borrow syntax (#4305)
Obviously a link to the web docs isn't ideal, but having hovers
available on the symbol is much better than nothing.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-09-17 09:52:41 +00:00
Joachim Breitner
445c8f2ee0 feat: FunInd: more equalities in context, more careful cleanup (#5364)
A round of clean-up for the context of the functional induction
principle cases.

* Already previously, with `match e with | p => …`, functional induction
would ensure that `h : e = p` is in scope, but it wouldn’t work in
dependent cases. Now it introduces heterogeneous equality where needed
(fixes #4146)
* These equalities are now added always (previously we omitted them when
the discriminant was a variable that occurred in the goal, on the
grounds that the goal gets refined through the match, but it’s more
consistent to introduce the equality in any case)
* We no longer use `MVarId.cleanup` to clean up the goal; it was
sometimes too aggressive (fixes #5347)
* Instead, we clean up more carefully and with a custom strategy:
* First, we substitute all variables without a user-accessible name, if
we can.
  * Then, we substitute all variable, if we can, outside in.
* As we do that, we look for `HEq`s that we can turn into `Eq`s to
substitute some more
  * We substitute unused `let`s.
  
**Breaking change**: In some cases leads to a different functional
induction principle (different names and order of assumptions, for
example).
2024-09-16 12:30:12 +00:00
Kim Morrison
3f8e3e726d feat: some BitVec GetElem lemmas (#5361) 2024-09-16 11:30:05 +00:00
Kim Morrison
45af92fcd1 feat: lemmas about List.tail (#5360) 2024-09-16 09:25:24 +00:00
Tobias Grosser
7952a7f74d feat: add BitVec.getElem_truncate (#5278)
Co-authored-by: luisacicolini <luisacicolini@gmail.com>
Co-authored-by: Kim Morrison <scott@tqft.net>
2024-09-16 08:59:33 +00:00
Kim Morrison
c25d206647 chore: Fin.ofNat' uses NeZero (#5356) 2024-09-16 07:13:18 +00:00
Violeta Hernández
078e9b6d77 doc: add documentation for groupBy.loop (#5349)
We add some documentation explaining the auxiliary function in the
definition of `groupBy`. This has been moved here from Mathlib PR
[16818](https://github.com/leanprover-community/mathlib4/pull/16818) by
request of @semorrison.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-09-16 05:56:44 +00:00
Kim Morrison
a745e33123 feat: BitVec.truncate lemmas (#5357)
These improve confluence of lemmas involving `truncate`.
2024-09-16 05:55:50 +00:00
Kim Morrison
7740a38a71 chore: remove @[simp] from Option.bind_map (#5354) 2024-09-16 04:44:38 +00:00
Kim Morrison
9568f305d8 chore: switch primes on List.getElem_take (#5294)
This will probably have fallout downstream, and as it is a direct name
switch I'm not going to provide any deprecations.
2024-09-16 03:40:42 +00:00
Kim Morrison
b1179d5cc3 chore: fix implicitness of List.getElem_mem (#5331) 2024-09-16 03:28:14 +00:00
Kim Morrison
e6145a6937 feat: simp lemmas for LawfulBEq (#5355) 2024-09-16 03:21:30 +00:00
Kim Morrison
d47ae99721 feat: List.head_mem_head? (#5353) 2024-09-16 03:05:17 +00:00
Kim Morrison
0aac83fe40 feat: List.attachWith lemmas (#5352) 2024-09-16 02:24:14 +00:00
Kim Morrison
8c6ac845b1 chore: cleanup after export Bool.and/or/not/xor 2024-09-16 12:45:51 +10:00
Kim Morrison
b714a96034 chore: update stage0 2024-09-16 12:45:51 +10:00
Kim Morrison
4e0f6b8b45 feat: export Bool.and/or/not/xor 2024-09-16 12:45:51 +10:00
Kim Morrison
979c5a4d6a chore: update stage0 2024-09-16 12:45:51 +10:00
Kim Morrison
2079bdcbca feat: deprecate _root_.or/and/not/xor 2024-09-16 12:45:51 +10:00
Kim Morrison
1a2217d47e feat: cleanup of List.getElem_append variants (#5303) 2024-09-16 02:01:37 +00:00
Kim Morrison
3ef67c468a feat: List.replicate lemmas (#5350) 2024-09-15 23:57:04 +00:00
Joachim Breitner
4c439c73a7 test: tracing and test case for #5347 (#5348)
not a fix, unfortunately, just recording the test.
2024-09-15 15:45:39 +00:00
thorimur
5eea8355ba fix: set check level correctly during workflow (#5344)
Fixes a workflow bug where the `check-level` was not always set
correctly. Arguments to a `gh` call used to determine the `check_level`
were accidentally outside of the relevant command substitution (`$(gh
...)`).

-----

This can be observed in [these
logs](https://github.com/leanprover/lean4/actions/runs/10859763037/job/30139540920),
where the check level (shown first under "configure build matrix") is
`2`, but the PR does not have the `release-ci` tag. As a "test", run the
script for "set check level" printed in those logs (with some lines
omitted):
```
check_level=0

labels="$(gh api repos/leanprover/lean4/pulls/5343) --jq '.labels'"
if echo "$labels" | grep -q "release-ci"; then
  check_level=2
elif echo "$labels" | grep -q "merge-ci"; then
  check_level=1
fi

echo "check_level=$check_level"
```
Note that this prints `check_level=2`, but changing `labels` to
`labels="$(gh api repos/leanprover/lean4/pulls/5343 --jq '.labels')"`
prints `check_level=0`.
2024-09-14 08:14:08 +00:00
thorimur
60bb451d45 feat: allow addition of release-ci label via comment (#5343)
Updates the PR labeling workflow to allow an external contributor to add
the `release-ci` label to their own PR via comment. This is allows users
on Windows and Intel-based macs to generate toolchains for local
testing. The pull request template is also updated to reflect this.

-----

See Zulip discussion
[here](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/No.20binary.20for.20lean.20PR.20testing.20locally).
2024-09-14 08:13:48 +00:00
Marc Huisinga
f989520d2b fix: invalid namespace completions (#5322)
This PR fixes an issue reported a while ago at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60Monad.2Emap.60.20is.20a.20namespace.3F/near/425662846
where `Monad.map` was incorrectly reported by the autocompletion as a
namespace.

The underlying issue is that `Monad.map` contains an internal
declaration `_default`. This PR ensures that no namespaces are
registered that only contain internal declarations.

This also means that `open`ing namespaces that only contain internal
declarations will now fail.

The Mathlib adaption for this is a minor change where a declaration
(i.e. a namespace that only contains internal declarations) was `open`ed
by accident.
2024-09-13 12:23:03 +00:00
Jeremy Tan Jie Rui
626dda9358 refactor: tag Iff.refl with @[refl] (#5329)
and remove `exact Off.rfl` from the `rfl` macro.


This upstreams a property found in
[`Mathlib.Init.Logic`](4e40837aec/Mathlib/Init/Logic.lean (L63)).
2024-09-13 11:55:36 +00:00
Sebastian Ullrich
5f789e63fa chore: remove confusing test 2024-09-13 13:04:57 +02:00
Sebastian Ullrich
438061a924 fix: inaccessible pattern vars reported as binders (#5337)
Fixes an unused variable false positive on some wildcard patterns

Fixes #1633, fixes #2830
2024-09-13 09:53:58 +00:00
Mario Carneiro
ec98c92ba6 feat: @[builtin_doc] attribute (part 2) (#3918)
This solves the issue where certain subexpressions are lacking syntax
hovers because the hover text is not "builtin" - it only shows up if the
`Parser` constant is imported in the environment. For top level syntaxes
this is not a problem because `builtin_term_parser` will automatically
add this doc information, but nested syntaxes don't get the same
treatment.

We could walk the expression and add builtin docs recursively, but this
is somewhat expensive and unnecessary given that it's a fixed list of
declarations in lean core. Moreover, there are reasons to want to
control which syntax nodes actually get hovers, and while a better
system for that is forthcoming, for now it can be achieved by
strategically not applying the `@[builtin_doc]` attribute.

Fixes #3842
2024-09-13 08:05:10 +00:00
Henrik Böving
2080fc0221 feat: (DHashMap|HashMap|HashSet).(getKey?|getKey|getKey!|getKeyD) (#5244) 2024-09-13 05:40:10 +00:00
Marc Huisinga
b34379554d feat: completion fallback (#5299)
When the elaborator doesn't provide us with any `CompletionInfo`, we
currently provide no completions whatsoever. But in many cases, we can
still provide some helpful identifier completions without elaborator
information. This PR adds a fallback mode for this situation.

There is more potential here, but this should be a good start.

In principle, this issue alleviates #5172 (since we now provide
completions in these contexts). I'll leave it up to an elaboration
maintainer whether we also want to ensure that the completion infos are
provided correctly in these cases.
2024-09-12 16:09:20 +00:00
Siddharth
273b7540b2 feat: toNat_sub_of_le (#5314)
This adds a simplification lemma for `(x - y).toNat` when the
subtraction is known to not overflow (i.e., `y ≤ x`).

We make a new section for this for two reasons:
1. Definitions of subtraction occur before the definition of
`BitVec.le_def`, so we cannot directly place this lemma at `sub`.
2. There are other theorems of this kind, for addition and
multiplication, which can morally live in the same section.
2024-09-12 13:19:39 +00:00
Lars - he/him
b875627198 feat: add ediv_nonneg_of_nonpos_of_nonpos to DivModLemmas (#5320)
The theorem 

```lean
namespace Int

theorem ediv_nonneg_of_nonpos_of_nonpos {a b : Int} (Ha : a ≤ 0) (Hb : b ≤ 0) : 0 ≤ a / b := by
  match a, b with
  | ofNat a, b =>
    match Int.le_antisymm Ha (ofNat_zero_le a) with
    | h1 =>
    rw [h1, zero_ediv,]
    exact Int.le_refl 0
  | a, ofNat b =>
    match Int.le_antisymm Hb (ofNat_zero_le  b) with
    | h1 =>
    rw [h1, Int.ediv_zero]
    exact Int.le_refl 0
  | negSucc a, negSucc b =>
    rw [Int.div_def, ediv]
    have le_succ {a: Int} : a ≤ a+1 := (le_add_one (Int.le_refl a))
    have h2: 0 ≤ ((↑b:Int) + 1) := Int.le_trans (ofNat_zero_le b) le_succ
    have h3: (0:Int) ≤ ↑a / (↑b + 1) := (ediv_nonneg (ofNat_zero_le a) h2)
    exact Int.le_trans h3 le_succ
```
is nontrivial to prove from existing theorems and would be nice to add
as standard theorem in DivModLemmas.

See the zullip conversation
[here](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Adding.20theorem.20theorem.20ediv_nonneg'.20for.20negative.20a.20and.20b)

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-09-12 11:26:20 +00:00
Kim Morrison
adfd6c090e chore: add Nat.self_sub_mod lemma (#5306) 2024-09-12 03:36:50 +00:00
Kim Morrison
da0d309d65 feat: provide mergeSort comparator autoParam (#5302)
Write `mergeSort xs ys cmp` to provide an explicit comparator, or
otherwise `mergeSort xs ys` falls back to `LE` and `DecidablePred` via
an autoparam.
2024-09-12 01:50:01 +00:00
Kim Morrison
87fdd7809f feat: List.tail lemma (#5316) 2024-09-12 01:09:57 +00:00
Henrik Böving
8fd6e46a9c feat: more basic BitVec ordering theory for UInt (#5313) 2024-09-11 18:16:21 +00:00
Sebastian Ullrich
0602b805c8 fix: changing whitespace after module header may break subsequent commands (#5312)
`with` considered harmful when merging old and new state, let's always
be explicit in these cases
2024-09-11 13:00:42 +00:00
Kim Morrison
0b7debe376 chore: fix List.countP lemmas (#5311) 2024-09-11 10:09:37 +00:00
Kim Morrison
f5146c6edb chore: fix List.all/any lemmas (#5310) 2024-09-11 10:02:47 +00:00
Kim Morrison
461283ecf4 chore: restoring Option simp confluence (#5307) 2024-09-11 06:52:31 +00:00
Kim Morrison
27bf7367ca chore: rename Nat bitwise lemmas (#5305) 2024-09-11 06:29:00 +00:00
Kim Morrison
d4cc934149 chore: rename Int.div/mod to tdiv/tmod (#5301)
From the new doc-string:
```quote
In early versions of Lean, the typeclasses provided by `/` and `%`
were defined in terms of `tdiv` and `tmod`, and these were named simply as `div` and `mod`.

However we decided it was better to use `ediv` and `emod`,
as they are consistent with the conventions used in SMTLib, Mathlib,
and often mathematical reasoning is easier with these conventions.

At that time, we did not rename `div` and `mod` to `tdiv` and `tmod` (along with all their lemma).
In September 2024, we decided to do this rename (with deprecations in place),
and later we intend to rename `ediv` and `emod` to `div` and `mod`, as nearly all users will only
ever need to use these functions and their associated lemmas.
```
2024-09-11 06:15:44 +00:00
Kim Morrison
b88cdf6a3e chore: Array.not_mem_empty (#5304) 2024-09-11 06:13:24 +00:00
Kim Morrison
325a058893 feat: more List.findIdx theorems (#5300) 2024-09-11 04:53:59 +00:00
Henrik Böving
f869018447 feat: BitVec unsigned order theoretic results (#5297)
Proves that `<` and `<=` on `BitVec` are (strict) (total) partial
orders. This is required for the `UInt` as `BitVec` refactor.

This does open the question how to state these theorems "correctly" for
`BitVec`, we have both `<` living in `Prop` and `BitVec.ult` living in
`Bool`. We might of course say to always use `<` but: Once we start
adding `IntX` we need to prove the same results for `BitVec.slt` to
provide an equivalent API. So it would appear that it is unavoidable to
have a `= true` variant of these theorems there?

Question answered: Use `<` and `slt`.
2024-09-10 12:32:44 +00:00
Kim Morrison
c1da100997 chore: remove debug.byAsSorry 2024-09-10 19:30:09 +10:00
Kim Morrison
6c97c4ce37 chore: update stage0 2024-09-10 19:30:09 +10:00
Kim Morrison
c209d0d745 chore: upstream Zero and NeZero 2024-09-10 19:30:09 +10:00
Kim Morrison
5bc199ea1c chore: debug.byAsSorry on broken proofs 2024-09-10 19:30:09 +10:00
Arthur Adjedj
cb4a73a487 refactor: Lean.Elab.Deriving.FromToJson (#5292)
Refactors the derive handlers for `ToJson` and `FromJson` in preparation
for #3160.
This splits up the different parts of the handler according to how other
similar handlers are implemented while keeping the original logic
intact. This makes the changes necessary to adapt the file in #3160 much
easier.
2024-09-10 08:55:52 +00:00
Lean stage0 autoupdater
92e1f168b2 chore: update stage0 2024-09-10 08:04:39 +00:00
Marc Huisinga
a58520da16 fix: travelling auto-completion (#5257)
Fixes #4455, fixes #4705, fixes #5219

Also fixes a minor bug where a dot in brackets would report incorrect
completions instead of no completions.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-09-10 07:26:44 +00:00
Joachim Breitner
8f899bf5bd doc: code comments about reflection support (#5235)
I found that the kernel has special support for `e =?= true`, and will
in this case aggressively whnf `e`. This explains the following behavior
(for a `sqrt` function with fuel):

```lean
theorem foo : sqrt 100000000000000000002 == 10000000000 := rfl       -- fast
theorem foo : sqrt 100000000000000000002 =  10000000000 := rfl       -- slow
theorem foo : sqrt 100000000000000000002 =  10000000000 := by decide -- fast
```

The special support in the kernel only applies for closed `e` and `true`
on the RHS. It could be generlized (also open terms, also `false`, other
data type's constructors, different orientation). But maybe I should
wait for evidence that this generaziation really matters, or whether
all applications (proof by reflection) can be made to have this form.
2024-09-10 06:36:38 +00:00
Kim Morrison
7a5a08960a feat: cleanup of List.findIdx / List.take lemmas (#5293) 2024-09-10 06:17:38 +00:00
Lean stage0 autoupdater
5a9cfa0aec chore: update stage0 2024-09-10 05:59:09 +00:00
Kim Morrison
c79b09fdbd chore: restore Lake build 2024-09-10 15:24:23 +10:00
Kim Morrison
0b9a4bd65e chore: update stage0 2024-09-10 15:24:23 +10:00
Kim Morrison
e41e305479 chore: rename Array.data to Array.toList 2024-09-10 15:24:23 +10:00
Kim Morrison
b1a03a471f chore: disable Lake build 2024-09-10 15:24:23 +10:00
Sebastian Ullrich
6aa0c46b04 chore: fix Nix update-stage0 (#5290) 2024-09-09 16:27:24 +00:00
Kim Morrison
7eedf6467f feat: List.mem_ite_nil_left and analogues (#5289) 2024-09-09 14:08:01 +00:00
Kim Morrison
64b35ba555 chore: use boolean predicates in List.filter (#5287) 2024-09-09 12:15:04 +00:00
Marc Huisinga
ab7aed2930 feat: use incrementality for completion in tactic blocks (#5205)
This PR enables the use of incrementality for completion in tactic
blocks. Consider the following example:
```lean
example : True := by
  have : True := T
  sleep 10000
```

Before this PR, in order to respond to a completion request after `T`,
`sleep 10000` has to complete first since the command must be fully
elaborated. After this PR, the completion request is responded to
immediately.
2024-09-09 12:08:37 +00:00
Kim Morrison
a9e6c41b54 feat: allow simplifying dite_not/decide_not with only Decidable (¬p) (#5263)
These lemmas are mostly useful for ensuring confluence of `simp`, but
rarely useful in proofs. However they don't seem to have any negative
impact.
2024-09-09 11:46:20 +00:00
Sebastian Ullrich
1a857aa4f8 fix: do not link to Lake_shared with absolute path (#5286)
batteries CI fell over this but there was no PR comment
2024-09-09 11:11:00 +00:00
Sebastian Ullrich
c2761dc270 feat: Lake shared library (#5143)
Fixes #2436 #5050

Next step: when libLake_shared is in stage 0, --load-dynlib it when
building stage 1 Lake
2024-09-09 09:05:54 +00:00
Kim Morrison
ec7ae59473 feat: List.count lemmas (#5285) 2024-09-09 07:04:57 +00:00
Kim Morrison
c96fbdda44 chore: remove @[simp] from List.head_mem and similar (#5271)
These attributes do not seem particularly useful after all.
2024-09-09 06:05:06 +00:00
Kim Morrison
48db0f2d32 chore: turn off Inhabited (Sum α β) instances (#5284)
Alternative to #5270.
2024-09-09 01:10:20 +00:00
Kyle Miller
7a7440f59b feat: have IR checker suggest noncomputable (#4729)
Currently, `ll_infer_type` is responsible for telling the user about
`noncomputable` when a definition depends on one without executable
code. However, this is imperfect because type inference does not check
every subexpression. This leads to errors later on that users find to be
hard to interpret.

Now, `Lean.IR.checkDecls` has a friendlier error message when it
encounters constants without compiled definitions, suggesting to
consider using `noncomputable`. While this function is an internal IR
consistency check, it is also reasonable to have it give an informative
error message in this particular case. The suggestion to use
`noncomputable` is limited to just unknown constants.

Some alternatives would be to either (1) create another checker just for
missing constants, (2) change `ll_infer_type` to always visit every
subexpression no matter if they are necessary for inferring the type, or
(3) investigate whether `tests/lean/run/1785.lean` is due to a deeper
issue.

Closes #1785
2024-09-07 22:00:21 +00:00
Kyle Miller
c9239bfaa8 feat: let unfold do zeta-delta reduction of local definitions (#4834)
This is "upstreaming" mathlib's `unfold_let` tactic by incorporating its
functionality into `unfold`. Now `unfold` can, in addition to unfolding
global definitions, unfold local definitions. The PR also updates the
`conv` version of the tactic.

An improvement over `unfold_let` is that it beta reduces unfolded local
functions.

Two features not present in `unfold` are that (1) `unfold_let` with no
arguments does zeta delta reduction of *all* local definitions, and also
(2) `unfold_let` can interleave unfoldings (in contrast, `unfold a b c`
is exactly the same as `unfold a; unfold b; unfold c`).

Closes RFC #4090
2024-09-07 21:48:08 +00:00
Kyle Miller
8fcec4049b fix: make pretty printer escape identifiers that are tokens (#4979)
For example, if `forall` is a variable, it now pretty prints as
`«forall»`.

Closes #4686
2024-09-07 21:28:44 +00:00
Kyle Miller
e5e577865f doc: mention that inferType does not ensure type correctness (#5087)
This also adds links to the implementations of `whnf` and `inferType` to
make it easier to navigate this part of the code base.
2024-09-07 20:46:53 +00:00
Kim Morrison
7432a6f01f feat: more List.attach lemmas (#5277) 2024-09-07 05:29:40 +00:00
Kim Morrison
fcfead8cde feat: lemmas about List.attach (#5273)
#5272 should be merged first; this contains some material from that PR.
2024-09-06 22:14:56 +00:00
Kim Morrison
e5eea67020 chore: reverse direction of List.tail_map (#5275) 2024-09-06 11:55:50 +00:00
Kim Morrison
943dec48c4 feat: remove @[simp] from Option.pmap/pbind and add simp lemmas (#5272) 2024-09-06 11:39:29 +00:00
Kim Morrison
eba0cbaeb0 chore: remove HashMap's duplicated Pairwise and Sublist (#5269) 2024-09-06 09:28:51 +00:00
Kim Morrison
3ec55d3d49 chore: Nat.testBit_add_one should not be a global simp lemma (#5262) 2024-09-06 00:43:38 +00:00
Kim Morrison
c8c35ad3b9 chore: missing lemma about Fin.ofNat' (#5250) 2024-09-06 00:23:07 +00:00
Kim Morrison
7a6fa85ed1 chore: fix binders on ite_eq_left_iff (#5268) 2024-09-05 23:45:14 +00:00
Kim Morrison
f18ecd4493 chore: protect some Nat bitwise theorems (#5267) 2024-09-05 23:32:41 +00:00
Kyle Miller
74cf53f2b1 fix: preserve order of overapplied arguments in elab_as_elim procedure (#5266)
When an eliminator was overapplied with more than one additional
argument, elaboration produced an incorrect term because the list of
processed arguments was being reversed. Now these arguments are not
reversed.
2024-09-05 19:44:16 +00:00
Kim Morrison
76ea33c4c6 chore: review of List API (#5264) 2024-09-05 13:08:31 +00:00
Kim Morrison
1b099521c1 feat: Nat bitwise lemmas (#5261) 2024-09-05 06:36:21 +00:00
Kim Morrison
7c364543a3 chore: review of List API (#5260) 2024-09-05 06:27:08 +00:00
Henrik Böving
795edcf8ad perf: reduce allocations in Json.compress (#5222)
1. Remove the need to allocate an intermediate `String` for literally
every character in a JSON `String`.
2. Use a single `String` buffer in the entire `Json.compress` machinery.
3. Use `toListAppend`

Number 1 is doing most of the lifting in the perf diff, the rest are
some minor but measurable improvements.
2024-09-04 19:52:10 +00:00
Kim Morrison
d08051cf0b chore: variables appearing on both sides of an iff should be implicit (#5254) 2024-09-04 08:33:24 +00:00
Kim Morrison
f1b2850aa4 chore: split Init.Data.Array.Lemmas for better bootstrapping (#5255)
This allows significantly reducing the imports of `Init.Data.List.Impl`.
2024-09-04 08:33:13 +00:00
Marc Huisinga
d55f55d575 fix: include identifier before cursor in document highlight request (#5237)
Fixes #3023. Also fixes a similar off-by-one in the file worker
definition request.
2024-09-04 08:05:54 +00:00
Alex Keizer
fa8439a663 refactor: make extractLsb' the primitive bv_decide understands, rather than extractLsb (#5211)
We change the `bv_decide` to understand `BitVec.extractLsb'` as a
primitive, and add a normalization lemma for `extractLsb`.
It's important to pick the primed version as a primitive, because it is
not always possible to rewrite `extractLsb'` back into `extractLsb` (see
#5007 for that direction, and the relevant side-conditions).

That is, with this PR, `bv_decide` is able to bitblast both versions of
extracting bits.
2024-09-04 08:02:04 +00:00
Kim Morrison
05fe436bda chore: don't use simp_arith when simp will do (#5256) 2024-09-04 07:56:25 +00:00
Kim Morrison
a926d0ced0 chore: change BitVec.intMin/Max from abbrev to def (#5252)
I don't think we gain anything from having them as `abbrev` here, and
the simpNF linter complains:

```
-- Init.Data.BitVec.Lemmas
#check @BitVec.toNat_intMin /- simp can prove this:
  by simp only [BitVec.toNat_twoPow]
One of the lemmas above could be a duplicate.
If that's not the case try reordering lemmas or adding @[priority].
 -/
#check @BitVec.toNat_intMax /- Left-hand side simplifies from
  (BitVec.intMax w).toNat
to
  (2 ^ w - 1 % 2 ^ w + 2 ^ (w - 1)) % 2 ^ w
using
  simp only [@BitVec.toNat_sub, @BitVec.ofNat_eq_ofNat, BitVec.toNat_ofNat, BitVec.toNat_twoPow, Nat.add_mod_mod]
Try to change the left-hand side to the simplified term!
 -/
 ```
2024-09-04 05:29:58 +00:00
Kim Morrison
8c0c154ebf chore: remove Int simp lemmas that can't fire (#5253)
```
#lint only simpNF in all
```
reports (amongst others):

```
-- Init.Data.Int.Order
#check @Int.toNat_of_nonneg /- Left-hand side simplifies from
  ↑a.toNat
to
  max a 0
using
  simp only [Int.ofNat_toNat]
Try to change the left-hand side to the simplified term!
 -/
#check Int.toNat_sub_toNat_neg /- Left-hand side simplifies from
  ↑n.toNat - ↑(-n).toNat
to
  max n 0 - max (-n) 0
using
  simp only [Int.ofNat_toNat]
Try to change the left-hand side to the simplified term!
 -/
```
2024-09-04 05:29:51 +00:00
Kim Morrison
52bc8dcb40 chore: remove redundant simp annotations (#5251) 2024-09-04 04:36:09 +00:00
Kim Morrison
c219303270 chore: remove @[simp] from some BitVec lemmas (#5249)
I think it would be reasonable, but for now unnecessary, to add @[simp]
to `toNat_of_zero_length` and the subsequent three lemmas.
2024-09-04 03:08:03 +00:00
Kim Morrison
05ba835925 feat: simp lemmas for BitVec, improving confluence (#5248) 2024-09-04 03:03:46 +00:00
Kim Morrison
9587c67781 feat: BitVec.getElem_zeroExtend (#5247) 2024-09-04 02:29:51 +00:00
Kim Morrison
744b68358e chore: cleanup imports of Array.Lemmas (#5246) 2024-09-04 01:48:14 +00:00
Kim Morrison
318e455d96 chore: avoid importing List.Basic without List.Impl (#5245)
This doesn't completely resolve the danger (only relevant in `prelude`
files) of importing `Init.Data.List.Basic` but not `Init.Data.List.Impl`
and thereby not having `@[csimp]` lemmas installed for some list
operations.

I'm going to address this better while working on `Array`.
2024-09-04 01:25:50 +00:00
Joachim Breitner
4eea57841d refactor: rfl tactic: do not use Kernel.isDefEq (#3772)
Sebastian mentioned that the use of the kernel defeq was to work around
a performance issue that was fixed since. Let's see if we can do
without.

This is also a semantic change: Ground terms (no free vars, no mvars)
are reduced at
“all” transparency even if the the transparency setting is default. This
was the case
even before 03f6b87647 switched to the
kernel defeq
checking for performance. It seems that this is rather surprising
behavior from the user
point of view. The fallout on batteries and mathlib is rather limited,
only a few
`rfl` proofs seem to have (inadvertently or not) have relied on this.

The speedcenter reports no significant regressions on core or mathlib.
2024-09-03 19:51:14 +00:00
Kim Morrison
a5162ca748 feat: add @[simp] to Nat.add_eq_zero_iff (#5241) 2024-09-03 09:05:04 +00:00
Kim Morrison
b053403238 chore: improve naming for List.mergeSort lemmas (#5242) 2024-09-03 06:42:33 +00:00
Kim Morrison
66688e10ce chore: remove BitVec simps with complicated RHS (#5240) 2024-09-03 06:27:05 +00:00
Kim Morrison
4a2458b51d feat: gaps in Bool lemmas (#5228) 2024-09-03 04:33:43 +00:00
Leonardo de Moura
e9e858a448 chore: use Expr.numObjs instead of lean_expr_size_shared (#5239)
Remark: declarations like `sizeWithSharing` must be in `IO` since they
are not functions.

The commit also uses the more efficient `ShareCommon.shareCommon'`.
2024-09-02 21:26:00 +00:00
Mac Malone
df9cdcd1b7 feat: lake: Reservoir-related configuration for packages (#4770)
Adds additional fields to the package configuration which will be used
by Reservoir:

* `version`: The version of the package. Follows Lean's model of
`<major>.<minor>.<patch>[-<specialDescr>]`.
* `versionTags`: A pattern matching the set of Git tags Reservoir should
consider package version revisions.
* `description`: A short description for the package. Takes precedence
over the GitHub's description.
* `keywords`: An array of package keywords that will be used to group
packages into categories on Reservoir. Takes precedence over labels on
the repository.
* `homepage`: A URL to a website for the package. Takes precedence over
GitHub's homepage.
* `license`: An SPFX license identifier for the package's license (not
verified to be well-formed).
* `licenseFiles`: An array of (relative) files the contain license
information (e.g., `#["LICENSE", "NOTICE"]` for Apache 2.0).
* `readmeFile`: Relative path to the package's readme (enables
non-standard README locations).
* `reservoir`: Reservoir will use this setting to determine whether to
include packages in its index.

Also adds two new CLI commands:

* `lake reservoir-config`: Used by Reservoir to extract a package's
configuration.
* `lake check-build`: Determines whether the package has any default
build targets configured.

The Reservoir configuration also makes uses of the exiting `name` and
`platformIndependent` fields.
2024-09-02 16:07:08 +00:00
Markus Himmel
830b1191b3 doc: correct docstrings for integer division and modulus (#5230)
Fixes #5204.
2024-09-02 09:33:12 +00:00
Sebastian Ullrich
2117b89cd5 feat: pp.exprSizes debugging option (#5218) 2024-09-02 07:29:23 +00:00
Kim Morrison
4f04112446 chore: remove unused lemmas from a non-terminal simp (#5229)
These non-terminal `simp` calls broke on a branch, but can be fixed on
both `master` and that branch by removing a lemma.
2024-09-02 06:34:56 +00:00
Kyle Miller
db3631ba1f chore: release notes for 4.11.0 (#5221) 2024-09-02 00:19:41 +00:00
Leonardo de Moura
5214154ea9 perf: maximize term sharing at instantiateMVarDeclMVars (#5226)
The `instantiateMVarDeclMVars` is used by `runTactic`.

This commit address a performance issue at `LinearCategory`.
2024-09-01 23:00:48 +00:00
Leonardo de Moura
1b40ec5366 perf: cache visited exprs at CheckAssignmentQuick (#5225) 2024-09-01 22:04:40 +00:00
Kyle Miller
d31066646d feat: make #check and #reduce typecheck terms (#5079)
These commands were trusting that elaboration resulted in type-correct
terms, but users testing custom elaborators have found it to be
surprising that they do not do typechecking. This adds a `Meta.check`
step.
2024-08-31 02:39:38 +00:00
Henrik Böving
88c193d71c fix: out of bounds access when the CNF is too small (#5220)
As reported by @alexkeizer to me.
2024-08-30 22:30:03 +00:00
Sebastian Ullrich
e04a40ddc1 doc: include: currently applies to theorems only (#5206)
Fixes #5184
2024-08-30 12:51:50 +00:00
Henrik Böving
648239c6ec fix: BitVec benchmark after renaming of getLsb (#5217)
fallout from https://github.com/leanprover/lean4/pull/5200
2024-08-30 09:08:24 +00:00
Kim Morrison
a50ed83560 feat: List.erase_range (#5215) 2024-08-30 06:46:42 +00:00
Kim Morrison
bb87a3314d chore: move @[csimp] lemmas earlier where possible (#5214) 2024-08-30 06:42:05 +00:00
Kim Morrison
a47c590a91 chore: make some AIG simps local (#5212)
These had leaked out and were being noticed by the confluence tool.
Better to just make them local.
2024-08-30 02:50:53 +00:00
Kim Morrison
0a0405f4fb chore: List.getElem_drop, add @[simp] and switch primes (#5210)
This is a breaking change, as it reverses the meaning of
`List.getElem_drop` and `List.getElem_drop'`.
2024-08-30 02:48:59 +00:00
Kim Morrison
16aa80306e feat: Nat.bitwise lemmas (#5209) 2024-08-30 02:37:11 +00:00
Kim Morrison
a24370b049 chore: reverse direction of Int.toNat_sub (#5208)
The previous direction conflicted with `toNat_pred`, and this version is
equally helpful for confluence.
2024-08-30 02:25:53 +00:00
Kim Morrison
6b62fed82e feat: proposed change to BitVec API (#5200)
This renames `BitVec.getLsb` to `getLsbD` (`D` for "default" value, i.e.
false), and introduces `getLsb?` and `getLsb'` (which we can rename to
`getLsb` after a deprecation cycle).

(Similarly for `getMsb`.)

Also adds a `GetElem` class so we can use `x[i]` and `x[i]?` notation. 

Later, we will turn
```
theorem getLsbD_eq_getElem?_getD (x : BitVec w) (i : Nat) (h : i < w) :
    x.getLsbD i = x[i]?.getD false
```
on as a `@[simp]` lemma.

This PR doesn't attempt to demonstrate the benefits, but I think both
arguments are going to get easier, and this will bring the BitVec API
closer in line to List/Array, etc.

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
2024-08-30 02:00:57 +00:00
Joachim Breitner
f30ff6ae79 refactor: put new eqns options into backward namespace (#5207)
in #4154 and #5129 the rules for equational lemmas have changed, and new
options were introduced that can be used to revert to the pre-4.12
behavior. Hopefully nobody really needs these options besides for
backwards compatibility, therefore we put these options in the
`backward` option name space.

So the previous behavior can be achieved by setting
```lean
set_option backward.eqns.nonrecursive false
set_option backward.eqns.deepRecursiveSplit false
```
2024-08-29 17:03:51 +00:00
Joachim Breitner
50a009f811 fix: recursion over predicates: add some whnf sprinkles (#5136)
This fixes #4540.

---------

Co-authored-by: Richard Kiss <him@richardkiss.com>
2024-08-29 16:55:54 +00:00
Joachim Breitner
a993934839 feat: generate f.eq_unfold lemmas (#5141)
With this, lean produces the following zoo of rewrite rules:
```
Option.map.eq_1      : Option.map f none = none
Option.map.eq_2      : Option.map f (some x) = some (f x)
Option.map.eq_def    : Option.map f p = match o with | none => none | (some x) => some (f x)
Option.map.eq_unfold : Option.map = fun f p => match o with | none => none | (some x) => some (f x)
```

The `f.eq_unfold` variant is especially useful to rewrite with `rw`
under
binders.

This implements and fixes #5110
2024-08-29 16:47:40 +00:00
Joachim Breitner
aa3c87b2c7 fix: conv => arg n to handle .subsingletonInst (#5149)
this fixes #4394, see there for an analysis.
2024-08-29 15:48:31 +00:00
thorimur
869e42b7c3 fix: handle AttributeKinds in LabelAttributes correctly (#3698)
This PR propagates the `AttributeKind` to `SimpleScopedEnvExtension.add`
in attributes created with `register_label_attr`.

This also fixes a nearby stale docstring which referenced `Std`.

---

Closes #3697
2024-08-29 17:57:14 +02:00
Lean stage0 autoupdater
bdbadbd74b chore: update stage0 2024-08-29 13:56:52 +00:00
Henrik Böving
3120c3d8f8 feat: add bv_decide benchmarks (#5203) 2024-08-29 12:45:58 +00:00
FR
e1cbae26cc doc: fix typo in Quotient.liftOn docstring (#5202) 2024-08-29 12:00:36 +00:00
Marc Huisinga
9009c1ac91 fix: ilean loading performance (#4900)
This PR roughly halves the time needed to load the .ilean files by
optimizing the JSON parser and the conversion from JSON to Lean data
structures.

The code is optimized roughly as follows:
- String operations are inlined more aggressively
- Parsers are changed to use new `String.Iterator` functions `curr'` and
`next'` that receive a proof and hence do not need to perform an
additional check
- The `RefIdent` of .ilean files now uses a `String` instead of a `Name`
to avoid the expensive parse step from `String` to `Name` (despite the
fact that we only very rarely actually need a `Name` in downstream code)
- Instead of `List`s and `Subarray`s, the JSON to Lean conversion now
directly passes around arrays and array indices to avoid redundant
boxing
- Parsec's `peek?` sometimes generates redundant `Option` wrappers
because the generation of basic blocks interferes with the ctor-match
optimization, so it is changed to use an `isEof` check where possible
- Early returns and inline-do-blocks cause the code generator to
generate new functions, which then interfere with optimizations, so they
are now avoided
- Mutual defs are used instead of unspecialized passing of higher-order
functions to generate faster code
- The object parser is made tail-recursive

This PR also fixes a stack overflow in `Lean.Json.compress` that would
occur with long lists and adds a benchmark for the .ilean roundtrip
(compressed pretty-printing -> parsing).
2024-08-29 11:51:48 +00:00
Sebastian Ullrich
5c61ad38be chore: revert "chore: temporarily remove test broken by #4746" (#5201)
This reverts commit 7aec6c9ae7.
2024-08-29 08:47:48 +00:00
Kim Morrison
44985dc9a6 chore: remove >6 month deprecations (#5199) 2024-08-29 05:18:44 +00:00
Kim Morrison
3dfa7812f9 chore: cleanup allowUnsafeReducibility (#5198) 2024-08-29 05:12:54 +00:00
Kim Morrison
2dd6b2b9c8 chore: upstream Fin.le_antisymm (#5197) 2024-08-29 04:45:27 +00:00
Kim Morrison
6d0b00885e feat: List.Pairwise_erase and related lemmas (#5196) 2024-08-28 23:11:02 +00:00
Kim Morrison
75c0373c1a feat: lemmas about if-then-else improving confluence (#5191) 2024-08-28 23:10:13 +00:00
Henrik Böving
b37df8e31a chore: update-stage0 2024-08-28 18:14:39 +02:00
Henrik Böving
da9c68a37a feat: import LeanSAT's tactic frontends
Co-authored-by: Markus Himmel <markus@lean-fro.org>
2024-08-28 18:14:39 +02:00
Marc Huisinga
6fce7b82bc fix: duplicate "import out of date" messages (#5185)
This PR fixes a small bug where over time, "import out of data" messages
would accumulate in files when their size changed before restarting its
file worker.
2024-08-28 14:03:17 +00:00
Marc Huisinga
f220efc5ba doc: update quickstart guide for new display name (#5193)
https://github.com/leanprover/vscode-lean4/pull/521 changed the display
name of the VS Code extension so that it can be found more easily when
searching for "Lean" (before it would appear far down in the list). This
PR updates the quickstart guide to reflect this fact.
2024-08-28 13:29:16 +00:00
Kim Morrison
613dbf1637 feat: Int and Nat simp lemmas (#5190)
`@[simp]` lemmas for Int and Nat that improve confluence.
2024-08-28 10:53:28 +00:00
Kim Morrison
8e68c5d44e chore: cleanup simps in CNF.Basic / DHashMap.Internal.List (#5189)
A few unused implementation detail simp lemmas had leaked out and were
being detected by the confluence checker. Just remove them or make them
local.
2024-08-28 06:53:07 +00:00
Kim Morrison
9ce15fb0c6 chore: remove bad simp lemmas (#5180)
This disables some simp lemmas with bad discrimination tree keys, as
identified by @mattrobball on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Infrastructure.20for.20tracking.20frequently.20applied.20simp.20theorems/near/459926416).
2024-08-28 02:55:17 +00:00
Kim Morrison
0dc317c73c feat: restore reduceCtorEq in norm_cast tactic (#5187)
#5167 removed `reduceCtorEq` from the default simproc set. `norm_cast`
relies on it, so we add it back in there.
2024-08-28 02:38:57 +00:00
Jannis Limperg
44366382d3 fix: ignore implementationDetail hyps in rename_i (#5183)
Closes #5176
2024-08-27 14:45:16 +00:00
Markus Himmel
095c7b2bfc chore: deprecate Nat.strongInductionOn (#5179) 2024-08-27 07:18:06 +00:00
Kim Morrison
c4e4248487 chore: remove @[simp] from List.getLast_eq_iff_getLast_eq_some (#5178)
This was not a great simp lemma, and hurts simp confluence. Better to
just use it locally where it is useful.

Similarly `List.head_eq_iff_head?_eq_some`.
2024-08-27 03:23:39 +00:00
Kim Morrison
9ef996259b feat: add BitVec.intMax_add_one 2024-08-27 11:26:16 +10:00
Kim Morrison
30fa18816c feat: activate and use boolToPropSimps 2024-08-27 11:26:16 +10:00
Kim Morrison
94fd406c04 chore: update stage0 2024-08-27 11:26:16 +10:00
Tobias Grosser
3411935e53 feat: add BitVec.intMin
This PR also pulls in some mathlib theorems on testBit and Nat and establishes facts about 2^w that are needed here and which are generally useful for bitvector reasoning.

The following theorem is not generalized to arbitrary x instead of 2, as this would require a condition to be added for x > 1 which would have to be passed to simp each time this theorem should fire.

chore: derive from testBit_two_pow

chore: convert first to prop and then decide

chore: move intMax down as well

chore: add simp set

Add simp-set into this PR

chore: fix simp extension

Move file to src/Lean to fix build

Add prelude

update date

Add university of cambridge as copyright holder

improve naming

use whitespace uniformly

use decide (n = m)

Drop the 'Nat.' namespace

Update src/Init/Data/BitVec/Lemmas.lean

Co-authored-by: Siddharth <siddu.druid@gmail.com>

Update src/Init/Data/BitVec/Lemmas.lean

Co-authored-by: Siddharth <siddu.druid@gmail.com>

Fix build

add some theorems

Revert "add some theorems"

This reverts commit fb97bc2007e371854b40badb3d6014da034c1f5e.

WIP

Shorten proof

Update src/Init/Data/Nat/Lemmas.lean

finish proofs

Update src/Init/Data/BitVec/Lemmas.lean

Co-authored-by: Kim Morrison <scott@tqft.net>

Update src/Init/Data/Nat/Lemmas.lean

Co-authored-by: Kim Morrison <scott@tqft.net>

chore: move BoolToPropSimps
2024-08-27 11:26:16 +10:00
Kim Morrison
b518091bd4 chore: better statement for List.find?_filterMap (#5177) 2024-08-27 00:22:59 +00:00
Siddharth
a58a09056f feat: relate BitVec.signExtend to truncate (#4392)
This adds helper lemmas to relate sign extension to truncation, and as a
corollary shows that sign extension to the same width is a no-op.
2024-08-26 23:39:49 +00:00
Jon Eugster
c45a6a93f9 chore: use emoji variant of ️,️,💥️ (#5173)
First part of #5015, using emoji variant of unicode symbols for
️,️,💥️.

---

(Partially) closes #5015
2024-08-26 19:46:37 +00:00
Leonardo de Moura
f917f811c8 chore: cleanup #5167 workarounds after update stage0 (#5175)
PR #5167 implemented RFC #5046, but it required several workarounds due
to staging issues. This PR cleans up these workarounds.
2024-08-26 17:53:30 +00:00
Lean stage0 autoupdater
3c687df6d5 chore: update stage0 2024-08-26 15:32:27 +00:00
Leonardo de Moura
45475d6434 feat: allow users to disable simpCtorEq simproc (#5167)
`simp only` will not apply this simproc anymore. Users must now write
`simp only [reduceCtorEq]`. See RFC #5046 for motivation.
This PR also renames simproc to `reduceCtorEq`. 

close #5046 


@semorrison A few `simp only ...` tactics will probably break in
Mathlib. Fix: include `reduceCtorEq`.
2024-08-26 13:51:21 +00:00
Tobias Grosser
c6feffa2bd feat: add Bitvec.ofInt_ofNat (#5081)
We use `no_index` to work around special-handling of `OfNat.ofNat` in
`DiscrTree`, which has been reported as an issue in
https://github.com/leanprover/lean4/issues/2867 and is currently in the
process of being fixed in https://github.com/leanprover/lean4/pull/3684.
As the potential fix seems non-trivial and might need some time to
arrive in-tree, we meanwhile add the `no_index` keyword to the
problematic subterm.

---------

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2024-08-26 13:12:40 +00:00
Matthew Robert Ballard
b54a9ec9b9 feat: swap arguments to Membership.mem (#5020)
We swap the arguments for `Membership.mem` so that when proceeded by a
`SetLike` coercion, as is often the case in Mathlib, the resulting
expression is recognized as eta expanded and reduce for many
computations. The most beneficial outcome is that the discrimination
tree keys for instances and simp lemmas concerning subsets become more
robust resulting in more efficient searches.

Closes `RFC` #4932

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-08-26 12:35:47 +00:00
Tobias Grosser
68bb92a35a feat: add BitVec.toInt_[pos|neg]_iff (#5083)
Co-authored-by: Kim Morrison <scott@tqft.net>
2024-08-26 09:44:58 +00:00
Sebastian Ullrich
dcdbb9b411 fix: Syntax.unsetTrailing (#5170)
Fixes #4958
2024-08-26 07:56:04 +00:00
Jeremy Tan Jie Rui
dd22447afd chore: @[elab_as_elim] additions (#5147)
This adds `@[elab_as_elim]` to `Quot.rec`, `Nat.strongInductionOn` and
`Nat.casesStrongInductionOn`, and also renames the latter two to
`Nat.strongRecOn` and `Nat.casesStrongRecOn`.

The first change resolves the todos in
[`Mathlib.Init.Quot`](ca6a6fdc07/Mathlib/Init/Quot.lean)
while the other two are based on a suggestion of @YaelDillies on [the
Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Technical.20Debt.20Counters/near/464804567)
and related to
https://github.com/leanprover-community/mathlib4/pull/16096.
2024-08-26 07:44:54 +00:00
Kim Morrison
f0b0c60e0f chore: running simpNF linter (#5168) 2024-08-26 07:07:52 +00:00
Kim Morrison
9305049f1e feat: lemmas about List.find? and range'/range/iota (#5164) 2024-08-26 04:44:17 +00:00
Kim Morrison
852ee1683f feat: Int lemmas relating neg and emod/mod (#5166) 2024-08-26 03:05:16 +00:00
Kim Morrison
4c9db2fab8 feat: adjusting Int simp lemmas (#5165) 2024-08-26 03:05:10 +00:00
Kim Morrison
70c1e5690d feat: more improvements to List simp confluence (#5163) 2024-08-26 03:04:58 +00:00
Kim Morrison
5d84aebeb9 feat: lemmas about Function.comp that help confluence (#5162) 2024-08-26 03:04:53 +00:00
Kim Morrison
7e5d1103c2 feat: more lemmas about List.pmap/attach (#5160) 2024-08-26 02:15:58 +00:00
Kim Morrison
2d9cbdb450 feat: more List.findSome? lemmas (#5161) 2024-08-26 01:51:40 +00:00
Kim Morrison
fcdecacc4f feat: head/getLast lemmas for List.range (#5158) 2024-08-26 01:48:45 +00:00
Leonardo de Moura
c9c2c8720a fix: PANIC at Fin.isValue (#5159)
closes #4983
2024-08-26 00:36:47 +00:00
Leonardo de Moura
703658391e fix: PANIC at Lean.MVarId.falseOrByContra (#5157)
closes #4985
closes #4984
2024-08-26 00:28:28 +00:00
Kim Morrison
8898c8eaa9 feat: Bool lemmas improving confluence (#5155) 2024-08-25 11:15:07 +00:00
Kim Morrison
2d89693b71 chore: Option lemmas (#5154) 2024-08-25 09:20:24 +00:00
Kim Morrison
c3655b626e chore: remove bad simp lemma in omega theory (#5156) 2024-08-25 07:47:16 +00:00
Wojciech Nawrocki
644a12744b doc: fix option name (#5150)
Small typo fix. I don't believe there is an `autoBoundImplicitLocal`
option.
2024-08-25 07:16:44 +00:00
Kim Morrison
92b271ee64 feat: lemmas about List.erase(|P|Idx) (#5152) 2024-08-25 07:01:46 +00:00
Joachim Breitner
24f550fd6f feat: same equational lemmas for recursive and non-recursive functions (#5129)
This is part of #3983.

After #4154 introduced equational lemmas for non-recursive functions and
#5055
unififed the lemmas for structural and wf recursive funcitons, this now
disables the special handling of recursive functions in
`findMatchToSplit?`, so that the equational lemmas should be the same no
matter how the function was defined.

The new option `eqns.deepRecursiveSplit` can be disabled to get the old
behavior.

### Breaking change

This can break existing code, as there now can be extra equational
lemmas:

* Explicit uses of `f.eq_2` might have to be adjusted if the numbering
  changed.

* Uses of `rw [f]` or `simp [f]` may no longer apply if they previously
  matched (and introduced a `match` statement), when the equational
  lemmas got more fine-grained.

  In this case either case analysis on the parameters before rewriting
  helps, or setting the option `opt.deepRecursiveSplit false` while
  defining the function
2024-08-25 06:51:03 +00:00
Kim Morrison
cee84286e6 feat: improving confluence of List simp lemmas (#5151)
More theorems coming shortly that are easier after these changes, but
I'll test Mathlib on these simp changes first.
2024-08-25 04:32:45 +00:00
Kim Morrison
75781b46f5 feat: lemmas about List.attach/pmap (#5153) 2024-08-25 03:58:54 +00:00
Kim Morrison
ea97aac83b feat: improve Nat simp lemma confluence (#5148) 2024-08-24 11:37:37 +00:00
Kim Morrison
b1ebe7b484 feat: missing Nat.and_xor_distrib_(left|right) (#5146) 2024-08-24 07:46:57 +00:00
Kim Morrison
07013da720 chore: running the simpNF linter over Lean (#5133)
This should resolve nearly all of the simpNF lints. This is a follow-up
to #4620.
2024-08-24 07:10:07 +00:00
Wojciech Nawrocki
2bc87298d9 doc: update user widget manual (#5006)
Updates the user widget manual to account for more recent changes. One
issue is that the samples no longer work on https://live.lean-lang.org/
because it uses an outdated version of the `@leanprover/infoview` NPM
package. They work on https://lean.math.hhu.de/ and in recent versions
of the VSCode extension.
2024-08-23 19:03:39 +00:00
Sebastian Ullrich
390a9a63a2 fix: mixing variable binder updates and declarations (#5142)
Fixes #2143
2024-08-23 09:31:49 +00:00
Sebastian Ullrich
6d4ec153ad feat: ship cadical (#4325)
Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-08-23 09:13:27 +00:00
Kim Morrison
bf304769e0 feat: misc List lemma updates (#5127) 2024-08-23 01:17:17 +00:00
Kim Morrison
7488b27b0d feat: lemmas about membership of sublists (#5132) 2024-08-23 01:16:53 +00:00
Sebastian Ullrich
33d24c3bca fix: improper handling of strict-implicit section variables (#5138)
This was actually broken even before `include`
2024-08-22 14:20:25 +00:00
Sebastian Ullrich
f71a1fb4ae test: add missing test 2024-08-22 16:48:11 +02:00
Joachim Breitner
01ec8c5e14 doc: unfold tactic docstring (#5109) 2024-08-22 13:58:42 +00:00
Joachim Breitner
d975e4302e feat: fine-grained equational lemmas for non-recursive functions (#4154)
This is part of #3983.

Fine-grained equational lemmas are useful even for non-recursive
functions, so this adds them.

The new option `eqns.nonrecursive` can be set to `false` to have the old
behavior.

### Breaking channge

This is a breaking change: Previously, `rw [Option.map]` would rewrite
`Option.map f o` to `match o with … `. Now this rewrite will fail
because the equational lemmas require constructors here (like they do
for, say, `List.map`).

Remedies:

 * Split on `o` before rewriting.
* Use `rw [Option.map.eq_def]`, which rewrites any (saturated)
application of `Option.map`
* Use `set_option eqns.nonrecursive false` when *defining* the function
in question.

### Interaction with simp

The `simp` tactic so far had a special provision for non-recursive
functions so that `simp [f]` will try to use the equational lemmas, but
will also unfold `f` else, so less breakage here (but maybe performance
improvements with functions with many cases when applied to a
constructor, as the simplifier will no longer unfold to a large
`match`-statement and then collapse it right away).

For projection functions and functions marked `[reducible]`, `simp [f]`
won’t use the equational theorems, and will only use its internal
unfolding machinery.

### Implementation notes

It uses the same `mkEqnTypes` function as for recursive functions, so we
are close to a consistency here. There is still the wrinkle that for
recursive functions we don't split matches without an interesting
recursive call inside. Unifying that is future work.
2024-08-22 13:26:58 +00:00
Henrik Böving
74715a0f9c feat: support for secure temporary files (#5125)
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-08-22 13:01:40 +00:00
Kim Morrison
d540ba787a feat: Option lemmas (#5128) 2024-08-22 12:43:16 +00:00
Kim Morrison
b33d08078d feat: more lemmas about List.append (#5131) 2024-08-22 12:42:57 +00:00
Kim Morrison
e9025bdf79 feat: lemmas about List.join (#5130) 2024-08-22 12:09:45 +00:00
Sebastian Ullrich
5651a11ac8 feat: improve unused section variable warning (#5036)
See
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Opt.20out.20of.20.22included.20section.20variable.20is.20not.20used.22.20linter
2024-08-22 10:18:09 +00:00
Kim Morrison
481894e95d feat: range/iota lemmas (#5123) 2024-08-22 06:09:42 +00:00
Kim Morrison
7213583c8d feat: lemmas about List.find? (#5124) 2024-08-22 06:09:42 +00:00
Lean stage0 autoupdater
6a473e67aa chore: update stage0 2024-08-21 21:35:52 +00:00
Joachim Breitner
e5d44f4033 fix: hover text over _ in ?_ (#5118)
in principle we'd like to use the existing parser
```
   "?" >> (ident <|> hole)
```
but somehow annotate it so that hovering the `hole` will not show the
hole's hover. But for now it was easier to just change the parser to
```
   "?" >> (ident <|> "_")
```
and be done with it.

Fixes #5021
2024-08-21 20:47:19 +00:00
Joachim Breitner
c78bb62c51 fix: get_elem_tactic_trivial to not loop in the presence of mvars (#5119)
The goal at the crucial step is
```
a : Array Nat
i : Fin ?m.27
⊢ ↑i < a.size
```
and after the `apply Fin.val_lt_of_le;` we have
```
a : Array Nat
i : Fin ?m.27
⊢ ?m.27 ≤ a.size
```
and now `apply Fin.val_lt_of_le` applies again, due to accidential
defeq. Adding `with_reducible` helps here.

fixes #5061
2024-08-21 19:51:58 +00:00
Joachim Breitner
e620cf3c80 fix: count let-bound variables in induction … with correctly (#5117)
This fixes #5058 and is a follow-up to #3505.
2024-08-21 18:49:51 +00:00
Henrik Böving
edecf3d4ba chore: move Lean.Data.Parsec to Std.Internal.Parsec (#5115)
Again as discussed for bootstrapping reasons.
2024-08-21 15:26:17 +00:00
Lean stage0 autoupdater
1c73983dcf chore: update stage0 2024-08-21 14:11:59 +00:00
Sebastian Ullrich
4b7b69c20a feat: omit (#5000) 2024-08-21 13:22:34 +00:00
Henrik Böving
87d361d9b6 chore: move LeanSAT logic to Std (#5113)
As discussed for bootstrapping reasons. The only new files here are
`Std.Tactic` and `Std.Tactic.BVDecide`. The rest is move +
renamespacing.
2024-08-21 13:00:41 +00:00
Lean stage0 autoupdater
a3ae75f847 chore: update stage0 2024-08-21 12:24:33 +00:00
Kim Morrison
0a8d1bf808 feat: basic instances for ULift and PLift (#5112) 2024-08-21 11:37:13 +00:00
Kim Morrison
a58da122b9 feat: change statement of List.getLast?_cons (#5106)
To avoid using `getLastD`, which is not simp-normal-form.
2024-08-21 10:59:34 +00:00
Kim Morrison
3b1af163eb feat: adjust List simp lemmas (#5102)
I'll do this in a few stages, testing against Mathlib as we go.
2024-08-21 07:25:36 +00:00
Kim Morrison
0e823710e3 feat: Nat.add_left_eq_self and relatives (#5104) 2024-08-21 04:11:57 +00:00
Kim Morrison
c38d271283 feat: lemmas about Option/if-then-else (#5101) 2024-08-21 03:16:48 +00:00
Kim Morrison
4dbd20343f chore: remove @[simp] from mem_of_find?_eq_some (#5105) 2024-08-21 03:16:22 +00:00
Kim Morrison
0203cb091d feat: more aggressive simp lemmas for List.subset (#5103) 2024-08-21 03:14:23 +00:00
Kim Morrison
f6ce866e39 chore: add mergeSort lemmas (#5107)
Some missing easy lemmas.
2024-08-21 03:03:05 +00:00
Henrik Böving
95549f17da feat: LeanSAT's LRAT parsers + SAT solver interface (#5100)
Step 5/6 in upstreaming LeanSAT.

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
2024-08-20 11:42:26 +00:00
Joachim Breitner
15c6ac2076 chore: restart-on-label: Also filter by commit SHA (#5099) 2024-08-20 07:45:43 +00:00
Kim Morrison
4aa74d9c0b feat: List.mergeSort (#5092)
Defines `mergeSort`, a naive stable merge sort algorithm, replaces it
via a `@[csimp]` lemma with something faster at runtime, and proves the
following results:

* `mergeSort_sorted`: `mergeSort` produces a sorted list.
* `mergeSort_perm`: `mergeSort` is a permutation of the input list.
* `mergeSort_of_sorted`: `mergeSort` does not change a sorted list.
* `mergeSort_cons`: proves `mergeSort le (x :: xs) = l₁ ++ x :: l₂` for
some `l₁, l₂`
so that `mergeSort le xs = l₁ ++ l₂`, and no `a ∈ l₁` satisfies `le a
x`.
* `mergeSort_stable`: if `c` is a sorted sublist of `l`, then `c` is
still a sublist of `mergeSort le l`.
2024-08-20 06:32:52 +00:00
Joachim Breitner
efbecf272d feat: explain reduce steps in trace.Debug.Meta.Tactic.simp (#5054) 2024-08-19 15:05:13 +00:00
Joachim Breitner
78146190e5 feat: mutual recursion: allow common prefix up to alpha-equivalence (#5041)
@arthur-adjedj was very confused when a mutually recursive definition
didn't work as expected, and the reason was that he used different names
for the fixed parameters.

It seems plausible to simply allow that and calculate the fixed-prefix
up to alpha renaming.

It does mean, though, that, for example, termination proof goals will
mention the names as used by the first function. But probably better
than simply failing. And we could even fix that later (by passing down
the
actual names, and renmaing the variables in the context of the mvar,
depending on the “current function”) should it bother our users.
2024-08-19 15:00:03 +00:00
Joachim Breitner
b4db495f98 feat: unify equational theorems between wf and structural recursion (#5055)
by removing the `tryRefl` variation between the two.

Part of #3983
2024-08-19 14:59:15 +00:00
Henrik Böving
9f47e08ecc feat: import LeanSAT LRAT (#5074)
This PR imports LeanSAT's LRAT module as step 4/~6 (step 7 could go
after I did some refactorings to import this) of the LeanSAT
upstreaming. It is the last large component, after this only the LRAT
parser and the reflection tactic that hooks everything up to the meta
level remains. In particular it is the last component that contains
notable proofs, yay!

Again a few remarks:
1. Why is this not in `Std`? I'm not quite sure whether it should be
there. At the current level of code/proof quality we can certainly not
import the checker itself into `Std` but maybe having the data type as
well as the trimming algorithm there might be of interested? I'm hoping
that as we refactor the checker in the future its quality will be high
enough to be also put into `Std`. At this point we would have a full AIG
-> CNF -> LRAT verification pipeline in `Std` for everyone to use. One
additional blocker in this is that we cannot provide the parsers for the
format in `Std` as of today because `Parsec` is still in `Lean` so that
would also have to change.
2. There do exist two abstraction levels to make sure we can swap out
the LRAT implementation at any time:
- The public interface is just all files in the top level `LRAT`
directory. It basically only contains the LRAT format itself, the
checker + soundness proof and the trimming algorithm. As long as we
don't need to change their API (which we shouldn't have to I think) we
can always swap out the entire `Internal` directory without breaking
anything else in LeanSAT.
- The `Internal` module itself contains another layer of abstraction in
the form of the `Formula` class. This allows us to swap out the most
complex component in `Internal` as well, without having to touch any of
the infrastructure that is built around it either.
3. I mostly performed stylistic cleanups on the `Internal` module. In my
experience over upgrading to many nightlies during the course of LeanSAT
development, I have gotten these proofs cleaned up to the point, where
they only break if we change the `List` or `Array` proof API
significantly. Given that we are currently in the process of stabilizing
it I'm hoping that these proofs do not have to be touched anymore unless
we do something crazy. All of the custom theory that the LRAT component
developed around various basic data types has been upstreamed into Lean
over the course of various other PRs.
4. If there are some simple tricks that we can pull off to increase the
code / proof quality in `Internal` and in particular `Internal.Formula`
(this module is not for the light-hearted Lean reviewer) I'm all for it.
Otherwise the best course of action to provide LeanSAT to our users soon
would probably be to merge it as is and do a cut + rewrite at one of the
two interface points described above.
2024-08-19 14:31:00 +00:00
Joachim Breitner
728980443f refactor: rename new option to debug.rawDecreasingByGoal (#5066)
as suggested by @semorrison in 

https://leanprover.zulipchat.com/#narrow/stream/116290-rss/topic/cleanDecreasingBy/near/462659021


Follow-up to #5016.
2024-08-19 11:53:54 +00:00
Sebastian Ullrich
ca945be133 fix: disable incrementality in case .. | .. (#5090) 2024-08-19 09:17:03 +00:00
Eric Wieser
f2573dc51e fix: Do not overwrite existing signal handlers (#5062)
Such handlers can come from address sanitizers and similar. When
combined with #4971, this forward-ports
676b9bc477
/ rust-lang/rust#69685

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-08-19 09:11:38 +00:00
Joachim Breitner
51f01d8c8a feat: expose index option to dsimp tactic (#5071)
makes the option introduced in #4202 also available when using `dsimp`
2024-08-19 07:57:16 +00:00
Matthew Toohey
b486c6748b fix: correct typo in invalid reassignment error (#5080)
Corrects a small typo in the error message for when a user attempts to
mutate something which cannot be mutated.
2024-08-18 08:10:07 +00:00
Kim Morrison
38288ae07a feat: upstream List.Perm (#5069) 2024-08-17 04:11:35 +00:00
Kim Morrison
b939fef2cf chore: fix implicitness in refl/rfl lemma binders (#5077) 2024-08-16 22:31:06 +00:00
Arthur Adjedj
eb15c08ea0 fix: instantiate mvars of indices before instantiating fvars (#4717)
When elaborating the headers of mutual indexed inductive types, mvars
have to be synthesized and instantiated before replacing the fvars
present there. Otherwise, some fvars present in uninstantiated mvars may
be missed and lead to an error later.
Closes #3242 (again)
2024-08-16 15:19:48 +00:00
Joachim Breitner
72f2e7aab1 feat: make structure type clickable in “not a field” error (#5072) 2024-08-16 09:06:18 +00:00
Joachim Breitner
cd21687884 feat: simp debug trace tag to use “dpre” in rlfOnly mode (#5073)
to distinguish from `pre`.
2024-08-16 08:56:38 +00:00
Joachim Breitner
a08ef5ffa2 fix: remove partially copied code comment (#5070) 2024-08-16 08:42:30 +00:00
Joachim Breitner
53e6e99a29 refactor: generalize addMatcherInfo (#5068)
works in any `MonadEnv`.
2024-08-16 06:24:32 +00:00
Kim Morrison
59ca274296 chore: minimize some imports (#5067) 2024-08-16 06:18:11 +00:00
Henrik Böving
ac4927de46 feat: List.foldlRecOn (#5039)
As discussed with @semorrison, feel free to do whatever to the branch.

---------

Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Kim Morrison <kim@tqft.net>
2024-08-15 23:26:06 +00:00
Sebastian Ullrich
0ecbcfdcc3 chore: remove stray markPersistent (#5056)
It is conditionally applied a few lines below
2024-08-15 15:41:42 +00:00
Sebastian Ullrich
4d4d485c19 chore: avoid rebuilding leanmanifest in each build (#5057) 2024-08-15 14:55:36 +00:00
Joachim Breitner
d1174e10e6 feat: always run clean_wf, even before decreasing_by (#5016)
Previously, the tactic state shown at `decreasing_by` would leak lots of
details about the translation, and mention `invImage`, `PSigma` etc.
This is not nice.
  
So this introduces `clean_wf`, which is like `simp_wf` but using
`simp`'s `only` mode, and runs this unconditionally. This should clean
up the goal to a reasonable extent.
  
Previously `simp_wf` was an unrestricted `simp […]` call, but we
probably don’t want arbitrary simplification to happen at this point, so
this now became `simp only` call. For backwards compatibility,
`decreasing_with` begins with `try simp`. The `simp_wf` tactic
is still available to not break too much existing code; it’s docstring
suggests to no longer use it.

With `set_option cleanDecreasingByGoal false` one can disable the use of
`clean_wf`. I hope this is only needed for debugging and understanding.
  
Migration advise: If your `decreasing_by` proof begins with `simp_wf`,
either remove that (if the proof still goes through), or replace with
`simp`.
  
I am a bit anxious about running even `simp only` unconditionally here,
as it may do more than some user might want, e.g. because of options
like `zetaDelta := true`. We'll see if we need to reign in this tactic
some more.

I wonder if in corner cases the `simp_wf` tactic might be able to close
the goal, and if that is a problem. If so, we may have to promote simp’s
internal `mayCloseGoal` parameter to a simp configuration option and use
that here.
  
fixes #4928
2024-08-15 14:42:15 +00:00
Sebastian Ullrich
a43356591c chore: CI: fix 32bit stage 0 builds (#5052)
Let's link stage 0 against libuv in both cases, even if for Emscripten
we won't for stage 1
2024-08-15 12:35:25 +00:00
Sebastian Ullrich
082ed944d8 fix: Windows stage 0 2024-08-15 14:50:56 +02:00
Kim Morrison
36d71f8253 feat: more List.find?/findSome?/findIdx? theorems (#5053) 2024-08-15 11:53:35 +00:00
Lean stage0 autoupdater
3c07e48a33 chore: update stage0 2024-08-15 12:12:52 +00:00
Markus Himmel
8a6eec0047 doc: add release note drafts for LibUV and hash map deprecation (#5049) 2024-08-15 09:10:02 +00:00
Kim Morrison
213a7221f6 feat: more List.Sublist theorems (#5048) 2024-08-15 05:38:25 +00:00
Sebastian Ullrich
42fcfcbad6 fix: macOS: install name of libleanshared_1 (#5034) 2024-08-15 05:22:34 +00:00
Kim Morrison
2ba7c995a6 chore: upstream List.Pairwise lemmas (#5047) 2024-08-15 02:59:05 +00:00
Kim Morrison
7e72f9ab85 chore: add libuv to the required packages heading in macos docs (#5045) 2024-08-15 01:33:58 +00:00
Kim Morrison
326dbd1e15 chore: upstream #time command (#5044) 2024-08-15 00:17:48 +00:00
Markus Himmel
6bc98af67b chore: reduce usage of refine' (#5042) 2024-08-14 15:14:44 +00:00
Sebastian Ullrich
f883fc0db6 chore: clean up cmdline snapshots logic (#5043) 2024-08-14 15:10:37 +00:00
Sebastian Ullrich
20a7fe89b5 perf: mark entire reported info tree as persistent (#5040)
As we can definitely not free it until .ilean generation at the very end
2024-08-14 13:39:35 +00:00
Joachim Breitner
ac64cfd70a fix: array_get_dec etc. tactics to solve more cases (#5037)
Using `Nat.lt_trans` is too restrictive, and using `Nat.lt_of_lt_of_le`
should make this tactic prove more goals.

This fixes a regression probably introduced by #3991; at least in some
cases before that `apply sizeOf_get` would have solved the goal here.
And it’s true that this is now subsumed by `simp`, but because of the
order that `macro_rules` are tried, the too restrictive variant with
`Nat.lt_trans` would be tried before `simp`, without backtracking.

Fixes #5027
2024-08-14 12:41:14 +00:00
Henrik Böving
958ad2b54b feat: upstream LeanSAT's bitblaster (#5013)
Step 3/~7 in upstreaming LeanSAT.

A few thoughts:
- Why is this not in `Std.Sat`? LeanSAT's bitblaster operates on a
limited internal language. For example it has no idea that signed
comparision operators even exist. This is because it relies on a
normalization pass before being given the goal. For this reason I would
not classify the bitblaster as an API that we should publicly advertise
at this abstraction level
- Sometimes I slightly rebuild parts of the LawfulOperator
infrastructure for operators that work non-tail-recursively. This is
because they do not return an `Entrypoint` but instead an
`ExtendingEntrypoint` in order to even be defined in the first place
(casting Ref's and all that). Given the fact that this barely happens
and I never actually commit to rebuilding the full API I'm hoping that
this is indeed a fine decision?
- The single explicit `decreasing_by` that has a simp only which
*almost* looks like `simp_wf` is missing a singular lemma from `simp_wf`
because it doesn't terminate otherwise.
- I am not using functional induction because it basically always fails
at some generalization step, that is also the reason that there is lots
of explicit `generalize` and manually recursive proofs.

---------

Co-authored-by: Markus Himmel <markus@lean-fro.org>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-08-14 09:54:10 +00:00
Lean stage0 autoupdater
bd5f8ef242 chore: update stage0 2024-08-14 09:45:24 +00:00
Sebastian Ullrich
337db03717 fix: report info trees on cmdline for .ileans (#5018)
In #4976, I forgot that we do need info trees eventually on the cmdline
for .ilean generation. Unfortunately, not reporting them incrementally
would require an API change, so let's see what the impact of incremental
reporting is
2024-08-14 08:59:29 +00:00
Markus Himmel
3efd0e4e1f chore: fix inconsistent style in internal hash map lemmas (#5033) 2024-08-14 07:49:11 +00:00
Kim Morrison
8c96d213f3 chore: use local instance in Lsp.Diagnostics (#5031)
I'm experimenting with changing the signature of `Ord.arrayOrd`; rather
than make a local synonym here, let's make a local instance so it
doesn't interact with the experiments.
2024-08-14 05:04:32 +00:00
Kim Morrison
154385fdb9 chore: remove dead code in Lake.Util.Compare (#5030)
While exploring refactors of `List.lt` I ran into errors here, in code
that is entirely unused. Propose cleaning up to get things out of my
way!
2024-08-14 04:59:20 +00:00
Kim Morrison
9e39dc8100 feat: new+old lemmas about List.Sublist (#5029)
Some upstreamed from mathlib, some new.
2024-08-14 04:13:57 +00:00
Markus Himmel
dcadfd1c89 chore: remove oldSectionVars from hash map lemmas (#5023) 2024-08-14 03:04:33 +00:00
Tobias Grosser
7c5d8661f4 feat: add BitVec.toNat_[udiv|umod] and [udiv|umod]_eq (#4997)
Co-authored-by: Siddharth <siddu.druid@gmail.com>
Co-authored-by: Atticus Kuhn <52258164+AtticusKuhn@users.noreply.github.com>
2024-08-14 03:03:31 +00:00
Alex Keizer
bff30fe98e feat: express BitVec.extractLsb' in terms of extractLsb (#5007)
Adds a lemma to rewrite `BitVec.extractLsb'` to `extractLsb` plus a
cast.
Note that `extractLsb'` with a length of 0 returns `BitVec 0`, while
`extractLsb` will never return an empty bitvector (because of the `+ 1`
in it `hi - lo + 1`). Hence, this lemma needs a side condition that the
length is non-zero.

Also adds `getLsb_extractLsb'`

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
2024-08-14 03:01:58 +00:00
Jeremy Tan Jie Rui
ac2dabdedf chore: use in Fin.ne_of_val_ne (#5011)
Instead of a `Not (Eq …)` term use the proper `≠` in `Fin.ne_of_val_ne`,
to make it symmetric with `Fin.val_ne_of_ne`, and move the former to the
same place as the latter.

This answers a query of @eric-wieser at

https://github.com/leanprover-community/mathlib4/pull/15762#discussion_r1714990412
2024-08-14 01:34:47 +00:00
Joachim Breitner
7283e2c14e chore: pr-release: pass --retry to curl (#5025)
Since https://github.com/curl/curl/pull/4465 curl adheres to the
`Retry-After` header, so maybe this fixes the issues with
```
jq: error (at <stdin>:5): Cannot index string with string "body"
```
that sometimes make this workflow fail.
2024-08-13 16:19:43 +00:00
Joachim Breitner
f500af99e8 chore: ci.yaml: build MacOS Aarch64 release for PRs by default (#5022)
should make https://github.com/leanprover-community/mathlib4/pull/13301
unnecessary, which has a fair number of bad side-effects
2024-08-13 15:34:44 +00:00
Joachim Breitner
861ef27503 refactor: state WellFoundedRelation Nat using <, not Nat.lt (#5012)
as that’s the simp normal form.
2024-08-13 13:37:42 +00:00
Joachim Breitner
11be29e68c chore: pr-release: adjust lakefile editing sed to new git syntax (#5014) 2024-08-13 12:03:51 +00:00
Henrik Böving
74f9dea701 feat: use save-always in cache action (#5010)
Follows up on
https://github.com/leanprover/lean4/pull/5003#issuecomment-2284813940
2024-08-13 09:27:15 +00:00
Sebastian Ullrich
041b80a4f5 chore: speedcenter: reduce number of runs for "fast" benchmarks from 10 to 3 (#5009) 2024-08-13 09:06:06 +00:00
Sebastian Ullrich
5bc6496a7c chore: more libuv search patterns for the speedcenter (#5008) 2024-08-13 10:40:09 +02:00
Sebastian Ullrich
f3e7b455bb perf: avoid MT marking environment in language processor (#5004)
#4976 moved resolution of a promise to an earlier point, but that led to
object being marked MT earlier, so we need to move the code that
minimizes those objects earlier too to revert the performance
regression.
2024-08-12 19:15:38 +00:00
Kyle Miller
7cd406f335 fix: check is valid structure projection when pretty printing (#4982)
For structure projections, the pretty printer assumed that the
expression was type correct. Now it checks that the object being
projected is of the correct type. Such terms appear in type mismatch
errors.

Also, fixes and improves `#print` for structures. The types of
projections now use MessageData (so are now hoverable), and the type of
`self` is now the correct type.

Closes #4670
2024-08-12 15:52:17 +00:00
Henrik Böving
ecb35795eb chore: upgrade cache action to silence warnings (#5003)
According to the release notes of cache this should not break anything
as they merely upgraded the node version.
2024-08-12 15:46:53 +00:00
Henrik Böving
dc3eccdf26 feat: Std.Sat.AIG (#4953)
Step 2/~7 in upstreaming LeanSAT.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
Co-authored-by: Siddharth <siddu.druid@gmail.com>
Co-authored-by: Markus Himmel <markus@lean-fro.org>
Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
2024-08-12 14:58:38 +00:00
Markus Himmel
c237c1f9fb feat: link LibUV (#4963) 2024-08-12 12:33:24 +00:00
Sebastian Ullrich
dd4e26f247 feat: output panics into Lean's redirected stderr (#4952)
...unless we are about to kill the process anyway (which is not the
default)

Ensures panics are visible as regular messages in the language server
and properly ordered in relation to other messages on the cmdline
2024-08-12 12:15:15 +00:00
Sebastian Ullrich
c5114c971a fix: Windows needs more LEAN_EXPORTs 2024-08-12 14:14:42 +02:00
Sebastian Ullrich
adc799584c fix: split libleanshared on Windows to avoid symbol limit 2024-08-12 14:14:42 +02:00
Sebastian Ullrich
bbb448cdf6 chore: update stage0 2024-08-12 14:14:42 +02:00
Sebastian Ullrich
9d0302e749 chore: remove LEAN_EXPORT denylist workaround 2024-08-12 14:14:42 +02:00
Sebastian Ullrich
8d12dd87a4 fix: disable incremental body elaboration in presence of where (#5001) 2024-08-12 10:42:19 +00:00
Henrik Böving
da9d44df2d feat: handle \r on all operating systems in IO.FS.lines (#4973)
Closes: #4573
2024-08-12 09:51:50 +00:00
David Thrane Christiansen
5c182bd540 fix: reduce default max depth for ext tactic (#4996)
The prior default of 1000000 could not be achieved in practice, because
the stack would overflow after around 5000 recursive invocations. This
meant that a poorly-chosen @[ext] lemma could crash Lean.

Talking to Mathlib users, it seems that 10 would be a very large number
in practice, so a default limit of 100 should not change successful
uses. But it does make it much easier to diagnose and recover from poor
choices of @[ext] lemmas.
2024-08-12 07:26:32 +00:00
David Thrane Christiansen
ecd3aa4b5d fix: handle SIGBUS when looking for stack overflows (#4971)
Without this change, a stack overflow on Mac OS during tactic execution
can lead to the message:

    terminated by signal SIGBUS (Misaligned address error)

This comes from `lean_alloc_small`. With the change, the process instead
terminates with the more accurate and actionable:

    Stack overflow detected. Aborting.
2024-08-12 07:08:22 +00:00
Kim Morrison
12ca422d86 chore: upstream List.findIdx lemmas (#4995) 2024-08-12 04:11:00 +00:00
Kim Morrison
0a7af630a5 chore: when a linter crashes, prefix its name (#4967)
Helpful for diagnosing which linter is failing, c.f. [recent
problem](https://leanprover.zulipchat.com/#narrow/stream/428973-nightly-testing/topic/quote4/near/457349304)
in quote4.
2024-08-12 02:36:42 +00:00
Kim Morrison
fc5615880e chore: add deprecation for Array.get_modify (#4957) 2024-08-12 02:02:18 +00:00
François G. Dorais
23d898c86b feat: TransGen r is transitive (#4960)
Closes #4959
2024-08-12 02:01:52 +00:00
Tobias Grosser
dfe493d9d8 feat: add BitVec.[sshiftRight/shiftLeft]_*_distrib (#4951)
After having added already `BitVec.ushiftRight_*_distrib`in
https://github.com/leanprover/lean4/pull/4667 for ushiftRight, this PR
now completes the `*_distrib` theorems for shift.
2024-08-12 02:00:58 +00:00
François G. Dorais
759ece7f9e fix: naming convention for UInt lemmas (#4514)
Closes #4513

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-08-12 01:03:21 +00:00
Leonardo de Moura
89c3079072 chore: fix typo in hash code for Expr equality test (#4990)
We observed a small performance improvement at
https://github.com/leanprover/LNSym/blob/proof_size_expt/Proofs/SHA512/Experiments/Sym30.lean
Before: 2.65s
After: 2.60s
2024-08-12 00:47:08 +00:00
Tobias Grosser
37f9063c3e feat: add BitVec.neg_neg (#4977)
.. as well as neg_neq_iff_neq_neg.

---------

Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-08-12 00:34:46 +00:00
Kim Morrison
8364c3e178 chore: begin development cycle for v4.12.0 (#4986) 2024-08-12 00:33:05 +00:00
Kim Morrison
215b4a6a8d fix: omega regression (#4989)
This is a better fix to the problem reported at
https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/nat.20fighting,
which itself had a problem as reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/omega.20regression/near/456539091.
2024-08-12 00:24:24 +00:00
Leonardo de Moura
7d7447563d fix: panic at reducePow (#4988)
closes #4947
2024-08-12 00:20:29 +00:00
Leonardo de Moura
2436562d57 fix: regular mvar assignments take precedence over delayed ones (#4987)
closes #4920
2024-08-12 00:14:38 +00:00
Tobias Grosser
4236d8a85b feat: add Std.[Associative|Commutative] instances for BitVec.[and|or|xor] (#4981) 2024-08-11 09:40:07 +00:00
Kyle Miller
5f31e938c1 feat: @[app_delab] (#4976)
Adds `@[app_delab ident]` as a macro for `@[delab app.ident]`. Resolves
the identifier when expanding the macro, saving needing to use the fully
qualified identifiers that `@[delab]` requires. Also, unlike `@[delab]`,
throws an error if the identifier cannot be resolved.

Closes #4899
2024-08-10 16:54:39 +00:00
Kyle Miller
95bf6793aa fix: make cdot anonymous function notation handle ambiguous notation (#4833)
Fixes an issue where each alternative in choice nodes would get their
own arguments. Now cdot function expansion is aware of choice nodes.

Also modifies the variable naming so that multi-argument functions like
`(· + ·)` expand as `fun x1 x2 => x1 + x2` rather than `fun x x_1 => x +
x_1`.

Closes #4832
2024-08-09 21:16:51 +00:00
Lean stage0 autoupdater
30cf3bb3bf chore: update stage0 2024-08-09 16:16:48 +00:00
Sebastian Ullrich
238885436b fix: resolve parser promise before starting elaboration (#4974)
A regression introduced in #3106 that meant we could actually not
interrupt elaboration of previous document versions but would always
wait on them
2024-08-09 15:38:13 +00:00
David Thrane Christiansen
30a52b794a feat: add [ext] attribute to Array.ext (#4970)
This fixes a minor papercut.
2024-08-09 12:40:39 +00:00
Sebastian Ullrich
5da9038fb4 chore: adapt stdlib to new variable behavior 2024-08-09 11:50:54 +02:00
Sebastian Ullrich
3a588e7547 chore: update stage0 2024-08-09 11:50:54 +02:00
Sebastian Ullrich
9f76cb9aa5 feat: new variable command 2024-08-09 11:50:54 +02:00
Lean stage0 autoupdater
88a7f5c592 chore: update stage0 2024-08-09 08:46:18 +00:00
Kim Morrison
dd6ed124ba chore: upstream Thunk.ext (#4969) 2024-08-09 05:49:13 +00:00
Alok Singh
6dd502321f chore: add parallelism fallback for macOS on build (#4647)
1 less thing to think about.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-08-08 14:26:06 +00:00
David Thrane Christiansen
bcbd7299e9 fix: export more symbols needed by Verso (#4956)
This enables the Verso LSP server extensions to work.
2024-08-08 13:31:34 +00:00
Markus Himmel
b144107ed5 chore: deprecate Lean.HashMap and Lean.HashSet (#4954)
This restores all of the imports of `Lean.Data.HashMap` and
`Lean.Data.HashSet` so that users actually see the deprecation warnings
instead of a "declaration not found" error.
2024-08-08 12:46:10 +00:00
Sebastian Ullrich
c24d2186fc doc: stderrAsMessages is now the default on the cmdline as well (#4955) 2024-08-08 10:28:22 +00:00
Sebastian Ullrich
7ef2d2fea2 chore: CI: remove rebase command
We'll try using the buttons provided by GitHub for now
2024-08-08 11:17:52 +02:00
Henrik Böving
7776852d22 feat: revamp file IO, this time Windows compatible (#4950)
This implements a naive version of `getline` because Windows does not
have `getline`. Given the fact that `FILE` has buffered IO, calling
`fgetc` in a loop is not as big of a performance hazard as it might seem
at first glance.

The proper solution to this would of course be to have our own buffered
IO so we are fully in charge of the buffer. In this situation we could
check the entire buffer for a newline at once instead of char by char.
However that is not going to happen for the near future so I propose we
stay with this implementation. If reading individual lines of a file
does truly end up being the performance bottle neck we have already
won^^.
2024-08-07 22:33:37 +02:00
Markus Himmel
63c4de5fea chore: update stage0 2024-08-07 18:24:42 +02:00
Markus Himmel
3b14642c42 chore: build Lake again 2024-08-07 18:24:42 +02:00
Markus Himmel
d52da36e68 chore: update stage0 2024-08-07 18:24:42 +02:00
Markus Himmel
bf82965eec chore: avoid builing Lake 2024-08-07 18:24:42 +02: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
8b9d27de31 chore: Revert "feat: Revamp file reading and writing" (#4948)
Reverts leanprover/lean4#4906
2024-08-07 16:00:45 +00:00
Henrik Böving
d15f0335a9 feat: setup Std.Sat with definitions of SAT and CNF (#4933)
Step 1 out of approximately 7 to upstream LeanSAT.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
Co-authored-by: Markus Himmel <markus@lean-fro.org>
2024-08-07 15:44:46 +00:00
Sebastian Ullrich
240ebff549 chore: Windows needs more LEAN_EXPORTs (#4941) 2024-08-07 17:13:13 +02:00
Sebastian Ullrich
a29bca7f00 chore: CI: placate linter 2024-08-07 16:52:18 +02:00
Tobias Grosser
313f6b3c74 chore: name variables in Data/BitVec consistently (#4930)
This change canonicalizes the BitVec variable names to `x y z : BitVec`
instead of alternative namings such as `s t : BitVec` or `a b : BitVec`.
Variable names that carry semantic meaning such as `(msbs : BitVec w)
(lsb : Bool)` remain untouched.

This is purely a naming change to make our bitvector proofs more
consistent and polish the (auto-generated) documentation as a very small
step towards polishing the documentation of the BitVec library in Lean.

---------

Co-authored-by: AnotherAlexHere <153999274+AnotherAlexHere@users.noreply.github.com>
2024-08-07 13:43:15 +00:00
Markus Himmel
43fa46412d feat: deprecated variants of hash map query methods (#4943)
#4917 will expose users of the `Lean` API to the renaming of the hash
map query methods. This PR aims to make the transition easier by adding
deprecated functions with the old names.
2024-08-07 13:36:19 +00:00
Henrik Böving
234704e304 feat: upstream utilities around Array, Bool and Prod from LeanSAT (#4945)
Co-authored-by: Kim Morrison <kim@tqft.net>
2024-08-07 12:32:40 +00:00
Sebastian Ullrich
12a714a6f9 chore: CI: fix rebase command 2024-08-07 14:27:53 +02:00
Sebastian Ullrich
cdc7ed0224 chore: CI: fix rebase command 2024-08-07 14:21:43 +02:00
Sebastian Ullrich
217abdf97a chore: CI: fix rebase command 2024-08-07 14:15:18 +02:00
Sebastian Ullrich
490a2b4bf9 chore: CI: fix rebase command 2024-08-07 14:05:00 +02:00
Sebastian Ullrich
84d45deb10 chore: CI: fix rebase 2024-08-07 14:02:57 +02:00
Sebastian Ullrich
f46d216e18 chore: CI: !rebase PR comment command 2024-08-07 13:53:17 +02:00
Tobias Grosser
cc42a17931 feat: add ushiftRight_*_distrib theorems (#4667) 2024-08-07 10:43:54 +00:00
Siddharth
e106be19dd feat: sshiftRight bitblasting (#4889)
We follow the same strategy as
https://github.com/leanprover/lean4/pull/4872,
https://github.com/leanprover/lean4/pull/4571, and implement bitblasting
theorems for `sshiftRight`.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-08-07 10:33:56 +00:00
Sebastian Ullrich
1efd6657d4 test: unflakify test cases (#4940)
With the recent unification of server and cmdline processing,
`IO.Process` tests that previously broke the server because they
directly wrote to stdout are now flaky on the cmdline because
elaboration and reporting are happening in separate threads. By removing
direct writes to stdout, the race condition is removed and the file can
actually be edited in the language server as well again.
2024-08-07 09:34:29 +00:00
Henrik Böving
473b34561d feat: Revamp file reading and writing (#4906)
This PR:
- changes the implementation of `readBinFile` and `readFile` to only
require two system calls (`stat` + `read`) instead of one `read` per
1024 byte chunk.
- fixes a bug where `Handle.getLine` would get tripped up by a NUL
character in the line and cut the string off. This is caused by the fact
that the original implementation uses `strlen` and `lean_mk_string`
which is the backer of `mk_string` does so as well.
- fixes a bug where `Handle.putStr` and thus by extension `writeFile`
would get tripped up by a NUL char in the line and cut the string off.
Cause here is the use of `fputs` when a NUL char is possible.

Closes: #4891 
Closes: #3546
Closes: #3741
2024-08-07 07:39:15 +00:00
Marc Huisinga
574066b30b fix: language server windows issues (#4821)
This PR resolves two language server bugs that especially affect Windows
users:
1. Editing the header could result in the watchdog not correctly
restarting the file worker (#3786, #3787), which would lead to the file
seemingly being processed forever.
- The cause of this issue was a race condition in the watchdog that was
accidentally introduced as far back as #1884: In specific circumstances,
the watchdog will attempt forwarding a message to the file worker after
the process has exited due to a changed header, but before the file
worker exiting has been noticed by the watchdog (which will then restart
the file worker). In this case, the watchdog would mark the file worker
as having crashed and not look at its exit code to restart the file
worker, but instead treat it like a crashed file worker that will only
be restarted when editing the file again. Not inspecting the exit code
of the file worker when it crashed from forwarding a message from the
file worker is necessary since we do not restart the file worker until
another notification from the client arrives, and so we would read the
same crash exit code over and over again in the main loop of the
watchdog if we did not remove it from our list of file workers that we
listen to.
- This PR resolves this issue by distinguishing between "crashes when
forwarding messages to the file worker" and "crashes when forwarding
messages from the file worker". In the former case, we still inspect the
exit code of the file worker and potentially restart it if the imports
changed, whereas in the latter case, we stop inspecting the exit code of
the file worker. This is correct because the latter case is exactly the
one where we need to stop inspecting the exit code but where a crash
cannot occur as a result of a changed header, whereas the former case is
exactly the one where we still need to inspect the exit code after a
crash to ensure that we restart the file worker in case it exited
because the header changed.
- At some point in the future, it would be nice to revamp the
concurrency model of the watchdog entirely now that we have all those
fancy concurrency primitives that were not available four years ago when
the watchdog was first written.

2. On an especially slow Windows machine, we found that starting the
language server would sometimes not succeed at all because reading from
the stdin pipe in the watchdog produced an EINVAL error, which was in
turn caused by an NT "pipe empty" error.
- After lots of debugging, @Kha found that Lake accidentally passes its
stdin to Git because it does not explicitly set the `stdin` field to
`null` when spawning the process.
- Changing this fixes the issue, which suggests that Git may mutate the
pipe we pass to it to be non-blocking, which then causes a "pipe empty"
error in the watchdog when we also attempt to read from that same pipe.
- I'm still very uncertain why we only saw this issue on one
particularly slow machine and not across the whole eco system.

This PR also resolves an issue where we would not correctly emit
messages that we received while the file worker is being restarted to
the corresponding file worker after the restart.

Closes #3786, closes #3787.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-08-07 06:19:33 +00:00
Kim Morrison
1e6d617aad chore: minor fixes to release checklist (#4937) 2024-08-07 01:09:35 +00:00
Leonardo de Moura
c17a4ddc94 perf: skip betaReduceLetRecApps if it is not needed (#4936) 2024-08-07 00:57:35 +00:00
Leonardo de Moura
5be4f5e30c perf: skip eraseRecAppSyntaxExpr if it is not needed (#4935) 2024-08-07 00:29:50 +00:00
Leonardo de Moura
3c5ac9496f perf: expr_eq_fn (#4934)
This PR contains a collection of small optimizations that improve the
equality test for `Expr`.
2024-08-07 00:02:14 +00:00
Kyle Miller
6c1f8a8a63 fix: ensure autoparam errors have correct positions (#4926)
Autoparam tactic scripts have no source positions, which until recently
made it so that any errors or messages would be logged at the current
ref, which was the application or structure instance being elaborated.
However, with the new incrementality features the ref is now carefully
managed to avoid leakage of outside data. This inhibits the elaborator's
ref from being used for the tactic's ref, causing messages to be placed
at the beginning of the file rather than on the syntax that triggered
the autoparam.

To fix this, now the elaborators insert the ref's source position
everywhere into the autoparam tactic script.

If in the future messages for synthetic tactics appear at the tops of
files in other contexts, we should consider an approach where
`Lean.Elab.Term.withReuseContext` uses something like `replaceRef` to
set the ref while disabling incrementality when the tactic does not
contain source position information.

Closes #4880
2024-08-06 22:27:51 +00:00
Matthew Robert Ballard
7bea3c1508 chore: wrap diagnostic results in MessageData.traces (#4897)
Currently, the messages in the diagnostic summaries are created by
appending interpolated strings. We wrap these in `.trace`'s, and the
results are better formatted when expanding child nodes in the info
view. Particularly, the latter diagnostic summaries remain on their own
lines flush to the left instead of on the same line directly adjacent to
the last child node.
2024-08-06 19:10:51 +00:00
Leonardo de Moura
a27d4a9519 chore: reduce stack space usage at instantiate_mvars_fn (#4931) 2024-08-06 17:38:59 +00:00
Leonardo de Moura
4a2fb6e922 chore: fix typo (#4929) 2024-08-06 15:27:20 +00:00
Henrik Böving
b7db82894b feat: generalized Parsec (#4774)
For experimentation by @the-sofi-uwu.

I also have an efficient number parser in LeanSAT that I am planning to
upstream after we have sufficiently bikeshed this change.
2024-08-06 15:17:23 +00:00
Sebastian Ullrich
35e1554ef7 chore: ignore stale leanpkg tests (#4925) 2024-08-06 08:19:33 +00:00
Leonardo de Moura
14d59b3599 feat: theorem diagnostics (#4924)
When `set_option diagnostics true`, for each theorem with size >
`diagnostics.threshold.proofSize`, display proof size, and the number of
applications for each constant symbol.
2024-08-06 01:01:28 +00:00
Leonardo de Moura
a8e480cd52 chore: profile instantiateMVars at MutualDef.lean (#4923)
`instantiateMVars` can be a performance bottleneck when assembling the
final proof term.

For example, it takes approx. 1 second at

https://github.com/leanprover/LNSym/blob/proof_size_expt/Proofs/SHA512/Experiments/Sym30.lean
2024-08-05 19:15:56 +00:00
Leonardo de Moura
d07239d1bd perf: use lean_instantiate_expr_mvars at instantiateExprMVars (#4922)
This PR completes #4915
2024-08-05 19:02:54 +00:00
Leonardo de Moura
590de785cc chore: cleanup betaRev (#4921) 2024-08-05 18:02:20 +00:00
Lean stage0 autoupdater
d671d0d61a chore: update stage0 2024-08-05 17:53:40 +00:00
Leonardo de Moura
8e476e9d22 perf: instantiateExprMVars (#4915)
TODO: 
- Support for `zeta := true` at `apply_beta`.
- Investigate test failure. 
- Break PR in pieces because of bootstrapping issues. The current PR
updates a stage0 file to workaround the issue.

Motivation: significant performance improvement at
https://github.com/leanprover/LNSym/blob/proof_size_expt/Proofs/SHA512/Experiments/Sym30.lean

With M1 Pro:
- Before: 4.56 secs
- After: 3.16 secs

Successfully built stage2 using this PR
2024-08-05 17:15:22 +00:00
Sebastian Ullrich
a3d144a362 feat: new snapshot architecture on the cmdline (#3106)
This is #3014 with cad5cce reverted for testing.
2024-08-05 15:57:42 +00:00
Sebastian Ullrich
87d41e6326 chore: missing include on Windows (#4919) 2024-08-05 15:50:43 +00:00
Kim Morrison
d6cb2432c6 chore: remove unnecessary steps from release checklist (#4914) 2024-08-05 01:57:30 +00:00
Kim Morrison
c0ffc85d75 chore: require docs in BitVec (#4913) 2024-08-05 01:12:04 +00:00
Leonardo de Moura
f62359acc7 perf: use lean_instantiate_level_mvars (#4912)
implemented in C/C++.
Next step: same for `instantiateExprMVars`
2024-08-04 23:21:57 +00:00
Shuhao Song
2d09c96caf chore: cli help text: comma-separate alternative option forms (#4911)
The help message of Lean command line contains
```
--o=oname -o create olean file
```
This may lead to misunderstanding that the command needs both argument
`--o=oname` and `-o`, i. e. `lean --o=test.o -o test.lean`. In the help
message of GNU coreutils, such as `ls`, it is `-a, --all ...`, which
might be better.
Some discussion is on Zulip thread
[https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/The.20help.20message.20of.20Lean.20command.20line](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/The.20help.20message.20of.20Lean.20command.20line).
2024-08-04 22:54:34 +00:00
Lean stage0 autoupdater
21b4377d36 chore: update stage0 2024-08-04 19:11:50 +00:00
Leonardo de Moura
1e9d96be22 perf: add lean_instantiate_level_mvars (#4910)
The new code is not active yet because of bootstrapping issues.
It requires an `update_stage0`.
2024-08-04 18:31:44 +00:00
Leonardo de Moura
647a5e9492 perf: use NatPow Int instead of HPow Int Nat Int (#4903)
This modification improves the performance of the example in issue
#4861. It no longer times out but is still expensive.

Here is the analysis of the performance issue: Given `(x : Int)`, to
elaborate `x ^ 1`, a few default instances have to be tried.

First, the homogeneous instance is tried and fails since `Int` does not
implement `Pow Int`. Then, the `NatPow` instance is tried, and it also
fails. The same process is performed for each term of the form `p ^ 1`.
There are seveal of them at #4861. After all of these fail, the lower
priority default instance for numerals is tried, and `x ^ 1` becomes `x
^ (1 : Nat)`. Then, `HPow Int Nat Int` can be applied, and the
elaboration succeeds. However, this process has to be repeated for every
single term of the form `p ^ 1`. The elaborator tries all homogeneous
`HPow` and `NatPow` instances for all `p ^ 1` terms before trying the
lower priority default instance `OfNat`.

This commit ensures `Int` has a `NatPow` instance instead of `HPow Int
Nat Int`. This change shortcuts the process, but it still first tries
the homogeneous `HPow` instance, fails, and then tries `NatPow`. The
elaboration can be made much more efficient by writing `p ^ (1 : Nat)`.
2024-08-03 00:35:04 +00:00
Clement Courbet
9c4028aab4 perf: avoid expr copies in replace_rec_fn::apply (#4702)
Those represent ~13% of the time spent in `save_result`,
even though `r` is a temporary in all cases but one.

See #4698 for details.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-08-02 18:32:36 +00:00
Clement Courbet
2c002718e0 perf: fix implementation of move constructors and move assignment ope… (#4700)
…rators

Right now those constructors result in a copy instead of the desired
move. We've measured that expr copying and assignment by itself uses
around 10% of total runtime on our workloads.

See #4698 for details.
2024-08-02 17:55:03 +00:00
Sebastian Ullrich
b07384acbb feat: accept user-defined options on the cmdline (#4741)
Initial options are now re-parsed and validated after importing. Cmdline
option assignments prefixed with `weak.` are silently discarded if the
option name without the prefix does not exist.

Fixes #3403
2024-08-02 12:24:56 +00:00
Sebastian Ullrich
efc99b982e chore: deprecate Nix-based build, remove interactive components (#4895)
Users who prefer the flake build should maintain it externally
2024-08-02 09:57:34 +00:00
Siddharth
ee430b6c80 feat: getLsb_replicate (#4873)
This allows bitblasting `BitVec.replicate`.

I changed the definition of `BitVec.replicate` to use `BitVec.cast` in
order to make the proof smoother, since it's an easier time simplifying
away terms with `BitVec.cast`.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-08-01 23:07:19 +00:00
Alok Singh
a8740f5ed9 doc: add docstring to IO.FS.realpath (#4648)
Based on `IO.FS.rename` template.
2024-08-01 14:00:54 +00:00
Sebastian Ullrich
5e6a3cf5f9 chore: revert "fix: make import resolution case-sensitive on all platforms" (#4896)
Reverts leanprover/lean4#4538 because of unexpected overhead
2024-08-01 13:55:37 +00:00
Sebastian Ullrich
0ed1cf7244 fix: LEAN_EXPORT in sharecommon (#4893) 2024-08-01 13:03:25 +02:00
Lean stage0 autoupdater
e83f78d5af chore: update stage0 2024-08-01 06:54:29 +00:00
David Thrane Christiansen
32b9de8c77 fix: export symbols needed by Verso (#4884)
Verso needed a symbol that was unexported - this exposes it again.
2024-08-01 04:56:27 +00:00
Leonardo de Moura
a856016b9d perf: precise cache for expr_eq_fn (#4890)
This performance issue was exposed by the benchmarks at
https://github.com/leanprover/LNSym/tree/proof_size_expt/Proofs/SHA512/Experiments
2024-08-01 02:56:41 +00:00
Siddharth
c517688f1d feat: ushiftRight bitblasting (#4872)
This adds theorems `ushiftRight_rec_zero`, `ushiftRight_rec_succ`,
`ushiftRight_rec_eq`, and `shiftRight_eq_shiftRight_rec`.

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
2024-07-31 21:44:06 +00:00
Leonardo de Moura
db594425bf refactor: sharecommon (#4887)
This PR also fixes a missing borrow annotation.
2024-07-31 19:13:12 +00:00
Kim Morrison
dcea47db02 chore: shorten suggestion about diagnostics (#4882)
This message is often incorporated into source files via `#guard_msgs`.
This change ensures it won't go over the 100 character ruler, and I
think is equally grammatical. :-)
2024-07-31 17:56:43 +00:00
Siddharth
f869902a4b feat: Nat simprocs for simplifying bit expressions (#4874)
This came up in the context of simplifying proof states for
https://github.com/leanprover/LNSym.
2024-07-31 17:26:05 +00:00
Sebastian Ullrich
d5a8c9647f fix: make import resolution case-sensitive on all platforms (#4538)
Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-07-31 16:48:14 +00:00
Sebastian Ullrich
d19bab0c27 feat: include command (#4883)
To be implemented in #4814
2024-07-31 13:25:54 +00:00
Sebastian Ullrich
6a4159c4a7 refactor: split out Lean.Language.Lean.Types (#4881) 2024-07-31 09:50:12 +00:00
Kim Morrison
8acdafd5b3 chore: correct doc-string for Array.swap! (#4869) 2024-07-31 04:02:30 +00:00
Kim Morrison
688da9d8a7 chore: updates to release_checklist.md (#4876)
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-07-31 04:02:19 +00:00
Kyle Miller
d5e7dbad80 fix: make "use `set_option diagnostics true" message conditional on current setting (#4781)
It is confusing that the message suggesting to use the `diagnostics`
option is given even when the option is already set. This PR makes use
of lazy message data to make the message contingent on the option being
false.

It also tones down the promise that there is any diagonostic information
available, since sometimes there is nothing to report.

Suggested by Johan Commelin.
2024-07-31 03:53:09 +00:00
Kyle Miller
82f48740dc chore: copy release notes from releases/v4.10.0 (#4864)
This also updates the 4.9.0 release notes with backported changes.
2024-07-31 03:30:13 +00:00
Kyle Miller
a827759f1d fix: mistake in statement of List.take_takeWhile (#4875)
This theorem is meant to say that `List.take` and `List.takeWhile`
commute.
2024-07-31 03:29:34 +00:00
Kim Morrison
a4015ca36c chore: rename PSigma.exists (#4878) 2024-07-31 03:26:17 +00:00
Kim Morrison
81719f94c9 chore: fix binder explicitness in List.map_subset (#4877) 2024-07-31 03:03:52 +00:00
Leonardo de Moura
afe0b5a013 perf: precise cache for foldConsts (#4871)
It addresses a performance issue at
https://github.com/leanprover/LNSym/blob/proof_size_expt/Proofs/SHA512/Experiments/Sym20.lean
2024-07-30 18:35:45 +00:00
Kim Morrison
90dab5e267 chore: fix naming of List.Subset lemmas (#4868) 2024-07-30 09:21:23 +00:00
Kim Morrison
6a904f2c85 chore: upstream List.eraseIdx lemmas (#4865) 2024-07-30 06:59:45 +00:00
Kim Morrison
2c396d6424 chore: upstream List.pairwise_iff_getElem (#4866) 2024-07-30 06:55:29 +00:00
Kim Morrison
69f86d6478 chore: split Init.Data.List.Lemmas (#4863)
Init.Data.List.Lemmas had reached 5000 lines: splitting into
function-specific files.
2024-07-30 03:17:34 +00:00
Joachim Breitner
4ea55687a5 refactor: deriving DecidableEq to use termination_by structural (#4826)
now that we support structural mutual recursion, I expect that every
`DecidableEq` instance be implemented using structural recursion, so
let's be explicit about it.
2024-07-29 21:24:05 +00:00
Kyle Miller
69c71f6476 fix: make elabAsElim aware of explicit motive arguments (#4817)
Some eliminators (such as `False.rec`) have an explicit motive argument.
The `elabAsElim` elaborator assumed that all motives are implicit.

If the explicit motive argument is `_`, then it uses the elab-as-elim
procedure, and otherwise it falls back to the standard app elaborator.

Furthermore, if an explicit elaborator is not provided, it falls back to
treating the elaborator as being implicit, which is convenient for
writing `h.rec` rather than `h.rec _`. Rationale: for `False.rec`, this
simulates it having an implicit motive, and also motives are generally
not going to be available in the expected type.

Closes #4347
2024-07-29 19:18:47 +00:00
Kyle Miller
7f128b39e7 feat: more than one optional argument can be omitted while pretty printing (#4854)
Before, the delaborator was conservative about omitting optional
arguments, only omitting the very last one. Now it can omit arbitrarily
long sequences of optional arguments from the end.

For simplicity of implementation, every optional argument is delaborated
and then potentially discarded. It could save state and lazily
delaborate, but we're running under the hypothesis that most optional
arguments are for very simple values (like `true`, `false`, or a numeric
literal), so it is unlikely that efficiency gains, if any, are worth it.
In particular, in the future structure constructors will have optional
arguments, but `unexpandStructureInstance` assumes none of the optional
fields are omitted.

Closes #4812
2024-07-29 19:02:39 +00:00
Kim Morrison
a845a007ac chore: fix universe in PSigma.exists (#4862) 2024-07-29 12:30:31 +00:00
Sebastian Ullrich
abf4206e9c chore: CI: fix msys2 2024-07-29 10:25:59 +02:00
Kim Morrison
83ad82162f feat: upstream more List lemmas (#4856) 2024-07-28 23:23:59 +00:00
arthur-adjedj
93ac635a89 chore: fix parenthesizing in test 2024-07-29 08:58:49 +10:00
Kim Morrison
642c28cdbb chore: update stage0 2024-07-29 08:58:49 +10:00
arthur-adjedj
a04f3cab5a fix: reduction behaviour of derived BEq instances
fix: forgot an assignation
2024-07-29 08:58:49 +10:00
arthur-adjedj
86af04cc08 fix: handle dependent fields when deriving BEq 2024-07-29 08:58:49 +10:00
arthur-adjedj
7253ef8751 chore: inverse rhs construction order in BEq's handler 2024-07-29 08:58:49 +10:00
Joachim Breitner
f830fc9f4d refactor: IndPredBelow: use apply_assumption (#4841)
when transforming the `match` statements in `IndPredBelow`, given a
local variable `x : T`, we need to search for `hx : T.below x`.
Previously this was done using the custom `backwardsChaining` method,
although my hypothesis is that we don’t need to chain anything here, and
can use `apply_assumption`.
2024-07-28 17:22:54 +00:00
Joachim Breitner
671ce7afd3 fix: IndPred: track function's motive in a let binding, use withoutProofIrrelevance, no chaining (#4839)
this improves support for structural recursion over inductive
*predicates* when there are reflexive arguments.

Consider
```lean
inductive F: Prop where
  | base
  | step (fn: Nat → F)

-- set_option trace.Meta.IndPredBelow.search true
set_option pp.proofs true

def F.asdf1 : (f : F) → True
  | base => trivial
  | step f => F.asdf1 (f 0)
termination_by structural f => f`
```

Previously the search for the right induction hypothesis would fail with
```
could not solve using backwards chaining x✝¹ : F
x✝ : x✝¹.below
f : Nat → F
a✝¹ : ∀ (a : Nat), (f a).below
a✝ : Nat → True
⊢ True
```

The backchaining process will try to use `a✝ : Nat → True`, but then has
no idea what to use for `Nat`.

There are three steps here to fix this.

1. We let-bind the function's type before the whole process. Now the
   goal is

   ```
   funType : F → Prop := fun x => True
   x✝ : x✝¹.below
   f : Nat → F
   a✝¹ : ∀ (a : Nat), (f a).below
   a✝ : ∀ (a : Nat), funType (f a)
   ⊢ funType (f 0)
   ```
2. Instead of using the general purpose backchaining proof search, which
is more
powerful than we need here (we need on recursive search and no
backtracking),
   we have a custom search that looks for local assumptions that 
   provide evidence of `funType`, and extracts the arguments from that
   “type” application to construct the recursive call.

   Above, it will thus unify `f a =?= f 0`.

3. In order to make progress here, we also turn on use
`withoutProofIrrelevance`,
because else `isDefEq` is happy to say “they are equal” without actually
looking
   at the terms and thus assigning `?a := 0`.

This idea of let-binding the function's motive may also be useful for
the other recursion compilers, as it may simplify the FunInd
construction. This is to be investigated.

fixes #4751
2024-07-28 17:22:27 +00:00
Kim Morrison
87c92a3f87 feat: upstream more List operations (#4855)
Upstreams `tail`, `findIdx`, `indexOf`, `countP`, `count`, `range'` from
Batteries.
2024-07-28 04:52:21 +00:00
Ikko Eltociear Ashimine
15bf41cd67 chore: update Topological.lean (#4853)
minor fix
2024-07-27 18:14:42 +00:00
Kyle Miller
906bc583c5 fix: handle unimported builtin names for location links (#4780)
The function `locationLinksFromDecl` could throw an error if the name it
is provided doesn't exist in the environment, which is possible if for
example an elaborator is a builtin.

Closes #3789
2024-07-27 17:39:39 +00:00
Kim Morrison
ea43ebd54a chore: cleanups for Mathlib.Init (#4852)
It is convenient to adjust some attributes here, to allow easier cleanup
in `Mathlib.Init`.
2024-07-27 07:37:17 +00:00
Siddharth
bb9c9bd99f feat: bitVec shiftLeft recurrences for bitblasting (#4571)
```lean 
@[simp]
theorem shiftLeftRec_zero (x : BitVec w₁) (y : BitVec w₂) :
    shiftLeftRec x y 0 = x <<< (y &&& twoPow w₂ 0)  := by
  simp [shiftLeftRec]

@[simp]
theorem shiftLeftRec_succ (x : BitVec w₁) (y : BitVec w₂) :
    shiftLeftRec x y (n + 1) =
      (shiftLeftRec x y n) <<< (y &&& twoPow w₂ (n + 1)) := by
  simp [shiftLeftRec]

theorem shiftLeftRec_eq (x : BitVec w₁) (y : BitVec w₂) (n : Nat) (hn : n + 1 ≤ w₂) :
  shiftLeftRec x y n = x <<< (y.truncate (n + 1)).zeroExtend w₂ := by
```

These theorems are used for bitblasting shiftLeft in LeanSAT.

---------

Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Kim Morrison <scott@tqft.net>
Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-07-27 06:36:52 +00:00
Mac Malone
fe5894f2f6 feat: lake: CLI options to control output & failure log levels (#4847)
Adds the `--log-level=<lv>` CLI option for controlling the minimum log
level Lake should output. For instance, `--log-level=error` will only
print errors (not warnings or info).

Also, adds the parallel `--fail-level` CLI option to control what the
minimum log level of build failures is. The existing `--iofail` and
`--wfail` options are equivalent to `--fail-level=info` and
`--fail-level=warning` , respectively.

Closes #4805,
2024-07-27 06:16:59 +00:00
Mac Malone
3ecbf4ae2d doc: lake: require @ git in README (#4849)
Demonstrates `require @ git` in Lake's README and tweaks related
documentation.
2024-07-27 02:44:50 +00:00
Sebastian Ullrich
9b342efb84 fix: calling programs with spaces on Windows (#4515)
This entire API has been carefully optimized for maximum pain output

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-07-26 17:35:05 +00:00
Sebastian Ullrich
c02aa98c6a doc: triage 2024-07-26 18:24:06 +02:00
Kim Morrison
18ba5f24e1 chore: correct List.Subset lemma names (#4843) 2024-07-26 11:36:28 +00:00
Kim Morrison
cbe39dc4bb chore: fix List deprecations (#4842) 2024-07-26 11:32:18 +00:00
Joachim Breitner
a5b8d5b486 chore: upon nightly release, trigger nightly_bump_toolchain on mathlib4 (#4838)
as discussed at
https://leanprover.zulipchat.com/#narrow/stream/428973-nightly-testing/topic/Bumping.20more.20often/near/453976634
2024-07-26 06:51:19 +00:00
Kim Morrison
895391b73f feat: List.IsPrefix/IsSuffix is decidable (#4837) 2024-07-26 05:17:41 +00:00
Kim Morrison
e280de00b6 feat: gaps/cleanup in List lemmas (#4835) 2024-07-26 05:00:50 +00:00
Kim Morrison
8c87a90cea chore: upstream IsPrefix/IsSuffix/IsInfix (#4836)
Further lemmas to follow; this is the basic material from Batteries.
2024-07-26 04:35:36 +00:00
Joachim Breitner
54c22efca1 fix: structural recursion: do not check for brecOn too early (#4831)
Due to nested recursion, we do two passes of `getRecArgInfo`: One on
each argument in isolation, to see which inductive types are around
(e.g. `Tree` and `List`), and
then we later refine/replace this result with the data for the nested
type former (the implicit `ListTree`).

If we have nested recursion through a non-recursive data type like
`Array` or `Prod` then arguemnts of these types should survive the first
phase, so that we can still use them when looking for, say, `Array
Tree`.

This was helpfully reported by @arthur-adjedj.
2024-07-25 15:25:34 +00:00
Joachim Breitner
d4f2db9559 chore: report github actions failure on zulip (#4830)
only the master branch
2024-07-25 11:15:33 +00:00
Joachim Breitner
39e0b41fe1 test: make #1697 test case Linux-Debug safe (#4829) 2024-07-25 10:26:01 +00:00
Marc Huisinga
84f8871c3f fix: filter duplicate subexpressions (#4786)
For every parenthesized expression `(foo)`, the InfoView produces an
interactive component both for `(foo)` itself and its subexpression
`foo` because the corresponding `TaggedText` in the language server is
duplicated as well. Both of these subexpressions have the same
subexpression position and so they are identical w.r.t. interactive
features.

Removing this duplication would help reduce the size of the DOM of the
InfoView and ensure that the UI for InfoView features is consistent for
`(foo)` and `foo` (e.g. hovers would always highlight `(foo)`, not
either `(foo)` or `foo` depending on whether the mouse cursor is on the
bracket or not). It would also help resolve a bug where selecting a
subexpression will yield selection highlighting both for `(foo)` and
`foo`, as we use the subexpression position to identify which terms to
highlight.

This PR adjusts the parenthesizer to move the corresponding info instead
of duplicating it.
2024-07-25 08:58:49 +00:00
Austin Letson
93fa9c8837 feat: create ci workflow on lake new/init (#4608)
Draft of adding ci workflow using lean-action on `lake new/init`

This PR is currently missing lake options for the user to control this
feature.

Closes #4606

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-07-25 01:23:54 +00:00
Sebastian Ullrich
0768ad4eb9 chore: CI: Jira sync 2024-07-24 19:52:55 +02:00
Kyle Miller
c545e7b0c9 fix: make sure anonymous dot notation works with pi-type-valued type synonyms (#4818)
When resolving anonymous dot notation (`.ident x y z`), it would reduce
the expected type to whnf. Now, it unfolds definitions step-by-step,
even if the type synonym is for a pi type like so
```lean
def Foo : Prop := ∀ a : Nat, a = a
protected theorem Foo.intro : Foo := sorry
example : Foo := .intro
```

Closes #4761
2024-07-24 17:09:42 +00:00
Sebastian Ullrich
7b3c64fc85 feat: trailing whitespace changes should not invalidate imports (#4580)
Thus, starting to type the first declaration after the imports should
not make them reload
2024-07-24 13:08:01 +00:00
Sebastian Ullrich
af0b563099 feat: respond to info view requests as soon as relevant tactic has finished execution (#4727)
After each tactic step, we save the info tree created by it together
with an appropriate info tree context that makes it stand-alone (which
we already did before to some degree, see `Info.updateContext?`). Then,
in the adjusted request handlers, we first search for a snapshot task
containing the required position, if so wait on it, and if it yielded an
info tree, use it to answer the request, or else continue searching and
waiting, falling back to the full info tree, which should be unchanged
by this PR.

The definition header does *not* report info trees early as in general
it is not stand-alone in the tactic sense but may contain e.g.
metavariables solved by the body in which case we do want to show the
ultimate state as before. This could be refined in the future in case
there are no unsolved mvars.

The adjusted request handlers are exactly the ones waited on together by
the info view, so they all have to be adjusted to have any effect on the
UX. Further request handlers may be adjusted in the future.

No new tests as "replies early" is not something we can test with our
current framework but the existing test suite did help in uncovering
functional regressions.
2024-07-24 13:02:13 +00:00
Sebastian Ullrich
af40e61811 chore: typo 2024-07-24 15:11:54 +02:00
Kim Morrison
1758b37a71 chore: List.filterMapM runs and returns left-to-right (#4820)
Closes #4676. Previously `List.filterMapM` was returning results
left-to-right, but evaluating right-to-left.
2024-07-24 09:00:10 +00:00
Joachim Breitner
3701bee777 test: test case for #4751 (#4819)
and tracing for `IndPredBelow.backwardsChaining`.
2024-07-24 08:14:25 +00:00
Sebastian Ullrich
6d971827e2 chore: CI: add back dropped check-stage3 2024-07-24 09:03:11 +02:00
Joachim Breitner
871c9b4164 test: update test output following stage0 update (#4815)
this is a consequenc of #4807 that only shows up once that change made
it to stage0, it seem.
2024-07-23 21:43:38 +00:00
Lean stage0 autoupdater
ee6737ab4d chore: update stage0 2024-07-23 16:14:57 +00:00
Joachim Breitner
7d60d8b563 feat: safer #eval, and #eval! (#4810)
previously, `#eval` would happily evaluate expressions that contain
`sorry`, either explicitly or because of failing tactics. In conjunction
with operations like array access this can lead to the lean process
crashing, which isn't particularly great.

So how `#eval` will refuse to run code that (transitively) depends on
the `sorry` axiom (using the same code as `#print axioms`).

If the user really wants to run it, they can use `#eval!`.

Closes #1697
2024-07-23 15:26:56 +00:00
Joachim Breitner
a4673e20a5 chore: release notes for mutual structural induction (#4808) 2024-07-23 07:40:29 +00:00
Marc Huisinga
b2ee8c240d doc: update quickstart guide (#4806)
This PR updates the screenshots and instructions in the quickstart guide
for the most recent Lean 4 VS Code extension version and makes a small
stylistic change suggested by @semorrison.
2024-07-23 07:31:21 +00:00
Markus Himmel
5d632a97b8 feat: more hash map lemmas (#4803) 2024-07-23 06:57:44 +00:00
Kyle Miller
5938dbbd14 fix: make elab_as_elim eagerly elaborate arguments for parameters appearing in the types of targets (#4800)
The `elab_as_elim` elaborator eagerly elaborates arguments that can help
with elaborating the motive, however it does not include the transitive
closure of parameters appearing in types of parameters appearing in ...
types of targets.

This leads to counter-intuitive behavior where arguments supplied to the
eliminator may unexpectedly have postponed elaboration, causing motives
to be type incorrect for under-applied eliminators such as the
following:

```lean
class IsEmpty (α : Sort u) : Prop where
  protected false : α → False

@[elab_as_elim]
def isEmptyElim [IsEmpty α] {p : α → Sort _} (a : α) : p a :=
  (IsEmpty.false a).elim

example {α : Type _} [IsEmpty α] :
  id (α → False) := isEmptyElim (α := α)
```

The issue is that when `isEmptyElim (α := α)` is computing its motive,
the value of the postponed argument `α` is still an unassignable
metavariable. With this PR, this argument is now among those that are
eagerly elaborated since it appears as the type of the target `a`.

This PR also contains some other fixes:
* When underapplied, does unification when instantiating foralls in the
expected type.
* When overapplied, type checks the generalized-and-reverted expected
type.
* When collecting targets, collects them in the correct order.

Adds trace class `trace.Elab.app.elab_as_elim`.

This is a followup to #4722, which added motive type checking but
exposed the eagerness issue.
2024-07-22 23:23:28 +00:00
grunweg
852add3e55 doc: document Command.Scope (#4748)
Also extends existing definition for `getScope`/`getScopes` and
clarifies that the `end` command is optional at the end of a file.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-07-22 21:55:37 +00:00
Joachim Breitner
20c857147c feat: unnecessary termination_by clauses cause warnings, not errors (#4809)
fixes #4804
2024-07-22 20:52:14 +00:00
Joachim Breitner
9f1eb479b0 feat: functional induction for mutual structural recursion (#4772) 2024-07-22 15:10:11 +00:00
Markus Himmel
92cca5ed1b chore: remove bif from hash map lemmas (#4791)
The original idea was to use `bif` in computation contexts and `if` in
propositional contexts, but this turned out to be really inconvenient in
practice.
2024-07-22 14:39:00 +00:00
Joachim Breitner
3a4d2cded3 refactor: Introduce PProdN module (#4807)
code to create nested `PProd`s, and project out, and related functions
were scattered in variuos places. This unifies them in
`Lean.Meta.PProdN`.

It also consistently avoids the terminal `True` or `PUnit`, for slightly
easier to read constructions.
2024-07-22 11:56:50 +00:00
Joachim Breitner
22ae04f3e7 refactor: FunInd overhaul (#4789)
This refactoring PR changes the structure of the `FunInd` module, with
the main purpose to make it easier to support mutual structural
recursion.

In particular the recursive calls are now longer recognized by their
terms (simple for well-founded recursion, `.app oldIH [arg, proof]`, but
tedious for structural recursion and even more so for mutual structural
recursion), but the type after replacing `oldIH` with `newIH`, where the
type will be simply and plainly `mkAppN motive args`).

We also no longer try to guess whether we deal with well-founded or
structural recursion but instead rely on the `EqnInfo` environment
extensions. The previous code tried to handle both variants, but they
differ too much, so having separate top-level functions is easier.

This also fuses the `foldCalls` and `collectIHs` traversals and
introduces a suitable monad for collecting the inductive hypotheses.
2024-07-21 14:46:52 +00:00
François G. Dorais
99f362979b feat: use usize for array types (#4802)
This is part 2 of 2 of #4801 (which closes #4654). That PR was split in
two to allow a stage0 update between declaring the `usize` functions and
using them where they are needed.
2024-07-21 12:26:04 +00:00
Lean stage0 autoupdater
3a309f7691 chore: update stage0 2024-07-21 11:05:36 +00:00
François G. Dorais
8f0631ab1f feat: usize for array types (#4801)
Add efficient `usize` functions for `Array`, `ByteArray`, `FloatArray`.

This is part 1 of 2 since there is a need to update stage0 between the
two parts. (See discussion below.)

Closes #4654
2024-07-21 10:23:49 +00:00
Markus Himmel
08acf5a136 fix: remove typeclass assumptions for Nodup.eraseP (#4790)
The `α` in the typeclass assumptions wasn't even the element type of the
list.
2024-07-21 07:51:42 +00:00
Markus Himmel
bdfaa00b1e doc: remove reference to HashMap.find? from Option docstring (#4782) 2024-07-21 07:51:06 +00:00
Leonardo de Moura
8ceb24a5e6 perf: Expr.replace (#4799)
use the kernel implementation.
2024-07-20 04:53:43 +00:00
Lean stage0 autoupdater
201749ccac chore: update stage0 2024-07-20 04:31:11 +00:00
Leonardo de Moura
d0bc4e4245 fix: replace_fn.cpp (#4798) 2024-07-19 21:20:43 -07:00
Lean stage0 autoupdater
c2117d75a6 chore: update stage0 2024-07-20 03:58:16 +00:00
Leonardo de Moura
3477b0e7f6 fix: for_each_fn.cpp (#4797) 2024-07-20 03:22:56 +00:00
Lean stage0 autoupdater
696f70bb4e chore: update stage0 2024-07-20 02:35:13 +00:00
Leonardo de Moura
726e162527 perf: kernel replace with precise cache (#4796)
Changes:

- We avoid the thread local storage.
- We use a hash map to ensure that cached values are not lost.
- We remove `check_system`. If this becomes an issue in the future we
should precompute the remaining amount of stack space, and use a cheaper
check.
- We add a `Expr.replaceImpl`, and will use it to implement
`Expr.replace` after update-stage0
2024-07-20 02:00:29 +00:00
Leonardo de Moura
de5e07c4d2 perf: find? and findExt? (#4795)
use the kernel implementation.
2024-07-20 01:13:54 +00:00
Lean stage0 autoupdater
327986e6fb chore: update stage0 2024-07-20 00:51:23 +00:00
Leonardo de Moura
6c33b9c57f perf: for_each with precise cache (#4794)
This commit also adds support for `find?` and `findExt?` using kernel
`for_each`.
We need to perform `update-stage0`.
2024-07-20 00:18:55 +00:00
Henrik Böving
d907771fdd feat: theory from LeanSAT (#4742)
Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
2024-07-19 16:21:03 +00:00
Leonardo de Moura
5c3360200e fix: add term elaborator for Lean.Parser.Term.namedPattern (#4792)
closes #4662
2024-07-19 16:14:32 +00:00
Joachim Breitner
204d4839fa refactor: add numFixed to Structural.EqnInfo (#4788) 2024-07-19 10:21:43 +00:00
Joachim Breitner
e32f3e8140 refactor: IndGroupInst.brecOn (#4787)
this logic fits nicely within `IndGroupInst`.

Also makes `isAuxRecursorWithSuffix` recognize `brecOn_<n>`.
2024-07-19 10:20:50 +00:00
Sebastian Ullrich
7d2155943c doc: fix integer division example
Fixes #4785
2024-07-19 10:36:43 +02:00
Lean stage0 autoupdater
78c4d6daff chore: update stage0 2024-07-18 20:38:21 +00:00
Leonardo de Moura
5526ff6320 chore: Simp.Config.implicitDefEqProofs := true by default (#4784)
Motivation: unblock PR #4595
`Simp.Config.implicitDefEqProofs := false` is currently creating too
many issues in Mathlib.
2024-07-18 19:10:18 +00:00
Leonardo de Moura
bfca7ec72a fix: .eq_def theorem generation with messy universes (#4712)
closes #4673
2024-07-18 17:34:23 +00:00
Leonardo de Moura
9208b3585f chore: document replaceUnsafeM issue (#4783) 2024-07-18 16:26:20 +00:00
Leonardo de Moura
a94805ff71 perf: ensure Expr.replaceExpr preserve DAG structure in Exprs (#4779) 2024-07-18 02:24:15 +00:00
Lean stage0 autoupdater
4eb842560c chore: update stage0 2024-07-18 01:19:02 +00:00
Kyle Miller
490d16c80d fix: have elabAsElim check inferred motive for type correctness (#4722)
Declarations with `@[elab_as_elim]` could elaborate as type-incorrect
expressions. Reported by Jireh Loreaux [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/bug.20in.20revert/near/450522157).

(In principle the elabAsElim routine could revert fvars appearing in the
expected type that depend on the discriminants (if the discriminants are
fvars) to increase the likelihood of type correctness, but that's at the
cost of some complexity to both the elaborator and to the user.)
2024-07-17 20:48:03 +00:00
Leonardo de Moura
f60721bfbd feat: add some low level helper APIs (#4778) 2024-07-17 20:12:05 +00:00
Kyle Miller
a5ecdd0a17 feat: improve @[ext] error message when ext_iff generation fails (#4762)
Now it suggests using `@[ext (iff := false)]` to disable generating the
`ext_iff` lemma.

This PR also adjusts error messages and attribute documentation.
Additionally, to simplify the code now the `x` and `y` arguments can't
come in reverse order (this feature was was added in the refactor
#4543).

Closes #4758
2024-07-17 18:26:12 +00:00
Leonardo de Moura
be717f03ef fix: missing assignment validation at closeMainGoal (#4777)
This primitive is used by the `exact` tactic. This issue allowed users
to create loops in the metavariable assignment.

closes #4773
2024-07-17 18:25:02 +00:00
Leonardo de Moura
41b4914836 perf: Replacement.apply (#4776)
Avoid potentially expensive `e.replace` if it is not applicable.
2024-07-17 16:17:47 +00:00
Leonardo de Moura
933445608c chore: simplify shareCommon' (#4775) 2024-07-17 15:32:35 +00:00
Markus Himmel
8e396068e4 doc: mention linearity in hash map docstring (#4771) 2024-07-17 09:26:38 +00:00
Markus Himmel
c1df7564ce fix: resolve instances for HashMap via unification (#4759) 2024-07-17 08:02:22 +00:00
Markus Himmel
ba3565f441 chore: fix BEq argument order in hash map lemmas (#4732)
The previous argument order was a conscious choice, but I had missed
#3056.
2024-07-17 04:25:21 +00:00
Kim Morrison
af03af5037 feat: simprocs for #[1,2,3,4,5][2] (#4765)
None of these were working previously:

```
#check_simp #[1,2,3,4,5][2]  ~> 3
#check_simp #[1,2,3,4,5][2]? ~> some 3
#check_simp #[1,2,3,4,5][7]? ~> none
#check_simp #[][0]? ~> none
#check_simp #[1,2,3,4,5][2]! ~> 3
#check_simp #[1,2,3,4,5][7]! ~> (default : Nat)
#check_simp (#[] : Array Nat)[0]! ~> (default : Nat)
```
2024-07-17 03:05:17 +00:00
Leonardo de Moura
f6666fe266 chore: add missing withTraceNode (#4769)
Motivation: improve `trace.profiler`
2024-07-17 02:32:32 +00:00
Leonardo de Moura
c580684c22 perf: add ShareCommon.shareCommon' (#4767)
A more restrictive but efficient max sharing primitive.

**Motivation:** Some software verification proofs may contain
significant redundancy that can be eliminated using hash-consing (also
known as `shareCommon`). For example, [theorem
`sha512_block_armv8_test_4_sym`](460fe5d74c/Proofs/SHA512/SHA512Sym.lean (L29))
took a few seconds at [`addPreDefinitions`
](1a12f63f74/src/Lean/Elab/PreDefinition/Main.lean (L155))
and one second at `fixLevelParams` on a MacBook Pro (with M1 Pro). The
proof term initially had over 16 million subterms, but the redundancy
was indirectly and inefficiently eliminated using `Core.transform` at
`addPreDefinitions`. I tried to use `shareCommon` method to fix the
performance issue, but it was too inefficient. This PR introduces a new
`shareCommon'` method that, although less flexible (e.g., it uses only a
local cache and hash-consing table), is much more efficient. The new
procedure minimizes the number of RC operations and optimizes the
caching strategy. It is 20 times faster than the old `shareCommon`
procedure for theorem `sha512_block_armv8_test_4_sym`.
2024-07-17 01:33:54 +00:00
Joachim Breitner
1a12f63f74 refactor: move Synax.hasIdent, shake dependencies (#4766)
I noticed that a change to `Lean.PrettyPrinter.Delaborator.Builtins`
rebuilt more modules than I expected, so I moved a definition and
reduced some dependcies.

More reduction would be possible to move const-delaboration out of the
big `Lean.PrettyPrinter`, and import from `Lean.PrettyPrinter`
selectively.
2024-07-16 21:19:26 +00:00
Joachim Breitner
95b8095fa6 feat: PProd syntax (part 3) (#4756)
reworks #4730 based on feedback from @kmill:

 * Uses `×'` for PProd
 * No syntax for MProd for now
 * Angle brackets (without nesting) for the values
2024-07-16 21:06:04 +00:00
Kyle Miller
94cc8eb863 chore: add comment for why anonymous constructor notation isn't flattened during pretty printing (#4764) 2024-07-16 19:04:51 +00:00
Kim Morrison
1cf47bce5a chore: rename TC to Relation.TransGen (#4760)
This is barely used in Lean, and this rename is both more readable, and
consistent with further developments downstream.

See
[zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Relation.2ETransGen.20vs.2E.20TC.20from.20Init.2ECore/near/448941824)
discussion.
2024-07-16 17:06:49 +00:00
Leonardo de Moura
b73fe04710 feat: add Lean.Expr.numObjs (#4754)
Add helper function for computing the number of allocated
sub-expressions in a given expression. Note: Use this function primarily
for diagnosing performance issues.
2024-07-16 15:52:33 +00:00
Leonardo de Moura
f986a2e9ef chore: missing profileitM (#4753)
This PR addresses the absence of the `profileitM` function in two
auxiliary functions. The added `profileitM` instances are particularly
useful for diagnosing performance issues in declarations that contain
many repeated sub-terms.
2024-07-16 15:43:23 +00:00
Markus Himmel
1a9cbc96f1 chore: rename HashMap.remove to HashMap.erase (#4725)
The name `remove` was chosen because it is more popular in mainstream
programming languages, but being consistent with other Lean container
types (including `Lean.HashMap` and `Batteries.HashMap`) is more
important, so let's change the name while we still can.
2024-07-16 08:14:56 +00:00
Sebastian Ullrich
7aec6c9ae7 chore: temporarily remove test broken by #4746 2024-07-16 09:43:26 +02:00
Lean stage0 autoupdater
31de2494fb chore: update stage0 2024-07-15 21:53:05 +00:00
Lean stage0 autoupdater
d679591880 chore: update stage0 2024-07-15 21:29:34 +00:00
Sebastian Ullrich
f167cfba71 chore: exclude more symbols to get below Windows symbol limit 2024-07-15 23:19:04 +02:00
Joachim Breitner
180c6aaa5e feat: PProd and MProd syntax (part 2) (#4730)
the internal constructions for structural and well-founded recursion
use plenty of `PProd` and `MProd`, and reading these, deeply
nested and in prefix notation, is unnecessarily troublesome.

Therefore this introduces notations
```
a ×ₚ b   -- PProd a b
a ×ₘ b   -- MProd a b
()ₚ      -- PUnit.unit
(x,y,z)ₚ -- PProd.mk x (PProd.mk y z)
(x,y,z)ₘ -- MProd.mk x (MProd.mk y z)
```

(This is the post-stage0-part 2.)
2024-07-15 15:40:42 +00:00
Lean stage0 autoupdater
ab0241dac8 chore: update stage0 2024-07-15 15:02:32 +00:00
Joachim Breitner
dc65f03c41 feat: PProd and MProd syntax (part 1) (#4747)
the internal constructions for structural and well-founded recursion
use plenty of `PProd` and `MProd`, and reading these, deeply
nested and in prefix notation, is unnecessarily troublesome.

Therefore this introduces notations
```
a ×ₚ b   -- PProd a b
a ×ₘ b   -- MProd a b
()ₚ      -- PUnit.unit
(x,y,z)ₚ -- PProd.mk x (PProd.mk y z)
(x,y,z)ₘ -- MProd.mk x (MProd.mk y z)
```

(This is part 1, the rest will follow in #4730 after a stage0 update.)
2024-07-15 14:21:11 +00:00
Joachim Breitner
de96b6d8a7 feat: structural recursion over nested datatypes (#4733)
This now works:

```lean
inductive Tree where | node : List Tree → Tree

mutual
def Tree.size : Tree → Nat
  | node ts => list_size ts

def Tree.list_size : List Tree → Nat
  | [] => 0
  | t::ts => t.size + list_size ts
end
```

It is still out of scope to expect to be able to use nested recursion
(e.g. through `List.map` or `List.foldl`) here.

Depends on #4718.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-07-15 11:49:53 +00:00
Joachim Breitner
3ab2c714ec feat: infer mutual structural recursion (#4718)
the support for mutual structural recursion (new since #4575) is
extended so that Lean tries to infer it even without annotations.

* The error message when termination checking fails looks quite
different now. Maybe a bit better, maybe with more room for
improvements.
* If there are too many combinations (with an arbitrary cut-off) for a
given argument type, it will just give up and ask the user to use
`termination_by structural`.
* It is now legal to specify `termination_by structural` on not
necessarily all functions of a clique; this simply restricts the
combinations of arguments that Lean considers.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-07-15 09:34:06 +00:00
Joachim Breitner
f99427bd1a test: extend test for #4671 with nice example reported on zulip (#4740)
from
<https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.E2.9C.94.20Doubly-nested.20inductive/near/451204850>

I really like when I can respond to bug report with “will fix in -1
weeks”
2024-07-13 22:22:40 +00:00
Joachim Breitner
1118978cbb refactor: IndGroupInfo and IndGroupInst (#4738)
This adds the types
* `IndGroupInfo`, a variant of `InductiveVal` with information that
   applies to a whole group of mutual inductives and
* `IndGroupInst` which extends `IndGroupInfo` with levels and parameters
   to indicate a instantiation of the group.

One purpose of this abstraction is to make it clear when a fuction
operates on a group as a whole, rather than a specific inductive within
the group.

This is extracted from #4718 and #4733 to reduce PR size and improve
bisectability.
2024-07-13 08:30:09 +00:00
James Sully
4ea8c5ad8d doc: fix misplaced docstring for getThe (#4737) 2024-07-13 08:10:05 +00:00
Mac Malone
a6ae49c3ab feat: lake: cleaner release handling & related touchups (#4735)
Improves a number of elements related to Git checkouts, cloud releases,
and related error handling.

* On error, Lake now prints all top-level logs. Top-level logs are those
produced by Lake outside of the job monitor (e.g., when cloning
dependencies).
* When fetching a remote for a dependency, Lake now forcibly fetches
tags. This prevents potential errors caused by a repository recreating
tags already fetched.
* Tweaked Git error handling to hopefully be more informative.
* The builtin package facets `release`, `optRelease`, `extraDep` are now
caption in the same manner as other facets. Previously, they were
attempting to be too clever.
* `afterReleaseSync` and `afterReleaseAsync` now fetch `optRelease`
rather than `release`.
* Added support for optional jobs, whose failure does not cause the
whole build to failure (and made `optRelease` such a job).

Closes #4302.
2024-07-13 01:10:41 +00:00
Joachim Breitner
2ad6d397f8 refactor: use indVal.numNested or indVal.numTypeFormers where applicable (#4734)
follow-up to #4684
2024-07-12 22:07:25 +00:00
Joachim Breitner
891824bc51 feat: .below and .brecOn for nested inductive (#4658)
We now get `.below` and `.brecOn` definitions for nested inductives.

No surprises in the implementation: the kernel already gives us suitable
`.rec_1` etc. recursors, and our construction follows the structure of
this recursor.

---------

Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-07-12 21:26:35 +00:00
Matthew Robert Ballard
f35c562ef8 feat: add #discr_tree_key command and discr_tree_key tactic (#4447)
Adds a command and tactic to print the `Array <| DiscrTree.Key` for
equalities helping the user to debug perceived `simp` failures.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-07-12 15:05:10 +00:00
Joachim Breitner
bcd8517307 feat: Meta.withErasedFVars (#4731)
this idiom shows up multiple times, is non-trivial (in the sense that
the `localInsts` has to be updated, and I am about to use it once more.
Hence time to abstract this out.
2024-07-12 14:58:04 +00:00
Kyle Miller
ce73bbe277 feat: detailed feedback on decide tactic failure (#4674)
When the `decide` tactic fails, it can try to give hints about the
failure:
- It tells you which `Decidable` instances it unfolded, by making use of
the diagnostics feature.
- If it encounters `Eq.rec`, it gives you a hint that one of these
instances was likely defined using tactics.
- If it encounters `Classical.choice`, it hints that you might have
classical instances in scope.
- During this, it tries to process `Decidable.rec`s and matchers to pin
blame on a particular instance that failed to reduce.

This idea comes from discussion with Heather Macbeth [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Decidable.20with.20structures/near/449409870).
2024-07-11 20:08:29 +00:00
Joachim Breitner
f0eab4b7b1 fix: nested structural recursion over reflexive data type (#4728)
this code
```
inductive N where
 | cons : (Nat -> N) -> N

mutual
def f : N -> Nat
 | .cons a => g (a 32) + 1
termination_by structural n => n
def g : N -> Nat
 | .cons a => f (a 42) + 1
termination_by structural  n => n
end
```
would break. When searching for the right `belowDict` we now have to,
evne after instantiating the paramters for a reflexive argument, again
search through a bunch of `PProd`s.

(Instead of searching we could pass down the index, but since we are
searching anyways in this function let's just re-use.)

Fixes: #4726
2024-07-11 15:25:48 +00:00
Kyle Miller
5f70c1ca64 fix: make matcher pretty printer sensitive to pp.explicit (#4724)
Matchers usually have implicit arguments, and even if they don't the
notation hides the name of the matcher function.

Now when hovering over `match` expressions you can see the actual
underlying matcher expression.
2024-07-11 01:49:49 +00:00
Kim Morrison
fce82eba40 feat: further theorems for List.erase (#4723) 2024-07-10 22:19:12 +00:00
grunweg
9d14e4423c chore: fix typo in doc-string (#4719)
Fix a typo "to at" in a doc-string.
2024-07-10 22:03:11 +00:00
Kim Morrison
0c7859a7dd feat: upstream more erase API (#4720)
This should complete leansat's requirements.
2024-07-10 20:26:51 +00:00
Joachim Breitner
c01e003b49 fix: mutual structural recursion: check that datatype parameters agree (#4715)
if will fail otherwise, but with a worse error message, and it's helpful
in later transformation to know that the parameters are the same for the
whole group.
2024-07-10 08:14:57 +00:00
Leonardo de Moura
ce8a130724 fix: deprecated warnings for overloaded symbols (#4713)
closes #4636
2024-07-10 04:06:25 +00:00
Kyle Miller
3c18d151a6 fix: make iff theorem generated by @[ext] preserve inst implicits (#4710)
Previously all arguments from the ext theorem were made implicit, but
now only default and strict implicits are made implicit.
2024-07-10 03:48:39 +00:00
Leonardo de Moura
0f48e926eb fix: decide tactic transparency (#4711)
closes #4644
2024-07-10 01:40:32 +00:00
Leonardo de Moura
850964999e fix: Repr instances for Int and Float (#4709)
closes #4677
2024-07-10 00:10:58 +00:00
Kim Morrison
57b8b32c72 chore: reorganise lemmas on list getters (#4708)
Just reordering lemmas, sorting into subsections.
2024-07-09 22:55:20 +00:00
Kim Morrison
bd2aefee01 feat: simp normal form tests for Pairwise and Nodup (#4707) 2024-07-09 22:26:27 +00:00
Kim Morrison
74dcd6c2a9 feat: lemmas for List.head and List.getLast (#4678) 2024-07-09 22:13:41 +00:00
Kyle Miller
23b893f778 doc: update release checklist for new release notes workflow (#4458)
This makes it reflect how we are writing release notes for 4.9.0,
including how to handle the `releases_drafts` folder and how and when to
update `RELEASES.md`.

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-07-09 21:44:15 +00:00
Kim Morrison
1e02c08111 feat: basic material on List.Pairwise and Nodup (#4706)
Upstreaming of basic material on `List.Pairwise` and `List.Nodup`. More
complete API to follow later, this is just a first approximation of what
leansat will need.
2024-07-09 21:39:08 +00:00
Kim Morrison
0f6a802314 feat: characterisations of List.Sublist (#4704) 2024-07-09 21:34:29 +00:00
Mario Carneiro
be197cd431 fix: prefer original module in const2ModIdx (#4652)
When a definition is redeclared, the original code would clobber the
value of `const2ModIdx` every time, meaning that a constant would be
attributed to a module which occurs later than the modules for constants
referencing this one. Preferring the original module ensures that these
module indexes are dependency-ordered. This originally came up as a bug
in `shake`, which assumes this property, see
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/check.20for.20unused.20imports.20doesn't.20stop/near/449139309).
2024-07-09 14:14:39 +00:00
Kim Morrison
f531f4e5db feat: chore upstream List.Sublist and API from Batteries (#4697)
I'll update `list_simp.lean` (simp normal form testing) and add missing
lemmas in follow-up PRs.

This just upstreams the material, and reorders the lemmas to match the
other sections.
2024-07-09 12:57:09 +00:00
Kim Morrison
8229b28cc9 feat: omega doesn't push coercion over multiplication unnecessarily (#4695) 2024-07-09 12:49:31 +00:00
Sebastian Ullrich
582d6e7f71 chore: CI: update download-artifact actions 2024-07-09 10:17:19 +02:00
Mac Malone
4daa29e71d feat: lake: require @ git (#4692)
Adds syntactic sugar specifying a git revision as a dependency version
in a `require` command. For example:

```
require "leanprover-community" / "proofwidgets" @ git "v0.0.39"
```
2024-07-09 02:50:50 +00:00
Kim Morrison
9124426c55 chore: upstream eq_iff_true_of_subsingleton (#4689) 2024-07-08 21:09:33 +00:00
Kyle Miller
cb0755bac0 chore: make use of ext_iff realization now that stage0 is updated (#4694)
This is a followup to #4543. This also adds "go to definition" for
generated lemmas.
2024-07-08 21:05:53 +00:00
Lean stage0 autoupdater
4b32d9b9a1 chore: update stage0 2024-07-08 20:22:24 +00:00
Kyle Miller
7602265923 feat: make @[ext] derive ext_iff theorems from user ext theorems (#4543)
This PR refactors the 'ext' attribute and implements the following
features:
- The 'local' and 'scoped' attribute kinds are now usable.
- The attribute realizes the `ext`/`ext_iff` lemmas when they do not
already exist, rather than always generating them. This is useful in
conjunction with `@[local ext]`.
- Adding `@[ext]` to a user ext lemma now realizes an `ext_iff` lemma as
well; formerly this was only for structures. The name of the generated
`ext_iff` theorem for a user `ext` theorem named `A.B.myext` is
`A.B.myext_iff`. If this process leads to an error, the user can write
`@[ext (iff := false)]` to disable this feature.

Breaking changes:
- Now the "x" and "y" term arguments to the realized `ext` and `ext_iff`
lemmas are implicit.
- Now the realized `ext` and `ext_iff` lemmas are protected.

Bootstrapping notes:
- There are a few `ext_iff` lemmas to address after the next stage0
update.

Closes https://github.com/leanprover/lean4/issues/3643

Suggested by Floris [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.22Missing.20Tactics.22.20list/near/446267660).
2024-07-08 19:37:56 +00:00
Lean stage0 autoupdater
6ba5704e00 chore: update stage0 2024-07-08 21:18:50 +02:00
Joachim Breitner
98ee789990 refactor: InductiveVal.numNested instead of .isNested
right now, in order to find out how many auxilary datatype are in a
mutual group of inductive with nested data type, one has to jump
through hoops like this:

```
private def numNestedInducts (indName : Name) : MetaM Nat := do
  let .inductInfo indVal ← getConstInfo indName | panic! "{indName} is an inductive"
  let .recInfo recVal ← getConstInfo (mkRecName indName) | panic! "{indName} has a recursor"
  return recVal.numMotives - indVal.all.lengt
```

The `InductiveVal` data structure already has `.isNested : Bool`, so it
seems to be a natural extension to beef that up to `.numNested: Nat`.

This touched kernel code.
2024-07-08 21:18:50 +02:00
Kim Morrison
e08a562c48 chore: add step to release checklist (#4693) 2024-07-08 18:58:18 +00:00
Kim Morrison
84c40d9999 chore: improve compatibility of tests/list_simp with Mathlib (#4691)
I'd like to be able to automatically re-test simp normal forms
post-Mathlib. This makes the file compatible with Mathlib.
2024-07-08 17:17:28 +00:00
Kim Morrison
aecebaab74 chore: upstream SMap.foldM (#4690) 2024-07-08 17:11:58 +00:00
Kim Morrison
3b3901b824 chore: forward and backward directions of not_exists (#4688)
These are added in Batteries.
2024-07-08 16:31:04 +00:00
Kim Morrison
811c1e3685 chore: upstream ToExpr FilePath and compile_time_search_path% (#4453) 2024-07-08 15:41:03 +00:00
Kim Morrison
27e85cc947 chore: adjust List.replicate simp lemmas (#4687) 2024-07-08 15:29:19 +00:00
Henrik Böving
9a852595c4 feat: Process.tryWait (#4660)
Reopen of #4659 due to "processing updates" bug.
2024-07-08 15:14:13 +00:00
Joachim Breitner
1311e36a98 feat: structural mutual recursion (#4575)
This adds support for mutual structural recursive functions.

For now this is opt-in: The functions must have a `termination_by
structural …` annotation (new since #4542) for this to work:

```lean
mutual
inductive A
  | self : A → A
  | other : B → A
  | empty
inductive B
  | self : B → B
  | other : A → B
  | empty
end

mutual
def A.size : A → Nat
  | .self a => a.size + 1
  | .other b => b.size + 1
  | .empty => 0
termination_by structural x => x
def B.size : B → Nat
  | .self b => b.size + 1
  | .other a => a.size + 1
  | .empty => 0
termination_by structural x => x
end
```

The recursive functions don’t have to be in a one-to-one relation to a
set of mutually recursive inductive data types. It is possible to ignore
some of the types:

```lean
def A.self_size : A → Nat
  | .self a => a.self_size + 1
  | .other _ => 0
  | .empty => 0
termination_by structural x => x
```

or have more than one function per argument type:

```lean
  def isEven : Nat → Prop
    | 0 => True
    | n+1 => ¬ isOdd n
  termination_by structural x => x

  def isOdd : Nat → Prop
    | 0 => False
    | n+1 => ¬ isEven n
  termination_by structural x => x
```


This does not include

 * Support for nested inductive data types or nested recursion
* Inferring mutual structural recursion in the absence of
`termination_by`.
 * Functional induction principles for these.
* Mutually recursive functions that live in different universes. This
may be possible,
maybe after beefing up the `.below` and `.brecOn` functions; we can look
into this some
   other time, maybe when there are concrete use cases.

---------

Co-authored-by: Richard Kiss <him@richardkiss.com>
Co-authored-by: Tobias Grosser <tobias@grosser.es>
2024-07-08 14:39:50 +00:00
Joachim Breitner
db7a01d126 chore: update comments in kernel/declaration.h (#4683)
This file has comments that recall the data type definitions in Lean.
Most of them were still using lean3 syntax, and at least one of them was
out of date (one field missing), so I updated them.

I took the liberty to shorten the comments from the original file, or
omit them if they don’t add much over the field names.
2024-07-08 14:39:43 +00:00
Sebastian Ullrich
4d2f2d7cc5 fix: calculate error suppression per snapshot (#4657)
Generalizes #3556 to not suppressing errors in tactic steps either when
the parse error is in a later step, as otherwise changes to the end of a
proof would affect (correctness or effectiveness of) incrementality of
preceding steps.

Fixes #4623, in combination with #4643
2024-07-08 09:54:43 +00:00
Sebastian Ullrich
f6265e25f4 chore: fix "max dynamic symbols" metric (#4669)
As we do not build multiple shared libraries on non-Windows anymore,
count the max exported symbols per static library instead.
Unfortunately, this still does seem to match the number on Windows.
2024-07-08 09:09:19 +00:00
Markus Himmel
d6c6e16254 fix: unorphan modules in Std.Data (#4679) 2024-07-08 07:57:56 +00:00
Markus Himmel
818b9d7de0 chore: update codeowners (#4681) 2024-07-08 07:57:54 +00:00
Markus Himmel
34e6579190 chore: Inhabited instances for Std.HashMap (#4682) 2024-07-08 07:57:51 +00:00
Markus Himmel
2b0ed751bd fix: unorphan modules in Init (#4680) 2024-07-08 07:57:50 +00:00
Kim Morrison
6ed26dcf8f chore: cleanup unused arguments (from linter) (#4621) 2024-07-07 21:20:06 +00:00
Joachim Breitner
955135b3f9 chore: bump actions/checkout and actions/upload-artifacts (#4664)
to reduce warnings on CI. Based on the changelogs/migrations guides I
found they should work as before.
2024-07-07 20:26:59 +00:00
Joachim Breitner
f36bbc8d56 fix: hasBadParamDep? to look at term, not type (#4672)
The previous check, looking only at the type of the parameter, was too
permissive and led to ill-typed terms later on.

This fixes #4671.

In some cases the previous code might have worked by accident, in this
sense this is a breaking change. Affected functions can be fixed by
reordering their parameters to that all the function parameters that
occur in the parameter of the inductive type of the parameter that the
function recurses on come first.
2024-07-07 16:00:00 +00:00
Kim Morrison
64eeba726a chore: make Antisymm a Prop (#4666)
As pointed out on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60Antisymm.60.20is.20in.20.60Type.60/near/449084812).
2024-07-07 12:31:35 +00:00
Sebastian Ullrich
4ed79472af fix: explicitly initialize Std in lean_initialize (#4668)
Fixes the stage 2 build, which runs with `prefer_native=true`
2024-07-06 13:17:30 +00:00
Sebastian Ullrich
55d09a39b4 fix: move Std from libleanshared to much smaller libInit_shared (#4661)
Fixes the Windows build. As libLean is by far the biggest component,
there is no need for a separate libStd_shared for now.

```
$ find build/release/stage1/lib/lean -name '*.a' -exec bash -c 'echo -n "{} " ; nm {} | grep " T " | wc -l' \;
build/release/stage1/lib/lean/libleanrt.a 497
build/release/stage1/lib/lean/libleancpp.a 1320
build/release/stage1/lib/lean/libInit.a 7476
build/release/stage1/lib/lean/libStd.a 1696
build/release/stage1/lib/lean/libLean.a 64339
build/release/stage1/lib/lean/libLake.a 5722
```
2024-07-06 11:43:09 +02:00
Kyle Miller
7de0c58dc1 fix: don't set pp.tagAppFns when pretty printing signatures (#4665)
In #3911, a refactor to share `MessageData` code between `ppConst` and
the signature pretty printer unintentionally caused the signature pretty
printer to use the `pp.tagAppFns` option. This causes, for example, `+`
in `a + b` to independently have its own hover information due to the
fact that `notation` app unexpanders use the head function's syntax as
the `ref` when constructing the notation syntax. This behavior of
`pp.tagAppFns` is intentional, and it is used by docgen, but it should
not be activated for signatures.

This affects `#check` and was reported by Kevin Buzzard [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/degraded.20hover.20experience.20on.20.23check/near/449380674).

This PR also makes sure the initial `ref` when applying app unexpanders
is `.missing`, rather than whatever random value might be present in the
`CoreM` context.
2024-07-05 23:02:39 +00:00
Joachim Breitner
04fefdd728 chore: restart-on-label: wait for 30s (#4663)
this doesn't work reliable when it cancels jobs. Maybe sleeping helps.
2024-07-05 19:50:14 +00:00
Lean stage0 autoupdater
75fe520562 chore: update stage0 2024-07-05 16:43:21 +00:00
Markus Himmel
3e0ea762b8 feat: Std.HashMap (#4583)
### Preliminary PRs:

- [x] #4597 
- [x] #4599
- [x] #4600
- [x] #4602
- [x] #4603
- [x] #4604
- [x] #4605
- [x] #4607
- [x] #4627
- [x] #4629 

### Quick overview over API/naming changes compared to `Lean.HashMap`
and `Batteries.HashMap`:
#### Lean

* `find?` -> `get?`/`getElem?`
* `find!` -> `get!`/`gtetElem!`
* `findD` -> `getD`
* `findEntry?` -> not implemented for now
* `insert'` -> `containsThenInsert` (order reversed in result)
* `insertIfNew` -> `getThenInsertIfNew?` (order reversed in result)
* `numBuckets` -> `Internal.numBuckets`
* `ofListWith` -> not implemented for now
* `Array.groupByKey` -> not implemented for now
* `merge` -> not implemented for now, but you can use `insertMany`

#### Batteries

* `modify` -> not implemented for now
* `mergeWith` -> not implemented for now
* `mergeWithM` -> not implemented for now
2024-07-05 10:14:20 +00:00
Joachim Breitner
5ce886cf96 refactor: Split Constructions module (#4656)
for better build paralleization and less rebuilding when editing one of
these files.
2024-07-05 08:25:44 +00:00
Joachim Breitner
5ad5c2cf04 fix: universe level in .below and .brecOn construction (#4651)
I made a mistake in #4517, fixed here, so about time to add a test.

I wonder if this generic level optimization should be moved into
`mkLevelMax'`, but not today.

fixes #4650
2024-07-04 18:19:43 +00:00
Markus Himmel
d4e141e233 feat: EquivBEq and LawfulHashable classes (#4607)
Split from #4583

There are two open questions, opinions appreciated:

- Should this material be part of `Init` or `Std`?
- Should the typeclasses be in the `Std` namespace?
2024-07-04 05:07:18 +00:00
Markus Himmel
05f78939f6 feat: additional lemmas for arrays (#4627)
Split from #4583
2024-07-04 05:06:34 +00:00
Leonardo de Moura
7b965f3f18 fix: improve synthAppInstances (#4646)
This is an auxiliary procedured used by `rw` and `apply` tactics. It
synthesizes pending type class instances.
The new test contains an example where it failed. The comment at
`synthAppInstances.step` explains why, and the fix.
2024-07-03 19:14:25 +00:00
Joachim Breitner
0594bc4e5a refactor: lambdaBoundedTelescope (#4642)
we have a `forallBoundedTelescope`, and for a long while I was
wondering why we also don't have `lambdaBoundedTelescope`, and every now
and then felt the need for it. So let's just add it.
2024-07-03 15:57:12 +00:00
Sebastian Ullrich
3fb7f632a5 fix: snapshot subtree was not restored on reuse (#4643)
This could lead to nested error messages and info trees vanishing on
edits (strictly) below them

Fixes the second issue in #4623
2024-07-03 15:27:15 +00:00
Joachim Breitner
f6deaa8fb2 chore: update stage0 2024-07-03 14:54:58 +02:00
Joachim Breitner
15a41ffc1c refactor: include declNames in Structural.EqnInfo
this is in preparation for #4575. Because we use the EqnInfo in
attributes, this should be followed by a stage0 update before the field
is used.
2024-07-03 14:54:58 +02:00
Joachim Breitner
cc5c95f377 chore: CI: restart-on-label: view run more often (#4640)
this job sometimes fails, maybe a race condition with the `gh run
cancel` not happenign quickly enough. Maybe more verbose output will
help understand this better.
2024-07-03 12:35:50 +00:00
Sebastian Ullrich
62c5bc5d0d chore: manual nightly trigger (#4638)
Now that nightly releases may fail more often because of more checks,
let's make it possible to retry them on a later commit
2024-07-03 08:19:07 +00:00
Kyle Miller
c2edae92c8 fix: make sure syntax nodes always run their formatters (#4631)
Now syntax nodes have their formatters run even if the parsers they wrap
are all arity zero. This fixes an issue where if `ppSpace` appears in a
`macro`/`elab` then it does not format with a space due to the fact that
macro argument processing wraps this as `group(ppSpace)`, and `ppSpace`
has arity zero.

Implementation note: the fix is to make the `visitArgs` formatter
combinator always visit the last child, even if it does not exist (in
which case the visited node will be `Syntax.missing`). To compensate,
parser combinators like many and optional need to be sure to keep track
of whether there any children. Only optional's needed to be modified.

Closes #4561
2024-07-03 07:45:34 +00:00
Lean stage0 autoupdater
7ef95cd30b chore: update stage0 2024-07-03 07:48:23 +00:00
Alok Singh
2cd2364974 chore: typo (#4635) 2024-07-03 05:14:09 +00:00
Leonardo de Moura
f5fd962a25 feat: safe exponentiation (#4637)
Summary:
- Adds configuration option `exponentiation.threshold`
- An expression `b^n` where `b` and `n` are literals is not reduced by
`whnf`, `simp`, and `isDefEq` if `n > exponentiation.threshold`.

Motivation: prevents system from becoming irresponsive and/or crashing
without memory.

TODO: improve support in the kernel. It is using a hard-coded limit for
now.
2024-07-03 05:12:53 +00:00
Markus Himmel
d72fcb6b2a feat: Option.or (#4600)
Split from #4583
2024-07-03 01:30:15 +00:00
Markus Himmel
a2a73e9611 feat: USize.and_toNat (#4629)
Split from #4583
2024-07-03 01:28:36 +00:00
Kyle Miller
3f2cf8bf27 fix: set default value of pp.instantiateMVars to true and make the option be effective (#4558)
Before, `pp.instantiateMVars` generally had no effect because most call
sites for the pretty printer instantiated metavariables first, but now
this functionality is entrusted upon the `pp.instantiateMVars` option.

This also has an effect in hovers, where metavariables can be unfolded
one assignment at a time. However, the goal state still sees all
metavariables instantiated due to the fact that the algorithm relies on
expression equality post-instantiation (see
`Lean.Widget.goalToInteractive`).

Closes #4406
2024-07-02 22:59:44 +00:00
Joachim Breitner
d39c4d6a1c chore: pr-release: use right tag name (#4632)
this improves upon #4598
2024-07-02 21:06:55 +00:00
Sebastian Ullrich
b28cfb9336 fix: Windows build (#4628) 2024-07-02 20:32:00 +00:00
Leonardo de Moura
6080e3dd5c fix: enforce isDefEqStuckEx at unstuckMVar procedure (#4596)
Closes #2736

See comment at `ExprDefEq.lean` for explanation.
Side effects:
- Improved error messages in two tests.
- Had to improve `getSuccesses` procedure at `App.lean`. It now
  discards candidates that contain postponed elaboration problems.
  If it is too disruptive for Mathlib, we should try to discard the
  ones that have postponed metavariables.
2024-07-02 13:42:47 +00:00
Markus Himmel
8959b2ca87 chore: make constructor-as-variable test more robust (#4625)
The test tended to fail every time the number of structures in `Init`
changes, which turns out to be quite often.
2024-07-02 11:44:46 +00:00
Kim Morrison
554e723433 chore: add 'since' dates to deprecated (#4617) 2024-07-02 04:30:09 +00:00
Kim Morrison
9cc1164305 chore: follow simpNF linter's advice (#4620)
We can run the `simpNF` environment linter from Batteries. Nearly all
its advice is good.
2024-07-02 04:30:00 +00:00
Kim Morrison
0c6f83eb6d chore: satisfy duplicate namespace linter (#4616) 2024-07-02 04:29:56 +00:00
Kim Morrison
1225b0f651 chore: delete deprecations from 2022 (#4618) 2024-07-02 03:47:33 +00:00
Kim Morrison
75e11ecf7c chore: defs that should be theorems (#4619) 2024-07-02 03:03:11 +00:00
Markus Himmel
4055aecba2 feat: additional lemmas for bounded integers (#4605)
Split from #4583
2024-07-02 02:03:13 +00:00
Markus Himmel
1681b2fa67 feat: additional lemmas for cond (#4604)
Split from #4583
2024-07-02 02:02:41 +00:00
Markus Himmel
c97f958ecf feat: getElem_congr (#4603)
Split from #4583

Rewriting the `i` in `xs[i]` usually fails with `motive is not type
correct`, but with this lemma it works.
2024-07-02 02:02:17 +00:00
Markus Himmel
e2dc85274b feat: additional lemmas for lists (#4602)
Split from #4583

`exists_of_set` appears in Batteries as `exists_of_set'`. The
`exists_of_set` version is unused in batteries and mathlib at least and
I would argue that the primed version (i.e., the one added in this PR)
is always better anyway.

`isEmpty_iff` appears in mathlib as `isEmpty_iff_eq_nil`.
2024-07-02 02:01:44 +00:00
Markus Himmel
e12999bcf6 feat: additional lemmas for Option (#4599)
Split from #4583

Mathlib has `isSome_map'` but calls it `isSome_map`.
2024-07-02 01:58:33 +00:00
Markus Himmel
7a0fe6f54c feat: Nat.and_le_(left|right) (#4597)
Split from #4583
2024-07-02 01:55:12 +00:00
Mario Carneiro
4a2210b7e6 fix: unresolve name avoiding locals (#4593)
Fixes #4591. The extra code already existed in the only other user of
`unresolveNameGlobal` (in the pretty printer), although I did not make
it use this function because it has some additional behavior around
universes and in pattern position.
2024-07-02 01:15:39 +00:00
Siddharth
e9d2f8f5f2 feat: mul recurrence theorems for LeanSAT (#4568)
This implements the recurrence theorems `getLsb_mul`, `mulRec_zero_eq`,
`mulRec_succ_eq` to allow bitblasting multiplication.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-07-01 23:47:29 +00:00
Lean stage0 autoupdater
d5a45dfa8b chore: update stage0 2024-07-01 17:36:58 +00:00
Joachim Breitner
fb0c46a011 feat: termination_by structural (#4542)
This implements the `termination_by structural` syntax proposed in
#3909.

I went with `termination_by structural` over, say,
`termination_by (config := {method := .structural})` mainly because it
was
easier to get going (otherwise I’d have to look into how to define
recursive
parsers, as `Parser.config` depends on `term` and `termination_by` is
part of
term. But also because I find it more ergonomic and aesthetic as a user.
But syntax can still change.

The `termination_by?` syntax will no longer force well-founded
recursion,
and instead the inferred `termination_by structurally` annotation will
be shown
if structural termination is possible.

While I was it, this fixes #4546 the easy way (log errors about but
otherwise
ignore incomplete `termination_by` sets for mutual recursion). Maybe we
get
multiple replacements (#4551), but even then this this good behavior.

Involves a bit of shuffling around `TerimationHints` (now validated for
a
clique already by `PreDefinition.main`) and `TerminationArguments` (now
lifted
out of the `WF` namespace, and a bit simplified).

Fixes #3909

---------

Co-authored-by: Richard Kiss <him@richardkiss.com>
2024-07-01 16:51:30 +00:00
Joachim Breitner
0635b277ec fix: diagnostics: show kernel diags even if it is the only section (#4611) 2024-07-01 16:45:39 +00:00
Joachim Breitner
087054172c feat: omega error message: normalize constraint order (#4612)
using the order as it comes out of the `HashMap` led to annying test
suite output variations. Moreover, sorting by the canonical order leads
to messages that are probably easier to digest as a user.
2024-07-01 16:11:15 +00:00
Sebastian Ullrich
7f00767b1e fix: adapt kernel interruption to new cancellation system (#4584)
Kernel checks were not canceled on edit after #3014
2024-07-01 14:52:42 +00:00
Joachim Breitner
be54ccd246 chore: pr-release: adjust to new lakefile.lean syntax (#4598)
as per

f5c3f06aa7
2024-07-01 08:48:33 +00:00
Kim Morrison
4d0b7cf66c chore: begin development cycle for v4.11.0 (#4594) 2024-06-30 23:28:48 +00:00
Joachim Breitner
0629eebc09 chore: release triggers update of release.lean-lang.org (#4531) 2024-06-30 10:39:32 +00:00
Wojciech Nawrocki
9248ada3a8 feat: total ByteArray.toList/findIdx? (#4582)
This is to enable proving facts about these functions.
2024-06-30 07:09:08 +00:00
Kyle Miller
144a3d9463 fix: typo hearbeats -> heartbeats (#4590)
Reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/is.20.60trace.2Eprofiler.2EuseHeartbeats.60.20a.20thing.3F/near/447950838).
2024-06-30 07:07:11 +00:00
L
a7bbe7416b feat: upstream List.attach and Array.attach from Batteries (#4586)
Source material:

555ec79bc6/Batteries/Data/List/Init/Attach.lean

555ec79bc6/Batteries/Data/Array/Basic.lean (L133-L148)

Closes RFC #4414
2024-06-30 07:06:26 +00:00
Leonardo de Moura
f31d4dc128 chore: update stage0 2024-06-29 19:18:53 +02:00
Leonardo de Moura
fb97275dcb feat: add Simp.Config.implicitDefEqProofs
This commit does **not** implement this feature.
2024-06-29 19:18:53 +02:00
Leni Aniva
d4d7c72365 fix: Add linking of -lStd back into nix build flags on darwin (#4587)
Adds linkage to `Std` so the build behaviour on darwin is in line with
linux

I'm not sure why linking with `Std` is needed. I deleted it in the
previous patch https://github.com/leanprover/lean4/pull/3811 and Lean
still builds and runs. @tydeu mentioned this issue so I created this PR.
2024-06-29 08:12:57 +00:00
Mac Malone
93c9ae7c20 feat: lake: reservoir require (#4495)
Adds a new type of `require` which fetches package metadata from a
registry API endpoint (i.e., Reservoir) and then clones a Git package
using the information provided. To require such a dependency, the new
syntax is:

```lean
require <scope> / <pkg-name> [@ "git#<rev>"] -- e.g., require "leanprover" / "doc-gen4"
```

Or in TOML:

```toml
[[require]]
name = "<pkg-name>"
scope = "<scope>"
rev = "<rev>"
```

Unlike with Git dependencies, Lake can make use of the richer
information provided by the registry to determine the default branch of
the package. This means for repositories of packages like `doc-gen4`
which have a default branch that is not `master`, Lake will now use said
default branch (e.g., in `doc-gen4`'s case, `main`).

Lake also supports configuring the registry endpoint via an environment
variable: `RESERVIOR_API_URL`. Thus, any server providing a similar
interface to Reservoir can be used as the registry. Further
configuration options paralleling those of Cargo's [Alternative
Registries](https://doc.rust-lang.org/cargo/reference/registries.html)
and [Source
Replacement](https://doc.rust-lang.org/cargo/reference/source-replacement.html)
will come in the future.

Updated and split from #3174.
2024-06-29 01:40:54 +00:00
Leni Aniva
b8dd51500f fix: nix: add platform dependent flag to lib target (#3811)
Closes #3810
2024-06-28 10:40:11 +00:00
Kim Morrison
bd091f119b chore: fix bv_omega regression since v4.9.0 (#4579)
This example, reported from LNSym, started failing when we changed the
definition of `Fin.sub` in
https://github.com/leanprover/lean4/pull/4421.

When we use the new definition, `omega` produces a proof term that the
kernel is very slow on.

To work around this for now, I've removed `BitVec.toNat_sub` from the
`bv_toNat` simp set,
and replaced it with `BitVec.toNat_sub'` which uses the old definition
for subtraction.

This is only a workaround, and I would like to understand why the term
chokes the kernel.

```
example
    (n : Nat)
    (addr2 addr1 : BitVec 64)
    (h0 : n ≤ 18446744073709551616)
    (h1 : addr2 + 18446744073709551615#64 - addr1 ≤ BitVec.ofNat 64 (n - 1))
    (h2 : addr2 - addr1 ≤ addr2 + 18446744073709551615#64 - addr1) :
    n = 18446744073709551616 := by
  bv_omega
```
2024-06-28 01:20:08 +00:00
Leonardo de Moura
d8e719f9ab feat: add set_option debug.skipKernelTC true
The new option `set_option debug.skipKernelTC true` is meant for
temporarily working around kernel performance issues.
It compromises soundness because a buggy tactic may produce an invalid
proof, and the kernel will not catch it if the new option is set to true.
2024-06-28 00:55:47 +02:00
Leonardo de Moura
93d2ad5fa7 chore: update stage0 2024-06-28 00:55:47 +02:00
Leonardo de Moura
7b56eb20a0 feat: prepare for adding new option debug.skipKernelTC
Remark: I had to comment
```
if debug.skipKernelTC.get opts then
  addDeclWithoutChecking env decl
else
```
because the build was crashing when trying to compile Lake.
Going to perform `update-stage0` and try again.
2024-06-28 00:55:47 +02:00
Leonardo de Moura
30a922a7e9 feat: add option debug.byAsSorry true (#4576) 2024-06-27 18:29:26 +00:00
Mac Malone
294f7fbec5 fix: lake: computation of precompiled libs (#4566)
Addresses a few issues with precompile library computation. 

* Fixes a bug where Lake would always precompile the package of a
module.
* If a module is precompiled, it now precompiles its imports.
Previously, it would only do this if imported.

Closes #4565.
2024-06-27 15:08:52 +00:00
Sebastian Ullrich
f3cb8a6c2d fix: interrupt exception was swallowed by some tryCatchRuntimeEx uses (#4569)
This appears to have been a semantic merge conflict between #3940 and
#4129. The effect on the language server is that if two edits are
sufficiently close in time to create an interrupt, some elaboration
steps like `simp` may accidentally catch the exception when it is
triggered during their execution, which makes incrementality assume that
elaboration of the body was successful, which can lead to incorrect
reuse, presenting the interrupted state to the user with symptoms such
as "uses sorry" without accompanying errors and incorrect lints.
2024-06-27 10:03:22 +00:00
Kim Morrison
5c978a2e24 feat: remove Decidable instances from GetElem (#4560) 2024-06-27 02:09:29 +00:00
Leonardo de Moura
ee42c3ca56 fix: discrepancy in the elaborators for theorem, def, and example (#4482)
When the type of a definition or example is a proposition,
we should elaborate on them as we elaborate on theorems.
This is particularly important for examples that are often
used in educational material.

Recall that when elaborating theorem headers, we convert unassigned
universe metavariables into universe parameters. The motivation is
that the proof of a theorem should not influence its statement.
However, before this commit, this was not the case for definitions and
examples when their type was a proposition. This discrepancy often
confused users.

Additionally, we considered extending the above behavior whenever
the type of a definition is provided. That is, we would keep the
current behavior only if `: <type>` was omitted in a definition.
However, this proved to be too restrictive.
For example, the following instance in `Core.lean` would fail:
```
instance {α : Sort u} [Setoid α] : HasEquiv α :=
  ⟨Setoid.r⟩
```
and we would have to write instead:
```
instance {α : Sort u} [Setoid α] : HasEquiv.{u, 0} α :=
  ⟨Setoid.r⟩
```
There are other failures like this in the core, and we assume many more
in Mathlib.

closes #4398

@semorrison @jcommelin: what do you think?
2024-06-27 00:58:58 +00:00
Joachim Breitner
18c97926a1 refactor: extract withRecArgInfo from findRecArg (#4549)
this is  in preparation for #4542, and extracts from `findRecArg` the
functionality for trying one particular argument.

It also refactors the code a bit. In particular

 * It reports errors in the order of the parameters, not the order of
   in which they are tried (it tries non-indices first).
 * For every argument it will say why it wasn't tried, even if the
   reason is quite obviously (fixed prefix, or `Prop`-typed etc.)

Therefore there is some error message churn.
2024-06-26 11:10:57 +00:00
Joachim Breitner
ea22ef4485 refactor: port below and brecOn construction to Lean (#4517)
This ports the `.below` and `.brecOn` constructions to lean.

I kept them in the same file, as they were in the C code, because they
are
highly coupled and the constructions are very analogous.

For validation I developed this in a separate repository at
https://github.com/nomeata/lean-constructions/tree/fad715e
and checked that all declarations found in Lean and Mathlib are
equivalent, up to

    def canon (e : Expr) : CoreM Expr := do
      Core.transform (← Core.betaReduce e) (pre := fun
        | .const n ls  => return .done (.const n (ls.map (·.normalize)))
        | .sort l => return .done (.sort l.normalize)
        | _ => return .continue)

It was not feasible to make them completely equal, because the kernel's
type inference code seem to optimize level expressions a bit less
aggressively, and beta-reduces less in inference.

The private helper functions about `PProd` can later move into their own
file, used by these constructions as well as the structural recursion
module.
2024-06-26 11:10:39 +00:00
Leonardo de Moura
62b6e58789 fix: avoid unnecessary proof steps in simp (#4567)
closes #4534
2024-06-26 05:48:03 +00:00
Mac Malone
714dc6d2bb fix: lake: non-ident script names (#4564)
Fixes a bug where non-identifier script names could not be entered on
the CLI without French quotes. [Reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Running.20.60lake.60.20scripts.20from.20the.20command.20line/near/446944450).

Also adds support for string literal script names in a `lakefile.lean`.
2024-06-26 04:24:01 +00:00
Mac Malone
5e7d2c34dc fix: lake: exe bad import errors & related touchups (#4529)
Fixes some issues with the executable build and bad imports.

**Release notes:** 
* A bad import in an executable no longer prevents the executable's root
module from being built., This also fixes a problem where the location
of a transitive bad import would not been shown.
 * The root module of the executable now respects `nativeFacets`.

**Technical touchups:**

* Expanded and better documented `tests/badImport`.
* Use `ensureJob` in `recBuildDeps` to catch import errors instead of
individual `try ... catch` blocks.
2024-06-26 03:39:39 +00:00
Leonardo de Moura
fb6d29e260 fix: IndPredBelow should not add auxiliary declarations containing sorry (#4563)
Issue #4535 is being affected by a bug in the structural inductive
predicate termination checker (`IndPred.lean`). This module did not
exist in Lean 3, and it is buggy in Lean 4. In the given example, it
introduces an auxiliary declaration containing a `sorry`, and the fails.
This PR ensures this kind of declaration is not added to the
environment.

Closes #4535

TODO: we need a new maintainer for the `IndPred.lean`.
2024-06-25 20:57:32 +00:00
Leonardo de Moura
4964ce3ce8 fix: two functions with the same name in a where/let rec block (#4562)
closes #4547
2024-06-25 20:03:53 +00:00
Kyle Miller
230f335702 fix: block implicit lambda feature for type-free type ascription (#4536)
The implicit lambda feature is already blocked for type ascriptions, but
there is an oversight where it was not blocked for the `(x :)` type
ascription as well. Reported on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60refine.60.20with.20implicit.20variables/near/446327230).
2024-06-25 18:18:23 +00:00
Sebastian Ullrich
875e4b1904 fix: tactics in terms in tactic combinators breaking incrementality (#4554)
Fixes #4553
2024-06-25 08:59:38 +00:00
Kyle Miller
49249b9107 feat: introduce pp.maxSteps (#4556)
The `pp.maxSteps` option is a hard limit on the complexity of pretty
printer output, which is necessary to prevent the LSP from crashing when
there are accidental large terms. We're using the default value from the
corresponding Lean 3 option.

This PR also sets `pp.deepTerms` to `false` by default.
2024-06-24 19:19:45 +00:00
Kim Morrison
3b67e15827 feat: maximum?_eq_some_iff' (#4550)
Requested by @hargoniX.
2024-06-24 11:57:27 +00:00
Leonardo de Moura
e3578c2f36 fix: discrepancy theorem vs example (#4493)
When the type of an `example` is a proposition,
we should elaborate on them as we elaborate on theorems.
This is particularly important for examples that are often
used in educational material.

Recall that when elaborating theorem headers, we convert unassigned
universe metavariables into universe parameters. The motivation is
that the proof of a theorem should not influence its statement.
However, before this commit, this was not the case for examples when
their type was a proposition.
This discrepancy often confused users.

Additionally, we considered extending the above behavior to definitions
when
1- When their type is a proposition. However, it still caused disruption
in Mathlib.
2- When their type is provided. That is, we would keep the current
behavior only if `: <type>` was omitted. This would make the elaborator
for `def` much closer to the one for `theorem`, but it proved to be too
restrictive.
For example, the following instance in `Core.lean` would fail:
```
instance {α : Sort u} [Setoid α] : HasEquiv α :=
  ⟨Setoid.r⟩
```
and we would have to write instead:
```
instance {α : Sort u} [Setoid α] : HasEquiv.{u, 0} α :=
  ⟨Setoid.r⟩
```
There are other failures like this in the core, and we assume many more
in Mathlib.

closes #4398
closes #4482 Remark: PR #4482 implements option 1 above. We may consider
it again in the future.
2024-06-24 01:18:41 +00:00
Kim Morrison
0f416c6a83 chore: mark releases as prerelease (#4544) 2024-06-24 01:04:04 +00:00
Markus Schmaus
5178c4b6da feat: change succ to + 1 (#4532)
The simp normal form of `succ` is `+ 1`, this changes additional
theorems to use that normal form.
2024-06-24 00:38:22 +00:00
Siddharth
bc6188a70a feat: BitVec.twoPow and lemmas, toward bitblasting multiplication for LeanSAT (#4417)
We add a new definition `BitVec.twoPow w i` to represent `(1#w <<< i)`.
This expression is used to test bits when building the multiplication
bitblaster.

Patch 1/?, being peeled from https://github.com/opencompl/lean4/pull/6.

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
2024-06-23 22:37:02 +00:00
Leonardo de Moura
33f7865bbb fix: cached results at synthInstance? (#4530)
Synthesized type class instances may introduce new metavariables, and we
should actually cache `AbstractMVarsResult`.

closes #2283
2024-06-23 17:54:35 +00:00
Lean stage0 autoupdater
968aff403b chore: update stage0 2024-06-23 10:09:59 +00:00
Joachim Breitner
1076ca1ead chore: unset parseQuotWithCurrentStage in stage1’s src/stdlib_flags.h (#4537) 2024-06-23 09:44:14 +00:00
Bhavik Mehta
43a9c73556 chore: fix typo and incorrect name in doc (#4404)
Fixes typo "reflexivitiy" to "reflexivity", and changes exact Eq.rfl to
exact rfl, since Eq.rfl does not exist.

(I got something confused wrt the bot message on #4367 and accidentally
closed that one, so making this one instead, which I think satisfies the
requirements it wanted.)

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-06-23 09:06:50 +00:00
Kim Morrison
a92e9c7944 chore: move @[simp] from pred_le to sub_one_le (#4522)
(We already have a simp lemma unfolding `pred` to `· - 1`.)

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-06-23 07:58:38 +00:00
Joachim Breitner
378b02921d refactor: port recOn construction to Lean (#4516)
this is the simplest of the constructions to be ported from C++ to Lean,
so I’ll PR this one first.

This begins to put each construction into its own file, as it was the
case with C++.

For validation I developed this in a separate repository at
https://github.com/nomeata/lean-constructions/tree/fad715e
and checked that all `.recOn` declarations found in Lean and Mathlib are
identical (per `==`) to the ones produced by the C code.
2024-06-23 07:36:27 +00:00
Bolton Bailey
5426a5c8b3 chore: Remove simp from Option.elim, replace with individal simp lemmas (#4504)
This PR removes the `simp` attribute from `Option.elim` and adds it to
two related simp lemmas, `Option.elim_none` and `Option.elim_some`.

This PR comes from some discussion
[here](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/optionEquivLeft_apply.20simp/near/438321459)
about `simps!` feeling too aggressive in unfolding this lemma.
2024-06-23 00:58:25 +00:00
Kim Morrison
d7da45cbe6 chore: fix explicitness of Prod.map lemmas (#4533) 2024-06-22 11:05:19 +00:00
Mac Malone
24d51b90cc fix: lake: remove module dynlib from platform-independent trace (#4478)
Fixes a bug where Lake incorrectly included the module dynlib in a
platform-independent trace. It was incorrectly excluded only external
native libraries from the trace. Also adds a test.
2024-06-22 01:24:23 +00:00
Mac Malone
0d529e18a6 feat: expose flags for the bundled C compiler (#4477)
Expose the C compiler and linker flags used with the bundled compiler
(clang) to Lean code. This is needed to skip the use of `leanc` in Lake.
2024-06-22 01:23:33 +00:00
Sebastian Ullrich
4808eb7c4b chore: Nix: fix cacheRoots 2024-06-21 23:35:38 +02:00
Sebastian Ullrich
5767a597d4 chore: update stage0 2024-06-21 22:04:02 +02:00
Sebastian Ullrich
e665a0d716 chore: Nix: fix update-stage0 2024-06-21 22:02:10 +02:00
Joachim Breitner
073b2cfc83 fix: cdot parser error message range (#4528)
as #4527 describes there is inconsistency between `by`, `case` and
`next` on the one hand who, if the goal isn’t closed, put squiggly
underlines on the first line, and `.`, which so far only squiggled the
dot (which is a very short symbol!)

With this change the same mechanism as used by `case`, namely
`withCaseRef`, is also used for `.`.

There is an argument for the status quo: The `.` tactic is more commonly
used
with further tactics on the same line, and thus there is now a higher
risk that
the user might think that the first tactic is broken. But 

* the same argument does apply to `by` and `case` where there was an
intentional
  choice to do it this way
* consistency and
* a squiggly line just under the short `.` is easy to miss, so it is
actually
better to underlining more here (at least until we have a better way to
  indicate incomplete proofs, which I have hopes for)

Fixes #4527, at least most of it.
2024-06-21 15:06:07 +00:00
David Thrane Christiansen
84e46162b5 feat: more infrastructure for tactic documentation (#4490)
This is the groundwork for a tactic index in generated documentation, as
there was in Lean 3. There are a few challenges to getting this to work
well in Lean 4:
* There's no natural notion of *tactic identity* - a tactic may be
specified by multiple syntax rules (e.g. the pattern-matching version of
`intro` is specified apart from the default version, but both are the
same from a user perspective)
* There's no natural notion of *tactic name* - here, we take the
pragmatic choice of using the first keyword atom in the tactic's syntax
specification, but this may need to be overridable someday.
* Tactics are extensible, but we don't want to allow arbitrary imports
to clobber existing tactic docstrings, which could become unpredictable
in practice.

For tactic identity, this PR introduces the notion of a *tactic
alternative*, which is a `syntax` specification that is really "the same
as" an existing tactic, but needs to be separate for technical reasons.
This provides a notion of tactic identity, which we can use as the basis
of a tactic index in generated documentation. Alternative forms of
tactics are specified using a new `@[tactic_alt IDENT]` attribute,
applied to the new tactic syntax. It is an error to declare a tactic
syntax rule to be an alternative of another one that is itself an
alternative. Documentation hovers now take alternatives into account,
and display the docs for the canonical name.

*Tactic tags*, created with the `register_tactic_tag` command, specify
tags that may be applied to tactics. This is intended to be used by
doc-gen and Verso. Tags may be applied using the `@[tactic_tag TAG1 TAG2
...]` attribute on a canonical tactic parser, which may be used in any
module to facilitate downstream projects introducing tags that apply to
pre-existing tactics. Tags may not be removed, but it's fine to
redundantly add them. The collection of tags, and the tactics to which
they're applied, can be seen using the `#print tactic tags` command.

*Extension documentation* provides a structured way to document
extensions to tactics. The resulting documentation is gathered into a
bulleted list at the bottom of the tactic's docstring. Extensions are
added using the `tactic_extension TAC` command. This can be used when
adding new interpretations of a tactic via `macro_rules`, when extending
some table or search index used by the tactic, or in any other way. It
is a command to facilitate its flexible use with various extension
mechanisms.
2024-06-21 12:49:30 +00:00
Kim Morrison
a1a245df40 chore: missing Prod.map lemmas (#4526) 2024-06-21 11:53:50 +00:00
Kim Morrison
07ee719761 chore: fix statement of List.filter_congr (#4525) 2024-06-21 11:36:07 +00:00
Kim Morrison
ee9996ec89 chore: fix statement of List.filter_congr (#4524) 2024-06-21 11:35:43 +00:00
Markus Schmaus
d2ae678fbf feat: change List.length_cons to use + 1 instead of succ (#4500)
The simp normal form of `succ` is `+ 1`, this changes `List.length_cons`
to use that normal form.
2024-06-21 11:25:07 +00:00
David Thrane Christiansen
2a00d6cf70 doc: more detailed docstring for PersistentEnvExtension (#4501)
Describes the intended modes of use, potential performance tradeoffs,
and data representation in more detail.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-06-21 08:34:04 +00:00
Sebastian Ullrich
d020a9c5a6 feat: introduce Std (#4499)
Situated between `Init` and `Lean`, provides functionality not in the
prelude to both Lean's implementation and external users
2024-06-21 07:08:45 +00:00
Kim Morrison
301a89aba4 feat: lemmas about List.map (#4521) 2024-06-21 06:40:30 +00:00
Mac Malone
f32780d863 refactor: lake: more robust trace reading (#4518)
The recent change of the trace format exposed some unexpected issues
with Lake's tracing handling. This aims to fix that.

Lake will now perform a rebuild if the trace file is invalid/unreadable.
However, it will still fall back to modification times if the trace file
is missing. Also, Lake is now backwards compatible with the previous
pure numeric traces (and tolerates the absence of a `log` field in the
JSON trace).
2024-06-21 01:43:05 +00:00
Sebastian Ullrich
d6eab393f4 chore: fix benchmark 2024-06-20 18:18:41 +02:00
Sebastian Ullrich
1f732bb3b7 fix: missing unboxing in interpreter when loading initialized value (#4512)
Fixes #4457
2024-06-20 10:06:24 +00:00
Joe Hendrix
7d7f378e02 feat: complete Int div/mod simprocs (#3850)
This PR introduces complete simprocs for all the Int versions of
div/mod, and makes some small refactoring of Int lemmas and
library_search.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-06-20 04:42:31 +00:00
Kim Morrison
95db616cb6 chore: cherry-pick stray test from #3850 (#4509)
#3850 included a commit that added an extra test for `exact?`, but was
otherwise unrelated the to PR. It also removed a test. I've
cherry-picked that test over, and restored the deleted test, and next
will remove the commit from #3850.
2024-06-20 01:00:45 +00:00
Leonardo de Moura
45c5d009d6 fix: dsimp missing theorems for literals (#4467) 2024-06-20 00:35:53 +00:00
Leonardo de Moura
458835360f fix: [implemented_by] at functions defined by well-founded recursion (#4508)
closes #2899
2024-06-20 00:06:38 +00:00
Leonardo de Moura
3e05b0641b chore: fix test 2024-06-20 01:05:52 +02:00
Leonardo de Moura
53be53f5ae chore: update stage0 2024-06-20 01:05:52 +02:00
Leonardo de Moura
dac1dacc5b feat: add Rewrite.Config.newGoals field
It is not used yet. We need a update-stage0.
2024-06-20 01:05:52 +02:00
Leonardo de Moura
d3a7569c97 refactor: move ApplyNewGoals and ApplyConfig to Init 2024-06-20 01:05:52 +02:00
Leonardo de Moura
49f058cb76 feat: open _root_.<namespace> (#4505)
closes #3045
2024-06-19 21:59:46 +00:00
Joachim Breitner
bc047b8530 refactor: port mk_definition_inferring_unsafe to Lean (#4498)
this already can be used in two places, and will be used more as I port
more constructions. Hope the location in `Lean.Environment` is ok.
2024-06-19 18:26:19 +00:00
JovanGerb
c7c50a8bec chore: fix linter errors (#4502)
The linters in Batteries can be used to spot mistakes in Lean. See the
message on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Go-to-def.20on.20typeclass.20fields.20and.20type-dependent.20notation/near/442613564).
These are the different linters with errors:

- unusedArguments:
There are many unused instance arguments, especially a redundant `[Monad
m]` is very common
- checkUnivs:
There was a problem with universes in a definition in
`Init.Control.StateCps`. I fixed it by adding a `variable` statement for
the implicit arguments in the file.
- defLemma:
many proofs are written as `def` instead of `theorem`, most notably
`rfl`. Because `rfl` is used as a match pattern, it must be a def. Is
this desirable?
The keyword `abbrev` is sometimes used for an alias of a theorem, which
also results in a def. I would want to replace it with the `alias`
keyword to fix this, but it isn't available.
- dupNamespace:
I fixed some of these, but left `Tactic.Tactic` and `Parser.Parser` as
they are as these seem intended.
- unusedHaveSuffices:
  I cleaned up a few proofs with unused `have` or `suffices`
- explicitVarsOfIff:
  I didn't fix any of these, because that would be a breaking change.
- simpNF:
I didn't fix any of these, because I think that requires knowing the
intended simplification order.
2024-06-19 18:24:08 +00:00
Leonardo de Moura
de269060d1 chore: fix tests 2024-06-19 20:21:34 +02:00
Leonardo de Moura
e8f768f9fd chore: cleanup PersistentHashMap.lean 2024-06-19 20:21:34 +02:00
Leonardo de Moura
0783d0fcbe chore: re-enable #reduce elaborator 2024-06-19 20:21:34 +02:00
Leonardo de Moura
2518105bd9 chore: update stage0 2024-06-19 20:21:34 +02:00
Leonardo de Moura
9096d6fc71 fix: remove PersistentHashMap.size
It is buggy and was unnecessary overhead.

closes #3029
2024-06-19 20:21:34 +02:00
Mario Carneiro
0a1a855ba8 fix: validate UTF-8 at C++ -> Lean boundary (#3963)
Continuation of #3958. To ensure that lean code is able to uphold the
invariant that `String`s are valid UTF-8 (which is assumed by the lean
model), we have to make sure that no lean objects are created with
invalid UTF-8. #3958 covers the case of lean code creating strings via
`fromUTF8Unchecked`, but there are still many cases where C++ code
constructs strings from a `const char *` or `std::string` with unclear
UTF-8 status.

To address this and minimize accidental missed validation, the
`(lean_)mk_string` function is modified to validate UTF-8. The original
function is renamed to `mk_string_unchecked`, with several other
variants depending on whether we know the string is UTF-8 or ASCII and
whether we have the length and/or utf8 char count on hand. I reviewed
every function which leads to `mk_string` or its variants in the C code,
and used the appropriate validation function, defaulting to `mk_string`
if the provenance is unclear.

This PR adds no new error handling paths, meaning that incorrect UTF-8
will still produce incorrect results in e.g. IO functions, they are just
not causing unsound behavior anymore. A subsequent PR will handle adding
better error reporting for bad UTF-8.
2024-06-19 14:05:48 +00:00
Joachim Breitner
c4718a87ab refactor: constructions: modify environment in lean world (#4474)
this is a first step towards porting the code `constructions.cpp` to
Lean: It leaves the construction of the `Declaration` untouched, but
moves adding the declarations to the environment, and setting various
attributes, to the Lean world.

This allows the remaining logic (the construction of the `Declaration`)
to be implemented in Lean separately and easily compared to the C++
implementation, before we replace that too.

To that end, `Declaraion` gains an `BEq` instance.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
Co-authored-by: Arthur Adjedj <arthur.adjedj@ens-paris-saclay.fr>
2024-06-19 08:58:53 +00:00
Leonardo de Moura
357b52928f fix: global definition shadowing a local one when using dot-notation (#4497)
closes #3079
2024-06-19 05:52:45 +00:00
Mac Malone
bd45c0cd04 fix: lake: visit direct deps before adding manifest entries (#4485)
Fixes a bug in #4371 where the version of a package used by a dependency
would take precedence over that of a the same package as a direct
dependency if that package had a a manifest. This was because the direct
dependency's manifest entries were added before all the direct
dependencies were visited.
2024-06-19 02:49:59 +00:00
Mac Malone
f9952e8c39 refactor: touchup require syntax & docs (#4496)
A set of general tweaks of the `require` syntax and docs that provide a
base for #4495.

The sole significant behavioral change is that the `name` field of a
`require` in TOML now falls back to being interpreted as a simple string
name if the value is not a valid Lean identifier. This means that a
require for a package like `doc-gen4` can be written without French
quotes.
2024-06-19 02:49:57 +00:00
Kyle Miller
1b5b91cccf doc: add docstrings for dsimp configuration (#4258)
The dsimp configuration is a subset of the simp configuration, and so
it's a matter of copying the docstrings.
2024-06-19 00:05:25 +00:00
JovanGerb
74f1373706 chore: remove redundant if-else in isDefEqQuickOther (#4388)
I removed a redundant `if tFn.isMVar || sFn.isMVar then ... else return
LBool.undef` in the `else` clause of
```
if !tFn.isMVar && !sFn.isMVar then
  return LBool.undef
else
```
2024-06-18 23:44:29 +00:00
JovanGerb
c87205bc9b fix: eta reduce mvar assignments in isDefEq (#4387)
I made a modification to the `mkLambdaFVars` function, adding a
`etaReduce : Bool` parameter that determines whether a new lambda of the
form `fun x => f x` should be replaced by `f`. I then set this option to
true at `isDefEq` when processing metavariable assignments.

This means that many unnecessary eta unreduced expression are now
reduced. This is beneficial for users, so that they do not have to deal
with such unreduced expressions. It is also beneficial for performance,
leading to a 0.6% improvement in build instructions. Most notably,
`Mathlib.Algebra.DirectLimit`, previously a top 50 slowest file, has
sped up by 40%.

Quite a number of proof in mathlib broke. Many of these involve removing
a now unnecessary `simp only`. In other cases, a simp or rewrite doesn't
work anymore, such as a `simp_rw [mul_comm]` that was used to rewrite
`fun x => 2*x`, but now this term has turned into `HMul.hMul 2`.

Closes #4386
2024-06-18 23:41:40 +00:00
Leonardo de Moura
294b1d5839 chore: cleanup (#4494)
closes #4287
closes #4288
2024-06-18 23:39:16 +00:00
Leonardo de Moura
167771923e test: for isDefEq issue (#4492)
The issue has already been fixed in previous PRs.

closes #2461
2024-06-18 17:54:55 +00:00
Sebastian Ullrich
eb67654ae6 feat: incremental next and tactic if (#4459) 2024-06-18 12:36:59 +00:00
Joachim Breitner
6a8cb7ffa0 chore: nix shell: add gdb (#4476)
seems to work better when it comes from the same nixpkgs that we use for
building, it seems. And is plain convenient.
2024-06-18 11:07:20 +00:00
Kim Morrison
face4cef75 feat: complete API for List.replicate (#4487)
This is not the most exciting place to start, but I started here to:
* pick a function with little development in Batteries and Mathlib, so I
wouldn't have conflicts
* that is easy!
* to see how much effort it is to get fairly complete coverage
* and to set up some infrastructure to be used later, i.e.
`tests/lean/run/list_simp.lean`
2024-06-18 08:30:09 +00:00
Kim Morrison
6cad341764 chore: @[simp] List.getElem?_eq_getElem (#4488)
This is often helpful, and Mathlib doesn't mind.
2024-06-18 08:29:51 +00:00
Kim Morrison
2995e74133 chore: missing withSynthesize in #check_tactic (#4489)
Ran into this writing `#check_simp` tests for `List`. I guess it wasn't
a probably for `Bool` / `Prop`.
2024-06-18 05:24:45 +00:00
Kim Morrison
d768f46ba6 chore: @[simp] Nat.min_assoc (#4486) 2024-06-18 03:08:34 +00:00
Leonardo de Moura
97588301e1 fix: deprecated warning position at simp arguments (#4484)
closes #4452
2024-06-17 23:21:14 +00:00
Leonardo de Moura
fca87da2d4 fix: simp support for OfNat instances that are functions (#4481)
closes #4462
2024-06-17 22:01:25 +00:00
Leonardo de Moura
3c4d6ba864 feat: new #reduce elaborator
closes #4465
2024-06-17 23:27:34 +02:00
Leonardo de Moura
2c83e080f7 chore: update stage0 2024-06-17 23:27:34 +02:00
Leonardo de Moura
8f023b85c5 chore: move #reduce parser to Init/Notation.lean 2024-06-17 23:27:34 +02:00
Leonardo de Moura
06731f99d4 chore: missing instances (#4479)
cc @shigoel
2024-06-17 20:14:00 +00:00
Joachim Breitner
59a09fb4e7 feat: use priorities to ensure simp applies eqational lemmas in order (#4434)
This assigns priorities to the equational lemmas so that more specific
ones
are tried first before a possible catch-all with possible
side-conditions.

We assign very low priorities to match the simplifiers behavior when
unfolding
a definition, which happens in `simpLoop`’ `visitPreContinue` after
applying
rewrite rules.

Definitions with more than 100 equational theorems will use priority 1
for all
but the last (a heuristic, not perfect).

fixes #4173, to some extent.
2024-06-17 18:22:28 +00:00
Mac Malone
42c4a770c2 chore: lake: fix tests/init cleanup (#4468)
Forgot to update `tests/init/clean.sh` when I updated the test and
`.gitignore`.
2024-06-17 16:17:59 +00:00
Kim Morrison
d334e96275 chore: add forgotten deprecation (#4475) 2024-06-17 08:46:44 +00:00
Kim Morrison
e9caf40493 feat: cleanup @[simp] annotations for List (#4473)
These are mostly (sensible) `@[simp]` annotations that Mathlib adds.
2024-06-17 07:31:48 +00:00
Kim Morrison
a09726bb94 feat: lemmas about List.filter (#4472)
This upstreams some lemmas from Batteries, giving dumbed-down proofs, as
I do not (yet?) want to move up `List.Sublist`.
2024-06-17 06:53:16 +00:00
Markus Schmaus
1cf71e54cf feat: add missing theorems for + 1 and - 1 normal form (#4242)
`Nat.succ_eq_add_one` and `Nat.pred_eq_sub_one` are now simp lemmas. For
theorems about `Nat.succ` or `Nat.pred` without corresponding theorem
for `+ 1` or `- 1`, this adds the corresponding theorem.
2024-06-17 05:35:32 +00:00
Kim Morrison
2efcbfe803 feat: improvements to List.set and List.concat API (#4470) 2024-06-17 05:10:35 +00:00
Kim Morrison
03d01f4024 chore: reorganisation of List API (#4469)
This PR neither adds nor removes material, but improves the organization
of `Init/Data/List/*`.

These files are essentially completely re-ordered, to ensure that
material is developed in a consistent order between `List.Basic`,
`List.Impl`, `List.BasicAux`, and `List.Lemmas`.

Everything is organised in subsections, and I've added some module docs.
2024-06-17 04:21:53 +00:00
John Tristan
f237fb67eb doc: documenting Char and upstreaming extensionality from batteries (#4438)
* Basic documentation for characters
* Upstreamed two extensionality theorems from batteries

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-06-16 00:43:34 +00:00
Kim Morrison
e10a37d80d feat: switching List lookup normal forms to L[n] and L[n]? (#4400)
This is presumably going to have significant breakage downstream.
2024-06-15 07:35:36 +00:00
Joachim Breitner
fe0cb97c5d feat: use lazy MessageData for omega errors (#4360)
presumably this avoids unnecessary work when `omega` is used in tactic
combinators where the error message is never seen. Measurement did not
show
any significant changes, though.

With an artificial sleep in
```diff
diff --git a/src/Lean/Elab/Tactic/Omega/Frontend.lean b/src/Lean/Elab/Tactic/Omega/Frontend.lean
index fd297eef60..31ea3f6bd0 100644
--- a/src/Lean/Elab/Tactic/Omega/Frontend.lean
+++ b/src/Lean/Elab/Tactic/Omega/Frontend.lean
@@ -538,6 +538,7 @@ def formatErrorMessage (p : Problem) : OmegaM MessageData := do
     else
       let as ← atoms
       return .ofLazyM (es := as) do
+        IO.sleep 10000
         let mask ← mentioned as p.constraints
         let names ← varNames mask
         return m!"a possible counterexample may satisfy the constraints\n" ++
```
I can observe that `omega` is slow and `try omega` fast, so it seems to
work at least.
2024-06-14 20:21:37 +00:00
JovanGerb
c96797eb93 fix: show argument name in implicit argument error (#4426)
When an implicit argument cannot be inferred, the error should show the
name of the argument.

Showing the argument name in the error message for an uninstantiated
metavariable was introduced in da33f498f5,
but this implementation causes some argument names to get lost.
2024-06-14 18:08:42 +00:00
JovanGerb
4798c8418c perf: replace hasMVar by hasExprMVar in CollectMVars, FindMVar (#4451)
The modules `CollectMVars` and `FindMVars` only search for expression
metavariables and not level metavariables, so we should use
`Expr.hasExprMVar` instead of `Expr.hasMVar`.
2024-06-14 18:06:00 +00:00
David Thrane Christiansen
456ed44550 feat: add a linter for local vars that clash with their constructors (#4301)
This came up when watching new Lean users in a class situation. A number
of them were confused when they omitted a namespace on a constructor
name, and Lean treated the variable as a pattern that matches anything.

For example, this program is accepted but may not do what the user
thinks:
```
inductive Tree (α : Type) where
  | leaf
  | branch (left : Tree α) (val : α) (right : Tree α)

def depth : Tree α → Nat
  | leaf => 0
```
Adding a `branch` case to `depth` results in a confusing message.

With this linter, Lean marks `leaf` with:
```
Local variable 'leaf' resembles constructor 'Tree.leaf' - write '.leaf' (with a dot) or 'Tree.leaf' to use the constructor.
note: this linter can be disabled with `set_option linter.constructorNameAsVariable false`
```

Additionally, the error message that occurs when invalid names are
applied in patterns now suggests similar names. This means that:
```
def length (list : List α) : Nat :=
  match list with
  | nil => 0
  | cons x xs => length xs + 1
```
now results in the following warning on `nil`:
```
warning: Local variable 'nil' resembles constructor 'List.nil' - write '.nil' (with a dot) or 'List.nil' to use the constructor.
note: this linter can be disabled with `set_option linter.constructorNameAsVariable false`
```

and error on `cons`:
```
invalid pattern, constructor or constant marked with '[match_pattern]' expected

Suggestion: 'List.cons' is similar
```

The list of suggested constructors is generated before the type of the
pattern is known, so it's less accurate, but it truncates the list to
ten elements to avoid being overwhelming. This mostly comes up with
`mk`.
2024-06-14 13:03:09 +00:00
Sebastian Ullrich
237f392cc1 chore: update stage0 2024-06-14 12:35:45 +02:00
Sebastian Ullrich
5eb5fa49cf chore: Nix: fix update-stage0-commit 2024-06-14 12:35:14 +02:00
L
5d2403535a feat: default pp if pp expr/syntax/level without context (#4433)
This restores the behavior prior to
9f6bbfa106
for `MessageData.ofSyntax` `MessageData.ofExpr`, and
`MessageData.ofLevel` while staying within the new `.ofLazy` paradigm.

Also adds some documentation to help developers understand the missing
context issue.

Closes #4432

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-06-14 08:55:49 +00:00
Kim Morrison
2cf478cbbe chore: prefer · == a over a == · (#3056)
We recently discovered inconsistencies in Mathlib and Std over the
ordering of the arguments for `==`.

The most common usage puts the "more variable" term on the LHS, and the
"more constant" term on the RHS, however there are plenty of exceptions,
and they cause unnecessary pain when switching (particularly, sometimes
requiring otherwise unneeded `LawfulBEq` hypotheses).

This convention is consistent with the (obvious) preference for `x == 0`
over `0 == x` when one term is a literal.

We recently updated Std to use this convention
https://github.com/leanprover/std4/pull/430

This PR changes the two major places in Lean that use the opposite
convention, and adds a suggestion to the docstring for `BEq` about the
preferred convention.
2024-06-14 04:08:45 +00:00
Kim Morrison
b096e7d5f2 chore: make Name.isInternalDetail public, to remove duplication downstream (#4454)
This private function is duplicated downstream, so move it to the
`Lean.Name` namespace.
2024-06-14 01:55:52 +00:00
Mac Malone
1835dd123d feat: configuration DSL touchups (#4439)
This incorporates many general Lake DSL changes from #2439 and adds some
new related changes.

* Rework configuration names (e.g., `package <name>`)
  * String literals ca now be used instead of identifiers for names.
* The name syntax is now optional and can instead be set via the `name`
field.
* Avoid French quotes in `lake new` / `lake init` templates (except in
`lean_lib` names). This is not done for `lean_lib` because it needs a
proper identifier for its root. It could use a string and reparse it as
an identifier, but this seems liable to produce confusion.
* The `exe` templates now names it main module `Main` like the `std`
template.
* Improve `math` template error if `lean-toolchain` fails to download.
* Lake now logs a warning rather than an error on unknown configuration
fields. This increases the Lake DSL's cross-version compatibility.

Closes #3385.
2024-06-14 00:17:43 +00:00
Mac Malone
db74ee9e83 feat: lake: reliably cache logs and hashes (#4402)
Moves the cached log into the trace file (no more `.log.json`). This
means logs are no longer cached on fatal errors and this ensures that an
out-of-date log is not associated with an up-to-date trace. Separately,
`.hash` file generation was changed to be more reliable as well. `.hash`
files are deleted as part of the build and always regenerate with
`--rehash`.

Closes #2751.
2024-06-13 23:15:49 +00:00
Mac Malone
285a313078 chore: src/lake/lakefile.toml (#4446)
Use a TOML file for the Lake configuration of the `src/lake` directory
instead of a Lean file. This avoids having to load a version of the Lake
library to build Lake.
2024-06-13 16:56:32 +00: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
749bf9c279 fix: bad 'unknown package' error message (#4424)
This message is older than corresponding, better checks in Lake and
vscode-lean4

Fixes #4419

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-06-13 15:48:20 +00:00
Sebastian Ullrich
7b971b90c5 fix: redundant and wrong case in forEachModuleInDir (#4425)
Calling `f` on `dir.lean` for each `dir` is unnecessary as we call it on
each file anyway and the check was wrong because it ignored
`entry.root`.
2024-06-13 15:40:27 +00:00
Marc Huisinga
3119fd0240 fix: make watchdog more resilient against badly behaving clients (#4443)
This PR addresses some non-critical but annoying issues that sometimes
cause the language server to report an error:
- When using global search and replace in VS Code, the language client
sends `textDocument/didChange` notifications for documents that it never
told the server to open first. Instead of emitting an error and crashing
the language server when this occurs, we now instead ignore the
notification. Fixes #4435.
- When terminating the language server, VS Code sometimes still sends
request to the language server even after emitting a `shutdown` request.
The LSP spec explicitly forbids this, but instead of emitting an error
when this occurs, we now error requests and ignore all other messages
until receiving the final `exit` notification. Reported on Zulip several
times over the years but never materialized as an issue, e.g.
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Got.20.60shutdown.60.20request.2C.20expected.20an.20.60exit.60.20notification/near/441914289.
- Some language clients attempt to reply to the file watcher
registration request before completing the LSP initialization dance. To
fix this, we now only send this request after the initialization dance
has completed. Fixes #3904.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-06-13 13:48:36 +00:00
Sebastian Ullrich
16cad2b45c chore: CI: do not fetch complete history 2024-06-13 14:50:49 +02:00
Sebastian Ullrich
6d265b42b1 chore: CI: fix github.event.pull_request.merge_commit_sha sometimes not being available 2024-06-13 14:47:42 +02:00
Sebastian Ullrich
c5120c1d0d chore: CI: fix Wasm release-ci (#4442) 2024-06-13 11:58:49 +00:00
Sebastian Ullrich
37f8b0390d chore: CI: fix workflow change breaking unrebased PRs (#4441) 2024-06-13 09:56:31 +00:00
Sebastian Ullrich
bd3b466f2f chore: CI: fix speedcenter tests (#4440) 2024-06-13 10:53:47 +02:00
Mac Malone
f3274d375a refactor: lake: simplify load code (#4371)
Simplifies the Lake dependency resolution code. Largely split from
#3998.
2024-06-13 03:22:47 +00:00
Sebastian Ullrich
a8de4b3b06 chore: CI: use Namespace runners (#4427) 2024-06-12 16:06:41 +00:00
Sebastian Ullrich
8d3be96024 fix: tactics in terms in tactics may break incremental reporting (#4436)
A pending tactic mvar managed to escape into an unexpected context in
specific circumstances.

```lean
example : True := by
  · rw [show 0 = 0 by rfl]
```
* Term elaboration of the `show` creates a pending mvar for the `by rfl`
proof
* `rw` fails with an exception because the pattern does not occur in the
target
* `cdot` catches the exception and admits the goal
* `Term.runTactic` [synthesizes all pending mvars from the tactic's
execution](5f9dedfe5e/src/Lean/Elab/SyntheticMVars.lean (L350)),
including the `by rfl` proof. But this would not have happened without
`cdot` as the exception would have skipped that invocation!
* Now incrementality is confused because the nested `by rfl` proof is
unexpectedly run in the same context as the top-level proof, writing to
the wrong promise, and the error message is lost

Solution: disable incrementality for these pending mvars
2024-06-12 14:59:24 +00:00
hwatheod
bedcbfcfee chore: fix typo in trace.split.failure error message (#4431)
should be "failure" not "failures"

Co-authored-by: q r <qr@abc.local>
2024-06-12 05:57:29 +00:00
Leonardo de Moura
ce6ebd1044 feat: dsimprocs for ite and dite (#4430) 2024-06-11 23:36:18 +00:00
Leonardo de Moura
ab73ac9d15 fix: missing simproc for BitVec equality (#4428) 2024-06-11 22:05:28 +00:00
Leonardo de Moura
3bd39ed8b6 perf: a isDefEq friendly Fin.sub (#4421)
The performance issue at #4413 is due to our `Fin.sub` definition.
```
def sub : Fin n → Fin n → Fin n
  | ⟨a, h⟩, ⟨b, _⟩ => ⟨(a + (n - b)) % n, mlt h⟩
```
Thus, the following runs out of stack space
```
example (a : UInt64) : a - 1 = a :=
  rfl
```
at the `isDefEq` test
```
(a.val.val + 18446744073709551615) % 18446744073709551616 =?= a.val.val
```

From the user's perspective, this timeout is unexpected since they are
using small numerals, and none of the other `Fin` basic operations (such
as `Fin.add` and `Fin.mul`) suffer from this problem.

This PR implements an inelegant solution for the performance issue. It
redefines `Fin.sub` as
```
def sub : Fin n → Fin n → Fin n
  | ⟨a, h⟩, ⟨b, _⟩ => ⟨((n - b) + a) % n, mlt h⟩
```
This approach is unattractive because it relies on the fact that
`Nat.add` is defined using recursion on the second argument.

The impact on this repo was small, but we want to evaluate the impact on
Mathlib.

closes #4413
2024-06-11 17:18:11 +00:00
Sebastian Ullrich
5f9dedfe5e chore: slightly more informative trace.Elab.snapshotTree 2024-06-11 10:44:04 +02:00
Kim Morrison
2a2b276ede chore: unify String.csize : Nat and Char.utf8Size : UInt32 as Char.size : Nat (#4357)
It seems:
* there was no actual need for the UInt32 valued version
* downstream we were getting duplicative lemmas about both
* so lets reduce the API surface area!

If anyone would prefer the remaining function is still called
`Char.utf8Size` I will happily change it. (`size` is hopefully still
unambiguous, and it's helpful to rename here so we can give a
deprecation warning that explains the type signature change.)

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-06-11 02:51:18 +00:00
Leonardo de Moura
ec775df6cc fix: rw should not include existing goal metavariables in the resulting subgoals (#4385)
closes #4381
2024-06-11 02:50:58 +00:00
Leonardo de Moura
c8e668a9ad fix: occurs check at metavariable types (#4420)
closes #4405
2024-06-11 00:16:19 +00:00
Leonardo de Moura
a1c8a941f0 fix: universe parameter order discrepancy between theorem and def (#4408)
Before this commit, the `theorem` and `def` declarations had different
universe parameter orders.
For example, the following `theorem`:
```
theorem f (a : α) (f : α → β) : f a = f a := by
  rfl
```
was elaborated as
```
theorem f.{u_2, u_1} : ∀ {α : Sort u_1} {β : Sort u_2} (a : α) (f : α → β), f a = f a :=
  fun {α} {β} a f => Eq.refl (f a)
```
However, if we declare `f` as a `def`, the expected order is produced.
```
def f.{u_1, u_2} : ∀ {α : Sort u_1} {β : Sort u_2} (a : α) (f : α → β), f a = f a :=
  fun {α} {β} a f => Eq.refl (f a)
```

This commit fixes this discrepancy.

@semorrison @jcommelin: This might be a disruptive change to Mathlib,
but it is better to fix the issue asap. I am surprised nobody has
complained about this issue before. I discovered it while trying to
reduce discrepancies between `theorem` and `def` elaboration.
2024-06-10 23:37:52 +00:00
L
6a7bed94d3 fix: kernel exception from fvars left from ?m a b instantiation (#4410)
Closes #4375

The following example raises `error: (kernel) declaration has free
variables '_example'`:
```lean
example: Nat → Nat :=
  let a : Nat := Nat.zero
  fun (_ : Nat) =>
    let b : Nat := Nat.zero
    (fun (_ : a = b) => 0) (Eq.refl a)
```

During elaboration of `0`, `elabNumLit` creates a synthetic mvar
`?_uniq.16` which gets abstracted by `elabFun` to `?_uniq.16 :=
?_uniq.50 _uniq.6 _uniq.12`. The `isDefEq` to `instOfNatNat 0` results
in:
```
?_uniq.50 :=
  fun (x._@.4375._hyg.13 : Nat) =>
    let b : Nat := Nat.zero
    fun (x._@.4375._hyg.23 : Eq.{1} Nat _uniq.4 b) =>
      instOfNatNat 0
```

This has a free variable `_uniq.4` which was `a`.

When the application of `?_uniq.50` to `#[#2, #0]` is instantiated, the
`let b : Nat := Nat.zero` blocks the beta-reduction and `_uniq.4`
remains in the expression.

fix: add `(useZeta := true)` here:

ea46bf2839/src/Lean/MetavarContext.lean (L567)
2024-06-10 19:02:27 +00:00
Henrik Böving
366f3ac272 feat: order the output of #print axioms (#4416)
Closes #4415
2024-06-10 09:17:05 +00:00
Sebastian Ullrich
ea46bf2839 fix: non-incremental command blocking further incremental reporting in macro (#4407)
As [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/v4.2E9.2E0-rc1.20discussion/near/443356495).
2024-06-08 16:50:15 +00:00
Sebastian Ullrich
adfd438164 fix: incremental reuse leading to goals in front of the text cursor being shown (#4395)
As [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/maybe.20a.20cache.20bug.3F).

We expected that for sound reuse of elaboration results, it is
sufficient to compare the old and new syntax tree's structure and atoms
including position info, but not the whitespace in between them.
However, we have at least one request handler, the goal view, that
inspects the whitespace after a tactic and thus could return incorrect
results on reuse. For now we implement the straightforward fix of
checking the whitespace as well. Alternatives like updating the
whitespace stored in the reused info tree are tbd.

This has the slight disadvantage that adding whitespace at the end of a
tactic will re-execute it (or the entire body, but not the header, if
the body is not a tactic block), but only up to typing the first
character of the next tactic or command.
2024-06-08 15:08:14 +00:00
Mac Malone
748eab9511 refactor: lake: inputBinFile / inputTextFile (#4384)
Deprecates `inputFile` and replaces it with `inputBinFile` and
`inputTextFile`. `inputTextFile` normalizes line endings, which helps
ensure text file traces are platform-independent.
2024-06-08 01:20:46 +00:00
Leonardo de Moura
fd4281a636 fix: misleading type at Option.forM (#4403)
The type uses `PUnit`, but the `pure ()` in the body was forcing the
implicit universe level at `PUnit` to be `1`.

We should probably elaborate `def`s like we elaborate theorems when the
resulting type is provided. This kind of mistake is hard to spot.
2024-06-07 23:33:15 +00:00
Markus Himmel
2d05ff8a48 perf: linearity in HashMap.(insert|erase) (#4372)
The speedcenter doesn't seem to care much, but in [my
benchmark](2e04b4f844/Hashmap/Benchmark/InsertReplace.lean)
for replace-heavy workloads, the fixed code is about 40% faster.
2024-06-07 22:41:39 +00:00
Leonardo de Moura
b02c1c56ab fix: improve split discriminant generalization strategy (#4401)
This commit also
- improves `split` error messages.
- adds `trace.split.failure` option.
- uses new convention for trace messages.

closes #4390
2024-06-07 21:35:09 +00:00
Kim Morrison
73348fb083 chore: make Array.reverse_data proof more robust (#4399)
This proof was breaking during a refactor, so making it more robust
first.
2024-06-07 19:17:03 +00:00
Henrik Böving
18264ae62e feat: getBitVecValue? understands BitVec.ofNatLt (#4391) 2024-06-07 17:43:08 +00:00
Sebastian Ullrich
7b72458392 chore: build Lake again 2024-06-07 13:59:22 +02:00
Sebastian Ullrich
bfcaaa3d9d chore: update stage0 2024-06-07 13:59:22 +02:00
Sebastian Ullrich
0768b508e6 chore: temporarily avoid building Lake 2024-06-07 13:59:22 +02:00
Sebastian Ullrich
d644b377bb chore: update stage0 2024-06-07 13:59:22 +02:00
Sebastian Ullrich
d85d3d5f3a fix: accidental ownership with specialization 2024-06-07 13:59:22 +02:00
Kim Morrison
745d77b068 chore: upstream @[simp] attribute (#4389)
Very minor, but progress towards deleting a downstream file.
2024-06-07 03:32:18 +00:00
Kyle Miller
63739a42f3 chore: clear releases_drafts for start of 4.10.0 (#4377) 2024-06-06 23:45:54 +00:00
Mac Malone
a99007ac75 perf: remove @[inline] from NameMap.find? (#4382)
This `@[inline]` causes Lean to respecialize `RBMap.find?` to `NameMap`
at each call site of `NameMap.find?`, creating lots of unnecessary
duplicate IR.
2024-06-06 22:53:14 +00:00
Henrik Böving
b9bfd30514 chore: remove partial TODO (#4380) 2024-06-06 18:04:55 +00:00
Leonardo de Moura
0a0f1d7cc7 fix: variable must execute pending tactics and elaboration problems (#4370)
closes #2226
closes #3214
2024-06-06 13:06:18 +00:00
Kim Morrison
ba97928fbf chore: begin development cycle for v4.10.0 (#4374) 2024-06-06 12:06:13 +00:00
Kim Morrison
287d46e1f6 chore: update stage0 2024-06-06 06:20:50 +01:00
Leonardo de Moura
0d30517dca feat: make <num>#<term> bitvector literal notation global
chore: `toFin_ofNat`
2024-06-06 06:20:50 +01:00
Leonardo de Moura
faea7f98c1 chore: missing registerTraceClass (#4369)
closes #3373
2024-06-06 00:53:16 +00:00
Leonardo de Moura
ff0d338dd2 feat: improve error messages for numerals (#4368)
closes #4365
2024-06-06 00:28:42 +00:00
Kim Morrison
56adfb856d chore: upstream basic String lemmas (#4354) 2024-06-05 21:28:43 +00:00
Mac Malone
9c079a42e1 chore: lake: add build log file path to warning (#4356)
Adds the path to build log to the warning for a missing/invalid build
log to help with debugging.
2024-06-05 15:18:08 +00:00
Sebastian Ullrich
9d47377bda feat: incrementality for careful command macros such as set_option in theorem, theorem foo.bar, lemma (#4364)
See Note [Incremental Macros] for the caveat on correct `withRef` use
2024-06-05 14:10:38 +00:00
Joachim Breitner
e33c32fb00 feat: ppOrigin to use MessageData.ofConst (#4362)
so that the pretty-printed origin is clickable, and avoid the
unnecessary `@`.

Particularly nice is this fix:
```diff
 /--
-info: [Meta.Tactic.simp.discharge] @bar discharge 
+info: [Meta.Tactic.simp.discharge] bar discharge 
       autoParam T _auto✝
-  [Meta.Tactic.simp.rewrite] { }:1000, T ==> True
-[Meta.Tactic.simp.rewrite] @bar:1000, U ==> True
+  [Meta.Tactic.simp.rewrite] T.mk:1000, T ==> True
+[Meta.Tactic.simp.rewrite] bar:1000, U ==> True
 -/
```
2024-06-05 11:00:34 +00:00
Joachim Breitner
42f12967a6 chore: CI: pr-release: install elan (#4361)
PR #4333 added a call to `lake`, but that needs elan installed
2024-06-05 08:20:57 +00:00
Joachim Breitner
5cd9f805b7 fix: without recover bad simp arg should fail (#4359)
this is an amendment to #4177, after @kmill pointed out an issue:

Users might expect that within a tactic combinator like `first`, `simp
[h]` fails if `h` does not exist. Therefore the behavior introduced in
PR #4177, which is really most useful in mormal interactive use of
`skip`, is restricted to when `recover := true`.
2024-06-05 08:05:38 +00:00
Joachim Breitner
f0a11b8864 fix: FunInd: support structural recursion on reflexive types (#4327)
types like
```
inductive Many (α : Type u) where
  | none : Many α
  | more : α → (Unit → Many α) → Many α
```
have a `.brecOn` only supports motives producing `Type u`, but not `Sort
u`, but our induction principles produce `Prop`. So the previous
implementation of functional induction would fail for functions that
structurally recurse over such types.

We recognize this case now and, rather hazardously, replace `.brecOn`
with `.binductionOn` (and thus `.below ` with `.ibelow` and `PProd` with
`And`). This assumes that these definitions are highly analogous.

This also improves the error message when realizing a reserved name
fails with an exception, by prepending
```
Failed to realize constant {id}:
```
to the error message.

Fixes #4320
2024-06-05 07:54:48 +00:00
Joachim Breitner
5a25612434 fix: GuessLex: delaborate unused parameters as _ (#4329)
fixes #4230
2024-06-05 07:54:29 +00:00
Kim Morrison
37d60fd2ec chore: use match_expr in omega (#4358) 2024-06-05 06:53:45 +00:00
Siddharth
fbb3055f82 feat: getLsb_signExtend (#4187)
The key idea is to notice that `signExtend` behavior is controlled by
the `msb`. When `msb = false`, `sext` behaves the same as `trunc`. When
`msb = true`, `sext` behaves like `trunc` but adds high 1-bits. This is
expressed using the negate-truncate-negate pattern. Lemma statements
below:

```lean
theorem signExtend_eq_neg_truncate_neg_of_msb_false {x : BitVec w} {v : Nat} (hmsb : x.msb = false) :
    (x.signExtend v) = x.truncate v := by
 
theorem signExtend_eq_neg_truncate_neg_of_msb_true {x : BitVec w} {v : Nat} (hmsb : x.msb = true) :
    (x.signExtend v) = ~~~((~~~x).truncate v) := by
```

These give the final theorem statement:


```lean
theorem getLsb_signExtend {x  : BitVec w} {v i : Nat} :
    (x.signExtend v).getLsb i = (decide (i < v) && if i < w then x.getLsb i else x.msb) := by
```

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Kim Morrison <scott@tqft.net>
2024-06-05 05:17:29 +00:00
Austin Letson
644c1d4e36 doc: add docstrings and examples for String functions (#4332)
Add docstrings, usage examples, and doctests for `String.get'`,
`String.next'`, `String.posOf`, `String.revPosOf`.
2024-06-05 05:16:56 +00:00
Leonardo de Moura
46db59d1d9 fix: split (for if-expressions) should work on non-propositional goals (#4349)
Remark: when splitting an `if-then-else` term, the subgoals now have
tags `isTrue` and `isFalse` instead of `inl` and `inr`.
closes #4313

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-06-05 04:43:46 +00:00
Leonardo de Moura
c53a350a9e chore: apply naming convention to IsLawfulSingleton (#4350)
closes #4324
2024-06-05 04:33:20 +00:00
Kim Morrison
8f507b1008 chore: simplify lean4checker step in release checklist (#4355) 2024-06-05 04:14:36 +00:00
Mac Malone
28b8778218 perf: lake: fix LogIO inling/lifting (#4351)
The current manner of lifting `LogIO` into `CliM` produces excessive
specializations (due to a nested inlined `forM`). There was also a bug
where `IO` was lifted into `CliM` via `LogIO` rather than directly
through `MainM`.
2024-06-05 01:59:21 +00:00
Leonardo de Moura
982c338b45 fix: missing dsimp simplification when applying auto-congr theorems (#4352)
closes #4339
2024-06-05 01:01:33 +00:00
Mac Malone
ce67d6ef9e fix: lake: track trace of cached build logs (#4343)
Stores the dependency trace for a build in the cached build log and then
verifies that it matches the trace of the current build before replaying
the log. Includes test.

Closes #4303.
2024-06-05 00:35:09 +00:00
Kim Morrison
1d6fe34b29 chore: upstream Char lemmas from Mathlib (#4348)
The main purpose here is to add `Char.ofUInt8`, so I can delete the
semantically suspect `UInt8.toLower` etc in Mathlib.
2024-06-04 23:45:26 +00:00
Leonardo de Moura
5924c5aea9 fix: simp must not use the forward version of an user-specified backward theorem (#4345)
closes #4290
2024-06-04 22:49:31 +00:00
Mac Malone
612bdee68c test: lake: more robust tests/serve (#4346)
In Lake's `tests/serve`, save server log to a file and give it a timeout
(one smaller than CMake's).
2024-06-04 22:38:20 +00:00
Leonardo de Moura
28cf1cf5cf fix: mutual inductives with instance parameters (#4342)
closes #4310
2024-06-04 17:35:41 +00:00
Leonardo de Moura
2ae762eb75 fix: panic when applying @[simp] to malformed theorem syntax (#4341)
closes #4309
2024-06-04 16:52:26 +00:00
Sebastian Ullrich
8437d1f660 fix: incorrect info tree reuse (#4340)
The `save` happened in a slightly different context from the restore,
which a refinement of the `saveOrRestoreFull` signature now makes
impossible.

Fixes #4328
2024-06-04 09:28:40 +00:00
Sebastian Ullrich
d45952e386 feat: incremental have (#4308)
Implemented as a macro special case, with some implementation caveats
2024-06-04 09:12:27 +00:00
Siddharth
9d46961236 chore: deprecate shiftLeft_shiftLeft, shiftRight_shiftRight (#4321)
As discussed previously
(https://github.com/leanprover/lean4/pull/4179#discussion_r1615183093),
we deprecate the two functions in favour of `shift{Left, Right}_add`.
2024-06-04 01:57:51 +00:00
Kyle Miller
e47d84e37a doc: improve docstrings for repeat* tactics (#4338) 2024-06-04 01:47:40 +00:00
Kim Morrison
05ea3ac19f chore: update batteries in manifest when creating lean-pr-testing-NNNN at Mathlib (#4333) 2024-06-04 01:45:37 +00:00
Kyle Miller
a54fa7cae6 fix: partial calc tactic would fail due to mdata or uninstantiated mvars (#4335)
Reported by Heather Macbeth.

Closes #4334

---------

Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com>
2024-06-04 01:23:20 +00:00
Joachim Breitner
f65e3ae985 feat: simp to still work even if one simp arg does not work (#4177)
this fixes a usability paper cut that just annoyed me. When editing a
larger simp proof, I usually want to see the goal state after the simp,
and this is what I see while the `simp` command is complete. But then,
when I start typing, and necessarily type incomplete lemma names, that
error makes `simp` do nothing again and I see the original goal state.
In fact, if a prefix of the simp theorem name I am typing is a valid
identifier, it jumps even more around.

With this PR, using `logException`, I still get the red squiggly lines
for the unknown identifer, but `simp` just ignores that argument and
still shows me the final goal. Much nicer.

I also demoted the message for `[-foo]` when `foo` isn’t `simp` to a
warning and gave it the correct `ref`.

See it in action here: (in the middle, when you suddenly see the
terminal,
I am switching lean versions.)


https://github.com/leanprover/lean4/assets/148037/8cb3c563-1354-4c2d-bcee-26dfa1005ae0
2024-06-03 14:21:31 +00:00
Siddharth
81f5b07215 feat: getLsb_sshiftRight (#4179)
In the course of the development, I grabbed facts about right shifting
over integers [from
`mathlib4`](https://github.com/leanprover-community/mathlib4/blob/master/Mathlib/Data/Int/Bitwise.lean).

The core proof strategy is to perform a case analysis of the msb:
- If `msb = false`, then `sshiftRight = ushiftRight`.
- If `msb = true`. then `x >>>s i = ~~~(~~~(x >>>u i))`. The double
negation introduces the high `1` bits that one expects of the arithmetic
shift.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-06-01 16:43:11 +00:00
Siddharth
9a597aeb2e feat: getLsb_{rotateLeft, rotateRight} (#4257)
These will be used by LeanSAT for bitblasting rotations by constant
distances.

We first reduce the case when the rotation amount is larger than the
width to the case where the rotation amount is less than the width
(`x.rotateLeft/Right r = x.rotateLeft/Right (r%w)`).

Then, we case analyze on the low bits versus the high bits of the
rotation, where we prove equality by extensionality.

---------

Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Tobias Grosser <github@grosser.es>
2024-06-01 16:42:10 +00:00
Tobias Grosser
ff116dae5f feat: add BitVec _assoc lemmas (#4299) 2024-06-01 16:24:18 +00:00
John Tristan
0dff5701af doc: updated build instructions for mac os X (#4317)
Edit to the platform specific setup for mac os X. The installation of
llvm does not accept the options --with-clang and --with-asan anymore.
2024-06-01 16:23:17 +00:00
Kim Morrison
299cb9a806 chore: remove @[simp] from bind_eq_some (#4314) 2024-06-01 16:04:02 +00:00
Leonardo de Moura
b53a74d6fd fix: miscompilation in constant folding (#4311)
closes #4306
2024-05-31 04:24:45 +00:00
Lean stage0 autoupdater
007b423006 chore: update stage0 2024-05-30 09:57:02 +00:00
Sebastian Ullrich
6c63c9c716 feat: quotations for parser aliases (#4307)
Another papercut towards incremental `have`
2024-05-30 09:22:22 +00:00
Kim Morrison
8bbb015a97 chore: add namespace in Init/Data/Fin/Fold (#4304) 2024-05-29 16:40:55 +00:00
Alex Keizer
9133470243 feat: upstream BitVec.toFin_ofNat and BitVec.toFin_neg (#4298)
These lemmas are morally equivalent to Mathlib lemmas which are proposed
to be deleted from Mathlib in
[#13286](https://github.com/leanprover-community/mathlib4/pull/13286).

It is only morally equivalent, because the Mathlib lemmas are stated in
terms of Mathlib-defined things: `toFin_natCast` uses a coercion from
`Nat` to `Fin (2^w)` which relies on `NeZero` machinery available only
in Mathlib. Thus, I've rephrased the rhs in terms of the def-eq
`Fin.ofNat'` with an explicit proof that `2^w` is non-zero.

Similarly, the RHS of `toFin_neg` was phrased in terms of negation on
`Fin`s, which is only defined in Mathlib, so I've unfolded the
definition.
2024-05-29 08:25:51 +00:00
Markus Himmel
d07b316804 fix: incorrect docstring for named pattern syntax (#4294)
---
2024-05-29 08:23:15 +00:00
Wojciech Nawrocki
ec59e7a2c0 feat: widget messages (#4254)
Allows embedding user widgets in structured messages. Companion PR is
leanprover/vscode-lean4#449.

Some technical choices:
- The `MessageData.ofWidget` constructor might not be strictly necessary
as we already have `MessageData.ofFormatWithInfos`, and there is
`Info.ofUserWidget`. However, `.ofUserWidget` also requires a `Syntax`
object (as it is normally produced when widgets are saved at a piece of
syntax during elaboration) which we do not have in this case. More
generally, it continues to be a bit cursed that `Elab.Info` nodes are
used both for elaboration and delaboration (pretty-printing), so
entrenching that approach seems wrong. The better approach would be to
have a separate notion of pretty-printer annotation; but such a refactor
would not be clearly beneficial right now.
- To support non-JS-based environments such as
https://github.com/Julian/lean.nvim, `.ofWidget` requires also providing
another message which approximates the widget in a textual form.
However, in practice these environments might still want to support a
few specific user widgets such as "Try this".

---

Closes #2064.
2024-05-29 06:37:42 +00:00
Sebastian Ullrich
cc33c39cb0 chore: bootstrap fixes 2024-05-28 23:04:19 +02:00
Sebastian Ullrich
8c7364ee64 chore: update stage0 2024-05-28 23:04:19 +02:00
Sebastian Ullrich
26b6718422 chore: haveId node kind 2024-05-28 23:04:19 +02:00
Sebastian Ullrich
66777670e8 fix: stray tokens in tactic block should not inhibit incrementality (#4268) 2024-05-27 07:36:13 +00:00
Sebastian Ullrich
f05a82799a chore: CI: restore macOS aarch64 install sufix 2024-05-26 14:29:56 +02:00
Leonardo de Moura
8eee5ff27f fix: do not include internal match equational theorems at simp trace (#4274)
closes #4251
2024-05-25 17:16:19 +00:00
Mac Malone
fe17b82096 refactor: lake: ensure job actions can be lifted to FetchM (#4273)
In `v4.8.0-rc2`, due to additional build refactor changes, `JobM` no
longer cleanly lifts in `FetchM`. Generally, a `JobM` action should not
be run `FetchM` directly but spawned asynchronously as job (e.g., via
`Job.async`). However, there may be some edge cases were this is
necessary and it is a backwards compatibility break, so this change adds
back the lift. This change also includes an `example` definition to
ensure the lift works in order to prevent similar accidental breakages
in the future.

This breakage was first reported by Mario on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/v4.2E8.2E0-rc2.20discussion/near/440407037).
2024-05-25 02:20:04 +00:00
Mac Malone
def00d3920 refactor: lake: manifest semver & code cleanup (#4083)
Switches the manifest format to use `major.minor.patch` semantic
versions. Major version increments indicate breaking changes (e.g., new
required fields and semantic changes to existing fields). Minor version
increments (after `0.x`) indicate backwards-compatible extensions (e.g.,
adding optional fields, removing fields). This change is backwards
compatible. Lake will still successfully read old manifest with numeric
versions. It will treat the numeric version `N` as semantic version
`0.N.0`. Lake will also accept manifest versions with `-` suffixes
(e.g., `x.y.z-foo`) and then ignore the suffix.

This change also includes the general cleanup/refactoring of the
manifest code and data structures that was part of #3174.
2024-05-24 21:32:41 +00:00
Mac Malone
cd16975946 feat: lake pack / lake unpack (#4270)
Adds two new Lake commands, `lake pack` and `lake unpack`, which pack
and unpack, respectively, Lake build artifacts from an archive. If a
path argument is given, creates the archive specified, otherwise uses
the information in a package's `buildArchive` configuration as the
default.

The pack command will be used by Reservoir to prepare crate-style build
archives for packages. In the future, the command will also be
extensible through configuration file hooks.
2024-05-24 21:32:07 +00:00
Mac Malone
0448e3f4ea feat: lake test improvements & lake lint (#4261)
Extends the functionality of `lake test` and adds a parallel command in
`lake lint`.

* Rename `@[test_runner]` / `testRunner` to `@[test_driver]` /
`testDriver`. The old names are kept as deprecated aliases.
* Extend help page for `lake test` and adds one for `lake check-test`. 
* Add `lake lint` and its parallel tag `@[lint_driver]` , setting
`lintDriver`, and checker `lake check-lint`.
* Add support for specifying test / lint drivers from dependencies. 
* Add `testDriverArgs` / `lintDriverArgs` for fixing additional
arguments to the invocation of a driver script or executable.
* Add support for library test drivers (but not library lint drivers). 
* `lake check-test` / `lake check-lint` only load the package (without
dependencies), not the whole workspace.

Closes #4116. Closes #4121. Closes #4142.
2024-05-24 21:31:41 +00:00
Sebastian Ullrich
d3ee0be908 feat: show signature elaboration errors on body parse error (#4267)
Fixes #3556

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-05-24 10:07:07 +00:00
Sebastian Ullrich
d1a96f6d8f chore: CI: native-compile aarch64 macOS (#4265) 2024-05-24 08:18:49 +00:00
Kim Morrison
b0c1112471 chore: better omega error message if no facts found (#4264) 2024-05-24 05:15:15 +00:00
JovanGerb
e5e5a4d2e0 chore: fix the MonadStore type classes, with semiOutParam (#4205)
The type class `MonadStore1` and friends have an outParam, which should
not be an outParam, because there are multiple possible values for this
parameter. At this function
[fetchOrCreate](1382e9fbc4/src/lake/Lake/Load/Main.lean (L196C49-L196C63)),
there are multiple stacked `StateT` monad transformers that each give a
different instance to `MonadStore1`. It is an implementation detail of
type class synthesis which instance is found. This particular type class
synthesis fails when the unused instance
`Lake.instMonadStore1OfMonadDStoreOfFamilyOut` is set to a lower
priority, because then the synthesis order happens to go differently, so
the wrong instance is found.

Replacing the outParam with a semiOutParam solves this issue. Thus, we
make a new type class `MonadStore1Of`, which is the same, but with a
semiOutParam. This follows the design of `MonadState` and
`MonadStateOf`.

However, then it turns out that the instance cannot anymore be
synthesised.

There are two instances for `MonadStore1`:
```
instance [MonadDStore κ β m] : MonadStore1 k (β k) m
instance [MonadDStore κ β m] [FamilyOut β k α] : MonadStore1 k α m 
```
The first one is problematic during unification, especially when `β`
should be instantiated as a constant function. We make the second one
sufficient by adding an instance for the general type family:
```
/-- The general type family -/
instance (priority := low) : FamilyDef Fam a (Fam a) where
  family_key_eq_type := rfl
```
So then we can get rid of the first instance.
2024-05-24 02:09:07 +00:00
Sebastian Ullrich
e020f3d159 chore: CI: move some expensive checks from merge queue to releases (#4255) 2024-05-23 20:45:44 +00:00
Sebastian Ullrich
811bad16e1 fix: ensure incremental commands and tactics are reached only on supported paths (#4259)
Without this, it would not easy but perhaps be feasible to break
incrementality when editing command prefixes such as `set_option ... in
theorem` or also `theorem namesp.name ...` (which is a macro),
especially if at some later point we support incrementality in input
shifted by an edit. Explicit, sound support for these common cases will
be brought back soon.
2024-05-23 17:57:42 +00:00
Sebastian Ullrich
67338bac23 chore: replace registerBuiltinIncrementalTactic with @[builtin_incremental] 2024-05-23 17:53:58 +02:00
Sebastian Ullrich
ba629545cc chore: update stage0 2024-05-23 17:26:21 +02:00
Sebastian Ullrich
dfb496a271 fix: allow multiple declareBuiltin per declaration 2024-05-23 17:23:39 +02:00
Sebastian Ullrich
250994166c feat: [(builtin_)incremental] elab attribute 2024-05-23 17:23:39 +02:00
Sebastian Ullrich
73a0c73c7c chore: modernize build instructions (#4032)
Use `cmake --preset`, adjust and document parallelism settings
2024-05-23 10:55:07 +00:00
meow-sister
258cc28dfc fix: docstring in Attributes.lean (#4238)
Changing document string in `Attributes.lean`, in order to consistent
with code in `Lean.Parser.Attr`.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-05-23 10:13:43 +00:00
Sebastian Ullrich
f61a64d2ff chore: reset LEAN_VERSION_IS_RELEASE 2024-05-23 12:28:24 +02:00
Kyle Miller
d984030c6a chore: set up procedure for preparing release notes (#4247)
We are switching to a new system for preparing release notes.
* Release notes will be compiled when creating a release candidate from
all the commits that are part of that release.
* PRs can include suggestions for release notes in PR messages. Please
use language such as "release notes" and "breaking changes" to call
attention to the suggestions. Release notes are user-centric rather than
developer-centric.
* For more complicated release notes, these can be put into the
`releases_drafts` folder.

This solves an issue where PRs that include release notes can, when
merged, have those notes appear under the wrong Lean version, since they
might have been created before a release but not merged until after. It
also solves merge conflicts due to multiple PRs updating the release
notes.
2024-05-23 02:46:11 +00:00
FR
93758cc222 perf: faster Nat.testBit (#4188)
`1 &&& n` is faster than `n &&& 1` for big `n`.

---
2024-05-23 01:34:40 +00:00
Alex Keizer
4fa3b3c4a0 feat: bitblasting theorems for signed comparisons (#4201)
Prove theorems that relate `BitVec.slt` and `sle` to `carry`, so that
these signed comparisons may be bitblasted in LeanSAT.

This PR is stacked on top of #4200. For the diff without changes from
that PR, see:
https://github.com/opencompl/lean4/compare/opencompl:lean4:bitvec-toInt-iff-msb...bitvec-slt-blast

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-05-23 01:24:04 +00:00
Leonardo de Moura
2bc41d8f3a fix: case tactic in macros (#4252)
We must erase macro scopes for tags in `case` as we do in `cases .. with
..` and `induction .. with ..`.
2024-05-23 00:01:24 +00:00
Sebastian Ullrich
f97a7d4234 feat: incremental elaboration of definition headers, bodies, and tactics (#3940)
Extends Lean's incremental reporting and reuse between commands into
various steps inside declarations:
* headers and bodies of each (mutual) definition/theorem
* `theorem ... := by` for each contained tactic step, including
recursively inside supported combinators currently consisting of
  * `·` (cdot), `case`, `next`
  * `induction`, `cases`
  * macros such as `next` unfolding to the above

![Recording 2024-05-10 at 11 07
32](https://github.com/leanprover/lean4/assets/109126/c9d67b6f-c131-4bc3-a0de-7d63eaf1bfc9)

*Incremental reuse* means not recomputing any such steps if they are not
affected by a document change. *Incremental reporting* includes the
parts seen in the recording above: the progress bar and messages. Other
language server features such as hover etc. are *not yet* supported
incrementally, i.e. they are shown only when the declaration has been
fully processed as before.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-05-22 13:23:30 +00:00
Alex Keizer
23a202b6be feat: characterize BitVec.toInt in terms of BitVec.msb (#4200)
This PR extracts `msb_eq_false_iff_two_mul_lt` and
`msb_eq_true_iff_two_mul_ge` from #4179, and uses them to prove a
theorem that characterizes `BitVec.toInt` in terms of `BitVec.msb`. This
lemma will be useful to prove a bit-blasting theorem for `BitVec.slt`
and `BitVec.sle`.

Also cleans up an existing proof (`toInt_eq_toNat_cond `), which turns
out to be provable by `rfl`.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-05-22 11:14:37 +00:00
Leonardo de Moura
ff37e5d512 feat: add grind core module (#4249) 2024-05-22 03:50:36 +00:00
Kim Morrison
c2b8a1e618 chore: fix implicitness in HashMap.ofList (#4248)
Reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Typeclass.20Inference.20Failure.20on.20HashMap/near/439842209
2024-05-22 03:04:37 +00:00
Mac Malone
8ca00918fb chore: lake: fix noRelease test when lean repo is tagged (#4244)
Fixes a bug with the Lake `noRelease` test where the test would fail if
the current revision of the Lean repository itself had a tag.
2024-05-21 22:51:33 +00:00
Leonardo de Moura
6155513c60 chore: update stage0
Motivation: `[grind_cases]` at `Init`
2024-05-21 21:46:23 +02:00
Leonardo de Moura
d6709eb157 feat: add [grind_cases] attribute 2024-05-21 21:46:23 +02:00
Leonardo de Moura
e6be8b90f5 feat: add grind.injection (#4243) 2024-05-21 17:57:02 +00:00
Joachim Breitner
82401938cf fix: hovers on binders with metavariables (#4192)
this fixes #4078. It is an alternative fix to the one in #4137,
suggested
by @kmill.

Incidentially, it makes the unused variable linter better. My theory is
that
if we don’t reset the info when backtracking, the binder shows up more
than
once in the info tree, and then it is considered “used”, although there
are
just multiple binders.
2024-05-21 10:34:58 +00:00
Kim Morrison
3de60bb1f6 chore: Lake details & improve formatting in changelog (#4239)
This is #4207, but targeting `master`.

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-05-21 06:11:32 +00:00
Leonardo de Moura
8c03650359 feat: some Char, UInt, and Fin theorems (#4231)
for SSFT24 summer school: https://github.com/david-christiansen/ssft24

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
Co-authored-by: Kim Morrison <scott.morrison@gmail.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-05-21 06:11:23 +00:00
Austin Letson
2faa81d41f doc: add docstrings and examples for String functions (#4166)
Add docstrings, usage examples, and doc tests for `String.prev`,
`.front`, `.back`, `.atEnd`.

Improve docstring examples for `String.next` based on discussion
examples for `String.prev`.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-05-21 04:27:40 +00:00
Siddharth
097a4d5b6b feat: define rotateLeft/Right with modulo (#4229)
This ensures that rotateLeft/Right behave correctly even when the
rotation amount is larger than the bitwidth.

This shall be followed up with `getLsb` theorems for rotations for
LeanSAT.

We choose to write `aux` definitions since it is cleaner to reason about
the `aux` theorems with the assumption that `rotation-amount <
bit-width`, followed by auxiliary lemmas that link the behavior of
rotation to the canonical case when `rotation-amount < bit-width`.

Proof strategy we will execute based on these definitions: [Link to
proof of
`getLsb_rotateLeft`](a0b18ec0f4/src/Init/Data/BitVec/Lemmas.lean (L1129-L1204))

---------

Co-authored-by: Tobias Grosser <github@grosser.es>
2024-05-21 03:49:09 +00:00
Mac Malone
f512826b9a chore: lake: spinner icon for computing step (#4236) 2024-05-21 03:48:39 +00:00
Leonardo de Moura
7c053259d3 feat: add grind.cases tactic (#4235) 2024-05-21 02:03:33 +00:00
Leonardo de Moura
f3ccd6b023 feat: some string simprocs (#4233)
For the SSFT24 summer school.
2024-05-20 22:53:10 +00:00
Mac Malone
7ece5d56e3 feat: lake: ANSI monitor: only display progress + running job info (#4232)
The ANSI mode build monitor now now longer displays built jobs (instead
only those that print info or failed). Also upgrades the progress ticker
with a spinner icon and information on the number of running jobs.
2024-05-20 20:29:21 +00:00
Kyle Miller
a7338c5ad8 feat: make frontend normalize line endings to LF (#3903)
To eliminate parsing differences between Windows and other platforms,
the frontend now normalizes all CRLF line endings to LF, like [in
Rust](https://github.com/rust-lang/rust/issues/62865).

Effects:
- This makes Lake hashes be faithful to what Lean sees (Lake already
normalizes line endings before computing hashes).
- Docstrings now have normalized line endings. In particular, this fixes
`#guard_msgs` failing multiline tests for Windows users using CRLF.
- Now strings don't have different lengths depending on the platform.
Before this PR, the following theorem is true for LF and false for CRLF
files.
```lean
example : "
".length = 1 := rfl
```

Note: the normalization will take `\r\r\n` and turn it into `\r\n`. In
the elaborator, we reject loose `\r`'s that appear in whitespace. Rust
instead takes the approach of making the normalization routine fail.
They do this so that there's no downstream confusion about any `\r\n`
that appears.

Implementation note: the LSP maintains its own copy of a source file
that it updates when edit operations are applied. We are assuming that
edit operations never split or join CRLFs. If this assumption is not
correct, then the LSP copy of a source file can become slightly out of
sync. If this is an issue, there is some discussion
[here](https://github.com/leanprover/lean4/pull/3903#discussion_r1592930085).
2024-05-20 17:13:08 +00:00
Leonardo de Moura
b278f9dd30 fix: missing withIncRecDepth and unifyEqs? and add support for offsets at unifyEq? (#4224)
Given `h` with type `x + k = y + k'` (or `h : k = k')`, `cases h`
produced a proof of size linear in `min k k'`. `isDefEq` has support for
offset, but `unifyEq?` did not have it, and a stack overflow occurred
while processing the resulting proof. This PR fixes this issue.

closes #4219
2024-05-20 13:42:36 +00:00
Eric Wieser
f0471a519b doc: upstream the Lean4 pygments lexer (#3125)
An improved `lean4` lexer is now part of pygments.

This depends on https://github.com/pygments/pygments/pull/2618 (now
merged), and [a subsequent
release](https://github.com/pygments/pygments/milestone/23)
2024-05-20 11:40:24 +00:00
Alex Keizer
42215cc072 feat: Nat.shiftLeft_shiftRight (#4199)
Show that shifting a natural number left and then shifting right by the
same amount is a no-op.

I originally proved this in a different PR, ended up not needing the
fact after all, but it still seemed like a generally useful simp lemma
to have.
2024-05-20 06:50:28 +00:00
Leonardo de Moura
f53b778c0d feat: improve grind preprocessor (#4221) 2024-05-20 04:29:49 +00:00
Leonardo de Moura
72b345c621 chore: remove #guard_msgs from tests that rely on pointer equality 2024-05-20 06:12:43 +02:00
Mac Malone
6171070deb chore: lake: cloud release build output fixes & related touchups (#4220)
Fixes two output bugs with cloud releases: (1) the fetch as part of an
`extraDep` was not properly isolated in a job, and (2) the release job
would be shown even if the release had already been successfully
fetched.

Also includes some related touchups, including the addition of show all
jobs on `-v` which helps with debugging job counts.
2024-05-20 03:28:50 +00:00
Kim Morrison
7c5249278e chore: move release notes about MessageData to v4.9.0 (#4222) 2024-05-20 01:42:30 +00:00
Leonardo de Moura
239ade80dc chore: update stage0 2024-05-19 07:20:10 +02:00
Leonardo de Moura
47c8e340d6 fix: move cdot and calc parsers to Lean namespace
closes #3168
2024-05-19 07:20:10 +02:00
Leonardo de Moura
c8b72beb4d chore: update stage0 2024-05-19 07:20:10 +02:00
Leonardo de Moura
9803c5dd63 chore: prepare to move cdot and calc parsers to Lean namespace
see issue #3618
2024-05-19 07:20:10 +02:00
Leonardo de Moura
d66d00dece fix: missing occurs-check at delayed assignment (#4217)
closes #4144
2024-05-19 02:53:00 +00:00
JovanGerb
9fde33a09f fix: oversight in isReadOnlyOrSyntheticOpaque (#4206)
### Explanation
In the case that `assignSyntheticOpaque := true` and the given
metavariable is `syntheticOpaque` and the depth of the metavariable is
not the current depth, `isReadOnlyOrSyntheticOpaque` returns false, even
though the metavariable is read-only because of being declared at a
smaller depth. This causes the metavariable to (wrongly) be able to be
instantiated by `isDefEq`.

This bug was found at the proof of
[RingHom.PropertyIsLocal.sourceAffineLocally_of_source_openCover](https://leanprover-community.github.io/mathlib4_docs/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.html#RingHom.PropertyIsLocal.sourceAffineLocally_of_source_openCover),
which involves a type class synthesis for `CommRing ?m.2404`, and the
synthesis manages to instantiate this metavariable into different
values, even though `synthInstance?` increases the metavariable depth.
This synthesis fails after 1 second.

I found the bug while modifying the instance synthesis code: the
modified code spent several minutes on this failed synthesis.

### Test
The problem can be verified with the test:
```
run_meta do
  let m ← mkFreshExprMVar (Expr.sort levelOne) MetavarKind.syntheticOpaque
  withAssignableSyntheticOpaque do
  withNewMCtxDepth do
  let eq ← isDefEq m (.const ``Nat [])
  Lean.logInfo m! "{eq}"
```
this unification used to succeed, giving `true`, and this fix makes it
return `false`.

### Impact on Mathlib

This fix causes a change in the behaviour of `congr`, `convert` and
friends, which breaks a couple of proofs in mathlib. Most of these are
fixed by supplying more arguments.

I fixed these proofs, and
[benched](http://speed.lean-fro.org/mathlib4/compare/b821bfd9-3769-4930-b77f-0adc6f9d218f/to/e7b27246-a3e6-496a-b552-ff4b45c7236e?hash2=4f3c460cc1668820c9af8418a87a23db44c7acab)
mathlib. The result is that most files are unaffected, but some files
are significantly improved. This is most prominent in
Mathlib.RingTheory.Jacobson, where the number of instructions has
decreased by 28%. The overall improvement is a 0.3% reduction in
instructions.

[Zulip
message](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Ways.20to.20speed.20up.20Mathlib/near/439218960)
2024-05-18 21:01:31 +00:00
Kyle Miller
b639d102d1 fix: use maxType when building expression in expression tree elaborator (#4215)
The expression tree elaborator computes a "maxType" that every leaf term
can be coerced to, but the elaborator was not ensuring that the entire
expression tree would have maxType as its type. This led to unexpected
errors in examples such as
```lean
example (a : Nat) (b : Int) :
  a = id (a * b^2) := sorry
```
where it would say it could not synthesize an `HMul Int Int Nat`
instance (the `Nat` would propagate from the `a` on the LHS of the
equality). The issue in this case is that `HPow` uses default instances,
so while the expression tree elaborator decides that `a * b^2` should be
referring to an `Int`, the actual elaborated type is temporarily a
metavariable. Then, when the binrel elaborator is looking at both sides
of the equality, it decides that `Nat` will work and coercions don't
need to be inserted.

The fix is to unify the type of the resulting elaborated expression with
the computed maxType. One wrinkle is that `hasUncomparable` being false
is a valid test only if there are no leaf terms with unknown types (if
they become known, it could change `hasUncomparable` to true), so this
unification is only performed if the leaf terms all have known types.

Fixes issue described by Floris van Doorn on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/elaboration.20issue.20involving.20powers.20and.20sums/near/439243587).
2024-05-18 20:59:54 +00:00
Leonardo de Moura
02b6fb3f41 fix: canonInstances := true issue (#4216)
closes #4213
2024-05-18 18:13:41 +00:00
Joachim Breitner
9f6bbfa106 feat: apply’s error message should show implicit arguments as needed (#3929)
luckily the necessary functionality already exists in the form of
`addPPExplicitToExposeDiff`. But it is not cheap, and we should not run
this code
when the error message isn’t shown, so we should do this lazily.

We already had `MessageData.ofPPFormat` to assemble the error message
lazily, but it
was restricted to returning `FormatWithInfo`, a data type that doesn’t
admit a nice
API to compose more complex messages (like `Format` or `MessageData`
has; an attempt to
fix that is in #3926).

Therefore we split the functionality of `.ofPPFormat` into
`.ofFormatWithInfo` and `.ofLazy`,
and use `.ofLazy` to compute the more complex error message of `apply`.

Fixes #3232.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Wojciech Nawrocki <wjnawrocki@protonmail.com>
2024-05-18 06:25:43 +00:00
Leonardo de Moura
1ff0e7a2f2 fix: split at h when h has forward dependencies (#4211)
We use an approach similar to the one used in `simp`. 

closes #3731
2024-05-18 02:48:15 +00:00
Leonardo de Moura
3cb6eb0ae6 fix: ensure a local instance is not registered multiple times (#4210)
closes #4203
2024-05-18 02:30:12 +00:00
Alok Singh
489d2d11ec feat: lake: add readme to package templates (#4147)
Messaged @tydeu about adding a README.md to new lake projects. I decided
to add it with the help of GPT.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-05-18 02:02:36 +00:00
Mac Malone
7648bf255c feat: lake: build monitor improvements (#4127)
The new Lake build monitor is now more selective, accurate, and prettier
in what it prints.

**Key Changes:**
 
* Poll jobs at a fixed frequency (100ms), updating the caption and
finished job count.
* Add `action` field to jobs to record information about what jobs do.
It enables distinguishing between jobs which build something, fetch from
a store, or reload logs from the cache.
* At standard verbosity, print build captions only when a job is know to
build or fetch something (i.e., `action >= .fetch`).
* Add an icon and color to job captions based on their log-level / build
status. Also add color to levels in logs.
* Add `--ansi`/`--no-ansi` to toggle Lake's use of ANSI escape codes.
* Fix some `v4.8.0-rc1` bugs and `--old`.

Closes #2822.
2024-05-17 23:20:45 +00:00
Leonardo de Moura
4d2ff6fb04 feat: pretty print Array DiscrTree.Key (#4208) 2024-05-17 22:35:24 +00:00
Leonardo de Moura
ee0bcc8321 feat: add Simp.Config.index (#4202)
The `simp` tactic uses a discrimination tree to select candidate
theorems that will be used to rewrite an expression. This indexing data
structure minimizes the number of theorems that need to be tried and
improves performance. However, indexing modulo reducibility is
challenging, and a theorem that could be applied, when taking reduction
into account, may be missed. For example, suppose we have a `simp`
theorem `foo : forall x y, f x (x, y).2 = y`, and we are trying to
simplify the expression `f a b <= b`. `foo` will not be tried by `simp`
because the second argument of `f a b` is not a projection of a pair.
However, `f a b` is definitionally equal to `f a (a, b).2` since we can
reduce `(a, b).2`.

In Lean 3, we had a much simpler indexing data structure where only the
head symbol was taken into account. For the theorem `foo`, the head
symbol is `f`. Thus, the theorem would be considered by `simp`.

This commit adds the option `Simp.Config.index`. When `simp (config := {
index := false })`, only the head symbol is considered when retrieving
theorems, as in Lean 3. Moreover, if `set_option diagnostics true`,
`simp` will check whether every applied theorem would also have been
applied if `index := true`, and report them. This feature can help users
diagnose tricky issues in code that has been ported from libraries
developed using Lean 3 and then ported to Lean 4. In the following
example, it will report that `foo` is a problematic theorem.

```lean
opaque f : Nat → Nat → Nat

@[simp] theorem foo : f x (x, y).2 = y := by sorry

example : f a b ≤ b := by
  set_option diagnostics true in
  simp (config := { index := false })
```

In the example above, the following diagnostic message is produced.
```lean
[simp] theorems with bad keys
    foo, key: [f, *, Prod.1, Prod.mk, Nat, Nat, *, *]
```

With the information above, users can annotate theorems such as `foo`
using `no_index` for problematic subterms.
Example:
```lean
opaque f : Nat → Nat → Nat

@[simp] theorem foo : f x (no_index (x, y).2) = y := by sorry

example : f a b ≤ b := by
  simp -- `foo` is still applied
```

cc @semorrison 
cc @PatrickMassot
2024-05-17 21:14:58 +00:00
Leonardo de Moura
1382e9fbc4 feat: simprocs for applying shiftLeft_shiftLeft and shiftRight_shiftRight (#4194) 2024-05-16 19:34:46 +00:00
Leonardo de Moura
e8c4540f87 feat: simprocs for reducing x >>> i and x <<< i where i is a bittvector literal (#4193) 2024-05-16 18:16:52 +00:00
FR
f2a304e555 style: fix whitespace and remove duplicate docstring (#4189) 2024-05-16 06:46:39 +00:00
Kim Morrison
3a457e6ad6 chore: use #guard_msgs in run tests (#4175)
Many of our tests in `tests/lean/run/` produce output from `#eval` (or
`#check`) statements, that is then ignored.

This PR tries to capture all the useful output using `#guard_msgs`. I've
only done a cursory check that the output is still sane --- there is a
chance that some "unchecked" tests have already accumulated regressions
and this just cements them!

In the other direction, I did identify two rotten tests:
* a minor one in `setStructInstNotation.lean`, where a comment says `Set
Nat`, but `#check` actually prints `?_`. Weird?
* `CompilerProbe.lean` is generating empty output, apparently indicating
that something is broken, but I don't know the signficance of this file.

In any case, I'll ask about these elsewhere.

(This started by noticing that a recent `grind` test file had an
untested `trace_state`, and then got carried away.)
2024-05-16 00:38:31 +00:00
Alex Keizer
2a966b46f2 feat: bitblasting theorems about unsigned bitvector inequalities (#4178)
This PR adds theorems that relate unsigned bitvector comparisons
`BitVec.ult` and `BitVec.ule` to `BitVec.carry`. These lemmas are a
prerequisite to bit-blasting these comparisons in LeanSAT.
2024-05-16 00:01:31 +00:00
Leonardo de Moura
8204b79b3c fix: cleanup type annotations in congruence theorems (#4185) 2024-05-15 23:50:35 +00:00
Kim Morrison
f63616891f chore: fix bug in omega (#4184)
Fixes #4183
2024-05-15 22:21:17 +00:00
Leonardo de Moura
9a8e7a6411 feat: add cleanupAnnotations parameter to forallTelescope methods (#4180) 2024-05-15 22:19:07 +00:00
JovanGerb
c7741607fb fix: add missing registerTraceClass `Meta.synthInstance.instances (#4151)
The trace class Meta.synthInstance.answer isn't registered, so it can't
be used.

I set `inherited := true`, because I think it is a useful trace to have.
In particular it tells you when an instance has been found that has a
too large size. This is very useful information.
2024-05-15 18:59:01 +00:00
Joachim Breitner
82666e5e7c fix: make erased names in simp clickable (#4176)
as usually, just a matter of using the `WithInfo` variant.

Also simplifying the code a bit, it seems we can use
`realizeGlobalConstNoOverloadWithInfo` here.

(It's somehwatdubious API design that of all the functions in
the `{resolve/realise}GlobalConst{NoOverload,}{WithInfo,}` family
the one with the longest name is the one that should be used
unless one has a reason to use another one.)

Fixes: #4174
2024-05-15 14:12:15 +00:00
Joachim Breitner
aeea7fdf5d fix: List.length_pos no @[simp] (#4172)
in #4158 I was experimenting with a change to the simplifier that
affectes the order in which lemmas were tried, and of course it breaks
proofs all over the place whenever we have a non-confluent simp set.

Among the first breakages encountered, a large fraction was due to
`simp` rewriting with `List.length_pos  : 0 < length l ↔ l ≠ []`.

This does not strike me a as a good simp lemma: If `l` is a manifest
constructor, the simplifier will reduce `length` and solve it anyways,
and if it isn't then an inequality usually isn’t very simp friendly. It
is also highly non-confluent with any kind of `length`-lemma we might
have.

This therefore removes it from the standard simp set.
2024-05-15 13:28:54 +00:00
Leonardo de Moura
3035d2f8f6 feat: grind preprocessor skeleton (#4170) 2024-05-15 04:25:22 +00:00
Leonardo de Moura
3493d066e4 feat: add MVarId.ensureNoMVar (#4169) 2024-05-15 00:37:28 +00:00
Leonardo de Moura
d0e34aaed5 feat: add revertAll tactic for grind (#4167) 2024-05-14 23:22:54 +00:00
Siddharth
367b97885a chore: delete double namespace BitVec.BitVec (#4165)
Fixes double namespace introduced in #4148
2024-05-14 19:34:14 +00:00
Leonardo de Moura
f3538dbdfa feat: grind normalization theorems (#4164) 2024-05-14 19:19:38 +00:00
Leonardo de Moura
770235855f chore: update stage0 2024-05-14 19:52:25 +02:00
Leonardo de Moura
0a515e2ec9 feat: add grind_norm simp attribute for grind tactic 2024-05-14 19:52:25 +02:00
Kim Morrison
91244b2dd9 chore: add dates to @[deprecated] attributes (#3967) 2024-05-14 03:24:57 +00:00
Leonardo de Moura
de5e039c83 fix: type class issues with maxSynthPendingDepth := 1 (#4119)
Summary:

- Take `synthPendingDepth` into account when caching TC results
- Add `maxSynthPendingDepth` option with default := 2.
- Add support for tracking `synthPending` failures when using
`set_option diagnostics true`

closes #2522
closes #3313
closes #3927

Identical to #4114  but with `maxSynthPendingDepth := 1`

closes #4114 

cc @semorrison
2024-05-14 03:03:32 +00:00
Mac Malone
61a84c96db refactor: lake: import errors, job captions, log grouping (#4115)
This improves job captions, the grouping of logs underneath them, and
the handling of import errors. It also adds a number of log-related
utilities to help achieve this.

**Key Changes:**

* Job captions for facets now include the name of the object (e.g.,
module, library, facet). A caption has also been added to the top-level
build of imports (e.g., for the server and `lake lean`).
 
* Stray I/O and errors outside the build job in a build function
captioned with `withRegisterJob` (e.g., user-defined targets) will now
be properly grouped under that caption instead of ending up under
"Computing build jobs". Stray I/O will be converted to a single
informational log entry.

* Builds no longer fail immediately on erroneous imports. Lake will now
attempt to recover as best as possible from any import errors.
Information on the import error will appear both in the build of the
erroneous import and in the files which transitive import it. For
example, uf `Lib.B` imports a missing module `Lib.A`, then the build of
`Lib.A` will mention that the file does not exist, and the build of
`Lib.B` will mention the bad import of `Lib.A`.

Closes #3351. Closes #3809.
2024-05-13 22:11:18 +00:00
Leonardo de Moura
98b2681d0e perf: simplify canonicalizer (#4155) 2024-05-13 19:45:20 +00:00
Joachim Breitner
7c4284aa91 refactor: no need for simpMatchWF? (#4153)
Despite what it said in its docstring, `simpMatchWF?` seems to behave
like `simpMatch?`, so let’s just use that.
2024-05-13 19:33:23 +00:00
Joachim Breitner
842280321b refactor: let Nat.mod reduce more (#4145)
this refined upon #4098 and makes `Nat.mod` reduce on even more
literals. The key observation that I missed earlier is that `if m ≤ n`
reduces better than `if n < m`.

Also see discussion at

https://github.com/leanprover-community/mathlib4/pull/12853#discussion_r1597798308
2024-05-13 16:41:09 +00:00
Joachim Breitner
d833f82fe8 chore: rerun CI only when full-ci label is added or removed (#4136)
Previously, the CI would run upon every label addition, including things
like `builds-mathlib`
or `will-merge-soon`, possibly triggering a new PR release, new mathlib
builds etc. Very wasteful!

Unfortunately (but not surprisingly) Github does not offer a nice way of
saying
“this workflow depends on that label, please re-run if changed”. Not
enough
functional programmer or nix enthusiasts there, I guess…

So here is the next iteration trying to work with what we have from
Github:

A new workflow watches for (only) `full-ci` label addition or deletion,
and then re-runs
the CI job for the current PR.

Sounds simple? But remember, this is github!

* `github.event.pull_request.labels.*.name` is *not* updated when a job
is re-run.

(This is actually a reasonable step towards determinism, but doesn't
help us
   constructing this work-around.)
   
   Ok, so let’s use the API to fetch the current state of the label.

* There is no good way to say “find the latest run of workflow `"CI"` on
PR `$n`”.

The best approximation seems to search by branch and triggering event.
This can
probably go wrong if there are multiple PRs from different repos with
the same
head ref name (`patch-1` anyone?). Let’s hope that it doesn’t happen too
often.

* You cannot just rerun a workflow. You can only rerun a finished
workflow. So cancel
  it first. And `sleep` a bit…

So let’s see how well this will work. It’s plausibly an improvement.
2024-05-13 16:40:36 +00:00
Siddharth
a17c3f424c feat: BitVec.shiftLeft_shiftLeft, BitVec.shiftRight_shiftRight (#4148)
Closes two `sorry`s at
https://github.com/leanprover/leansat/pull/64/files.

---------

Co-authored-by: Kim Morrison <scott@tqft.net>
2024-05-13 12:35:59 +00:00
Kim Morrison
799923d145 chore: move have to decreasing_by in substrEq.loop (#4143)
Currently this causes linter warnings downstream in proofs that unfold
substrEq.loop.
2024-05-13 06:18:44 +00:00
Kim Morrison
f74980ccee chore: incorrect lemma resolution in omega (#4141)
Fixes #4138.
2024-05-12 23:06:48 +00:00
Joachim Breitner
b8f2f28e0d fix: check that funind-reserved names are available (#4135)
I did not introduce `inductTheoremSuffix` etc, it seems more direct to
just spell out the suffix here. If we ever change it there are many
occurrences where they need to be changed anyways, so the definition
doesn't seem to save much work or add that much robustness.
2024-05-12 20:39:14 +00:00
Marcus Rossel
0d9af1b777 fix: typo in Meta.unfoldProjInstWhenInstances? (#4139) 2024-05-12 16:45:56 +00:00
Leonardo de Moura
7db8e6482e fix: auto/option params should not break sorry (#4132)
closes #2649
2024-05-11 02:10:40 +00:00
Leonardo de Moura
147aeaea45 test: for issue 2558 (#4133)
Issue has been fixed by another PR.

closes #2558
2024-05-11 00:47:33 +00:00
Leonardo de Moura
a875ae3acf feat: recover from runtime errors in tactics (#4130)
closes #3554
2024-05-11 00:07:13 +00:00
Mac Malone
25e94f916f feat: IO.TaskState (#4097)
Adds `IO.getTaskState` which returns the state of a `Task` in the Lean
runtime's task manager. The `TaskState` inductive has 3 constructors:
`waiting`, `running`, and `finished`. The `waiting` constructor
encompasses the waiting and queued states within the C task object
documentation, because the task object does not provide a low cost way
to distinguish these different forms of waiting. Furthermore, it seems
unlikely for consumers to wish to distinguish between these internal
states. The `running` constructor encompasses both the running and
promised states in C docs. While not ideal, the C implementation does
not provide a way to distinguish between a running `Task` and a waiting
`Promise.result` (they both have null closures).
2024-05-10 23:04:54 +00:00
Kyle Miller
a1be9ec850 chore: tidying up Lean.unresolveNameGlobal (#4091)
The main loop logic could be simplified, and `if let` could be used to
make control flow more obvious.

Also adds a check for macro scopes to prevent `unresolveNameGlobal` from
returning names with macro scopes in the event there's an alias with
one.

This is a follow up to #3946.
2024-05-10 22:37:34 +00:00
Leonardo de Moura
e237e12478 refactor: add tryCatchRuntimeEx combinator (#4129)
see #4079
2024-05-10 22:34:09 +00:00
Leonardo de Moura
a6d186a81d fix: add checkSystem and withIncRecDepth to withAutoBoundImplicit (#4128)
Fix stack overflow crash.

Closes #4117

The fix can be improved: we could try to avoid creating hundreds of auto
implicits before failing.
2024-05-10 21:55:26 +00:00
Arthur Adjedj
6c6b56e7fc fix: revert "monadic generalization of FindExpr" (#4125)
This reverts commit 706a4cfd73 introduced
in #3970

As explained in #4124, `findM?` can become a footgun if used in monads
which induce side-effects such as caching. This PR removes that
function, and fixes the code introduced by #3398 for which the function
was first added.

cc @semorrison.
2024-05-10 20:36:08 +00:00
JovanGerb
228ff58f3a chore: remove duplicate check (#4126) 2024-05-10 20:35:21 +00:00
Lean stage0 autoupdater
dcdc3db3d4 chore: update stage0 2024-05-10 07:39:47 +00:00
Joachim Breitner
39286862e3 feat: well-founded definitions irreducible by default (#4061)
we keep running into examples where working with well-founded recursion
is slow because defeq checks (which are all over the place, including
failing ones that are back-tracked) unfold well-founded definitions.

The definition of a function defined by well-founded recursion should be
an implementation detail that should only be peeked inside by the
equation generator and the functional induction generator.

We now mark the mutual recursive function as irreducible (if the user
did not
set a flag explicitly), and use `withAtLeastTransparency .all` when
producing
the equations.

Proofs can be fixed by using rewriting, or – a bit blunt, but nice for
adjusting
existing proofs – using `unseal` (a.k.a. `attribute [local
semireducible]`).

Mathlib performance does not change a whole lot:

http://speed.lean-fro.org/mathlib4/compare/08b82265-75db-4a28-b12b-08751b9ad04a/to/16f46d5e-28b1-41c4-a107-a6f6594841f8
Build instructions -0.126 %, four modules with significant instructions
decrease.

To reduce impact, these definitions were changed:

* `Nat.mod`, to make `1 % n` reduce definitionally, so that `1` as a
`Fin 2` literal
works nicely. Theorems with larger `Fin` literals tend to need a `unseal
Nat.modCore`
   https://github.com/leanprover/lean4/pull/4098
* `List.ofFn` rewritten to be structurally recursive and not go via
`Array.ofFn`:
   https://github.com/leanprover-community/batteries/pull/784

Alternative designs explored were

 * Making `WellFounded.fix` irreducible. 
 
One benefit is that recursive functions with equal definitions (possibly
after
instantiating fixed parameters) are defeq; this is used in mathlib to
relate

[`OrdinalApprox.gfpApprox`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/SetTheory/Ordinal/FixedPointApproximants.html#OrdinalApprox.gfpApprox)
with `.lfpApprox`.
   
   But the downside is that one cannot use `unseal` in a
targeted way, being explicit in which recursive function needs to be
reducible here.

And in cases where Lean does unwanted unfolding, we’d still unfold the
recursive
definition once to expose `WellFounded.fix`, leading to large terms for
often no good
   reason.

* Defining `WellFounded.fix` to unroll defintionally once before hitting
a irreducible
`WellFounded.fixF`. This was explored in #4002. It shares most of the
ups and downs
with the previous variant, with the additional neat benefit that
function calls that
do not lead to recursive cases (e.g. a `[]` base case) reduce nicely.
This means that
   the majority of existing `rfl` proofs continue to work.

Issue #4051, which demonstrates how badly things can go if wf recursive
functions can be
unrolled, showed that making the recursive function irreducible there
leads to noticeably
faster elaboration than making `WellFounded.fix` irreducible; this is
good evidence that
the present PR is the way to go. 

This fixes https://github.com/leanprover/lean4/issues/3988

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-05-10 06:45:21 +00:00
Mac Malone
ca6437df71 fix: lake: TOML key order bug in ppTable (#4104)
Fixes a bug in `Lake.Toml.ppTable` where root table keys could be
printed after a subtable header.

Closes #4099.
2024-05-10 05:12:19 +00:00
Mario Carneiro
3491c56c49 fix: segfault in old compiler due to noConfusion assumptions (#2903)
This fixes #2901, a bug in the old compiler which causes a segfault. The
issue is that when visiting `noConfusion` applications, it assumes that
each constructor case has `nfields` arguments, e.g. `head1 = head2 ->
tail1 = tail2 -> P` has two arguments because `List.cons` has 2 fields,
but in fact propositional fields are skipped by the noConfusion type
generator, so for example `Subtype.noConfusionType` is:
```lean
@[reducible] protected def Subtype.noConfusionType.{u_1, u} : {α : Sort u} →
  {p : α → Prop} → Sort u_1 → Subtype p → Subtype p → Sort u_1 :=
fun {α} {p} P v1 v2 ↦
  Subtype.casesOn v1 fun val property ↦ Subtype.casesOn v2 fun val_1 property ↦ 
    (val = val_1 → P) → P
```
where `val = val_1 → P` only has the one argument even though
`Subtype.mk` has two fields, presumably because it is useless to have an
equality of propositions. Unfortunately there isn't any easy cache or
getter to use here to get the number of non-propositional fields, so we
just calculate it on the spot.
2024-05-10 01:38:38 +00:00
Tobias Grosser
368adaf847 feat: add BitVec.[toInt_inj|toInt_ne] (#4075)
Co-authored-by: Kim Morrison <scott@tqft.net>
2024-05-10 00:57:00 +00:00
Leonardo de Moura
6a040ab068 feat: propagate maxHeartbeats to kernel (#4113)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-05-09 17:44:19 +00:00
Kim Morrison
fe7b96d8a0 fix: generate deprecation warnings for dot notation (#3969)
Fixes #3270 by moving the deprecation check from
`Lean.Elab.Term.mkConsts` to `Lean.Elab.Term.mkConst`, so
`Lean.Elab.Term.mkBaseProjections`, `.elabAppLValsAux`, `.elabAppFn`,
and `.elabForIn` also hit the check. Not all of these really need to hit
the check, so I'll run `!bench` to see if it's a problem.
2024-05-09 04:52:09 +00:00
Leonardo de Moura
ec87283465 perf: use withSynthesize when elaborating let/have type (#4096)
closes #4051

cc @semorrison
2024-05-09 00:58:43 +00:00
Leonardo de Moura
d7c6920550 chore: remove dead functionpreprocessLevels (#4112) 2024-05-08 15:38:04 +00:00
Joachim Breitner
227e861719 refactor: make 1 % n reduce without well-founded recursion (#4098)
this is in preparation for #4061. Once that lands, `1 % 42 = 1` will no
longer hold definitionally (at least not without an ungly `unseal
Nat.modCore in` around). This affects mathlib in a few places,
essentially every time a `1 : Fin (n+1)` literal is written.

So this extends the existing special case for `0 % n = 0` to `1 % n`.
2024-05-08 15:12:47 +00:00
Joachim Breitner
e9c302c17e chore: bug template: point to live.lean-lang.org (#4109)
https://live.lean-lang.org/#project=lean-nightly now allows users to
play around with the latest lean nightly, and it seems prudent to ask
them to test bug reports, if possible, there, and not just with whatever
release they use.

Also reformatted the descriptions to look well in a text area. Users
will not see this as rendered markdown, but as plain text.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-05-08 13:21:17 +00:00
Mario Carneiro
5814a45d44 fix: mainModuleName should use srcSearchPath (#4066)
As [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/341532-lean4-dev/topic/Find.20references.20broken.20in.20lean.20core/near/437051935).
The `mainModuleName` was being set incorrectly when browsing lean core
sources, resulting in failure of cross-file server requests like "Find
References". Because the `srcSearchPath` is generated asynchronously, we
store it as a `Task Name` which is resolved some time before the header
is finished parsing. (I don't think the `.get` here will ever block,
because the srcSearchPath will be ready by the time the initial command
snap is requested.)

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-05-08 12:34:27 +00:00
Kim Morrison
dcf74b0d89 chore: Std -> Batteries renaming (#4108) 2024-05-08 05:04:25 +00:00
Kyle Miller
a257767417 fix: make deriving handler for Repr be consistent about erasing types and proofs (#3944)
The deriving handler would use `_` for types and proofs for structures
but not for inductives.

Reported by Graham Leach-Krouse on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Deriving.20Repr.20for.20an.20inductive.20with.20proof.20parameters/near/434181985).
2024-05-07 23:55:52 +00:00
Austin Letson
b8e67d87a8 doc: add docstrings and usage examples in Init.Data.String.Basic (#4001)
Add docstrings and usage examples for `String.length`, `.push`,
`.append`, `.get?`, `.set`, `.modyify`, and `.next`. Update docstrings
and add usage examples for `String.toList`, `.get`, and `.get!`.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-05-07 23:49:43 +00:00
Leonardo de Moura
2a5ca00ad6 perf: issue at binop% and binrel% elaborators (#4092)
This issue was affecting several Mathlib files.

@mattrobball @semorrison This is a different solution for the issue. The
comment at `Extra.lean` describes the new solution and documents the new
issues found with the previous one.

closes #4085
2024-05-07 23:31:05 +00:00
François G. Dorais
ec27b3760d fix: swap Nat.zero_or and Nat.or_zero (#4094)
Closes #4093
2024-05-07 23:29:38 +00:00
Siddharth
e5b7dc819b feat: bitvec lemma to turn negation into bitwise not+add (#4095)
Identity 2-2 (a) (Section: Addition Combined with Logical Operations)
from Hacker's Delight, 2nd edition.
2024-05-07 22:31:19 +00:00
Leonardo de Moura
93c06c0552 feat: relaxed reset/reuse in the code generator (#4100)
closes #4089
2024-05-07 22:08:32 +00:00
Mario Carneiro
bb7e6e4769 chore: lake: tweak hovers for family_def et al (#4088)
This makes the `leanArts` in `library_data leanArts : BuildJob Unit` get
a hover for the generated axiom. It also simplifies the `quoteFrom`
function so that it delaborates properly by using a name literal (which
elaborates to `mkStr1`, `mkStr2` etc) instead of a `mkStr` application.
2024-05-07 15:14:09 +00:00
Kim Morrison
883a3e752d chore: allow omega to use classicality, in case Decidable instances are too big (#4073)
From bug report at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/omega.20regression.20in.204.2E8.2E0-rc1/near/437150155
2024-05-07 01:44:56 +00:00
Leonardo de Moura
03040618b8 chore: test for issue #4064
closes #4064
2024-05-07 03:23:30 +02:00
Leonardo de Moura
dfde4ee3aa chore: update stage0 2024-05-07 03:23:30 +02:00
Leonardo de Moura
07c407ab82 feat: collect kernel diagnostic information (#4082)
We now also track which declarations have been unfolded by the kernel
when using
```lean
set_option diagnostics true
```
2024-05-06 21:53:16 +00:00
Leonardo de Moura
00dceb9a9d fix: code duplication at liftCoreM and liftTermElabM at Command.lean (#4080)
This PR also fixes:

- Fields caching specific `Options` at `CoreM` are now properly set.
- `nextMacroScope` was not being propagated at `liftCoreM`.
2024-05-06 19:17:35 +00:00
Kim Morrison
35d9307df3 chore: move @[simp] attribute on length_eq_zero earlier (#4077)
Cleanup.
2024-05-06 11:14:18 +00:00
Kyle Miller
9e4c414f48 fix: remove Subtype.instInhabited (#4055)
It has had a long history going back [10
years](3afad10a72 (diff-4e22e2bb74f004d2ff7cdabcb5c01429abbc906e20befe2517679e257b4387e4R41)),
but its time has come to an end since this instance is never applicable.
2024-05-06 11:08:19 +00:00
Joachim Breitner
6d22793ddf refactor: Array.feraseIdx: avoid have in definition (#4074)
otherwise it remains in the equational theorem and may cause the
“unused have linter” to trigger. By moving the proof into
`decreasing_by`, the equational theorems are unencumbered by termination
arguments.

see also
https://github.com/leanprover/std4/pull/690#issuecomment-2095378609
2024-05-06 08:08:43 +00:00
Arthur Adjedj
e0c1afd12d fix: occurence check in mkInjectiveTheoremTypeCore? (#3398)
Closes #3386

Currently, when generating the signature of an injectivity lemma for a
certain constructor `c : forall xs, Foo a_1 ... a_n`,
`mkInjectiveTheoremTypeCore?` will differentiate between variables which
are bound to stay the same between the two equal values (i.e inductive
indices), and non-fixed ones. To do that, the function currently checks
whether a variable `x ∈ xs` appears in the final co-domain `Foo a_1 ...
a_n` of the constructor. This condition isn't enough however. As shown
in the linked issue, the codomain may also depend on variables which
appears in the type of free vars contained in `Foo a_1 ... a_n`, but not
in the term itself. This PR fixes the issue by also checking the types
of any free variable occuring in the final codomain, so as to ensure
injectivity lemmas are well-typed.
2024-05-06 06:50:08 +00:00
Harun Khan
b1bedbe0d2 feat: equivalence of bit-vector negation and bitblasted negation (#3920) 2024-05-06 06:03:28 +00:00
Arthur Adjedj
1ea92baa21 fix: Incorrect promotion from index to paramater (#3591)
Depends on #3590

Closes #3458
2024-05-06 05:58:15 +00:00
Peiran Wu
07be352ea7 feat: lemmas to simplify equalities with Option-typed dependent if-then-else (#4037)
Closes #4013.

Add `dite_some_none_eq_none` and `dite_some_none_eq_some`, analogous to
the existing `ite_some_none_eq_none` and `ite_some_none_eq_some`.
2024-05-06 05:51:52 +00:00
Kim Morrison
3c11cca3cb feat: upstream lemmas about basic List/Array operations (#4059)
This PR upstreams lemmas about List/Array operations already defined in
Lean from std/batteries.

Happy to take suggestions about increasing or decreasing scope.

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-05-06 03:52:33 +00:00
Kyle Miller
3bd2a7419d fix: have app unexpanders be considered before field notation (#4071)
On
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Notation.20in.20namespace.20not.20showing.20in.20pp/near/437016468),
Peter Nelson reported that notations that could be pretty printed with
generalized field notation did not pretty print using the intended
notation.

This PR makes it so that app unexpanders are considered before
generalized field notation. The complexity before was that we wanted to
do parent projection collapse, and since we did the collapse before
pretty printing that argument, it meant it wasn't possible to do app
unexpanders when there was a field notation candidate. The new solution
is to collapse parent projections only when actually considering field
notation, which can be done because we can safely strip off projection
syntax in an expression-directed way.
2024-05-05 22:44:01 +00:00
Joachim Breitner
26a1b934c2 fix: rfl tactic error messsage when there are no goals (#4067)
fixes #4063
2024-05-05 10:42:41 +00:00
Mario Carneiro
93d7afb00a fix: bug in reduceLeDiff simproc proof term (#4065)
As [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/v4.2E8.2E0-rc1.20issue/near/437059527).
2024-05-05 07:44:36 +00:00
Leonardo de Moura
e362b50fa9 feat: add seal and unseal commands (#4053) 2024-05-03 13:44:58 +00:00
Leonardo de Moura
2df35360ee feat: validate reducibility attribute setting (#4052)
and new option `set_option allowUnsafeReductibility true` to override
validation.

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-05-03 13:44:42 +00:00
Mario Carneiro
2db602c209 doc: layout algorithm (#3915)
The layout algorithm, while somewhat finicky, is (unfortunately)
necessary for C code to interface with lean structures. This adds a
(AFAIK) complete description of the layout algorithm, including a worked
example large enough to make it possible to reconstruct the whole
decision diagram.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-05-03 11:47:23 +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
Kim Morrison
51abb0d4c7 chore: begin development cycle for v4.9.0 (#4058) 2024-05-03 03:20:29 +00:00
Mac Malone
e733149134 feat: lake: require doc comments (#4057)
Lake now supports docstrings on `require` commands:

```lean
/-- This is a docstring for a require statement. -/
require std from ...
```

Closes #2898.
2024-05-03 01:08:18 +00:00
Mac Malone
ac08be695e chore: lake: cleanup tests (#4056)
Various tweaks and fixes to the Lake tests to make them cleaner and more
standardized.
2024-05-03 01:08:12 +00:00
Leonardo de Moura
1d17c7df2b chore: cleanup and remove unnecessary checkpointDefEq (#4029) 2024-05-02 17:58:03 +00:00
Sebastian Ullrich
092ca8530a chore: CI: disable large runner again 2024-05-02 17:46:29 +02:00
Sebastian Ullrich
92fac419e7 chore: CI: use large runners on Windows (#4050) 2024-05-02 14:28:17 +00:00
Mac Malone
e6160d7d4a feat: IO.Process.get/setCurrentDir (#4036)
Adds `IO.Process.getCurrentDir` and `IO.Process.setCurrentDir` for
retrieving and setting, respectively, the current working directory of a
process. The names of the functions are inspired by Rust (e.g.,
[`set_current_dir`](https://doc.rust-lang.org/std/env/fn.set_current_dir.html)).
2024-05-02 13:49:10 +00:00
Joachim Breitner
74adb0961c chore: add ./script/rebase-stage0.sh (#3984)
heavily based on an script by Kim.
2024-05-02 12:26:25 +00:00
Sebastian Ullrich
4591747381 feat: trace.profiler.useHeartbeats (#3986)
Makes trace.profiler useful for debugging heartbeat timeouts etc.. Not
an exact science as enabling profiling consumes itself but close enough.
2024-05-02 12:09:19 +00:00
Joachim Breitner
bc23383194 feat: subst notation (heq ▸ h) tries both orientation (#4046)
even when rewriting the type of `h` becuase there is no expected type.

(When there is an expected type, it already tried both orientations.)

Also feeble attempt to include this information in the docstring without
writing half a manual chapter.
2024-05-02 07:02:40 +00:00
Joachim Breitner
b470eb522b refactor: do not try rfl in mkEqnTypes in WF.mkEqns (#4047)
when dealing with well-founded recursive definitions, `tryURefl` isn't
going to be that useful and possibly slow. So disable that code path
when doing well-founded recursion.

(This is a variant of #4025 where I tried using `with_reducible` to
limit the impact of slow unfolding, but if we can get away with
disabling it complete, then even better.)
2024-05-02 06:17:15 +00:00
Kim Morrison
e13613d633 chore: report used instances correctly in diagnostics (#4049) 2024-05-02 05:47:51 +00:00
Leonardo de Moura
5f1c4df07d feat: display diagnostic information at term and tactic set_option diagnostics true (#4048)
We don't need to include reduction info at `simp` diagnostic
information.
2024-05-01 22:47:57 +00:00
Kyle Miller
5f727699b0 doc: mention build doc source location (#4045) 2024-05-01 22:42:54 +00:00
Leonardo de Moura
e1b7984836 perf: improve simp cache behavior for well-behaved dischargers (#4044)
See comment at `Methods.wellBehavedDischarge`.
The default discharger is now well-behaved.
2024-05-01 19:57:44 +00:00
Leonardo de Moura
d9ea092585 feat: include congruence theorems at simp diagnostic information (#4043) 2024-05-01 17:22:24 +00:00
Kyle Miller
359f60003a fix: use correct expr positions when delaborating match patterns (#4034)
In the following, hovering over `true` in the infoview was showing
`Nat.succ y`.
```lean
#check fun (x : Nat) =>
  match h : x with
  | 0 => false
  | y + 1 => true
```
Now hovering over `true` shows `true`.

The issue was that SubExpr positions were not being tracked for
patterns, and the position for a pattern could coincide with the
position for a RHS, putting overwriting terminfo. Now the position given
to a pattern is correct and unique.

Refactors the `match` delaborator, makes it handle shadowing of `h :`
discriminant annotations correctly, and makes it use the standard
`withOverApp` combinator to handle overapplication.
2024-05-01 12:02:10 +00:00
Leonardo de Moura
806e41151b chore: fix tests 2024-05-01 03:19:39 +02:00
Leonardo de Moura
527493c2a1 feat: in tried theorem section at simp diagnostics, indicate how many times is succeeded 2024-05-01 03:19:39 +02:00
Leonardo de Moura
a12e8221da feat: include counters for unfolded declarations at simp diagnostics 2024-05-01 03:19:39 +02:00
Leonardo de Moura
bcfad6e381 feat: report diagnostic information for simp at exception 2024-05-01 03:19:39 +02:00
Leonardo de Moura
283587987a feat: diagnostic information for simp 2024-05-01 03:19:39 +02:00
Leonardo de Moura
99e652ab1c feat: mention set_option diagnostics true at maximum recursion depth error message 2024-05-01 03:19:39 +02:00
Leonardo de Moura
c833afff11 feat: mention set_option diagnostics true at deterministic timeout message 2024-05-01 03:19:39 +02:00
Leonardo de Moura
c3714bdc6d feat: add structure to diagnostic information 2024-05-01 03:19:39 +02:00
Mac Malone
cc2ccf71d5 fix: lake: log refactor bugs (#4033)
Fixes some bugs with the log refactor (#3835). Namely, quiet mode
progress printing and missing string interpolation in the fetching cloud
release caption.
2024-04-30 23:25:32 +00:00
Kim Morrison
f8d2ebd47a chore: remove @[simp] from BitVec.of_length_zero (#4039) 2024-04-30 23:19:27 +00:00
Kim Morrison
660eb9975a chore: restore #4006 (#4038) 2024-04-30 23:06:50 +00:00
Leonardo de Moura
5c3f6363cc fix: mismatch between TheoremVal in Lean and C++ (#4035) 2024-04-30 18:10:20 +00:00
Sebastian Ullrich
6e731b4370 chore: delete interpreter copy constructor just to be safe 2024-04-30 10:36:40 +02:00
Sebastian Ullrich
18a69914da chore: fix asan linking 2024-04-30 10:36:19 +02:00
Leonardo de Moura
83c139f750 feat: improve set_option diagnostics true (#4031) 2024-04-30 05:07:03 +00:00
Leonardo de Moura
edbd7ce00d chore: rename set_option diag true to set_option diagnostics true (#4030) 2024-04-30 03:57:57 +00:00
Mac Malone
02925447bd refactor: lake: --wfail & track jobs & logs & simplify build monads (#3835)
This is a major refactor of Lake's build code.  The key changes:

* **Job Registration**: Significant build jobs are now registered by
build functions. The DSL inserts this registration automatically into
user-defined targets and facets, so this change should require no
end-user adaption. Registered jobs are incrementally awaited by the main
build function and the progress counter now indicates how many of these
jobs are completed and left-to-await. On the positive side, this means
the counter is now always accurate. On the negative side, this means
that jobs are displayed even if they are no-ops (i.e., if the target is
already up-to-date).

* **Log Retention**: Logs are now part of a Lake monad's state instead
of being eagerly printed. As a result, build jobs retain their logs.
Using this change, logs are are now always printed after their
associated caption (e.g., `[X/Y] Building Foo`) and are not arbitrarily
interleaved with the output of other jobs.

* **Simplify the build monad stack**: Previously, there was a lot of
confused mixing between the various build monads in the codebase (i.e.,
`JobM`, `ScedulerM`, `BuildM`, `RecBuildM`, and `IndexBuildM` ). This
refactor attempts to make there use more consistent and straightforward:
* `FetchM` (formerly `IndexBuildM`) is the top-level build monad used by
targets and facets and is now uniformly used in the codebase for all
top-level build functions.
* `JobM` is the monad of asynchronous build jobs. It is more limited
than `FetchM` due to the fact that the build cache can not be modified
asynchronously.
* `SpawnM` (formerly `SchedulerM`) is the monad used to spawn build
jobs. It lifts into `FetchM`.
* `RecBuildM` and `CoreBuildM` (formerly `BuildM`) have been relegated
to internal details of how `FetchM` / `JobM` are implemented / run and
are no longer used outside of that context.

* **Pretty progress.** Build progress (e.g., `[X/Y] Building Foo`) is
now updated on a single line via ANSI escape sequences when Lake is
outputting to a terminal. Redirected Lake output still sees progress on
separate lines.

* **Warnings-as-error option.** Adds a `--wfail` option to Lake that
will cause a build to fail if Lake logs any warnings doing a build.
Unlike some systems, this does not convert warnings into errors and it
does not abort jobs which log warnings. Instead, only the top-level
build fails.

* **Build log cache.** Logs from builds are now cached to a file and
replayed when the build is revisited. For example, this means multiple
runs of a `--wfail` Lean build (without changes) will still produce the
same warnings even though there is now an up-to-date `.olean` for the
module.

 Closes #2349. Closes #2764.
2024-04-30 01:55:20 +00:00
Mac Malone
a969d2702f chore: lake: error on package name mismatch + std special case (#3999)
Lake now errors instead of warns on a mismatch between a package name
and what is required as. This avoids sometimes confusing downstream
errors. Also, this change provides additional information for errors
that may be caused by the upcoming Std rename.
2024-04-30 01:32:35 +00:00
Leonardo de Moura
27c79cb614 fix: double reset bug at ResetReuse (#4028)
We conjecture this is the cause for the segfaults when compiling Mathlib
with #4006
2024-04-29 23:26:07 +00:00
Joachim Breitner
e2983e44ef perf: use with_reducible in special-purpose decreasing_trivial macros (#3991)
Because of the last-added-tried-first rule for macros, all the special
purpose `decreasing_trivial` rules are tried for most recursive
definitions out there, and because they use `apply` and `assumption`
with default transparency may cause some definitoins to be unfolded over
and over again.

A quick test with one of the functions in the leansat project shows that
elaboration time goes down from 600ms to 375ms when using
```
decreasing_by all_goals decreasing_with with_reducible decreasing_trivial
```
instead of
```
decreasing_by all_goals decreasing_with decreasing_trivial
```

This change uses `with_reducible` in most of these macros.

This means that these tactics will no longer work when the
relations/definitions they look for is hidden behind a definition.
This affected in particular `Array.sizeOf_get`, which now has a
companion `sizeOf_getElem`.

In addition, there were three tactics using `apply` to apply Nat-related
lemmas
that we now expect `omega` to solve. We still need them when building
`Init` modules
that don’t have access to `omega`, but they now live in
`decreasing_trivial_pre_omega`,
meant to be only used internally.
2024-04-29 15:12:27 +00:00
Kim Morrison
01573067f9 chore: typos (#4026) 2024-04-29 14:04:50 +00:00
Joachim Breitner
f0b2621047 test: add guard_msgs to wfEqns tests (#4024)
otherwise we would not catch changes to the shape of these equational
lemmas.

Also, no need to manually trigger the generation of these lemmas.
2024-04-29 12:45:53 +00:00
Leonardo de Moura
4b88965363 chore: disable #4006 (#4021)
Mathlib is crashing with #4006. Here is the stacktrace produced by Kim:
```
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x100000000000a)
  * frame #0: 0x00000001066db21c libleanshared.dylib`lean::ir::interpreter::eval_body(lean::object_ref const&) + 2816
    frame #1: 0x00000001066dd464 libleanshared.dylib`lean::ir::interpreter::call(lean::name const&, lean::array_ref<lean::object_ref> const&) + 1360
    frame #2: 0x00000001066db394 libleanshared.dylib`lean::ir::interpreter::eval_body(lean::object_ref const&) + 3192
    frame #3: 0x00000001066dd464 libleanshared.dylib`lean::ir::interpreter::call(lean::name const&, lean::array_ref<lean::object_ref> const&) + 1360
    frame #4: 0x00000001066db394 libleanshared.dylib`lean::ir::interpreter::eval_body(lean::object_ref const&) + 3192
    frame #5: 0x00000001066dd464 libleanshared.dylib`lean::ir::interpreter::call(lean::name const&, lean::array_ref<lean::object_ref> const&) + 1360
    frame #6: 0x00000001066db394 libleanshared.dylib`lean::ir::interpreter::eval_body(lean::object_ref const&) + 3192
    frame #7: 0x00000001066df288 libleanshared.dylib`lean::ir::interpreter::stub_m(lean_object**) + 556
    frame #8: 0x00000001066d6ee0 libleanshared.dylib`lean_object* lean::ir::interpreter::with_interpreter<lean_object*>(lean::environment const&, lean::options const&, lean::name const&, std::__1::function<lean_object* (lean::ir::interpreter&)> const&) + 320
    frame #9: 0x00000001066dee84 libleanshared.dylib`lean::ir::interpreter::stub_m_aux(lean_object**) + 92
    frame #10: 0x00000001066deafc libleanshared.dylib`lean::ir::interpreter::stub_9_aux(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*) + 60
    frame #11: 0x00000001066f52a0 libleanshared.dylib`lean_apply_6 + 1748
    frame #12: 0x00000001055d1ac8 libleanshared.dylib`l_Array_forInUnsafe_loop___at___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___spec__10___lambda__2 + 156
    frame #13: 0x00000001055d47e8 libleanshared.dylib`l_Array_forInUnsafe_loop___at___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___spec__10___lambda__2___boxed + 144
    frame #14: 0x00000001066f5bcc libleanshared.dylib`lean_apply_7 + 1348
    frame #15: 0x00000001055ccccc libleanshared.dylib`l_Lean_Elab_withInfoTreeContext___at___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___spec__4 + 528
    frame #16: 0x00000001066f5b6c libleanshared.dylib`lean_apply_7 + 1252
    frame #17: 0x00000001055d1550 libleanshared.dylib`l_Lean_Elab_withLogging___at___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___spec__6 + 240
    frame #18: 0x00000001055d4cb4 libleanshared.dylib`l_Array_forInUnsafe_loop___at___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___spec__10 + 940
    frame #19: 0x00000001055d5394 libleanshared.dylib`l___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___lambda__1 + 60
    frame #20: 0x00000001055d5740 libleanshared.dylib`l___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore___lambda__1___boxed + 148
    frame #21: 0x00000001066f11f4 libleanshared.dylib`lean_apply_1 + 840
    frame #22: 0x0000000103bce27c libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg___lambda__1 + 24
    frame #23: 0x0000000103bce4ec libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg___lambda__1___boxed + 20
    frame #24: 0x00000001066f10bc libleanshared.dylib`lean_apply_1 + 528
    frame #25: 0x0000000106644260 libleanshared.dylib`lean_profileit + 128
    frame #26: 0x0000000103bce3e0 libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg + 112
    frame #27: 0x00000001055d564c libleanshared.dylib`l___private_Lean_Elab_Term_0__Lean_Elab_Term_applyAttributesCore + 268
    frame #28: 0x00000001055d6264 libleanshared.dylib`l_Lean_Elab_Term_applyAttributes + 52
    frame #29: 0x000000010597b840 libleanshared.dylib`l_Array_forInUnsafe_loop___at_Lean_Elab_Command_elabAttr___spec__6___lambda__1 + 740
    frame #30: 0x000000010597daf4 libleanshared.dylib`l_Array_forInUnsafe_loop___at_Lean_Elab_Command_elabAttr___spec__6___lambda__1___boxed + 124
    frame #31: 0x00000001066f65d8 libleanshared.dylib`lean_apply_8 + 1252
    frame #32: 0x00000001066f5b6c libleanshared.dylib`lean_apply_7 + 1252
    frame #33: 0x0000000104f587b0 libleanshared.dylib`l___private_Lean_Elab_InfoTree_Main_0__Lean_Elab_withSavedPartialInfoContext___at_Lean_Elab_Command_liftTermElabM___spec__2___rarg___lambda__1 + 344
    frame #34: 0x0000000104f59ec4 libleanshared.dylib`l___private_Lean_Elab_InfoTree_Main_0__Lean_Elab_withSavedPartialInfoContext___at_Lean_Elab_Command_liftTermElabM___spec__2___rarg + 280
    frame #35: 0x0000000104f5af20 libleanshared.dylib`l_Lean_Elab_Command_liftTermElabM___rarg___lambda__1 + 144
    frame #36: 0x00000001066f5ab8 libleanshared.dylib`lean_apply_7 + 1072
    frame #37: 0x0000000105636090 libleanshared.dylib`l_Lean_Elab_Term_TermElabM_run___rarg + 844
    frame #38: 0x0000000104f5b8fc libleanshared.dylib`l_Lean_Elab_Command_liftTermElabM___rarg + 1696
    frame #39: 0x000000010597d67c libleanshared.dylib`l_Array_forInUnsafe_loop___at_Lean_Elab_Command_elabAttr___spec__6 + 928
    frame #40: 0x000000010597de60 libleanshared.dylib`l_Lean_Elab_Command_elabAttr + 772
    frame #41: 0x000000010597e838 libleanshared.dylib`l_Lean_Elab_Command_elabAttr___boxed + 20
    frame #42: 0x00000001066f2cd4 libleanshared.dylib`lean_apply_3 + 868
    frame #43: 0x0000000104f385f8 libleanshared.dylib`l_Lean_Elab_withInfoTreeContext___at___private_Lean_Elab_Command_0__Lean_Elab_Command_elabCommandUsing___spec__2 + 396
    frame #44: 0x0000000104f39e48 libleanshared.dylib`l___private_Lean_Elab_Command_0__Lean_Elab_Command_elabCommandUsing + 484
    frame #45: 0x00000001066f2cf0 libleanshared.dylib`lean_apply_3 + 896
    frame #46: 0x0000000104f341d4 libleanshared.dylib`l_Lean_withTraceNode___at_Lean_Elab_Command_runLinters___spec__11 + 788
    frame #47: 0x00000001066f2d54 libleanshared.dylib`lean_apply_3 + 996
    frame #48: 0x00000001066f2cf0 libleanshared.dylib`lean_apply_3 + 896
    frame #49: 0x0000000104f40e30 libleanshared.dylib`l_Lean_Elab_withLogging___at_Lean_Elab_Command_elabCommand___spec__2 + 104
    frame #50: 0x0000000104f4c51c libleanshared.dylib`l_Lean_Elab_Command_elabCommandTopLevel___lambda__1 + 432
    frame #51: 0x00000001066f10e8 libleanshared.dylib`lean_apply_1 + 572
    frame #52: 0x0000000103bce27c libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg___lambda__1 + 24
    frame #53: 0x0000000103bce4ec libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg___lambda__1___boxed + 20
    frame #54: 0x00000001066f10bc libleanshared.dylib`lean_apply_1 + 528
    frame #55: 0x0000000106644260 libleanshared.dylib`lean_profileit + 128
    frame #56: 0x0000000103bce3e0 libleanshared.dylib`l_Lean_profileitIOUnsafe___rarg + 112
    frame #57: 0x0000000104f4fce0 libleanshared.dylib`l_Lean_Elab_Command_elabCommandTopLevel + 1284
    frame #58: 0x00000001057d2f30 libleanshared.dylib`l_Lean_Elab_Frontend_elabCommandAtFrontend + 1384
    frame #59: 0x00000001057d63b8 libleanshared.dylib`l_Lean_Elab_Frontend_processCommand + 1332
    frame #60: 0x00000001057d6e48 libleanshared.dylib`l_Lean_Elab_Frontend_processCommands + 72
    frame #61: 0x00000001057d7248 libleanshared.dylib`l_Lean_Elab_IO_processCommands + 212
    frame #62: 0x00000001057d83d0 libleanshared.dylib`l_Lean_Elab_runFrontend___lambda__3 + 76
    frame #63: 0x00000001057d96d0 libleanshared.dylib`lean_run_frontend + 2436
    frame #64: 0x00000001065e72b4 libleanshared.dylib`lean::run_new_frontend(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, lean::options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, lean::name const&, unsigned int, lean::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> const&, unsigned char) + 244
    frame #65: 0x00000001065e9c8c libleanshared.dylib`lean_main + 8348
    frame #66: 0x0000000184f93f28 dyld`start + 2236
```

cc @Kha
2024-04-29 10:58:11 +00:00
Leonardo de Moura
15cfe60640 test: for flexible reducibility attributes 2024-04-29 05:46:11 +02:00
Leonardo de Moura
7294646eb9 chore: update stage0 2024-04-29 05:46:11 +02:00
Leonardo de Moura
47a34316fc feat: flexible reducibility attributes
- We can set `[irreducible]`, `[semireducible]`, and `[reducible]` for
imported declarations.
- Support for `scoped` and `local` versions

TODO: discuss whether we need all this power after we add the module
system.
2024-04-29 05:46:11 +02:00
Leonardo de Moura
5a5a77dd44 feat: set_option diag true tracks recursor reduction (#4020) 2024-04-29 02:06:14 +00:00
Leonardo de Moura
5e30638725 feat: set_option diag true tracks how many times an instance is used (#4019) 2024-04-29 01:05:00 +00:00
Leonardo de Moura
dc442ec137 fix: theorems should never be marked as extern (#4018) 2024-04-29 00:01:49 +00:00
Leonardo de Moura
9d14c0456b feat: add set_option diag true for diagnostic counters (#4016)
It currently only reports how many times each declaration has been
unfolded, and how often the `isDefEq` heuristic for `f a =?= f b` has
been used. Only counters above the threshold are reported.
2024-04-28 22:14:08 +00:00
Joachim Breitner
bb1a373420 fix: subst notation (heq ▸ h) should fail if it does't subst (#3994)
The subst notation substitues in the expected type, if present, or in
the type of the argument, if no expected type is known.

If there is an expected type it already fails if it cannot find the
equations' left hand side or right hand side. But if the expected type
is not known and the equation's lhs is not present in the second
argument's type, it will happily do a no-op-substitution.

This is inconsistent and unlikely what the user intended to do, so we
now print an error message now.

This still only looks for the lhs; search for the rhs as well seems
prudent, but I’ll leave that for a separate PR, to better diagnose the
impact on mathlib.

This triggers a small number of pointless uses of subst in mathlib, see
https://github.com/leanprover-community/mathlib4/pull/12451
2024-04-28 20:29:04 +00:00
Joachim Breitner
f817d5a706 feat: use structural recursion in Fin.induction (#4010)
this should help with reducing mathlib's vector notation (`![a,b,c] 2`),
and reduce fallout from #4002
2024-04-28 20:28:41 +00:00
Leonardo de Moura
adc4c6a7cf chore: add backward compatibility flags for recent isDefEq changes (#4012) 2024-04-28 17:30:49 +00:00
Leonardo de Moura
b8b6b219c3 chore: move trace.cpp to kernel (#4014)
Motivation: trace kernel `is_def_eq`
2024-04-28 17:24:48 +00:00
Leonardo de Moura
63067d0d34 chore: code convention (#4009) 2024-04-28 15:49:55 +00:00
Leonardo de Moura
3be22538d2 chore: add backward compatibility option for TC optimization (#4008) 2024-04-28 06:04:06 +00:00
Leonardo de Moura
99e8270d2d fix: proposition fields must be theorems (#4006)
closes #2575
2024-04-28 01:59:47 +00:00
Leonardo de Moura
8fa36c7730 fix: match_expr parser (#4007)
closes #3989
closes #3990
2024-04-27 23:56:28 +00:00
Leonardo de Moura
a359586a96 perf: isDefEqProj (#4004)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-04-27 23:30:35 +00:00
Leonardo de Moura
e3592e40cf chore: remove dead code at Structure.lean (#4005) 2024-04-27 23:10:28 +00:00
Sebastian Ullrich
7b0d4610b0 chore: CI: pin macos-13 (#3992)
macos-latest changed to arm64. It should not be hard to switch our setup
to cross-compiling x64 instead of arm64 but let's get master green again
first.
2024-04-27 20:58:22 +00:00
Leonardo de Moura
917a31f694 perf: consider at most one answer for type class resolution subgoals not containing metavariables
closes #3996
2024-04-27 21:12:19 +02:00
Leonardo de Moura
34a788110f chore: code convention 2024-04-27 21:12:19 +02:00
Leonardo de Moura
ce350f3481 perf: linearity issue 2024-04-27 21:12:19 +02:00
Leonardo de Moura
1630d9b803 feat: universe constraint approximations (#3981)
We add a new configuration flag for `isDefEq`:
`Meta.Config.univApprox`.
When it is true, we approximate the solution for universe constraints
such as
- `u =?= max u ?v`, we use `?v := u`, and ignore the solution `?v := 0`.
- `max u v =?= max u ?w`, we use `?w := v`, and ignore the solution `?w
:= max u v`.

We only apply these approximations when there the contraints cannot be
postponed anymore. These approximations prevent error messages such as
```
error: stuck at solving universe constraint
  max u ?u.3430 =?= u
```
This kind of error seems to appear in several Mathlib files.

We currently do not use these approximations while synthesizing type
class instances.
2024-04-24 20:27:51 +00:00
Sebastian Ullrich
605cecdde3 fix: show trace timings in infoview (#3985)
A regression introduced by #3801
2024-04-24 15:55:27 +00:00
Kyle Miller
a9db0d2e53 fix: use Name.appendCore instead of Name.append in unresolveNameGlobal (#3946)
`Name.append` has special handling of macro scopes, and it would cause
`unresolveNameGlobal` to panic. Using `Name.appendCore` to append name
parts is justified by the fact that it's being used to reassemble a
disassembled name.

Closes #2291
2024-04-24 15:07:18 +00:00
Kyle Miller
158979380e feat: make Level -> MessageData coercion respect pp.mvars (#3980)
Adds `ppLevel` to the `PPFns` extension so that the coercion can pass
the pretty printing context (including the `pp.mvars` option setting) to
the `Level` formatter.
2024-04-24 14:23:42 +00:00
Joachim Breitner
f9f278266e chore: ci to set “changes-stage0” label (#3979)
Expands on #3971 to do something useful even before the PR enters the
queue:

If stage0 changes are detected in the PR, set the changes-stage0 label
(which
has a tooltip to explain what this entail), and also remove the label if
it no
longer applies.
2024-04-24 07:08:34 +00:00
Austin Letson
861a92a06d doc: docstrings for List.rotateRight/Left and example for List.partitionM (#3919)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-04-24 06:15:05 +00:00
Markus Himmel
f4ae6fc8aa fix: add instances to make ac_rfl work out of the box (#3942)
Previously the `ac_rfl` tactic was only really usable when depending on
mathlib. With these instances, `ac_rfl` can deal with the various
operations defined in Lean.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-04-24 06:12:36 +00:00
Kim Morrison
f2a54ec0eb feat: script to summarize issues (#3952) 2024-04-24 06:11:07 +00:00
Sebastian Ullrich
22a581f38d chore: update code owners 2024-04-24 10:16:16 +02:00
Kim Morrison
706a4cfd73 feat: monadic generalization of FindExpr (#3970)
Not certain this is a good idea. Motivated by code duplication
introduced in #3398.
2024-04-24 06:07:54 +00:00
Richard Copley
4fe0259354 feat: exact?%: do not report suggestions which do not close the goal (#3974)
This makes `exact?%` behave like `by exact?` rather than `by apply?`.

If the underlying function `librarySearch` finds a suggestion which
closes the goal, use it (and add a code action). Otherwise log an error
and use `sorry`. The error is either
```text
`exact?%` didn't find any relevant lemmas
```
or
```text
`exact?%` could not close the goal. Try `by apply` to see partial suggestions.
```

---


[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Useful.20term.20elaborators/near/434863856)

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-04-24 06:07:11 +00:00
Kim Morrison
41697dcf6c feat: improvements to test_extern command (#3075)
Two improvements
[suggested](https://github.com/leanprover/lean4/pull/2970#issuecomment-1853436906)
by @digama0 after the initial PR was merged.

* Allow testing `implemented_by` attributes as well.
* Use `DecidableEq` rather than `BEq` for stricter testing.
2024-04-24 03:56:16 +00:00
Kim Morrison
3990a9b3be chore: upstream Std material from Data/List|Array/Init (#3975)
See proposal on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/upstreaming.20of.20List.2FArray.20material/near/434879041);
I won't merge this until there's a chance for discussion there.
2024-04-24 03:23:25 +00:00
François G. Dorais
05b68687c0 feat: #print command shows structure fields (#3768)
<!--
# Read this section before submitting

* Ensure your PR follows the [External Contribution
Guidelines](https://github.com/leanprover/lean4/blob/master/CONTRIBUTING.md).
* Please make sure the PR has excellent documentation and tests. If we
label it `missing documentation` or `missing tests` then it needs
fixing!
* Include the link to your `RFC` or `bug` issue in the description.
* If the issue does not already have approval from a developer, submit
the PR as draft.
* The PR title/description will become the commit message. Keep it
up-to-date as the PR evolves.
* If you rebase your PR onto `nightly-with-mathlib` then CI will test
Mathlib against your PR.
* You can manage the `awaiting-review`, `awaiting-author`, and `WIP`
labels yourself, by writing a comment containing one of these labels on
its own line.
* Remove this section, up to and including the `---` before submitting.
-->
See RFC #3644 for a discussion of design choices.

Closes #3644
2024-04-24 03:18:09 +00:00
Kyle Miller
94360a72b3 feat: make pp.mvars false pretty print universe mvars as _ (#3978)
Suggestion on
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.23guard_msgs.20variant.3A.20don't.20care.20about.20whitespace/near/434906526)
2024-04-23 20:34:48 +00:00
Kim Morrison
fb135b8cfe fix: improve isDefEqProj (#3977)
Currently this will fail in two tests, because of changes in #3965.

* Sometimes we need to add an additional universe annotation, or we get
a `stuck at solving universe constraint max u ?u =?= u`.
* Sometimes we need to specify arguments that could previously be found
by unification.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-04-23 18:09:26 +00:00
Mario Carneiro
4f664fb3b5 feat: improve @[deprecated] attr (#3968)
Complement to #3967 , adds a `(since := "<date>")` field to
`@[deprecated]` so that metaprogramming code has access to the
deprecation date for e.g. bulk removals. Also adds `@[deprecated
"deprecation message"]` to optionally replace the default text
"`{declName}` has been deprecated, use `{newName}` instead".
2024-04-23 17:00:32 +00:00
Mac Malone
7a076d0bd4 fix: lake: package duplication in workspace (#3957)
Fixes a bug where packages that appeared multiple times in the
dependency tree would be duplicated in the workspace (and in manifests).
Added a regression test for this to prevent this from happening again in
the future.

This was first reported in
l[eanprover/mathlib4#12250](https://github.com/leanprover-community/mathlib4/pull/12258#discussion_r1571834509).
2024-04-23 09:50:10 +00:00
Joachim Breitner
f40c51f346 chore: prevent stage0 changes via the merge queue (#3971)
these need manual rebase merges by an admin, so lets prevent accidential
merges via the squashing merge queue.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-04-23 09:47:27 +00:00
Leonardo de Moura
b2de43ed88 fix: simp caching (#3972)
closes #3943

TODO: remove `cache` field from `Simp.Result`.
2024-04-22 21:22:42 +00:00
Mac Malone
d95e741824 feat: lean CLI option to print messages as JSON (#3939)
Adds a `--json` option to the `lean` CLI. When used, the Lean frontend
will print messages as JSON objects using the default `ToJson` encoding
for the `Message` structure. This allows consumers (such as Lake) to
handle Lean output in a more intelligent, well-structured way.

`Message` has been refactored into `BaseMessage`, `Message`, and
`SerialMessage` to enable deriving `ToJson`/ `FromJson` instances
automatically for `BaseMessage` / `SerialMessage`. `SerialMessage` is a
`Message` with its `MessageData` eagerly serialized to a `String`.
2024-04-22 15:45:32 +00:00
Mario Carneiro
70a23945bf feat: add model implementation for UTF8 enc/dec (#3961)
- [x] Depends on: #3958 
- [x] Depends on: #3960

This makes the UTF-8 encode and decode functions have lean definitions,
so that we can prove properties about them downstream.
2024-04-22 10:24:53 +00:00
Kim Morrison
7c34b736fc chore: deprecate Option.toBool in favour of Option.isSome (#3866) 2024-04-22 07:20:19 +00:00
Sebastian Ullrich
7a65bde3e3 doc: Command.set_option (#3872)
Co-authored-by: Kim Morrison <kim@tqft.net>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-22 07:18:17 +00:00
Kim Morrison
22ce2fea9b chore: fix Util.Heartbeats module-doc (#3954) 2024-04-22 07:02:58 +00:00
Joachim Breitner
ea23ab6fef refactor: make throwTacticEx parameter msg optional (#3951)
previously, the empty `MessageData` (`m!""`) was used to indicate “no
message”, and `throwTacticEx` would format the message differently then.
But the semantics of `MessageData.isEmpty` isn't entirely clear in the
presence of lazy message data (e.g. `.ofPPFormat`).

So to avoid wondering what `isEmpty` should do there, let's simply use
an optional argument to `throwTacticEx` and get rid of
`MessageData.isEmpty`.
2024-04-22 06:55:41 +00:00
Mario Carneiro
e437bfece9 chore: use compareLex in lexOrd (#3882)
This reduces the number of reimplemented functions which complicate
proofs. After inlining it ends up the same as before.

`ltOfOrd` is also changed to use `compare a b = .lt` instead of
`(compare a b == .lt) = true`, for consistency with the normal form in
std.
2024-04-22 06:48:44 +00:00
Sebastian Ullrich
5e313e98d0 doc: Classical.choice (#3871)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-22 06:36:56 +00:00
Kyle Miller
46f42cc9ba doc: update norm_cast and push_cast documentation (#3908)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-22 05:28:25 +00:00
Sebastian Ullrich
7400a40116 doc: section/namespace/end (#3873)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-22 05:23:00 +00:00
Kyle Miller
41d310ab39 fix: solveByElim would add symm hypotheses to local context and make impossible-to-elaborate terms (#3962)
Rather than adding symm hypotheses to the local context, it now adds
them to the list of hypotheses derived from the local context.

This is not ideal for performance reasons, but it at least closes #3922.

In the future, solveByElim could maintain its own cache of facts that it
updates whenever it does intro.
2024-04-22 04:13:22 +00:00
Arthur Adjedj
6ad28ca446 feat: add inductive.autoPromoteIndices option (#3590)
This PR partly addresses #3458, by adding an option `autoPromoteIndices`
to turn off the promotion of fixed indices to parameters. The actual fix
for the issue is in a separate PR #3591.

Because nested inductive datatypes parameters cannot contain local
variables, it is often desirable for a fixed index to not be promoted,
as to allow free variables in that place. See example in `3458_1.lean`
2024-04-22 03:42:22 +00:00
Henrik Böving
263c93aac8 perf: ensure linearity in Parsec.many*Core (#3830) 2024-04-22 03:41:06 +00:00
Leonardo de Moura
e4daca8d6b chore: remove dead code at kernel compare (#3966) 2024-04-22 00:54:24 +00:00
Leonardo de Moura
3dd398a8a4 perf: improve isDefEq for contraints of the form t.i =?= s.i (#3965)
We now use lazy delta reduction at `t` and `s`.
See new test for motivation.
2024-04-22 00:41:34 +00:00
Kim Morrison
ac0f699775 perf: improve heuristic at isDefEq (#3837)
This is intended to fail at present: it just adds a test case containing
a minimization of a Mathlib slowdown from #3807.

Prior to #3807, the declaration `exists_algHom_adjoin_of_splits'''` at
the end of the file would take around 16,000 heartbeats. Now it takes
around 210,000 heartbeats.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-04-21 23:27:44 +00:00
Leonardo de Moura
69202d9b73 fix: ReducibilityHints.lt (#3964) 2024-04-21 21:44:18 +00:00
Mario Carneiro
62cdb51ed5 feat: UTF-8 string validation (#3958)
Previously, there was a function `opaque fromUTF8Unchecked : ByteArray
-> String` which would convert a list of bytes into a string, but as the
name implies it does not validate that the string is UTF-8 before doing
so and as a result it produces unsound results in the compiler (because
the lean model of `String` indirectly asserts UTF-8 validity). This PR
replaces that function by
```lean
opaque validateUTF8 (a : @& ByteArray) : Bool

opaque fromUTF8 (a : @& ByteArray) (h : validateUTF8 a) : String
```
so that while the function is still "unchecked", we have a proof witness
that the string is valid. To recover the original, actually unchecked
version, use `lcProof` or other unsafe methods to produce the proof
witness.

Because this was the only `ByteArray -> String` conversion function, it
was used in several places in an unsound way (e.g. reading untrusted
input from IO and treating it as UTF-8). These have been replaced by
`fromUTF8?` or `fromUTF8!` as appropriate.
2024-04-20 18:36:37 +00:00
Mario Carneiro
5eb274d486 fix: don't use modulo for UInt upcasting (#3960)
This makes `(v : UInt8).toUInt16.toNat = (v : UInt8).toNat` a defeq,
which simplifies proofs.
2024-04-20 16:37:02 +00:00
Mario Carneiro
aeacb7b69e feat: String.Pos.isValid (#3959)
This adds a function that can be used to check whether a position is on
a UTF-8 byte boundary.
2024-04-20 14:57:35 +00:00
Lean stage0 autoupdater
291bb84c97 chore: update stage0 2024-04-19 14:31:23 +00:00
Mario Carneiro
3c36020d13 feat: @[builtin_doc] attribute (part 1) (#3953)
First part of #3918.
2024-04-19 12:21:10 +00:00
Kim Morrison
f23be4a964 feat: upstream false_or_by_contra tests (2nd attempt) (#3949) 2024-04-19 08:09:50 +00:00
Kim Morrison
c5ff671b8a chore: update Authors: line in BitVec files (#3948) 2024-04-19 08:07:25 +00:00
Lean stage0 autoupdater
9dcf07203e chore: update stage0 2024-04-19 08:22:54 +00:00
Kim Morrison
d6474135ba feat: upstream false_or_by_contra tests (#3947)
And fix broken `builtin_tactic` attribute.
2024-04-19 05:30:51 +00:00
Kim Morrison
d1a42aae2a chore: remove @ from rw? suggestions, and enable hover on constants in #check (#3911)
* Replaces the unused `Lean.PrettyPrinter.ppConst` with
`MessageData.ofConst` (which similarly avoids an unnecessary `@`) and
that further generates a hover for the constant

* Uses this in `TryThis.addRewriteSuggestion`, so that `rw?` suggestions
don't have unnecessary `@`s.

* Add `MessageData.signature`, as a wrapper around
`PrettyPrinter.signature`, using the same machinery to generate hovers
for constants, improving the hover behaviour in #check so that we get
second order pop-up for constants in the signature. (Not sure how to
write tests for second order hovers, so there is no test for this.)
2024-04-19 01:27:02 +00:00
David Thrane Christiansen
b6d77be6a5 feat: show diffs when #guard_msgs fails (#3912)
Adds the ability to show a diff when `guard_msgs` fails, using the
histogram diff algorithm pioneered in jgit. This algorithm tends to
produce more user-friendly diffs, but it can be quadratic in the worst
case. Empirically, the quadratic case of this implementation doesn't
seem to be slow enough to matter for messages smaller than hundreds of
megabytes, but if it's ever a problem, we can mitigate it the same way
jgit does by falling back to Myers diff.

See lean/run/guard_msgs.lean in the tests directory for some examples of
its output.
2024-04-18 15:09:44 +00:00
Mac Malone
0c9f9ab37a feat: isTty (#3930)
Adds `IO.FS.Handle.isTty` to check whether a handle is a Windows console
or Unix terminal. Also adds an `isTty` field to `IO.FS.Stream`, so that
this can be checked on, e.g., `stdout`.
2024-04-18 08:50:43 +00:00
Mario Carneiro
df1e6ba7fe fix: built-in parser attributes link to the wrong place (#3916)
Go-to-def on `@[builtin_term_parser]` should go to the line
```lean
builtin_initialize registerBuiltinParserAttribute `builtin_term_parser ``Category.term
```
not
```lean
/-- `term` is the builtin syntax category for terms. ... -/
def term : Category := {}
```
2024-04-18 08:28:16 +00:00
Marc Huisinga
faa4d16dc1 fix: semantic tokens performance (#3932)
While implementing #3925, I noticed that the performance of the
`textDocument/semanticTokens/full` request is *extremely* bad due to a
quadratic implementation. Specifically, on my machine, computing the
full semantic tokens for `Lean/Elab/Do.lean` took a full 5s. In
practice, this means that while elaborating the file, one core is
entirely busy with computing the semantic tokens for the file.

This PR fixes this performance bug by re-implementing the semantic token
handling, reducing the latency for `Lean/Elab/Do.lean` from 5s to 60ms.
As a result, the overly cautious refresh latency of 5s in #3925 can
easily be reduced to 2s again.

Since the previous semantic tokens implementation used a very brittle
hack to identify projections, this PR also changes the projection
notation elaboration to augment the `InfoTree` syntax for the field of a
projection with a special syntax node of kind
`Lean.Parser.Term.identProjKind`. With this syntax kind, projection
fields can now easily be identified in the `InfoTree`.
2024-04-18 07:48:44 +00:00
Henrik Böving
11ff00439e feat: make linter options more explicitly discoverable (#3938)
Closes #3937
2024-04-18 07:20:55 +00:00
Kyle Miller
319940da77 feat: make anonymous instance names not include proofs (#3934) 2024-04-17 19:41:34 +00:00
Lean stage0 autoupdater
11a9d2ee4b chore: update stage0 2024-04-17 19:26:22 +00:00
Joachim Breitner
504336822f perf: faster Nat.repr implementation in C (#3876)
`Nat.repr` was implemented by generating a list of `Chars`, each created
by a 10-way if-then-else. This can cause significant slow down in some
particular use cases.

Now `Nat.repr` is `implemented_by` a faster implementation that uses
C++’s `std::to_string` on small numbers (< USize.size) and maintains an
array of pre-allocated strings for the first 128 numbers.

The handling of big numbers (≥ USize.size) remains as before.
2024-04-17 18:11:05 +00:00
Joachim Breitner
4f50544242 chore: Nat.repr microbenchmark (#3888) 2024-04-17 18:10:32 +00:00
Kyle Miller
627a0f308b fix: add unused variables ignore function for #guard_msgs (#3931)
The `#guard_msgs` command already runs linters by virtue of using
`elabCommandTopLevel`, so linters should *not* be run on `#guard_msgs`
itself. While we could use a more general solution, of the linters the
unused variables linter is the noisiest one, and it's easy enough to
make it not report messages for `#guard_msgs`.
2024-04-17 15:30:17 +00:00
Kyle Miller
89558a007b doc: docstrings on binder types, make sure hovers work (#3917)
Moved `ppGroup` inside the `leading_parser`s for all the binder types so
that hovering works. Improved the docstrings.
2024-04-17 14:21:34 +00:00
Kyle Miller
036b5381f0 fix: make tests be aware of new instance names (#3936)
#3089 caused the stage0 update to cause a number of tests to start
failing because they were using the old instance names.
2024-04-17 16:14:51 +02:00
Lean stage0 autoupdater
88ee503f02 chore: update stage0 2024-04-17 09:21:10 +00:00
Markus Himmel
2397a870f2 feat: add lemma Int.add_bmod (#3890)
Just a lemma that we noticed is missing when working on #3880 at the
retreat. We also noticed that there are naming inconsistencies in the
lemmas for `bmod` and `emod`, we should fix that in the future.
2024-04-17 06:13:22 +00:00
Markus Himmel
d3e004932c chore: move docstrings for open, variable, universe, export from elaborator to parser (#3891)
During the documentation sprint we discussed that user-visible
documentation for syntax should generally go on the parser instead of
the elaborator.
2024-04-17 06:13:11 +00:00
Kim Morrison
cefba8abd2 chore: rename Option.toMonad and remove argument (#3865) 2024-04-17 04:58:54 +00:00
Kim Morrison
c6fbeaa721 doc: add doc-string for LawfulMonad/Applicative (#3859)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-17 04:54:36 +00:00
David Thrane Christiansen
85e7000666 doc: update release checklist based on experience with 4.7.0 (#3833)
@semorrison, does this include all the answers to the questions I asked
in our thread? I think so!

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-04-17 04:33:45 +00:00
Kyle Miller
75e68e7565 doc: fix docstring for Lean.Meta.mkEqOfHEq (#3921) 2024-04-16 16:33:12 +00:00
Marc Huisinga
c51e4f57bd fix: do not send as many semantic token refresh requests (#3925)
Fixes #3879.

Making semantic token requests fast is still in progress.
2024-04-16 16:32:57 +00:00
Sebastian Ullrich
ac4b5089a3 chore: bring back tactic cache while incrementality is in-development (#3924) 2024-04-16 15:42:30 +00:00
Joachim Breitner
784972462a feat: omega: more helpful error messages (#3847)
while trying to help a user who was facing an unhelpful
```
omega did not find a contradiction:
[0, 0, 0, 0, 1, -1] ∈ [1, ∞)
[0, 0, 0, 0, 0, 1] ∈ [0, ∞)
[0, 0, 0, 0, 1] ∈ [0, ∞)
[1, -1] ∈ [1, ∞)
[0, 0, 0, 1] ∈ [0, ∞)
[0, 1] ∈ [0, ∞)
[1] ∈ [0, ∞)
[0, 0, 0, 1, 1] ∈ [-1, ∞)
```
I couldn’t resist and wrote a pretty-printer for these problem that
shows the linear combination as such, and includes the recognized atoms.
This is especially useful since oftem `omega` failures stem from failure
to recognize atoms as equal. In this case, we now get:

```
omega-failure.lean:19:2-19:7: error: omega could not prove the goal:
a possible counterexample may satisfy the constraints
  d - e ≥ 1
  e ≥ 0
  d ≥ 0
  a - b ≥ 1
  c ≥ 0
  b ≥ 0
  a ≥ 0
  c + d ≥ -1
where
 a := ↑(sizeOf xs)
 b := ↑(sizeOf x)
 c := ↑(sizeOf x.fst)
 d := ↑(sizeOf x.snd)
 e := ↑(sizeOf xs)
```
and this might help the user make progress (e.g. by using `case x`
first, and investingating why `sizeOf xs` shows up twice)
2024-04-16 15:11:51 +00:00
Sebastian Ullrich
535427ada4 feat: basic incrementality API (#3849)
The fundamentals of #3636
2024-04-16 12:26:28 +00:00
Joachim Breitner
c0fbcc76c4 feat: FunInd: reserve name .mutual_induct (#3898) 2024-04-16 11:59:40 +00:00
Joachim Breitner
ea910794fa doc: crosslink {realize,resolve}GlobalName[NoOverload]?[WithInfo]?, (#3897)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-16 11:59:22 +00:00
Kim Morrison
a8df7d9d5c fix: find nightly-with-mathlib SHA (#3923) 2024-04-16 11:18:51 +00:00
Joachim Breitner
23aacdeac0 doc: instantiateMVars (#3862)
(unclear if the example is worth the hover space here)
2024-04-15 14:02:40 +00:00
Kim Morrison
62bb0f662b doc: add docstring to add_decl_doc (#3863)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-15 12:51:38 +00:00
Joachim Breitner
822890ad27 doc: docstrings for Alternative (#3860)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-15 12:40:40 +00:00
Joachim Breitner
3b0c101792 doc: docstrings for List.head/tail/getLast variants (#3864)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-15 12:40:38 +00:00
Sebastian Ullrich
2dcd42f395 feat: trace.profiler export to Firefox Profiler (#3801)
Reusing the best profiling UI out there

Usage:
```
lean -Dtrace.profiler=true -Dtrace.profiler.output=profile.json foo.lean ...
```
then open `profile.json` in https://profiler.firefox.com/.

See also `script/collideProfiles.lean` for minimizing and merging
profiles.
2024-04-15 12:13:14 +00:00
Sebastian Ullrich
6712913bfe chore: update cross-bench setup 2024-04-15 10:59:07 +02:00
Kyle Miller
1c20b53419 feat: shorten auto-generated instance names (#3089)
Implements a new method to generate instance names for anonymous
instances that uses a heuristic that tends to produce shorter names. A
design goal is to make them relatively unique within projects and
definitely unique across projects, while also using accessible names so
that they can be referred to as needed, both in Lean code and in
discussions.

The new method also takes into account binders provided to the instance,
and it adds project-based suffixes. Despite this, a median new name is
73% its original auto-generated length. (Compare: [old generated
names](https://gist.github.com/kmill/b72bb43f5b01dafef41eb1d2e57a8237)
and [new generated
names](https://gist.github.com/kmill/393acc82e7a8d67fc7387829f4ed547e).)

Some notes:
* The naming is sensitive to what is explicitly provided as a binder vs
what is provided via a `variable`. It does not make use of `variable`s
since, when names are generated, it is not yet known which variables are
used in the body of the instance.
* If the instance name refers to declarations in the current "project"
(given by the root module), then it does not add a suffix. Otherwise, it
adds the project name as a suffix to protect against cross-project
collisions.
* `set_option trace.Elab.instance.mkInstanceName true` can be used to
see what name the auto-generator would give, even if the instance
already has an explicit name.

There were a number of instances that were referred to explicitly in
meta code, and these have been given explicit names.

Removes the unused `Lean.Elab.mkFreshInstanceName` along with the
Command state's `nextInstIdx`.

Fixes #2343
2024-04-13 18:08:50 +00:00
Kyle Miller
40df539ef1 doc: update RELEASES for rcases using the custom Nat eliminator (#3902)
Note for #3747.
2024-04-13 17:56:06 +00:00
Kyle Miller
c4bfe25d18 feat: make rcases use the custom Nat eliminator (#3747)
As a special case, makes the `rcases` machinery use `Nat.casesAuxOn` so
that goal states see `0` and `n + 1` rather than `Nat.zero` and
`Nat.succ n`. This is a followup to enabling custom eliminators for
`cases` and `induction`.

This doesn't use custom eliminators in general since `rcases` uses
`Lean.MVarId.cases`, which is completely different from what `cases` and
`induction` use.
2024-04-13 16:55:48 +00:00
Kyle Miller
3d24c68347 doc: rephrase a couple RELEASES entries (#3900) 2024-04-13 16:54:57 +00:00
Lean stage0 autoupdater
b0a305f19f chore: update stage0 2024-04-13 09:49:19 +00:00
Kyle Miller
eef928b98d feat: whitespace and message ordering configurations for #guard_msgs (#3883)
Adds options to control whitespace normalization and message ordering in
`#guard_msgs`.

Examples:
1. `#guard_msgs (whitespace := lax)` ignores differences in whitespace
completely.
2. `#guard_msgs (whitespace := exact)` requires an exact match for
whitespace (after trimming).
3. `#guard_msgs (ordering := sorted)` sorts the list of messages, to
make it insensitive to message order.
2024-04-13 08:53:43 +00:00
Joachim Breitner
9eeecb6d32 doc: docstrings for List.mapM and friends (#3867)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-04-13 07:57:55 +00:00
Kim Morrison
62747bd293 doc: add docstring for Nat.gcd (#3857) 2024-04-13 07:56:15 +00:00
Kim Morrison
32b9bc47b7 chore: add doc-string for Prod.mk (#3856) 2024-04-13 07:55:20 +00:00
David Thrane Christiansen
864221d433 chore: rename fields of Subarray to follow Lean conventions (#3851)
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2024-04-13 07:52:45 +00:00
Joachim Breitner
2e1ef2211c doc: docstrings for some Fin definitions (#3858)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-13 07:52:32 +00:00
Mario Carneiro
fb82428f2d feat: hover / go-to-def for attribute cmd (#3896)
`attribute [attr] foo` was missing a hover on `foo`.
2024-04-13 07:13:25 +00:00
Kyle Miller
c24b419ee4 doc: fix simp configuration option default value for decide (#3894) 2024-04-12 22:02:08 +00:00
Mario Carneiro
ddbdfb954b chore: use Ordering.then in deriving Ord (#3893)
This should improve the performance of the deriving a bit since it
doesn't have to generate so many matchers. The main motivation though is
to make it easier to prove properties about the expression by using more
standard functions. The generated implementation should end up the same,
since `Ordering.then` is `@[macro_inline]`.
2024-04-12 21:09:27 +00:00
Kyle Miller
e59fad2955 doc: describe all simp configuration options (#3870)
Co-authored by Marc Huisinga, with input from Leo.
2024-04-12 16:38:43 +00:00
Henrik Böving
ecba8529cc doc: Leo-Henrik retreat doc (#3869)
Part of the retreat Hackathon.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-12 09:14:31 +00:00
Henrik Böving
723c340a8b perf: fix linearity in (HashSet|HashMap).erase (#3887)
Fixes linearity issues in HashSet/HashMap erase functions.

IR before patch:
```
def Lean.HashMapImp.erase._rarg (x_1 : obj) (x_2 : obj) (x_3 : obj) (x_4 : obj) : obj :=
  let x_5 : obj := proj[0] x_3;
  inc x_5;
  let x_6 : obj := proj[1] x_3;
  inc x_6;
  let x_7 : obj := Array.size  x_6;
  inc x_4;
  let x_8 : obj := app x_2 x_4;
  let x_9 : u64 := unbox x_8;
  dec x_8;
  let x_10 : usize := _private.Lean.Data.HashMap.0.Lean.HashMapImp.mkIdx x_7 x_9 ;
  let x_11 : obj := Array.uget  x_6 x_10 ;
  inc x_11;
  inc x_4;
  inc x_1;
  let x_12 : u8 := Lean.AssocList.contains._rarg x_1 x_4 x_11;
  case x_12 : u8 of
  Bool.false →
    dec x_11;
    dec x_6;
    dec x_5;
    dec x_4;
    dec x_1;
    ret x_3
  Bool.true →
    let x_13 : u8 := isShared x_3;
    case x_13 : u8 of
    Bool.false →
      let x_14 : obj := proj[1] x_3;
      dec x_14;
      let x_15 : obj := proj[0] x_3;
      dec x_15;
      let x_16 : obj := 1;
      let x_17 : obj := Nat.sub x_5 x_16;
      dec x_5;
      let x_18 : obj := Lean.AssocList.erase._rarg x_1 x_4 x_11;
      let x_19 : obj := Array.uset  x_6 x_10 x_18 ;
      set x_3[1] := x_19;
      set x_3[0] := x_17;
      ret x_3
    Bool.true →
      dec x_3;
      let x_20 : obj := 1;
      let x_21 : obj := Nat.sub x_5 x_20;
      dec x_5;
      let x_22 : obj := Lean.AssocList.erase._rarg x_1 x_4 x_11;
      let x_23 : obj := Array.uset  x_6 x_10 x_22 ;
      let x_24 : obj := ctor_0[Lean.HashMapImp.mk] x_21 x_23;
      ret x_24
```

IR after the patch:
```
def Lean.HashMapImp.erase._rarg (x_1 : obj) (x_2 : obj) (x_3 : obj) (x_4 : obj) : obj :=
  let x_5 : u8 := isShared x_3;
  case x_5 : u8 of
  Bool.false →
    let x_6 : obj := proj[0] x_3;
    let x_7 : obj := proj[1] x_3;
    let x_8 : obj := Array.size  x_7;
    inc x_4;
    let x_9 : obj := app x_2 x_4;
    let x_10 : u64 := unbox x_9;
    dec x_9;
    let x_11 : usize := _private.Lean.Data.HashMap.0.Lean.HashMapImp.mkIdx x_8 x_10 ;
    let x_12 : obj := Array.uget  x_7 x_11 ;
    inc x_12;
    inc x_4;
    inc x_1;
    let x_13 : u8 := Lean.AssocList.contains._rarg x_1 x_4 x_12;
    case x_13 : u8 of
    Bool.false →
      dec x_12;
      dec x_4;
      dec x_1;
      ret x_3
    Bool.true →
      let x_14 : obj := 1;
      let x_15 : obj := Nat.sub x_6 x_14;
      dec x_6;
      let x_16 : obj := Lean.AssocList.erase._rarg x_1 x_4 x_12;
      let x_17 : obj := Array.uset  x_7 x_11 x_16 ;
      set x_3[1] := x_17;
      set x_3[0] := x_15;
      ret x_3
  Bool.true →
    let x_18 : obj := proj[0] x_3;
    let x_19 : obj := proj[1] x_3;
    inc x_19;
    inc x_18;
    dec x_3;
    let x_20 : obj := Array.size  x_19;
    inc x_4;
    let x_21 : obj := app x_2 x_4;
    let x_22 : u64 := unbox x_21;
    dec x_21;
    let x_23 : usize := _private.Lean.Data.HashMap.0.Lean.HashMapImp.mkIdx x_20 x_22 ;
    let x_24 : obj := Array.uget  x_19 x_23 ;
    inc x_24;
    inc x_4;
    inc x_1;
    let x_25 : u8 := Lean.AssocList.contains._rarg x_1 x_4 x_24;
    case x_25 : u8 of
    Bool.false →
      dec x_24;
      dec x_4;
      dec x_1;
      let x_26 : obj := ctor_0[Lean.HashMapImp.mk] x_18 x_19;
      ret x_26
    Bool.true →
      let x_27 : obj := 1;
      let x_28 : obj := Nat.sub x_18 x_27;
      dec x_18;
      let x_29 : obj := Lean.AssocList.erase._rarg x_1 x_4 x_24;
      let x_30 : obj := Array.uset  x_19 x_23 x_29 ;
      let x_31 : obj := ctor_0[Lean.HashMapImp.mk] x_28 x_30;
      ret x_31
```

Previously `x_6` (the buckets array) always gets `inc`remented, now only
if the HashMap itself is shared.
2024-04-12 08:54:21 +00:00
Joe Hendrix
2e3d523332 chore: protect Std.BitVec (#3884)
This makes `Std.BitVec` a protected abbreviation so `open Std` doesn't
result in ambiguity errors.
2024-04-12 05:09:46 +00:00
Scott Morrison
cd02ad76f1 doc: doc-string for Ord and Ord.compare (#3861)
Hopefully one day we will be able to do a thorough refactor of the
computable order types in Lean... In the meantime, some doc-strings.
2024-04-11 16:02:33 +00:00
Joe Hendrix
2ba0a4549b feat: add BitVec Int add & mul lemmas (#3880)
This adds some basic lemmas to support commuting ofInt/toInt and
add/mul.

It also removes the simp annotation on `ofNat_add_ofNat` as in some
contexts the other direction or conversion to Int may be desired.
2024-04-11 15:26:45 +00:00
Henrik Böving
3ed2d9b3ad perf: fix linearity issue in insertIfNew (#3881)
This fixes a linearity isssue in `insertIfNew`. As `insertIfNew` is used
in `Lean.finalizeImport` we expect this to improve performance.
2024-04-11 15:12:10 +00:00
Scott Morrison
36f1398aaa doc: some doc-strings for Option (#3868) 2024-04-11 14:27:07 +00:00
Sebastian Ullrich
37938ecde1 doc: moduleDoc (#3874) 2024-04-11 14:21:03 +00:00
Scott Morrison
68e3982eed chore: update CODEOWNERS (#3878)
This adds @digama0 to the CODEOWNERS files for the tactics files which
have recently been upstreamed from Std.
2024-04-11 04:21:42 +00:00
Joachim Breitner
36db040722 refactor: Canonicalizer: run getFunInfo on expression, not key (#3875)
The Canonicalizer creates a “key” expression eliding certain information
(implicit parameters, levels), and `getFunInfo` can be
confused by these terms (in particular, wrong number of level
parameters).

By running `getFunInfo` on the original expression we avoid this, and
can just put `[]` as the level list in the key.
2024-04-10 20:41:15 +00:00
Joachim Breitner
280525f1fc fix: omega: ignore levels in canonicalizer (#3853)
fixes #3848
2024-04-10 08:46:07 +00:00
Joachim Breitner
892bfe2c5f fix: remove unused trace.Elab.syntax option (#3844) 2024-04-08 17:16:24 +00:00
Joe Hendrix
a82f0d9413 fix: offset typeclass checking in simp rules (#3838)
This changes how Nat typeclass checks in offset terms from syntactic
equality to definitional equality with "instances" transparency.

This may have a negative performance penalty in `isOffset?`, but it
should be small in common cases since the relevant instances are small
terms.

This closes #3836
2024-04-07 13:43:59 +00:00
thorimur
182270f8bf fix: typo in withSetOptionIn (#3806)
When using `withSetOptionIn` on syntax `set_option ... in <command>`,
recurse into command syntax (`stx[2]`) instead of the syntax `in`
(`stx[1]`).

---

Demonstration of `stx[1]` vs. `stx[2]`:
```lean
import Lean

def stx := (Lean.Unhygienic.run `(set_option trace.debug true in #print foo)).raw

#eval stx[1] -- Lean.Syntax.atom (Lean.SourceInfo.none) "in"
#eval stx[2] -- `#print` command syntax
```
2024-04-06 18:00:34 +00:00
Scott Morrison
0aa68312b6 chore: when setting up Mathlib CI, make sure nightly-with-mathlib branch has been fetched (#3834)
As reported on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/PR.20release.20failure/near/431281042).
2024-04-05 00:40:50 +00:00
Joe Hendrix
f31c395973 fix: replace unary Nat.succ simp rules with simprocs (#3808)
This removes simp attributes from `Nat.succ.injEq` and
`Nat.succ_sub_succ_eq_sub` to replace them with simprocs. This is
because any reductions involving `Nat.succ` has a high risk of leading
proof performance problems when dealing with even moderately large
numbers.

Here are a couple examples that will both report a maximum recursion
depth error currently. These examples are fixed by this PR.

```
example : (123456: Nat) = 12345667 := by
  simp

example (x : Nat) (p : x = 0) : 1000 - (x + 1000) = 0 := by
  simp
```
2024-04-04 23:15:26 +00:00
Sebastian Ullrich
485baa1b8c chore: update-stage0-commit cmake target (#3692)
Automate creating the commit
2024-04-04 13:35:53 +00:00
Mario Carneiro
e41cd310e9 fix: String.splitOn bug (#3832)
Fixes #3829. As reported on Zulip (both
[recently](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/current.20definition.20of.20.60String.2EsplitOn.60.20is.20incorrect/near/430930535)
and [a year
ago](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/should.20we.20redefine.20.60String.2EsplitOnAux.60.3F/near/365899332)),
`String.splitOn` has a bug when dealing with separators of more than one
character (which are luckily rare). The code change here is very small,
replacing a `i` with `i - j`, but it makes termination more complex so
that's where the rest of the line count goes.
2024-04-04 09:30:53 +00:00
Sebastian Ullrich
d988849ce3 doc: profiler 2024-04-03 17:53:36 +02:00
Scott Morrison
f3121b0427 fix: omega works as a simp discharger (#3828)
Possibly the more principled fix is to not have `simp` invoke
dischargers under `withReducible`.

In the meantime, this ensures that `falseOrByContra` still succeeds with
`intro1` on a `Not` goal, which previously was breaking `omega` as a
simp discharger.

Closes #3805.
2024-04-03 03:00:00 +00:00
Marc Huisinga
ecf0459122 fix: don't use info nodes before cursor for completion (#3778)
This fixes an issue where the completion would use info nodes before the
cursor for computing completions.

Fixes https://github.com/leanprover/lean4/issues/3462.

ToDo:
- [x] Fix test failures for completions that previously worked by
accident (cc: @Kha)
- [x] stage0 update

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-04-02 08:49:24 +00:00
Joe Hendrix
eacb1790b3 feat: weight lazy discriminator tree results early matches (#3818)
The matches returned by the lazy discriminator tree are partially
constrained by a priority, but ties are broken by the order in which
keys are traversed and the order of declarations.

This PR changes the match key traversal to use an explicit stack rather
than recursion and implicitly changes the order in which results are
returned to favor left-matches first e.g., given the term `f a b` with
constants `f a b`, and a tree with patterns `f a x -> 1` `f x b -> 2`
that have the same priority, this will return `#[1, 2]` since the early
matches for the key `a` are returned before the match for `x` which has
a star.

This appears to address the [lower quality results mentioned on
zulip](https://leanprover.zulipchat.com/#narrow/stream/428973-nightly-testing/topic/Mathlib.20status.20updates/near/429955747).
2024-04-02 07:19:30 +00:00
Leonardo de Moura
c0027d3987 fix: simp only should break Char literals (#3824)
closes #3686
2024-04-02 03:11:40 +00:00
Leonardo de Moura
82ae779218 fix: missing test at addDocString (#3823)
closes #3497
2024-04-02 02:29:14 +00:00
Leonardo de Moura
2dab6939e4 fix: missing withTacticInfoContext (#3822)
closes #3720
2024-04-02 02:15:38 +00:00
Leonardo de Moura
f35fc18c88 fix: simp usedSimps (#3821)
When `discharge?` failed, the `usedSimps` was being restored, but the
cache wasn't. This bug was exposed by issue #3710.

This PR makes the following changes:
- We restore the `cache` at `discharge?`. We use `SMap` to ensure the
operation is efficient.
- We don't need the field `dischargeDepth` anymore at `Simp.Result`.
- `UsedSimps` should use `PHashMap` since it is not used linearly.

closes #3710

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-04-02 00:50:06 +00:00
Leonardo de Moura
0684c95d35 fix: do not lift (<- ...) over pure if-then-else (#3820)
Now, only `(<- ...)`s occurring in the condition of a pure if-then-else
are lifted.
That is, `if (<- foo) then ... else ...` is ok, but `if ... then (<-
foo) else ...` is not. See #3713

closes #3713 

This PR also adjusts this repo. Note that some of the `(<- ...)` were
harmless since they were just accessing some
read-only state.
2024-04-01 21:33:59 +00:00
Leonardo de Moura
a440e63435 fix: loose bound variables at ACLt (#3819)
Closes #3705 

This PR also fixes a performance issue at `ACLt` also exposed by example
at #3705
2024-04-01 20:26:20 +00:00
Leonardo de Moura
4a317ae3f8 fix: .yesWithDeltaI behavior (#3816)
It should not increase the transparency level from `reducible` to
`instances`. See new test.
2024-04-01 02:36:35 +00:00
Leonardo de Moura
0ba21269e8 fix: matcher splitter is code (#3815)
It have to keep it as a private definition for now. We currently only
support duplicate theorems in different modules. Splitters are generated
on demand, and are also used to write code.
2024-04-01 02:14:14 +00:00
Marc Huisinga
e1cadcbfca chore: bump language server version (#3813)
This will allow us to add backwards compatibility in vscode-lean4 for
some recent changes more easily.
2024-03-31 12:47:45 +00:00
Leonardo de Moura
d8d64f1fc0 perf: isDefEq performance issue (#3807)
Fixes a performance problem found by @hargoniX while working on LeanSAT.
2024-03-30 02:15:48 +00:00
Mac Malone
fdd9d6f306 feat: lake lean (#3793)
Adds a `lake lean` CLI command that builds the imports of a Lean file
and then elaborates it via `lean` with the workspace's configuration
(i.e., adding the `moreLeanArgs` / `leanOptions` of the root `package`
and Lake's environment).
2024-03-29 22:54:31 +00:00
Kyle Miller
9cb114eb83 feat: add pp.mvars and pp.mvars.withType (#3798)
* Setting `pp.mvars` to false causes metavariables to pretty print as
`?_`.
* Setting `pp.mvars.withType` to true causes metavariables to pretty
print with type ascriptions.

Motivation: when making tests, it is inconvenient using `#guard_msgs`
when there are metavariables, since the unique numbering is subject to
change.

This feature does not use `⋯` omissions since a metavariable is already
in a sense an omitted term. If repeated metavariables do not appear in
an expression, there is a chance that a term pretty printed with
`pp.mvars` set to false can still elaborate to the correct term, unlike
for other omissions.

(In the future we could consider an option that pretty prints uniquely
numbered metavariables as `?m✝`, `?m✝¹`, `?m✝²`, etc. to be able to tell
them apart, at least in the same pretty printed expression. It would
take care to make sure that these names are stable across different
hovers.)

Closes #3781
2024-03-29 18:03:05 +00:00
Joachim Breitner
b181fd83ef feat: in conv tactic, use try with_reducibe rfl (#3763)
The `conv` tactic tries to close “trivial” goals after itself. As of
now, it uses
`try rfl`, which means it can close goals that are only trivial after
reducing with
default transparency. This is suboptimal

* this can require a fair amount of unfolding, and possibly slow down
the proof
   a lot. And the user cannot even prevent it.
* it does not match what `rw` does, and a user might expect the two to
behave the
   same.

So this PR changes it to `with_reducible rfl`, matching `rw`’s behavior.

I considered `with_reducible eq_refl` to only solve trivial goals that
involve equality,
but not other relations (e.g. `Perm xs xs`), but a discussion on mathlib
pointed out
that it’s expected and desirable to solve more general reflexive goals:


https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Closing.20after.20.60rw.60.2C.20.60conv.60.3A.20.60eq_refl.60.20instead.20of.20.60rfl.60/near/429851605
2024-03-29 11:59:45 +00:00
Joachim Breitner
97e3257ffd chore: un-qualify .induct lemmas in tests (#3804)
now that #3803 is fixed.
2024-03-29 11:34:09 +00:00
Kyle Miller
44ad3e2e34 feat: hovering over binders shows their types (#3797)
Modifies `withBindingBodyUnusedName` to annotate the syntax for the
variable with its corresponding fvar. Now, for example, you can hover
over the variables in `fun x y => ...` in the infoview to see their
types. This change affects notations such as `∃ n, n = 1`, where
hovering over `n` shows that `n : Nat`.

Also adds such annotations for the variables in `let` and `let_fun`.

Implementation note: the variables are annotated with fresh positions
using `nextExtraPos`.

Removes the unused and unnecessary
`Lean.PrettyPrinter.Delaborator.liftMetaM`.

Closes #1618, closes #2737
2024-03-29 03:52:00 +00:00
Mac Malone
ca1cbaa6e9 feat: lake test (#3779)
Adds a `lake test` CLI command that runs a `script` or `lean_exe` tagged
`@[test_runner]` in the workspace's root package.
2024-03-29 03:19:46 +00:00
Leonardo de Moura
7a93a7b877 fix: reserved name resolution (#3803)
This PR includes the following fixes:

- Reserved name resolution inside namespaces
- Equation theorems for `match`er declarations are not private anymore
- Equation theorems for `match`er declarations are realizable
- `foo.match_<idx>.splitter` is now a reserved name
2024-03-29 02:56:48 +00:00
Mac Malone
e54a0d7b89 fix: lake: check normalized packages directory path before rename (#3795)
Normalize the relative packages directory paths in the pre-rename check
to avoid renames if the difference in paths is only in the path
separators. Also adds a log message on rename.
2024-03-29 01:15:59 +00:00
Kyle Miller
b15b971416 fix: require idents come in a column after the start of a command (#3799)
Commands that can optionally parse an `ident` or parse any number of
`ident`s generally should require that the `ident` use `colGt`. This
keeps typos in commands from being interpreted as identifiers.

For example, without this rule,
```
universe u
Open Lean
````
parses the same as `universe u Open Lean`. It would be better to get an
error on `Open`.

This PR adds `checkColGt` to `section`, `namespace`, `end`, `variable`,
and `universe`.

Closes #2684
2024-03-29 01:14:20 +00:00
Leonardo de Moura
9bdb37a9b0 chore: update stage0
Reason: new builtin environment extension
2024-03-28 17:58:33 -07:00
Leonardo de Moura
dee074dcde fix: simp regression introduced by equation theorems for non-recursive definitions 2024-03-28 17:58:33 -07:00
Leonardo de Moura
fe783cb778 feat: save whether a function has been defined by structural or well-founded recursion 2024-03-28 17:58:33 -07:00
Leonardo de Moura
d1c0149e17 chore: fix simproc doc-string (#3800) 2024-03-28 17:54:52 +00:00
James Sully
8af34df2d2 doc: typo in rcases docs (#3796)
"alteration pattern" -> "alternation pattern"
2024-03-28 07:31:01 +00:00
Mac Malone
55b7b07c54 feat: lake: alternative TOML config (#3298)
Adds an alternative TOML configuration format to Lake. 

* Uses TOML v1.0.0 and is fully specification compliant (tested via
[toml-test v1.4.0](https://github.com/toml-lang/toml-test/tree/v1.4.0)).
* Supports package configuration options, Lean libraries, Lean
executables, and dependencies.
* TOML configurations can be generated for new projects via `lake
new|init <pkg> <template>.toml`.
* Supported configurations can be converted to/from TOML via `lake
translate-config <lang>`.
2024-03-28 02:35:02 +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
Joe Hendrix
7989f62f70 fix: remove unused try catch (#3794)
This fixes some placeholder code inadvertently contributed.
2024-03-28 01:39:51 +00:00
Kyle Miller
4bacd70b3f feat: add option tactic.customEliminators to be able to turn off custom eliminators for induction and cases (#3655)
This was suggested by Scott Morrison to be able to help projects adjust
to `Nat` having built-in custom eliminators.
2024-03-28 01:14:17 +00:00
Mario Carneiro
775dabd4ce fix: toUInt64LE! and toUInt64BE! are swapped (#3660)
fixes #3657

These functions are mostly not used by lean itself, but it does affect
two occurrences of `ByteArray.toUInt64LE! <$> IO.getRandomBytes 8` which
I left as is instead of switching them to use `toUInt64BE!` to preserve
behavior; but they are random bytes anyway seeded by the OS so it's
unlikely any use of them depending on particular values was sound to
begin with.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-28 01:13:42 +00:00
Kyle Miller
5167324cb8 doc: edit Lean.MVarId.withReverted (#3743)
When it was upstreamed, it lost the mention of "revert/intro pattern",
which is helpful for finding this function. Also extended the
description of the function and clarified some points.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-28 01:12:23 +00:00
Kyle Miller
520cd3f0d6 fix: make generalized field notation for abbreviation types handle optional parameters (#3746)
Closes #3745
2024-03-28 00:59:09 +00:00
Scott Morrison
5b7ec4434e chore: fix rebase suggestion for Mathlib CI (#3701)
Previously we were suggesting rebasing onto the most recently nightly in
the branches history, but that is incorrect and we should *always*
suggest rebasing on `origin/nightly-with-mathlib`.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-03-27 23:46:06 +00:00
Kyle Miller
70924be89c feat: hovering over omission term shows reason for omission (#3751)
This avoids printing the entire docstring for `⋯` when hovering over it,
which is rather long, and instead it gives a brief reason for omission
and what option to set to pretty print the omitted term.
2024-03-27 15:10:20 +00:00
Scott Morrison
02c5700c63 feat: change apply_rfl tactic so that it does not operate on = (#3784)
Previously:

If the `rfl` macro was going to fail, it would:
1. expand to `eq_refl`, which is implemented by
`Lean.Elab.Tactic.evalRefl`, and call `Lean.MVarId.refl` which would:
* either try kernel defeq (if in `.default` or `.all` transparency mode)
  * otherwise try `IsDefEq`
  * then fail.
2. Next expand to the `apply_rfl` tactic, which is implemented by
`Lean.Elab.Tactic.Rfl.evalApplyRfl`, and call `Lean.MVarId.applyRefl`
which would look for lemmas labelled `@[refl]`, and unfortunately in
Mathlib find `Eq.refl`, so try applying that (resulting in another
`IsDefEq`)
3. Because of an accidental duplication, if `Lean.Elab.Tactic.Rfl` was
imported, it would *again* expand to `apply_rfl`.

Now:
1. Same behaviour in `eq_refl`.
2. The `@[refl]` attribute will reject `Eq.refl`, and `MVarId.applyRefl`
will fail when applied to equality goals.
3. The duplication has been removed.
2024-03-27 12:04:22 +00:00
Sebastian Ullrich
3ee1cdf3de chore: CI: continue on test-summary failure 2024-03-27 14:03:10 +01:00
Scott Morrison
94d6286e5a chore: reorganising to reduce imports (#3790)
[Before](https://github.com/leanprover/lean4/files/14772220/oi.pdf) and
[after](https://github.com/leanprover/lean4/files/14772226/oi2.pdf).

This gets `ByteArray`, `String.Extra`, `ToString.Macro` and `RCases` out
of the imports of `omega`. I'd hoped to get `Array.Subarray` too, but
it's tangled up in the list literal syntax. Further progress could come
from make `split` use available `Decidable` instances, so we could pull
out `Classical` (and possibly some of `PropLemmas`).
2024-03-27 11:15:01 +00:00
Sebastian Ullrich
16fdca1cbd chore: test results as job summary (#3715)
Tired of scrolling through and parsing the test output myself
2024-03-27 10:14:33 +00:00
Joachim Breitner
c857d08be6 fix: remove derive_functional_induction (#3788)
this follows up on #3776 and the subsequent stage0 update, now relying
on the reserved name for the induction principles.
2024-03-27 10:08:13 +00:00
Scott Morrison
1a5d064d08 chore: upstream tail-recursive implementations of List operations, and @[csimp] lemmas (#3785) 2024-03-27 08:36:48 +00:00
Henrik Böving
2405fd605e feat: trace non-easy whnf invocations (#3774) 2024-03-27 08:35:22 +00:00
Lean stage0 autoupdater
63290babde chore: update stage0 2024-03-27 07:34:13 +00:00
Scott Morrison
b4caee80a3 chore: rw? uses MVarId.refl not MVarId.applyRfl (#3783)
I think this was in error in my original Mathlib implementation. We're
not interested in relations other than `=`, so there is no point uses
`MVarId.applyRfl`, which just looks up `@[refl]` tagged lemmas and tries
those.

In a separate PR, I will change `MVarId.applyRfl` so it has a flag to
control whether on `=` it should just hand-off to `MVarId.refl`, or
fail. Failure is appropriate in the version we call from the `rfl`
macro, to avoid doing a double `IsDefEq` check on every `rfl`!
2024-03-27 03:02:30 +00:00
Joe Hendrix
b17c47d852 fix: lemma selection improvements to to rw? and lazy discriminator tree (#3769)
This makes several changes to rw? and lazy discrimination trees based on
test failures in rewrite search.

Changes include:
1. Reverting to Mathlib function for candidate lemma priority in rw?
2. Introducing additional filters for auto-generated named in lazy
discriminator tree.
3. Refactoring lazy discriminator values to clarify what is stored.
4. Including star keys in calculation of match closeness in
prioritization.
5. Using more fields in current core context when initializing lazy
discriminator tree and avoiding max heartbeat issues.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-26 23:57:08 +00:00
Joachim Breitner
ab318dda2d feat: use reserved name infrastructure for functional induction (#3776)
no need to enter `derive_functional_induction` anymore.

(Will remove the support for `derive_functional_induction` after the
next stage0 update, since we are already using it in Init.)
2024-03-26 22:25:10 +00:00
Joachim Breitner
301dd7ba16 feat: failing macros to show error from first registered rule (#3771)
fixes #3770

Also start `rfl` with a `fail` message that is hopefully more helpful
than what we get now (see updated test output). This would be a cheaper
way to address #3302 without changing the implementation of rfl (as
tried in #3714).
2024-03-26 22:24:45 +00:00
Joachim Breitner
466ef74ccc feat: functional induction for structural recursion (#3738)
This extends `derive_functional_induction` to work with structural
recursion as well.

It produces the less general, more concrete induction rule where the
induction hypothesis is
specialized for every argument of the recursive call, not just the the
one that the function
is recursing on.

Care is taken so that the induction principle and it's motive take the
arguments in the same
order as the original function.

While I was it, also makes sure that the order of the cases in the
induction principle matches
the order of recursive calls in the function better.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-03-26 13:36:24 +00:00
Eric Wieser
e8a2786d6d fix: actually catch the error code from MoveFileEx (#3753)
A user on Zulip [reported seeing an error code of "no
error"](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/.60lake.20update.60.20broken.20on.20Windows.20.28.3F.29/near/429134334)
here.
2024-03-26 09:00:25 +00:00
Julien Michel
4c0106d757 refactor: simplify Array.findIdx? code (#3648)
This shortens `Array.findIdx?` code, by using termination_by (and
well-founded recursion) instead of a structural recursion trick, with
the intent to make it more proof friendly.

One motivation is that it makes it easier to write a proof that
`Array.findIdx?` and `List.findIdx?` are equivalent. Furthermore, this
will be useful to prove that more complex functions are equivalent.

Closes #3646
2024-03-26 05:11:59 +00:00
Austin Letson
83369f3d9f fix: update System.FilePath.parent to handle edge cases for absolute paths (#3645)
System.FilePath.parent did not return the correct parent path in the
case of absolute file paths

Example of previous behavior
```
(FilePath.mk "/foo").parent -> some (FilePath.mk "")

(System.FilePath.mk "/").parent -> some (FilePath.mk "")
```

The new behavior is based on rust's std::path::Path::parent function (as
previously described in comment in System.FilePath)

Example of updated behavior
```
(System.FilePath.mk "/foo").parent -> some (FilePath.mk "/")

(System.FilePath.mk "/").parent -> none
```

Behavior for relative file paths is unchanged

Closes #3618
2024-03-26 05:09:44 +00:00
Leonardo de Moura
22b5c957e9 chore: rename automatically generated "unfold" theorems (#3767)
Given a definition `foo`, they were previously called `foo._unfold`
until 4.7.0. We tried to rename them to `foo.def`, but it created too
many issues in the Mathlib repo. We decided to rename it again to
`foo.eq_def`. The new name is also consistent with the `eq_<idx>`
theorems generated for different "cases". That is, `foo.eq_def` is the
equality theorem for the whole definition, and `foo.eq_<idx>` is the
equality theorem for case `<idx>`.

cc @semorrison
2024-03-25 21:41:26 +00:00
Leonardo de Moura
a0dac9f546 feat: ignore explicit proofs in canonicalizer (#3766) 2024-03-25 20:52:42 +00:00
Eric Wieser
d8047ddeb1 fix: change Quotient.sound to a theorem (#3765)
The result is a proof, so presumably this should not be a `def`.
2024-03-25 19:28:31 +00:00
Joachim Breitner
e0c6c5d226 fix: functional induction: preseve order of cases better (#3762)
by passing an explicit array of metavariable around, instead of relying
on `getMVarsNoDelayed`, which may return them in unexpected order.
2024-03-25 11:59:29 +00:00
Jon Eugster
3dd811f9ad chore: remove FileMap.lines and add FileMap.getLine (#3237)
`FileMap.lines` is an array that seems to be manually managed to have
the form `#[1, 2, ..., n-1, n-1]` with same length as
`FileMap.positions`. Remove this structure field in favour of
calculating the line number as `min(x+1, positions.size-1)` when needed.

Follow-up on #3221
2024-03-25 10:33:04 +00:00
Scott Morrison
1d245bcb82 chore: revert ToJson/FromJson Sum (#3759) (#3760)
Sorry, this was ill-considered, it doesn't round trip faithfully.
2024-03-25 09:09:44 +00:00
Scott Morrison
a943a79bd3 chore: ToJson/FromJson Sum (#3759) 2024-03-25 07:43:40 +00:00
Joachim Breitner
80d2455b64 fix: prune universe params in functional induction (#3754)
fixes #3752
2024-03-24 10:15:50 +00:00
Kyle Miller
655ec964f5 feat: flatten parent projections when pretty printing structure instance notation (#3749)
Given
```lean
structure A where
  x : Nat

structure B extends A where
  y : Nat
```
rather than pretty printing `{ x := 1, y := 2 : B }` as `{ toA := { x :=
1 }, y := 2 }`, it now pretty prints as `{ x := 1, y := 2 }`.

The option `pp.structureInstances.flatten` controls whether to flatten
structure instances like this.
2024-03-23 09:20:52 +00:00
Kyle Miller
925a6befd4 fix: do not pretty print theorems with generalized field notation (#3750)
For example, pretty print as `Nat.add_comm m n` rather than as
`m.add_comm n`.
2024-03-23 09:20:48 +00:00
Hongyu Ouyang
2ed777b2b4 doc: fix typo in docstring of left (#3748) 2024-03-23 07:39:36 +00:00
Joe Hendrix
6c8976abbe feat: upstream rw? tactic (#3719)
This updates the rw? tactic from Mathlib to use lazy discriminator trees
and upstreams it.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-23 05:01:35 +00:00
Kyle Miller
d39b0415f0 feat: enable pp.fieldNotation.generalized globally (#3744)
Sets the default value to `pp.fieldNotation.generalized` to `true`.
Updates tests, and fixes some minor flaws in the implementation of the
generalized field notation pretty printer.

Now generalized field notation won't be used for any function that has a
`motive` argument. This is intended to prevent recursors from pretty
printing using it as (1) recursors are more like control flow structures
than actual functions and (2) generalized field notation tends to cause
elaboration problems for recursors.

Note: be sure functions that have an `@[app_unexpander]` use
`@[pp_nodot]` if applicable. For example, `List.toArray` needs
`@[pp_nodot]` to ensure the unexpander prints it using `#[...]`
notation.
2024-03-23 02:38:09 +00:00
Kyle Miller
8ce98e62ac fix: typos in release notes (#3742) 2024-03-22 18:25:44 +00:00
Lean stage0 autoupdater
027b2bc38d chore: update stage0 2024-03-22 18:09:36 +00:00
Marc Huisinga
3f8f2b09af chore: more generic import out of date diagnostic (#3739)
The concrete dependency that is stale isn't really actionable
information for users (ideally we'd like something like "amount of
dependencies that will be rebuilt when you restart file"). This also
makes the diagnostic an "information" diagnostic so that non-infoview
users can still see it.

Since we are moving away from using notifications for stale dependency
information, we don't need to provide an ID anymore, either.
2024-03-22 13:13:20 +00:00
Kyle Miller
1f4dea8582 feat: add pp.fieldNotation.generalized for generalized field notation, add @[pp_nodot] attribute (#3737)
Refactors app delaborator, merging in the projection delaborator, to
support pretty printing with generalized field notation.

Renames option `pp.structureProjections` to `pp.fieldNotation` and adds
sub-option `pp.fieldNotation.generalized` to enable/disable generalized
field notation. Adds `@[pp_nodot]` attribute to permanently disable
using field notation for a given declaration.

For now, the default value of `pp.fieldNotation.generalized` is false
since we need a stage0 update to add `@[pp_nodot]` to some core
definitions (such as `List.toArray`) before updating the tests.

[Zulip
discussion](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60pp.2EgeneralizedFieldNotation.60/near/425856054)
2024-03-22 08:55:02 +00:00
Scott Morrison
d5a1dce0ae chore: omega notices that 0 ≤ (x : Int) % (y : Int) (#3736) 2024-03-22 02:49:24 +00:00
Kyle Miller
acb188f11c feat: apply pp_using_anonymous_constructor attribute (#3735)
This attribute, which was implemented in #3640, is applied to the
following structures: `Sigma`, `PSigma`, `PProd`, `And`, `Subtype`, and
`Fin`. These were given this attribute in Lean 3.
2024-03-22 00:30:36 +00:00
Lean stage0 autoupdater
d884a946c8 chore: update stage0 2024-03-22 01:16:40 +00:00
Kyle Miller
980e73c368 feat: make in Infoview hovers show docstring (#3663)
The docstring for `⋯` gives information about why the omission term
might appear in an expression, and it helps with discoverability to give
documentation right in the hover.

This was mentioned by Patrick Massot [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Deep.20terms.20ellipses/near/426133597)
as being an issue.
2024-03-22 00:00:23 +00:00
Scott Morrison
67c7729f96 doc: fix HDiv and HMod doc-strings (#3734)
As reported by @loefflerd on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/wrong.20docstring.20for.20integer.20division.3F/near/428076692).
2024-03-21 23:46:41 +00:00
David Thrane Christiansen
966fa800f8 chore: remove the coercion from String to Name (#3589)
This coercion caused difficult-to-diagnose bugs sometimes. Because there
are some situations where converting a string to a name should be done
by parsing the string, and others where it should not, an explicit
choice seems better here.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-03-21 23:46:03 +00:00
Lean stage0 autoupdater
d5701fc912 chore: update stage0 2024-03-22 00:00:55 +00:00
Kyle Miller
ff7a0db099 feat: add pp_using_anonymous_constructor attribute (#3640)
Implements a Lean 3 pretty printer feature. Structures with the
`@[pp_using_anonymous_constructor]` attribute pretty using anonymous
constructor notation (`⟨x, y, z⟩`) rather than structure instance
notation (`{a := x, b := y, c := z}`).

[Zulip
discussion](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60pp_using_anonymous_constructor.60/near/425705445)
2024-03-21 23:01:10 +00:00
Sebastian Ullrich
085d01942d fix: restore default of stderrAsMessages (#3733)
Puts trace.compiler back in the info view. Apparently an unintended
change in #3014.
2024-03-21 17:43:29 +00:00
Marc Huisinga
31767aa835 fix: use sticky diags in getInteractiveDiagnostics (#3730)
I forgot to use the sticky diagnostics in `getInteractiveDiagnostics` in
#3247, leading to them not consistently showing up in the "Messages"
panel of the InfoView.
2024-03-21 14:34:22 +00:00
Marc Huisinga
902668dc38 fix: use correct positions for header errors (#3728)
This lead to incorrect diagnostic spans in the editor and resulted in
header errors that did not show up under "Messages" everywhere in the
file because the `fullRange?` property was missing.

Also changes the "Import out of date" warning diagnostic severity to
"Hint" so that it doesn't show up in the "Problems" view.
2024-03-21 14:19:45 +00:00
Joachim Breitner
2867b93d51 chore: replace shell.nix with a devShell in flake.nix (#3717)
as a side effect this pins the “old nixpkgs” revision used by CI for
release builds.
(Not that that old branch is likely to change a lot…)
2024-03-21 13:24:01 +00:00
Mario Carneiro
49f66dc485 perf: rewrite UnusedVariables lint (#3186)
This is a rewrite of the `UnusedVariables` lint to inline and simplify
many of the dependent functions to try to improve the performance of
this lint, which quite often shows up in perf reports.

* The mvar assignment scanning is one of the most expensive parts of the
process, so we do two things to improve this:
  * Lazily perform the scan only if we need it
* Use an object-pointer hashmap to ensure that we don't have quadratic
behavior when there are many mvar assignments with slight differences.
* The dependency on `Lean.Server` is removed, meaning we don't need to
do the LSP conversion stuff anymore. The main logic of reference finding
is inlined.
* We take `fvarAliases` into account, and union together fvars which are
aliases of a base fvar. (It would be great if we had `UnionFind` here.)

More docs will be added once we confirm an actual perf improvement.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-03-21 12:28:57 +00:00
Scott Morrison
164689f00f feat: more BitVec lemmas (#3729) 2024-03-21 11:56:24 +00:00
Arthur Adjedj
bf8b66c6a5 fix: ignore unused alternatives in Ord derive handler (#3725)
Closes #3706

This derive handler's implementation is very similar to `BEq`'s, which
already ignores unused alternative so as to work correctly on indexed
inductive types. This PR simply implements the same solution as the one
present in
[`BEq.lean`](2c15cdda04/src/Lean/Elab/Deriving/BEq.lean (L94)).

After some tests, it doesn't seem like any other derive handler present
in Core suffers from the same issue (though some handlers don't work on
indexed inductives for other reasons).
2024-03-21 10:29:22 +00:00
Sebastian Ullrich
4d4e467392 feat: MonadAlwaysExcept for MonadCacheT (#3726) 2024-03-21 09:01:13 +00:00
Scott Morrison
2c15cdda04 feat: BitVec.ofBoolListLE and theorems (#3721)
Requested by Jeremy Avigad on
[zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/explicit.20bitvectors/near/427841343).

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-03-21 04:48:29 +00:00
Lean stage0 autoupdater
4391bc2977 chore: update stage0 2024-03-20 22:45:34 +00:00
Marc Huisinga
40b5282ec2 fix: use correct module name in references (#3722)
#3656 used the wrong name in `RefIdent`, which lead to "Find References"
being broken. I really need to set up some tests for this functionality
...
2024-03-20 20:28:01 +00:00
Sebastian Ullrich
afbf8759e1 fix: deadlock in IO.Promise.resolve (#3693) 2024-03-20 12:47:52 +00:00
Leni Aniva
3ab1c23500 fix: Build failure of nix build . on macOS (#3712)
Closes bug #3711 

Now we have
```
$ nix build .#stage0
$ ls result/lib/lean/
libInit_shared.dylib* libleanshared.dylib*
```
2024-03-18 21:39:39 +00:00
Scott Morrison
846300038f fix: make attribute based rfl tactic builtin (#3708) 2024-03-18 11:39:59 +00:00
Lean stage0 autoupdater
01432ffc5a chore: update stage0 2024-03-18 12:20:03 +00:00
Marc Huisinga
3c82f9ae12 feat: diagnostics for stale dependencies (#3247)
Sends a diagnostic informing the user to run Restart File when a file
dependency is saved.

Based on #3014 because this feature was easier to implement with the new
architecture.

ToDo:
- [x] Adjust vscode-lean4 to display a notification when this diagnostic
appears in a non-annoying way
(https://github.com/leanprover/vscode-lean4/pull/393)
- [x] Use a file watcher to identify changes to files not tracked by VS
Code
- [x] Rebase onto master when #3014 is merged
2024-03-18 10:38:38 +00:00
Kitamado
7abc1fdaac doc: fix docstring of List.span (#3707)
see
https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/docstring.20of.20.60List.2Espan.60.20is.20wrong
2024-03-18 10:26:47 +00:00
Liu Yuxi
2d18eff544 doc: lake: fix typo (#3704)
Closes #3703
2024-03-17 18:23:21 +00:00
Scott Morrison
66541b00a6 feat: upstream Std's rfl tactic (#3671)
This allows tagging lemmas with `@[refl]`, that will then by used by
`rfl`.

This is preparatory to upstreaming Mathlib's `convert` tactic.
2024-03-17 07:06:13 +00:00
Scott Morrison
f1f9b57df9 feat: upstream apply helper tactics from Mathlib (#3670)
These are used in Mathlib's `congr!` and `convert` tactics, which will
be upstreamed soon.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-03-17 06:47:56 +00:00
Scott Morrison
88b1751b54 chore: fix namespaces in recently upstreamed tactics (#3672) 2024-03-17 06:41:40 +00:00
Timo Carlin-Burns
8e96d7ba1d refactor: clean up public API around Array.eraseIdx (#3676)
- Removes the public definitions `Array.eraseIdxAux` and
`Array.eraseIdxSzAux` which were implementation details.
- Motivation: `Array.eraseIdxAux` and `Array.eraseIdxSzAux` were clearly
not intended to remain public, but simply making them private would make
it inconvenient to unfold them when writing proofs in Std.
- Adds documentation comments to the public `Array.eraseIdx`-related
definitions which remain.
- Removes `Array.eraseIdx'` which was just `Array.feraseIdx` wrapped in
a subtype and adds `Array.size_feraseIdx` to prove the subtype property
as a standalone theorem.

Co-Authored-By: Daniel Windham <daniel@atlascomputing.org>
2024-03-17 06:25:10 +00:00
Scott Morrison
9ee10aa3eb chore: in combined CI, check for required Std tag, then Mathlib (#3702) 2024-03-17 01:29:47 +00:00
Scott Morrison
811bedfa76 chore: fix combined CI for mathlib (#3700)
Previously, if there was a `nightly-testing-YYYY-MM-DD` tag at Std, but
not Mathlib, we were erroneously proceeding with Mathlib CI, and hence
using a probably-broken version of Mathlib.
2024-03-16 23:42:45 +00:00
Joachim Breitner
0b01ceb3bb fix: substVars in functional inductions removed valuable information (#3695)
using the `substVars` tactic on the goal can remove too much
information, as it does not take into account that the `motive` may
depend on the fixed parameters.

This is fixed by etracting `substVar` from `subst` which expects the
`x`, not the `h : x = rhs`, and then using this tactic on the local
declarations _after_ the `motive` exclusively.
2024-03-16 14:55:31 +00:00
Joachim Breitner
4c57da4b0f feat: infer termination arguments like xs.size - i (#3666)
a common pattern for recursive functions is
```
def countUp (n i acc : Nat) : Nat :=
  if i < n then
    countUp n (i+1) (acc + i)
  else
    acc
```
where we increase a value `i` until it hits an upper bound. This is
particularly common with array processing functions:
```
$ git grep 'termination_by.*size.*-' src/|wc -l
26
```

GuessLex now recognizes this pattern. The general approach is:

For every recursive call, check if the context contains hypotheses of
the form `e₁ < e₂` (or similar comparisions), and then consider `e₂ -
e₁` as a termination argument.

Currently, this only fires when `e₁` and `e₂` only depend on the
functions parameters, but not local let-bindings or variables bound in
local pattern matches.

Duplicates are removed.

In the table showing the termination argument failures, long termination
arguments are now given a number and abbreviated as e.g. `#4` in the
table headers.

More examples in the test file, here as some highlights:
```
def distinct (xs : Array Nat) : Bool :=
  let rec loop (i j : Nat) : Bool :=
    if _ : i < xs.size then
      if _ : j < i then
        if xs[j] = xs[i] then
          false
        else
          loop i (j+1)
      else
        loop (i+1) 0
    else
      true
  loop 0 0
```
infers
```
termination_by (Array.size xs - i, i - j)
```
and the weird functions where `i` goes up or down
```
def weird (xs : Array Nat) (i : Nat) : Bool :=
  if _ : i < xs.size then
    if _ : 0 < i then
      if xs[i] = 42 then
        weird xs.pop (i - 1)
      else
        weird xs (i+1)
    else
      weird xs (i+1)
  else
    true
decreasing_by all_goals simp_wf; omega
```
infers
```
termination_by (Array.size xs - i, i)
```
but unfortunately needs `decreasing_by` pending the “big
decreasing_tactic refactor” that
I expect we’ll want to do at some point.
2024-03-16 12:27:35 +00:00
Joachim Breitner
f0ff01ae28 refactor: pass Measures around as Expr in GuessLex (#3665)
this refactor prepares GuessLex to be able to infer more complex
termination arguments.

As a side-effect it fixes an (obscure) bug where `sizeOf` would be
applied to a term of the wrong type and thus a wrong `SizeOf` instance
could be inferred.
2024-03-16 10:25:55 +00:00
Joe Hendrix
0ec8862103 chore: migrate find functionality into LazyDiscrTree (#3685)
This migrates some lookup functionality from library_search to a more
generic version in LazyDiscrTree.

It is a step towards `rw?` in core.
2024-03-16 01:01:53 +00:00
Lean stage0 autoupdater
f70895ede5 chore: update stage0 2024-03-15 16:30:21 +00:00
Sebastian Ullrich
557777dd37 chore: CI: mark "Build matrix complete" as cancelled if builds cancelled (#3690) 2024-03-15 12:30:48 +00:00
Marc Huisinga
e47d8ca5cd fix: periodically refresh semantic tokens (#3691)
Based on #3619 that was reverted because of nondeterministic test
failures. This PR should resolve those.
2024-03-15 11:58:50 +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
Marc Huisinga
14654d802d chore: revert periodically refresh semantic tokens (#3619) (#3689)
This reverts commit 4e3a8468c3 for PR
#3619. It looks like the CI in that commit didn't inform me that a test
was broken by the PR, so I managed to commit it despite the broken test.
2024-03-15 09:17:53 +00:00
Leonardo de Moura
173b956961 feat: reserved names (#3675)
- Add support for reserved declaration names. We use them for theorems
generated on demand.
- Equation theorems are not private declarations anymore.
- Generate equation theorems on demand when resolving symbols.
- Prevent users from creating declarations using reserved names. Users
can bypass it using meta-programming.

See next test for examples.
2024-03-15 00:33:22 +00:00
Joachim Breitner
022b2e4d96 refactor: termination arguments as Expr, not Syntax (#3658)
Before, the termination argument as inferred by `GuessLex` was passed
further
on as `Syntax`, to be elaborated later in `WF.Rel`.

This didn’t feel quite right anymore. In particular if we want to teach
`GuessLex` about guessing more complex termination arguments like
`xs.size -
i`, using `Expr` here is more natural.

So this introduces `TerminationArgument` based on an `Expr` to be used
here.

A side-effect of how the termination arguments are elaborated is that
the unused
variables linter will now look at `termination_by` variables, and that
parameters
past the colon are not even invisibly in scope, so `‹_›` will not find
them
See https://github.com/leanprover-community/mathlib4/pull/11370/files
for examples
of fixing these changes.
2024-03-14 23:51:53 +00:00
Marc Huisinga
4e3a8468c3 fix: periodically refresh semantic tokens (#3619)
This PR fixes an issue where the file worker would not provide the
client with semantic tokens until the file had been elaborated
completely. The file worker now also tells the client to refresh its
semantic tokens after running "Restart File". This PR is based on #3271.
2024-03-14 17:10:04 +00:00
Marc Huisinga
78a72741c6 fix: jump to correct definition when names overlap (#3656)
Fixes #1170.

This PR adds the module name to `RefIdent` in order to distinguish
conflicting names from different files. This also fixes related issues
in find-references or the call hierarchy feature.
It also adds some docstrings and stylistically refactors a bunch of
code.
2024-03-14 16:21:19 +00:00
Marc Huisinga
795e332fb3 feat: server -> client requests (#3271)
This PR adds support for requests from the server to the client in the
language server. It is based on #3014 and was developed during an
experiment for #3247 that unfortunately did not go anywhere.
2024-03-14 16:00:32 +00:00
Joe Hendrix
1151d73a55 fix: use builtin_initialize in library_search (#3677)
This replaces a few uses of initialize with builtin_initialize, and
removes some unneeded functionality added when it was unclear if lazy
discriminator trees would be efficient enough.
2024-03-14 15:28:00 +00:00
Sebastian Ullrich
fb2ec54b60 chore: build Lean .os in parallel to rest of core (#3682)
Previously, we only did `Init/*.{o,olean}+Lean/*.olean` in parallel
2024-03-14 15:14:37 +00:00
Joachim Breitner
f89ed40618 refactor: ArgsPacker (#3621)
This introduces the `ArgsPacker` module and abstraction, to replace the
exising `PackDomain`/`PackMutual` code. The motivation was that we now
have more uses besides `Fix.lean` (`GuessLex` and `FunInd`), and the
code was spread in various places.

The goals are

* consistent function naming withing the the `PSigma` handling, the
`PSum` handling, and the combined interface
* avoid taking a type apart just based on the `PSigma`/`PSum` nesting,
to be robust in case the user happens to be using `PSigma`/`PSum`
somewhere. Therefore, always pass an `arity` or `numFuncs` or `varNames`
around.
* keep all the `PSigma`/`PSum` encoding logic contained within one
module (`ArgsPacker`), and keep that module independent of its users (so
no `EqnInfos` visible here).
 * pick good variable names when matching on a packed argument
* the unary function now is either called `fun1._unary` or
`fun1._mutual`, never `fun1._unary._mutual`.

This file has less heavy dependencies than `PackMutual` had, so build
parallelism is improved as well.
2024-03-14 14:59:40 +00:00
Sebastian Ullrich
68eaf33e86 feat: snapshot trees and language processors (#3014)
This is the foundation for work on making processing in the language
server both more fine-grained (incremental tactics) as well as parallel.
2024-03-14 13:40:08 +00:00
Sebastian Ullrich
0959bc45d2 chore: CI: temporarily disable fsanitize build 2024-03-14 15:36:28 +01:00
Leonardo de Moura
995726f75f chore: fix tests 2024-03-13 21:15:48 -07:00
Leonardo de Moura
214179b6b9 chore: update stage0 2024-03-13 21:15:48 -07:00
Leonardo de Moura
9ee1ff2435 chore: remove bootstrapping workaround 2024-03-13 21:15:48 -07:00
Leonardo de Moura
653eb5f66e chore: update stage0 2024-03-13 21:15:48 -07:00
Leonardo de Moura
2c8fd7fb95 chore: avoid reserved name
TODO: update state0 and cleanup
2024-03-13 21:15:48 -07:00
Leonardo de Moura
8d2adf521d feat: allow duplicate theorems to be imported 2024-03-13 12:57:41 -07:00
Leonardo de Moura
612d97440b chore: incorrectly annotated theorems 2024-03-13 12:37:58 -07:00
Leonardo de Moura
0f19332618 chore: update stage0 2024-03-13 12:37:58 -07:00
Leonardo de Moura
84b0919a11 feat: type of theorems must be propositions 2024-03-13 12:37:58 -07:00
Hongyu Ouyang
e61d082a95 doc: fix typo in USize.size docstring (#3664) 2024-03-13 10:51:24 +00:00
Leonardo de Moura
600412838c fix: auxiliary definition nested in theorem should be def if its type is not a proposition (#3662) 2024-03-13 09:38:37 +00:00
Joachim Breitner
a81205c290 feat: conv => calc (#3659)
`calc` is great for explicit rewriting, `conv` is great to say where to
rewrite, so it's natural to want `calc` as a `conv` tactic.

Zulip disucssion at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/idiom.20for.20using.20calc.20to.20rewrite.20the.20goal/near/424269608

Fixes #3557.
2024-03-13 09:03:39 +00:00
Leonardo de Moura
2003814085 chore: rename automatically generated equational theorems (#3661)
cc @nomeata
2024-03-13 07:56:27 +00:00
Scott Morrison
317adf42e9 chore: add @[simp] to Nat.succ_eq_add_one, and cleanup downstream (#3579) 2024-03-13 05:35:52 +00:00
Leonardo de Moura
5aca09abca fix: add Canonicalizer.lean and use it to canonicalize terms in omega (#3639) 2024-03-12 23:18:56 +00:00
Joachim Breitner
07dac67847 feat: guard_msgs to escapes trailing newlines (#3617)
This makes trailing whitespace visible and protectes them against
trimming by the editor, by appending the symbol ⏎ to such a line (and
also to any line that ends with such a symbol, to avoid ambiguities in
the case the message already had that symbol).

(Only the code action output / docstring parsing is affected; the error
message as sent
to the InfoView is unaffected.)

Fixes #3571
2024-03-12 16:35:14 +00:00
thorimur
5cf4db7fbf fix: make dsimp? use and report simprocs (#3654)
Modifies `dsimpLocation'` (which implements `dsimp?`) to take a
`simprocs : SimprocsArray` argument, like `simpLocation` and
`dsimpLocation`. This ensures that the behavior of `dsimp` matches
`dsimp?`.

---

Closes #3653
2024-03-12 05:17:58 +00:00
Mac Malone
b2ae4bd5c1 feat: allow noncomputable unsafe definitions (#3647)
Enables the combination of `noncomputable unsafe` to be used for
definitions. Outside of pure theory, `noncomputable` is also useful to
prevent Lean from compiling a definition which will be implemented with
external code later. Such definitions may also wish to be marked
`unsafe` if they perform morally impure or memory-unsafe functions.
2024-03-12 02:46:42 +00:00
Joe Hendrix
c43a6b5341 chore: upstream Std.Data.Int (#3635)
This depends on #3634.
2024-03-11 21:40:48 +00:00
Lean stage0 autoupdater
1388f6bc83 chore: update stage0 2024-03-11 17:22:37 +00:00
Joachim Breitner
d9b6794e2f refactor: termination_by parser to use binderIdent (#3652)
this way we should be able to use `elabBinders` to parse the binders.
2024-03-11 16:29:56 +00:00
Mac Malone
ebefee0b7d chore: response file to avoid arg limits in lean static lib build (#3612) 2024-03-11 16:14:24 +00:00
Joachim Breitner
32dcc6eb89 feat: GuessLex: avoid writing sizeOf in termination argument when not needed (#3630)
this makes `termination_by?` even slicker.

The heuristics is agressive in the non-mutual case (will omit `sizeOf`
if the argument is non-dependent and the `WellFoundedRelation` relation
is via `sizeOfWFRel`.

In the mutual case we'd also have to check the arguments, as they line
up in the termination argument, have the same types. I did not bother at
this point; in the mutual case we omit `sizeOf` only if the argument
type is `Nat`.

As a drive-by fix, `termination_by?` now also works on functions that
have only one plausible measure.
2024-03-10 22:57:10 +00:00
Leonardo de Moura
1d3ef577c2 chore: disable some tests on Windows (#3642)
This is a temporary workaround for a limitation on Windows shared
libraries. We are getting errors of the form:
```
ld.lld: error: too many exported symbols (got 65572, max 65535)
```
2024-03-09 23:48:41 +00:00
Kyle Miller
45fccc5906 feat: custom eliminators for induction and cases tactics, and beautiful eliminators for Nat (#3629)
Replaces `@[eliminator]` with two attributes `@[induction_eliminator]`
and `@[cases_eliminator]` for defining custom eliminators for the
`induction` and `cases` tactics, respectively.

Adds `Nat.recAux` and `Nat.casesAuxOn`, which are eliminators that are
defeq to `Nat.rec` and `Nat.casesOn`, but these use `0` and `n + 1`
rather than `Nat.zero` and `Nat.succ n`.

For example, using `induction` to prove that the factorial function is
positive now has the following goal states (thanks also to #3616 for the
goal state after unfolding).
```lean
example : 0 < fact x := by
  induction x with
  | zero => decide
  | succ x ih =>
    /-
    x : Nat
    ih : 0 < fact x
    ⊢ 0 < fact (x + 1)
    -/
    unfold fact
    /-
    ...
    ⊢ 0 < (x + 1) * fact x
    -/
    simpa using ih
```

Thanks to @adamtopaz for initial work on splitting the `@[eliminator]`
attribute.
2024-03-09 15:31:51 +00:00
Kyle Miller
3acd77a154 fix: make elabTermEnsuringType respect errToSorry when there is a type mismatch (#3633)
Floris van Doorn [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/have.20tactic.20error.20recovery/near/425283053)
that it is confusing that the `have : T := e` tactic completely fails if
the body `e` is not of type `T`. This is in contrast to `have : T := by
exact e`, which does not completely fail when `e` is not of type `T`.

This ends up being caused by `elabTermEnsuringType` throwing an error
when it fails to insert a coercion. Now, it detects this case, and it
checks the `errToSorry` flag to decide whether to throw the error or to
log the error and insert a `sorry`.

This is justified by `elabTermEnsuringType` being a frontend to
`elabTerm`, which inserts `sorry` on error.

An alternative would be to make `ensureType` respect `errToSorry`, but
there exists code that expects being able to catch when `ensureType`
fails. Making such code manipulate `errToSorry` seems error prone, and
this function is not a main entry point to the term elaborator, unlike
`elabTermEnsuringType`.
2024-03-09 15:30:47 +00:00
Leonardo de Moura
b39042b32c fix: eta-expanded instances at SynthInstance.lean (#3638)
Remark: this commit removes the `jason1.lean` test. Motivation: It
breaks all the time due to changes we make, and it is not clear anymore
what it is testing.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-03-08 20:37:38 +00:00
Joe Hendrix
6dd4f4b423 chore: upstream Std.Data.Nat (#3634)
This migrates lemmas about Nat `compare`, `min`, `max`, `dvd`, `gcd`,
`lcm` and `div`/`mod` from Std to Lean itself.

Std still has some additional recursors, `CoPrime` and a few additional
definitions that might merit further discussion prior to upstreaming.
2024-03-08 17:00:46 +00:00
Mac Malone
123dcb964c feat: lake: LEAN_GITHASH override (#3609)
If the `LEAN_GITHASH` environment variable is set, Lake will now use it
instead of the detected Lean's githash when computing traces for builds
and the elaborated Lake configuration. This override allows one to
replace the Lean version used by a library
(e.g., Mathlib) without completely rebuilding it, which is useful for
testing custom builds of Lean.
2024-03-08 15:03:07 +00:00
Patrick Massot
ccac989dda doc: expand an error message about compacting closures (#3627)
Provide a hint of where the error message may come from.
2024-03-07 20:02:23 +00:00
Kyle Miller
f336525f31 fix: make delabConstWithSignature avoid using inaccessible names (#3625)
The `delabConstWithSignature` delaborator is responsible for pretty
printing constants with a declaration-like signature, with binders, a
colon, and a type. This is used by the `#check` command when it is given
just an identifier.

It used to accumulate binders from pi types indiscriminately, but this
led to unfriendly behavior. For example, `#check String.append` would
give
```
String.append (a✝ : String) (a✝¹ : String) : String
```
with inaccessible names. These appear because `String.append` is defined
using patterns, so it never names these parameters.

Now the delaborator stops accumulating binders once it reaches an
inaccessible name, and for example `#check String.append` now gives
```
String.append : String → String → String
```
We do not synthesize names for the sake of enabling binder syntax
because the binder names are part of the API of a function — one can use
`(arg := ...)` syntax to pass arguments by name. The delaborator also
now stops accumulating binders once it reaches a parameter with a name
already seen before — we then rely on the main delaborator to provide
that parameter with a fresh name when pretty printing the pi type.

As a special case, instance parameters with inaccessible names are
included as binders, pretty printing like `[LT α]`, rather than
relegating them (and all the remaining parameters) to after the colon.
It would be more accurate to pretty print this as `[inst✝ : LT α]`, but
we make the simplifying assumption that such instance parameters are
generally used via typeclass inference. Likely `inst✝` would not
directly appear in pretty printer output, and even if it appears in a
hover, users can likely figure out what is going on. (We may consider
making such `inst✝` variables pretty print as `‹LT α›` or
`infer_instance` in the future, to make this more consistent.)

Something we note here is that we do not do anything to make sure
parameters that can be used as named arguments actually appear named
after the colon (nor do we assure that the names are the correct names).
For example, one sees `foo : String → String → String` rather than `foo
: String → (baz : String) → String`. We can investigate this later if it
is wanted.

We also give `delabConstWithSignature` a `universes` flag to enable
turning off pretty printing universe levels parameters.

Closes #2846
2024-03-07 18:14:06 +00:00
Sebastian Ullrich
3921257ece feat: thread initialization for reverse FFI (#3632)
Makes it possible to properly allocate and free thread-local runtime
resources for threads not started by Lean itself
2024-03-07 17:02:47 +00:00
Sebastian Ullrich
6af7a01af6 fix: stray dbgTraceVal in trace children elision (#3622) 2024-03-07 09:44:25 +00:00
Leonardo de Moura
611b174689 fix: ofScientific at simp (#3628)
closes #2159
2024-03-07 00:11:31 +00:00
Leonardo de Moura
d731854d5a chore: update stage0 2024-03-06 15:29:04 -08:00
Leonardo de Moura
3218b25974 doc: for issue #2835 2024-03-06 15:29:04 -08:00
Leonardo de Moura
ef33882e2f test: issue #2835
closes #2835
2024-03-06 15:29:04 -08:00
Leonardo de Moura
4208c44939 chore: update stage0 2024-03-06 15:29:04 -08:00
Leonardo de Moura
423fed79a9 feat: simplify .arrow ctor at DiscrTree.lean 2024-03-06 15:29:04 -08:00
Leonardo de Moura
5302b7889a fix: fold raw Nat literals at dsimp (#3624)
closes #2916

Remark: this PR also renames `Expr.natLit?` ==> `Expr.rawNatLit?`.
Motivation: consistent naming convention: `Expr.isRawNatLit`.
2024-03-06 18:29:20 +00:00
Joe Hendrix
46cc00d5db chore: add example to explanation cond_decide is not simp (#3615)
This just adds a concrete example to the `cond_decide` lemma to explain
why it is not a simp rule.
2024-03-06 16:58:12 +00:00
Joachim Breitner
0072d13bd4 feat: MatcherApp.transform: Try to preserve alt’s variable name (#3620)
this makes the ugly `fst`/`snd` variable names in the functional
induction principles go away.

Ironically I thought in order to fix these name, I should touch the
mutual/n-ary argument packing code used for well-founded recursion, and
embarked on a big refactor/rewrite of that code, only to find that at
least this particular instance of the issue was somewhere else. Hence
breaking this into its own PR; the refactoring will follow (and will
also improve some other variable names.)
2024-03-06 15:56:17 +00:00
Leonardo de Moura
09bc477016 feat: better support for reducing Nat.rec (#3616)
closes #3022

With this commit, given the declaration
```
def foo : Nat → Nat
  | 0 => 2
  | n + 1 => foo n
```
when we unfold `foo (n+1)`, we now obtain `foo n` instead of `foo
(Nat.add n 0)`.
2024-03-06 13:28:07 +00:00
Sebastian Ullrich
f0a762ea4d chore: CI: temporarily disable test binary check on Windows 2024-03-06 09:00:38 +01:00
Leonardo de Moura
30a61a57c3 chore: disable compiler tests on Windows 2024-03-05 20:24:01 -08:00
Leonardo de Moura
794228a982 refactor: Offset.lean and related files (#3614)
Motivation: avoid the unfold and check idiom.
This commit also minimize dependencies at `Offset.lean`.

closes #2615
2024-03-05 19:40:15 -08:00
Joe Hendrix
6cf82c3763 fix: update LazyDiscrTree to not reuse names when caching (#3610)
This fixes an issue discovered in Mathlib with the meta cache being
poisoned by using a name generator. It is difficult to reproduce due to
the name collisions being rare, but here is a minimal module with
definitions that result in an error:

```lean
prelude
universe u

inductive Unit2 : Type where
  | unit : Unit2

inductive Eq2 {α : Sort u} : α → α → Prop where
  | refl (a : α) : Eq2 a a

structure Subtype2 {α : Sort u} (p : α → Prop) where
  val : α

def End (α) := α → α
theorem end_app_eq (α : Type u) (f : End α) (a : α) : Eq2 (f a) (f a) := Eq2.refl _
theorem Set.coe_eq_subtype {α : Type u} (s : α → Prop) : Eq2 (Subtype2 s) (Subtype2 s) := Eq2.refl _
def succAboveCases {_ : Unit2} {α : Unit2 → Sort u} (i : Unit2) (v : α i) : α i := v
theorem succAbove_cases_eq_insertNth : Eq2 @succAboveCases.{u + 1} @succAboveCases.{u + 1} := Eq2.refl _
```

Removing any of thee last 5 definitions avoids the error. Testing
against Mathlib shows this PR fixes the issue.
2024-03-06 02:32:22 +00:00
Scott Morrison
01f0fedef8 feat: further shaking of Nat/Int/Omega (#3613) 2024-03-05 23:43:36 +00:00
Scott Morrison
b8ff951cd1 feat: restore Bool.and_xor_distrib_(left|right) (#3604)
I think these were dropped in #3508, and Mathlib needs them.
2024-03-05 22:22:21 +00:00
Leonardo de Moura
da869a470b chore: update stage0 2024-03-05 14:42:05 -08:00
Leonardo de Moura
acdb0054d5 feat: use dsimprocs at dsimp 2024-03-05 14:42:05 -08:00
Leonardo de Moura
63b068a77c chore: remove auxiliary functions used for bootstrapping 2024-03-05 14:42:05 -08:00
Leonardo de Moura
a4143ded64 chore: update stage0 2024-03-05 14:42:05 -08:00
Leonardo de Moura
02efb19aad chore: prepare to remove auxiliary functions used for bootstrapping 2024-03-05 14:42:05 -08:00
Leonardo de Moura
74c1ce1386 chore: use builtin_dsimproc when appropriate 2024-03-05 14:42:05 -08:00
Leonardo de Moura
1da65558d0 chore: update stage0 2024-03-05 14:42:05 -08:00
Leonardo de Moura
b24fbf44f3 feat: dsimproc command
Simplification procedures that produce definitionally equal results.

WIP
2024-03-05 14:42:05 -08:00
Marc Huisinga
f986f69a32 fix: getInteractiveDiagnostics off-by-one error (#3608)
This bug is the real cause of leanprover/vscode-lean4#392. 
At the end of a tactic state, the client calls
`getInteractiveDiagnostics` with a range `[last line of proof, last line
of proof + 1)`. The `fullRange` span of the `unresolved goals` error
however is something like `[(first line of proof, start character),
(last line of proof, nonzero end character)).
Since it operates on line numbers, `getInteractiveDiagnostics` would
then check whether `[last line of proof, last line of proof + 1)` and
`[first line of proof, last line of proof)` intersect, which is false
because of the excluded upper bound on the latter interval, despite the
fact that the end character in the last line may be nonzero.

This fix adjusts the intersection logic to use `[first line of proof,
last line of proof]` if the end character is nonzero.

Closes leanprover/vscode-lean4#392.
2024-03-05 17:21:10 +00:00
Leonardo de Moura
436d7befa5 fix: dsimp should reduce kernel projections (#3607)
closes #3395
2024-03-05 14:56:27 +00:00
Leonardo de Moura
414f0eb19b fix: bug at Result.mkEqSymm (#3606)
`cache` and `dischargeDepth` fields were being reset.
2024-03-05 14:37:09 +00:00
Scott Morrison
bf6d9295a4 chore: shaking imports in Init.Data.Nat/Int (#3605) 2024-03-05 13:29:35 +00:00
Marc Huisinga
06f4963069 feat: partial words import completion (#3602)
This PR enables import auto-completion to complete partial words in
imports.

Other inconsistencies that I've found in import completion already seem
to be fixed by #3014. Since it will be merged soon, there is no need to
invest time to fix these issues on master.
2024-03-05 13:20:07 +00:00
Joachim Breitner
8038604d3e feat: functional induction (#3432)
This adds the concept of **functional induction** to lean.

Derived from the definition of a (possibly mutually) recursive function,
a **functional
induction principle** is tailored to proofs about that function. For
example from:

```
def ackermann : Nat → Nat → Nat
  | 0, m => m + 1
  | n+1, 0 => ackermann n 1
  | n+1, m+1 => ackermann n (ackermann (n + 1) m)
derive_functional_induction ackermann
```
we get
```
ackermann.induct (motive : Nat → Nat → Prop) (case1 : ∀ (m : Nat), motive 0 m)
  (case2 : ∀ (n : Nat), motive n 1 → motive (Nat.succ n) 0)
  (case3 : ∀ (n m : Nat), motive (n + 1) m → motive n (ackermann (n + 1) m) → motive (Nat.succ n) (Nat.succ m))
  (x x : Nat) : motive x x
```

At the moment, the user has to ask for the functional induction
principle explicitly using
```
derive_functional_induction ackermann
```

The module docstring of `Lean/Meta/Tactic/FunInd.lean` contains more
details on the
design and implementation of this command.

More convenience around this (e.g. a `functional induction` tactic) will
follow eventually.


This PR includes a bunch of `PSum`/`PSigma` related functions in the
`Lean.Tactic.FunInd`
namespace. I plan to move these to `PackArgs`/`PackMutual` afterwards,
and do some cleaning
up as I do that.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-03-05 13:02:05 +00:00
Scott Morrison
ce77518ef5 feat: restore Bool.and_xor_distrib_(left|right) 2024-03-05 23:49:47 +11:00
Joachim Breitner
fbd9c076c0 chore: run nix-ci whenever we run ci (#3600)
this unifies the `on` settings between nix-ci and ci, less confusion
when adding a label doesn’t trigger all the CI stuff.
2024-03-05 09:11:19 +00:00
Scott Morrison
ae492265fe chore: cleanup a bitblast proof (#3598) 2024-03-05 04:59:58 +00:00
Scott Morrison
c4a784d6a3 feat: more BitVec lemmas (#3597) 2024-03-05 04:47:53 +00:00
Scott Morrison
def564183c feat: checklist for release process (#3536)
This is still WIP: the checklist for release candidates will get
finished as I do the release of `v4.7.0-rc1`.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-03-05 02:55:17 +00:00
Alex Keizer
46bf4b69b6 feat: add lemmas about BitVec.concat and bitwise ops (#3487)
Show how the various bitwise ops (`and`, `or`, `not`, and `xor`)
distribute over `concat`.
2024-03-05 02:48:10 +00:00
Scott Morrison
89ec60befe feat: lemmas about BitVec (#3593)
Basic API lemmas for BitVec, motivated by thinking about bitblasting.
2024-03-05 02:41:47 +00:00
Scott Morrison
f48079eb90 chore: begin development cycle for v4.8.0 (#3596) 2024-03-05 02:15:37 +00:00
Joe Hendrix
01104cc81e chore: bool and prop lemmas for Mathlib compatibility and improved confluence (#3508)
This adds a number of lemmas for simplification of `Bool` and `Prop`
terms. It pulls lemmas from Mathlib and adds additional lemmas where
confluence or consistency suggested they are needed.

It has been tested against Mathlib using some automated test
infrastructure.

That testing module is not yet included in this PR, but will be included
as part of this.

Note. There are currently some comments saying the origin of the simp
rule. These will be removed prior to merging, but are added to clarify
where the rule came from during review.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-04 23:56:30 +00:00
Leonardo de Moura
37450d47e2 fix: bug at elimOptParam (#3595)
`let_expr` uses `cleanupAnnotations` which consumes `optParam` type
annotations.

cc @nomeata
2024-03-04 23:56:00 +00:00
Scott Morrison
e814fc859e chore: cherry-picking v4.6.1 release notes (#3592) 2024-03-04 12:59:00 +00:00
Marc Huisinga
093e1cf22a test: add language server startup benchmark (#3558)
Benchmark to catch future regressions as the one fixed in #3552.
2024-03-04 09:01:51 +00:00
Leonardo de Moura
e6d6855a85 chore: missing double backticks (#3587) 2024-03-04 03:02:35 +00:00
Leonardo de Moura
bba4ef3728 feat: simprocs for folding numeric literals (#3586)
This PR folds exposed `BitVec` (`Fin`, `UInt??`, and `Int`) ground
literals.
cc @shigoel
2024-03-04 02:51:04 +00:00
Scott Morrison
3ad078fec9 chore: updates to RELEASES.md (#3585) 2024-03-04 02:32:30 +00:00
Leonardo de Moura
8689a56a5d feat: #print equations <decl-name> command (#3584) 2024-03-04 02:32:20 +00:00
Scott Morrison
870c6d0dc4 chore: replacing proofs in Init/Data/Nat/Bitwise/Lemmas with omega (#3576)
Replaces some tedious proofs with `omega`, and take advantage of `omega`
powerups to remove some preparatory steps.
2024-03-04 02:19:31 +00:00
Scott Morrison
ad901498fa chore: add release notes for #3507 and #3509 (#3583) 2024-03-04 00:55:53 +00:00
Kyle Miller
acb1b09fbf fix: expression tree elaborator for relations now localizes error messages to the LHS or RHS (#3442)
Added `withRef` when processing the LHS or RHS. Without this, in an
expression such as `true = ()` the entire expression would be
highlighted with "type mismatch, `()` has type `Unit` but is expected to
have type `Bool`". Now the error is localized to `()`.

This behavior was pointed out [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/error.20location.20bug/near/422665805).
2024-03-04 00:53:32 +00:00
Scott Morrison
791142a7ff feat: Nat.mul_mod (#3582)
Proves
`Nat.mod_mul : x % (a * b) = x % a + a * (x / a % b)` and
`Nat.mod_pow_succ : x % b ^ (k + 1) = x % b ^ k + b ^ k * ((x / b ^ k) %
b)`, helpful for bitblasting.
2024-03-03 23:31:07 +00:00
Scott Morrison
015af6d108 chore: use match_expr in omega (#3577) 2024-03-03 22:22:28 +00:00
Kyle Miller
04385b7fb9 doc: small improvements to docstrings for let and have tactics (#3560) 2024-03-03 22:00:32 +00:00
Joachim Breitner
2510808ebf chore: add unicode directory name to gitignore (#3565)
fixes #3358

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-03-03 20:19:17 +00:00
Leonardo de Moura
9f305fb31f fix: rename_i in macro (#3581)
closes #3553

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-03-03 19:05:37 +00:00
Sebastian Ullrich
380dd9e6e7 fix: free threadpool threads before process exit 2024-03-03 20:12:46 +01:00
Sebastian Ullrich
908b98dad8 fix: task_manager termination under Emscripten 2024-03-03 20:12:46 +01:00
Leonardo de Moura
a4d41beab1 perf: match_expr join points (#3580)
We use `let_delayed` to elaborate `match_expr` join points, which
elaborate the body of the `let` before its value. Thus, there is a
difference between:
- `let_delayed f (x : Expr) := <val>; <body>`
- `let_delayed f := fun (x : Expr) => <val>; <body>`

In the latter, when `<body>` is elaborated, the elaborator does not know
that `f` takes an argument of type `Expr`, and that `f` is a function.
Before this commit ensures the former representation is used.
2024-03-03 18:15:49 +00:00
Leonardo de Moura
95f28be088 fix: generalize excessive resource usage (#3575)
closes #3524
2024-03-03 17:58:11 +00:00
Leonardo de Moura
c66c5bb45b fix: simp? suggests generated equations lemma names (#3573)
closes #3547

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-03-02 23:59:35 +00:00
Leonardo de Moura
870de4322c fix: missing atomic at match_expr parser (#3572) 2024-03-02 21:55:07 +00:00
Joachim Breitner
4fdc243179 refactor: simplify some nomatch with nofun (#3564)
and also don’t wrap `nomatch` with `False.elim`; it is not necessary, as
`nomatch` already inhabits any type.
2024-03-02 20:43:31 +00:00
Leonardo de Moura
8a3c9cafb9 chore: update stage0 2024-03-02 10:07:15 -08:00
Leonardo de Moura
826f0580a6 fix: propagate expected type at do-match_expr 2024-03-02 10:07:15 -08:00
Leonardo de Moura
0359ff753b chore: use __do_jp workaround, and "implementation detail" variables at match_expr macro 2024-03-02 10:07:15 -08:00
Leonardo de Moura
8b2710c8b3 chore: use let_expr to cleanup code 2024-03-02 10:07:15 -08:00
Leonardo de Moura
0199228784 chore: update stage0 2024-03-02 08:16:18 -08:00
Leonardo de Moura
17e498c11f feat: expand let_expr macros 2024-03-02 08:16:18 -08:00
Leonardo de Moura
54ff38aa5f chore: update stage0 2024-03-02 08:16:18 -08:00
Leonardo de Moura
ecfaf8f3e7 feat: add let_expr notation 2024-03-02 08:16:18 -08:00
Leonardo de Moura
3c0e575fe0 feat: add matchExprPat parser 2024-03-02 08:16:18 -08:00
Leonardo de Moura
49f41a6224 chore: update stage0 2024-03-01 22:33:14 -08:00
Leonardo de Moura
7a27b04d50 feat: monadic match_expr 2024-03-01 22:33:14 -08:00
Leonardo de Moura
f777e0cc85 feat: macro expander for match_expr terms 2024-03-01 22:33:14 -08:00
Leonardo de Moura
64adb0627a feat: add auxiliary functions for compiling match_expr 2024-03-01 22:33:14 -08:00
Leonardo de Moura
ea9a417371 chore: update stage0 2024-03-01 22:33:14 -08:00
Leonardo de Moura
70d9106644 feat: match_expr parsers 2024-03-01 22:33:14 -08:00
Marc Huisinga
9cf3fc50c7 doc: update RELEASES.md for #3552 (#3561) 2024-03-02 00:27:21 +00:00
Joe Hendrix
78726c936f chore: add library_search and #check_tactic to 4.7 RELEASES.md (#3549)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-02 00:13:08 +00:00
Marc Huisinga
7e944c1a30 fix: load references asynchronously (#3552)
In v4.6.0, there was a significant regression in initial server startup
performance because the .ilean files got bigger in #3082 and we load the
information stored in all .ilean files synchronously when the server
starts up.

This PR makes this loading asynchronous. The trade-off is that requests
that are issued right after the initial server start when the references
are not fully loaded yet may yield incomplete results.

Benchmark for this in a separate PR soon after this one.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-03-01 13:57:52 +00:00
Scott Morrison
18306db396 chore: protect Int.add_right_inj et al (#3551)
Reducing some name conflicts in Mathlib.
2024-03-01 13:01:39 +00:00
Scott Morrison
570b50dddd chore: correct statement of Int.pow_zero, and protected theorems (#3550) 2024-03-01 12:38:02 +00:00
David Thrane Christiansen
43d6eb144e chore: add error recovery to RELEASES.md (#3540)
Adds the missing RELEASES.md from #3413. Apologies for the oversight!
2024-03-01 05:38:18 +00:00
Siddharth
ed02262941 feat: generalize msb_eq_decide to also handle the zero width case (#3480)
Note that this is a strict generalization of the previous statemens of
`getLsb_last` and `msb_eq_decide` that worked for bitwidths `>= 1`.
2024-02-29 22:46:32 +00:00
Joe Hendrix
c0dfe2e439 feat: BitVec int lemmas (#3474)
This introduces lemma support for BitVec.ofInt/BitVec.toInt as well as
lemmas upstreamed from Std and Mathlib for reasoning about emod and
bmod.
2024-02-29 20:48:57 +00:00
Sebastian Ullrich
61fba365f2 fix: revert shared library split on non-Windows platforms (#3529)
Avoids the performance hit and fixes #3528.
2024-02-29 19:15:01 +00:00
Marcus Rossel
0362fcea69 chore: remove redundant 'generalizing' (#3544) 2024-02-29 13:24:14 +00:00
Marcus Rossel
60d056ffdf doc: fix typos (#3543)
The doc comment on
[Lean.Meta.viewSubexpr](https://leanprover-community.github.io/mathlib4_docs/Lean/Meta/ExprLens.html#Lean.Meta.viewSubexpr)
also seems broken, but I don't know how to fix it.
2024-02-29 13:23:19 +00:00
Marcus Rossel
dc0f026e64 chore: remove redundant '..' pattern in match of 'Level.zero' (#3545) 2024-02-29 13:22:04 +00:00
Kyle Miller
67c9498892 doc: update RELEASES.md for #3495 (#3518) 2024-02-29 11:34:00 +00:00
Joachim Breitner
dc0f771561 doc: fix markdown indentation in RELEASES.md (#3542)
and while at it, unify how to style links (include “RFC”, “issue” in the
link)
2024-02-29 10:52:26 +00:00
Marc Huisinga
970b6e59b1 doc: update RELEASES.md for #3460 and #3482 (#3527) 2024-02-29 10:42:54 +00:00
Joe Hendrix
b9f9ce874d chore: have library search drop star only symbols (#3534)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-29 07:09:02 +00:00
Scott Morrison
5a33091732 chore: restore %$tk 2024-02-29 17:34:15 +11:00
Scott Morrison
b762567174 chore: update stage0 2024-02-29 17:34:15 +11:00
Scott Morrison
819a32a9eb chore: upstream show_term
add missing prelude
2024-02-29 17:34:15 +11:00
Scott Morrison
755de48ff3 chore: upstream orphaned tests from Std (#3539) 2024-02-29 04:12:52 +00:00
Leonardo de Moura
37cd4cc996 fix: match-expression when patterns cover all cases of a BitVec finite type (#3538) 2024-02-29 02:24:47 +00:00
Leonardo de Moura
e53ae5d89e chore: remove leftovers (#3537) 2024-02-29 02:12:08 +00:00
Joe Hendrix
69e33efa2f chore: One sided BitVec.toNat equality lemmas (#3533) 2024-02-29 00:25:40 +00:00
Scott Morrison
973cbb186b chore: begin moving orphaned tests from Std (#3535) 2024-02-29 00:09:51 +00:00
Joe Hendrix
9afca1c3a9 feat: port check_tactic commands from Std and add test cases (#3532)
This also adds several Array lemmas from std after cleaning up proofs
2024-02-28 23:32:54 +00:00
Leonardo de Moura
e1acdcd339 fix: get_elem_tactic_trivial regression (#3531) 2024-02-28 23:14:15 +00:00
Scott Morrison
dc4c2b14d3 chore: begin moving orphaned tests from Std 2024-02-29 10:54:19 +11:00
Joe Hendrix
2312c15ac6 chore: port librarySearch tests from std (#3530)
Needed List.partitionMap for test to complete, so ported it too.
2024-02-28 17:24:17 +00:00
Joachim Breitner
fa058ed228 fix: include let bindings when determining altParamNums for eliminators (#3505)
Else the `case` will now allow introducing all necessary variables.

Induction principles with `let` in the types of the cases will be more
common with #3432.

This implementation no longer reduces the type as it goes, but really
only counts
manifest foralls and lets. I find this more sensible and predictable: If
you have
```
theorem induction₂_symm {P : EReal → EReal → Prop} (symm : Symmetric P) …
```
then previously, writing
```
case symm => 
```
would actually bring a fresh `x` and `y` and variable `h : P x y` into
scope and produce a
goal of `P y x`, because `Symmetric P` happens to be
```
def Symmetric := ∀ ⦃x y⦄, x ≺ y → y ≺ x
```

After this change, after `case symm =>` will leave `Symmetric P` as the
goal.

This gives more control to the author of the induction hypothesis about
the actual
goal of the cases. This shows up in mathlib in two places; fixes in
https://github.com/leanprover-community/mathlib4/pull/11023.
I consider these improvements.
2024-02-28 13:14:34 +00:00
Lean stage0 autoupdater
17b8880983 chore: update stage0 2024-02-28 11:50:07 +00:00
Joachim Breitner
b9c4a7e51d feat: termination_by? (#3514)
the user can now write `termination_by?` to see the termination argument
inferred by GuessLex, and turn it into `termination_by …` using the “Try
this” widget or a code action.

To be done later, maybe: Avoid writing `sizeOf` if it's not necessary.
2024-02-28 10:53:17 +00:00
Kyle Miller
08e149de15 fix: make omission syntax be a builtin syntax (part 2)
Re-enables `⋯` processing that was disabled during the move to a builtin.
Adds tests.
2024-02-28 09:23:17 +01:00
Kyle Miller
37fd128f9f chore: update stage0 2024-02-28 09:23:17 +01:00
Kyle Miller
a3226d4fe4 fix: make omission syntax be a builtin syntax
When editing core Lean, the `pp.proofs` feature causes goal states to fail to display in the Infoview, instead showing only "error when printing message: unknown constant '«term⋯»'". This PR moves the `⋯` syntax from Init.NotationExtra to Lean.Elab.BuiltinTerm

It also makes it so that `⋯` elaborates as `_` while logging a warning, rather than throwing an error, which should be somewhat more friendly when copy/pasting from the Infoview.

Closes #3476
2024-02-28 09:23:17 +01:00
Leonardo de Moura
a23292f049 feat: add option tactic.skipAssignedInstances := true for backward compatibilty (#3526)
When using `set_option tactic.skipAssignedInstances false`, `simp` and
`rw` will synthesize instance implicit arguments even if they have
assigned by unification. If the synthesized argument does not match the
assigned one the rewrite is not performed. This option has been added
for backward compatibility.
2024-02-28 05:52:29 +00:00
Siddharth
d683643755 feat: add intMax (#3492) 2024-02-28 05:43:22 +00:00
Scott Morrison
7cce64ee70 feat: omega doesn't check for defeq atoms (#3525)
```
example (a : Nat) :
    (((a + (2 ^ 64 - 1)) % 2 ^ 64 + 1) * 8 - 1 - (a + (2 ^ 64 - 1)) % 2 ^ 64 * 8 + 1) = 8 := by
  omega
```
used to time out, and now is fast.

(We will probably make separate changes later so the defeq checks would
be fast in any case here.)
2024-02-28 05:41:29 +00:00
Leonardo de Moura
86ca8e32c6 feat: improve simp discharge trace messages (#3523) 2024-02-28 04:39:57 +00:00
Mac Malone
a179469061 fix: lake: detection of custom Lake build dir (#3506)
During the switch to `.lake`, I overlooked updating the paths in
`LakeInstall`. This fixes that and helps prevent further mistakes by
using the same default definitions as the package configuration itself.
2024-02-28 00:34:51 +00:00
Leonardo de Moura
aed29525ab fix: simp trace issues (#3522) 2024-02-27 23:19:25 +00:00
Kyle Miller
6e24a08907 feat: improve error messages and docstring for decide tactic (#3422)
The `decide` tactic produces error messages that users find to be
obscure. Now:
1. If the `Decidable` instance reduces to `isFalse`, it reports that
`decide` failed because the proposition is false.
2. If the `Decidable` instance fails to reduce, it explains what
proposition it failed for, and it shows the reduced `Decidable` instance
rather than the `Decidable.decide` expression. That expression tends to
be less useful since it shows the unreduced `Decidable` argument (plus
it's a lot longer!)

Examples:
```lean
example : 1 ≠ 1 := by decide
/-
tactic 'decide' proved that the proposition
  1 ≠ 1
is false
-/

opaque unknownProp : Prop

open scoped Classical in
example : unknownProp := by decide
/-
tactic 'decide' failed for proposition
  unknownProp
since its 'Decidable' instance reduced to
  Classical.choice ⋯
rather than to the 'isTrue' constructor.
-/
```

When reporting the error, `decide` only shows the whnf of the
`Decidable` instance. In the future we could consider having it reduce
all decidable instances present in the term, which can help with
determining the cause of failure (this was explored in
8cede580690faa5ce18683f168838b08b372bacb).
2024-02-27 23:07:38 +00:00
Kyle Miller
321ef5b956 fix: make Lean.Internal.liftCoeM and Lean.Internal.coeM unfold (#3404)
The elaboration function `Lean.Meta.coerceMonadLift?` inserts these
coercion helper functions into a term and tries to unfolded them with
`expandCoe`, but because that function only unfolds up to
reducible-and-instance transparency, these functions were not being
unfolded. The fix here is to give them the `@[reducible]` attribute.
2024-02-27 22:17:46 +00:00
Joachim Breitner
9c00a59339 feat: use omega in default decreasing_trivial (#3503)
with this, more functions will be proven terminating automatically,
namely those where after `simp_wf`, lexicographic order handling,
possibly `subst_vars` the remaining goal can be solved by `omega`.

Note that `simp_wf` already does simplification of the goal, so
this adds `omega`, not `(try simp) <;> omega` here.

There are certainly cases where `(try simp) <;> omega` will solve more 
goals (e.g. due to the `subst_vars` in `decreasing_with`), and
`(try simp at *) <;> omega` even more. This PR errs on the side of
taking
smaller steps.

Just appending `<;> omega` to the existing
`simp (config := { arith := true, failIfUnchanged := false })` call
doesn’t work nicely, as that leaves forms like `Nat.sub` in the goal
that
`omega` does not seem to recognize.

This does *not* remove any of the existing ad-hoc `decreasing_trivial`
rules based on `apply` and `assumption`, to not regress over the status
quo (these rules may apply in cases where `omega` wouldn't “see”
everything, but `apply` due to defeq works).

Additionally, just extending makes bootstrapping easier; early in `Init`
where
`omega` does not work yet these other tactics can still be used.

(Using a single `omega`-based tactic was tried in #3478 but isn’t quite
possible yet, and will be postponed until we have better automation
including forward reasoning.)
2024-02-27 18:53:36 +00:00
Joachim Breitner
d7ee5ba1cb feat: use omega in the get_elem tactic (#3515)
with this, hopefully more obvious array accesses will be handled
automatically.

Just like #3503, this PR does not investiate which of the exitsting
tactics in `get_elem_tactic_trivial` are subsumed now and could be
dropped without (too much) breakage.
2024-02-27 18:52:04 +00:00
Sebastian Ullrich
850bfe521c doc: split interface/implementation docs on ite (#3517)
The second part is an implementation notice, as evidenced by the
reference to "users".
2024-02-27 18:50:31 +00:00
Leonardo de Moura
855fbed024 fix: regression on match expressions with builtin literals (#3521) 2024-02-27 18:49:44 +00:00
Scott Morrison
2e4557dbd0 chore: default for librarySearch tactic argument (#3495)
There's a downstream tactic in Mathlib that calls `librarySearch`, and
it's easier it is has a default provided.
2024-02-27 14:53:25 +00:00
Lean stage0 autoupdater
7d5b6cf097 chore: update stage0 2024-02-27 10:00:46 +00:00
Kyle Miller
6e408ee402 feat: apply app unexpanders for all prefixes of an application (#3375)
Before, app unexpanders would only be applied to entire applications.
However, some notations produce functions, and these functions can be
given additional arguments. The solution so far has been to write app
unexpanders so that they can take an arbitrary number of additional
arguments. However, as reported in [this Zulip
thread](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/pretty.20printer.20bug/near/420662236),
this leads to misleading hover information in the Infoview. For example,
while `HAdd.hAdd f g 1` pretty prints as `(f + g) 1`, hovering over `f +
g` shows `f`. There is no way to fix the situation from within an app
unexpander; the expression position for `HAdd.hAdd f g` is absent, and
app unexpanders cannot register TermInfo.

This commit changes the app delaborator to try running app unexpanders
on every prefix of an application, from longest to shortest prefix. For
efficiency, it is careful to only try this when app delaborators do in
fact exist for the head constant, and it also ensures arguments are only
delaborated once. Then, in `(f + g) 1`, the `f + g` gets TermInfo
registered for that subexpression, making it properly hoverable.

The app delaborator is also refactored, and there are some bug fixes:
- app unexpanders only run when `pp.explicit` is false
- trailing parameters in under-applied applications are now only
considered up to reducible & instance transparency, which lets, for
example, optional arguments for `IO`-valued functions to be omitted.
(`IO` is a reader monad, so it's hiding a pi type)
- app unexpanders will no longer run for delaborators that use
`withOverApp`
- auto parameters now always pretty print, since we are not verifying
that the provided argument equals the result of evaluating the tactic

Furthermore, the `notation` command has been modified to generate an app
unexpander that relies on the app delaborator's new behavior.

The change to app unexpanders is reverse-compatible, but it's
recommended to update `@[app_unexpander]`s in downstream projects so
that they no longer handle overapplication themselves.
2024-02-27 07:04:17 +00:00
Leonardo de Moura
c5fd88f5e1 feat: set literal unexpander (#3513) 2024-02-27 03:02:41 +00:00
Leonardo de Moura
d6df1ec32f fix: register builtin rpc methods (#3512) 2024-02-27 00:15:21 +00:00
Leonardo de Moura
5e101cf983 feat: use attribute command to add and erase simprocs (#3511) 2024-02-26 23:41:49 +00:00
Leonardo de Moura
bb0695b017 fix: simp? should track unfolded let-decls (#3510)
closes #3501
2024-02-26 20:49:24 +00:00
Leonardo de Moura
4a14ea3a5c fix: rewrite tactic should not try to synthesize instances that have been inferred by unification (#3509) 2024-02-26 20:18:07 +00:00
Leonardo de Moura
f0b4902f7a fix: simp should not try to synthesize instance implicit arguments that have been inferred by unification (#3507) 2024-02-26 20:17:55 +00:00
Mac Malone
e73495e5a6 fix: lake: warn on fetch cloud release failure (#3401)
If Lake fails to download a cloud release, it will now print a warning
indicating that it is falling back to a local build. For example:

```
[0/2] Downloading cloud_test cloud release
[0/2] Building CloudTest
error: > curl -s -f -o [...] -L [...]
error: external command `curl` exited with code 22
warning: fetching cloud release failed; falling back to local build
```
2024-02-26 13:55:19 +00:00
Leonardo de Moura
17fb8664f8 fix: issue when matching Int literals (#3504) 2024-02-26 13:09:07 +00:00
Sebastian Ullrich
992000a672 fix: C++ exceptions across shared libraries on Linux (#3500)
Server interruptions in C++ started to fail after #3421
2024-02-26 10:35:11 +00:00
Marc Huisinga
eb48e6908b feat: sorted call hierarchy items & no private prefix (#3482)
Sorts call hierarchy items and strips the private prefix to make the
call hierarchy more readable.
2024-02-26 09:43:47 +00:00
Marc Huisinga
a929c0176d fix: auto-completion bugs and performance (#3460)
This PR addresses several performance issues in the auto-completion
implementation. It also fixes a number of smaller bugs related to
auto-completion.

In a file with `import Mathlib`, the performance of various kinds of
completions has improved as follows:
- Completing `C`: 49000ms -> 1400ms
- Completing `Cat`: 14300ms -> 1000ms
- Completing `x.` for `x : Nat`: 3700ms -> 220ms
- Completing `.` for an expected type of `Nat`: 11000ms -> 180ms

The following bugs have been fixed as well:
- VS Code never used our custom completion order. Now, the server fuzzy
completion score decides the order that completions appear in.
- Dot auto-completion for private types did not work at all. It does
now.
- Completing `.<identifier>` (where the expected type is used to infer
the namespace) did not filter by the expected type and instead displayed
all matching constants in the respective namespace. Now, it uses the
expected type for filtering. Note that this is not perfect because
sub-namespaces are technically correct completions as well (e.g.
`.Foo.foobar`). Implementing this is future work.
- Completing `.` was often not possible at all. Now, as long as the `.`
is not used in a bracket (where it may be used for the anonymous lambda
feature, e.g. `(. + 1)`), it triggers the correct completion.
-  Fixes #3228.
- The auto-completion in `#check` commands would always try to complete
identifiers using the full declaration name (including namespaces) if it
could be resolved. Now it simply uses the identifier itself in case
users want to complete this identifier to another identifier.

## Details

Regarding completion performance, I have more ideas on how to improve it
further in the future.

Other changes:
- The feature that completions with a matching expected type are sorted
to the top of the server-side ordering was removed. This was never
enabled in VS Code because it would use its own completion item order
and when testing it I found it to be more confusing than useful.
- In the server-side ordering, we would always display keywords at the
top of the list. They are now displayed according to their fuzzy match
score as well.

The following approaches have been used to improve performance:
- Pretty-printing the type for every single completion made up a
significant amount of the time needed to compute the completions. We now
do not pretty-print the type for every single completion that is offered
to the user anymore. Instead, the language server now supports
`completionItem/resolve` requests to compute the type lazily when the
user selects a completion item.
- Note that we need to keep the amount of properties that we compute in
a resolve request to a minimum. When the server receives the resolve
request, the document state may have changed from the state it was in
when the initial auto-completion request was received. LSP doesn't tell
us when it will stop sending resolve requests, so we cannot keep this
state around, as we would have to keep it around forever.
LSP's solution for this dilemma is to have servers send all the state
they need to compute a response to a resolve request to the client as
part of the initial auto completion response (which then sends it back
as part of the resolve request), but this is clearly infeasible for all
real language servers where the amount of state needed to resolve a
request is massive.
This means that the only practical solution is to use the current state
to compute a response to the resolve request, which may yield an
incorrect result. This scenario can especially occur when using
LiveShare where the document is edited by another person while cycling
through available completions.
- Request handlers can now specify a "header caching handler" that is
called after elaborating the header of a file. Request handlers can use
this caching handler to compute caches for information stored in the
header. The auto-completion uses this to pre-compute non-blacklisted
imported declarations, which in turn allow us to iterate only over
non-blacklisted imported declarations where we would before iterate over
all declarations in the environment. This is significant because
blacklisted declarations make up about 4/5 of all declarations.
- Dot completion now looks up names modulo private prefixes to figure
out whether a declaration is in the namespace of the type to the left of
the dot instead of first stripping the private prefix from the name and
then comparing it. This has the benefit that we do not need to scan the
full name in most cases.

This PR also adds a couple of regression tests for fixed bugs, but *no
benchmarks*. We will add these in the future when we add proper support
for benchmarking server interaction sessions to our benchmarking
architecture.

All tests that were broken by producing different completion output
(empty `detail` field, added `sortText?` and `data?` fields) have been
manually checked by me to be still correct before replacing their
expected output.
2024-02-26 09:43:19 +00:00
Leonardo de Moura
88fbe2e531 chore: missing prelude 2024-02-25 11:44:42 -08:00
Leonardo de Moura
b9b7f97d42 chore: update stage0 2024-02-25 11:44:42 -08:00
Leonardo de Moura
c96f815137 fix: command_code_action initialization 2024-02-25 11:44:42 -08:00
Leonardo de Moura
bc8511ccbf chore: builtin_command_code_action for #guard_msgs 2024-02-25 11:44:42 -08:00
Leonardo de Moura
bfb981d465 chore: update stage0 2024-02-25 11:44:42 -08:00
Leonardo de Moura
48a9a99a97 feat: add builtin_command_code_action attribute 2024-02-25 11:44:42 -08:00
Leonardo de Moura
365243e9a3 chore: code_action_provider => builtin_code_action_provider 2024-02-25 11:44:42 -08:00
Leonardo de Moura
ade3256625 chore: remove workaround 2024-02-25 11:44:42 -08:00
Leonardo de Moura
02e4fe0b1c chore: update stage0 2024-02-25 11:44:42 -08:00
Leonardo de Moura
5514b8f1fd chore: move command_code_action attribute syntax to Init 2024-02-25 11:44:42 -08:00
Leonardo de Moura
2edde7b376 chore: initialize => builtin_initialize 2024-02-25 11:44:42 -08:00
Scott Morrison
3dd10654e1 chore: upstream Std.CodeAction.*
Remove tactic_code_action

rearrange

oops

.

add tests

import file

Update src/Lean/Elab/Tactic/GuardMsgs.lean

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>

Update src/Lean/Elab/Tactic/GuardMsgs.lean

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>

fix namespace

move GuardMsgs

cleanup
2024-02-25 11:44:42 -08:00
Leonardo de Moura
72d233d181 fix: match patterns containing int values and constructors (#3496) 2024-02-25 17:44:08 +00:00
Leonardo de Moura
9e5e0e23b2 perf: mkSplitterProof 2024-02-24 16:08:07 -08:00
Leonardo de Moura
33bc46d1a7 fix: complete Fin match 2024-02-24 16:08:07 -08:00
Leonardo de Moura
056cb75ee0 fix: match literal pattern support
The equation lemmas were not using the standard representation for literals.
2024-02-24 16:08:07 -08:00
Leonardo de Moura
66be8b9d4c fix: ToExpr instance for Fin 2024-02-24 16:08:07 -08:00
Leonardo de Moura
6d569aa7b5 refactor: use LitValue.lean to implement simprocs 2024-02-24 16:08:07 -08:00
Leonardo de Moura
335fef4396 feat: add helper functions for recognizing builtin literals 2024-02-24 16:08:07 -08:00
Sebastian Ullrich
a3596d953d fix: clean build after update-stage0 (#3491) 2024-02-24 15:54:50 +00:00
Leonardo de Moura
5b15e1a9f3 fix: disable USize simprocs (#3488) 2024-02-24 02:37:39 +00:00
Leonardo de Moura
d179d6c8d7 perf: bitvector literals in match patterns (#3485) 2024-02-24 00:38:46 +00:00
Leonardo de Moura
3ead33bd13 chore: isNatLit => isRawNatLit 2024-02-23 15:18:30 -08:00
Leonardo de Moura
51fe66b9eb test: toExpr tests 2024-02-23 15:16:12 -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
Leonardo de Moura
2defc58159 chore: rename isNatLit => isRawNatLit
Motivation: consistency with `mkRawNatLit`
2024-02-23 15:16:12 -08:00
Leonardo de Moura
338aa5aa7c fix: Std.BitVec occurrences at OmegaM.lean 2024-02-23 15:15:57 -08:00
Leonardo de Moura
4d4b79757d chore: move BitVec to top level namespace
Motivation: `Nat`, `Int`, `Fin`, `UInt??` are already in the top level
namespace. We will eventually define `UInt??` and `Int??` using `BitVec`.
2024-02-23 15:15:57 -08:00
Joe Hendrix
710c3ae9e8 chore: upstream exact? and apply? from Std (#3447)
This is still a draft PR, but includes the core exact? and apply?
tactics.

Still need to convert to builtin syntax and test on Std.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-23 21:55:24 +00:00
Joachim Breitner
87e7c666e2 refactor: drop sizeOf_get_lt, duplicate of sizeOf_get (#3481) 2024-02-23 18:43:28 +00:00
Sebastian Ullrich
60f30a46cf chore: CI: typo 2024-02-23 18:23:00 +01:00
Joachim Breitner
6c828ee9eb doc: fix references to Std.Tactic.Omega in comments (#3479) 2024-02-23 16:05:32 +00:00
Sebastian Ullrich
4d94147643 chore: build Lean in parallel to Init (#3455)
A, for now, less problematic subset of #3103
2024-02-23 10:44:58 +00:00
Wojciech Nawrocki
9dfb93bbe9 fix: unnecessary map (#3470)
This came up while looking into cancelling RPC requests. It turns out
that `IO.cancel (Task.map t f)` does *not* cancel `t` (see
[here](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Should.20cancelling.20a.20purely.20mapped.20task.20cancel.20the.20original.3F)),
so it is important to avoid mapping here. It also turns out that the
`map` is completely unnecessary: it lifts from `Except` to `Except`. So
while from the cancellation perspective this is perhaps more of a
bandaid than a solution, it at least doesn't hurt.
2024-02-23 09:27:57 +00:00
Sebastian Ullrich
8bf9d398af chore: CI: flag Lean modules not using prelude (#3463)
Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-02-23 08:06:55 +00: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
Alex Keizer
b9b4d8f41d feat: add BitVec.toNat_concat (#3471)
Make `x.toNat * 2 + b.toNat` the simp normal form of `(concat x
b).toNat`.

The choice for multiplication and addition was inspired by `Nat.bit_val`
from Mathlib.
Also, because we have considerably more lemmas about multiplication and
`_ + 1` than about shifts and `_ ||| 1`.
2024-02-23 02:16:01 +00:00
Scott Morrison
4e87d7f173 chore: rename Bool.toNat_le_one (#3469)
To merge after #3457.

---------

Co-authored-by: Alex Keizer <alex@keizer.dev>
2024-02-23 02:07:18 +00:00
Siddharth
e17e0d36a7 feat: omega uses b^(e+1) = b^e*b when b constant (#3450)
This is very helpful when dealing with bitvectors, where a case analysis
on the bitwidth leaves one with hypotheses of the form `x<2^(Nat.succ
w)`.

Design decisions I am unsure about:
- Is creating a helper `succ?` the correct way to match on the exponent
`e+1`?
- I'm not certain why the prior call to `Int.ofNat_pow` also checked
that the exponent was a ground natural. I removed this, since we now
explicitly handle cases where the exponent is a term of the form `e+1`.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Joe Hendrix <joe@lean-fro.org>
Co-authored-by: Alex Keizer <alex@keizer.dev>
2024-02-23 01:17:03 +00:00
Alex Keizer
8bf6475e10 feat: add BitVec.getLsb_concat (#3457)
First (baby)-step to a `concat`-based `bitblast`: a characterization of
`concat` in terms of `getLsb`.

The proof might benefit slightly from a `toNat_concat` lemma, but I
wasn't sure what the normal form there should be, so I avoided it.

---------

Co-authored-by: Scott Morrison <scott@tqft.net>
2024-02-23 00:58:27 +00:00
Scott Morrison
7f7d9bdaaf chore: cleanup in BitVec/Bitblast.lean (#3468) 2024-02-23 00:47:30 +00:00
Scott Morrison
0824442a6f chore: remove @[simp] from some new BitVec lemmas (#3466) 2024-02-23 00:26:06 +00:00
Alex Keizer
815200eaad refactor: make BitVec.carry take bitvector arguments (#3461)
Every usage of `carry` followed the pattern: `carry _ x.toNat y.toNat`,
so we've refactorod `carry` to take the `BitVec`s as arguments, and made
the `toNat` part of its definition.
2024-02-22 19:25:01 +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
53146db620 fix: zetaDelta := false regression (#3459)
See new test. It is a mwe for an issue blocking Mathlib.
2024-02-22 19:10:02 +00:00
Joachim Breitner
23d3ac4760 refactor: reduced unsed imports (#3464) 2024-02-22 18:12:57 +00:00
Joachim Breitner
5bbc54429f fix: improve error message when termination argument is too dependent (#3414)
this may help users when they face #2260

fixes #2260
2024-02-22 16:39:26 +00:00
Joachim Breitner
b27ab5e25d refactor: module MatcherApp.Transform (#3439)
PR #3432 will introduce more operations on `MatcherApp`, including somet
that have more dependencies.

This change prepares by introducing `Lean.Meta.Match.MatcherApp.Basic`
for the basic definition, and `Lean.Meta.MatcherApp.Transform` for the
transformations, currently `addArg` and `refineThrough`, but more to
come.
2024-02-22 16:16:26 +00:00
Scott Morrison
47595540bb chore: more List lemmas for auto (#3454) 2024-02-22 06:23:50 -08:00
Scott Morrison
aa0f43e9a1 chore: namespacing in solve_by_elim (#3453) 2024-02-22 06:23:50 -08:00
Alex Keizer
997ae402da feat: show basic properties of BitVec multiplication (#3445)
Show that multiplication of bitvectors is associative and commutative,
and show that it has 1#w as identity (both on the left and right).
2024-02-22 06:23:50 -08:00
Joe Hendrix
61c22c88d7 chore: address copyright inconsistencies (#3448) 2024-02-22 06:23:50 -08:00
Scott Morrison
629b7d0fdd chore: add bv_toNat attributes 2024-02-22 06:23:38 -08:00
Scott Morrison
46df6142a6 chore: update stage0 2024-02-22 06:23:26 -08:00
Scott Morrison
2b1a0371c6 feat: add bv_omega tactic 2024-02-22 06:23:13 -08:00
Siddharth
b6ed97bb3d feat: setup simp lemmas: 'msb -> getLsb -> decide ...' (#3436)
This is a follow up to 'https://github.com/leanprover/std4/pull/645',
where the simp lemmas were requested:
https://github.com/leanprover/std4/pull/645#issuecomment-1944862251

---

Note that @semorrison asked to use `(Fin.last _)` to index. Now that we
use a `Nat` to index `msb` , the pattern `(Fin.last _)` would not have
the width be automatically inferred. Therefore, I've changed the
definitions to use `Nat` for indexing.

---------

Co-authored-by: Siddharth Bhat Mala <sb2743@cl.cam.ac.uk>
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-22 00:07:14 +00:00
Phil de Joux
9a970611ca doc: correct typo "can calls" (#3446)
Fixes a minor typo.
2024-02-21 22:31:02 +00:00
Joe Hendrix
6e821de11a chore: update stage0 2024-02-21 21:58:54 +01:00
Joe Hendrix
db3c1d4e7e chore: make server completion predicate not private 2024-02-21 21:58:54 +01:00
Leonardo de Moura
4d0c0e2328 fix: allow users to disable builtin simprocs in simp args (#3441) 2024-02-21 20:01:11 +00:00
Leonardo de Moura
e5d2cbceaa fix: structural equation proof generator (#3444)
See new test.
2024-02-21 19:42:39 +00:00
Leonardo de Moura
ddd6342737 fix: support for Fin and BitVec literal normalization (#3443) 2024-02-21 19:05:47 +00:00
Joe Hendrix
75272cb157 feat: BitVec.ofNatLt and updates to use it (#3430)
This PR is an effort to improve reasoning at the Nat level about
bitvectors and reduce of Fin and Nat.

It slightly tightens some proofs, but is generally aimed at reducing
inconsistencies between definitions at the Nat and Fin types in favor of
more consistently using Nat operations.

This ports leanprover/std4#664 to Lean core.

Here was the rational I provided in the discussion for
leanprover/std4#664:

It's mostly about consistency. If we use the same types and style in
definitions and proofs, there is less surprise when unfolding or
otherwise using definitions. We use some Nat based operations that
haven't been extended to Fin such as the bitwise operations, and I don't
want to pay the overhead of introducing a Fin version of every Bitvector
operation.
So this basically means Nat is preferred.

One argument potentially in favor of Fin is that we could reuse results
proven there, but that doesn't really seem to be the case so far.

A second argument is that we want to simplify expression to use more
canonical forms and we currently can pretty-print those operations
better using ofNat than ofFin. We could define the notations using ofFin
of course though, but that's additional operators that will show up in
expressions.
2024-02-21 18:02:56 +00:00
Leonardo de Moura
d55bab41bb feat: Int.toNat simproc (#3440) 2024-02-21 17:12:14 +00:00
Lean stage0 autoupdater
71cfbb26de chore: update stage0 2024-02-21 15:19:07 +00:00
David Thrane Christiansen
74e7886ce7 feat: custom error recovery in parser (#3413)
Adds a simple error-recovery mechanism to Lean's parser, similar to
those used in other combinator parsing libraries.

Lean itself isn't very amenable to error recovery with this mechanism,
as it requires global knowledge of the grammar in question to write
recovery rules that don't break backtracking or `<|>`. I only found a
few opportunities.

But for DSLs, this is really important. In particular, Verso parse
errors interacted very badly with Lean parse errors in a way that
required frequent "restart file" commands, but this mechanism allows me
to both recover from Verso parse errors and to have Lean skip the rest
of the file rather than repeatedly trying to parse it as Lean commands.
2024-02-21 14:29:54 +00:00
Leonardo de Moura
0fb936158b chore: explicit DecidableEq instance for BitVec (#3438) 2024-02-21 13:37:00 +00:00
Scott Morrison
cc8adfb2a5 feat: support for Fin in omega (#3427) 2024-02-21 13:09:38 +00:00
Leonardo de Moura
a0089d4667 fix: match pattern missing test 2024-02-21 05:14:26 -08:00
Scott Morrison
29b589a867 chore: add @[simp] to BitVec.toNat_mul (#3434) 2024-02-21 11:57:12 +00:00
Scott Morrison
f76bb2495b feat: omega handles shift operators, and normalises ground term exponentials (#3433)
This is a preliminary to a BitVec frontend for `omega`.
2024-02-21 11:55:58 +00:00
Joe Hendrix
89490f648a fix: address symm and label bugs from #3408 (#3429)
#3408 was somewhat large and didn't properly test the symm and label
attribute code after edits to the builtin versions.

This migrates the code for generating labeled attributes from Init back
to Lean so that the required definitions are in scope.

This also addresses a mistake in the symm elaborator that prevented symm
without location information from elaborating.

Both fixes have been tested on the Std test suite and successfully
passed.
2024-02-21 07:21:07 +00:00
Scott Morrison
6719af350f chore: remove mkAppN macro in omega (#3428) 2024-02-21 05:11:37 +00:00
Scott Morrison
3d8f73380e chore: simplify decide (b = true) and variants (#3426)
```
@[simp] theorem decide_eq_true {b : Bool} : decide (b = true) = b := by cases b <;> simp
@[simp] theorem decide_eq_false {b : Bool} : decide (b = false) = !b := by cases b <;> simp
@[simp] theorem decide_true_eq {b : Bool} : decide (true = b) = b := by cases b <;> simp
@[simp] theorem decide_false_eq {b : Bool} : decide (false = b) = !b := by cases b <;> simp
```
2024-02-21 04:30:25 +00:00
Scott Morrison
959ad98861 fix: bug in omega's elimination selection (#3425)
Silly bug that was resulting in unnecessary inexact eliminations. I'm
surprised this hasn't already been biting users.
2024-02-21 01:46:08 +00:00
Joe Hendrix
29244f32f6 chore: upstream solve_by_elim (#3408)
This upstreams the solve_by_elim tactic from Std.

It is a key tactic needed by library_search.
2024-02-21 01:16:04 +00:00
Scott Morrison
09cfcefb25 chore: upstream List.get?_append (#3424)
This suffices to get `lean-auto` off Std. (At least, `lake build` works.
Their test suite is [not
automated](https://github.com/leanprover-community/lean-auto/issues/21)?)
2024-02-20 23:53:41 +00:00
Sebastian Ullrich
c9aea32d3e chore: speedcenter: count max symbols in shared libraries (#3418) 2024-02-20 19:25:24 +00:00
Eric Wieser
07f490513c doc: fix confusing language in Expr.isProp (#3420)
`True` "is *a* `Prop`", but this function actually returns whether
something *is* `Prop`.
2024-02-20 16:08:28 +00:00
Leonardo de Moura
928f3e434e chore: add norm_cast_add_elim ne_eq
Recall that `add_elim` was a local command in Std
2024-02-20 07:00:47 -08:00
Leonardo de Moura
855a762bcb chore: update stage0 2024-02-20 07:00:47 -08:00
Leonardo de Moura
e1c176543a feat: add command norm_cast_add_elim 2024-02-20 07:00:47 -08:00
Leonardo de Moura
15be8fc2a6 fix: builtin_initialize at pushCastExt 2024-02-20 07:00:47 -08:00
Scott Morrison
28a02a8688 chore: upstream norm_cast attributes and tests 2024-02-20 07:00:47 -08:00
Adrien Champion
a898aa18f3 chore: add documentation for the String.iterator API (#3300)
Adds documentation to the `String.Iterator` API, mentored by
@eric-wieser and @david-christiansen

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-20 13:31:27 +00:00
Joachim Breitner
263629d140 chore: pr-release to suggest a git rebase command (#3417) 2024-02-20 13:06:06 +00:00
Henrik Böving
b598c0fea9 doc: prelude convention in Lean (#3416) 2024-02-20 12:11:57 +00:00
Sebastian Ullrich
d0fb48b4e4 fix: use builtin code action for "try this" 2024-02-20 12:48:19 +01:00
Sebastian Ullrich
79a9f6759a chore: update stage0 2024-02-20 12:48:19 +01:00
Sebastian Ullrich
f1a3169424 fix: [builtin_code_action_provider] 2024-02-20 12:48:19 +01:00
Scott Morrison
4a7c1ea439 chore: upstream simp? 2024-02-20 12:48:19 +01:00
Scott Morrison
15cbcae7b2 chore: typo (#3415) 2024-02-20 10:40:59 +00:00
Scott Morrison
ea665de453 chore: CI checks for copyright headers (#3412)
Hopefully this will fail until #3411 is merged.
2024-02-20 07:02:50 +00:00
Scott Morrison
8b8e001794 chore: add missing copyright headers (#3411) 2024-02-20 01:49:55 +00:00
Scott Morrison
35e374350c chore: upstream norm_cast tactic (#3322)
This is a quite substantial tactic.

It also includes the infamour `NatCast` typeclass (which I've equipped
with a module-doc). I wasn't at all sure where that should live, so it
is currently randomly in `Lean/Elan/Tactic/NatCast.lean`: presumably if
we're doing this it will go somewhere in `Init`.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-19 17:49:17 -08:00
Leonardo de Moura
9e27e92eea chore: set literal notation (#3348)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-02-19 23:22:36 +00:00
Leonardo de Moura
489f2da711 feat: add simproc for BitVec.signExtend (#3409) 2024-02-19 15:15:37 -08:00
Leonardo de Moura
75d7bc0ef1 chore: disable test to fix build failure on Windows (#3410) 2024-02-19 15:15:26 -08:00
Leonardo de Moura
5d9552d66c feat: simprocs for BitVec (#3407) 2024-02-19 14:01:00 -08:00
Leonardo de Moura
067913bc36 chore: remove sorry 2024-02-19 13:01:44 -08:00
Leonardo de Moura
c23a35c472 chore: quick temporary fix 2024-02-19 12:53:25 -08:00
Leonardo de Moura
f64d14ea54 chore: update stage0 2024-02-19 12:47:04 -08:00
Leonardo de Moura
90b5a0011d feat: assume function application arguments occurring in local simp theorems have been annotated with no_index (#3406)
closes #2670
2024-02-19 12:43:34 -08:00
Scott Morrison
ca941249b9 chore: upstream Std.BitVec.* (#3400)
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-19 12:43:34 -08:00
Sebastian Ullrich
94a9ab45ff chore: Nix CI: stop pushing to cachix (#3402) 2024-02-19 16:41:20 +00:00
Joe Hendrix
e2b3b34d14 feat: introduce native functions for Int.ediv / Int.emod (#3376)
These still need tests, but I thought I'd upstream so I can use
benchmarking and check for build errors.
2024-02-19 15:04:51 +00:00
Sebastian Ullrich
204b408df7 chore: remove noisy root code owners 2024-02-19 17:30:21 +01:00
Lean stage0 autoupdater
7545b85512 chore: update stage0 2024-02-19 15:51:18 +00:00
Sebastian Ullrich
1d66c32d5f fix: weaken builtin widget collision check 2024-02-19 15:45:01 +00:00
Scott Morrison
7f08975176 chore: upstream simpa (#3396) 2024-02-19 13:37:34 +00:00
Sebastian Ullrich
0e0ed9ccaf fix: broken trace tree on elab runtime exception (#3371) 2024-02-19 11:15:23 +00:00
Sebastian Ullrich
59bf220934 chore: update stage0 2024-02-19 12:37:19 +01:00
Sebastian Ullrich
032a2ecaa1 chore: update builtin_widget_module registration code 2024-02-19 12:33:23 +01:00
Joachim Breitner
da24708ba5 refactor: use isAppOfArity (#3394) 2024-02-19 09:24:11 +00:00
Scott Morrison
16757bb256 chore: upstream Std.Data.Fin.Iterate (#3392) 2024-02-19 04:29:45 +00:00
Scott Morrison
3f548edcd7 chore: upstream (most of) Std.Data.Nat.Lemmas (#3391)
When updating Std, be careful that not every lemma has been upstreamed,
so we need to be careful to only delete things that have already been
declared.
2024-02-19 03:47:49 +00:00
Scott Morrison
8758c0adf5 chore: upstream Std.Data.Bool (#3389) 2024-02-19 02:44:07 +00:00
Scott Morrison
b41499cec1 chore: upstream Std.Data.Fin.Basic (#3390) 2024-02-19 02:16:17 +00:00
Scott Morrison
88deb34ddb chore: upstream omega (#3367)
Co-authored-by: Joe Hendrix <joe@lean-fro.org>
2024-02-19 00:19:55 +00:00
Sebastian Ullrich
5e5bdfba1a fix: savePanelWidgetInfo on @[builtin_widget_module] (#3329) 2024-02-18 22:47:30 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Leonardo de Moura
5ce20ba160 chore: add link to issue 2024-02-18 14:19:01 -08:00
Leonardo de Moura
aa42fc07d3 test: for issue #2843
closes #2843
2024-02-18 14:14:55 -08:00
Leonardo de Moura
bc74e6eb38 chore: update RELEASES.md 2024-02-18 14:14:55 -08:00
Leonardo de Moura
52f1fcc498 chore: remove workaround 2024-02-18 14:14:55 -08:00
Leonardo de Moura
a6cdc333d5 chore: fix tests 2024-02-18 14:14:55 -08:00
Leonardo de Moura
58ed6b9630 chore: update stage0 2024-02-18 14:14:55 -08:00
Leonardo de Moura
cd9648a61e fix: dsimp zeta bug
Before the `zeta` / `zetaDelta` split, `dsimp` was performing `zeta`
by going inside of a `let`-expression, performing `zetaDelta`, and
then removing the unused `let`-expression.
2024-02-18 14:14:55 -08:00
Leonardo de Moura
55ce5d570c chore: add temporary workaround 2024-02-18 14:14:55 -08:00
Leonardo de Moura
ead14987bc chore: set zetaDelta := true at simp_wf 2024-02-18 14:14:55 -08:00
Leonardo de Moura
834b515592 chore: update stage0 2024-02-18 14:14:55 -08:00
Leonardo de Moura
9fe72c5f95 chore: set zetaDelta := false by default in the simplifier 2024-02-18 14:14:55 -08:00
Leonardo de Moura
77de817960 chore: update stage0 2024-02-18 14:14:55 -08:00
Leonardo de Moura
457d33d660 feat: configuration options zeta and zetaDelta
TODO: bootstrapping issues, set `zetaDelta := false` in the simplifier.
2024-02-18 14:14:55 -08:00
Leonardo de Moura
b882ebcf4a chore: update stage0 2024-02-18 14:14:55 -08:00
Leonardo de Moura
602b1a0d15 feat: add zetaDelta configuration option 2024-02-18 14:14:55 -08:00
Joachim Breitner
17c7cb0e1c feat: conv => fun (#3240)
Given a target
```
| f a b
```
the new conv tactic
```
conv => fun
```
turns it into
```
| f a
```
and `arg 0` turns it into
```
| f
```

Fixes #3239
2024-02-18 12:02:25 +00:00
Scott Morrison
e206e53f4e chore: add @[simp] to Nat.sub_add_cancel (#3378) 2024-02-18 06:48:10 +00:00
Kyle Miller
d569ed4e5f feat: make loose fvars pretty print as _fvar.123 instead of _uniq.123 (#3380)
Loose fvars are never supposed to be pretty printed, but having them
print with "fvar" in the name can help with debugging broken tactics and
elaborators.

Metaprogramming users often do not realize at first that `_uniq.???` in
pretty printing output refers to fvars not in the current local context.
2024-02-18 01:53:37 +00:00
Kyle Miller
433c4d22c2 fix: exposeRelevantUniverses was inserting the whole expression into itself
This bug appeared in c9db8619f1
2024-02-17 17:53:19 -08:00
Leonardo de Moura
6383af0595 chore: update stage0 2024-02-17 17:51:24 -08:00
Leonardo de Moura
c8236ccd47 chore: basic simprocs for String 2024-02-17 17:51:24 -08:00
Leonardo de Moura
559a18874c chore: simprocs for Eq 2024-02-17 17:51:24 -08:00
Leonardo de Moura
3dcc8cab3e feat: simprocs for Char.val, default char, and Char.ofNatAux 2024-02-17 17:51:24 -08:00
Leonardo de Moura
fb18ef3688 feat: simprocs for UInt??.ofNatCore and UInt??.toNat 2024-02-17 17:51:24 -08:00
Leonardo de Moura
3e5695e07e feat: simprocs for Char (#3382) 2024-02-17 20:36:51 +00:00
Leonardo de Moura
61a76a814f feat: delaborator for Char literals (#3381) 2024-02-17 12:19:40 -08:00
Arthur Adjedj
0c92d17792 fix: instantiate the types of inductives with the right parameters (#3246)
Closes #3242
2024-02-17 16:52:28 +00:00
Joachim Breitner
d536534c4d refactor: drop CasesOnApp, use MatcherApp (#3369)
in all uses of `CasesOnApp`, we treat `MatcherApp`s the same way,
dupliating a fair amount of relatively hairy code (and there is more to
come).

However, the `MatcherApp` abstraction is perfectly capable of
also representing `casesOn` applications, at least for the use cases
encountered so far.

So lets just (optionally) include `casesOn` applications when looking
for matchers,
and remove the `CasesOnApp` abstraction completely.
2024-02-17 15:25:32 +00:00
Leonardo de Moura
97e7e668d6 chore: pp.proofs.withType is now false by default (#3379)
`pp.proofs.withType := true` often produces too much noise in the info
view.
2024-02-17 15:09:24 +00:00
Sebastian Ullrich
dda88c9926 feat: infoview.maxTraceChildren (#3370)
Incrementally unveil trace children for excessively large nodes to
improve infoview rendering time, adjust particularly chatty
`simp.ground` trace to make use of it.
2024-02-17 14:04:46 +00:00
Leonardo de Moura
ef9a6bb839 fix: an equation lemma with autoParam arguments fails to rewrite (#3316)
closes #2243
2024-02-17 13:42:34 +00:00
Leonardo de Moura
baa9fe5932 fix: simp gets stuck on autoParam (#3315)
closes #2862
2024-02-17 13:42:19 +00:00
Leonardo de Moura
368326fb48 fix: simp fails when custom discharger makes no progress (#3317)
closes #2634
2024-02-17 13:42:04 +00:00
Leonardo de Moura
678797b67b fix: simp fails to discharge autoParam premises even when it can reduce them to True (#3314)
closes #3257
2024-02-17 13:41:48 +00:00
Mac Malone
496a8d578e fix: lake: open config trace as read-only first & avoid deadlock (#3254)
Lake previously opened the configuration trace as read-write even if it
does not update the configuration. This meant it failed if the trace was
read-only. With this change, it now first acquires a read-only handle
and then, if and only if it determines the need for a reconfigure, does
it re-open the file with a read-write handle. Also, this change fixes a
potential deadlock (Lake will error instead) and generally clarifies the
trace locking code.
2024-02-17 04:20:14 +00:00
Mac Malone
3fb7262fe0 fix: cloud release trace & lake build :release errors (#3248)
Fixes a bug with Lake cloud releases where a cloud release would produce
a different trace if the package was the root of the workspace versus a
dependency. Also, an explicit fetch of a cloud release (e.g., via `lake
build :release`) will now error out with a non-zero exit code if it
fails to find, download, and unpack a release.
2024-02-17 00:18:10 +00:00
Joe Hendrix
8f010a6115 fix: liasolver benchmark bug introduced by #3364 (#3372)
This fixes a rounded division/mod bug introduced by the change in
semantics from Int.div to Int.mod in #3364.
2024-02-16 23:39:26 +00:00
Joachim Breitner
089cd50d00 refactor: let MatcherApp.addArg? check if argument was refined (#3368)
Previously, `CasesOn.addArg?` would do that check inline, while
`MatcherApp.addArg?` would do it after the fact.

Now `MatcherApp.addArg?` uses the same idiom.

Also, makes both `addArg?` always fail if the argument was not refined.

The work on functional induction principles calls for more unification
between the handling of `CasesOnApp` and `MatcherApp`, so this is a step
in that direction.
2024-02-16 15:35:19 +00:00
Scott Morrison
18afefda96 chore: upstream basic statements about inequalities (#3366) 2024-02-16 05:42:38 +00: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
Scott Morrison
c9f27c36a0 chore: upstream false_or_by_contra tactic (#3363)
Changes the goal to `False`, retaining as much information as possible:

* If the goal is `False`, do nothing.
* If the goal is an implication or a function type, introduce the
argument and restart.
  (In particular, if the goal is `x ≠ y`, introduce `x = y`.)
* Otherwise, for a propositional goal `P`, replace it with `¬ ¬ P`
(attempting to find a `Decidable` instance, but otherwise falling back
to working classically)
  and introduce `¬ P`.
* For a non-propositional goal use `False.elim`.
2024-02-16 03:58:10 +00:00
Scott Morrison
c9cba33f57 chore: upstream Expr.nat? and int? for recognising 'normal form' numerals (#3360)
`nat?` checks if an expression is a "natural number in normal form",
i.e. of the form `OfNat n`, where `n` matches `.lit (.natVal n)` for
some `n`.
and if so returns `n`.
2024-02-16 03:31:22 +00:00
Scott Morrison
84bd563cff chore: upstream Std's material on Ord and Ordering (#3365) 2024-02-16 02:57:47 +00:00
Scott Morrison
73524e37ae chore: upstream exfalso (#3361) 2024-02-16 02:21:32 +00:00
Scott Morrison
229f16f421 chore: upstream MVarId.applyConst (#3362)
Helper function for applying a constant to the goal, with fresh universe
metavariables.
2024-02-16 02:08:47 +00:00
Scott Morrison
eaf44d74ae chore: upstream Option material from Std (#3356) 2024-02-16 02:05:18 +00:00
Scott Morrison
6fc3ea7790 chore: upstream Expr.getAppFnArgs (#3359)
This is a widely used helper function in Std/Mathlib when matching on
expressions.

I've reordered some definitions to keep things together. This
introduces:
```
/-- Return the function (name) and arguments of an application. -/
def getAppFnArgs (e : Expr) : Name × Array Expr :=
  withApp e λ e a => (e.constName, a)
```
and 
```
/-- If the expression is a constant, return that name. Otherwise return `Name.anonymous`. -/
def constName (e : Expr) : Name :=
  e.constName?.getD Name.anonymous
```
2024-02-16 01:51:59 +00:00
Scott Morrison
a4e27d3090 chore: upstream HashSet.merge (#3357) 2024-02-16 01:38:16 +00:00
Joe Hendrix
1d9074c524 chore: upstream NatCast and IntCast (#3347)
This upstreams NatCast and IntCast alone independent of norm_cast in
#3322.

This will allow more efficiently upstreaming parts of Std.Data.Int
relevant for omega.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-16 00:54:22 +00:00
Kyle Miller
e29d75a961 feat: have pp.proofs use for omission (#3241)
By having the `pp.proofs` feature use `⋯` when omitting proofs, when
users copy/paste terms from the InfoView the elaborator can give an
error message explaining why the term cannot be elaborated.

Also adds `pp.proofs.threshold` option to allow users to pretty print
shallow proof terms. By default, only atomic proof terms are pretty
printed.

This adjustment was suggested in PR #3201, which added `⋯` and the
related `pp.deepTerms` option.
2024-02-15 21:49:41 +00:00
Kyle Miller
8aab74e65d fix: make withOverApp annotate the expression position and register TermInfo (#3327)
This makes it so that when `withOverApp` is handling overapplied
functions, the term produced by the supplied delaborator is hoverable in
the Infoview.
2024-02-15 17:40:54 +00:00
Sebastian Ullrich
4e58b428e9 doc: add Kyle Miller as delaborator code owner 2024-02-15 17:42:57 +01:00
Lean stage0 autoupdater
271ae5b8e5 chore: update stage0 2024-02-15 12:32:00 +00:00
Leonardo de Moura
a14bbbffb2 chore: add [ext] basic theorems, add test 2024-02-15 13:26:01 +01:00
Scott Morrison
5a95f91fae chore: update stage0 2024-02-15 13:26:01 +01:00
Scott Morrison
11727a415b chore: upstream ext
and_intros and subst_eqs are not builtin

clarify failure modes

Clarify docString of extCore

clarify

chore: builtin `subst_eqs` tactic

chore: builtin `ext`
2024-02-15 13:26:01 +01:00
Sebastian Ullrich
90a516de09 chore: avoid libleanshared symbol limit (#3346) 2024-02-15 11:39:44 +00:00
Scott Morrison
ae524d465f chore: a missing List lemma in Init (#3344) 2024-02-15 08:55:48 +00:00
Scott Morrison
9a3f0f1909 chore: upstream Std.Data.Array.Init.Lemmas (#3343) 2024-02-15 17:50:07 +11:00
Scott Morrison
fae5b2e87c chore: upstream Std.Data.List.Init.Lemmas (#3341) 2024-02-15 03:19:23 +00:00
Leonardo de Moura
2bd187044f chore: builtin haveI and letI 2024-02-15 14:33:36 +11:00
Scott Morrison
144c1bbbaf chore: update stage0 2024-02-15 14:33:36 +11:00
Scott Morrison
98085661c7 chore: upstream haveI tactic
chore: `haveI` and `letI` builtin parsers
2024-02-15 14:33:36 +11:00
Scott Morrison
9cea1a503e chore: upstream Std.Data.Prod.Lex (#3338) 2024-02-15 02:47:08 +00:00
Joe Hendrix
25147accc8 chore: upstream set notation (#3339)
This upstream Std Set notation except for [set
literals](1b4e6926f0/Std/Classes/SetNotation.lean (L115-L131)).
2024-02-15 02:08:45 +00:00
Scott Morrison
6048ba9832 chore: upstream Std.Classes.LawfulMonad (except SatisfiesM) (#3340) 2024-02-15 01:52:02 +00:00
Scott Morrison
33bb87cd1d chore: upstream Std.Data.Fin.Init.Lemmas (#3337) 2024-02-15 01:50:47 +00:00
Scott Morrison
4aa62a6a9c chore: upstream Std.Data.List.Init.Basic (#3335) 2024-02-15 01:50:33 +00:00
Joe Hendrix
eebdfdf87a chore: upstream of Std.Data.Nat.Init (#3331) 2024-02-15 00:18:41 +00:00
Leonardo de Moura
01c9f4c783 fix: run_meta macro (#3334) 2024-02-15 00:12:45 +00:00
Kyle Miller
a706c3b89a feat: delaboration collapses parent projections (#3326)
When projection functions are delaborated, intermediate parent
projections are no longer printed. For example, rather than pretty
printing as `o.toB.toA.x` with these `toB` and `toA` parent projections,
it pretty prints as `o.x`.

This feature is being upstreamed from mathlib.
2024-02-14 23:44:48 +00:00
Scott Morrison
329e00661a chore: upstream Std.Util.ExtendedBinders (#3320)
This is not a complete upstreaming of that file (it also supports `∀ᵉ (x
< 2) (y < 3), p x y` as shorthand for `∀ x < 2, ∀ y < 3, p x y`, but I
don't think we need this; it is used in Mathlib).

Syntaxes still need to be made built-in.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-14 11:36:00 +00:00
Joe Hendrix
8b0dd2e835 chore: upstream Std.Logic (#3312)
This will collect definitions from Std.Logic

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-14 09:40:55 +00:00
Leonardo de Moura
88a5d27d65 chore: upstream run_cmd and fixes bugs (#3324)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-14 04:15:28 +00:00
Scott Morrison
232b2b6300 chore: upstream replace tactic (#3321)
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-14 01:53:25 +00:00
Scott Morrison
fdc64def1b feat: upstream 'Try this:' widgets (#3266)
There is a test file in Std that should later be reunited with this
code.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-02-13 21:58:36 +00:00
Leonardo de Moura
644d4263f1 fix: #eval command was leaking auxiliary declarations into the environment (#3323) 2024-02-13 21:44:52 +00:00
Mario Carneiro
56d703db8e fix: trailing whitespace in location formatter (#3318)
This causes problems when used in conjunction with `#guard_msgs` (which
checks whitespace) and trailing whitespace removal. Discovered by
@PatrickMassot in verbose-lean4.
2024-02-13 15:53:29 +00:00
Henrik Böving
50d661610d perf: LLVM backend, put all allocas in the first BB to enable mem2reg (#3244)
Again co-developed with @bollu.

Based on top of: #3225 

While hunting down the performance discrepancy on qsort.lean between C
and LLVM we noticed there was a single, trivially optimizeable, alloca
(LLVM's stack memory allocation instruction) that had load/stores in the
hot code path. We then found:
https://groups.google.com/g/llvm-dev/c/e90HiFcFF7Y.

TLDR: `mem2reg`, the pass responsible for getting rid of allocas if
possible, only triggers on an alloca if it is in the first BB. The
allocas of the current implementation get put right at the location
where they are needed -> they are ignored by mem2reg.

Thus we decided to add functionality that allows us to push all allocas
up into the first BB.
We initially wanted to write `buildPrologueAlloca` in a `withReader`
style so:
1. get the current position of the builder
2. jump to first BB and do the thing
3. revert position to the original

However the LLVM C API does not expose an option to obtain the current
position of an IR builder. Thus we ended up at the current
implementation which resets the builder position to the end of the BB
that the function was called from. This is valid because we never
operate anywhere but the end of the current BB in the LLVM emitter.

The numbers on the qsort benchmark got improved by the change as
expected, however we are not fully there yet:
```
C:
Benchmark 1: ./qsort.lean.out 400
  Time (mean ± σ):      2.005 s ±  0.013 s    [User: 1.996 s, System: 0.003 s]
  Range (min … max):    1.993 s …  2.036 s    10 runs

LLVM before aligning the types
Benchmark 1: ./qsort.lean.out 400
  Time (mean ± σ):      2.151 s ±  0.007 s    [User: 2.146 s, System: 0.001 s]
  Range (min … max):    2.142 s …  2.161 s    10 runs

LLVM after aligning the types
Benchmark 1: ./qsort.lean.out 400
  Time (mean ± σ):      2.073 s ±  0.011 s    [User: 2.067 s, System: 0.002 s]
  Range (min … max):    2.060 s …  2.097 s    10 runs

LLVM after this
Benchmark 1: ./qsort.lean.out 400
  Time (mean ± σ):      2.038 s ±  0.009 s    [User: 2.032 s, System: 0.001 s]
  Range (min … max):    2.027 s …  2.052 s    10 runs
```

Note: If you wish to merge this PR independently from its predecessor,
there is no technical dependency between the two, I'm merely stacking
them so we can see the performance impacts of each more clearly.
2024-02-13 14:54:40 +00:00
Eric Wieser
0554ab39aa doc: Add a docstring to Simp.Result and its fields (#3319) 2024-02-13 13:57:24 +00:00
Scott Morrison
3a6ebd88bb chore: upstream repeat/split_ands/subst_eqs (#3305)
Small tactics used in the implementation of `ext`.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-13 12:21:14 +00:00
Henrik Böving
06f73d621b fix: type mismatches in the LLVM backend (#3225)
Debugged and authored in collaboration with @bollu.

This PR fixes several performance regressions of the LLVM backend
compared to the C backend
as described in #3192. We are now at the point where some benchmarks
from `tests/bench` achieve consistently equal and sometimes ever so
slightly better performance when using LLVM instead of C. However there
are still a few testcases where we are lacking behind ever so slightly.

The PR contains two changes:
1. Using the same types for `lean.h` runtime functions in the LLVM
backend as in `lean.h` it turns out that:
a) LLVM does not throw an error if we declare a function with a
different type than it actually has. This happened on multiple occasions
here, in particular when the function used `unsigned`, as it was
wrongfully assumed to be `size_t` sized.
b) Refuses to inline a function to the call site if such a type mismatch
occurs. This means that we did not inline important functionality such
as `lean_ctor_set` and were thus slowed down compared to the C backend
which did this correctly.
2. While developing this change we noticed that LLVM does treat the
following as invalid: Having a function declared with a certain type but
called with integers of a different type. However this will manifest in
completely nonsensical errors upon optimizing the bitcode file through
`leanc` such as:
```
error: Invalid record (Producer: 'LLVM15.0.7' Reader: 'LLVM 15.0.7')
```
Presumably because the generate .bc file is invalid in the first place.
Thus we added a call to `LLVMVerifyModule` before serializing the module
into a bitcode file. This ended producing the expected type errors from
LLVM an aborting the bitcode file generation as expected.

We manually checked each function in `lean.h` that is mentioned in
`EmitLLVM.lean` to make sure that all of their types align correctly
now.

Quick overview of the fast benchmarks as measured on my machine, 2 runs
of LLVM and 2 runs of C to get a feeling for how far the averages move:
- binarytrees: basically equal performance
- binarytrees.st: basically equal performance
- const_fold: equal if not slightly better for LLVM
- deriv: LLVM has 8% more instructions than C but same wall clock time
- liasolver: basically equal performance
- qsort: LLVM is slower by 7% instructions, 4% time. We have identified
why the generated code is slower (there is a store/load in a hot loop in
LLVM that is not in C) but not figured out why that happens/how to
address it.
- rbmap: LLVM has 3% less instructions and 13% less wall-clock time than
C (woop woop)
- rbmap_1 and rbmap_10 show similar behavior
- rbmap_fbip: LLVM has 2% more instructions but 2% better wall time
- rbmap_library: equal if not slightly better for LLVM
- unionfind: LLVM has 5% more instructions but 4% better wall time

Leaving out benchmarks related to the compiler itself as I was too lazy
to keep recompiling it from scratch until we are on a level with C.

Summing things up, it appears that LLVM has now caught up or surpassed
the C backend in the microbenchmarks for the most part. Next steps from
our side are:
- trying to win the qsort benchmark
- figuring out why/how LLVM runs more instructions for less wall-clock
time. My current guesses would be measurement noise and/or better use of
micro architecture?
- measuring the larger benchmarks as well
2024-02-13 10:57:35 +00:00
Scott Morrison
c27474341e chore: upstream change tactic (#3308)
We previously had the syntax for `change` and `change at`, but no
implementation.

This moves Kyle's implementation from Std.

This also changes the `changeLocalDecl` function to push nodes to the
infotree about FVar aliases.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-13 04:47:11 +00:00
Scott Morrison
27b962f14d chore: upstream liftCommandElabM (#3304)
These are used in the implementation of `ext`.
2024-02-13 04:17:19 +00:00
Scott Morrison
2032ffa3fc chore: DiscrTree helper functions (#3303)
`DiscrTree` helper functions from `Std`, used in `ext`, `exact?`, and
`aesop`.

(There are a few more to follow later, with other Std dependencies.)
2024-02-13 03:46:31 +00:00
Scott Morrison
c424d99cc9 chore: upstream left/right tactics (#3307)
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-02-13 03:45:59 +00:00
Mario Carneiro
fbedb79b46 fix: add_decl_doc should check that declarations are local (#3311)
This was causing a panic previously, [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/CI.20errors.20that.20are.20not.20local.20errors/near/420986393).
2024-02-12 12:04:51 +00:00
Eric Wieser
1965a022eb doc: fix typos around inductiveCheckResultingUniverse (#3309)
The unpaired backtick was causing weird formatting in vscode doc hovers.

Also closes an unpaired `(` in an error message.
2024-02-12 10:11:50 +00:00
Scott Morrison
90b08ef22e feat: upstream guard_expr (#3297)
Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-11 23:25:04 +00:00
Wojciech Nawrocki
66e8cb7966 doc: implicit type arguments are indexed in the discrtree (#3301)
A small fix to the `DiscrTree` documentation to reflect the fact that
implicit type arguments *are* indexed and do not become `star` or
`other`. The following is a reproduction:
```lean
import Lean
open Lean Meta Elab Tactic

elab "test_tac" t:term : tactic => do
  Tactic.withMainContext do
    let e ← Term.elabTerm t none
    let a : DiscrTree Nat ← DiscrTree.empty.insert e 1 {}
    logInfo m!"{a}"

example (α : Type) (ringAdd : Add α) : True := by
  /- (Add.add => (node (Nat => (node (* => (node (0 => (node (1 => (node #[1])))))))))) -/
  test_tac @Add.add Nat instAddNat 0 1
  /- (Add.add => (node (_uniq.1154 => (node (* => (node ( => (node ( => (node #[1])))))))))) -/
  test_tac @Add.add α ringAdd ?_ ?_
```
2024-02-11 21:42:54 +00:00
Scott Morrison
4718af5474 chore: upstream rcases (#3292)
This moves the `rcases` and `obtain` tactics from Std, and makes them
built-in tactics.

We will separately move the test cases from Std after #3297
(`guard_expr`).

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-10 05:22:02 +00:00
Leonardo de Moura
c138801c3a chore: rwa tactic macro (#3299) 2024-02-10 04:59:24 +00:00
Leonardo de Moura
5b4c24ff97 chore: add nomatch tactic (#3294) 2024-02-10 04:59:06 +00:00
Leonardo de Moura
1cb7450f40 fix: nomatch regression (#3296) 2024-02-10 04:58:48 +00:00
Leonardo de Moura
02d1ebb564 fix: extended coe notation and delaborator (#3295) 2024-02-10 04:58:28 +00:00
Lean stage0 autoupdater
488bfe2128 chore: update stage0 2024-02-09 12:46:12 +00:00
Sebastian Ullrich
55402a5899 feat: add [builtin_code_action_provider] (#3289) 2024-02-09 11:51:40 +00:00
Sebastian Ullrich
659218cf17 feat: add [builtin_widget_module] (#3288) 2024-02-09 11:20:46 +00:00
Scott Morrison
904239ae61 feat: upstream some Syntax/Position helper functions used in code actions in Std (#3260)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-09 10:50:19 +00:00
Sebastian Ullrich
b548b4faae refactor: make Promise implementation opaque (#3273)
This follows the standard `Ref` recipe and moves the `unsafeCast` into
C++
2024-02-09 10:43:41 +00:00
Scott Morrison
a7364499d2 chore: update line numbers in test after rebase 2024-02-09 10:05:54 +01:00
Leonardo de Moura
003835111d chore: fix tests 2024-02-09 18:23:46 +11:00
Scott Morrison
61a8695ab1 chore: update stage0 2024-02-09 18:23:46 +11:00
Leonardo de Moura
127214bd18 chore: cleanup and move unsafe term elaborator to BuiltinNotation 2024-02-09 18:23:46 +11:00
Scott Morrison
b1944b662c chore: update stage0 2024-02-09 18:23:46 +11:00
Leonardo de Moura
a17832ba14 chore: add unsafe term builtin parser 2024-02-09 18:23:46 +11:00
Scott Morrison
561ac09d61 chore: make mkAuxName private, add comment about alternatives 2024-02-09 18:23:46 +11:00
Scott Morrison
f68429d3a7 chore: move syntax to Init/Notation, make builtin_term_elab 2024-02-09 18:23:46 +11:00
Scott Morrison
a58232b820 core: upstream Std.Util.TermUnsafe 2024-02-09 18:23:46 +11:00
Scott Morrison
696b08dca2 chore: upstream Std.Tactic.CoeExt to Lean.Elab.CoeExt (#3280)
Moves the `@[coe]` attribute and associated elaborators/delaborators
from Std to Lean.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-09 04:55:49 +00:00
Scott Morrison
3a63b72eea chore: update stage0 2024-02-09 15:56:57 +11:00
Leonardo de Moura
9c160b8030 feat: nofun tactic and term
closes #3279
2024-02-09 15:56:57 +11:00
Scott Morrison
4bd75825b4 chore: update stage0 2024-02-09 15:56:57 +11:00
Leonardo de Moura
709e9909e7 feat: add nofun term parser
This new syntax suggested by @semorrison for the `fun.` Std macro.
2024-02-09 15:56:57 +11:00
Scott Morrison
83dd720337 chore: upstream MetavarContext helpers (#3284)
These are from Std, but mostly used in Aesop.
2024-02-09 03:58:10 +00:00
Scott Morrison
ac631f4736 feat: allow overriding getSimpTheorems in mkSimpContext (#3281)
The `push_cast` tactic in Std currently uses a copy-paste version of
`mkSimpContext` that allows overriding `getSimpTheorems`. However it has
been diverging from the version in Lean.

This is one way of generalizing `mkSimpContext` in Lean to allow what is
needed downstream., but I'm not at all set on this one. As far as I can
see there are no other tactics currently using this.

`push_cast` itself just replaces `getSimpTheorems` with
`pushCastExt.getTheorems`, where `pushCastExt` is a simp extension. If
there is another approach that suits that situation it would be fine.

I've tested that the change in this PR works downstream.
2024-02-09 03:57:40 +00:00
Leonardo de Moura
1f547225d1 feat: nary nomatch (#3285)
Base for https://github.com/leanprover/lean4/pull/3279

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-09 00:28:34 +00:00
Leonardo de Moura
09a43990aa refactor: move if-then-else tactic to Init 2024-02-09 09:57:57 +11:00
Leonardo de Moura
819848a0db chore: update stage0 2024-02-09 09:57:57 +11:00
Leonardo de Moura
8f8b0a8322 chore: fix proofs and test 2024-02-09 09:57:57 +11:00
Leonardo de Moura
9f633dcba2 chore: add register_parser_alias for matchRhs 2024-02-09 09:57:57 +11:00
Leonardo de Moura
cd4c7e4c35 refactor: move by_cases to Init/Classical.lean 2024-02-09 09:57:57 +11:00
Scott Morrison
9908823764 chore: upstream Std.Tactic.ByCases 2024-02-09 09:57:57 +11:00
Joe Hendrix
3e313d38f4 chore: upstream Std.Data.Array.Init.Basic (#3282)
This migrates the handful of array operations in
[Std.Data.Array.Init.Basic](https://github.com/leanprover/std4/blob/main/Std/Data/Array/Init/Basic.lean).
2024-02-08 19:30:47 +00:00
Scott Morrison
1b101a3d43 chore: upstream Std.Lean.Tactic (#3278)
A simple one, a small variant on `evalTacticAt`.

Perhaps a rename is in order?
2024-02-08 19:30:08 +00:00
Joe Hendrix
adcec8e67a chore: upstream Divides class and syntax (#3283)
This just upstreams the class and notation. Instances will be provided
with Nat/Int upstream
2024-02-08 08:09:02 +00:00
Scott Morrison
86d032ebf9 chore: upstream Std.Lean.LocalContext (#3275) 2024-02-08 07:43:25 +00:00
Scott Morrison
92ca504903 feat: upstreaming the json% term elaborator (#3265)
This is used in the "Try this:" widget machinery powering `simp?`.

There is a test file in Std, which I am not upstreaming at the same
time, as that relies on more code actions / #guard_msgs material. That
test file will still of course test things from Std, and later it can be
reunited with the code it is testing.

---------

Co-authored-by: Leonardo de Moura <leomoura@amazon.com>
2024-02-08 03:30:41 +00:00
Scott Morrison
021dd2d509 feat: additional options for Format.pretty (#3264)
These additional options are currently implemented in Std in a function
`Format.prettyExtra` (via `open private`), and used to implement the
`simp?` functionality.

This just adds the options to the core function.
2024-02-07 23:25:21 +00:00
Scott Morrison
2ad3c6406e feat: upstream TSyntax helper functions (#3261)
From Std.Lean.Syntax.
2024-02-07 22:53:27 +00:00
Scott Morrison
211770e2f9 feat: upstream helper functions for Name (#3263)
This does not completely empty `Std.Lean.Name`, as working out how to
document the difference between `Name.isInternalDetail` and
`Name.isImplementationDetail` requires further thought.
2024-02-07 21:51:58 +00:00
Leonardo de Moura
760e824b9f fix: we should not crash when simp loops (#3269)
see #3267
2024-02-07 02:30:28 +00:00
Scott Morrison
17722369c6 feat: InfoTree helper function used in code actions (#3262)
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-02-06 23:31:28 +00:00
Joachim Breitner
64688d4cee fix: let induction handle parameters (#3256)
The induction principle used by `induction` may have explicit parameters
that are
not motive, target or “real” alternatives (that have the `motive` as
conclusion), e.g. restrictions on the `motive` or other parameters.

Previously, `induction` would treat them as normal alternatives, and try
to re-introduce the automatically reverted hypotheses. But this only
works when the `motive` is actually the conclusion in the type of that
alternative.

We now pay attention to that, thread that information through, and only
revert when needed.

Fixes #3212.
2024-02-06 20:32:12 +00:00
Scott Morrison
69d462623e fix: don't drop doc-comments on simprocs (#3259) 2024-02-06 20:31:36 +00:00
Leonardo de Moura
17520fa0b8 fix: cache issue at split tatic (#3258)
closes #3229

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-02-06 19:44:28 +00:00
Jesse Wright
0055baf73a doc: add links to folder references (#3249)
This PR adds links to some folder references in the docs, making them
easier to navigate.

Please advise if these need to be made to be full URIs rather than
relative paths in order to work correctly with the doc generation
tooling that is in place.
2024-02-05 13:30:48 +00:00
Joachim Breitner
f40c999f68 feat: improve termination_by error messages (#3255)
as suggested in

<https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/termination_by.20regression/near/419786430>

Also refactored the code a bit and removed the code smell around
`GuessLex`-produced termination arguments (which may not be
surface-syntactically expressible) a bit by introducing an explicit flag
for those.
2024-02-05 13:13:53 +00:00
Leonardo de Moura
cf092e7941 refactor: add helper function evalPropStep (#3252) 2024-02-04 21:50:34 +00:00
Scott Morrison
43bbedca46 chore: begin development cycle for v4.7.0 (#3243) 2024-02-01 23:29:32 +00:00
Marcus Rossel
509f35df02 doc: fix typos (#3236) 2024-02-01 19:03:58 +00:00
Sebastian Ullrich
732b266de0 chore: CI: do not fail on broken links (#3238) 2024-02-01 13:40:27 +00:00
Kyle Miller
1d8cf38ff9 feat: pp.numericTypes option for printing number literals with type ascriptions (#2933)
Implements the pretty printer option `pp.numericTypes` for including a
type ascription for numeric literals. For example, `(2 : Nat)`, `(-2 :
Int)`, and `(-2 / 3 : Rat)`. This is useful for debugging how arithmetic
expressions have elaborated or have been otherwise transformed. For
example, with exponentiation is is helpful knowing whether it is `x ^ (2
: Nat)` or `x ^ (2 : Real)`. This is like the Lean 3 option
`pp.numeralTypes` but it has a wider notion of a numeric literal.

Also implements the pretty printer option `pp.natLit` for including the
`nat_lit` prefix for raw natural number literals.

Closes #3021
2024-02-01 17:23:32 +11:00
Leonardo de Moura
a4226a4f6d fix: tolerate missing simp and simproc sets
When we declare a `simp` set using `register_simp_attr`, we
automatically create `simproc` set. However, users may create `simp`
sets programmatically, and the associated `simproc` set may be missing
and vice-versa.
2024-02-01 16:58:54 +11:00
Leonardo de Moura
76224e409b fix: Mathlib regressions reported by Scott 2024-02-01 16:58:54 +11:00
Leonardo de Moura
c3383de6ff feat: add helper method withDischarger 2024-02-01 16:58:54 +11:00
Scott Morrison
e5b1c87606 chore: update stage0 2024-02-01 16:58:54 +11:00
Leonardo de Moura
da072c2ec8 fix: simp cache issue 2024-02-01 16:58:54 +11:00
Leonardo de Moura
d3c71ce2ff refactor: remove unfoldGround and cacheGround workarounds from simp 2024-02-01 16:58:54 +11:00
Scott Morrison
da21ef4fe8 chore: update stage0 2024-02-01 16:58:54 +11:00
Leonardo de Moura
168217b2bd chore: remove TODOs 2024-02-01 16:58:54 +11:00
Leonardo de Moura
8deb1838aa feat: add seval 2024-02-01 16:58:54 +11:00
Leonardo de Moura
3d1b3c6b44 chore: getSimpCongrTheorems to CoreM 2024-02-01 16:58:54 +11:00
Leonardo de Moura
676121c71d chore: style 2024-02-01 16:58:54 +11:00
Leonardo de Moura
6439d93389 chore: remove dead code 2024-02-01 16:58:54 +11:00
Scott Morrison
e4e6601546 chore: update stage0 2024-02-01 16:58:54 +11:00
Leonardo de Moura
01469bdbd6 refactor: remove workaround
We don't need to keep passing `discharge?` method around anymore.
2024-02-01 16:58:54 +11:00
Leonardo de Moura
01750e2139 chore: mark simprocs that are relevant for the symbolic evaluator 2024-02-01 16:58:54 +11:00
Scott Morrison
8037a8733d chore: update stage0 2024-02-01 16:58:54 +11:00
Leonardo de Moura
c4e6e48690 feat: builtin seval simproc attribute 2024-02-01 16:58:54 +11:00
Leonardo de Moura
9cfca51257 chore: register seval simp set 2024-02-01 16:58:54 +11:00
Leonardo de Moura
de886c617d feat: simproc sets
The command `register_simp_attr` now also declares a `simproc` set.
2024-02-01 16:58:54 +11:00
Leonardo de Moura
755b59c2cf chore: update RELEASES.md 2024-02-01 16:58:54 +11:00
Leonardo de Moura
266075b8a4 chore: fix tests 2024-02-01 16:58:54 +11:00
Scott Morrison
8db28ac32f chore: update stage0 2024-02-01 16:58:54 +11:00
Leonardo de Moura
b4a290a203 refactor: simp Step and Simproc types
Before this commit, `Simproc`s were defined as `Expr -> SimpM (Option Step)`, where `Step` is inductively defined as follows:
```
inductive Step where
  | visit : Result → Step
  | done  : Result → Step
```
Here, `Result` is a structure containing the resulting expression and a proof demonstrating its equality to the input. Notably, the proof is optional; in its absence, `simp` assumes reflexivity.

A simproc can:
- Fail by returning `none`, indicating its inapplicability. In this case, the next suitable simproc is attempted, along with other simp extensions.
- Succeed and invoke further simplifications using the `.visit`
constructor. This action returns control to the beginning of the
simplification loop.
- Succeed and indicate that the result should not undergo further
simplifications. However, I find the current approach unsatisfactory, as it does not align with the methodology employed in `Transform.lean`, where we have the type:

```
inductive TransformStep where
  /-- Return expression without visiting any subexpressions. -/
  | done (e : Expr)
  /--
  Visit expression (which should be different from current expression) instead.
  The new expression `e` is passed to `pre` again.
  -/
  | visit (e : Expr)
  /--
  Continue transformation with the given expression (defaults to current expression).
  For `pre`, this means visiting the children of the expression.
  For `post`, this is equivalent to returning `done`. -/
  | continue (e? : Option Expr := none)
```
This type makes it clearer what is going on. The new `Simp.Step` type is similar but use `Result` instead of `Expr` because we need a proof.
2024-02-01 16:58:54 +11:00
Matthew Robert Ballard
03f344a35f feat: use supplied structure fields left to right and eta reduce terms in structure instance elaboration (#2478)
Modifies the structure instance elaborator to
1. Fill in missing fields from sources in strict left-to-right order. In
`{a, b with}`, sometimes the elaborator
would ignore `a` even if both `a` and `b` provided the same field,
depending on what subobject fields they had.
2. Use the sources, or subobjects of the sources, to fill in entire
subobjects of the target structure as much as possible.
Currently, a field cannot be filled directly by a source itself
resulting in the term being eta expanded.
This change avoids this unnecessary and surprisingly costly extra eta
expansion.

Adds two new tests to illustrate the performance benefit (one courtesy
@semorrison). These are currently failing on master and succeed on this
branch.

There is one additional test to exercise the changes to the elaboration
of structure instances.

Changes to make mathlib build are in leanprover-community/mathlib4#9843

Closes #2451
2024-02-01 03:42:39 +00:00
Mac Malone
a48ca7b0a4 feat: lake: improved platform information & control (#3226)
This combines a few platform-related changes:

* Add a ternary `platformIndependent` Lean configuration option to
assert whether Lake should assume Lean code is platform-independent. If
`true`, Lake will exclude platform-independent objects like external
libraries or dynlibs created through `precompileModules` from module
traces. If `false`, Lake will add the platform to module traces. If
`none` (the default), Lake will retain the current behavior (modules are
platform-dependent if and only if it depends on native objects).
* Use `System.Platform.target` from #3207 as the platform descriptor in
Lake for the configuration file trace, the cloud release archive, and as
the platform trace in Lean modules and native artifacts (e.g., object
files, and static and shared libraries).
* Do not add the platform descriptor into custom build archive names
(i.e., a user-set `buildArchive` configuration). This allows users to
create cross-platform / platform-independent archives via a name
override should they so desire.

Closes #2754.
2024-01-31 23:56:33 +00:00
Jon Eugster
1cb1602977 doc: add doc for FileMap (#3221) 2024-01-31 21:51:37 +00:00
Mario Carneiro
c98deeb709 feat: @[unused_variables_ignore_fn] attribute (#3184)
This replaces the no-op `unusedVariablesIgnoreFnsExt` environment
extension with an actual environment extension which can be extended
using either `@[unused_variables_ignore_fn]` or
`@[builtin_unused_variables_ignore_fn]` (although for the present all
the builtin `unused_variables_ignore_fn`s are being added using direct
calls to `builtin_initialize addBuiltinUnusedVariablesIgnoreFn`, because
this also works and a stage0 update is required before the attribute can
be used).

We would like to use this attribute to disable unused variables in
syntaxes defined in std and mathlib, like
[`proof_wanted`](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Unused.20variables.20and.20proof_wanted/near/408554690).
2024-01-31 19:27:32 +00:00
Marc Huisinga
cd0be38bb4 feat: elidible subterms (#3201)
This PR adds two new delaboration settings: `pp.deepTerms : Bool`
(default: `true`) and `pp.deepTerms.threshold : Nat` (default: `20`).

Setting `pp.deepTerms` to `false` will make the delaborator terminate
early after `pp.deepTerms.threshold` layers of recursion and replace the
omitted subterm with the symbol `⋯` if the subterm is deeper than
`pp.deepTerms.threshold / 4` (i.e. it is not shallow). To display the
omitted subterm in the InfoView, `⋯` can be clicked to open a popup with
the delaborated subterm.

<details>
<summary>InfoView with pp.deepTerms set to false (click to show
image)</summary>


![image](https://github.com/leanprover/lean4/assets/10852073/f6df8b2c-d769-41c8-821e-efd0af23ccfa)
</details>

### Implementation

- The delaborator is adjusted to use the new configuration settings and
terminate early if the threshold is exceeded and the corresponding term
to omit is shallow.
- To be able to distinguish `⋯` from regular terms, a new constructor
`Lean.Elab.Info.ofOmissionInfo` is added to `Lean.Elab.Info` that takes
a value of a new type `Lean.Elab.OmissionInfo`.
- `ofOmissionInfo` is needed in `Lean.Widget.makePopup` for the
`Lean.Widget.InteractiveDiagnostics.infoToInteractive` RPC procedure
that is used to display popups when clicking on terms in the InfoView.
It ensures that the expansion of an omitted subterm is delaborated using
`explicit := false`, which is typically set to `true` in popups for
regular terms.
- Several `Info` widget utility functions are adjusted to support
`ofOmissionInfo`.
- The list delaborator is adjusted with special support for `⋯` so that
long lists `[x₁, ..., xₖ, ..., xₙ]` are shortened to `[x₁, ..., xₖ, ⋯]`.
2024-01-31 17:28:29 +00:00
Lean stage0 autoupdater
578a2308b1 chore: update stage0 2024-01-31 15:48:29 +00:00
Joachim Breitner
279607f5f8 refactor: forallAltTelescope to take altNumParams (#3230)
this way this function does not have to peek at the `altType` to see
when there are no more arguments, which makes it a bit more explicit,
and also a bit more robust should one apply this function to the type of
an alternative with the motive already instantiated.

It seems this uncovered a variable shadow bug, where the counter `i` was
accidentially reset after removing the `i`’th entry in `ys`.
2024-01-31 11:03:03 +00:00
Sebastian Ullrich
456e435fe0 chore: remove unused GH Pages deployment (#3217) 2024-01-31 10:39:15 +00:00
Kyle Miller
31981090e4 feat: make intro be aware of let_fun (#3115)
Adds support for `let_fun` to the `intro` and `intros` tactics. Also
adds support to `intro` for anonymous binder names, since the default
variable name for a `letFun` with an eta reduced body is anonymous.
2024-01-31 08:55:52 +00:00
David Thrane Christiansen
dd77dbdc11 chore: add GitHub token to manual link checker (#3235)
Hopefully this will avoid [429 errors from
GitHub](da4c46370d)
2024-01-31 06:44:00 +00:00
Kyle Miller
fcb30c269b doc: expand docstring for intros (#2777)
The docstring for `intros` did not explain the difference between the
zero-argument and the one-or-more-argument cases.
2024-01-30 22:59:02 +00:00
Sebastian Ullrich
5f59d7f7b4 fix: do not throw C++ heartbeat exceptions in pure functions (#3224) 2024-01-29 20:27:27 +00:00
Marc Huisinga
1364157e91 doc: adjust RELEASES.md call hierarchy url (#3220)
This links a better description of what the call hierarchy does.
2024-01-26 15:54:18 +00:00
David Thrane Christiansen
a524fd4be8 doc: update link target (#3218)
This fixes a link target found by the link checker CI for lean-lang.org
2024-01-26 10:20:22 +00:00
Joachim Breitner
de23226d0c refactor: fuse nested mkCongrArg calls (#3203)
Encouraged by the performance gains from making `rewrite` produce
smaller proof objects
(#3121) I am here looking for low-hanging fruit in `simp`.

Consider this typical example:

```
set_option pp.explicit true

theorem test
  (a : Nat)
  (b : Nat)
  (c : Nat)
  (heq : a = b)
  (h : (c.add (c.add ((c.add b).add c))).add c = c)
  : (c.add (c.add ((c.add a).add c))).add c = c
```
We get a rather nice proof term when using
```
  := by rw [heq]; assumption
```
namely
```
theorem test : ∀ (a b c : Nat),
  @Eq Nat a b →
    @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c →
      @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c :=
fun a b c heq h =>
  @Eq.mpr (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c)
    (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c)
    (@congrArg Nat Prop a b (fun _a => @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c _a) c))) c) c) heq) h
```
(this is with #3121).

But with `by simp only [heq]; assumption`, it looks rather different:

```
theorem test : ∀ (a b c : Nat),
  @Eq Nat a b →
    @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c →
      @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c :=
fun a b c heq h =>
  @Eq.mpr (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c)
    (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c)
    (@id
      (@Eq Prop (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c)
        (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c))
      (@congrFun Nat (fun a => Prop) (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c))
        (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c))
        (@congrArg Nat (Nat → Prop) (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c)
          (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) (@Eq Nat)
          (@congrFun Nat (fun a => Nat) (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))))
            (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))))
            (@congrArg Nat (Nat → Nat) (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c)))
              (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) Nat.add
              (@congrArg Nat Nat (Nat.add c (Nat.add (Nat.add c a) c)) (Nat.add c (Nat.add (Nat.add c b) c)) (Nat.add c)
                (@congrArg Nat Nat (Nat.add (Nat.add c a) c) (Nat.add (Nat.add c b) c) (Nat.add c)
                  (@congrFun Nat (fun a => Nat) (Nat.add (Nat.add c a)) (Nat.add (Nat.add c b))
                    (@congrArg Nat (Nat → Nat) (Nat.add c a) (Nat.add c b) Nat.add
                      (@congrArg Nat Nat a b (Nat.add c) heq))
                    c))))
            c))
        c))
    h
```
Since simp uses only single-step `congrArg`/`congrFun` congruence lemmas
here, the proof
term grows very large, likely quadratic in this case.

Can we do better? Every nesting of `congrArg` (and it's little brother
`congrFun`) can be
turned into a single `congrArg` call. 

In this PR I make making the smart app builders `Meta.mkCongrArg` and
`Meta.mkCongrFun` a bit
smarter and not only fuse with `Eq.refl`, but also with
`congrArg`/`congrFun`.

Now we get, in this simple example,
```
theorem test : ∀ (a b c : Nat),
  @Eq Nat a b →
    @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c →
      @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c :=
fun a b c heq h =>
  @Eq.mpr (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c a) c))) c) c)
    (@Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c b) c))) c) c)
    (@congrArg Nat Prop a b (fun x => @Eq Nat (Nat.add (Nat.add c (Nat.add c (Nat.add (Nat.add c x) c))) c) c) heq) h
```

Let’s see if it works and how much we gain.
2024-01-25 17:48:27 +00:00
Joachim Breitner
550fa6994e feat: induction using <term> (#3188)
right now, the `induction` tactic accepts a custom eliminator using the
`using <ident>` syntax, but is restricted to identifiers. This
limitation becomes annoying when the elminator has explicit parameters
that are not targets, and the user (naturally) wants to be able to write
```
induction a, b, c using foo (x := …)
```

This generalizes the syntax to expressions and changes the code
accordingly.

This can be used to instantiate a multi-motive induction:
```
example (a : A) : True := by
  induction a using A.rec (motive_2 := fun b => True)
  case mkA b IH => exact trivial
  case A => exact trivial
  case mkB b IH => exact trivial
```

For this to work the term elaborator learned the `heedElabAsElim` flag,
`true` by default. But in the default setting, `A.rec (motive_2 := fun b
=> True)`
would fail to elaborate, because there is no expected type. So the
induction
tactic will elaborate in a mode where that attribute is simply ignored.

As a side effect, the “failed to infer implicit target” error message 
is improved and prints the name of the implicit target that could not be
instantiated.
2024-01-25 16:57:41 +00:00
Marc Huisinga
f9e5f1f1fd feat: add call hierarchy support (#3082)
This PR adds support for the "call hierarchy" feature of LSP that allows
quickly navigating both inbound and outbound call sites of functions. In
this PR, "call" is taken to mean "usage", so inbound and outbound
references of all kinds of identifiers (e.g. functions or types) can be
navigated. To implement the call hierarchy feature, this PR implements
the LSP requests `textDocument/prepareCallHierarchy`,
`callHierarchy/incomingCalls` and `callHierarchy/outgoingCalls`.

<details>
  <summary>Showing the call hierarchy (click to show image)</summary>
  

![show_call_hierarchy](https://github.com/leanprover/lean4/assets/10852073/add13943-013c-4d0a-a2d4-a7c57ad2ae26)
  
</details>

<details>
  <summary>Incoming calls (click to show image)</summary>
  

![incoming_calls](https://github.com/leanprover/lean4/assets/10852073/9a803cb4-6690-42b4-9c5c-f301f76367a7)
  
</details>

<details>
  <summary>Outgoing calls (click to show image)</summary>
  

![outgoing_calls](https://github.com/leanprover/lean4/assets/10852073/a7c4f193-51ab-4365-9473-0309319b1cfe)
  
</details>

It is based on #3159, which should be merged before this PR.

To route the parent declaration name through to the language server, the
`.ilean` format is adjusted, breaking backwards compatibility with
version 1 of the ILean format and yielding version 2.

This PR also makes the following more minor adjustments:
- `Lean.Server.findModuleRefs` now also combines the identifiers of
constants and FVars and prefers constant over FVars for the combined
identifier. This is necessary because e.g. declarations declared using
`where` yield both a constant (for usage outside of the function) and an
FVar (for usage inside of the function) with the same range, whereas we
would typically like all references to refer to the former. This also
fixes a bug introduced in #2462 where renaming a declaration declared
using `where` would not rename usages outside of the function, as well
as a bug in the unused variable linter where `where` declarations would
be reported as unused even if they were being used outside of the
function.
- The function converting `Lean.Server.RefInfo` to `Lean.Lsp.RefInfo`
now also computes the `Lean.DeclarationRanges` for parent declaration
names via `MetaM` and must hence be in `IO` now.
- Add a utility function `Array.groupByKey` to `HashMap.lean`.
- Stylistic refactoring of `Watchdog.lean` and `LanguageFeatures.lean`.
2024-01-25 14:43:23 +00:00
Sebastian Ullrich
6b0e7e1f46 feat: synchronous execution of task continuations (#3013)
In the new snapshot design, we have a tree of `Task`s that represents
the asynchronously processed document structure. When transforming this
tree in response to a user edit, we want to quickly run through
reusable, already computed nodes of the tree synchronously and then
spawn new tasks for the new parts. The new flag allows us to do such
mixed sync/async tree transformations uniformly. This flag exists as
e.g.
[`ExecuteSynchronously`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskcontinuationoptions?view=net-8.0)
in other runtimes.
2024-01-25 13:54:20 +00:00
Sebastian Ullrich
9fb44fae29 doc: remove nightly and other outdated references (#3027) 2024-01-25 13:53:36 +00:00
David Thrane Christiansen
1f4359cc80 fix: broken internal links in the docs (#3216)
I deleted internal links that seemed to have the character of "TODO". I
think that the residual TODO is of little value, given that we plan a
big revamp and revision soon anyway, but I could do it some other way as
well.
2024-01-25 09:56:20 +00:00
Joe Hendrix
8293fd4e09 feat: cleanups to ACI and Identity classes (#3195)
This makes changes to the definitions of Associativity, Commutativity,
Idempotence and Identity classes to be more aligned with Mathlib's
versions.

The changes are:
*  Move classes are moved from `Lean` to root namespace.
* Drop `Is` prefix from names.
* Rename `IsNeutral` to `LawfulIdentity` and add Left and Right
subclasses.
* Change neutral/identity element to outParam.
* Introduce `HasIdentity` for operations not intended for proofs to
implement

The identity changes are to make this compatible with
[Mathlib](718042db9d/Mathlib/Init/Algebra/Classes.lean)
and to enable nicer fold operations in Std that can use type classes to
infer the identity/initial element on binary operations.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-01-24 21:46:58 +00:00
Sebastian Ullrich
2beb948a3b feat: System.Platform.target (#3207)
Makes the LLVM triple of the current platform available to Lean code
towards a solution for #2754.

Defaults to the empty string if the compiler is not clang, which can
introduce some divergence between CI and local builds but should not be
noticeable in most cases and is not really possible to avoid.
2024-01-24 12:11:00 +00:00
Joachim Breitner
409c6cac4c fix: predefinition preprocessing: float .mdata out of non-unary applications (#3204)
Recursive predefinitions contains “rec app” markers as mdata in the
predefinitions,
but sometimes these get in the way of termination checking, when you
have
```
  [mdata (fun x => f)] arg
```

Therefore, the `preprocess` pass floats them out of applications
(originally
only for structural recursion, since #2818 also for well-founded
recursion).

But the code was incomplete: Because `Meta.transform` calls `post` on `f
x y` only
once (and not also on `f x`) one has to float out of nested applications
as well.

A consequence of this can be that in a recursive proof, `rw [foo]` does
not work
although `rw [foo _ _]` does.

Also adding the testcase where @david-christiansen and I stumbled over
this


(Maybe the two preprocess modules can be combined, now that #2973 is
landed, will try that
in a follow-up).
2024-01-24 08:37:16 +00:00
Eric Wieser
ec39de8cae fix: allow generalization in let (#3060)
As suggested by @kmill, removing an unnecessary `let` (possibly only
there in the first place for copy/paste reasons) seems to fix the
included test.

This makes `~q()` matching in quote4 noticeably more useful in things
like `norm_num` (as it fixes
https://github.com/leanprover-community/quote4/issues/29)

It also makes a quote4 bug slightly more visible
(https://github.com/leanprover-community/quote4/issues/30), but the bug
there already existed anyway, and isn't caused by this patch.

Fixes #3065
2024-01-23 09:02:05 +00:00
Kyle Miller
586c3f9140 feat: make mkApp, mkApp2, ..., mkApp10 have @[match_pattern] attribute (#2900)
Give n-ary `Expr.app` constructors such as `mkApp2`, `mkApp3`, ...,
`mkApp10` the `@[match_pattern]` attribute so that it is easier to read
and write pattern matching for applications.
2024-01-23 08:56:15 +00:00
David Renshaw
feda615ed5 doc: add missing 'not' in simprocs example in RELEASES.md (#3206) 2024-01-22 16:14:18 +00:00
Marc Huisinga
4f41ccfcbf doc: update RELEASES.md for #3159 (#3205) 2024-01-22 13:47:25 +00:00
Marc Huisinga
e9f69d1068 feat: partial context info (#3159)
This PR facilitates augmenting the context of an `InfoTree` with
*partial* contexts while elaborating a command. Using partial contexts,
this PR also adds support for tracking the parent declaration name of a
term in the `InfoTree`. The parent declaration name is needed to compute
the call hierarchy in #3082.

Specifically, the `Lean.Elab.InfoTree.context` constructor is refactored
to take a value of the new type `Lean.Elab.PartialContextInfo` instead
of a `Lean.Elab.ContextInfo`, which now refers to a full `InfoTree`
context. The `PartialContextInfo` is then merged into a `ContextInfo`
while traversing the tree using
`Lean.Elab.PartialContextInfo.mergeIntoOuter?`. The partial context
after executing `liftTermElabM` is stored in values of a new type
`Lean.Elab.CommandContextInfo`.

As a result of this, `Lean.Elab.ContextInfo.save` moves to
`Lean.Elab.CommandContextInfo.save`.

For obtaining the parent declaration for a term, a new typeclass
`MonadParentDecl` is introduced to save the parent declaration in
`Lean.Elab.withSaveParentDeclInfoContext`. `Lean.Elab.Term.withDeclName
x` now calls `withSaveParentDeclInfoContext x` to save the declaration
name.

### Migration

**The changes to the `InfoTree.context` constructor break backwards
compatibility with all downstream users that traverse the `InfoTree`
manually instead of going through the functions in `InfoUtils.lean`.**
To fix this, you can merge the outer `ContextInfo` in a traversal with
the `PartialContextInfo` of an `InfoTree.context` node using
`PartialContextInfo.mergeIntoOuter?`. See e.g.
`Lean.Elab.InfoTree.foldInfo` for an example:
```lean
partial def InfoTree.foldInfo (f : ContextInfo → Info → α → α) (init : α) : InfoTree → α :=
  go none init
where go ctx? a
  | context ctx t => go (ctx.mergeIntoOuter? ctx?) a t
  | node i ts =>
    let a := match ctx? with
      | none => a
      | some ctx => f ctx i a
    ts.foldl (init := a) (go <| i.updateContext? ctx?)
  | _ => a
```

Downstream users that manually save `InfoTree`s may need to adjust calls
to `ContextInfo.save` to use `CommandContextInfo.save` instead and
potentially wrap their `CommandContextInfo` in a
`PartialContextInfo.commandCtx` constructor when storing it in an
`InfoTree` or `ContextInfo.mk` when creating a full context.

### Motivation

As of now, `ContextInfo`s are always *full* contexts, constructed as if
they were always created in `liftTermElabM` after running the
`TermElabM` action. This is not strictly true; we already create
`ContextInfo`s in several places other than `liftTermElabM` and work
around the limitation that `ContextInfo`s are always full contexts in
certain places (e.g. `Info.updateContext?` is a crux that we need
because we can't always create partial contexts at the term-level), but
it has mostly worked out so far. Note that one must be very careful when
saving a `ContextInfo` in places other than `liftTermElabM` because the
context may not be as complete as we would like (e.g. it may lack
meta-variable assignments, potentially leading to a language server
panic).

Unfortunately, the parent declaration of a term is another example of a
context that cannot be provided in `liftTermElabM`: The parent
declaration is usually set via `withDeclName`, which itself lives in
`TermElabM`. So by the time we are trying to save the full
`ContextInfo`, the declaration name is already gone. There is no easy
fix for this like in the other cases where we would really just like to
augment the context with an extra field.

The refactor that we decided on to resolve the issue is to refactor the
`InfoTree` to take a `PartialContextInfo` instead of a `ContextInfo` and
have code that traverses the `InfoTree` merge inner contexts with outer
contexts to produce a full `ContextInfo` value.

### Bumps for downstream projects

- `lean-pr-testing-3159` branch at Std, not yet opened as a PR
- `lean-pr-testing-3159` branch at Mathlib, not yet opened as a PR
- https://github.com/leanprover/LeanInk/pull/57
- https://github.com/hargoniX/LeanInk/pull/1
- https://github.com/tydeu/lean4-alloy/pull/7
- https://github.com/leanprover-community/repl/pull/29

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-22 12:34:20 +00:00
Scott Morrison
5cc9f6f9cb chore: CI creates lean-pr-testing-NNNN branches at Std too (#3200)
Currently we create `lean-pr-testing-NNNN` branches at Mathlib
automatically for each Lean PR.

We don't automatically create one at Std; mostly simply because Std
fails less often, so it has been okay to do this manually as needed. It
is conceptually simpler, however, if this is done uniformly.

This PR:
* does not proceed with Std/Mathlib CI unless the appropriate
`nightly-testing-YYYY-MM-DD` tag exists at Std (like it already doesn't
proceed if that tag is missing at Mathlib)
* creates `lean-pr-testing-NNNN` branches at Std
* when it creates `lean-pr-testing-NNNN` branches at Mathlib, updates
the Std dependency to use the `lean-pr-testing-NNNN` branch at Std

- [x] depends on #3199

Note that because most users do not have write access at Std, in order
to make updates to `lean-pr-testing-NNNN` branches there they will need
to make PRs. These will be merged with a very low bar, and feel free to
ping me for assistance on this. If this is annoying we will automate.
Also, frequent contributors to Lean may ask @digama0 or @joehendrix for
write access in order to easily work on these branches.

This PR requires that we have a secret here with write access at Std.
I'm arranging that [on
zulip](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/bot.20access/near/416686090).

I will update the documentation at
https://leanprover-community.github.io/contribute/tags_and_branches.html
to reflect these changes when they are merged.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-01-22 03:06:59 +00:00
Kyle Miller
09aa845940 doc: clarify and expand docstrings for the instantiate functions (#3183)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-22 02:58:29 +00:00
Scott Morrison
73b87f2558 chore: CI looks for nightly-testing-YYYY-MM-DD at Mathlib as either a branch or tag (#3199)
As discussed during the FRO meeting 2024-01-18, we are changing the
`nightly-testing-YYYY-MM-DD` branches at Std and Mathlib from branches
to tags, in:

* https://github.com/leanprover/std4/pull/545
* https://github.com/leanprover-community/mathlib4/pull/9842

This PR updates the script that creates the `lean-pr-testing-NNNN`
branches at Mathlib so it is agnostic about whether
`nightly-testing-YYYY-MM-DD` will be a branch or a tag.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-01-20 23:50:03 +00:00
Joachim Breitner
c0f264ffe0 fix: reducing out-of-bounds swap! should return a, not default (#3197)
`Array.set!` and `Array.swap!` are fairly similar operations, both
modify an array, both take an index that it out of bounds.

But they behave different; all of these return `true`
```
#eval #[1,2].set! 2 42 == #[1,2]    -- with panic
#reduce #[1,2].set! 2 42 == #[1,2]  -- no panic

#eval #[1,2].swap! 0 2 == #[1,2]    -- with panic
#reduce #[1,2].swap! 0 2 == default -- no panic
```

The implementations are
```
@[extern "lean_array_set"]
def Array.set! (a : Array α) (i : @& Nat) (v : α) : Array α :=
  Array.setD a i v
```
but
```
@[extern "lean_array_swap"]
def swap! (a : Array α) (i j : @& Nat) : Array α :=
  if h₁ : i < a.size then
  if h₂ : j < a.size then swap a ⟨i, h₁⟩ ⟨j, h₂⟩
  else panic! "index out of bounds"
  else panic! "index out of bounds"
```

It seems to be more consistent to unify the behaviors, and define
```
@[extern "lean_array_swap"]
def swap! (a : Array α) (i j : @& Nat) : Array α :=
  if h₁ : i < a.size then
  if h₂ : j < a.size then swap a ⟨i, h₁⟩ ⟨j, h₂⟩
  else a
  else a
```

Also adds docstrings.

Fixes #3196
2024-01-19 18:29:18 +00:00
Joachim Breitner
52d0f715c3 refactor: rewrite: produce simpler proof terms (#3121)
Consider
```
import Std.Tactic.ShowTerm

opaque a : Nat
opaque b : Nat
axiom a_eq_b : a = b
opaque P : Nat → Prop

set_option pp.explicit true

-- Using rw
example (h : P b) : P a := by show_term rw [a_eq_b]; assumption
```

Before, a typical proof term for `rewrite` looked like this:
```
-- Using the proof term that rw produces
example (h : P b) : P a :=
  @Eq.mpr (P a) (P b)
  (@id (@Eq Prop (P a) (P b))
    (@Eq.ndrec Nat a (fun _a => @Eq Prop (P a) (P _a))
      (@Eq.refl Prop (P a)) b a_eq_b))
  h
```
which is rather round-about, applying `ndrec` to `refl`. It would be
more direct to write
```
example (h : P b) : P a :=
  @Eq.mpr (P a) (P b)
  (@id (@Eq Prop (P a) (P b))
    (@congrArg Nat Prop a b (fun _a => (P _a)) a_eq_b))
  h
```
which this change does.

This makes proof terms smaller, causing mild general speed up throughout
the code; if the brenchmarks don’t lie the highlights are

* olean size -2.034 %
* lint wall-clock -3.401 %
* buildtactic execution s -10.462 %

H'T to @digama0 for advice and help.

NB: One might even expect the even simpler
```
-- Using the proof term that I would have expected
example (h : P b) : P a :=
  @Eq.ndrec Nat b (fun _a => P _a) h a a_eq_b.symm
```
but that would require non-local changes to the source code, so one step
at a time.
2024-01-19 07:20:58 +00:00
Leonardo de Moura
ec30da8af7 feat: new implementation for simp (config := { ground := true }) (#3187) 2024-01-18 17:39:06 +00:00
Joachim Breitner
27b7002138 fix: checkTargets check for duplicate target (#3171)
The `checkTargets` function introduced in 4a0f8bf2 as
```
  checkTargets (targets : Array Expr) : MetaM Unit := do
    let mut foundFVars : FVarIdSet := {}
    for target in targets do
      unless target.isFVar do
        throwError "index in target's type is not a variable (consider using the `cases` tactic instead){indentExpr target}"
      if foundFVars.contains target.fvarId! then
        throwError "target (or one of its indices) occurs more than once{indentExpr target}"
```
looks like it tries to check for duplicate indices, but it doesn’t
actually, as `foundFVars` is never written to.

This adds
```
      foundFVars := foundFVars.insert target.fvarId!
```
and a test case.

Maybe a linter that warns about `let mut` that are never writen to would
be useful?
2024-01-18 09:44:17 +00:00
Arthur Adjedj
a2ed4db562 fix: derive BEq on structure with Prop-fields (#3191)
Closes #3140

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2024-01-18 02:32:51 +00:00
Joachim Breitner
628633d02e test: failed to infer implicit target (#3189)
The `induction` tactic complains if implicit targets cannot be inferred,
let’s test that.
2024-01-17 11:17:34 +00:00
Joachim Breitner
f8edf452de chore: CI: add actionlint action, fix actions (#3156)
I keep messing things up, so time for some guard rails, so check them
using
[actionlint](https://github.com/raven-actions/actionlint).

This also runs [shellcheck](https://www.shellcheck.net/) on the files.
Shellcheck
is a bit picky about putting double quotes around variables, and will
flag many
cases where we know it’s safe, but why not simply always write the safer
variant.

Unfortunately, actionlint does not (yet) check `actions/github-script`
scripts, which is
unfortunate. Maybe they will in the future
(https://github.com/rhysd/actionlint/issues/389)
2024-01-15 17:53:04 +00:00
Marcus Rossel
12dc171c48 doc: fix typos (#3178) 2024-01-14 14:02:51 +00:00
Mario Carneiro
42e6214a42 feat: lake: GNU/BSD OS detection in test scripts (#3180)
fixes #3179
2024-01-14 02:49:38 +00:00
Joachim Breitner
53af5ead53 fix: Fix/GuessLex: refine through more casesOnApp/matcherApp (#3176)
there was a check

if !Structural.recArgHasLooseBVarsAt recFnName fixedPrefixSize e then

that would avoid going through `.refineThrough`/`.addArg` for
matcher/casesOn applications. It seems it tries to detect when refining
the motive/param is pointless, but it was too eager, and cause confusion
with, for example, this reasonably reasonable function:

    def foo : (n : Nat) → (i : Fin n) → Bool
      | 0, _ => false
      | 1, _ => false
      | _+2, _ => foo 1 ⟨0, Nat.zero_lt_one⟩
    decreasing_by simp_wf; simp_arith

In particular, the `GuessLex` code later expects that the (implict)
`PProd.casesOn` in the implementation of `foo._unary` will refine the
paramter, because else the (rather picky) `unpackArg` fails. But it also
prevents this from being provable.

So let's try without this shortcut.

Fixing this also revealed that `withRecApps` wasn’t looking in all
corners
of a matcherApp/casesOnApp.

Fixes #3175
2024-01-13 18:02:41 +00:00
Joachim Breitner
b706c0064e chore: pr-release: more robust comment id recognition (#3173)
this didn’t recognize the new comments with an intro, and thus the bot
would post multiple comments.

The code was also out of sync with mathlib, fixing.

The `first(…)` in the `jq` program makes it more robust in case this
went wrong once (as on #3171) and there are now multiple PRs matching.
2024-01-13 02:48:42 +00:00
Joachim Breitner
8e1b51701b chore: pr-release.yml: parentheses are significant in jq (#3169) 2024-01-12 10:20:53 +00:00
Joe Hendrix
ad068824d0 chore: use termination_by in Nat.gcd (#3164)
This uses the improved termination_by syntax to give Nat.gcd a cleaner
definition. It removes the last explicit use of WellFounded.fix in Init.

This was also partly motivated by leanprover/std4#520 so that unfold
Nat.gcd gives a sensible definition.
2024-01-11 21:31:27 +00:00
Joe Hendrix
7c4c57759d chore: use more specific import in OfScientific (#3165)
This just removes a spurious import of `Init.Data.Nat`. That's the only
non-aggregating import of that file in Init.
2024-01-11 18:23:43 +00:00
Joe Hendrix
1118931516 feat: add bitwise operations to reduceNat? and kernel (#3134)
This adds bitwise operations to reduceNat? and the kernel. It
incorporates some basic test cases to validate the correct operations
are associated.
2024-01-11 18:12:45 +00:00
Mac Malone
7150638836 feat: lake update from unsupported manifest versions (#3149)
If the current manifest is from unsupported (or has errors), a bare
`lake update` will now discard it and create a new one from scratch
rather than erroring and requiring you to manually delete the manifest.
Lake will produce warnings noting it is ignoring such invalid manifests.
2024-01-11 00:30:56 +00:00
Joachim Breitner
30693a2dae doc: mention termination_by and decreasing_by (#3016)
so far, our reference manual did not mention these at all, this takes
the discussion of recursive definition out of the “equation compiler”
section, put it into its own section, and expands it a bit.

This is more a MVP doc change to at least mention the features briefly,
and not the most polished and thought through didactic exposition. But
it provides a start for more improvements.

---------

Co-authored-by: Arthur Adjedj <arthur.adjedj@gmail.com>
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2024-01-10 16:35:19 +00:00
Joachim Breitner
368ead54b2 refactor: termination_by changes in stdlib 2024-01-10 17:27:35 +01:00
Joachim Breitner
7c10415cd8 chore: update stage0 2024-01-10 17:27:35 +01:00
Joachim Breitner
b5122b6a7b feat: per-function termination hints
This change

 * moves `termination_by` and `decreasing_by` next to the function they
   apply to
 * simplify the syntax of `termination_by`
 * apply the `decreasing_by` goal to all goals at once, for better
   interactive use.

See the section in `RELEASES.md` for more details and migration advise.

This is a hard breaking change, requiring developers to touch every
`termination_by` in their code base. We decided to still do it as a
hard-breaking change, because supporting both old and new syntax at the
same time would be non-trivial, and not save that much. Moreover, this
requires changes to some metaprograms that developers might have
written, and supporting both syntaxes at the same time would make
_their_ migration harder.
2024-01-10 17:27:35 +01:00
Sebastian Ullrich
8bc1a9c4ba chore: actually include full build in benchmark (#3158)
I must have reverted too much while testing #3104
2024-01-10 14:33:27 +00:00
Eric Wieser
4169cac51f fix: do not strip dotted components from lean module names (#2994)
This introduces `FilePath.addExtension` to take a path that we know has
no prior extension, and append a new extension to it.
As this function is simpler than `FilePath.withExtension`, this change
eagerly replaces uses of the latter with the former, except in a few
cases where stripping the extension really is the right thing to do.

This should fix the bug described at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Import.20file.20with.20multiple.20dots.20in.20file.20name/near/404508048,
where `import «A.B».«C.D.lean»` is needed to import `A.B/C.D.lean`.

Closes #2999

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-10 14:24:26 +00:00
Kyle Miller
c394a834c3 feat: extract delabAppCore, define withOverApp, and make over-applied projections pretty print (#3083)
To handle delaborating notations that are functions that can be applied
to arguments, extracts the core function application delaborator as a
separate function that accepts the number of arguments to process and a
delaborator to apply to the "head" of the expression.

Defines `withOverApp`, which has the same interface as the combinator of
the same name from std4, but it uses this core function application
delaborator.

Uses `withOverApp` to improve a number of application delaborators,
notably projections. This means Mathlib can stop using `pp_dot` for
structure fields that have function types.

Incidentally fixes `getParamKinds` to specialize default values to use
supplied arguments, which impacts how default arguments are delaborated.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-10 13:24:28 +00:00
Geoffrey Irving
9069c538ad doc: state that Float is IEEE compliant (#3157)
Github discussion:
https://github.com/leanprover/lean4/pull/3147#discussion_r1446735973
2024-01-10 12:16:42 +00:00
Scott Morrison
4e16eb0476 chore: fix typo from #3148 in pr-release bot (#3154) 2024-01-10 03:14:43 +00:00
Leonardo de Moura
e924ef229c doc: add simproc release notes 2024-01-09 12:57:15 +01:00
Scott Morrison
8012eedab5 test: timeout in Mathlib.Computability.PartrecCode 2024-01-09 12:57:15 +01:00
Leonardo de Moura
33c53a2418 fix: panic at ite and dite simprocs 2024-01-09 12:57:15 +01:00
Scott Morrison
3b9b13b706 test: test for panic in simprocs 2024-01-09 12:57:15 +01:00
Leonardo de Moura
94d51b2321 chore: cleanup builtin simprocs using OptionT 2024-01-09 12:57:15 +01:00
Leonardo de Moura
0342d62109 chroe: fix tests 2024-01-09 12:57:15 +01:00
Leonardo de Moura
4e5ce6b65d chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
e11b320cd6 chore: use mathlib naming convention 2024-01-09 12:57:15 +01:00
Leonardo de Moura
cb6bfefc7a chore: better method names 2024-01-09 12:57:15 +01:00
Leonardo de Moura
25ea5f6fa1 chore: add default parameter value for (simprocs : Simprocs) 2024-01-09 12:57:15 +01:00
Leonardo de Moura
4958404f37 chore: add another simproc test 2024-01-09 12:57:15 +01:00
Leonardo de Moura
3e11b5fe15 fix: trace used builtin simprocs even if they are not in the environment 2024-01-09 12:57:15 +01:00
Leonardo de Moura
57bc058209 chore: fix tests 2024-01-09 12:57:15 +01:00
Leonardo de Moura
610fa69f15 chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
3a9b594fc5 chore: remove staging workaround 2024-01-09 12:57:15 +01:00
Leonardo de Moura
0bc8fe48e3 chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
7350d0a3ff chore: remove staging workaround 2024-01-09 12:57:15 +01:00
Leonardo de Moura
b376b1594e test: builtin simproc option that is not in the environment 2024-01-09 12:57:15 +01:00
Leonardo de Moura
88801166b6 chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
ad58deeae3 fix: allow builtin simprocs to be provided to simp even if they are not in the environment
Motivation: `simp?`
2024-01-09 12:57:15 +01:00
Leonardo de Moura
666d454b42 test: Int simprocs 2024-01-09 12:57:15 +01:00
Leonardo de Moura
b7efd200f0 chore: typo 2024-01-09 12:57:15 +01:00
Leonardo de Moura
e83e467667 feat: add simprocs for Int 2024-01-09 12:57:15 +01:00
Leonardo de Moura
2efa9de78a feat: add simprocs for UInt 2024-01-09 12:57:15 +01:00
Leonardo de Moura
25baf73005 feat: replace ite and dite shortcircuit theorems with simproc
Motivation: better `simp` cache behavior. Recall that `simp` cache
uses `dischargeDepth`.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
0bd424b5e6 feat: add simprocs for Fin 2024-01-09 12:57:15 +01:00
Leonardo de Moura
d841ef5eb5 chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
188ff2dd20 chore: remove bogus registerSimproc 2024-01-09 12:57:15 +01:00
Leonardo de Moura
7564b204ec feat: add basic simprocs for Nat 2024-01-09 12:57:15 +01:00
Leonardo de Moura
6fd7350c7b chore: update stage0 2024-01-09 12:57:15 +01:00
Leonardo de Moura
7ed4d1c432 feat: add builtin simproc support 2024-01-09 12:57:15 +01:00
Leonardo de Moura
5f847c4ce3 chore: missing copyright 2024-01-09 12:57:15 +01:00
Leonardo de Moura
090d158fb9 feat: add simp option - <simproc-name>
We can now disable `simproc`s using the same notation we use to
disable rewriting rules in the simplifier.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
81ced3bd0f feat: trace simprocs 2024-01-09 12:57:15 +01:00
Leonardo de Moura
ab721c64b3 feat: add option simprocs
It is true by default. Packages can set it to false to disable
simplification procedue support for backward compatibility.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
93369e8773 chore: fix test 2024-01-09 12:57:15 +01:00
Leonardo de Moura
23f2314da7 chore: update stage0
`Origin.decl` constructor has an extra field.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
8a23c294a4 fix: simp.trace missing pre annotation 2024-01-09 12:57:15 +01:00
Leonardo de Moura
a7a3ae13dd feat: allow extra simprocs to be provided as simp arguments 2024-01-09 12:57:15 +01:00
Leonardo de Moura
5edd59806c feat: simp only should not use default simproc set 2024-01-09 12:57:15 +01:00
Leonardo de Moura
a2aadee28f feat: simproc declaration vs simproc attribute
Allow `simproc`s to be declared without setting the `[simproc]`
attribute. A `simproc` declaration is function + pattern.

Motivation: allow them to be provided as arguments to `simp` **and** `simp only`.

TODO: track their use in `simp`.
TODO: builtin simprocs
2024-01-09 12:57:15 +01:00
Leonardo de Moura
923216f9a9 feat: add simprocs
TODO:
- `builtin_simproc` attribute
- more tests
2024-01-09 12:57:15 +01:00
Leonardo de Moura
0f9702f4b4 chore: address feedback 2024-01-09 12:57:15 +01:00
Leonardo de Moura
df53e6c4cf refactor: simplify simpImpl 2024-01-09 12:57:15 +01:00
Leonardo de Moura
916c97b625 refactor: simplify match-expressions at pre simp method 2024-01-09 12:57:15 +01:00
Leonardo de Moura
439689b219 chore: simplify mutual at simpImpl 2024-01-09 12:57:15 +01:00
Leonardo de Moura
1d78712b6c refactor: use unsafe code to break recursion in simp implementation
Motivations:
- We can simplify the big mutual recursion and the implementation.
- We can implement the support for `match`-expressions in the `pre` method.
- It is easier to define and simplify `Simprocs`.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
39f716f902 chore: fix regression due to changes in previous commits
The example was looping with the new `simp` reduction strategy. Here
is the looping trace.
```
List.reverseAux (List.reverseAux as []) bs
==> rewrite using reverseAux_reverseAux
List.reverseAux [] (List.reverseAux (List.reverseAux as []) bs)
==> unfold reverseAux
List.reverseAux (List.reverseAux as []) bs
==> rewrite using reverseAux_reverseAux
List.reverseAux [] (List.reverseAux (List.reverseAux as []) bs)
==> ...
```
2024-01-09 12:57:15 +01:00
Leonardo de Moura
22c8154811 feat: add pre simp lemmas for if-then-else terms
See new test for example that takes exponential time without new simp
theorems.
TODO: replace auxiliary theorems with simprocs as soon as we implement them.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
05e9983e25 feat: better support for match-application in the simplifier
The new test exposes a performance problem found in software
verification applications.
2024-01-09 12:57:15 +01:00
Leonardo de Moura
f51b356002 feat: add Expr.getAppArgsN 2024-01-09 12:57:15 +01:00
Leonardo de Moura
ec9570fdd0 feat: add Expr.getAppPrefix 2024-01-09 12:57:15 +01:00
Leonardo de Moura
b37fdea5bf feat: add reduceStep, and try pre simp steps again if term was reduced 2024-01-09 12:57:15 +01:00
Leonardo de Moura
29c245ceba perf: (try to) fix regression introduced by #3139 2024-01-09 12:57:15 +01:00
Joachim Breitner
b8b49c50b9 refactor: WF.Eqns: remove unreachable fix-folding (#3133)
I was about to to address the TODO

/- TODO: check arity of the given function. If it takes a PSigma as the
last argument,
        this function will produce incorrect results. -/

because we now have an arity-observing variant of `decodePackedArg?` in
`unpackArg` in `PackMutual`, and it would be prudent to use it here.

But I first wanted to create a test case that would actually exhibit
this corner case, and failed.

This code was added in 096e4eb6d0 and it had a test case, but not even
that test case seems to be actually using the `decodePackedArg?`
function, neither back then nor now.

Also, mathlib works without this code.

So this seems to be dead code, possibly due to other changes to the
system, and thus can be removed. A strategically place comments points
back to this PR in case we need to resurrect that code.
2024-01-09 08:17:36 +00:00
Geoffrey Irving
127b309a0d doc: Document that Float corresponds to 64-bit double in C (#3147)
Closes #3142.

---------

Co-authored-by: Scott Morrison <scott@tqft.net>
2024-01-09 08:07:38 +00:00
Arthur Adjedj
b7c3ff6e6d fix: manage all declarations in a given derive (#3058)
Closes #3057
2024-01-09 07:42:06 +00:00
Joachim Breitner
0aa2b83450 chore: pr-release.yml: Suggest nightly-with-mathlib (#3148)
and suggest rebasing instead of waiting, for a more actionable
suggestion.
2024-01-09 03:11:18 +00:00
Joachim Breitner
684f32fabe feat: let get_elem_tactic_trivial handle [a]'h.2 (#3132)
The pattern
```
    for h : i in [:xs.size] do
      let x := xs[i]'h.2
```
is occassionally useful to iterate over an array with the index in
hand. This PR extends the `get_elem_tactic_trivial` so that one can
simply write
```
    for h : i in [:xs.size] do
      let x := xs[i]
```

fixes #3032.
2024-01-08 16:23:09 +00:00
Joachim Breitner
eefcbbb37b chore: pr-release.yaml: indicate information using github status (#3137)
When looking at a PR I sometimes wonder which `nightly` release is this
based on, and is used for the mathlib testing.

Right now, the action uses a label (`toolchain-available`) for this, but
a label cannot easily carry more information.

It seems a rather simple way to communicate extra information is by
setting [commit
statuses](https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status);
with this change the following statuses will appear in the PR:


![statusses](https://github.com/leanprover/lean4/assets/148037/e32a24da-065e-406a-adb3-8dca8c0f157f)

One could also use
[checks](https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run)
to add more information, even with a nicely formatted markdown
description as in [this
example](https://github.com/nomeata/lean4/pull/1/checks?check_run_id=20165137082),
but it seems there you can’t set a summary that’s visible without an
extra click, and Github seems to associate these checks to “the first
workflow”, which is odd. So using statuses seems fine here.

Often one uses bots writing PR comments for this purpose, but that's a
bit noisy (extra notifications etc.), especially for stuff that happens
on every PR, but isn’t always interesting/actionable

If this works well, we can use this for more pieces of information, and
a link can be added as well.
2024-01-08 06:44:01 +00:00
Joe Hendrix
903493799d fix: reduceNat? match terms with free or meta variables (#3139)
This removes checks in `Lean.Meta.reduceNat?` that caused it to fail on
terms it could handle because they contain meta variables in arguments.
This lead to those operations being reduced using their equational
definitions and slow performance on large patterns:

```
set_option profiler true
set_option profiler.threshold 1

def testMod (x:Nat) :=
  match x with
  | 128 % 1024 => true
  | _ => false
-- elaboration took 3.02ms

def testMul (x:Nat) :=
  match x with
  | 128 * 1 => true
  | _ => false
-- type checking took 11.1ms
-- compilation of testMul.match_1 took 313ms
-- compilation of testMul took 65.7ms
-- elaboration took 58.9ms
```

Performance is slower on `testMul` than `testMod` because `whnf` ends up
evaluateing `128 * 1` using Peano arithmetic while `128 % 1024` is able
to avoid that treatment since `128 < 1024`.
2024-01-05 18:08:26 +00:00
David Thrane Christiansen
7d90b0558e chore: Netlify deployment for manual (#3138)
Set up Netlify deployment for our manual in addition to GH Pages

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-04 18:07:46 +00:00
Scott Morrison
504b6dc93f feat: do not instantiate metavariables in kabstract/rw for disallowed occurrences (#2539)
Fixes #2538.
2024-01-03 00:01:40 +00:00
Joachim Breitner
6998acad66 doc: fix typo “reursive” (#3131) 2024-01-02 17:16:24 +00:00
Kyle Miller
cc1dcf8043 feat: delaborate have inside do blocks (#3116) 2024-01-02 09:36:39 +00:00
Leonardo de Moura
f54bce2abb chore: remove unused argument 2023-12-28 10:41:04 -08:00
Joachim Breitner
1145976ff9 test: test “motive is not type correct” (#3122) 2023-12-28 15:28:17 +00:00
Marcus Rossel
13d41f82d7 doc: fix typos (#3114) 2023-12-23 18:55:48 +00:00
Sebastian Ullrich
caf7a21c6f chore: include full build in stdlib benchmark (#3104) 2023-12-23 16:27:07 +00:00
Wojciech Nawrocki
7c38649527 chore: remove workaround in widgets (#3105)
This is a follow-up on #2964 that ~~updates stage0,~~ removes a
workaround ~~, and updates release notes.~~
2023-12-22 14:52:53 +00:00
Mario Carneiro
d1a15dea03 fix: hover info for cases h : ... (#3084)
This makes hover info, go to definition, etc work for the `h` in `cases
h : e`. The implementation is similar to that used for the `generalize h
: e = x` tactic.
2023-12-21 22:39:23 +00:00
Scott Morrison
f1f8db4856 chore: begin development cycle for v4.6.0 (#3109) 2023-12-21 22:39:04 +00:00
Scott Morrison
bcc49d1c5f chore: update tests for #2966 to use test_extern (#3092)
#2966 was the `@[extern]` bug that prompted development of the
`test_extern` command, but then we merged the fix to #2966 without
updating the tests to use `test_extern`.
2023-12-21 22:22:47 +00:00
Joachim Breitner
63d00ea3c2 doc: avoid universe issue in example type class code (#3098)
by allowing `Inhabited` to apply to any sort.

fixes #3096.
2023-12-21 16:57:26 +00:00
Lean stage0 autoupdater
fdc52e0ea9 chore: update stage0 2023-12-21 12:02:01 +00:00
Sebastian Ullrich
767139b235 chore: use all cores in stdlib benchmark 2023-12-21 10:37:18 +01:00
Sebastian Ullrich
bddb2152e5 chore: default compiler.enableNew to false until development restarts (#3034) 2023-12-21 07:48:25 +00:00
Wojciech Nawrocki
8d04ac171d feat: bundle of widget improvements (#2964)
Implements RFC #2963.

Leftover tasks:
- [x] Provide companion PR to vscode-lean4 (leanprover/vscode-lean4#376)
- [x] Companion PR to std4 (leanprover/std4#467)
- [x] Companion PR to ProofWidgets4
(leanprover-community/ProofWidgets4#36)
- [X] Companion commit to mathlib4
(0f4660f655)
- [ ] ~~Update the manual chapter~~ (will do in a follow-up)
2023-12-21 06:24:33 +00:00
Kyle Miller
ae6fe098cb feat: Rust-style raw string literals (#2929)
For example, `r"\n"` and `r#"The word "this" is in quotes."#`.

Implements #1422
2023-12-20 16:53:08 +00:00
Joachim Breitner
79c7b27034 chore: pr-release: Also work with older tags (#3097) 2023-12-20 10:11:05 +00:00
Wojciech Nawrocki
2644b239a3 feat: snippet extension (#3054)
# Summary

This makes a small addition to our take on the LSP protocol
in the form of supporting snippet text edits.
It has been discussed
[here](https://github.com/microsoft/language-server-protocol/issues/592)
on the LSP issue tracker for a while,
but seems unlikely to be added anytime soon.
This feature was requested by @PatrickMassot for the purposes
of supporting Lean code templates in code actions and widgets.

---------

Co-authored-by: David Thrane Christiansen <david@davidchristiansen.dk>
2023-12-20 09:29:19 +00:00
Mac Malone
eb432cd3b7 fix: lake: save config trace before elab (#3069)
Lake will now delete any old `.olean` and save the new trace before
elaborating a configuration file. This will enable the automatic
reconfiguration of the file if elaboration fails.

Fixes an issue that was [discussed on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Invalid.20lake.20configuration/near/406717198).
2023-12-19 21:29:41 +00:00
lu-bulhoes
312ea12bc2 fix: fixing path of the generated binary in documentation (#3093)
This PR fixes the documentation error in "Extended Setup Notes", where
the path of builded binary is pointed to
`./build/bin/foo`, but the truly path is `./lake/build/bin/foo`.

---

Closes #3094 (`RFC` or `bug` issue number fixed by this PR, if any)
2023-12-19 17:26:55 +00:00
Kyle Miller
67bfa19ce0 feat: add quot_precheck for expression tree elaborators (binop%, etc.) (#3078)
There were no `quot_precheck` instances registered for the expression
tree elaborators, which prevented them from being usable in a `notation`
expansion without turning off the quotation prechecker.

Users can evaluate whether `set_option quotPrecheck false` is still
necessary for their `notation` definitions.
2023-12-18 16:52:49 +00:00
Sebastian Ullrich
3335b2a01e perf: improve avoidance of repeated Expr visits in unused variables linter (#3076)
-43% linter run time in a big proof case
2023-12-18 15:56:58 +00:00
Joachim Breitner
78816a3ee7 chore: refine PR template (#3074)
given that we now use the PR description as the commit message, the PR
template should point that out. Also, a `# Summary` is relatively
strange in a commit message, so removed it.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2023-12-18 13:47:04 +00:00
Joachim Breitner
7acbee8ae4 refactor: move unpackArg etc. to WF.PackDomain/WF.PackMutual (#3077)
extracted from #3040 to keep the diff smaller
2023-12-18 13:46:42 +00:00
Leonardo de Moura
4dd59690e0 refactor: generalize some simp methods (#3088) 2023-12-18 04:03:29 -08:00
Kyle Miller
a2226a43ac feat: encode let_fun using a letFun function (#2973)
Switches from encoding `let_fun` using an annotated `(fun x : t => b) v`
expression to a function application `letFun v (fun x : t => b)`.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-12-18 09:01:42 +00:00
Hunter Monroe
62c3e56247 doc: Bold "Diaconescu's theorem" (#3086) 2023-12-17 19:10:35 +00:00
Marcus Rossel
89d7eb8b78 doc: fix typos/indentation (#3085) 2023-12-17 18:41:46 +00:00
Scott Morrison
8475ec7e36 fix: reference implementation ByteArray.copySlice (#2967)
Fixes reference implementation of `ByteArray.copySlice`, as reported
https://github.com/leanprover/lean4/issues/2966.

Adds tests.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2023-12-16 20:26:16 +00:00
Scott Morrison
4497aba1a9 fix: don't panic in leanPosToLspPos (#3071)
Testing a problem in the REPL.
2023-12-16 04:20:45 +00:00
Joachim Breitner
cddc8089bc chore: pr-release: revert to originally used action to get PR number (#3072)
Getting the original PR number from a `workflow_run` cleanly and
reliably seems to be
basically impossible. See
<https://github.com/orgs/community/discussions/25220> for a discussion.
So for now let’s go back to the working state, even though it’s
deprecated and throws warnings.
2023-12-14 22:53:02 +00:00
Joachim Breitner
ce15b43798 chore: allow updating stage0 via workflow_dispatch (#3052)
follow-up to #3042
2023-12-14 22:46:32 +00:00
Eric Wieser
430f4d28e4 doc: mention x:h@e variant in docstring of x@e (#3073)
This was done in 1c1e6d79a7

[Zulip
thread](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Naming.20equality.20hypothesis.20in.20match.20branch/near/408016140)
2023-12-14 18:58:14 +00:00
Eric Wieser
d279a4871f chore: add the lean4 extension to the vscode workspace (#3059)
This prompts users opening the workspace (on a new device) for the first
time to install the lean extension

# Summary

Link to `RFC` or `bug` issue: N/A
2023-12-14 08:58:21 +00:00
Scott Morrison
f208d7b50f chore: refactor pr-release.yml to avoid 'await' (#3070)
#3066 is causing CI failures, e.g.
[here](https://github.com/leanprover/lean4/actions/runs/7202184616/job/19619827364).

Although there are plenty of examples of using `await` in a Github
workflow script block, the error *seems* to be about this. This refactor
hopefully works around that, but I'm still uncertain of a root cause.
2023-12-14 04:51:17 +00:00
Joachim Breitner
df18f3f1ff chore: pr-release.yml: use API to get pull request number (#3066)
partially reverting 6a629f7d7f. What a
mess.
2023-12-13 19:58:14 +00:00
Mac Malone
fbcfe6596e fix: lake: leave run options for script (#3064)
Options passed to `lake script run <name>` / `lake run <name>` after the
`<name>` will now be properly passed on through to the script rather
than being consumed by Lake.

The issue was reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Lake.20script.20flag.20.22passthrough.22.3F/near/407734447).
2023-12-13 17:45:30 +00:00
Joachim Breitner
b5b664e570 chore: pr-release.yaml: remove hardcoded date (#3061)
This fixe a surprisingly embarrassing bug introduced by me in
fa26d222cb (maybe while testing).

Enable more debug output while we are at it, to find out why sometimes
`context.payload.workflow_run.pull_requests[0]` is undefined.
2023-12-13 13:50:19 +00:00
Mac Malone
2f216b5255 fix: lake: re-elab if config olean is missing (#3036)
If a user deleted `lakefile.olean` manually without deleting
`lakefile.olean.lock`, Lake would still attempt to load it and thus
produce an error. Now it should properly re-elaborate the configuration
file.
2023-12-13 01:07:57 +00:00
Scott Morrison
d4dca3baac feat: test_extern command (#2970)
This adds a `test_extern` command.

Usage:
```
import Lean.Util.TestExtern

test_extern Nat.add 17 37
```

This:
* Checks that the head symbol has an `@[extern]` attribute.
* Writes down `t == t'`, where `t` is the term provided, and `t'` is the
reference implementation (specifically, `t` with the head symbol
unfolded).
* Tries to reduce this to `true`, and complains if this fails.

Note that the type of the term must have a `BEq` instance for this to
work: there's a self-explanatory error message if it isn't available.
2023-12-12 23:33:05 +00:00
Joachim Breitner
de7d78a9f1 chore: do not use actions-ecosystem/action-add-labels (#3055)
That action seems to be unmaintained and causes warnings
(https://github.com/actions-ecosystem/action-add-labels/issues/459).

Let's just use the API directly, like we already do in
`.github/workflows/labels-from-comments.yml`
2023-12-12 22:40:27 +00:00
Joachim Breitner
6a629f7d7f chore: robustify PR release workflow (#3051)
the workflow is triggered not only by pull-request-CI-runs but also by
others. These should be skipped.

Also, no need to query the Github API to get the pull request number and
head sha, they are part of the payload, it seems.
2023-12-12 11:23:22 +00:00
Marc Huisinga
f74516a032 doc: update quickstart guide to reference vs code setup guide (#2968)
Since the vscode-lean4 setup guide allows us to provide information on
setting up Lean 4 tailored to the user's operating system, this PR
adjusts the quickstart guide to reference the vscode-lean4 setup guide
instead.
2023-12-12 08:36:27 +00:00
Sebastian Ullrich
78200b309f fix: run_task/deactivate_task race condition on m_imp->m_closure (#2959)
Fixes #2853, unblocking my work before I get to refactoring this part of
the task manager.
2023-12-12 02:01:40 +00:00
Mario Carneiro
b120080b85 fix: move Lean.List.toSMap to List.toSMap (#3035)
This definition was clearly meant to be in the `List` namespace, but it
is also in a `namespace Lean` so it ended up as `Lean.List.toSMap`
instead of `List.toSMap`. It would be nice if #3031 made this
unnecessary, but for now this seems to be the convention.

I noticed this because of another side effect: it defines `Lean.List` as
a namespace, which means that
```lean
import Std

namespace Lean
open List

#check [1] <+ [2]
```
does not work as expected, it opens the `Lean.List` namespace instead of
the `List` namespace. Should there be a regression test to ensure that
the `Lean.List` namespace (and maybe others) are not accidentally
created? (Unfortunately this puts a bit of a damper on #3031.)
2023-12-12 01:01:24 +00:00
Scott Morrison
4b8c342833 chore: withLocation * should not fail if it closes the main goal (#2917)
Arising from discussion at
https://github.com/leanprover/lean4/pull/2909/files#r1398527730.
2023-12-12 00:45:13 +00:00
Joachim Breitner
fa26d222cb chore: refactor pr release workflow (#3020)
In particular:

* Do not use deprecated `potiuk/get-workflow-origin`.
* Use a bare checkout to push PR to `pr-releases`
* Replace `script/most-recent-nightly-tag.sh` by a one-liner inside the
workflow, so that th workflow is self-contained
2023-12-12 00:45:10 +00:00
Jannis Limperg
e2f957109f fix: omit fvars from simp_all? theorem list (#2969)
Removes local hypotheses from the simp theorem list generated by
`simp_all?`.

Fixes: #2953

---

Supersedes PR #1862
2023-12-12 00:45:07 +00:00
Scott Morrison
20dd63aabf chore: fix superfluous lemmas in simp.trace (#2923)
Fixes an issue reported on Zulip; see the test case.

* Modifies the `MonadBacktrack` instance for `SimpM` to also backtrack
the `UsedSimps` field.
* When calling the discharger, `saveState`, and then `restoreState` if
something goes wrong.

I'm not certain that it makes sense to restore the `MetaM` state if
discharging fails. I can easily change this to more conservatively just
backtrack the `UsedSimps` after failed discharging.
2023-12-11 23:51:31 +00:00
Scott Morrison
c656e71eb8 chore: make List.all and List.any short-circuit (#2972)
Changes the implementation of `List.all` and `List.any` so they
short-circuit. The implementations are tail-recursive.

This replaces https://github.com/leanprover/std4/pull/392, which was
going to do this with `@[csimp]`.
2023-12-11 23:48:15 +00:00
Lean stage0 autoupdater
104c92d4f3 chore: update stage0 2023-12-11 18:37:33 +00:00
Joachim Breitner
5cd90f5826 feat: drop support for termination_by' (#3033)
until around 7fe6881 the way to define well-founded recursions was to
specify a `WellFoundedRelation` on the argument explicitly. This was
rather low-level, for example one had to predict the packing of multiple
arguments into `PProd`s, the packing of mutual functions into `PSum`s,
and the cliques that were calculated.

Then the current `termination_by` syntax was introduced, where you
specify the termination argument at a higher level (one clause per
functions, unpacked arguments), and the `WellFoundedRelation` is found
using type class resolution.

The old syntax was kept around as `termination_by'`. This is not used
anywhere in the lean, std, mathlib or the theorem-proving-in-lean
repositories,
and three occurrences I found in the wild can do without

In particular, it should be possible to express anything that the old
syntax
supported also with the new one, possibly requiring a helper type with a
suitable instance, or the following generic wrapper that now lives in
std
```
def wrap {α : Sort u} {r : α → α → Prop} (h : WellFounded r) (x : α) : {x : α // Acc r x}
```

Since the old syntax is unused, has an unhelpful name and relies on
internals, this removes the support. Now is a good time before the
refactoring that's planned in #2921.

The test suite was updated without particular surprises.

The parametric `terminationHint` parser is gone, which means we can
match on syntax more easily now, in `expandDecreasingBy?`.
2023-12-11 17:33:17 +00:00
Mario Carneiro
178ab8ef2e fix: Option.getD eagerly evaluates dflt (#3043)
Reported [on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/Panics.20in.20Std.2EHashMap.2Efind!/near/406872395).
The `dflt` argument of `Option.getD` is not evaluated lazily, as the
documentation says, because even after `macro_inline` the expression
```lean
match opt, dflt with
| some x, _ => x
| none, e => e
```
still has the semantics of evaluating `dflt` when `opt` is `some x`.
2023-12-11 10:07:30 +00:00
Joachim Breitner
e6c0484074 chore: stage0 autoupdater action (#3042)
This Github action automatically updates `stage0` on `master` if
`src/stdlib_flags.h` and `stage0/src/stdlib_flags.h`
are out of sync there.

It bypasses the merge queue to be quick, this way, an out-of-date stage0
on on
master should only exist for a few minutes.

Needs access to a _deploy SSH key_ with write permission.
2023-12-11 09:50:27 +00:00
Eric Wieser
dd42a0919d doc: explain how to use custom lexers in the latest minted (#3047)
v3.0 is not yet released; in the meantime, the previous instructions did
not work in the latest version without some hacks.
[Zulip
thread](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/XeLaTeX.20with.20minted.20error/near/406959183)
2023-12-11 09:16:40 +00:00
Joachim Breitner
1b2bbe717d chore: remove obsolete comment in test (#3044) 2023-12-09 13:20:58 +00:00
Joachim Breitner
00359a0347 chore: update stage0 (#3041) 2023-12-08 12:14:47 +00:00
Eric Wieser
c474dff38c doc: document constructors of TransparencyMode (#3037)
Taken from
https://github.com/leanprover-community/lean4-metaprogramming-book/blob/master/md/main/04_metam.md#transparency

I can never remember which way around `reducible` and `default` go, and
this avoids me needing to leave the editor to find out.
2023-12-07 17:04:40 +00:00
Joachim Breitner
f2a92f3331 fix: GuessLex: deduplicate recursive calls (#3004)
The elaborator is prone to duplicate terms, including recursive calls,
even if the user only wrote a single one. This duplication is wasteful
if we run the tactics on duplicated calls, and confusing in the output
of GuessLex. So prune the list of recursive calls, and remove those
where another call exists that has the same goal and context that is no
more specific.
2023-12-07 09:08:46 +00:00
Kyle Miller
bcbcf50442 feat: string gaps for continuing string literals across multiple lines (#2821)
Implements "gaps" in string literals. These are escape sequences of the
form `"\" newline whitespace+` that have the interpretation of an empty
string. For example,
```
  "this is \
     a string"
```
is equivalent to `"this is a string"`. These are modeled after string
continuations in
[Rust](https://doc.rust-lang.org/beta/reference/tokens.html#string-literals).

Implements RFC #2838
2023-12-07 08:17:00 +00:00
Joachim Breitner
ec8811a75a fix: WF.Fix: deduplicate subsumed goals before running tactic (#3024)
before code like

    def dup (a : Nat) (b : Nat := a) := a + b

    def rec : Nat → Nat
     | 0 => 1
     | n+1 => dup (dup (dup (rec n)))
    decreasing_by decreasing_tactic

would run the `decreasing_tactic` 8 tims, because the recursive call
`rec n` gets duplicate due to the default paramter. Similar effects can
be observed due to dependent types or tactics like `cases`.

This is wasteful, and is confusing to the user when they use
`decreasing_by` interactively. Therfore, we now go through the proof
obligations (MVars) and if solving one would imply solving another one,
we assign the mvars to each other accordingly.

This PR is a sibling of #3004.
2023-12-07 08:04:27 +00:00
Sebastian Ullrich
b3a85631d8 chore: set warningAsError in CI only (#3030)
Don't fail local builds because of this
2023-12-06 08:18:39 +00:00
Joachim Breitner
5d35e9496e doc: fix MetavarContext markdown (#3026)
I found the documentation page hard to parse, so I figured I should fix
this. It's mostly indentation (e.g. in lists), some line breaks and
making URLs clickable.
2023-12-06 08:15:45 +00:00
bc²
d4f10bc07e feat: detail error message about invalid mutual blocks (#2949)
To prevent user confusion as in this [Zulip
message](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Matching.20on.20prop/near/341456011)
2023-12-05 10:50:10 +00:00
Marc Huisinga
feb0cb6fc4 doc: add migration guide for per-package server options (#3025)
This PR adjusts `RELEASES.md` to match the recently adjusted release
notes.

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2023-12-05 10:36:53 +00:00
Joachim Breitner
d6c81f8594 feat: GuessLex: print inferred termination argument (#3012)
With

    set_option showInferredTerminationBy true

this prints a message like

    Inferred termination argument:
    termination_by
      ackermann n m => (sizeOf n, sizeOf m)

it tries hard to use names that

 * match the names that the user used, if present
 * have no daggers (so that it can be copied)
 * do not shadow each other
 * do not shadow anything from the environment (just to be nice)

it does so by appending sufficient `'` to the name.

Some of the emitted `sizeOf` calls are unnecessary, but they are needed
sometimes with dependent parameters. A follow-up PR will not emit them
for non-dependent arguments, so that in most cases the output is pretty.

Somewhen down the road we also want a code action, maybe triggered by
`termination_by?`. This should come after #2921, as that simplifies that
feature (no need to merge termination arguments from different cliques
for example.)
2023-12-05 09:41:52 +00:00
Joachim Breitner
17825bf81d feat: GuessLex: if no measure is found, explain why (#2960)
by showing the matrix of calls and measures, and what we know about that
call (=, <, ≤, ?), e.g.

guessLexFailures.lean:27:0-33:31: error: Could not find a decreasing
measure.
    The arguments relate at each recursive call as follows:
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted)
               x1 x2 x3
    1) 29:6-25  =  =  =
    2) 30:6-23  =  ?  <
    3) 31:6-23  <  _  _
    Please use `termination_by` to specify a decreasing measure

It’s a bit more verbose for mutual functions.

It will use the user-specified argument names for functions written
```
foo (n : Nat) := …
```
but not with pattern matching like
```
foo : Nat → … 
  | n => …
```
This can be refined later and separately (and maybe right away in
`expandMatchAltsWhereDecls`).
2023-12-05 08:32:15 +00:00
Joachim Breitner
9290b491bb refactor: WF.Fix: gather subgoals (#3017)
This is pure refactoring: Instead of solving each subgoal as we
encounter it while traversing the syntax tree, we leave the `MVar`
there, at the end collect them all using `getMVarsNoDelayed`, and then
solve them.

This is a refactoring preparing for two upcoming changes:

 * removing unexpected duplicate goals that can arise from term
   duplication
 * running interactive tactics on all, not each goal (#2921)

In order to not regress with error locations, we have to associated the
`TermElabM`’s syntax refernce with the `MVar` somehow. I do this using
the existing `mkRecAppWithSyntax` expression annotation, on the `MVar`’s
type. Alternatives would be stack another `StateT` on the traversal
and accumulate `Array (MVarId, Syntax)` explicitly, but that did not
seem to be more appealing.
2023-12-04 21:42:24 +00:00
Joachim Breitner
c91ece4f58 doc: typo Runnign (#3018) 2023-12-04 16:55:07 +00:00
Eric Wieser
93a6279025 chore: add vscode cmake configuration (#3008)
This sets the build directory to `build/release` for the "CMake Tools
for Visual Studio Code" extension documented at
https://vector-of-bool.github.io/docs/vscode-cmake-tools/settings.html#cmake-builddirectory.

It also sets the generator to `make`, since otherwise it tries `Ninja`
which doesn't work.

Without these settings, the extension runs configure in a bad place at
startup.

This does *not* add the cmake tools extension to the default workspace
configuration; the goal is simply to prevent bad behavior for users who
already have the extension enabled.

# Summary

Screenshot of this in action:


![image](https://github.com/leanprover/lean4/assets/425260/6a08e5e5-77af-4ac5-85ed-a149a128e2ca)


Link to `RFC` or `bug` issue: N/A, this is not a bug nor a user-visible
feature.
2023-12-04 16:35:03 +00:00
Joachim Breitner
5c2292a923 doc: In testing doc, suggest make to pick up new tests (#2815) 2023-12-04 10:29:49 +00:00
Sebastian Ullrich
14296ae720 chore: Nix CI: update setup (#3015)
Now that we're, at least temporarily, relying more on the Nix CI,
replace some old hacks of mine with better solutions people have figured
out in the meantime.

Cachix support could probably be dropped at this point but it doesn't
really hurt.
2023-12-03 17:51:05 +00:00
Joachim Breitner
6d23450642 refactor: rewrite TerminationHint elaborators (#2958)
In order to familiarize myself with this code, and so that the next
person has an easier time, I

* added docstrings explaining what I found out these things to
* rewrote the syntax expansion functions using syntax pattern matches,
  to the extend possible
2023-12-02 10:08:07 +00:00
Joachim Breitner
92f1755e9b chore: run tests with full-ci (#3009)
it looks like inter-job outputs are just strings, not boolean values?
2023-12-01 21:14:48 +00:00
Joachim Breitner
465f0feb2d test: expand tests/lean/issue2981.lean a bit (#3007) 2023-12-01 17:52:34 +00:00
Sebastian Ullrich
24466a25f3 doc: widget code owner 2023-12-01 15:46:45 +00:00
Mac Malone
e4eff3bc6e doc: fix recent issue links in RELEASES.md (#3000)
These links were broken because the links used `issue` rather than
`issues`.
2023-12-01 14:48:24 +00:00
Arthur Adjedj
66cb44c53c fix: missing whnf in mkBelowBinder and mkMotiveBinder (#2991)
Closes #2990
2023-12-01 14:46:09 +00:00
Joachim Breitner
8be3897a8b chore: improve tests/lean/copy-produced (#3006)
* do not take an argument, no longer needed
* make it whitespace-in-filenames safe
* copy verbosely when there are changes, for better user feedback
2023-12-01 14:34:52 +00:00
Joachim Breitner
bd89787a87 chore: fix CPP warnings about static_assert (#3005)
else I see
```
[ 69%] Building CXX object runtime/CMakeFiles/leanrt.dir/platform.cpp.o
/home/jojo/build/lean/lean4/src/runtime/io.cpp:509:75: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions]
    static_assert(sizeof(std::chrono::milliseconds::rep) <= sizeof(uint64));
                                                                          ^
                                                                          , ""
/home/jojo/build/lean/lean4/src/runtime/io.cpp:517:74: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions]
    static_assert(sizeof(std::chrono::nanoseconds::rep) <= sizeof(uint64));
                                                                         ^
                                                                         , ""
2 warnings generated.
```
when building
2023-12-01 13:00:01 +00:00
Joachim Breitner
a5af90c724 chore: run CI on new labels (#3003)
CI will now run on _any_ manually added label; hard to avoid.

Fun fact: Because the `toolchain-available` label is added by a github
action with the default token, it will _not_ trigger the workflow. Lucky
coincidence.
2023-12-01 11:32:05 +00:00
Sebastian Ullrich
5937f4208a chore: CI: update github-script (#3002) 2023-12-01 08:39:51 +00:00
Sebastian Ullrich
ea5b55b8f2 doc: remove Nix docs 2023-12-01 08:32:20 +00:00
Sebastian Ullrich
0fca41ddb2 chore: CI: remove changelog job 2023-12-01 08:28:52 +00:00
Joachim Breitner
f356d8830e chore: CI: in quick mode, only Nix build runs the tests (#2998)
Following up on #2986, stop running the test suite in ci.yml in quick
mode; the test suite is run in the Nix job, and we do not need to run it
twice.

With a cold nix cache, when `lean` is rebuilt, not much changes, as both
jobs take ~20mins. But when `lean` is unchanged, the nix build should
be faster, and shaving off the (currently) 4mins in the CI.yaml run
should get us to a green PR sooner.

Another benefit is that we get the PR release sooner and even get it
when the test suite fails, which can be useful if you want to test
mathlib or other things before fixing the lean test suite.
2023-11-30 17:21:51 +00:00
Sebastian Ullrich
5b6e4faacd fix: find macOS system libraries in leanc (#2997)
Fixes #2971
2023-11-30 13:34:24 +00:00
Marcus Rossel
0ad611cf2f doc: fix typos (#2996) 2023-11-30 10:16:33 +00:00
Sebastian Ullrich
3a0edd05e6 doc: VS Code dev setup (#2961)
* multi-root workspace
* default settings including .lean line length
* tasks `build` and `test`

---------

Co-authored-by: mhuisi <mhuisi@protonmail.com>
2023-11-30 08:35:03 +00:00
Scott Morrison
99331219f9 chore: begin development cycle for v4.5.0 (#2995) 2023-11-30 01:27:33 +00:00
Joachim Breitner
18459cb537 refactor: CasesOnApp.refineThrough can return a lambda, not an open term (#2974)
which also removes an error condition at the use site.

While I am at it, I rename a parameter in `GuessLex` that I forgot to
rename earlier.

The effect will be user-visible (in obscure corner cases) with #2960, so
I’ll have the test there.

A few places would benefit from a `lambdaTelescopeBounded` that
garantees the result has the right length (eta-expanding when
necessary). I’ll look into that separately, and left TODOs here.
2023-11-29 15:58:03 +00:00
Joachim Breitner
e4f2c39ab2 test: termination checking and duplicated terms (#2993)
These tests came out of #2981 and #2982; let’s have them in master even
if the changes there will not happen right away.
2023-11-29 15:40:57 +00:00
Marc Huisinga
3025a4a9a1 chore: update stage0 (#2992)
Updates stage-0 so that we can use import auto-completion ourselves.
2023-11-29 15:26:12 +00:00
Joachim Breitner
367ac01279 chore: trim CI set by default (#2986)
The goal of this change is to run a trimmed-down CI on PRs by default,
but allows opt-in the full CI as necessary.

### Specification

The CI workflow runs in “quick” mode if it was triggered from a pull
request, and that pull request does not have the `full-ci` label set.

In “quick” mode the build matrix contains fewer jobs. At the moment
only:

* Linux-release, to get the PR releases.

In non-quick mode everything should be as before.

### Implementation notes

I created a `configure` job that combines all the previous `set-` jobs,
I guess this is faster than firing up separate jobs.

The matrix is calculated in this job; this seems to be the cleanest way
to get a dynamic matrix going (experiments using `exclude` failed). The
downside is that the matrix is now in JSON rather than Yaml syntax. The
upside is that we can (later) make it’s calculation simpler, e.g. set
default `shell` values etc.

I was not able to make it so that CI runs when the `full-ci` label is
added, but don’t do anything otherwise. I think it can be done with
another workflow listening to `labeled` and then triggering this one,
but let’s do that separately. For now, add the label and then push (or
close and reopen).

The checks
```
  if: matrix.build-stage2 || matrix.check-stage3
  if: matrix.check-stage3
```
were dead code, we did not have these fields in the matrix anymore, so I
replaced them with
```
  if: matrix.test-speedcenter
```
2023-11-29 13:24:45 +00:00
Joachim Breitner
4f2f704962 chore: make PR title check work as a merge_group check (#2987) 2023-11-29 12:03:20 +00:00
Joachim Breitner
34264a4b1d doc: Improve docstrings around Array.mk,.data,.toList (#2771)
following a discussion at

<https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Understanding.20the.20docstring.20for.20docs.23Array.2Edata/near/398705430>

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2023-11-29 08:49:13 +00:00
Scott Morrison
5d22145b83 chore: remove supportInterpreter from lake template (#2984)
Now that there is a helpful message at the point of use when
`supportInterpreter` is required, we don't need to clutter every
`lakefile` with the advice.
2023-11-29 06:16:34 +00:00
Joachim Breitner
0a6aed61e9 chore: CI: Create an all-builds-ok job (#2983)
there is a little dance with `if: success()` because otherwise a failed
`build` job would make this new job skipped, not failed, and I fear
skipped means ok when it is a required job.
So let’s make sure this job actually fails.
2023-11-29 00:10:11 +00:00
Joachim Breitner
6c7a765abb chore: Check PR title, not commit, for commit convention (#2978)
Also turn this into a proper check, run when a PR is opened or edited.

I took the liberty to rename the workflow file and name, so that one
doesn't have to look inside to guess what the workflow is doing.
2023-11-28 17:48:09 +00:00
Scott Morrison
c1f6daf1ac fix: remove unnecessary step in pr-release.yml (#2976)
This step was unnecessary, as the script uses an unauthenticated https
URL anyway, and apparently was causing a [permissions
problem](https://github.com/leanprover/lean4/actions/runs/7005903162/job/19094622187#step:8:7).
2023-11-28 13:18:20 +00:00
Joachim Breitner
ffbea840bf feat: WF.GuessLex: If there is only one plausible measure, use it (#2954)
If here is only one plausible measure, there is no point having the
`GuessLex` code see if it
is terminating, running all the tactics, only for the `MkFix` code then
run the tactics again.

So if there is only one plausible measure (non-mutual recursion with
only one varying
parameter), just use that measure.

Side benefit: If the function isn’t terminating, more detailed error
messages are shown
(failing proof goals), located at the recursive calls.
2023-11-27 22:41:40 +00:00
Mac Malone
190ac50994 doc: release notes for recent lake changes (#2938)
Release notes for PRs #2928, #2930, #2932, and #2937.
2023-11-27 18:30:45 +00:00
Mac Malone
c20d65771c refactor: lake: simplify math template & test it (#2930)
Removes the `CI` option from the `math` template. Since the template
does not currently generate a GitHub workflow, it does not do anything
out of the box except add unnecessary complexity.

The `math` template is also now tested in `tests/init` (minus the
Mathlib `require`).
2023-11-27 18:14:00 +00:00
Joachim Breitner
cbba783bcf feat: Guess lexicographic order for well-founded recursion (#2874)
This improves Lean’s capabilities to guess the termination measure for
well-founded
recursion, by also trying lexicographic orders.  For example:

    def ackermann (n m : Nat) := match n, m with
      | 0, m => m + 1
      | .succ n, 0 => ackermann n 1
      | .succ n, .succ m => ackermann n (ackermann (n + 1) m)

now just works.

The module docstring of `Lean.Elab.PreDefinition.WF.GuessLex` tells the
technical story.
Fixes #2837
2023-11-27 16:30:20 +00:00
Mac Malone
a4aaabf396 refactor: reverse pkg/lib search & no exe roots in import (#2937)
Closes #2548.

Later packages and libraries in the dependency tree are now preferred
over earlier ones. That is, the later ones "shadow" the earlier ones.
Such an ordering is more consistent with how declarations generally work
in programming languages.

This will break any package that relied on the previous ordering.

Also includes a related fix to `findModule?` that mistakenly treated
executable roots as importable.
2023-11-27 16:12:11 +00:00
Mac Malone
984d55c962 fix: lake: proper exe targets & pkg generation (#2932)
Improves executable handling in `lake exe` and `lake init`:

* `lake exe <target>` now parses `target` like a build target (as the
help text states it should) rather than as a basic name.
* `lake new foo.bar [std]` now generates executables named `foo-bar`.
* `lake new foo.bar exe` now properly creates `foo/bar.lean`.
2023-11-27 16:11:12 +00:00
Mac Malone
0249a8c15e fix: untar cloud release if no build dir (#2928)
Cloud releases will now properly be re-unpacked if the build directory
is removed. This fixes [an issue reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Some.20files.20not.20found.20in.20the.20cache/near/402921424)
with the new `.lake` directory that broke Mathlib's ProofWidgets cache.
2023-11-27 16:09:58 +00:00
Joachim Breitner
6592df52cc feat: Add MatcherApp. and CasesOnApp.refineThrough (#2882)
these are compagnions to `MatcherApp.addArg` and `CasesOnApp.addArg`
when one only has an
expression (which may not be a type) to transform, but not a concret
values.

This is a prerequisite for guessing lexicographic order (#2874). Keeping
this on a separate PR because it’s sizable, and has a clear independent
specification.
2023-11-27 15:52:32 +00:00
Mario Carneiro
9769ad6572 fix: missing withContext in simp trace (#2053)
As [reported on
Zulip](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/simp.3F.20.5B*.5D/near/322724789).

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2023-11-27 12:02:38 +00:00
Sebastian Ullrich
79251f5fa2 feat: embed and check githash in .olean (#2766)
This is an additional safety net on top of #2749: it protects users that
circumvent the build system (e.g. with `lake env`) as well as obviates
the need for TOCTOU-like race condition checks in the build system.

The check is activated by `CHECK_OLEAN_VERSION=ON`, which now defaults
to `OFF` as the sensible default for local development. When activated,
`USE_GITHASH=ON` is also force-enabled for stage 0 in order to make sure
that stage 1 can load its own core library.
2023-11-27 10:24:43 +00:00
Sebastian Ullrich
f142d9f798 fix: ignore errors on IO.FS.Handle finalization (#2935) 2023-11-27 08:17:33 +00:00
Marc Huisinga
7ff7cf9b5a feat: per-package server options (#2858)
This PR adds per-package server options to resolve #2455. It is based on
the previous work in #2456, but takes a different approach: options are
loaded for the specific file in the file worker when `print-paths` is
called, instead of loading them in the watchdog with a separate Lake
command. This change addresses review comments made in #2456.

In doing so, it introduces two new Lake config fields: 
- `leanOptions`: `-D` flag options that are passed to both the language
server and `lean` when building.
- `moreServerOptions`: `-D` flag options that are passed to the language
server.

Since `print-paths` must also accept a file path to compute the options
for that file, this PR is changing the API for `print-paths`. As there
have been numerous complaints about the name `print-paths`, I also
decided to change it to `setup-file` in this PR, since it would break
compatibility with the old Lake API anyways.

This PR deprecates the Lakefile field `moreServerArgs` in favor of
`moreGlobalServerArgs`, as suggested in the review for #2456.

Fixes #2455

---------

Co-authored-by: digama0 <mcarneir@andrew.cmu.edu>
2023-11-26 13:42:38 +00:00
Kyle Miller
5639302989 feat: pp.beta to apply beta reduction when pretty printing (#2864)
This was a Lean 3 pretty printer option. While this pretty printer
option tends to lead to confusing situations when set, it has been
frequently requested. [It is
possible](https://github.com/leanprover-community/mathlib4/pull/7910) to
implement this pretty printer option as a user, but it comes with some
artifacts -- for instance, expressions in hovers are not beta reduced.
Adding this as a core pp option is cleanest.

(We should consider having hooks into the tactic evaluator to allow
users to transform the tactic state between tactics. This would enable
beta reducing the entire local context for real, which would be useful
for teaching.)

Closes #715
2023-11-24 12:26:31 +00:00
Scott Morrison
5f5d579986 chore: remove unused MonadBacktrack instance for SimpM (#2943)
We noticed at
https://github.com/leanprover/lean4/pull/2923#discussion_r1400468371
that this instance is not used. It's arguably also incorrect (as it
doesn't backtrack the `usedTheorems` field).

Seems better to just remove to avoid confusion.

Evidence that this is dead code:
* After deleting the instance, calling `saveState` in the `SimpM` monad
raises an error `failed to synthesize instance MonadBacktrack PUnit
SimpM`.
* Understanding the `MonadBacktrack` monad leads one to believe that
would have happened, via the fact that the only instances for
`MonadBacktrack` are either concrete instances (e.g. for `MetaM`,
`TacticM`, etc), or a single lifting instance `instance [MonadBacktrack
s m] [Monad m] : MonadBacktrack s (ExceptT ε m)`. (This is good and
correct behaviour: lifting instances for `MonadBacktrack` would be hard
to model.)
* Mathlib builds after the instance is removed.

Potential evidence that I have not sought, because we don't have
sufficient tooling:
* Compiling Lean/Std/Mathlib with a debugger, breaking on entering this
code.
2023-11-24 08:44:38 +00:00
Marc Huisinga
681fca1f8f feat: import auto-completion (#2904)
This PR adds basic auto-completion support for imports. Since it still
lacks Lake support for accurate completion suggestions (cc @tydeu - we
already know what needs to be done), it falls back to traversing the
`LEAN_SRC_PATH` for available imports.

Three kinds of import completion requests are supported:

- Completion of the full `import` command. Triggered when requesting
completions in an empty space within the header.
- Known issue: It is possible to trigger this completion within a
comment in the header. Fixing this would require architecture for
parsing some kind of sub-syntax between individual commands.
- Completion of the full module name after an incomplete `import`
command.
- Completion of a partial module name with a trailing dot.

Since the set of imports is potentially expensive to compute, they are
cached for 10 seconds after the last import auto-completion request.

Closes #2655.

### Changes

This PR also makes the following changes:
- To support completions on the trailing dot, the `import` syntax was
adjusted to provide partial syntax when a trailing dot is used.
- `FileWorker.lean` was refactored lightly with some larger definitions
being broken apart.
- The `WorkerState` gained two new fields:
- `currHeaderStx` tracks the current header syntax, as opposed to
tracking only the initial header syntax in `initHeaderStx`. When the
header syntax changes, a task is launched that restarts the file worker
after a certain delay to avoid constant restarts while editing the
header. During this time period, we may still want to serve import
auto-completion requests, so we need to know the up-to-date header
syntax.
- `importCachingTask?` contains a task that computes the set of
available imports.
- `determineLakePath` has moved to a new file `Lean/Util/LakePath.lean`
as it is now needed both in `ImportCompletion.lean` and
`FileWorker.lean`.
- `forEachModuleIn` from `Lake/Config/Blob.lean` has moved to
`Lean/Util/Path.lean` as it is a generally useful utility function that
was useful for traversing the `LEAN_SRC_PATH` as well.

### Tests

Unfortunately, this PR lacks tests since the set of imports available in
`tests/lean/interactive` will not be stable. In the future, I will add
support for testing LSP requests in full project setups, which is when
tests for import auto-completion will be added as well.
2023-11-24 07:46:19 +00:00
Joachim Breitner
e34656ce75 doc: Markdown fixes in Lean.Expr (#2956)
there were wrong italics, missing backticks, missing indentation and I
took the liberty to replace `[here]` links with link targets that better
tell the reader what to expect when clicking there.
2023-11-24 06:54:43 +00:00
Joachim Breitner
5a68ad9ef4 chore: Run CI on all PRs, even base ≠ master (#2955) 2023-11-23 21:50:30 +00:00
Scott Morrison
a422f3f2c9 chore: script/most-recent-nightly-tag uses https rather than ssh repo URL (#2951)
The https URL suffices, and does not require that the caller has an
appropriate ssh key.
2023-11-23 10:27:46 +00:00
Joachim Breitner
260eaebf4e fix: PackMutual: Eta-Expand as needed (#2902)
The `packMutual` code ought to reliably replace all recursive calls to
the functions in `preDefs`, even when they are under- or over-applied.
Therefore eta-expand if need rsp. keep extra arguments around.

Needs a tweak to `Meta.transform` to avoid mistaking the `f` in
`f x1 x2` as a zero-arity application.

Includes a test case.

This fixes #2628 and #2883.
2023-11-22 14:25:56 +00:00
Joachim Breitner
dede354e77 fix: Float RecApp out of applications (#2818)
This didn't work before
```
def f (n : Nat) : Nat :=
  match n with
  | 0 => 0
  | n + 1 => (f) n
```
because the `RecApp` metadata marker gets in the way. More practically
relevant, such code is to be produced when using `rw` or `simp` in
recursive theorems (see included test case).

We can fix this by preprocessing the definitions and floating the
`.mdata` marker out of applications.

For structural recursion, there already exists a `preprocess` function;
this now also floats out `.mdata` markers.

For well-founded recursion, this introduces an analogous `preprocess`
function.

Fixes #2810.

One test case output changes: With the `.mdata` out of the way, we get a
different error message. Seems fine.

Alternative approaches are:

* Leaving the `.mdata` marker where it is, and looking around it.
  Tried in #2813, but not nice (many many places where `withApp` etc.
  need to be adjusted).
* Moving the `.mdata` _inside_ the application, so that `withApp` still
  works. Tried in #2814. Also not nice, the invariant that the `.mdata`
  is around the `.const` is tedious to maintain.
2023-11-22 14:25:09 +00:00
Sebastian Ullrich
5eb4a007a6 chore: CI: pin macos-11 to work around 12.7.1 breakage (#2946)
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2023-11-22 13:17:27 +00:00
Joachim Breitner
54dd588fc2 fix: Use whnf for mutual recursion with types hiding (#2926)
the code stumbled over recursive functions whose type doesn’t have
enough manifest foralls, like:

```
def FunType := Nat → Nat

mutual
def foo : FunType
  | .zero => 0
  | .succ n => bar n
def bar : FunType
  | .zero => 0
  | .succ n => foo n
end
termination_by foo n => n; bar n => n
```

This can be fixed by using `whnf` in appropriate places, to expose the
`.forall` constructor.

Fixes #2925, comes with test case.
2023-11-22 11:31:36 +00:00
Scott Morrison
9efdde23e0 fix: most-recently-nightly-tag does not assume a 'nightly' remote (#2947)
`script/most-recent-nightly-tag.sh` determines the most recent nightly
release in your current git history.

Previously it was assuming that you had a `nightly` remote, to pull tags
from. Now it just pulls directly from the repository by URL.
2023-11-22 10:56:39 +00:00
Scott Morrison
91917516f1 chore: run CI on merge_group (#2948)
Per
https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#triggering-merge-group-checks-with-github-actions
2023-11-22 11:24:13 +00:00
Joachim Breitner
fb30932ca7 refactor: WF.Fix: Pass all remaining goals to Term.reportUnsolvedGoals (#2922)
This only really shows up when the `decreasing_tactic` fails with
multiple goals, as in
```
macro_rules
  | `(tactic|decreasing_tactic) => `(tactic| by_cases (2 > 1))
def foo (n : Nat) : Nat := foo (n - 1)
termination_by foo n => n
```
where we now get
```
unsolved goals
case inl
n: Nat
h✝: 2 > 1
⊢ (invImage (fun a => a) instWellFoundedRelation).1 (n - 1) n


case inr
n: Nat
h✝: ¬2 > 1
⊢ (invImage (fun a => a) instWellFoundedRelation).1 (n - 1) n
```
rather than
```
LeanProject.lean:3:27

unsolved goals
case inl
n: Nat
h✝: 2 > 1
⊢ (invImage (fun a => a) instWellFoundedRelation).1 (n - 1) n

LeanProject.lean:3:27

unsolved goals
case inr
n: Nat
h✝: ¬2 > 1
⊢ (invImage (fun a => a) instWellFoundedRelation).1 (n - 1) n
```

The effect is neglectible, but the code is a bit nicer, so why not,
before someone looks at it again and wonders whether the goals are
reported separately for a reason.
2023-11-21 19:26:52 +01:00
Joachim Breitner
0adca630cc chore: update stage0 2023-11-21 18:59:22 +01:00
Joachim Breitner
37362658ab fix: eq_refl tactic’s name is eqRefl
Previously, it has `name := refl`, which looked confusing in
[the
docs](https://leanprover-community.github.io/mathlib4_docs/Init/Tactics.html#Lean.Parser.Tactic.refl),
as there is no `refl` tactic,
2023-11-21 18:59:22 +01:00
Adrien Champion
66aa2c46a8 doc: mention dite in ite docstring (#2924)
Some beginners have trouble finding the `if h : c then t else e`
(`dite`) version of `ite`. This augments `ite`'s docstring to mention
the dependent version.
2023-11-21 15:59:35 +01:00
Mario Carneiro
b97b0ad2aa feat: rename request handler (#2462)
This implements a request handler for the `textDocument/rename` LSP
request, enabling renames via F2. It handles both local renames (e.g.
`let x := 1; x` to `let y := 1; y`) as well as global renames
(definitions).

Unfortunately it does not work for "orphan" files outside a project, as
it uses ilean data for the current file and this does not seem to be
saved for orphan files. As a result, the test file does not work,
although one can manually test the implementation against a project such
as mathlib. (This issue already exists for the "references" request,
e.g. ctrl click on the first `x` in `let x := 1; x` takes you to the
second one only if you are not in an orphan file.)

* Fixes leanprover-community/mathlib4#7124
2023-11-21 13:10:52 +01:00
Joachim Breitner
fbefbce8c7 doc: Adjust contributor's docs to squash merging (#2927)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-11-21 10:13:43 +00:00
Scott Morrison
f1b274279b feat: helpful error message about supportInterpreter (#2912)
Following [@Kha's
suggestion](https://github.com/leanprover/lean4/issues/2897#issuecomment-1816043031)
from #2897.

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2023-11-21 10:31:26 +01:00
Kyle Miller
6a33afb745 feat: Lean.MVarId.cleanup configuration (#2919)
Modifies `cleanup` so that it takes (1) an array of additional fvarids
to preserve and (2) a flag to control whether to include indirect
propositions.

(This is wanted in mathlib for the `extract_goal` tactic.)
2023-11-21 10:09:48 +01:00
Joachim Breitner
9800e066bc fix: PackMutual: Deal with extra arguments (#2892)
previously, it would ignore a recursive call that has extra arguments,
which can happen when the recursive functions return something of
function type. Therefore just leave them extra arguments in place.

Fixes #2883.
2023-11-20 17:07:50 +01:00
Mac Malone
5858549037 doc: release notes for recent lake fixes
Co-authored-by: Scott Morrison <scott@tqft.net>
2023-11-20 15:51:31 +00:00
Kyle Miller
4d39a0b0e3 fix: DecidableEq deriving handler could not handle fields whose types start with an implicit argument (#2918)
Fixes #2914
2023-11-20 20:51:47 +11:00
Sebastian Ullrich
9bf0f5116b chore: more code owners 2023-11-20 09:30:18 +01:00
Scott Morrison
8b86beeb07 doc: clarify doc-string for Lean.Elab.Tactic.withLocation (#2909)
In the previous doc-string, the sentence

> "If any of the selected tactic applications fail, it will call
`failed` with the main goal mvar."

was false both for `Location.wildcard` (where it should have said "If
all", not "If any") or for `Location.targets` (where `failed` is never
called).
2023-11-20 09:15:27 +01:00
Mario Carneiro
8881517018 fix: report goals in induction with parse error 2023-11-20 09:15:27 +01:00
Eric Wieser
0668544a35 feat: add an OfNat instance for Level (#2880)
This allows writing `1 : Level`, which is pretty handy for using `Sort 1` aka `Type`.

Co-authored-by: Scott Morrison <scott@tqft.net>
2023-11-20 09:14:16 +01:00
Marcus Rossel
1362268472 doc: fix typos (#2915) 2023-11-19 20:00:47 +00:00
tydeu
65d08fdcdd chore: ignore forgotten Lake test artifacts 2023-11-17 21:25:41 -05:00
tydeu
e29c3239e3 fix: lake: whitelist loaded config olean env exts 2023-11-17 13:50:14 -05:00
Adrien Champion
ed1a98d5ae doc: add documentation for universe, open, export, variable
Add documentation comments with examples to `universe`, `open`,
`export`, and `variable`.

The documentation shows up when hovering over keywords, hopefully
improving the experience for beginners.
2023-11-17 13:19:10 +00:00
github-actions[bot]
c6e4b98793 doc: update changelog 2023-11-17 12:32:02 +00:00
Leni Aniva
ab36ed477e feat: allow trailing comma in tuples, lists, and tactics (#2643) 2023-11-17 13:31:41 +01:00
tydeu
5d1d493635 feat: bare lake init & validated pkg names 2023-11-16 12:54:52 -05:00
Mac Malone
893d480c77 refactor: lake: use plain lib name for root and native name 2023-11-16 12:49:46 -05:00
tydeu
857ba0a3e5 fix: support non-identifier library names 2023-11-16 12:48:55 -05:00
Joachim Breitner
ad77e7e762 chore: Issue template: Suggest #eval Lean.versionString (#2884)
as this works also on https://live.lean-lang.org/ or for people
not familiar with the command line.
2023-11-16 18:40:55 +01:00
Scott Morrison
b3e9bb4997 chore: update release notes after v4.3.0-rc2 2023-11-16 21:55:25 +11:00
Sebastian Ullrich
139973217c chore: more code owners 2023-11-16 10:09:54 +01:00
tydeu
b770060b9e doc: lakefile.olean compatibility check release note 2023-11-15 19:31:08 -05:00
tydeu
8a2054ca09 fix: stricter lakefile.olean compatibility check 2023-11-15 19:31:08 -05:00
tydeu
171837216a feat: IO.FS.Handle.lock/tryLock/unlock 2023-11-15 19:31:08 -05:00
tydeu
19c81a19ea feat: IO.FS.Handle.rewind/truncate 2023-11-15 19:31:08 -05:00
Sebastian Ullrich
7cc2c9f1c9 doc: code owners (#2875) 2023-11-15 18:21:23 +01:00
Alexander Bentkamp
7fb7b5c5cb chore: releases for web assembly and x86 Linux (#2855) 2023-11-15 18:18:47 +01:00
tydeu
bbc759522a doc: lake: flexible manifest release notes 2023-11-15 00:39:06 -05:00
tydeu
712d3c2292 chore: deprecate Lake.PackageConfig.manifestFile 2023-11-15 00:39:06 -05:00
tydeu
73540ecd48 feat: lake: use / in Windows manifest file paths 2023-11-15 00:39:06 -05:00
tydeu
d07e8fd6a4 test: lake: add manifest version upgrade test 2023-11-15 00:39:06 -05:00
tydeu
446d547817 refactor: lake: more flexible manifest 2023-11-15 00:39:06 -05:00
Scott Morrison
37c2ec10e9 chore: fix conditional syntax in pre-release.yml 2023-11-15 12:24:20 +11:00
Eric Wieser
6f2eb3f6b4 doc: fix typo 2023-11-15 12:19:42 +11:00
Kyle Miller
76a7754d08 fix: have parenthesizer copy source info to parenthesized term
This causes the info view to have the entire parenthesized expression be hoverable.
2023-11-14 20:24:30 +01:00
Sebastian Ullrich
77ee031172 fix: re-read HTTP header when skipping notification in Ipc.readResponseAs 2023-11-14 17:34:04 +01: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
tydeu
6d349201b4 doc: add note on .lake to RELEASES.md 2023-11-13 20:31:24 -05:00
tydeu
dcb92296f6 test: use built lake for examples/reverse-ffi 2023-11-13 20:31:24 -05:00
tydeu
4ec3d78afa chore: update tests to account for .lake 2023-11-13 20:31:24 -05:00
tydeu
2ff4821026 refactor: .lake directory for Lake outputs 2023-11-13 20:31:24 -05:00
tydeu
ffd79a0824 fix: lake: ensure untar output directory exists 2023-11-13 20:31:24 -05:00
Sebastian Ullrich
8cfcf7ce61 fix: look through binop% variants in elabCDotFunctionAlias? 2023-11-12 16:57:51 +11:00
Sebastian Ullrich
dbe1c7f459 fix: make ^ a right action, add NatPow and HomogeneousPow 2023-11-12 16:57:51 +11:00
Kyle Miller
4bd0525a99 chore: update stage0 2023-11-12 16:57:51 +11:00
Sebastian Ullrich
31f234ba3c feat: leftact%/rightact% binop variants 2023-11-12 16:57:51 +11:00
Kyle Miller
262f213391 chore: update stage0 2023-11-12 16:57:51 +11:00
Sebastian Ullrich
8b145b05e2 feat: add leftact%/rightact% syntax 2023-11-12 16:57:51 +11:00
Scott Morrison
f3c3a1b62d feat: find Decidable instances via unification (#2816)
Because `Decidable` carries data,
when writing `@[simp]` lemmas which include a `Decidable` instance on the LHS,
it is best to use `{_ : Decidable p}` rather than `[Decidable p]`
so that non-canonical instances can be found via unification rather than
typeclass search.

(Previously this behaviour was often being hidden by the default `decide :=
true` in `simp`.)
2023-11-12 00:47:13 +00:00
Scott Morrison
1f68dec119 chore: fix commit used for PR release (#2861)
We were checking out the synthetic merge commit between the PR `HEAD`
and `master`, and this was then breaking the logic to determine which
nightly-testing branches to use in Mathlib and Std.
2023-11-11 00:35:27 +00:00
Joachim Breitner
fd0a209f74 refactor: TerminationHint: Remove duplicted code line (#2859)
(I sincerely hope that erasing from a map is idempotent :-))
2023-11-10 16:17:27 +00:00
Marcus Rossel
5189578a48 doc: fix typo in Array.Mem docstring (#2856) 2023-11-10 11:16:32 +00:00
Leonardo de Moura
dcb40f67c1 chore: update RELEASES.md 2023-11-09 04:06:30 -08:00
Leonardo de Moura
e53952f167 chore: fix tests 2023-11-09 04:06:30 -08:00
Leonardo de Moura
d7c05a5ac4 fix: fixes #2042 2023-11-09 04:06:30 -08:00
Scott Morrison
ac73c8d342 feat: Lean.Linter.logLintIf (#2852)
A utility function moving from Mathlib.
2023-11-09 23:00:34 +11:00
Scott Morrison
007b1b5979 feat: extend API of KVMap (#2851) 2023-11-09 22:59:56 +11:00
Sebastian Ullrich
b278172b7c chore: add import Lean benchmark 2023-11-07 18:46:28 +01:00
Leonardo de Moura
d9eddc9652 feat: ensure nested proofs having been abstracted in equation and unfold auxiliary theorems 2023-11-07 06:23:45 -08:00
Leonardo de Moura
2099190ad4 chore: do not abstract nested proofs in a proof 2023-11-07 06:23:45 -08:00
Eric Wieser
72f7144403 doc: mention the proof-binding syntax in match
This comes up over and over again in the zulip; let's document it!
2023-11-06 11:28:03 -08: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
Joachim Breitner
b1f2fcf758 fix: Escape ? in C literal strings to avoid trigraphs
This fixes #3829
2023-11-06 16:25:00 +01:00
Scott Morrison
37c154b6de chore: use flow control rather than exit codes in CI scripts (#2828) 2023-11-06 06:08:12 +00:00
Scott Morrison
f201f63e49 chore: fix identification of most recent nightly tag (#2827) 2023-11-06 03:53:06 +00:00
Scott Morrison
691113ca7c chore: add Mathlib CI comments using the mathlib bot (#2824) 2023-11-06 00:25:41 +00:00
Joachim Breitner
ea20911a85 feat: Better error location in structural recursion (#2819)
previously, only the WellFounded code was making use of the error
location in the RecApp-metadata. We can do the same for structural
recursion. This way,
```
def f (n : Nat) : Nat :=
  match n with
  | 0 => 0
  | n + 1 => f (n + 1)
```
will show the error with squiggly lines under `f (n + 1)`, and not at
`def f`.
2023-11-05 22:24:17 +01:00
Sebastian Ullrich
b0d1c3b99c perf: avoid quadratic number of info tree nodes in DecEq deriving handler 2023-11-04 13:59:23 -07:00
Scott Morrison
8cf9d13ca4 chore: still fixing CI (#2817) 2023-11-04 06:32:05 +00:00
Leonardo de Moura
47c09ac36c chore: the previous commit exposed an issue with simp
`simp` was previously swallowing runtime exceptions and masking an
issue with this example.

`runT` is defined by well-founded recursion, but reducing the ground
term `runT x` takes a long time when `decide := true`.

Remark PR #2722 changes the `decide` default value to `false`.

When `decide := true`, we should probably have better diagnostics /
error messages for this kind of situation.
2023-11-03 05:56:59 -07:00
Leonardo de Moura
4afcdeb771 fix: fixes #2775
fixes #2744
2023-11-03 05:56:59 -07:00
Scott Morrison
e217ad3929 chore: more adjustments to new CI scripts (#2811) 2023-11-03 02:34:23 +00:00
Henrik Böving
1d061da98f fix: --no-build lake test for new naming scheme 2023-11-02 23:21:47 +01:00
Henrik Böving
59d3b3d85a chore: update stage0 2023-11-02 23:21:47 +01:00
Henrik Böving
433c094e95 feat: LLVM bc separation for CMake 2023-11-02 23:21:47 +01:00
Siddharth Bhat
5980e665a8 test: add test of LLVM integration into lake 2023-11-02 23:21:47 +01:00
Siddharth Bhat
3b175fdb0e feat: lake LLVM backend support
Co-authored-by: Henrik Böving <hargonix@gmail.com>
Co-authored-by: Mac Malone <tydeu@hatpress.net>
2023-11-02 23:21:47 +01:00
Siddharth Bhat
145a4952e5 feat: add internal flag lean_has_llvm_backend 2023-11-02 23:21:47 +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
Henrik Böving
1b3799ecde fix: set LEANC_CC to the CMake CC by default
In LLVM builds the Cmake CC is necessarily clang -> leanc will be able
to act on LLVM bitcode files if configured this way.

Co-authored-by: Siddharth <siddu.druid@gmail.com>
2023-11-02 23:21:47 +01:00
Siddharth Bhat
3369356788 fix: remove target triple parameter from FFI that no longer exists in the Lean API 2023-11-02 23:21:47 +01:00
Siddharth Bhat
b8d81e1081 fix: option parsing for bitcode, needs to be -b 2023-11-02 23:21:47 +01:00
Siddharth Bhat
0b37bad2cb feat: split bitcode optimization and object file building to be outside lean 2023-11-02 23:21:47 +01:00
Mario Carneiro
82196efe94 feat: hovers on open and export decls 2023-11-02 17:01:51 +01:00
Scott Morrison
4934f5c56d chore: force push to nightly branch when making nightly-YYYY-MM-DD tags (#2808) 2023-11-02 12:05:15 +00:00
Scott Morrison
e360544001 chore: don't run irrelevant CI steps (#2807) 2023-11-02 11:45:19 +00:00
Joachim Breitner
03b681c056 doc: Add docstrings to dbg_trace and assert! in do blocks (#2787)
they had doc strings in their term forms, but the doElem variant did
not, as noted [on zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Infoview.20hangs.20after.20using.20.60IO.2Eprintln.60.20in.20.60Delab.60/near/399317734)
2023-11-02 11:10:42 +01:00
Scott Morrison
1bc07a4e06 chore: fix to Mathlib combined CI (#2806) 2023-11-02 09:54:08 +00:00
Scott Morrison
1e915b1248 chore: fix to Mathlib combined CI (#2804) 2023-11-02 06:21:19 +00:00
Scott Morrison
da32b5f837 feat: use nightly-testing-YYYY-MM-DD branches on Mathlib for testing PRs, and be more conservative about launching Mathlib CI (#2798) 2023-11-02 12:07:06 +11:00
Mauricio Collares
cfe5a5f188 chore: change simp default to decide := false (#2722) 2023-11-02 10:06:38 +11:00
TAKANO Mitsuhiro
29b09b0900 chore: CI: use setup-emsdk@v12 (#2796)
Fix for below warning in GitHub Actions.

```
Web Assembly
The following actions uses node12 which is deprecated and will be forced to run on node16: mymindstorm/setup-emsdk@v11. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
```
2023-11-01 18:53:08 +01:00
Scott Morrison
9d2ea99753 chore: fix duplication in release notes (#2794) 2023-11-01 00:52:49 +00:00
tydeu
72fdddfed3 test: adjustment for lake update behavior change 2023-10-31 13:25:26 -04:00
tydeu
793329fd56 fix: lake: consistent order for manifest packages 2023-10-31 13:25:26 -04:00
Scott Morrison
55bd2eb2e1 feat: reorder Lake help 2023-10-31 13:24:44 -04:00
Scott Morrison
c359d03b60 chore: begin development cycle for v4.4.0 (#2792) 2023-10-31 08:57:26 +00:00
Scott Morrison
49bdeb3c46 doc: complete release notes for v4.3.0-rc1 (#2791) 2023-10-31 02:50:06 +00:00
Leonardo de Moura
db281f60fe fix: fixes #2178 (#2784) 2023-10-30 15:06:56 +11:00
Scott Morrison
7286dfa38a feat: withAssignableSyntheticOpaque in assumption (#2596)
* feat: withAssignableSyntheticOpaque in assumption
* add test
2023-10-30 04:00:52 +00:00
thorimur
50f2154cbb fix: make rw [foo] look in the local context for foo before it looks in the environment (#2738) 2023-10-30 14:08:02 +11:00
Parth Shastri
642bc5d8f3 fix: replace DecidableEq with BEq/LawfulBEq in List mem theorems (#2041) 2023-10-30 14:03:16 +11:00
Joachim Breitner
f74ae5f9c0 feat: Array.mem: Avoid DecidableEq, set up decreasing_trivial (#2774)
The notation `a ∈ as` for Arrays was previously only defined with
`DecidableEq` on the elements, for (apparently) no good reason. This
drops this requirements (by using `a ∈ as.data`), and simplifies a bunch
of proofs by simply lifting the corresponding proof from lists.

Also, `sizeOf_lt_of_mem` was defined, but not set up to be picked up by
`decreasing_trivial` in the same way that the corresponding List lemma
was set up, so this adds the tactic setup.

The definition for `a ∈ as` is intentionally not defeq to `a ∈ as.data`
so that the termination tactics for Arrays don’t spuriously apply when
recursing through lists.
2023-10-30 13:47:30 +11:00
Eric Rodriguez
df6626f06b doc: fix a link in development documentation #2780 2023-10-30 10:58:25 +11:00
Kyle Miller
5fc079d9ce fix: dsimp missing consumeMData when closing goals by rfl (#2776)
Fixes #2514
2023-10-30 09:32:32 +11:00
Leonardo de Moura
af301fac55 chore: update stage0 2023-10-29 09:41:48 -07:00
Leonardo de Moura
175a6ab606 refactor: add Init/MetaTypes to workaround bootstrapping issues
Motivation: we could not set `simp` configuration options at `WFTactics.lean`
2023-10-29 09:38:23 -07:00
Leonardo de Moura
a53ec40df1 chore: update stage0 2023-10-29 09:18:23 -07:00
Leonardo de Moura
1abd5cc665 chore: add simp option unfoldPartialApp
It is not being used yet, but we need to add it before solving issue #2042.
Reason: bootstrapping.
2023-10-29 09:12:21 -07:00
Leonardo de Moura
08c47b2d61 chore: update stage0 2023-10-29 09:07:33 -07:00
Patrick Massot
c916238e5c feat: lake: sensible default arguments for math template (#2770) 2023-10-29 10:39:43 -04:00
Scott Morrison
f76a17b33f chore: run CI against the head of the branch, not a virtual merge with master (#2769) 2023-10-27 21:46:49 +11:00
Scott Morrison
dba299ac6a chore: update 'nightly' branch to track nightly releases (#2767) 2023-10-27 21:46:06 +11:00
Sebastian Ullrich
6c5f79c0df chore: update stage0 2023-10-26 10:47:14 +02:00
Sebastian Ullrich
23c68cfc5b fix: remove unguarded check_interrupted call 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
9874848f83 perf: inline checkInterrupted
Amazingly, the extra result allocation seems to have triggered a mathlib
heartbeat timeout
2023-10-26 08:33:09 +02:00
Sebastian Ullrich
d3bc2ac1a9 fix: switch to C++ interruption whitelist 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
462a583d98 fix: do not throw interrupt exceptions inside pure functions 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
c5691f816a feat: cancel tasks on document edit 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
fa3cf4d613 feat: translate interrupted kernel exception 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
74b8dda181 feat: check task cancellation in elaborator 2023-10-26 08:33:09 +02:00
Sebastian Ullrich
5f37f7d86f feat: move check_interrupted from unused thread class to Task cancellation 2023-10-26 08:33:09 +02:00
Leonardo de Moura
dbcc7966cf test: for simp [x] where x is a let-variable 2023-10-25 03:12:35 -07:00
Leonardo de Moura
a3642bd8d9 feat: add support for expanding let-declarations to simp
Given a local context containing `x : t := e`,
`simp (config := { zeta := false }) [x]` will expand `x` even
if `zeta := false`.
2023-10-25 03:12:35 -07:00
Leonardo de Moura
771ec8324c chore: fix configuration for UnificationHints 2023-10-25 03:12:35 -07:00
Leonardo de Moura
691defdc5d chore: typos and PR feedback
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2023-10-25 03:12:35 -07:00
Leonardo de Moura
3b831271ee fix: fixes #2669 #2281 2023-10-25 03:12:35 -07:00
Leonardo de Moura
3a13200772 refactor: add configuration options to control WHNF
This commit also removes parameter `simpleReduce` from discrimination
trees, and take WHNF configuration options.
Reason: it is more dynamic now. For example, the simplifier
will be able to use different configurations for discrimination tree insertion
and retrieval. We need this feature to address issues #2669 and #2281

This commit also removes the dead Meta.Config field `zetaNonDep`.
2023-10-25 03:12:35 -07:00
Leonardo de Moura
aecc83e2fc chore: add some doc strings and cleanup 2023-10-25 03:12:35 -07:00
tydeu
170fd845f2 feat: LAKE_PKG_URL_MAP 2023-10-25 04:17:53 -04:00
Denis Gorbachev
d126c099f4 doc: Update contribution guides (#2624)
* doc: update contribution guides

This moves the contribution guide from `doc/contributions.md` to `CONTRIBUTING.md`.
2023-10-25 13:05:55 +11:00
thorimur
6063deb6bd fix: rw ... at h unknown fvar bug (#2728) 2023-10-25 01:52:19 +00:00
thorimur
291e95e3c5 fix: add instantiateMVars to replaceLocalDecl (#2712)
* fix: `instantiateMVars` in `replaceLocalDecl`
* docs: update `replaceLocalDecl`
* test: `replaceLocalDecl` instantiates mvars
2023-10-25 10:26:09 +11:00
Buster Copley
bccbefdc1c fix: version numbers in code actions (#2721)
Co-authored-by: Richard Copley <buster@buster.me.uk>
2023-10-24 22:55:47 +11:00
Scott Morrison
d07ec56c33 chore: correcting typos (#2746) 2023-10-24 10:55:30 +00:00
Leonardo de Moura
b00c13a00e chore: remove "paper cut" when using Fin USize.size (#2724) 2023-10-24 21:06:35 +11:00
Mario Carneiro
eaf85607f4 fix: don't pack ._ files on MacOS (#2743) 2023-10-24 21:03:51 +11:00
Leonardo de Moura
a7323c9805 feat: use forall_prop_domain_congr in simp tactic
closes #1926
2023-10-23 06:19:19 -07:00
Leonardo de Moura
50d0aced7f feat: add auxiliary lemma for simp 2023-10-23 06:19:19 -07:00
Leonardo de Moura
0bd15be1a1 chore: fix tests output 2023-10-22 06:48:22 -07:00
Leonardo de Moura
370476cc14 fix: bug at substCore 2023-10-22 06:48:22 -07:00
Leonardo de Moura
9a7565d66c perf: closes #2552 2023-10-22 06:48:22 -07:00
Leonardo de Moura
52f1000955 chore: update doc, add support for modn 2023-10-20 19:07:48 -07:00
Leonardo de Moura
9d02e0ee6f chore: remove unnecessary % operations at Fin.mod and Fin.div
We now have the missing proofs `Nat.mod_le` and `Nat.div_le_self` in
core.
See:
https://github.com/leanprover/std4/pull/286#discussion_r1359807875
2023-10-20 19:07:48 -07:00
thorimur
1facbde113 test: ensure dsimp can use rfl thm constants 2023-10-20 19:06:40 -07:00
thorimur
b5e95bf632 fix: allow constants to be marked for dsimp 2023-10-20 19:06:40 -07:00
tydeu
6c20673737 refactor: change postUpdate? config to a decl 2023-10-20 21:38:31 -04:00
github-actions[bot]
b52317537c doc: update changelog 2023-10-20 18:51:37 +00:00
tydeu
6e98453189 chore: lake: test auto-manifest & update cleaning 2023-10-20 14:51:10 -04:00
tydeu
e435a45af7 feat: lake: create manifest on load if missing 2023-10-20 14:51:10 -04:00
Leonardo de Moura
419100d42b feat: add Simp.Config.ground for simplifying nested ground terms
This is an experimental new feature. We need more bells and whistles,
and `cbv` tactic for improving its performance.
2023-10-19 13:59:17 -07:00
tydeu
67b5cd9c0e feat: lake: run_io to execute IO at term elab time 2023-10-19 13:27:35 -04:00
tydeu
ca6d1fd47a chore: lake: simplify config decl syntax
* deprecate `:=` syntax in config decls
* standardize field syntax across `where` and `{...}`
2023-10-19 13:25:07 -04:00
Scott Morrison
fb0d0245db Revert "Cancel outstanding tasks on document edit in the language server" (#2703)
* Revert "perf: inline `checkInterrupted`"

This reverts commit 6494af4513.

* Revert "fix: switch to C++ interruption whitelist"

This reverts commit 5aae74199b.

* Revert "fix: do not throw interrupt exceptions inside pure functions"

This reverts commit c0e3b9568e.

* Revert "feat: cancel tasks on document edit"

This reverts commit a2e2481c51.

* Revert "feat: translate `interrupted` kernel exception"

This reverts commit 14c640c15e.

* Revert "feat: check task cancellation in elaborator"

This reverts commit 2070df2328.

* Revert "feat: move `check_interrupted` from unused thread class to `Task` cancellation"

This reverts commit bf48a18cf9.
2023-10-17 00:59:11 +00:00
SADIK KUZU
e0802d2dea fix: typos in specialize.cpp (#2702) 2023-10-17 00:58:10 +00:00
tydeu
4441662490 test: lake: tests/manifest -> tests/depTree
also clarify its difference  distinction with `tests/clone`
2023-10-16 13:35:24 -04:00
tydeu
8db978bb10 chore: lake: fail if no error in tests/serve 2023-10-16 13:35:24 -04:00
tydeu
894c3abb37 chore: lake: ignore manifest in examples/scripts 2023-10-16 13:35:24 -04:00
tydeu
2a91d3cf68 fix: lake: casing in tests/order/clean.sh 2023-10-16 13:35:24 -04:00
David Thrane Christiansen
d15a0a4acb chore: lake: explicit branch name in tests/clone 2023-10-16 09:29:31 +00:00
Mario Carneiro
e0cba05167 refactor: env extensions can only modify .extensions (#2661) 2023-10-16 14:22:09 +11:00
Scott Morrison
2f9c964753 chore: update RELEASES.md to reflect v4.2.0-rc2 (#2692) 2023-10-16 01:19:12 +00:00
Mario Carneiro
c0b021e196 fix: pp projection indices starting at 1 2023-10-15 14:25:00 -07:00
Scott Morrison
3e79ddda27 chore: add items to RELEASES.md (#2687) 2023-10-15 02:51:58 +00:00
Scott Morrison
1e74c6a348 feat: use nat_gcd in the kernel (#2533)
* feat: use nat_gcd in the kernel

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-10-15 13:49:41 +11:00
Scott Morrison
66ab016723 chore: simp tracing reports ← (#2621)
* chore: simp tracing reports ←

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2023-10-15 12:12:10 +11:00
github-actions[bot]
6df09d16e5 doc: update changelog 2023-10-14 17:20:54 +00:00
Leonardo de Moura
b8af36fba0 chore: update comments at src/Lean/Meta/Basic.lean
Co-authored-by: Timo <timorcb@gmail.com>
2023-10-14 10:20:29 -07:00
Leonardo de Moura
29198371d9 chore: update comments at src/Lean/Meta/ExprDefEq.lean
Co-authored-by: Timo <timorcb@gmail.com>
2023-10-14 10:20:29 -07:00
Leonardo de Moura
3bc18797b0 fix: ensure transient cache results for different transparency modes don't mix up 2023-10-14 10:20:29 -07:00
Sebastian Ullrich
6d0a3287e0 fix: cache typos 2023-10-14 10:20:29 -07:00
Leonardo de Moura
e3b08060d0 fix: chore add workaround for corrupted cache 2023-10-14 10:20:29 -07:00
Leonardo de Moura
2253b788b4 perf: fine grain isDefEq cache for terms not containing metavariables 2023-10-14 10:20:29 -07:00
Arthur Adjedj
ff20a14c69 fix : make mk_no_confusion_type handle delta-reduction when generating telescope (#2501)
* fix : make `mk_no_confusion_type` handle delta-reduction when checking the inductive type.

* tests: extend `2500.lean`
2023-10-14 17:18:37 +11:00
mhuisi
d0ae87d13f chore: improve error 2023-10-13 16:42:19 +02:00
mhuisi
b5348786a6 fix: pre-dependency-build-mode compatibility 2023-10-13 16:42:19 +02:00
mhuisi
253a5b931d fix: correct handling of FileWorker restarts 2023-10-13 16:42:19 +02:00
mhuisi
9945fa04d6 feat: FileWorker handling of --no-build 2023-10-13 16:42:19 +02:00
Sebastian Ullrich
4e1d95ce58 feat: pass along extra print-paths flags and handle no-build Lake error in server 2023-10-13 16:42:19 +02:00
tydeu
f3de5eb1e8 feat: lake: --no-build to exit before a build 2023-10-13 14:42:58 +02:00
github-actions[bot]
9f63a9f288 doc: update changelog 2023-10-13 07:57:12 +00:00
Sebastian Ullrich
6494af4513 perf: inline checkInterrupted
Amazingly, the extra result allocation seems to have triggered a mathlib
heartbeat timeout
2023-10-13 09:52:26 +02:00
Sebastian Ullrich
5aae74199b fix: switch to C++ interruption whitelist 2023-10-13 09:52:26 +02:00
Sebastian Ullrich
c0e3b9568e fix: do not throw interrupt exceptions inside pure functions 2023-10-13 09:52:26 +02:00
Sebastian Ullrich
a2e2481c51 feat: cancel tasks on document edit 2023-10-13 09:52:26 +02:00
Sebastian Ullrich
14c640c15e feat: translate interrupted kernel exception 2023-10-13 09:52:26 +02:00
Sebastian Ullrich
2070df2328 feat: check task cancellation in elaborator 2023-10-13 09:52:26 +02:00
Sebastian Ullrich
bf48a18cf9 feat: move check_interrupted from unused thread class to Task cancellation 2023-10-13 09:52:26 +02:00
tydeu
42802f9788 feat: lake: postUpdate? + test 2023-10-13 02:31:06 -04:00
tydeu
275af93904 test: lake: show module with failed import 2023-10-12 22:16:04 -04:00
tydeu
99b78bcc23 fix: stdin := .null in IO.Process.output 2023-10-12 08:55:26 +02:00
Mario Carneiro
6bdfde7939 fix: quot reduction bug 2023-10-11 21:25:34 -07:00
Scott Morrison
5d096c3fd8 chore: make Environment.add private (#2642)
* feat: replay constants into an Environment

* suggestions from code review

* chore: make Environment.add private

* patch Lake to use Environment.add via extern
2023-10-12 15:00:27 +11:00
Mario Carneiro
b558b5b912 perf: use quick_is_def_eq first 2023-10-11 19:35:16 -07:00
Scott Morrison
57e23917b6 fix: implementation of Array.anyMUnsafe
move test
2023-10-11 11:20:45 +02:00
Mario Carneiro
14e626a925 feat: ToMessageData (α × β) instance 2023-10-11 10:12:06 +02:00
Wojciech Nawrocki
856a9b5153 fix: treat pretty-printed names as strings
I initially expected `Name`s to always faithfully represent internal data, in particular that a name with macro scopes would have a form such as  ```foo._@.Module._hyg.1``, and that tombstones would only appear in types that represent pretty-printed output such as as `String` or `Format`. However, that is not what happens. We have `sanitizeNames` which rewrites the `userName` field of local hypotheses to be `Name.str .anonymous "blah✝"`.

Then in the server code, we put these into `names : Array Name`e. This works fine for displaying in the infoview, but if we try to deserialize an `InteractiveHypothesisBundle` inside an RPC method for widget purposes, the `FromJson Name` instance blows up in `String.toName`.

I think my preferred solution is to, rather than 'fix' `String.toName` to accept these names with tombstones, stop pretending that they are actual `Name`s and re-type `InteractiveHypothesisBundle.names : Array String`. This should be a backwards-compatible change w.r.t. infoview code as the JSON representation is a string in either case. It is not backwards compatible w.r.t. meta code that uses this field.
2023-10-11 09:51:14 +02:00
David Christiansen
0700925bbe doc: add a brief description of ccache 2023-10-11 09:30:46 +02:00
David Christiansen
7450a8cfa3 doc: describe commit conventions for update-stage0
Updates to stage0 should be their own commits.
2023-10-11 09:30:46 +02:00
Scott Morrison
97f5ad7804 chore: change trustCompiler axiom to True (#2662) 2023-10-11 06:59:03 +00:00
Mario Carneiro
115991066d chore: remove unnecessary partial in ForEachExpr.visit (#2657) 2023-10-11 04:28:54 +00:00
Scott Morrison
076908d13b feat: replay constants into an Environment (#2617)
* feat: replay constants into an Environment
2023-10-11 14:08:03 +11:00
Scott Morrison
833e778cd5 chore: add axiom for tracking use of reduceBool / reduceNat (#2654) 2023-10-11 01:47:59 +00:00
Scott Morrison
ca0e6b0522 chore: fix MVarId.getType' (#2595)
* chore: fix MVarId.getType'

* add test
2023-10-09 11:04:33 +00:00
Scott Morrison
41ed5ddf57 chore: add missing if statements to pr-release.yml workflow (#2639) 2023-10-09 04:00:56 +00:00
Sebastian Ullrich
00e981edcd perf: do not inhibit caching of default-level match reduction 2023-10-08 17:24:20 -07:00
Leonardo de Moura
9f50f44eed perf: missing cache at whnfImp 2023-10-08 17:22:14 -07:00
int-y1
ce4ae37c19 chore: fix more typos in comments 2023-10-08 14:37:34 -07:00
int-y1
8d7520b36f chore: fix typos in comments 2023-10-08 10:46:05 +02:00
Sebastian Ullrich
184318fd8b fix: eliminate widestring uses 2023-10-07 12:07:19 +02:00
David Christiansen
b0b922bae4 feat: list the valid case tags when the user writes an invalid one
Before, Lean would simply emit the message "tag not found". With this
change, it also tells the user what they could have written that would
be accepted.
2023-10-06 11:14:21 +02:00
David Christiansen
4c6d2b3998 doc: fix typo in comment
Fix a misspelled/mistyped word in a comment.
2023-10-06 11:14:21 +02:00
David Thrane Christiansen
b3ff006eb8 doc: add missing character in testing.md
The testing docs omit the `s` in the `tests` directory at one point. The incorrect directory name threw me off - it will probably throw others off.
2023-10-06 11:07:10 +02:00
Siddharth
734ce1ef2f feat: show path of failed import (#2616) 2023-10-04 23:38:59 -04:00
Denis Gorbachev
42cb59efdd doc: fix the link to contribution guidelines (#2623) 2023-10-05 12:02:55 +11:00
Sebastian Ullrich
dceed634a0 doc: fix typo in quickstart.md 2023-10-04 17:49:50 +02:00
Mario Carneiro
89b65c8f1d feat: make Environment.mk private (#2604)
* feat: make `Environment.mk` private

---------
2023-10-04 22:02:54 +11:00
Alexander Bentkamp
7dc1618ca5 feat: Web Assembly Build (#2599)
Co-authored-by: Rujia Liu <rujialiu@user.noreply.github.com>
2023-10-04 09:04:20 +02:00
kuruczgy
83c7c29075 fix: XML parsing bugs (#2601)
* fix: make XML parser handle trailing whitespace in opening tags

* fix: make XML parser handle comments correctly

---------

Co-authored-by: György Kurucz <me@kuruczgy.com>
2023-10-04 11:51:22 +11:00
Alex J Best
44bc68bdc6 fix: withLocation should use withMainContext for target (#2607) 2023-10-04 10:12:43 +11:00
Arthur Adjedj
6b93f05cd1 feat : derive DecidableEq for mutual inductives (#2591)
* feat : derive `DecidableEq` for mutual inductives

* doc: document `RELEASES.md`

---------
2023-10-03 02:17:13 +00:00
github-actions[bot]
1572e55f06 doc: update changelog 2023-10-02 13:03:48 +00:00
Sebastian Ullrich
842881e137 fix: default for MACOSX_DEPLOYMENT_TARGET (#2598)
Co-authored-by: Scott Morrison <scott@tqft.net>
2023-10-02 13:03:19 +00:00
Denis Gorbachev
4b47462ccc refactor: remove redundant let 2023-10-02 14:27:04 +02:00
thorimur
8c0f0b5250 docs: update RELEASES.md for #2502 (#2606) 2023-10-02 21:38:54 +11:00
Denis Gorbachev
e6292bc0b8 doc: fix docstring typos (#2605)
* lake: fix a typo in `get_config?` syntax doc
* fix a typo in `withImporting` doc
2023-09-30 07:51:35 -04:00
Joachim Breitner
06e057758e chore: Remove unused variables from kernel
when I build lean locally, I get a nice and warning-free build
experience with the exception of these two unused variables. They can
probably go?
2023-09-27 09:43:07 -07:00
Scott Morrison
75f91f372c chore: add release note about lake startup time (#2597) 2023-09-27 08:20:48 +00:00
Joachim Breitner
ae470e038e docs: fix doc comment syntax in declModifiers doc comment (#2590)
The hover on `declModifiers` says doc comments are `/-! … -/`, when it
should say `/-- … -/`.
2023-09-27 11:57:40 +10:00
Mario Carneiro
e6fe3bee71 fix: hover term/tactic confusion 2023-09-26 10:16:37 +02:00
Scott Morrison
a5a150a862 chore: begin development cycle for v4.3.0 (#2585) 2023-09-26 04:18:54 +00:00
Sebastian Ullrich
4acdcc4c40 doc: add token error change to RELEASES.md (#2579) 2023-09-26 11:38:59 +10:00
tydeu
decf7a042a perf: lake: lazily acquire repo URL/tag in :release 2023-09-25 17:07:27 -04:00
Sebastian Ullrich
2f51d5af49 chore: CI: add backport action 2023-09-25 11:33:14 +02:00
tydeu
2ac782c315 test: lake: add env & dep cfg benchmarks + cleanup 2023-09-22 20:31:48 -04:00
tydeu
16ceb4bf82 perf: lake: no lean --githash when collocated 2023-09-22 16:56:12 -04:00
Sebastian Ullrich
83ecac4fd8 perf: lake: build lakefile environment incrementally 2023-09-22 22:01:07 +02:00
Sebastian Ullrich
c3fd34f933 chore: disable "lake build lean" benchmark for now 2023-09-22 20:05:20 +02:00
Mac Malone
57fb580a71 doc: fix Inundation README typo
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-09-22 20:05:20 +02:00
tydeu
00efb7eaca test: add reconfigure benchmark 2023-09-22 20:05:20 +02:00
tydeu
5b2e3e2b0a test: make compatible with olean caching 2023-09-22 20:05:20 +02:00
tydeu
8dba187910 chore: inundation for configure benchmark 2023-09-22 20:05:20 +02:00
tydeu
7c2ca92661 doc: improve inundation README 2023-09-22 20:05:20 +02:00
tydeu
1d51492139 test: lake: add build Init/Lean/Lake benchmark 2023-09-22 20:05:20 +02:00
tydeu
9a0e57c721 test: add lake benchmarks 2023-09-22 20:05:20 +02:00
tydeu
1354fd9ccd perf: do not detect lean's toolchain
use `ELAN_TOOLCHAIN` only
2023-09-21 18:52:52 -04:00
Arthur Adjedj
325fab1c1d fix: don't try to generate below for nested predicates. (#2390)
* fix: don't try to generate `below` for nested predicates.

* doc : document test #2389

* doc : document `mkBelow`

* test: extend `2389.lean`

* style: fix comments in `IndPredBelow.lean` and `2389.lean`
2023-09-21 14:24:37 +10:00
thorimur
e79370a1e6 fix: only return new mvars from refine, elabTermWithHoles, and withCollectingNewGoalsFrom (#2502)
* fix: `withCollectingNewGoalsFrom`
do not collect old goals

* fix: update occurs check

* test: fix test `run/492.lean`

* docs: add docstring to `elabTermWithHoles`

* test: `refineFiltersOldMVars`

* test: fix `expected.out` name

* test: fix `expected.out` filename and line numbers

* docs: use long ascii dash instead of em dash

Co-authored-by: Scott Morrison <scott@tqft.net>

* docs: fix long line, mention lean4#2502

* docs: a couple more long lines

* test: fix line numbers

---------

Co-authored-by: Scott Morrison <scott@tqft.net>
2023-09-21 14:23:27 +10:00
tydeu
ec217caf22 feat: lake: add name to manifest 2023-09-20 22:52:39 -04:00
Sebastian Ullrich
dc60150b5a chore: update domain 2023-09-20 15:13:27 -07:00
Sebastian Ullrich
4114ffa273 chore: update stage0 2023-09-20 13:58:13 +02:00
Joachim Breitner
b2d668c340 perf: Use flat ByteArrays in Trie (#2529) 2023-09-20 13:22:37 +02:00
Sebastian Ullrich
de76a5d922 chore: activate stale PR labeler 2023-09-20 09:18:46 +02:00
Patrick Massot
0a59fd96a5 chore: finer-grained ref in getCalcFirstStep (#2563)
Suggested by @gebner at https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/Random.20calc.20ranges/near/372704972
2023-09-19 18:58:23 +00:00
Mario Carneiro
f0af71a57b fix: use MoveFileEx for rename on win 2023-09-19 20:24:37 +02:00
Sebastian Ullrich
6bd0a615f1 chore: CI: add workflow_dispatch for stale labeler 2023-09-19 15:29:00 +02:00
Sebastian Ullrich
9038d2e886 chore: disambiguate whnf system category 2023-09-19 05:57:01 -07:00
Sebastian Ullrich
97c4fe3244 chore: CI: label stale PRs 2023-09-19 08:53:23 -04:00
Sebastian Ullrich
0c324a5445 fix: set MACOSX_DEPLOYMENT_TARGET in CI only 2023-09-19 06:11:31 -04:00
Henrik
0d5f9122a1 perf: reduce allocations in unused variable linter 2023-09-18 05:41:37 -04:00
David Renshaw
ba416f2c1c fix: rename parameter of withImportModules to match doc string 2023-09-18 05:40:47 -04:00
Sebastian Ullrich
3e755dc0e1 fix: enforce linebreak between calc steps 2023-09-18 05:39:41 -04:00
thorimur
018020d36f fix: uninterpolated error message in registerRpcProcedure (#2547) 2023-09-18 11:39:04 +02:00
Scott Morrison
c4bd112a7f chore: when bumping Mathlib testing branches, bump to latest nightly-testing (#2553) 2023-09-18 02:02:24 +00:00
Scott Morrison
ee3ac9901e chore: do not generate PR releases from forks (#2550) 2023-09-17 09:28:42 +00:00
Scott Morrison
26de6d3591 chore: begin development cycle for 4.2.0 (#2545)
* chore: add release notes for #2470 and #2480

* chore: begin development cycle for 4.2.0

* chore: add Lake-related release notes for v4.1.0

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2023-09-17 14:17:30 +10:00
mhuisi
74b92d9cde chore: remove 'reproduces how often' field from bug template 2023-09-15 14:24:21 +02:00
mhuisi
debd71ec63 chore: make 'impact' a section 2023-09-15 14:24:21 +02:00
mhuisi
7eb3eb189f chore: add new issue templates 2023-09-15 14:24:21 +02:00
tydeu
be97757982 chore: lake: code cleanup
* remove MTime `checkIfNewer`
* remove unnecessary `@[noinline]`
* inline `MainM` combinators
2023-09-14 02:15:37 -04:00
tydeu
3be4d74321 fix: lake: lowercase template exe name to avoid clash with lib 2023-09-14 02:15:37 -04:00
tydeu
9088df4c57 doc: lake: add pkg org info to README + other tweaks 2023-09-14 02:15:37 -04:00
tydeu
65fa1e06b2 feat: lake: improve package templates
* add library directory
* add note on `supportInterpreter`
* use `where`-style configs
2023-09-14 02:15:37 -04:00
tydeu
473d4c51ad feat: lake: better native object tracing
* `weakLeanc/LinkArgs` for libs/mods/exes
* `weakArgs`/``extraDepTrace` for `buildO`
* include Lean trace when compiler is part of Lean toolchain
* do not include system-dependent file paths (e.g., `-I`) in dep trace
2023-09-14 02:15:37 -04:00
tydeu
be2eef5f3b feat: lake: better cloud release management
* step logging for cloud release fetching
* do not include cloud release bundle in trace
* `Package.afterReleaseSync/Async` utilities
* also cleanup `Package.recComputeDeps`
2023-09-14 02:15:37 -04:00
tydeu
0bb6bcf24c feat: lake: add upgrade and exec CLI aliases 2023-09-14 02:15:37 -04:00
tydeu
5983abcf78 fix: lake: use manifest opts
specifically, union manifest and config opts (preferring manifest)
2023-09-14 02:15:37 -04:00
tydeu
3f4a9dc9a1 feat: lake: better manifest-related error messages 2023-09-14 02:15:37 -04:00
tydeu
becc6fdb0e feat: lake: detect Elan install and Elan toolchain 2023-09-14 02:15:37 -04:00
tydeu
7b9d8a04c2 feat: lake: maintain order of libs and deps
provides a well-defined selection order when decls overlap
2023-09-14 02:15:37 -04:00
tydeu
e96b338cd9 feat: lake run <s> for s in any pkg 2023-09-14 02:15:37 -04:00
tydeu
113caf73fa fix: lake: reconfigure if toolchain changes 2023-09-14 02:15:37 -04:00
tydeu
522ea723ad fix: lake: dep URL match check in updateGitRepo
see 6176fdba9e (r125905901)
2023-09-14 02:15:37 -04:00
Scott Morrison
c318d5817d feat: allow configuring occs in rw 2023-09-13 12:03:18 -07:00
Joachim Breitner
09b9fdbdc3 chore: Do not hide stage0/src/stdlib_flags.h from diffs 2023-09-13 19:29:25 +02:00
Sebastian Ullrich
c2a5730bc9 chore: update stage0 2023-09-13 17:45:54 +02:00
Sebastian Ullrich
e9d60e143a perf: avoid allocation in mkUnexpectedTokenErrors 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
aab0e382c8 perf: inline ParserState.hasError 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
241430aa03 perf: avoid calculating position, revert building unexpected message in mkUnexpectedTokenErrors 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
c67686132a feat: include unexpected token in error message 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
e580c903e6 feat: adjust message range on unexpected token error 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
6c0baf4aed feat: support reporting range for parser errors, report ranges for expected token errors 2023-09-12 11:42:24 +02:00
Sebastian Ullrich
f4fc8b3e15 refactor: parser error setters 2023-09-12 11:42:24 +02:00
mhuisi
3aa1cfccea doc: update quickstart doc for release 2023-09-08 16:39:55 +02:00
Jannis Limperg
13ca443f05 fix: simp: include class projections in UsedSimps (#2489)
* fix: simp: include class projections in UsedSimps

Fixes #2488
2023-09-07 08:54:00 +10:00
tydeu
cfe4db16ea test: lake: check warnings in tests/clone
tests leanprover/lean4#2427
2023-09-06 17:35:59 -04:00
tydeu
2e726f5f5a test: lake: give issue tests meaningful names 2023-09-06 17:35:59 -04:00
tydeu
8c4811a300 test: lake: merge 49 and 116 into tests/serve 2023-09-06 17:35:59 -04:00
tydeu
398c131620 test: lake: merge tests/102 into globs 2023-09-06 17:35:59 -04:00
tydeu
9136309e59 test: lake: move examples/init to tests 2023-09-06 17:35:59 -04:00
tydeu
bb09efe1c4 test: lake: rename test to tests
(for consistency with Lean)
2023-09-06 17:35:59 -04:00
Mario Carneiro
2037094f8c doc: document all parser aliases (#2499) 2023-09-06 09:02:25 +00:00
Marcus Rossel
84bf315ac8 doc: fix comment for Unit 2023-09-05 07:52:06 +01:00
Scott Morrison
66e1472c7e chore: in nightly release notes, look for changes since last nightly 2023-09-01 11:08:18 +01:00
Scott Morrison
77600c56b6 chore: base lean-pr-testing-NNNN branches off nightly-testing (#2503) 2023-09-01 05:43:13 +00:00
Jannis Limperg
9a262d7cef fix: simpGoal reports incomplete UsedSimps (#2487) 2023-09-01 10:20:49 +10:00
Mario Carneiro
fec3575aaf fix: 0-arg functions in C need f(void) 2023-08-31 15:39:47 -04:00
tydeu
4cc1ca7a58 chore: lake: update tests 2023-08-31 15:37:33 -04:00
tydeu
5f77e70d27 feat: lake: save elaborated config as an olean 2023-08-31 15:37:33 -04:00
tydeu
926663505e chore: split up & simplify importModules 2023-08-31 15:37:33 -04:00
Scott Morrison
b2119313bd feat: add toolchain-available labels to PRs (#2492) 2023-08-31 08:36:32 +00:00
Scott Morrison
7de335c661 fix: create a mathlib branch for each Lean PR (#2494) 2023-08-31 05:48:24 +00:00
Scott Morrison
c4540f75b8 chore: create a mathlib branch for each Lean PR (#2473)
* chore: create a mathlib branch for each Lean PR

* use existing branch if present
2023-08-31 13:24:41 +10:00
Scott Morrison
0901e062eb feat: when making PR releases, only download necessary artifacts (#2474) 2023-08-31 12:52:22 +10:00
tydeu
a0440ea4ea feat: lake: cache built file hashes 2023-08-30 22:18:33 -04:00
tydeu
c6299eef45 refactor: lake: cleanup Build/Module/Trace code 2023-08-30 22:18:33 -04:00
Scott Morrison
a7efe5b60e Revert "fix: make sure refine preserves pre-existing natural mvars (#2435)" (#2485)
This reverts commit 0b64c1e330.
2023-08-30 08:00:30 +00:00
Scott Morrison
b8084d54e3 doc: update RELEASES.md for rename of getConst? (#2482) 2023-08-30 04:44:23 +00:00
Scott Morrison
f1f9dc0f2f chore: remove - from semver prerelease (#2481) 2023-08-29 23:14:28 +00:00
Scott Morrison
869d64e97a chore: update README to reflect beginning stable releases (#2477) 2023-08-29 13:24:19 +00:00
Scott Morrison
1fac294a2e chore: add introduction to RELEASES.md (#2476) 2023-08-29 13:10:55 +00:00
Scott Morrison
a5583d72bb chore: use bash-compatible SemVer regex (#2475) 2023-08-29 11:45:21 +00:00
Scott Morrison
4a41e7eb53 chore: basic tests exercising rw 2023-08-29 08:07:58 +01:00
Scott Morrison
aba37e37a5 chore: update CI to create official releases (#2472) 2023-08-29 05:48:20 +00:00
Scott Morrison
6861474e01 feat: create release at lean4-pr-releases for each PR (#2448) 2023-08-29 14:11:45 +10:00
Scott Morrison
7959091ce4 feat: add labels from comments (#2460) 2023-08-29 14:09:20 +10:00
Joachim Breitner
f7bff16c9a fix: If src is a dir, assume the lean file has the full path (#2465)
It seems that before, if `$src` isn’t a file, but a directory, that it
would contain `Bar.lean` directly, and not `Foo/Bar.lean`. This seemd
odd and would not allow dependencies to be included easily.
2023-08-28 14:45:45 +02:00
Marcus Rossel
7ee7595637 doc: fix typos (#2467) 2023-08-28 15:40:33 +10:00
thorimur
0b64c1e330 fix: make sure refine preserves pre-existing natural mvars (#2435)
* fix: `withCollectingNewGoals`
* don't exclude pre-existing natural mvars

* test: ensure pre-existing natural mvars are preserved

* docs: update comment and include issue number

* test: expected.out

* docs: add module docstrings to test
* also deleted superfluous `add_synthetic_goal`

* test: fix expected.out line numbers

* Update tests/lean/refinePreservesNaturalMVars.lean

Co-authored-by: Scott Morrison <scott@tqft.net>

* docs: clarify comment

---------

Co-authored-by: Scott Morrison <scott@tqft.net>
2023-08-25 19:25:54 -07:00
Scott Morrison
1dd443a368 doc: improve doc-string for Meta.getConst? 2023-08-24 07:42:28 -07:00
tydeu
d29b8e5422 chore: remove binaries before building them
This is required to avoid "permission denied" errors on Windows if the the file is already in use.
2023-08-23 14:33:27 -04:00
Mac Malone
216d2460e0 doc: explanation for lake.lock disabling
Co-authored-by: Scott Morrison <scott@tqft.net>
2023-08-23 01:58:18 -04:00
tydeu
25e673df54 chore: disable lake.lock (for now) 2023-08-23 01:58:18 -04:00
Mac Malone
8a536d0246 feat: lake env w/o configuration + more (#2428)
* feat: `lake env` w/o configuration + more

* chore: `lake env printenv DYLD_LIBRARY_PATH` illegal on MacOS
2023-08-23 13:27:16 +10:00
tydeu
898cd0b647 fix: include moreLinkArgs in precompile link 2023-08-22 21:47:04 -04:00
Scott Morrison
83556a1120 chore: add PULL_REQUEST_TEMPLATE.md 2023-08-22 07:08:13 -07:00
Connor Baker
24cfae2421 doc: fix typo in Lake's Require DSL 2023-08-21 12:43:56 -04:00
Mario Carneiro
ea60ac1443 doc: fix mid priority doc comment 2023-08-21 13:19:43 +02:00
Sebastian Ullrich
63d2bdd490 fix: integer type in llvm_count_params 2023-08-18 19:34:21 +02:00
Sebastian Ullrich
4e52283728 fix: FFI signature mismatches 2023-08-18 19:34:21 +02:00
tydeu
9d05b5f081 feat: warn rather than error if lake.lock disappears 2023-08-17 23:24:11 -04:00
Leonardo de Moura
50bece202b doc: add RFC questions 2023-08-17 20:23:38 -07:00
Joachim Breitner
6b429fed8f doc: fix markup in IO.RealWorld (#2430)
so that
<https://leanprover-community.github.io/mathlib4_docs/Init/System/IO.html#IO.RealWorld>
looks good.
2023-08-17 11:55:03 -07:00
Scott Morrison
f1412ddb45 feat: enable failIfUnchanged by default in simp 2023-08-16 10:14:23 -07:00
Scott Morrison
58d19b80b9 test: compiling from the interpreter, with common imports
hacky fix to windows test

Include test from #2407 as well
2023-08-16 10:11:50 -07:00
Sebastian Ullrich
f22695fdc5 fix: interpret module initializer at most once 2023-08-16 10:11:50 -07:00
Sebastian Ullrich
d4be21b559 chore: CI: Linux LLVM is not a release 2023-08-16 10:37:30 +02:00
tydeu
6176fdba9e feat: warn on local changes to dependency & related fixes 2023-08-16 09:44:12 +02:00
tydeu
b328835f4d fix: lake: reverse-ffi, manifest, and 62 tests 2023-08-15 20:33:09 -04:00
Henrik
35aa2c91a2 feat: LLVM backend: implement the equivalent of -fstack-clash-protection 2023-08-15 14:45:58 +02:00
tydeu
b81224c570 feat: lake update <pkg> & related tweaks 2023-08-15 09:50:39 +02:00
Leonardo de Moura
b5a736708f fix: fixes #2419 2023-08-14 16:18:30 -07:00
tydeu
736af918f5 doc: IO.Process.getPID tweak + IO.FS.Mode 2023-08-14 18:42:04 +02:00
Tobias Grosser
beddf011d7 chore: update stage0 2023-08-14 13:33:46 +02:00
Siddharth Bhat
496460020a fix: disabling forwarding --target to lean.
This will ensure that we do not invoke `lean --target` without compiling
using LLVM.
2023-08-14 13:33:46 +02:00
Henrik
8d3af73853 feat: Linux LLVM CI for stage1+ 2023-08-14 13:33:46 +02:00
Siddharth Bhat
146296b5fa feat: enable LLVM in stage1+ compiler 2023-08-14 13:33:46 +02:00
Siddharth Bhat
0054f6bfac feat: link 'llvm.h.bc' and then set linkage to internal
This obviates the need to play weak linkage games when
we build `lean.h.bc` from `lean.h`. We perform the following steps:

1. We remove the `static` modifier from all definitions in `lean.h`.
   This makes all definitions have `extern` linkage. Thus, when we build
   a `lean.h.bc` using `clang`, we will actually get definitions
   (instead of an empty file)
2. We build `lean.h.bc` from `lean.h` using `clang`.
3. When it comes time to link, we link
   `current_module.bc := LLVMLinkModules2(current_module.bc, lean.h.bc)`.
4. We loop over every symbol that arrived from `lean.h.bc`
   in `current_module.bc` and we then set this symbol to have
   `internal` linkage. This simulates the effect of
   `#include <lean.h>` where every definition in `lean.h`
   has internal linkage.

This yajna, one hopes, pleases the linker gods.
2023-08-14 13:33:46 +02:00
Leonardo de Moura
fac9e64cdf chore: update stage0 2023-08-13 09:56:29 -07:00
Scott Morrison
61fea57e73 feat: add failIfUnchanged flag to simp 2023-08-13 09:49:25 -07:00
Tobias Grosser
736a21cd5a chore: remove trailing whitespaces in EmitLLVM
For some reason, these two were missed in the last commit.
2023-08-13 16:18:23 +02:00
Tobias Grosser
d90176af71 chore: remove trailing whitespaces in CMakeLists.txt 2023-08-13 16:18:23 +02:00
Tobias Grosser
a0c0c486fd chore: remove trailing whitespace in EmitLLVM
This patch should not result in any functional changes, but
will reduce the diff of an upcoming PR.
2023-08-13 11:07:14 +02:00
Siddharth Bhat
0eddc167b9 feat: LLVM linkage bindings 2023-08-12 16:51:58 +02:00
Leonardo de Moura
dce7f71126 chore: clarify/fix contribution guidelines 2023-08-11 14:48:50 -07:00
Sebastian Ullrich
ff45efe3fa doc: one more enableInitializersExecution remark 2023-08-11 11:45:58 -07:00
Leonardo de Moura
133e03ce7f feat: update external contribution guidelines 2023-08-11 11:39:41 -07:00
tydeu
510bc47cc3 fix: delete lake.lock on error & test 2023-08-11 02:29:06 -04:00
tydeu
06853e5c3b fix: lake: lock test timeout + README typos 2023-08-10 12:17:47 -04:00
tydeu
75a9284320 feat: lake: lean lib extraDepTargets & related tweaks 2023-08-09 20:25:43 -04:00
Junyan Xu
2aeeed13cf fix: generalize Prod.lexAccessible to match Lean 3 (#2388)
* fix: generalize Prod.lexAccessible to match Lean 3

* fix

* fix
2023-08-09 08:54:53 -07:00
Marcus Rossel
8af25455ae doc: fix comment for Nat.sub 2023-08-09 08:54:24 -07:00
Sebastian Ullrich
befc4b997b doc: writing good tests 2023-08-09 08:52:55 -07:00
tydeu
e7a1512da8 doc: lake: update README target signatures 2023-08-08 21:42:07 -04:00
tydeu
63d303558d test: lake clean 2023-08-08 21:42:07 -04:00
tydeu
4c04690c24 fix: -d option for lake print-paths + test 2023-08-08 21:42:07 -04:00
tydeu
874d44a26e feat: lake clean <pkgs> 2023-08-08 21:42:07 -04:00
tydeu
3e4232c204 feat: lake.lock file for builds 2023-08-08 16:23:43 -04:00
tydeu
c79c7c89b3 feat: IO.Process.getPID & IO.FS.Mode.writeNew 2023-08-08 16:23:43 -04:00
tydeu
a315fdceb3 test: lake: make 116 deterministic & related tweaks 2023-08-08 16:21:28 -04:00
Sebastian Ullrich
bb738796ae test: update parser benchmark, add to speedcenter suite 2023-08-08 18:40:19 +02:00
tydeu
8de1c0786c chore: make Lean build shell configurable 2023-08-07 23:05:37 +02:00
Eric Wieser
1f3ef28a1d fix: correct universe polymorphism in Lean.instFromJsonProd
The previous type was
```
Lean.instFromJsonProd.{u, v} {α β : Type (max u v)} [FromJson α] [FromJson β] :
  FromJson (α × β)
```
where universe metavariable assignment assigned the wrong universe to both types!
2023-08-06 07:32:30 -07:00
Sebastian Ullrich
254582c000 doc: link to FFI examples 2023-08-04 10:45:53 +02:00
Sebastian Ullrich
f19f329b4c test: reverse FFI from C with Lake 2023-08-04 10:45:53 +02:00
tydeu
98da3c9e46 fix: lake: do not hash remote dep names + test
accidental leftover from a scrapped feature
2023-08-03 21:21:28 -04:00
Scott Morrison
ca4d824d75 chore: correct doc-string for elabTerm 2023-08-03 06:52:08 -07:00
tydeu
125a0ba798 chore: lake: adapt versioning to Lean repo & bump to v5.0.0 2023-08-03 01:09:18 -04:00
tydeu
0aa570044a fix: lake: distinct lib and precompile lib names for roots 2023-08-03 01:09:18 -04:00
tydeu
bb8259b9af feat: lake: warn on mismatch pkg name and require name
see #2324
2023-08-03 01:09:18 -04:00
tydeu
35bad47c1b refactor: lake: cleanup source materialization 2023-08-03 01:09:18 -04:00
Sebastian Ullrich
17602d9f28 chore: avoid "unused parameter" warnings in lean.h 2023-08-02 10:20:57 +02:00
tydeu
5fb42eb5c1 fix: include extraDepJob in module trace 2023-08-02 04:03:56 -04:00
tydeu
28f7334139 chore: .gitignore fixes 2023-08-02 04:03:56 -04:00
tydeu
e330a57036 test: fix 62/116/buildArgs 2023-08-02 04:03:56 -04:00
tydeu
86f11311ba test: merge examples/git and test/104 & use local test repo 2023-08-02 04:03:56 -04:00
tydeu
5c8093eaff chore: delete Lake's .github directory 2023-08-02 04:03:56 -04:00
tydeu
de3b198676 fix: use exe over lib & add missing opts from lib config to exe 2023-08-02 04:03:56 -04:00
tydeu
bb5cf96664 fix: fetch target type signatures 2023-08-02 04:03:56 -04:00
tydeu
6721150367 refactor: touchup DSL target docstrings & reorg 2023-08-02 04:03:56 -04:00
Siddharth
b9ec36d089 chore: get rid of all inline C annotations for LLVM (#2363) 2023-07-30 10:39:40 +02:00
Sebastian Ullrich
2eaa400b8e fix: do not unnecessarily wait on additional snapshot in server request handlers (#2370)
Co-authored-by: Wojciech Nawrocki <wjnawrocki+gh@protonmail.com>
2023-07-30 05:58:46 +00:00
Mario Carneiro
9c910ebe8e perf: faster replace "\r\n" "\n" 2023-07-29 17:31:48 -04:00
Siddharth
a436c225d8 chore: disable lake 116 test (#2358)
The test is flaky due to the presence of a fixed 'sleep()'.

The LLVM backend has introduced a performance
regression in Lake which causes this test to fail, as the
current sleep duration of 3s is insufficient.
Further investigation into the performance regression is pending.

We decided to disable the `leanlaketest_116` entirely on account
of the test being flaky by construction
(https://github.com/leanprover/lean4/pull/2358#issuecomment-1655371232).
2023-07-29 09:40:18 +00:00
Sebastian Ullrich
8fc1af650a fix: symmetry in orelse antiquotation parsing 2023-07-28 08:36:33 -07:00
Sebastian Ullrich
eceac9f12a perf: avoid syntax stack copy at orelseFn 2023-07-28 08:36:33 -07:00
Scott Morrison
b3fa4fd053 chore: revert #2317 2023-07-28 08:33:49 -07:00
Wojciech Nawrocki
74e0f09009 fix: handle error in withTraceNode message action (#2364)
* fix: handle error in withTrace message action

* Update src/Lean/Util/Trace.lean

Co-authored-by: Gabriel Ebner <gebner@gebner.org>

* Update Trace.lean

---------

Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2023-07-28 08:01:13 -07:00
Sebastian Ullrich
aeb60764c1 feat: auto-complete declaration names in arbitrary namespaces 2023-07-28 07:50:09 -07:00
Sebastian Ullrich
687f50ab33 fix: never show private names in completion 2023-07-28 07:50:09 -07:00
Sebastian Ullrich
e84ce2e1f1 test: make completion tests less dependent on core 2023-07-28 07:50:09 -07:00
Sebastian Ullrich
b15d6d41b8 fix: missing mkCIdents in Lean.Elab.Deriving.Util 2023-07-28 07:48:34 -07:00
Sebastian Ullrich
8ffb389f3f chore: Nix bump to LLVM 15
Also update mdbook dependency hash from nixpkgs bump.

Peeled from https://github.com/leanprover/lean4/pull/2340
to enable LLVM for stage1+ builds.
2023-07-28 10:56:54 +02:00
Mario Carneiro
776bff1948 fix: repeat conv should not auto-close the goal 2023-07-27 18:15:35 -04:00
Sebastian Ullrich
53477089fe chore: remove unused macOS dependencies 2023-07-26 15:36:36 +02:00
Sebastian Ullrich
132f655736 chore: add zlib search path on macOS only when linking libleanshared 2023-07-26 15:36:36 +02:00
Sebastian Ullrich
978a5b2528 fix: loading libc++ on macOS Sonoma 2023-07-26 15:36:36 +02:00
Siddharth Bhat
96c59ccced chore: update stage0 2023-07-25 11:03:16 +02:00
Siddharth Bhat
073c8fed86 feat: LLVM backend: support for visibility Style & DLL storage
Changes peeled from:
https://github.com/leanprover/lean4/pull/2340

to allow a `stage0` bump on master before merging in the
changes that allow LLVM to build in stage1+.
2023-07-25 11:03:16 +02:00
Alex J Best
808bb9b579 perf: dont repeatedly elab term in rw at multiple locations #2317 2023-07-24 08:47:52 -07:00
Bulhwi Cha
3b6bc4a87d style: remove unnecessary space characters 2023-07-23 16:11:11 +02:00
Mario Carneiro
dd313c6894 feat: add IO.FS.rename 2023-07-22 23:21:32 +02:00
Bulhwi Cha
7809d49a62 doc: fix type signature of Coe 2023-07-22 14:16:21 +02:00
Sebastian Ullrich
544b704a25 test: add Lake tests 2023-07-21 09:19:19 +02:00
Sebastian Ullrich
d991f5efe0 fix: ship libLake.a 2023-07-21 09:19:19 +02:00
Sebastian Ullrich
e2fbfb5731 chore: remove Lake flake
Fixes leanprover/lake#165
2023-07-21 09:19:19 +02:00
Sebastian Ullrich
8999ef067b chore: Nix: fixup Lake integration 2023-07-21 09:19:19 +02:00
Jannis Limperg
6407197e54 chore: better error message for loose bvar in whnf 2023-07-20 13:47:20 -07:00
Bulhwi Cha
367b38701f refactor: simplify String.splitOnAux (#2271) 2023-07-19 11:50:27 +00:00
Wojciech Nawrocki
e1b3f10250 doc: fix contradictory docstring 2023-07-19 10:53:47 +02:00
F. G. Dorais
d10e3da673 fix: protect sizeOf lemmas 2023-07-19 08:50:59 +02:00
Sebastian Ullrich
d62fca4e9c chore: safer bench script 2023-07-19 08:31:39 +02:00
Leonardo de Moura
634193328b fix: fixes #2327 2023-07-18 07:18:27 -07:00
Sebastian Ullrich
daae36d44d chore: remove obsolete file 2023-07-17 10:38:35 +02:00
Sebastian Ullrich
c35e41ce15 chore: Nix: add lake executable 2023-07-17 10:38:35 +02:00
Sebastian Ullrich
90aab46071 chore: fix update-stage0 2023-07-17 10:38:35 +02:00
Sebastian Ullrich
bf76eca0cd chore: merge Lake into src/lake 2023-07-17 10:38:20 +02:00
Sebastian Ullrich
9a3657df3f chore: remove Lake submodule 2023-07-15 12:03:41 +02:00
tydeu
d37bbf4292 chore: update Lake 2023-07-14 23:43:04 -04:00
Floris van Doorn
1a6663a41b chore: write "|-" as "|" noWs "-" (#2299)
* remove |- as an alias for ⊢

* revert false positive |->

* fix docstring

* undo previous changes

* [unchecked] use suggestion

* next attempt

* add test
2023-07-14 09:48:20 -07:00
Leonardo de Moura
212cd9c3e6 fix: fixes #2321 2023-07-13 14:41:32 -07:00
Scott Morrison
0d5c5e0191 feat: relax test in checkLocalInstanceParameters to allow instance implicits 2023-07-13 10:54:06 -07:00
Scott Morrison
7213ff0065 doc: document generating releases via tags (#2302) 2023-07-13 17:39:54 +02:00
Sebastian Ullrich
4562e8d9a2 fix: do not use GMP on ARM Linux 2023-07-13 09:35:00 +02:00
Leonardo de Moura
6e90442130 chore: disable benchtest at debug and fsanitize 2023-07-11 19:19:42 -07:00
Leonardo de Moura
fd0549feb5 chore: improve test 2023-07-11 19:19:42 -07:00
Leonardo de Moura
6d857a93b5 perf: pointer set for traversing DAGs 2023-07-11 19:19:42 -07:00
Leonardo de Moura
264e376741 chore: add helper function 2023-07-11 19:19:42 -07:00
Sebastian Ullrich
a3ebfe29ea chore: revert "chore: compile against glibc 2.26"
This reverts commit ae0e0ed1db.
2023-07-10 21:44:10 +02:00
Sebastian Ullrich
ae0e0ed1db chore: compile against glibc 2.26 2023-07-10 18:59:06 +02:00
Adrien Champion
d8a548fe51 chore: fix Int.div docstring examples 2023-07-10 09:09:07 -07:00
Scott Morrison
60b8fdd8d6 feat: use nat_pow in the kernel 2023-07-10 09:01:14 -07:00
Mario Carneiro
51694cd6de fix: calling convention for module initializers 2023-07-10 09:00:17 -07:00
Mario Carneiro
76023a7c6f fix: don't run [builtin_init] when builtin = false 2023-07-10 08:58:02 -07:00
tydeu
f46c792206 doc: fix up facet module docs 2023-07-06 00:37:32 -04:00
Sebastian Ullrich
c268d7e97b fix: kill descendant processes on worker exit 2023-07-05 23:42:53 +02:00
Sebastian Ullrich
9901804a49 feat: SpawnArgs.setsid, Child.kill 2023-07-05 23:42:53 +02:00
Leonardo de Moura
32d5def5b8 feat: add bne_iff_ne 2023-07-05 08:51:34 -07:00
tydeu
538ed26ca4 feat: module deps facet (+ test)
also improve facet build info docs
2023-07-03 18:31:34 -04:00
tydeu
331c4c39b8 feat: type-level named Package + target fetch helpers 2023-07-01 23:10:25 -04:00
tydeu
68800cdcf8 chore: fix test 2023-07-01 19:25:51 -04:00
tydeu
a0626a9334 refactor: libDir -> nativeLibDir; oleanDir -> leanLibDir
also
* remove deprecated `isLeanOnly`
* touch-up some docs
2023-07-01 11:53:52 -04:00
Leonardo de Moura
5402c3cf76 chore: fix test file names 2023-07-01 06:20:36 -07:00
Mario Carneiro
f1b2a8acce fix: lazy_binop + coercion bug
fixes #2300
2023-07-01 06:05:25 -07:00
Leonardo de Moura
94d4a427e2 fix: fixes #2115 2023-06-30 19:54:38 -07:00
Leonardo de Moura
a002ce6d0d fix: fixes #2077 2023-06-30 19:26:00 -07:00
Sebastian Ullrich
e2383729a6 doc: clarify current release process 2023-06-30 10:30:37 -07:00
tydeu
aee9ce4321 chore: update Lake 2023-06-30 09:44:26 +02:00
tydeu
01b3e70a8d feat: add some helpers for pkg and lib roots
also update some docstrings
2023-06-29 23:00:03 -04:00
tydeu
8f3468b82c chore: bump Lean version 2023-06-29 20:16:58 -04:00
tydeu
5190c7fcc3 test: rename issue dirs that test multiple issues 2023-06-29 17:47:18 -04:00
tydeu
337891c9eb fix: do not build missing directory modules (+ test)
error reported on Zulip:
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/lake.20build.20all/near/370788618
2023-06-29 17:42:27 -04:00
Leonardo de Moura
ec42581d1f perf: use Core.transform instead of Meta.transform at betaReduceLetRecApps
Observed big performance improvement on files containing big proofs
generated using tactics.
2023-06-28 12:29:12 -07:00
Sebastian Ullrich
371fc8868a doc: move out Nix setup 2023-06-28 09:49:08 +01:00
Leonardo de Moura
eece499da9 fix: fixes #2282 2023-06-27 16:46:38 -07:00
Sebastian Ullrich
f0583c3fd6 feat: trace nodes for SizeOf and injectivity theorem generation 2023-06-27 16:17:46 -07:00
Wojciech Nawrocki
ba4bfe26f2 fix: add missing instantiateMVars 2023-06-27 16:13:56 -07:00
Sebastian Ullrich
d54ecc4373 doc: refer to mathlib4 instructions in quickstart 2023-06-27 14:21:44 -07:00
Sebastian Ullrich
e84a5891f8 doc: quickstart note on moving from Lean 3 to 4 2023-06-27 14:21:44 -07:00
Mario Carneiro
3104c223d8 fix: reference implementation for Array.mapM 2023-06-27 14:21:22 -07:00
tydeu
46c77afeaf chore: update Lake 2023-06-27 21:35:51 +01:00
Sebastian Ullrich
e1999ada7f fix: make "elaboration" metric work in language server 2023-06-27 15:56:34 +01:00
Mario Carneiro
bb8cc08de8 chore: compact objects in post-order 2023-06-26 08:35:19 -07:00
Pietro Monticone
fff4aea0d9 doc: fix typos (#2287) 2023-06-25 20:30:33 +02:00
Leonardo de Moura
4036be4f50 fix: add missing check at IR checker 2023-06-23 08:43:39 -07:00
Mario Carneiro
123c1ff7f0 fix: basic ident fallback in identComponents 2023-06-22 09:50:24 +01:00
Floris van Doorn
32e93f1dc1 fix: delete Measure and SizeOfRef (#2275)
* move Measure to Nat namespace

We could (and maybe should) also move various other declarations to namespaces, like measure. However, measure seems to be used a lot in termination_by statements, so that requires other fixes as well. Measure seems to be almost unused

* fix

* delete Measure and SizeOfRef instead
2023-06-21 22:51:28 -07:00
Mario Carneiro
e0893b70e5 fix: incorrect type for SpecInfo.argKinds 2023-06-21 22:50:29 -07:00
Leonardo de Moura
26877c42ae chore: update stage0 2023-06-21 22:30:53 -07:00
Leonardo de Moura
425f42cd83 feat: better support for Nat literals at DiscrTree.lean 2023-06-21 22:30:09 -07:00
Leonardo de Moura
bebf1927f8 chore: remove workarounds 2023-06-21 20:35:33 -07:00
Leonardo de Moura
19d266e0c5 chore: upate stage0 2023-06-21 20:31:47 -07:00
Leonardo de Moura
184f2ed597 chore: improve isNonTrivialProof 2023-06-21 20:28:17 -07:00
Leonardo de Moura
7367f2edc6 fix: unfold constant theorems when transparency is set to .all 2023-06-21 20:28:17 -07:00
Leonardo de Moura
9df2f6b0c9 fix: bump transparency to .all when reducing the major premise of Acc.rec and WellFounded.rec 2023-06-21 20:28:17 -07:00
Leonardo de Moura
2b8e55c2f1 fix: Nat literal bug at DiscrTree.lean 2023-06-21 20:28:17 -07:00
Leonardo de Moura
d6695a7a2e fix: use mkAuxTheoremFor when creating helper proof_n theorems 2023-06-21 20:28:17 -07:00
tydeu
3f9a867469 test: generalize make test/clean targets 2023-06-21 18:48:09 -04:00
tydeu
abdbc39403 test: add test for leanprover/lake#174 2023-06-21 18:19:12 -04:00
Scott Morrison
a44dd71ad6 feat: add flag for apply to defer failed typeclass syntheses as goals 2023-06-19 20:07:07 -07:00
Scott Morrison
82196b5b94 feat: allow upper case single character identifiers when relaxedAutoImplicit false (#2277)
* feat: allow upper case single character identifiers when relaxedAutoImplicit false

* update tests

* fix tests

* fix another test

---------

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
2023-06-19 20:04:09 -07:00
Mario Carneiro
2348fb37d3 fix: use Lean.initializing instead of IO.initializing 2023-06-17 06:57:14 -07:00
Mario Carneiro
e64a2e1a12 fix: misleading indentation 2023-06-17 06:56:53 -07:00
Denis Gorbachev
1292819f64 chore: update scripts example to new GetElem syntax (leanprover/lake#171) 2023-06-10 03:55:55 -04:00
Gabriel Ebner
bff612e59e fix: simp: synthesize non-inst-implicit tc args
Fixes #2265.
2023-06-09 16:32:02 -07:00
Mario Carneiro
1ac8a4083f feat: report section name in invalid end msg 2023-06-09 14:41:39 -07:00
Mario Carneiro
b4cf1dd943 feat: binder info for generalize 2023-06-09 14:41:00 -07:00
Mario Carneiro
b139a97825 fix: hygieneInfo should not consume whitespace 2023-06-09 15:05:19 +02:00
tydeu
3fb146fad2 chore: fix test on MacOS 2023-06-08 14:05:04 -04:00
tydeu
462d306184 chore: fix test on non-Windows 2023-06-08 13:40:21 -04:00
tydeu
13d5e6f542 feat: add untraced weakLeanArgs
closes leanprover/lake#172
2023-06-08 03:29:51 -04:00
tydeu
cf216ecd16 chore: update Lean to 06-01
also:
* refactor code relying on the old `toName`
* do not decapitalize package names in `lake new`
2023-06-08 02:06:13 -04:00
tydeu
c0edda1373 doc: fix some README wording 2023-06-07 22:25:52 -04:00
Sebastian Ullrich
451ccec154 fix: save when used as last tactic 2023-06-07 14:29:45 -07:00
Sebastian Ullrich
8ba05f34ea doc: remove reference to harmful elan command 2023-06-07 20:08:33 +02:00
Sebastian Ullrich
d5348dfac8 chore: update stage0 2023-06-06 15:01:00 +02:00
Sebastian Ullrich
7987b795bb fix: workspace symbols
Somehow was broken by #2233
2023-06-06 14:58:24 +02:00
Bulhwi Cha
b3eeeffd90 doc: improve documentation of Init.Coe
Delete misleading explanations of `CoeFun` and `CoeSort`, and fix the
grammar in the documentation of `Init.Coe`.
2023-06-05 15:52:25 -07:00
Mario Carneiro
bc841809c2 chore: remove intermediate 2023-06-05 15:50:11 -07:00
Mario Carneiro
2ae78f3c45 fix: tail-recursive String.foldr 2023-06-05 15:50:11 -07:00
Mario Carneiro
e68554b854 fix: use empty string instead of mk 2023-06-05 15:50:11 -07:00
Mario Carneiro
fd72fdf8f8 fix: incorrect utf8 in splitAux 2023-06-05 15:50:11 -07:00
Mario Carneiro
aa60791db3 feat: remove partial in Init.Data.String.Basic 2023-06-05 15:50:11 -07:00
Sebastian Ullrich
90e2288187 fix: interpret initializers in order 2023-06-05 15:46:35 -07:00
bc²
18d6bce7a9 chore: add ₚ to lstlean.tex (#2221) 2023-06-05 16:53:08 +02:00
Sebastian Ullrich
97cffd4711 fix: prefer resolving parser alias over declaration 2023-06-05 16:52:23 +02:00
Sebastian Ullrich
af6c7cdbe0 doc: changelog
Resolves #2254
2023-06-03 11:12:40 +02:00
Mario Carneiro
a8d6178e19 feat: implement have this (part 2) 2023-06-02 16:19:02 +02:00
Mario Carneiro
0c624d8023 chore: update stage0 2023-06-02 16:19:02 +02:00
Mario Carneiro
43f6d0a761 feat: implement have this (part 1) 2023-06-02 16:19:02 +02:00
Mario Carneiro
c20a7bf305 feat: hygieneInfo parser (aka this 2.0) 2023-06-02 16:19:02 +02:00
tydeu
3f49861ee1 test: add test with - in lake new
from https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/lake.20new.20lean-data
2023-06-02 03:18:06 -04:00
Mario Carneiro
e826f5f42a fix: spacing around calc 2023-06-02 09:15:15 +02:00
Henrik
28538fc748 feat: trace nodes for kernel type checking 2023-05-31 06:10:26 -07:00
Bulhwi Cha
c1a58b212a chore: remove whitespace (#2244)
Remove a duplicate whitespace character.
2023-05-31 06:00:42 -07:00
Leonardo de Moura
25384fe951 fix: fixes #2232 2023-05-31 05:48:25 -07:00
Leonardo de Moura
e04d67f55f chore: expand docstring for TransformStep.visit 2023-05-31 05:48:25 -07:00
Sebastian Ullrich
efe75b2b16 chore: update Lake 2023-05-31 03:04:46 -07:00
Mario Carneiro
9ec9ea61a4 fix: infinite loop in isClassApp? 2023-05-30 18:47:17 -07:00
Mario Carneiro
5661b15e35 fix: spacing and indentation fixes 2023-05-28 18:48:36 -07:00
Leonardo de Moura
83cc0bcc96 fix: fixes #2199 2023-05-28 18:29:09 -07:00
Henrik Böving
f6c8923a9b feat: add compiler.enableNew for the new compiler 2023-05-28 17:43:32 -07:00
Jannis Limperg
c84690028b fix: ignore implDetail hyps in withLocation 2023-05-28 17:40:55 -07:00
Mario Carneiro
01ba75661e fix: implement String.toName using decodeNameLit
fixes #2231
2023-05-28 17:38:57 -07:00
Bulhwi Cha
8d0504b3b7 doc: add docstring to String.next' 2023-05-28 17:32:08 -07:00
Mario Carneiro
5d3ac5f80c fix: panic in Match.SimpH.substRHS 2023-05-28 17:04:28 -07:00
Mac
b74d9c09d5 chore: delete unintended commit of flake.lock (leanprover/lake#170) 2023-05-24 19:26:36 -04:00
Sebastian Ullrich
a32c3e0140 feat: make .lean hashes cross-platform compatible (leanprover/lake#170) 2023-05-23 08:10:19 -04:00
Sebastian Ullrich
8d4dd2311c fix: increase semantic token highlight limit 2023-05-21 10:17:35 +02:00
Mario Carneiro
df49512880 fix: use withoutPosition in anon constructor 2023-05-17 09:48:34 +02:00
Gabriel Ebner
ebc32af2e6 chore: fix flaky test 2023-05-15 13:23:38 -07:00
Parth Shastri
555f5f390c fix: stop iterating over visited mvars in collectUnassignedMVars 2023-05-15 09:37:19 -07:00
Parth Shastri
954190e457 fix: remove repeat calls to inferType in ignoreField 2023-05-15 09:35:44 -07:00
Scott Morrison
fd49af196f chore: lower monad for Term.reportUnsolvedGoals 2023-05-15 09:33:42 -07:00
Gabriel Ebner
5781752985 fix: offset unification with a+a+1
Fixes #2136
2023-05-15 09:06:37 -07:00
Gabriel Ebner
ae2b2c3903 chore: add regression test for mathlib eta perf issue 2023-05-15 09:05:41 -07:00
Gabriel Ebner
1f21ababfa chore: remove etaExperiment option 2023-05-15 09:05:41 -07:00
Gabriel Ebner
41729263c5 fix: tests 2023-05-15 09:05:41 -07:00
Gabriel Ebner
8de8c80119 perf: do not unify proof arguments 2023-05-15 09:05:41 -07:00
Gabriel Ebner
89cb94fcab perf: try structure eta after delta 2023-05-15 09:05:41 -07:00
Gabriel Ebner
9211dd6541 chore: tc: re-enable eta 2023-05-15 09:05:41 -07:00
Mario Carneiro
7f84bf07ba fix: bug in reference implementation of String.get? 2023-05-15 08:35:20 -07:00
Mario Carneiro
ad4b822734 fix: use snake case for @[code_action_provider] 2023-05-08 22:25:48 +02:00
Bulhwi Cha
445fd417be doc: add more explanations of quotients
Add explanations of `Quotient.ind` and `Quotient.inductionOn` to
`Init.Core`.
2023-05-05 12:22:59 -07:00
Bulhwi Cha
9fd1aeb0d8 fix: change the type of Quotient.ind
Change the type of `Quotient.ind` by changing the type of `q` from
`Quot Setoid.r` to `Quotient s`.
2023-05-05 12:22:59 -07:00
Leonardo de Moura
ede14adb20 chore: expand remark 2023-05-05 12:21:32 -07:00
Martin Dvořák
2d33726c69 doc: f(x) is no longer allowed (#2135) 2023-05-05 12:19:19 -07:00
Leonardo de Moura
ebcab266c6 chore: remove empty line 2023-05-05 12:18:36 -07:00
Henrik Böving
0e042d8ef6 fix: LCNF simp forgot to mark normalized decls as simplified 2023-05-05 12:17:26 -07:00
Mario Carneiro
c9e84a6ad6 fix: remove private from string defs 2023-05-05 12:09:38 -07:00
Jakob von Raumer
45b49e7f02 fix: typos 2023-05-05 12:07:54 -07:00
Bulhwi Cha
401e9868f8 doc: uncapitalize a letter
"this Type" should be "this type".
2023-05-05 12:04:35 -07:00
Gabriel Ebner
f9da1d8b55 chore: update Lake 2023-04-19 10:57:48 -07:00
Scott Morrison
ac7c447855 chore: update src/Init/Tactics.lean 2023-04-19 07:15:08 -07:00
tydeu
72487e5650 fix: remove olean/ilean duplication in module traces 2023-04-18 20:58:40 -04:00
tydeu
eb157000a4 chore: remove doc of isLeanOnly and warn on its use 2023-04-18 20:58:40 -04:00
Gabriel Ebner
0656482b91 feat: show number of files to go when building 2023-04-18 20:58:40 -04:00
Gabriel Ebner
312960820c feat: priority for bindSync 2023-04-18 20:58:40 -04:00
Gabriel Ebner
98a55105ff chore: update Lean version 2023-04-18 20:58:40 -04:00
Gabriel Ebner
a1a30aac1c refactor: simplify recBuildLeanCore 2023-04-18 20:58:40 -04:00
Scott Morrison
96969363e6 chore: modify misleading doc-string for repeat tactic 2023-04-18 15:56:49 +02:00
Henrik Böving
a6ae661195 feat: profiling of linters 2023-04-18 15:30:21 +02:00
Henrik Böving
36f0acfc51 feat: add timing profiling to the new compiler 2023-04-18 12:20:27 +02:00
tydeu
c49a7d84e9 chore: fix test 2023-04-15 21:04:46 -04:00
tydeu
346da2c29c feat: bare lake run default scripts 2023-04-15 20:07:47 -04:00
tydeu
227a350747 doc: tweak README + fix some typos 2023-04-15 18:32:21 -04:00
Gabriel Ebner
caa4494cb7 chore: remove dangerous instances 2023-04-15 18:16:53 -04:00
Sebastian Ullrich
8a302e6135 fix: match discriminant reduction should not unfold irreducible defs 2023-04-10 21:09:04 -07:00
Gabriel Ebner
7f51628986 fix: simp: strip mdata when testing for True/False
Fixes #2173
2023-04-10 21:06:42 -07:00
Scott Morrison
06c752448b chore: add missing simp lemma (¬ False) = True 2023-04-10 21:05:54 -07:00
Gabriel Ebner
8075d1f45d fix: reset local context in mkInjectiveTheorems 2023-04-10 21:05:16 -07:00
Gabriel Ebner
4af329588e doc: clarify semi-out params 2023-04-10 13:00:04 -07:00
Gabriel Ebner
56c3e3334f doc: semiOutParam 2023-04-10 13:00:04 -07:00
Gabriel Ebner
54c02d75b2 chore: let consumeTypeAnnotations remove semiOutParam 2023-04-10 13:00:04 -07:00
Gabriel Ebner
5eb9688846 chore: flaky tests 2023-04-10 13:00:04 -07:00
Gabriel Ebner
b8671ed18d fix: disable checkSynthOrder for Quote instance 2023-04-10 13:00:04 -07:00
Gabriel Ebner
d58f552b84 chore: update stage0 2023-04-10 13:00:04 -07:00
Gabriel Ebner
4544443d98 feat: reorder tc subgoals according to out-params 2023-04-10 13:00:04 -07:00
Gabriel Ebner
25fe723b14 chore: add semiOutParam annotations 2023-04-10 13:00:04 -07:00
Sebastian Ullrich
a0b960b77b perf: --profile can use tracing fast path 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
41a3ebed02 fix: profiler threshold in C++ 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
59ac123f61 chore: remove with_trace macro again 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
427540db45 chore: remove redundant Elab.input trace class in favor of Elab.command 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
6fdb73c6ed feat: pp.oneline 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
3336443358 fix: convert traces to messages at outermost level only 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
f9dcc9ca1b fix: trim syntax in messages 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
bafa4e0a78 feat: use with_trace for important trace classes 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
d8e826c2a7 feat: trace.profiler 2023-04-10 16:57:54 +02:00
Sebastian Ullrich
d51e404d6a refactor: move profiling options to Lean 2023-04-10 16:57:54 +02:00
Olivier Taïbi
9aeae67708 fix: advance pointer into array when generating random bytes
otherwise if we have more than one chunk then the first one is overwritten
over and over, and the end of the array is not really random
2023-04-06 11:32:12 +02:00
Bulhwi Cha
d694bf2d09 doc: heading (#2180)
Add '#' to the docstring.
2023-04-03 09:40:22 +02:00
Enrico Borba
6d583284df chore: Nix: fix depRoot with huge number of deps (#2179)
If `deps` or `depRoots` are too large, bash will carsh when executing
the modified script. This is because there are OS-level limits on the
size of environment variables. This commit changes the script so that
`deps` and `depRoots` are written to files instead of being passed as
environment variables.
2023-04-01 09:45:38 +02:00
Gabriel Ebner
742d053a97 fix: respect pp.raw in interactive .ofGoal
Fixes #2175
2023-03-30 17:19:35 -07:00
Scott Morrison
a45f808da4 chore: don't rely on simp calling decide (leanprover/lake#168) 2023-03-28 12:32:39 -04:00
Adrien Champion
39f0fa670a doc: document Int and its basic operations (#2167) 2023-03-28 14:54:14 +02:00
Connor Baker
667d54640d chore: Nix: use strings instead of URL literals (#2172) 2023-03-28 10:10:24 +02:00
github-actions[bot]
5495a4f91c doc: update changelog 2023-03-27 15:48:22 +00:00
Sebastian Ullrich
b076d488e3 feat: show typeclass and tactic names in profile output 2023-03-27 17:47:52 +02:00
Sebastian Ullrich
4048455060 chore: Nix: fix asan attribute 2023-03-27 16:48:49 +02:00
int-y1
9bc6fa1c6e chore: fix typos 2023-03-27 10:05:50 +02:00
Sebastian Ullrich
b81cff87bc chore: update temci 2023-03-24 11:34:21 +01:00
Pietro Monticone
158d58f3c3 doc: fix typos (#2160) 2023-03-22 10:01:59 +01:00
Sebastian Ullrich
042d14c470 fix: List.append_eq name
Fixes #2157
2023-03-19 10:28:48 +01:00
Sebastian Ullrich
7648ec57b5 fix: adapt to new Handle.mk signature
The previous code was arguably wrong in any case as the result of `lake
init` should not depend on the current platform
2023-03-17 09:15:26 -04:00
Gabriel Ebner
8650804b02 perf: cache tc results with mvars 2023-03-16 15:26:38 -07:00
Gabriel Ebner
d3c55ef249 perf: do not reset tc cache when adding local instances 2023-03-16 15:26:38 -07:00
Sebastian Ullrich
83c1a1ab77 chore: bench: update temci 2023-03-16 16:39:50 +01:00
Sebastian Ullrich
a62d412dce fix: implement · tacs as a builtin elaborator, part 2
Fixes #2153
2023-03-15 17:00:15 +01:00
Sebastian Ullrich
c327a61d33 chore: update stage0 2023-03-15 14:14:39 +01:00
Sebastian Ullrich
9d144c73fd fix: implement · tacs as a builtin elaborator 2023-03-15 13:59:16 +01:00
Sebastian Ullrich
b8cc5b277e fix: strict indentation check in · tacs 2023-03-15 11:33:19 +01:00
Sebastian Ullrich
97b4143e14 chore: update stage0 2023-03-15 10:55:42 +01:00
Sebastian Ullrich
a89accfbbe feat: parser alias for tacticSeqIndentGt 2023-03-15 10:54:05 +01:00
Sebastian Ullrich
d7a0197fee chore: improve tacticSeqIndentGt error message 2023-03-15 10:52:57 +01:00
Sebastian Ullrich
db2e710072 chore: Nix: update lean4-mode 2023-03-15 10:52:03 +01:00
Sebastian Ullrich
3d21124445 perf: scale Expr.replace cache with input size 2023-03-14 23:20:23 +01:00
Sebastian Ullrich
96aa021007 feat: add attribute application profile metric 2023-03-13 16:17:20 +01:00
Sebastian Ullrich
b15d7b8f17 feat: add kernel type checking profile metric 2023-03-13 16:17:20 +01:00
Gabriel Ebner
620587fc42 feat: make lake clean clean all packages
Fixes leanprover/lake#155
2023-03-10 22:51:11 -05:00
Gabriel Ebner
57fea2d8e3 feat: accept empty git hash as version
Fixes leanprover/lake#154
2023-03-10 22:49:36 -05:00
Gabriel Ebner
276bf837e2 feat: show stdout by default 2023-03-10 22:48:35 -05:00
Sebastian Ullrich
a4f732e6b1 fix: ignore vanishing files during watchdog update 2023-03-10 19:13:24 +01:00
Sebastian Ullrich
4cc6057f4a chore: ensure consistent (Unix) encoding for source files 2023-03-10 16:27:56 +01:00
Sebastian Ullrich
15c146b382 feat: proper I/O errors from getLine 2023-03-10 16:27:56 +01:00
Sebastian Ullrich
51e77d152c fix: do not inherit file handles across process creation 2023-03-10 16:27:56 +01:00
Sebastian Ullrich
113de7cca1 refactor: move from fopen to open 2023-03-10 16:27:56 +01:00
Sebastian Ullrich
aacab14394 chore: remove support for text-mode I/O
This didn't do anything except on Windows, where it would make the
application differ from standard Windows applications, which we don't
want.
2023-03-10 16:27:56 +01:00
int-y1
0477276f66 chore: fix typos in prelude 2023-03-09 18:12:24 +01:00
Adrien Champion
ce0d2a6928 chore: formatting/capitalization in RELEASES.md
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2023-03-09 18:11:11 +01:00
Adrien Champion
5111595753 chore: discuss alternative calc syntax in RELEASES.md 2023-03-09 18:11:11 +01:00
Sebastian Ullrich
8509a28798 feat: profile tactic execution 2023-03-09 17:18:19 +01:00
Gabriel Ebner
0cc9d7a43d fix: do not reverse subgoals of local instances 2023-03-08 15:54:07 -08:00
Gabriel Ebner
2262579f9b fix: tc: filter out assigned subgoals at the correct place 2023-03-08 15:54:07 -08:00
Gabriel Ebner
3ab859553e fix: allow function coercion to assign universe mvars 2023-03-08 15:54:07 -08:00
Gabriel Ebner
1c641b569a chore: synthInstance trace message on cache hit 2023-03-08 15:54:07 -08:00
Gabriel Ebner
1f61633da7 fix: typo in trace class name 2023-03-08 15:54:07 -08:00
Gabriel Ebner
e6b3202df3 chore: remove dead code 2023-03-08 15:54:07 -08:00
Sebastian Ullrich
d4caf1f922 fix: $_* anonymous suffix splice syntax pattern 2023-03-06 16:30:18 +01:00
Martin Dvořák
3b50410ec0 doc: typo 2023-03-04 11:19:25 +01:00
Gabriel Ebner
0da281fab4 fix: reject occurrences of inductive type in index
Fixes #2125
2023-02-28 12:22:54 -08:00
Kaiyu Yang
421e73f6c5 doc: fix typo in README (leanprover/lake#157) 2023-02-24 16:02:00 -05:00
Adrien Champion
473486eeb9 fix: calc indentation and allow underscore in first relation 2023-02-23 14:20:21 -08:00
Martin Dvořák
83dffbc2f8 doc: mention lake clean in README (leanprover/lake#156) 2023-02-23 12:14:17 -05:00
Sebastian Ullrich
3f6c5f17db fix: unhygiene in expandExplicitBinders 2023-02-22 17:07:31 +01:00
Gabriel Ebner
7992ce6b4d chore: add test for calc 2023-02-21 16:41:46 -08:00
Gabriel Ebner
adcca17991 chore: add option to enable structure eta in tc search 2023-02-21 16:41:30 -08:00
tydeu
16af1dddf4 fix: include link args in shared lib trace of extern lib 2023-02-21 06:35:39 -05:00
Sebastian Ullrich
c826168cfa fix: atomic --profile output for xargs -P 2023-02-11 17:41:07 +01:00
Sebastian Ullrich
3146aa477d fix: accumulate_profile: accept category names containing digits (e.g. hygiened decl names) 2023-02-11 17:41:07 +01:00
Gabriel Ebner
75252d2b85 perf: whnf projections during defeq 2023-02-09 19:54:23 -08:00
Gabriel Ebner
ecc74c5a9d fix: defeq condition for projections 2023-02-09 19:54:23 -08:00
Gabriel Ebner
448f49ee91 Revert "fix: reenable structure eta during tc search"
The fix is blocked by slow defeq checks for TC instances; see issues
1986 and 2055.  Enabling it right now causes lots of timeouts in
mathlib4.
https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/bump.20to.202023-02-06/near/326223768

This reverts commit 15a045ee66.
2023-02-09 11:37:30 -08:00
Gabriel Ebner
3c562c1a9b fix: unify goal before executing nested tactics in calc
Fixes #2095
2023-02-09 11:34:07 -08:00
Jon Eugster
07bd2a8488 feat: add quot_precheck Lean.Parser.Term.explicit 2023-02-08 12:21:40 +01:00
Sebastian Ullrich
9d013ba3f5 chore: update stage0 2023-02-08 12:11:41 +01:00
Gabriel Ebner
15a045ee66 fix: reenable structure eta during tc search
Fixes #2074.
2023-02-05 11:41:00 -08:00
tydeu
4b974fd60b chore: update Lake 2023-02-03 22:10:15 +01:00
tydeu
5080b08922 chore: reduce imports in Lake.Build.Actions 2023-02-02 20:38:06 -05:00
Arthur Paulino
05c2ac5f3c download lean-toolchain directly 2023-02-02 20:34:02 -05:00
Gabriel Ebner
d4b9a532d2 fix: calc: synthesize default instances
This is necessary to figure out the types with exponentiations.

Fixes #2079
2023-02-02 14:29:21 -08:00
Gabriel Ebner
8265d8bb13 chore: calc: improve error range 2023-02-02 14:21:06 -08:00
tydeu
7055f953f1 doc: fix typo
closes leanprover/lake#151
2023-02-02 15:40:02 -05:00
Leonardo de Moura
35ccf7b163 chore: update CONTRIBUTING.md 2023-02-01 12:07:15 -08:00
Sebastian Ullrich
7327b66179 doc: update FPiL entry in README
/cc @david-christiansen

I think it's progressed far enough that no "in development" annotation is necessary on this page
2023-01-31 08:10:44 -08:00
Gabriel Ebner
18b3bd7875 fix: calc: do not take lhs/rhs from expected type
Fixes #2073
2023-01-30 15:02:40 -08:00
tydeu
38a0d1e373 chore: update Lake 2023-01-28 18:29:00 +01:00
int-y1
b69fcbc28f chore: fix typos 2023-01-28 15:15:12 +01:00
Gabriel Ebner
e37f209c1a fix: unify types in calc 2023-01-27 13:38:42 -08:00
Gabriel Ebner
dd8319c3cd fix: disable gmp on windows
The msys2 gmp package does not support static linking at the moment.
f31bdf893a
2023-01-27 12:28:34 -08:00
Leonardo de Moura
decb08858f fix: kernel must ensure that safe functions cannot use partial ones.
Fix issue reported at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Meaning.20of.20.60DefinitionSafety.2Epartial.60
2023-01-27 12:17:37 -08:00
Sebastian Ullrich
1f41b91206 test: update Lean variant benchmarks 2023-01-26 13:33:28 +01:00
Sebastian Ullrich
2a7ae7b28a chore: Nix: explicit src 2023-01-26 13:32:42 +01:00
Sebastian Ullrich
12356b739b test: add rbmap_2 benchmark 2023-01-26 13:32:42 +01:00
Sebastian Ullrich
d01a521be2 test: fix 2023-01-26 13:31:16 +01:00
Sebastian Ullrich
badfcdc49f fix: missing info tree on elab failure 2023-01-26 13:05:57 +01:00
Sebastian Ullrich
f24608c4d1 fix: make eoi an actual command with info tree 2023-01-26 13:05:57 +01:00
Sebastian Ullrich
8a4059dc65 fix: avoid notation in quotation elaborator output 2023-01-26 13:05:33 +01:00
Sebastian Ullrich
18297d8d91 fix: notation unexpander on overapplication of non-nullary notation 2023-01-26 13:05:33 +01:00
Sebastian Ullrich
94547b3d85 chore: CI: avoid deprecated set-output 2023-01-25 10:23:22 +01:00
Gabriel Ebner
f4d005e86d chore: only build small allocator if enabled
This prevents us from calling alloc/dealloc if LEAN_SMALL_ALLOCATOR is
disabled.
2023-01-24 11:37:43 -08:00
Gabriel Ebner
3deef5d32a fix: mpz: honor LEAN_SMALL_ALLOCATOR 2023-01-24 11:37:43 -08:00
Gabriel Ebner
345aa6f835 chore: put throws in separate function for debugger 2023-01-23 09:27:09 -08:00
Gabriel Ebner
34777c9b90 fix: catch missing exceptions in kernel 2023-01-23 09:27:09 -08:00
Evgenia Karunus
a125a36bcc doc: Expr docs fix (#2047)
```
open Lean Meta

-- Docs text:
-- The let-expression `let x : Nat := 2; Nat.succ x` is represented as

def old : Expr :=
  Expr.letE `x (.const `Nat []) (.lit (.natVal 2)) (.bvar 0) true

elab "old" : term => return old
#check old  -- let x := 2; x : Nat
#reduce old -- 2

def new : Expr :=
  Expr.letE `x (.const `Nat []) (.lit (.natVal 2)) (.app (.const `Nat.succ []) (.bvar 0)) true

elab "new" : term => return new
#check new  -- let x := 2; Nat.succ x : Nat
#reduce new -- 3
```
2023-01-20 09:51:55 +01:00
Sebastian Ullrich
cbdd76f6b6 test: retire .perf benchmarks, cache misses are not very enlightening 2023-01-19 14:44:20 +01:00
Sebastian Ullrich
d0ca604d89 test: update mlton 2023-01-19 14:44:20 +01:00
Sebastian Ullrich
899b673531 test: add binarytrees.st benchmark 2023-01-19 14:44:20 +01:00
Sebastian Ullrich
83450d4bd9 test: clean up binarytrees.lean 2023-01-19 14:44:20 +01:00
Sebastian Ullrich
46f467db66 test: add single-threaded SML binarytrees 2023-01-19 14:44:20 +01:00
github-actions[bot]
57b9d25d5e doc: update changelog 2023-01-19 09:10:27 +00:00
Rishikesh Vaishnav
561e404fe4 feat: make go-to-definition on a typeclass projection application go to the instance(s) (#1767) 2023-01-19 09:10:01 +00:00
Rishikesh Vaishnav
600758ba49 fix: fuzzy-find bonus for matching last characters of pattern and symbol (#1917) 2023-01-19 09:06:53 +01:00
Sebastian Ullrich
e477d41f3f chore: pin Nix 2023-01-18 11:26:32 +01:00
Sebastian Ullrich
43c5ab802f fix: show tactic info on canonical by 2023-01-18 10:23:37 +01:00
Sebastian Ullrich
78bc2fd92b chore: more benchmarking setup 2023-01-17 13:28:05 +01:00
Sebastian Ullrich
223f1073d1 chore: info tree format should not leak hygiene IDs 2023-01-16 08:33:58 -08:00
Sebastian Ullrich
d59f5c2ffa fix: binop% info tree 2023-01-16 08:33:58 -08:00
Leonardo de Moura
4ec1c10dc0 chore: comments at private function mkAuxMVarType 2023-01-16 07:54:20 -08:00
Rishikesh Vaishnav
cce1b25d60 doc: improve documentation of MetavarContext.lean (#1625)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-01-16 16:34:36 +01:00
Siddharth
5349a089e5 feat: add --target flag for LLVM backend to build objects of a different architecture (#2034)
* feat: add --target flag for LLVM backend to build objects of a different architecture

* chore: remove dead comment

* Update src/Lean/Compiler/IR/EmitLLVM.lean

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>

* chore: normalize indentation in src/util/shell.cpp

* chore: strip trailing whitespace

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-01-15 12:00:10 -08:00
Siddharth Bhat
26edfc33f5 chore: remove unused isTaggedPtr from IR.
This reduces the surface area of `unimplemented` in the LLVM backend,
and also removes dead code in the compiler.
2023-01-15 09:24:41 -08:00
James Gallicchio
65db25bf49 feat: funext no arg tactic (#2027)
* feat: `funext` no arg tactic

Description of funext tactic includes behavior that is not implemented. This implements the behavior.

* fix

* feat: test new funext tactic

* use repeat for clarity of intent
2023-01-15 08:53:49 -08:00
Wojciech Nawrocki
ae97ae35e9 chore: remove Inhabited instance 2023-01-13 17:13:02 -08:00
Wojciech Nawrocki
c784031dd7 feat: add GoalLocation type 2023-01-13 17:13:02 -08:00
Wojciech Nawrocki
0960cd0a14 fix: term goal prefix 2023-01-13 17:13:02 -08:00
Wojciech Nawrocki
f5531c2a11 feat: add context and term data to goals 2023-01-13 17:13:02 -08:00
Wojciech Nawrocki
184ca3ddb0 chore: bump server version 2023-01-13 17:13:02 -08:00
Sebastian Ullrich
9b1f5c4df4 test: use OCaml 5 multicore binarytrees implementation 2023-01-12 18:28:41 +01:00
Sebastian Ullrich
f726891baf test: update benchmark flake 2023-01-12 18:28:41 +01:00
Siddharth Bhat
ae4f2de951 fix: metadata codegen for LLVM 2023-01-12 17:39:56 +01:00
Sebastian Ullrich
67a5846742 chore: Nix: more sanitizing 2023-01-12 15:05:14 +01:00
Sebastian Ullrich
707e762d78 chore: Nix: remove redundant link flags 2023-01-12 13:00:09 +01:00
Sebastian Ullrich
da2ea1fa98 chore: Nix: fix symbol interposition 2023-01-12 12:50:17 +01:00
Sebastian Ullrich
7aebab5e43 chore: CI: do not cancel release job on master push 2023-01-12 10:41:51 +01: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
tydeu
e1887fa510 fix: put FFI lib in pkg lib dir in example (for Linux) 2023-01-11 18:24:15 -05:00
tydeu
55fa486ce6 fix: packages dir path and repo url 2023-01-11 18:18:09 -05:00
tydeu
15d656bd9a fix: Linux still needs augmented library path 2023-01-11 17:32:26 -05:00
tydeu
4f505cd056 fix: use full path when loading dynlibs in the server
closes leanprover/lake#146
2023-01-11 16:17:47 -05:00
tydeu
8c793eaae5 chore: bump Lean version 2023-01-11 15:11:26 -05:00
Gabriel Ebner
cee959078d fix: do not require Environment to be inhabited 2023-01-11 15:01:45 -05:00
Eric Wieser
8cd9ce0684 refactor: redefine Nat.mod such that rfl : 0 % n = 0
This property was true in Lean 3, and it was very convenient for working with `Fin n`.
2023-01-11 09:49:58 -08:00
Gabriel Ebner
c21d2f29a2 perf: do not backtrack after eta-defeq 2023-01-09 16:12:02 -08:00
github-actions[bot]
6e5ba6b9e5 doc: update changelog 2023-01-09 23:09:06 +00:00
Sebastian Ullrich
5ffda810dd feat: include timings in trace when profiler is true 2023-01-09 15:08:42 -08:00
James Gallicchio
37650f9147 fix: add done alternative to decreasing_with (#2019)
Previously `decreasing_with` failed if `simp_wf` closes the goal on its
own. This can cause undesired regressions when new `simp` lemmas are
introduced.

Closes #2018.
2023-01-09 09:46:37 -08:00
Bulhwi Cha
99662c1b45 chore: rename le_or_eq_or_le_succ (#2024)
Rename `le_or_eq_or_le_succ` `le_or_eq_of_le_succ`. We need to change
its name in `Std/Data/Array/Init/Lemmas` and `Std/Data/Array/Lemmas`.

Co-authored-by: Bulhwi Cha <chabulhwi@semmalgil.com>
2023-01-09 09:45:51 -08:00
Chris Hughes
396fcd371b feat Init.Data.Nat add simp attribute to mod_zero (#1932) 2023-01-09 09:43:41 -08:00
François G. Dorais
493a887cfb fix: remove unnecessary hypothesis 2023-01-09 18:20:41 +01:00
Siddharth
5615ba6606 feat: implement uset for LLVM (#2025)
Fixes #1958.
2023-01-09 12:25:37 +00:00
Jeremy Salwen
60f30addc7 doc: add more detail to the split tactic docs (#1988)
Co-authored-by: Mac <tydeu@hatpress.net>
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-01-09 13:12:39 +01:00
Sebastian Ullrich
de0a569781 perf: avoid duplicate computation in syntax match elaborator 2023-01-09 13:05:00 +01:00
Sebastian Ullrich
fff1e12878 fix: be more careful with MatchResult.uncovered in syntax match 2023-01-09 13:05:00 +01:00
Sebastian Ullrich
74b3d101e9 chore: Nix: avoid store copies 2023-01-07 20:22:42 +01:00
Sebastian Ullrich
222a8140a7 chore: Nix: avoid quadratic attrset accumulation 2023-01-07 20:22:42 +01: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
Leonardo de Moura
474f1a4d39 feat: try to unify show type and expected type
The goal is to address the regression
```
example : (0 : Nat) + 0 = 0 :=
  show 0 + 0 = 0 from rfl
```
introduced by fedf235cba

Note that we should only *try to* unify the types. Otherwise, we would
produce another regression.
```
example : Int :=
  show Nat from 0
```

cc @kha
2023-01-06 08:48:48 -08:00
Leonardo de Moura
fedf235cba fix: fixes #2011
In Lean 4, we have support for typing constraints of the form
```
(?m ...).1 =?= v
```
where the type of `?m ...` is a structure with a single field.
This kind of constraint is reduced to `?m ... =?= ⟨v⟩`

This feature is implemented by the function `isDefEqSingleton`.
As far as I remember, Lean 3 does not implement this feature.

This commit disables this feature if the structure is a class.
The goal is to avoid the generation of counterintuitive instances by
typing inference.

For example, in the example at issue #2011, the following weird
instance was being generated for `Zero (f x)`
```
(@Zero.mk (f x✝) ((@instZero I (fun i => f i) fun i => inst✝¹ i).1 x✝)
```
where `inst✝¹` is the local instance `[∀ i, Zero (f i)]`
Note that this instance is definitinally equal to the expected nicer
instance `inst✝¹ x✝`.
However, the nasty instance trigger nasty unification higher order
constraints later.

Note that a few tests broke because different error messages were
produced. The new error messages seem better. I do not expect this
change to affect Mathlib4 since Lean 3 does not have this feature.
2023-01-05 17:33:45 -08:00
Gabriel Dahia
b9f0062a58 doc: replace maximum? in minimum? docstring
This is my first contribution, if it can be counted as a contribution. Following the [documentation for simple fixes](https://github.com/leanprover/lean4/blob/master/CONTRIBUTING.md#simple-fixes), I opened the PR directly instead of discussing in the zulip or opening an issue. Hope that's ok.
2023-01-05 14:02:19 -08:00
Leonardo de Moura
770815be9b test: for issue #1937 2023-01-05 13:46:15 -08:00
Leonardo de Moura
ce4dc2388e chore: update stage0 2023-01-05 13:38:15 -08:00
Leonardo de Moura
dd682bf1d5 feat: add support for HO projections at DiscrTree
closes #1937

Requires update stage0
2023-01-05 13:33:43 -08:00
Leonardo de Moura
57e30b670e chore: update stage0 2023-01-04 10:32:12 -08:00
Leonardo de Moura
9a236e70dc fix: fixes #2009 2023-01-04 10:32:03 -08:00
Leonardo de Moura
62812177cb chore: update stage0
We need this "update stege0" to be able to remove the workaround cb7657f47e
2023-01-04 09:11:01 -08:00
Leonardo de Moura
0739c9ccd7 chore: revert workaround 2023-01-04 09:02:02 -08:00
Leonardo de Moura
7bd005bbbe test: add test for local macro in auto tactic 2023-01-04 09:01:02 -08:00
Leonardo de Moura
6fea2946c2 fix: fixes #2006 2023-01-04 08:19:22 -08:00
Leonardo de Moura
069f08e3a3 chore: move getUnboxOpName 2023-01-04 08:07:32 -08:00
Sebastian Ullrich
fa4cbd93ee feat: highlight #exit as leanSorryLike 2023-01-04 10:50:02 +01:00
Sebastian Ullrich
38bd089a45 feat: introduce custom leanSorryLike semantic token type for sorry, admit, stop 2023-01-04 10:50:02 +01:00
Tobias Grosser
d74d4230b7 fix: avoid warning by dropping '#pragma once'
Before this change, we would see the warning:

	"#pragma once in main file"
2023-01-04 09:42:40 +01:00
Gabriel Ebner
905d3204ae chore: correctly comment out initUnboxed test 2023-01-03 18:28:24 -08:00
Gabriel Ebner
cb7657f47e fix: remove nonempty_list tactic 2023-01-03 18:17:19 -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
Leonardo de Moura
2b67da2854 fix: fixes #2000
We now add the macro scope to local syntax declarations.
2023-01-03 15:28:10 -08:00
Leonardo de Moura
30c9f58e6a chore: remove leftover 2023-01-03 15:05:31 -08:00
Leonardo de Moura
5424386c0d chore: update stage0 2023-01-03 14:14:50 -08:00
Gabriel Ebner
181fbdfb42 feat: add fun x ↦ y syntax 2023-01-03 13:59:53 -08:00
Gabriel Ebner
b83e185c79 chore: parse quotations with current stage 2023-01-03 13:59:53 -08:00
Gabriel Ebner
70a6c06eef fix: erase *dependent* local instances 2023-01-03 11:39:46 -08:00
Sebastian Ullrich
948eba4e8b fix: render examples 2023-01-01 21:08:31 +01:00
Sebastian Ullrich
f3f27f5c15 doc: titling consistency 2022-12-31 12:52:27 +01:00
Sebastian Ullrich
048a088010 fix: render monad tutorials 2022-12-31 12:51:48 +01:00
Siddharth
b6eb780144 feat: LLVM backend (#1837) 2022-12-30 12:45:30 +01:00
Gabriel Ebner
d19033e443 fix: correctly parse json unicode escapes 2022-12-23 17:04:10 -08:00
Gabriel Ebner
0553b5936e perf: avoid lifting ← over an if 2022-12-23 05:46:04 +01:00
Sebastian Ullrich
10d2403e83 chore: Nix: link dynamically by default
The Nix way
2022-12-22 12:13:22 +01:00
Gabriel Ebner
a2f5959118 chore: use deriving Nonempty 2022-12-22 03:48:15 +01:00
Gabriel Ebner
53ff517a92 chore: update stage0 2022-12-22 03:48:15 +01:00
Gabriel Ebner
430d7d05d6 feat: add derive handler for Nonempty 2022-12-22 03:48:15 +01:00
Gabriel Ebner
a90afa8a51 fix: tests 2022-12-22 02:02:55 +01:00
Gabriel Ebner
7736c051ff fix: assigned tc mvar check 2022-12-22 02:02:55 +01:00
Gabriel Ebner
6083b01c86 fix: remove maxCoeSize option 2022-12-22 02:02:55 +01:00
Gabriel Ebner
8a48a8f119 refactor: use coercion meta API 2022-12-22 02:02:55 +01:00
Gabriel Ebner
05401776f2 fix: add reflexivity instances to coercions
This is important when users plug custom instances into auxiliary
classes like `CoeTC`.  We already had a reflexivity instance for
`CoeTC`.
2022-12-22 02:02:55 +01:00
Gabriel Ebner
f798507bbf chore: tc: only normalize level mvars at current depth 2022-12-22 02:02:55 +01:00
Gabriel Ebner
e71a2e58bb fix: remove misleading leading space in " where" 2022-12-21 22:54:42 +01:00
Gabriel Ebner
0d598dcfdf fix: Format.align always prints whitespace 2022-12-21 22:54:42 +01:00
github-actions[bot]
d3c852a3b1 doc: update changelog 2022-12-21 21:00:58 +00:00
Sebastian Ullrich
de9a6374f1 feat: make #check <ident> always show the signature without elaboration 2022-12-21 21:59:05 +01:00
Sebastian Ullrich
de180e5c7a fix: private + pp.fullNames 2022-12-21 21:59:05 +01:00
Sebastian Ullrich
eaafd36918 feat: use signature pretty printer in #check id/#check @id 2022-12-21 21:59:05 +01:00
Sebastian Ullrich
84de976111 chore: fix copy-produced script 2022-12-21 21:59:05 +01:00
Sebastian Ullrich
b6bd2dea35 feat: signature pretty printer for hovers 2022-12-21 21:59:05 +01:00
Sebastian Ullrich
533c770e36 refactor: remove redundant state 2022-12-21 21:59:05 +01:00
Gabriel Ebner
572ffe77e3 fix: implement assertAfter using revert 2022-12-21 21:42:07 +01:00
Gabriel Ebner
eeab2af7ae fix: remove Inhabited Environment instance 2022-12-21 20:08:08 +01:00
Sebastian Ullrich
cbf1b433d7 chore: Nix: linkFarm, not symlinkJoin 2022-12-21 20:06:18 +01:00
Gabriel Ebner
443c1a08e5 fix: lsp change debouncing 2022-12-21 20:02:53 +01:00
Sebastian Ullrich
73f9377322 chore: Nix: cache depRoots 2022-12-21 15:22:13 +01:00
Gabriel Ebner
586079462c doc: explain variable conditions in type classes 2022-12-21 04:24:39 +01:00
Gabriel Ebner
14f8ff1642 feat: add CoeOut class 2022-12-21 04:24:39 +01:00
Gabriel Ebner
c7fb3a1c91 chore: make use of CoeHead chaining 2022-12-21 04:24:39 +01:00
Gabriel Ebner
78676a5a5a refactor: chain CoeHead 2022-12-21 04:24:39 +01:00
Gabriel Ebner
2b97392f2e refactor: use @[coe_decl] attribute 2022-12-21 04:24:39 +01:00
Gabriel Ebner
4e02c55766 chore: update stage0 2022-12-21 04:24:39 +01:00
Gabriel Ebner
e59ddb0c16 refactor: replace hardcoded list of coercions by attribute 2022-12-21 04:24:39 +01:00
Gabriel Ebner
d2203aa5a0 chore: restrict dangerous typed syntax coercions 2022-12-21 04:24:39 +01:00
Gabriel Ebner
118567657d chore: remove dangerous instances in json-rpc 2022-12-21 04:24:39 +01:00
Gabriel Ebner
434d889f4d chore: remove dangerous instances 2022-12-21 04:24:39 +01:00
Gabriel Ebner
2606021304 fix: use ppTerm instead of formatTerm 2022-12-21 03:08:18 +01:00
Gabriel Ebner
54290d537b fix: deterministic fvar alias printing 2022-12-21 03:08:18 +01:00
Sebastian Ullrich
96ccf192e8 fix: parenthesize by optParam values 2022-12-20 18:10:39 +01:00
Gabriel Ebner
e386d5941e refactor: replace ignoreLevelMVarDepth by levelAssignDepth 2022-12-19 20:14:17 +01:00
Mario Carneiro
8b0699cd3b fix: disable memoize in pattern conv 2022-12-19 06:21:54 -08:00
Sebastian Ullrich
adf74380cc chore: Nix: cache Leanc.src 2022-12-18 15:02:48 +01:00
Sebastian Ullrich
f732afed0a fix: dynamic linking of Lean programs 2022-12-18 12:19:21 +01:00
Sebastian Ullrich
f6cd6c0695 chore: Nix: cache LeanInk output 2022-12-15 13:38:46 +01:00
Sebastian Ullrich
dec355aaf8 chore: Nix: cache stand-alone lean, leanc 2022-12-15 13:26:04 +01:00
Scott Morrison
7c29cc742b chore: add iff_self to simpOnlyBuiltins 2022-12-15 01:00:30 +01:00
Mario Carneiro
52d00e8944 test: macro scopes in Conv.congr (#1955) 2022-12-14 16:43:26 +00:00
Sebastian Ullrich
d5fb32a393 fix: hygiened goal tags in conv congr 2022-12-14 16:36:47 +01:00
locriacyber
fa761b8baf chore: fix typo in CLI usage (--ldlags) (#1947) 2022-12-14 10:20:50 +01:00
Sebastian Ullrich
4fa8d003d8 chore: update stage0 2022-12-13 22:15:05 +01:00
Sebastian Ullrich
636afc654a fix: avoid mapping .oleans in the way of the stack 2022-12-13 22:11:41 +01:00
Sebastian Ullrich
3cebe7464c fix: protect against jumping over the stack guard page 2022-12-13 22:02:05 +01:00
Sebastian Ullrich
88c8cd5cf2 fix: show correct goal state after an empty by 2022-12-13 01:39:45 +01:00
Sebastian Ullrich
9c9cc017df fix: ignore empty character literals 2022-12-12 22:59:06 +01:00
Gabriel Ebner
f3f4eba945 fix: make Format.*join* tail-recursive 2022-12-12 22:58:21 +01:00
Gabriel Ebner
1c8ef51124 fix: make List.toString tail-recursive 2022-12-12 22:58:21 +01:00
Mario Carneiro
eb3b0377d7 fix: List.groupBy 2022-12-12 16:55:27 +01:00
Wojciech Nawrocki
7034e64b4f doc: update widget example 2022-12-09 09:51:08 +01:00
Gabriel Ebner
57a6aefb92 chore: CI: also save core dumps for builds 2022-12-08 15:55:40 -08:00
Gabriel Ebner
43e3b78eb0 feat: CI: capture core dumps 2022-12-08 20:08:13 +01:00
Wojciech Nawrocki
a9ba08ce11 doc: document msgToInteractiveDiagnostic 2022-12-07 19:16:25 +01:00
Sebastian Ullrich
6169435259 refactor: consolidate MessageData constructors into lazy formatting with infos 2022-12-07 19:16:25 +01:00
Sebastian Ullrich
0b243f0ca3 chore: Nix: avoid import errors for now
Gotta refactor this anyway
2022-12-04 18:52:33 +01:00
Sebastian Ullrich
9e83115072 chore: Nix: lazy-trees compatibility 2022-12-04 18:52:33 +01:00
Sebastian Ullrich
768ef310a0 refactor: Nix: LeanInk rendering based on packages, not directories 2022-12-03 15:14:17 +01:00
Sebastian Ullrich
ed3fa37341 chore: Nix: add overrideBuildModAttrs 2022-12-03 14:13:31 +01:00
Gabriel Ebner
4b87103931 chore: ignore document version errors 2022-12-03 01:20:47 +01:00
tydeu
fe09c9c824 chore: update Lake 2022-12-03 01:19:29 +01:00
tydeu
148b067724 test: fix shell script permissions 2022-12-02 17:58:51 -05:00
tydeu
479fe81894 feat: print log on failing lake print-paths
closes leanprover/lake#116
2022-12-02 17:26:36 -05:00
Gabriel Ebner
47b4eae9a6 perf: use ByteArray.hash directly 2022-12-02 14:31:48 -05:00
ChrisHughes24
e168806078 chore: rename Prod.ext 2022-12-02 20:24:19 +01:00
tydeu
c60ccdc974 test: increase sleep in 44 2022-12-02 14:20:58 -05:00
tydeu
25ab266a2e fix: escape names from new/init
closes leanprover/lake#128
2022-12-02 14:17:57 -05:00
tydeu
b8c4ed5a83 feat: -U to update & build; add packagesDir to manifest 2022-12-02 14:17:57 -05:00
tydeu
93f1d05e2a fix: various build problems
fixes leanprover/lake#139
touches on leanprover/lake#132
2022-12-02 14:17:56 -05:00
tydeu
b813197b36 chore: cleanup 2022-12-02 14:17:56 -05:00
Gabriel Ebner
b76bfcac91 fix: do not rely on iteration order of NameSet 2022-12-02 14:11:12 -05:00
Gabriel Ebner
7603e49169 chore: bump Lean version 2022-12-02 14:06:15 -05:00
Leonardo de Moura
8a573b5d87 fix: fixes #1900 2022-12-02 10:04:01 -08:00
Leonardo de Moura
a999015371 feat: add applicationTime to registerTagAttribute 2022-12-02 09:58:41 -08:00
Leonardo de Moura
50fc4a6ad8 fix: fixes #1907 2022-12-02 08:59:16 -08:00
Gabriel Ebner
681bbe5cf4 feat: ByteArray.hash 2022-12-01 20:18:14 -08:00
Gabriel Ebner
a67a5080e9 chore: fix tests after hash change 2022-12-01 20:18:14 -08:00
Gabriel Ebner
c83e33b06a chore: update stage0 2022-12-01 20:18:14 -08:00
Gabriel Ebner
9b416667e7 chore: replace all hashes by murmurhash 2022-12-01 20:18:14 -08:00
Gabriel Ebner
b0cadbc1fa fix: support escaped field names in deriving FromJson/ToJson 2022-12-02 03:48:19 +01:00
Gabriel Ebner
3d1571896c fix: support escaped field names in dot-notation 2022-12-02 03:48:19 +01:00
Gabriel Ebner
7af80766e3 fix: do not ignore applicationTime in parametric attributes 2022-12-02 02:15:35 +01:00
Leonardo de Moura
ffb0f42aae fix: fixes #1901 2022-12-01 08:39:06 -08:00
Leonardo de Moura
0dda3a8c02 fix: include instance implicits that depend on outParams at outParamsPos
This fixes the fix for #1852
2022-12-01 06:11:48 -08:00
Leonardo de Moura
0a031fc9bb chore: replace Expr.forEach with Expr.forEachWhere 2022-12-01 05:19:32 -08:00
Sebastian Ullrich
af5efe0b2d doc: MonadReader 2022-12-01 10:16:04 +01:00
Sebastian Ullrich
50b2ad89b4 test: limit maxRecDepth 2022-12-01 10:06:57 +01:00
Leonardo de Moura
30d625697e chore: use Expr.forEachWhere to implement linter
closes #1899

TODO: use `Expr.forEachWhere` in other modules. There are many other opportunities.
2022-11-30 18:44:20 -08:00
Leonardo de Moura
1c5706bcc0 feat: add Expr.forEachWhere 2022-11-30 18:41:12 -08:00
Leonardo de Moura
5a151ca64c chore: fix tests 2022-11-30 17:52:37 -08:00
Leonardo de Moura
0db02c3911 chore: update Lake 2022-11-30 17:05:38 -08:00
Leonardo de Moura
95467dfab7 chore: update stage0 2022-11-30 17:05:38 -08:00
Leonardo de Moura
e5681ac141 feat: replace mixHash implementation
We are now using part of the murmur hash like Scala.
For additional information and context, see
https://leanprover.zulipchat.com/#narrow/stream/147302-lean4-maintainers/topic/Increasing.20.60Expr.2Ehash.60.20to.2064.20bits/near/313114719
2022-11-30 17:03:58 -08:00
Leonardo de Moura
8fbb866798 fix: incorrect use of outParam
We have
```
class BindAsync (n : Type u → Type v) (k : outParam $ Type u → Type u)
instance : BindAsync BaseIO (EIOTask ε)
instance : BindAsync BaseIO OptionIOTask
instance [BindAsync n k] [Pure n] [Pure k] : BindAsync n (ExceptT ε k)
instance [BindAsync n k] [Pure n] [Pure k] : BindAsync n (OptionT k)
```

See discussion at: https://leanprover.zulipchat.com/#narrow/stream/147302-lean4-maintainers/topic/Increasing.20.60Expr.2Ehash.60.20to.2064.20bits/near/313183466
2022-11-30 16:56:09 -08:00
Leonardo de Moura
8fc3d77a0b feat: add trace.Meta.Tactic.simp.numSteps and trace.Meta.Tactic.simp.heads 2022-11-30 07:07:07 -08:00
Leonardo de Moura
2a36cf42d2 chore: update stage0 2022-11-30 06:43:57 -08:00
Leonardo de Moura
aee63ee7b0 feat: panic at Name.append if both names have macro scopes 2022-11-30 06:39:49 -08:00
Leonardo de Moura
7c5d91ebc3 fix: avoid hygienic ++ hygienic at Specialize.lean 2022-11-30 06:31:03 -08:00
Leonardo de Moura
a095dabb17 feat: Name.append and macro scopes 2022-11-29 23:06:04 -08:00
Leonardo de Moura
bc21716bad chore: helper simp theorems 2022-11-29 23:05:48 -08:00
Leonardo de Moura
dc937cb1f9 chore: Name.append 2022-11-29 23:05:19 -08:00
Leonardo de Moura
3e45060dd5 fix: disable implicit lambdas for local variables without type information
Problem reported at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/why.20doesn't.20this.20unify.3F/near/312806870
2022-11-29 14:33:16 -08:00
Scott Morrison
1b50292228 chore: protect Prod.Lex 2022-11-29 20:09:08 +01:00
Sebastian Ullrich
bc0684a29c fix: work around VS Code completion bug 2022-11-29 19:14:45 +01:00
Leonardo de Moura
069873d8e5 fix: fixes #1891 2022-11-29 08:59:46 -08:00
Mario Carneiro
40e212c166 feat: infer def/theorem DefKind for let rec 2022-11-29 08:16:47 -08:00
Gabriel Ebner
6e23ced6d9 fix: test 2022-11-29 08:16:09 -08:00
Gabriel Ebner
bdbab653fd fix: synthesize tc instances before propagating expected type 2022-11-29 08:16:09 -08:00
Henrik Böving
5286c2b5aa feat: optimize mul/div into shift operations 2022-11-29 01:05:06 +01:00
Henrik Böving
24cc6eae6d feat: log2 for Fin and UInts 2022-11-29 01:05:06 +01:00
Sebastian Ullrich
a38bc0e6ed refactor: revise server architecture
Replace complex debouncing logic in watchdog with single `IO.sleep` in
worker `didChange` handler, replace redundant header change logic in
watchdog with special exit code from worker.
2022-11-29 00:52:24 +01:00
Mario Carneiro
17ef0cea8a feat: intra-line withPosition formatting 2022-11-28 09:02:08 -08:00
Sebastian Ullrich
07953062ed perf: remove unnecessary, cache-defeating withPosition in doReassignArrow 2022-11-28 08:14:03 -08:00
Leonardo de Moura
9dbd9ec554 chore: fix build 2022-11-28 07:53:43 -08:00
Leonardo de Moura
6bc919742e chore: update stage0 2022-11-28 07:51:42 -08:00
Leonardo de Moura
c510d16ef5 fix: fixes #1808 2022-11-28 07:48:54 -08:00
Siddharth Bhat
dfb5548cab fix: update libleanrt.bc, rename to lean.h.bc
This adds `lean.h.bc`, a LLVM bitcode file of the Lean
runtime that is to be inlined. This is programatically generated.

1. This differs from the previous `libleanrt.ll`, since it produces an
   LLVM bitcode file, versus a textual IR file. The bitcode file
   is faster to parse and build an in-memory LLVM module from.
2. We build `lean.h.bc` by adding it as a target to `shell`,
   which ensures that it is always built.

3. We eschew the need for:

```cpp
```

which causes breakage in the build, since changing the meaning of
`static` messes with definitions in the C++ headers.

Instead, we build `lean.h.bc` by copying everything in
`src/include/lean/lean.h`, renaming `inline` to
`__attribute__(alwaysinline)` [which forces LLVM to generate
`alwaysinline` annotations], then running the `-O3` pass pipeline
to get reasonably optimised IR, and will be perfectly inlined
when linked into the generated LLVM code by
`src/Lean/Compiler/IR/EmitLLVM.lean`.

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2022-11-28 16:20:12 +01:00
Scott Morrison
a3dfa5516d feat: add HashSet.insertMany 2022-11-28 06:59:21 -08:00
Leonardo de Moura
36cc7c23b6 fix: fixes #1886 2022-11-28 06:50:44 -08:00
Sebastian Ullrich
092e26179b chore: fix script/reformat.lean 2022-11-28 15:47:17 +01:00
Sebastian Ullrich
c112ae7c58 test: fix Lake rename 2022-11-28 15:12:18 +01:00
Scott Morrison
c4ff5fe199 chore: change simp default to decide := false 2022-11-27 09:27:16 -08:00
Sebastian Ullrich
42a080fae2 fix: comments ending in --/
Fixes #1883
2022-11-25 10:32:49 +01:00
Sebastian Ullrich
39f2322f35 fix: save correct environment in info tree for example 2022-11-24 13:11:14 -08:00
Leonardo de Moura
543a7e26d4 test: for #1878
closes #1878
2022-11-24 13:03:45 -08:00
Leonardo de Moura
17855b6e90 chore: update stage0 2022-11-24 12:57:43 -08:00
Leonardo de Moura
4be7543adb feat: add APIs for issue #1878
We need `update-stage0` because this commit affects the .olean format.
2022-11-24 12:55:41 -08:00
Leonardo de Moura
c53c5b5e16 fix: fixes #1882
Better support for `intro <type-ascription>`.
It was treating it as a pattern before this commit.
2022-11-24 12:40:25 -08:00
Leonardo de Moura
897ccd3783 chore: spaces 2022-11-24 12:33:21 -08:00
Leonardo de Moura
9d8b324f8d fix: fixes #1869
Better support for simplifying class projections.
2022-11-24 11:56:36 -08:00
Leonardo de Moura
71b7562c2f fix: class projection at DiscrTree 2022-11-24 11:56:36 -08:00
github-actions[bot]
75f8ebdd19 doc: update changelog 2022-11-24 03:08:45 +00:00
Gabriel Ebner
6225a3e415 chore: update Lake 2022-11-23 19:08:14 -08:00
Leonardo de Moura
1ec535d523 test: alternative encoding experiment for decEq and noConfusion 2022-11-23 18:46:10 -08:00
Gabriel Ebner
733f015c65 chore: reduce imports 2022-11-23 20:56:40 -05:00
Gabriel Ebner
42a8e0f190 refactor: split code for lake update and lake build 2022-11-23 20:56:40 -05:00
Gabriel Ebner
1949285fdb chore: disable parallel testing in ci 2022-11-23 20:56:40 -05:00
Gabriel Ebner
2808cc2744 feat: improve manifest test 2022-11-23 20:56:40 -05:00
Gabriel Ebner
031d9712d5 chore: simplify test/manifest/test.sh 2022-11-23 20:56:40 -05:00
Gabriel Ebner
1e79d659f2 chore: bundle libatomic in releases 2022-11-23 16:42:37 -08:00
Gabriel Ebner
06dc85453e chore: CI: allow releases not starting with v 2022-11-23 16:42:37 -08:00
Mario Carneiro
9b572d4e20 chore: make <;> left associative 2022-11-23 07:44:54 -08:00
Leonardo de Moura
0694731af8 fix: fixes #1870 2022-11-23 05:49:19 -08:00
Leonardo de Moura
9c561b593a feat: add withTraceNodeBefore and use it at ExprDefEq
`withTraceNode` uses the metavariable context after executing
`k`. This is bad when debugging `isDefEq`.
2022-11-22 14:43:28 -08:00
Leonardo de Moura
dfaf9c6ebd chore: register missing trace options, and fix inherited parameter
The current setting was bad for debugging `isDefEq` issues.
2022-11-22 14:43:28 -08:00
Sebastian Ullrich
cbf7da0f6e chore: CI: update all actions to avoid warnings 2022-11-22 21:31:07 +01:00
Leonardo de Moura
89e1bc72ed doc: examples for Certora tutorial 2022-11-21 17:02:28 -08:00
Mario Carneiro
6cafcabe46 fix: print universe level lists in lean 4 style 2022-11-21 21:35:56 +01:00
Alex J Best
eff3c95f23 chore: fix typo in getNumBuiltiAttributes name 2022-11-21 09:22:31 -08:00
Sebastian Ullrich
019707ccf4 fix: do method lifting across choice nodes 2022-11-21 17:52:14 +01:00
Siddharth
4d47c8abc6 feat: add LLVM C API bindings (#1497)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2022-11-21 09:50:01 +01:00
Sebastian Ullrich
1b73fa3fa1 chore: lean.mk: re-suppress find error messages 2022-11-20 19:55:09 +01:00
Leonardo de Moura
027bf6e140 chore: update stage0 2022-11-20 10:48:22 -08:00
Sebastian Ullrich
9c3a283eb1 chore: update-stage0: simplify 2022-11-20 10:22:20 -08:00
Sebastian Ullrich
5053cb02b7 chore: don't copy .lean files to stage0 2022-11-20 10:22:20 -08:00
Sebastian Ullrich
7809b269ca chore: avoid xargs in update-stage0 2022-11-20 10:22:20 -08:00
Leonardo de Moura
9056824be5 chore: update stage0 2022-11-19 19:24:10 -08:00
Leonardo de Moura
9022fb8d48 fix: custom update-stage0 for osx 2022-11-19 19:20:13 -08:00
Leonardo de Moura
51a29098ab fix: fixes #1852 2022-11-19 09:37:52 -08:00
Leonardo de Moura
22e96c71e9 fix: fixes #1850 2022-11-19 09:18:12 -08:00
Gabriel Ebner
bbe5cf63b2 perf: pick cache size coprime to pointer alignment 2022-11-19 08:27:38 -08:00
Mario Carneiro
c8859a31d9 fix: Nat.log2_terminates should not be private 2022-11-19 08:26:59 -08:00
Leonardo de Moura
14d37739c7 chore: update stage0 2022-11-19 07:55:34 -08:00
Leonardo de Moura
ecac90c522 fix: optParam default value does not count as dependency at anyNamedArgDependsOnCurrent 2022-11-19 07:54:28 -08:00
Leonardo de Moura
ace674cc06 chore: remove unnecessary test 2022-11-19 07:52:53 -08:00
Leonardo de Moura
966e1df96d chore: fix build 2022-11-19 07:46:01 -08:00
Leonardo de Moura
a5ab59a413 fix: fixes #1851 2022-11-19 07:01:02 -08:00
Leonardo de Moura
5e9767a283 chore: fix test 2022-11-18 21:10:34 -08:00
Leonardo de Moura
556b6706ee fix: fixes #1856 2022-11-18 19:34:32 -08:00
Leonardo de Moura
a7107aedb3 fix: fixes #1848 2022-11-18 08:49:10 -08:00
Mario Carneiro
f74fee07e6 doc: document Init.Data.List.Basic (#1828)
* doc: document Init.Data.List.Basic

* Apply suggestions from code review

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2022-11-18 06:16:50 -08:00
Sebastian Ullrich
46b6391c77 fix: inconsistent use of precompiled symbols from interpreter on Windows 2022-11-18 06:16:05 -08:00
Sebastian Ullrich
a4abbf07b8 chore: remove remnants of C++ format 2022-11-18 06:11:24 -08:00
Sebastian Ullrich
7529e86307 feat: implement workspace/applyEdit server request (#1846) 2022-11-17 19:30:17 +00:00
E.W.Ayers
73644fc6f6 docs: add a section about how to insert text from a widget 2022-11-16 18:57:28 -08:00
E.W.Ayers
aca4703f04 fix: fix the code example for widgets docs. 2022-11-16 18:57:28 -08:00
Leonardo de Moura
d2a5ea137d fix: fixes #1842 2022-11-16 17:29:41 -08:00
Leonardo de Moura
edadd8c034 fix: fixes #1841
This commit adds the configuration option
`ApplyConfig.approx` (available in Lean 3), and sets it to true by
default like in Lean 3.
2022-11-16 14:46:05 -08:00
Leonardo de Moura
6f5bd3ccb6 chore: update stage0 2022-11-16 13:32:08 -08:00
Leonardo de Moura
7b03d9719c fix: fixes #1679 2022-11-16 13:15:53 -08:00
Henrik Böving
6fe52cac41 doc: explain some decisions in ElimDeadBranches 2022-11-16 08:17:13 -08:00
Henrik Böving
e0d619e3ee chore: basic tests for LCNF ElimDeadBranches 2022-11-16 08:17:13 -08:00
Henrik Böving
66009a5cd3 feat: constant folding for decision procedures 2022-11-16 08:17:13 -08:00
Henrik Böving
5a397c8525 feat: ElimDeadBranches for LCNF 2022-11-16 08:17:13 -08:00
Mario Carneiro
d3a30869c7 fix: spacing in by_cases 2022-11-16 08:16:42 -08:00
Mario Carneiro
118d1027d2 feat: go to definition for KeyedDeclsAttributes 2022-11-16 11:16:24 +01:00
Mario Carneiro
2184533236 fix: attribute info nesting 2022-11-16 11:12:24 +01:00
Leonardo de Moura
98922b878a fix: fixes #1815 2022-11-15 17:08:54 -08:00
Leonardo de Moura
a4acf084c8 chore: fix build 2022-11-15 16:51:40 -08:00
Leonardo de Moura
8a012c83d3 chore: update stage0 2022-11-15 16:49:07 -08:00
Leonardo de Moura
8225be2f0e feat: ensure projections are not reducing at DiscrTree V (simpleReduce := true)
Now, the `simp` discrimination tree does not perform `iota` nor reduce
projections.
2022-11-15 16:47:12 -08:00
Leonardo de Moura
1b0c2f7157 feat: parameterize DiscrTree indicating whether non trivial reductions are allowed or not when indexing/retrieving terms 2022-11-15 16:47:12 -08:00
Leonardo de Moura
81c84bf045 feat: do not perform iota reduction at the discrimination tree module 2022-11-15 16:47:12 -08:00
Gabriel Ebner
75aa732af5 doc: mention ignoreLevelMVarDepth 2022-11-15 11:29:26 -08:00
Leonardo de Moura
1cc58e60ef fix: fixes #1829 2022-11-15 08:31:36 -08:00
Sebastian Ullrich
3d1ff59f11 fix: parseImports': respect prelude 2022-11-15 07:40:10 -08:00
Sebastian Ullrich
e3b83625f2 perf: optimize --deps --json 2022-11-15 07:40:10 -08:00
Sebastian Ullrich
3f9ba30424 fix: integer overflows 2022-11-15 07:37:54 -08:00
Sebastian Ullrich
591eccee4f chore: move expensive test to beginning of test block 2022-11-14 15:46:34 +01:00
Sebastian Ullrich
6e34c89cbb chore: Nix: comment out rarely used lean-stage0 input
Optional inputs would be nice.
2022-11-14 13:12:07 +01:00
Sebastian Ullrich
fea819bf3c chore: update stage0 2022-11-14 12:56:03 +01:00
Sebastian Ullrich
4cd5b67271 chore: generalize parser kind detection 2022-11-14 12:53:18 +01:00
Mario Carneiro
73a8dc9738 feat: add decl links for Quot via add_decl_doc 2022-11-14 09:54:56 +01:00
Mario Carneiro
a2199d6d57 doc: document Init.Data.Nat.Basic 2022-11-13 21:59:57 -08:00
Mario Carneiro
2cb333a260 feat: elab_rules : conv 2022-11-13 21:09:26 -08:00
Leonardo de Moura
5654d8465d fix: fixes #1822 2022-11-13 18:13:29 -08:00
Leonardo de Moura
a87f0e25de feat: add compiler.checkTypes for sanity checking 2022-11-13 17:45:21 -08:00
Leonardo de Moura
854e655940 chore: document implementedBy := true use at phase 1 2022-11-13 15:47:13 -08:00
Mario Carneiro
b948a56196 chore: remove [Inhabited A] from binSearch / binInsert 2022-11-13 15:00:26 -08:00
Alex J. Best
c72cf24694 chore: protect Int.repr 2022-11-13 15:00:08 -08:00
Mario Carneiro
178d0ebe4f fix: protected on Nat.add_zero 2022-11-13 14:59:47 -08:00
Mario Carneiro
7358df2f7e chore: remove Int.natMod 2022-11-13 14:59:26 -08:00
Gabriel Ebner
716fe7abb8 perf: use parseImports' 2022-11-11 13:21:42 -05:00
Gabriel Ebner
c614ffa2f7 chore: bump Lean version 2022-11-11 13:21:42 -05:00
Sebastian Ullrich
bcd1673231 chore: abort build on panic 2022-11-11 16:24:04 +01:00
Leonardo de Moura
c3d86001c4 chore: simplify dependencies at MatchEqs 2022-11-11 05:51:05 -08:00
Sebastian Ullrich
1f447efa54 doc: update Lean.Parser.Basic 2022-11-11 14:17:21 +01:00
Sebastian Ullrich
7cdd8f81d7 refactor: simplify withCacheFn 2022-11-11 14:07:15 +01:00
Sebastian Ullrich
d44b70c24b chore: update stage0 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
43767f8f35 fix: uncacheable syntax stack access in doIf 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
4c11743f4b refactor: split paren parser, part 2 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
c370256870 chore: update stage0 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
791fc70dd9 refactor: split paren parser 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
64ec4106c3 chore: update stage0 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
30dd28480d fix: suppressInsideQuot inside quotation 2022-11-11 13:45:41 +01:00
Sebastian Ullrich
f5c13f9db8 chore: parseQuotWithCurrentStage and quotPrecheck 2022-11-11 13:45:41 +01:00
github-actions[bot]
140d10819d doc: update changelog 2022-11-11 08:13:31 +00:00
Sebastian Ullrich
0dea086669 fix: reset lhsPrec, errorMsg in withCacheFn 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
22510db004 refactor: simplify parser code using withFn 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
e7bf1cd3dc refactor: simplify adaptUncacheableContextFn
compiler.ir.result reports 0 allocations on happy path
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
fb941d0827 fix: ensure parser caching is sound re. syntax stack accesses 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
7410d00678 feat: Subarray.findRev? 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
12b267bd8c refactor: categoryParserOfStack is dead 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
17782fba1a fix: replace broken ptrEq cache sanity checks with private ParserContext constructor
The context is now manipulated using `adaptCacheableContext` and `adaptUncacheableContext`
and created using `ParserFn.run`.
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
d5255e94e8 perf: improve dynamicQuot caching 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
d3f7d0350f refactor: move parser types into separate file 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
9a4626c495 fix: must cache stack of parser evals 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
36189cb51a chore: simplify parser cache key computation, panic on environment/token table divergence 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
ed03ff9d00 perf: cache leading_parser and syntax as well
We better hope the `leading_parser`s are closed terms
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
da6efe1bca fix: make parser caching sound (I hope?) 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
35509b5e98 refactor: more sensible ordering of declarations in Lean.Parser.Basic 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
246923886a fix: do not create choice nodes for failed parses 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
57320712f0 fix: extraneous missing items on parser stack 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
260387d626 chore: update stage0 2022-11-11 09:13:02 +01:00
Sebastian Ullrich
7e193a45ce perf: cache category parses 2022-11-11 09:13:02 +01:00
Leonardo de Moura
8030aed56e fix: fixes #1814
Missing `hasAssignableMVar` checks.
2022-11-10 20:42:02 -08:00
tydeu
837eec5d9a feat: add buildO helper
closes leanprover/lake#126
2022-11-10 20:48:05 -05:00
tydeu
8e6abd7c56 doc: add --old to lake help 2022-11-10 20:48:05 -05:00
tydeu
ddd7581ee4 refactor: lean_packages -> lake-packages + cleanup 2022-11-10 20:48:04 -05:00
tydeu
855a655033 refactor: split actions requiring load into separate file
see 1bd8430c15 (r82430947)
2022-11-10 20:48:03 -05:00
tydeu
0bf59a5921 feat: library defaultFacets setting
closes leanprover/lake#117
2022-11-10 20:48:02 -05:00
tydeu
d3d526d43f test: make FFI example builds verbose 2022-11-10 20:46:57 -05:00
tydeu
0b1d2956a4 refactor: change manifest file path
closes leanprover/lake#111
2022-11-10 20:46:57 -05:00
Mario Carneiro
9544a0572e fix: remove #check 2022-11-10 20:46:55 -05:00
tydeu
f40dbbcf02 chore: remove verbosity from LoadConfig 2022-11-10 20:46:55 -05:00
tydeu
fc65f6e73e chore: start next Lake version 2022-11-10 20:46:54 -05:00
Leonardo de Moura
ca0fb21df4 fix: fixes #1813
Remark: modifies the value for the `mid` priority.
See new note at `Init/Notation.lean`
2022-11-10 16:09:21 -08:00
Leonardo de Moura
723b87ad63 chore: fix build
Incorrect assertion in the old code generator has been exposed by new test.
2022-11-10 15:27:43 -08:00
Leonardo de Moura
c147059fd7 fix: fixes #1812 2022-11-10 08:58:09 -08:00
Leonardo de Moura
9b02f982e2 chore: add ppCode' 2022-11-10 08:07:35 -08:00
Leonardo de Moura
2386c401d2 chore: use String.get' and String.next' at Parser/Basic.lean
This commit also cleans up old frontend legacy.
2022-11-09 17:06:22 -08:00
Leonardo de Moura
5eaa0fa2df chore: leftovers 2022-11-09 17:03:08 -08:00
Leonardo de Moura
7b8ade5ee4 test: String.get' and String.next' 2022-11-09 17:02:49 -08:00
Leonardo de Moura
afa567fc09 chore: update stage0 2022-11-09 16:58:52 -08:00
Leonardo de Moura
4f07c46956 fix: bug at lean_string_utf8_get_fast 2022-11-09 16:58:20 -08:00
Leonardo de Moura
1704debcd0 perf: add parseImports'
Faster version of `parserImports` for Lake
2022-11-09 14:50:11 -08:00
Leonardo de Moura
69bd25af4f chore: add Repr and Inhabited instances for Import 2022-11-09 14:35:57 -08:00
Leonardo de Moura
3e33fcc4f8 chore: use lean_string_utf8_next_fast 2022-11-09 12:06:37 -08:00
Leonardo de Moura
ab59cce346 chore: update stage0 2022-11-09 12:04:58 -08:00
Leonardo de Moura
92c03c0050 perf: prepare do add String.next' 2022-11-09 12:00:31 -08:00
Leonardo de Moura
20eeb4202f perf: fast String.get' without runtime bounds check
TODO: naming convention `String.get'` should be called `String.get`,
and we should rename the old `String.get`
2022-11-09 12:00:30 -08:00
Adrien Champion
33aa1724f2 fix: rewrite by with strict indentation in a few struct-fields 2022-11-08 08:30:42 -08:00
Adrien Champion
1823735ebf chore: tests for strict-indent nested by-s 2022-11-08 08:30:42 -08:00
Adrien Champion
5849fdc6c9 feat: require strict indentation on nested by-s 2022-11-08 08:30:42 -08:00
github-actions[bot]
d7636694a8 doc: update changelog 2022-11-08 16:29:53 +00:00
Mario Carneiro
4bf89dfa12 feat: allow doSeq in let x <- e | seq
fixes #1804
2022-11-08 08:29:21 -08:00
Sebastian Ullrich
9f2182fdd9 chore: update script/apply.lean semantics 2022-11-07 19:47:04 -08:00
Sebastian Ullrich
5be816244e chore: update script/apply.lean syntax 2022-11-07 19:47:04 -08:00
Leonardo de Moura
95df68f3e4 chore: [elab_as_elim] at Eq.substr
Lean 3 compatibility issue.

see #1806
2022-11-07 19:44:11 -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
65caa8f2c4 chore: update stage0 2022-11-07 18:20:48 -08:00
Leonardo de Moura
e8b4a8875c fix: type argument that is a fvar at FixedParams.lean 2022-11-07 18:18:07 -08:00
Leonardo de Moura
d11697cbf7 chore: fix some tests 2022-11-07 18:18:06 -08:00
Leonardo de Moura
9399164201 fix: simpCasesOnCtor? 2022-11-07 18:18:06 -08:00
Leonardo de Moura
a5dadfdb7a feat: activate all passes 2022-11-07 16:18:36 -08:00
Leonardo de Moura
828a815821 fix: simpAppApp? 2022-11-07 16:18:36 -08:00
Leonardo de Moura
92faeec832 fix: add Simp.findFunDecl'?
It may look like a simple optimization but affects the inlining
heuristics. Example:
```
fun f ... := ...
let x_1 := f
let x_2 := x_1 a
let x_3 := x_1 b
...
```
Before this commit, `f` was not being marked as being used multiple times.
2022-11-07 16:18:36 -08:00
Leonardo de Moura
f342d0ea35 fix: avoid unnecessary whitespace at LCNF pretty printer 2022-11-07 16:18:36 -08:00
Leonardo de Moura
cf13b29760 fix: nasty bug due to #1804 2022-11-07 16:18:36 -08:00
Leonardo de Moura
c5584581ce fix: inferType for Code.jmp 2022-11-07 16:18:36 -08:00
Leonardo de Moura
0cfdf285e3 chore: remove unnecessary auxiliary declaration 2022-11-07 16:18:36 -08:00
Leonardo de Moura
46d83f2d80 fix: unnecessary paren at ppArg 2022-11-07 16:18:36 -08:00
Leonardo de Moura
3a818ed6ae fix: broken cache at toLCNF 2022-11-07 16:18:36 -08:00
Leonardo de Moura
390d4b28f2 chore: disable most LCNF passes to be able to use update-stage0
We cannot effectively test without an `update-stage0` since the LCNF
representation is different and incompatible with the one in the
.olean files.

One of the passes is not terminating (probably `simp`) when compiling
stage2.
2022-11-07 16:18:36 -08:00
Leonardo de Moura
623e8cddf6 fix: ReduceArity.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
2e8150e50d chore: port Check.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
ea8e7d5c99 chore: port ReduceArity.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
a71c438838 chore: port ToMono.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
9647f003c5 chore: port Specialize.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
beb923c79f chore: anyFVar and allFVar 2022-11-07 16:18:36 -08:00
Leonardo de Moura
eaade5abde chore: port LambdaLifting.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
0e85d9aa34 chore: re-activate Simp.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
1e3c7d2b4e fix: Simp/Main.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
db44a3a3f3 fix: JpCases.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
2328cf2fb4 feat: add ppLetExpr 2022-11-07 16:18:36 -08:00
Leonardo de Moura
b63eb886ce chore: incorrect annotation 2022-11-07 16:18:36 -08:00
Leonardo de Moura
a19e8fc526 chore: port Simp/Main.lean 2022-11-07 16:18:36 -08:00
Henrik Böving
c5a99bda2b chore: port join point optimizations to LetExpr 2022-11-07 16:18:36 -08:00
Henrik Böving
695f972ff2 chore: migrate Compiler Probing to LetExpr 2022-11-07 16:18:36 -08:00
Henrik Böving
963cd8d175 chore: port FloatLetIn to LetExpr 2022-11-07 16:18:36 -08:00
Henrik Böving
0defadfa98 chore: migrate compiler test framework to LetExpr 2022-11-07 16:18:36 -08:00
Leonardo de Moura
3a783010a0 chore: adjust some declarations at LCNF/Simp 2022-11-07 16:18:36 -08:00
Leonardo de Moura
fd316ef027 chore: port ConstantFold.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
0c58913cf1 chore: port SimpValue.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
ddeb63f69f chore: port Used.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
846a872293 chore: port InlineProj.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
d6fe779d7a chore: port JpCases.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
34d18a49aa chroe: port DiscrM 2022-11-07 16:18:36 -08:00
Leonardo de Moura
c8eab4478d chore: re-enable pullInstances and cse passes 2022-11-07 16:18:36 -08:00
Leonardo de Moura
691afbfdc8 fix: ToLCNF visitNoConfusion 2022-11-07 16:18:36 -08:00
Leonardo de Moura
67e2735f07 chore: display LCNF unreachable type when pp.all is true 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
01791b0c19 chore: port ToLCNF 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
d521197c24 chore: port FunDeclInfo.lean 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
f5d6b0ed94 chore: port FVarUtil.lean 2022-11-07 16:18:35 -08:00
Leonardo de Moura
8f40899cde feat: add Expr.updateFVar! 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
Mario Carneiro
22cdac914d fix: improved error span for inherit_doc (#1807) 2022-11-07 20:11:41 +00:00
github-actions[bot]
cf35416f5b doc: update changelog 2022-11-07 19:01:40 +00:00
Mario Carneiro
4fefb2097f feat: hover/go-to-def/refs for options 2022-11-07 20:01:13 +01:00
github-actions[bot]
3fdbfa2ed4 doc: update changelog 2022-11-07 18:11:29 +00:00
Mario Carneiro
32b6bd0d8b feat: empty type ascription syntax (e :) (part 2) 2022-11-07 19:10:56 +01:00
Mario Carneiro
2cd11d22af chore: update stage0 2022-11-07 19:10:56 +01:00
Mario Carneiro
02d8a5d56e feat: empty type ascription syntax (e :) 2022-11-07 19:10:56 +01:00
Alex J. Best
648ecff830 feat: reduce precedence of unary neg 2022-11-06 18:13:48 -08:00
Alex J Best
8da48f2381 chore: typo fix in error message of overlapping structure fields 2022-11-05 12:41:40 -07:00
Mario Carneiro
999b61007c feat: tweak behavior of congrN to match lean 3 (#1798) 2022-11-04 06:55:13 -07:00
Scott Morrison
d0dc9a2f90 fix: reorder goals after specialize (#1796)
* fix: reorder goals after specialize

* fix test
2022-11-03 06:32:55 -07:00
Sebastian Ullrich
5249611d75 doc: fix mkAntiquot docstring 2022-11-03 10:07:38 +01:00
Sebastian Ullrich
17d67bb24c chore: revert "fix: revert LLVM 15 bump on MacOS aarch64"
This reverts commit bf734715d3.
2022-11-02 17:39:01 +01:00
Mario Carneiro
9b40613207 fix: formatting for if let and do if 2022-11-01 20:19:39 -07:00
Mario Carneiro
ad1c23f172 fix: bug in replaceLocalDeclDefEq
fixes #1615
2022-11-01 19:18:25 -07:00
Henrik Böving
00e3004ce5 feat: jp ctx extender after lambda lifting 2022-10-30 06:42:24 -07:00
David Thrane Christiansen
8b9fe9b6c2 doc: fix typo in manual ToC (#1790)
There was a typographical error in the manual's table of contents (the section itself and the filename did not have the mistake).
2022-10-30 02:52:16 +02:00
Sebastian Ullrich
62ec0bfdb0 chore: CI: fix Update changelog action's commit message 2022-10-28 23:01:49 +02:00
github-actions[bot]
ac23228c6e update changelog 2022-10-28 19:26:19 +00:00
Sebastian Ullrich
a89b1b4b95 fix: use patternIgnore to ignore now-relevant tokens again 2022-10-28 21:25:47 +02:00
Sebastian Ullrich
65fc6db504 chore: update stage0 2022-10-28 21:25:47 +02:00
Sebastian Ullrich
7475fd9cbd feat: ignore patternIgnore nodes in syntax patterns 2022-10-28 21:25:47 +02:00
Sebastian Ullrich
9b05f57ec8 fix: wrap &"..." <|> ... as well 2022-10-28 21:25:47 +02:00
Sebastian Ullrich
731e28df00 fix: syntax match should not ignore tokens in <|> 2022-10-28 21:25:47 +02:00
Sebastian Ullrich
b8ebfbfecc chore: improve pretty printer antiquotation support 2022-10-28 21:25:47 +02:00
Leonardo de Moura
5f38a483f2 fix: congr tactic
`MVarId.congr?` and `MVarId.hcongr?` should return `none` if an
exception is thrown while applying congruence theorem.

`MVarId.hcongr?` should try `eq_of_heq` before trying to apply
`hcongr` theorem.

closes #1787

BTW: Lean 4 `congr` tactic is applying `assumption`. Lean 3 version does not.
2022-10-28 08:00:04 -07:00
Leonardo de Moura
279c34ff46 feat: add MVarId.eqOfHEq tactic 2022-10-28 07:52:45 -07:00
Leonardo de Moura
f75d59047f feat: add commitWhenSomeNoEx?
TODO: better name?

This commit also removes the `[specialize]` annotations.
2022-10-28 07:51:41 -07:00
Leonardo de Moura
60802d83af chore: update stage0 2022-10-27 18:58:02 -07:00
Leonardo de Moura
31d2c8fb66 chore: fix test 2022-10-27 18:57:25 -07:00
Leonardo de Moura
25beba6624 feat: avoid modulo in HashMap and HashSet
closes #609

Context: trying to improve Lean startup time.

Remark: it didn't seem to make a difference in practice. We should
investigate more.

cc @kha @gebener
2022-10-27 18:54:56 -07:00
Leonardo de Moura
dd45391568 chore: hoist out error generation code
Motivation: it was affecting my performance tests
2022-10-27 18:26:38 -07:00
Leonardo de Moura
b8f4a345f1 feat: add Power2 2022-10-27 18:11:20 -07:00
Leonardo de Moura
dc750d143e chore: remove test/optimization that is essentially dead code 2022-10-27 16:45:50 -07:00
Gabriel Ebner
c16d7728b0 feat: improve import duplicate definition error 2022-10-27 16:42:09 -07:00
Mario Carneiro
29bda62198 fix: missed a file from #1771 2022-10-27 11:14:13 -07:00
Leonardo de Moura
d9243e07f9 chore: update stage0 2022-10-27 09:55:09 -07:00
Leonardo de Moura
99ea171e48 chore: zero startup time specExtension 2022-10-27 09:54:04 -07:00
Leonardo de Moura
346c18a5b5 perf: improve namespacesExt import function 2022-10-27 08:59:24 -07:00
Leonardo de Moura
181a065d1b chore: update stage0 2022-10-27 08:32:37 -07:00
Leonardo de Moura
635ccef5a3 perf: improve setImportedEntries
Remove linear scan at `getEntriesFor`.
2022-10-27 08:29:18 -07:00
Leonardo de Moura
44e889bd52 chore: avoid runtime bounds check 2022-10-27 07:48:30 -07:00
Leonardo de Moura
33045433d2 chore: update stage0 2022-10-27 07:35:47 -07:00
Leonardo de Moura
0a35ce7e3e perf: add ModuleData.constNames 2022-10-27 07:34:07 -07:00
Leonardo de Moura
95689d914f perf: use NameHashSet instead of NameSet 2022-10-27 07:10:54 -07:00
Leonardo de Moura
2c4056c104 chore: use exit during finalization
Motivation: Lean startup time profiling.
2022-10-27 06:51:29 -07:00
Leonardo de Moura
23ba495205 perf: better initial const2ModIdx size 2022-10-26 22:22:41 -07:00
Leonardo de Moura
bac4774b75 chore: update stage0 2022-10-26 21:56:23 -07:00
Leonardo de Moura
39249f0c1d perf: zero startup time function summaries 2022-10-26 21:55:37 -07:00
Leonardo de Moura
ad98df80fe feat: congr theorems using Iff
closes #1763
2022-10-26 18:00:24 -07:00
Leonardo de Moura
5e25d9148a feat: improve apply error message when root term elaboration is postponed
fixes #1719
2022-10-26 17:15:24 -07:00
Leonardo de Moura
0b6b754bca feat: improve apply tactic
It tries to address what the Mathlib community calls the "apply bug".

cc @digama0
2022-10-26 16:58:43 -07:00
Leonardo de Moura
f3b1eadb55 feat: copy docstring when copying parent fields
closes #1730
2022-10-26 15:43:46 -07:00
Leonardo de Moura
83d8e36773 fix: fixes #1780 2022-10-26 07:46:38 -07:00
Leonardo de Moura
5a8f9ace72 fix: open .. hinding .. should activate scoped attributes 2022-10-26 07:39:06 -07:00
Leonardo de Moura
e369c3beb6 fix: disallow . immediately after ..
Rejects the following weird example
```
```
which was being parsed as
```
```
2022-10-26 07:13:40 -07:00
Leonardo de Moura
d7e732e886 feat: use unop% to implement unary minus notation
closes #1779
2022-10-26 06:55:24 -07:00
Leonardo de Moura
6211de92f0 chore: update stage0 2022-10-26 06:52:21 -07:00
Leonardo de Moura
1216f5e658 feat: support for unop% at CollectPatternVars 2022-10-26 06:51:14 -07:00
Leonardo de Moura
39808d4eef chore: update stage0 2022-10-26 06:45:33 -07:00
Leonardo de Moura
e6caee97ec feat: unop% elaborator
We now have support for unary operators at `Op.toTree` and `Op.toExpr`

see #1779
2022-10-26 06:44:44 -07:00
Leonardo de Moura
0818cdc411 chore: update stage0 2022-10-26 06:28:50 -07:00
Leonardo de Moura
00ca0dde5c feat: add unop% term parser
We not to support unary minus at `BinOp.toTree`

see #1779
2022-10-26 06:19:22 -07:00
Mario Carneiro
a086d217a5 fix: bug in level normalization (soundness bug) 2022-10-26 05:22:26 -07:00
tydeu
17a4bcb3e1 Merge remote-tracking branch 'gebner/minmax' 2022-10-25 20:58:41 -04:00
Mario Carneiro
bf734715d3 fix: revert LLVM 15 bump on MacOS aarch64 2022-10-26 00:51:20 +02:00
Gabriel Ebner
56d0fbd537 chore: bump Lean version 2022-10-25 15:20:38 -07:00
Sebastian Ullrich
1893857f15 fix: expandCDot? should create canonical syntax 2022-10-25 12:23:13 +02:00
Sebastian Ullrich
f39281f6b4 fix: hoverableInfoAt? in presence of canonical syntax 2022-10-25 12:23:13 +02:00
Sebastian Ullrich
36fbf53a79 chore: improve trace.Elab.info formatting 2022-10-25 12:23:13 +02:00
Leonardo de Moura
e55badef05 feat: List.mapMono 2022-10-24 19:50:09 -07:00
Leonardo de Moura
2cd21e08ba chore: add CollectLevelParams.visitLevels 2022-10-24 19:50:09 -07:00
Leonardo de Moura
81f8ab8fbb refactor: Level.instantiateParams => Level.substParams, add Level.instantiateParams
Motivation: make sure `Level.instantiateParams` and
`Expr.instantiateLevelParams` have similar types.
2022-10-24 19:49:57 -07:00
Mario Carneiro
d7d61bfb55 feat: use withoutPosition consistently (part 2) 2022-10-24 12:51:32 -07:00
Mario Carneiro
8b8fc64fa0 chore: update stage0 2022-10-24 12:51:32 -07:00
Mario Carneiro
765ebcdbf0 feat: use withoutPosition consistently 2022-10-24 12:51:32 -07:00
Gabriel Ebner
4ff6798284 perf: use instantiation cache 2022-10-24 12:23:13 -07:00
Gabriel Ebner
fa9538ffa6 perf: use old instantiateLevelParams in compiler 2022-10-24 12:23:13 -07:00
Gabriel Ebner
d87c36157a perf: speed up Expr.replace 2022-10-24 12:23:13 -07:00
Gabriel Ebner
dcc97c9bbe fix: preserve sharing in instantiateLevelParams 2022-10-24 12:23:13 -07:00
Gabriel Ebner
725aa8b39a refactor: instantiateTypeLevelParams in Lean 2022-10-24 12:23:13 -07:00
Mario Carneiro
e7c7678ab0 refactor: line wrapping in parser code 2022-10-24 08:37:29 -07:00
David Renshaw
e4ab10dc30 doc: fix some typos
assinged -> assigned
collction -> collection
2022-10-24 16:01:39 +02:00
mcdoll
6cf9a63193 doc: fix typo (#1775)
equaal -> equal
2022-10-24 15:05:51 +02:00
Sebastian Ullrich
3a12c99666 chore: register Elab.app trace classes 2022-10-24 13:16:36 +02:00
Yuri de Wit
c98b3a5388 fix: add local Hashable instance (fixes #1737)
When inductives are indirectly mutually recursive, say `inductive T | t
(args: List T)` instead of `inductive T | t (arg : T)`, Lean would fail
to find an instance of Hashable for `T` because it was not yet defined.

This commit makes sure that the deriving handler adds a needed Hashable T
instance to the local scope so that Hashable.hash can be resolved
recursively.
2022-10-23 21:26:04 +02:00
joao guilherme
e796943414 doc: fix typo (#1769) 2022-10-23 21:23:57 +02:00
github-actions[bot]
24d91094f3 update changelog 2022-10-23 19:12:23 +00:00
Mario Carneiro
c4cbefce11 feat: add linter.deprecated option to silence deprecation warnings 2022-10-23 21:11:57 +02:00
Sebastian Ullrich
89fd86cb3c chore: Nix: update lean4-mode 2022-10-23 17:59:32 +02:00
Mario Carneiro
b3ba78aade feat: hovers & name resolution in registerCombinatorAttribute (part 2) 2022-10-23 09:30:38 +02:00
Mario Carneiro
e412edc0f6 chore: update stage0 2022-10-23 09:30:38 +02:00
Mario Carneiro
f168af76a7 feat: hovers & name resolution in registerCombinatorAttribute 2022-10-23 09:30:38 +02:00
David Renshaw
16320a297f doc: fix some typos
Leah -> Lean
giveName -> givenName
2022-10-22 21:16:35 +02:00
Henrik Böving
1e00eff3e7 fix: jp context extender missed out on some variables 2022-10-21 17:58:47 -07:00
Henrik Böving
dac6127810 feat: Compiler pass for reducing common jp args 2022-10-21 17:35:40 -07:00
Henrik Böving
a608532fd4 chore: Improve LCNF check goto error message 2022-10-21 17:35:40 -07:00
Gabriel Ebner
fc304d95c0 feat: Min/Max typeclasses 2022-10-21 14:36:38 -07:00
Gabriel Ebner
783a61ab76 chore: Min/Max typeclasses 2022-10-21 11:23:29 -07:00
Gabriel Ebner
041307fd4b fix: build 2022-10-20 12:42:32 -07:00
E.W.Ayers
112cb5e261 test: fix test output 2022-10-20 11:20:42 -07:00
E.W.Ayers
46112a5f2a fix: review 2022-10-20 11:20:42 -07:00
E.W.Ayers
c9a26596dc refactor: switch resolve to double eval strategy
Using option (2) from this comment:
https://github.com/leanprover/lean4/pull/1661#pullrequestreview-1135363727
2022-10-20 11:20:42 -07:00
E.W.Ayers
691835037e feat: code action resolvers 2022-10-20 11:20:42 -07:00
E.W.Ayers
297d06fc0c fix: issue where code action was not running 2022-10-20 11:20:42 -07:00
E.W.Ayers
c795e2b073 fix: rm CodeActionData 2022-10-20 11:20:42 -07:00
Ed Ayers
7f47a34656 style: apply suggestions from code review
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2022-10-20 11:20:42 -07:00
E.W.Ayers
260e42b0a7 doc: fix docs from review 2022-10-20 11:20:42 -07:00
E.W.Ayers
8085ce88e9 feat: CodeActionProvider
This is a low-level system for registering LSP code actions.
Developers can register their own code actions.
In future commits I am going to add features on top of this.
2022-10-20 11:20:42 -07:00
tydeu
3ad183e502 Merge branch 'snake' 2022-10-20 12:27:16 -04:00
tydeu
25fe4a6f4d chore: update Lean version + attr fixes 2022-10-20 12:20:57 -04:00
Leonardo de Moura
aeddcbdc6d fix: disable implicit lambdas at intro <pattern> notation
See issue reported at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/intro.20with.20type.20specified/near/305150215
2022-10-20 09:04:06 -07:00
Leonardo de Moura
dddf9e8a3f chore: remove leftover comment 2022-10-20 08:35:47 -07:00
Mario Carneiro
dd8bbe9367 fix: catch kernel exceptions in Kernel.{isDefEq, whnf}
fixes #1756
2022-10-20 05:38:29 -07:00
awson
d5063c8fa7 fix: environment leak on Windows 2022-10-19 19:34:43 -07:00
Gabriel Ebner
c02955141b chore: update stage0 2022-10-19 11:17:34 -07:00
Gabriel Ebner
c672046767 chore: update LeanInk 2022-10-19 09:28:08 -07:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
Mario Carneiro
e86b8c65a8 chore: update stage0 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
Patrick Massot
e80cb2eb51 doc: Option is a monad again
Maybe it would also be nice to add an explanation (or a link to an explanation) about why `List` is no longer a monad.
2022-10-19 08:44:53 -07:00
Sebastian Ullrich
9fd433785b chore: register pretty printer trace classes 2022-10-19 14:51:07 +02:00
Sebastian Ullrich
18d9720975 chore: CI: fix Update changelog action 2022-10-19 10:01:14 +02:00
Mario Carneiro
39feeaab74 chore: snake-case attributes 2022-10-18 21:34:51 -04:00
Gabriel Ebner
0c2a5580cb feat: enforce correct syntax kind in macros 2022-10-18 14:59:14 -07:00
Gabriel Ebner
fb4d90a58b feat: dynamic quotations for categories 2022-10-18 14:59:14 -07:00
Gabriel Ebner
96acc7269d fix: use typed syntax 2022-10-18 10:53:48 -07:00
Leonardo de Moura
0e7afae1da chore: update stage0
Make sure we can use recent improvements for developing Lean itself.
2022-10-18 10:41:24 -07:00
Leonardo de Moura
084a173a47 feat: disable info tree while creating WF auxiliary definitions 2022-10-18 07:44:39 -07:00
Leonardo de Moura
1d6d61af89 feat: disable info tree while creating _unsafe_rec 2022-10-18 07:05:19 -07:00
Leonardo de Moura
4d51cdd1b7 feat: disable info tree while creating sunfold definitions
see #1750
2022-10-18 06:57:46 -07:00
Mario Carneiro
faa612e7b7 chore: remove #resolve_name 2022-10-17 14:53:51 -07:00
Mario Carneiro
8fc6a2a856 fix: dbg_trace tactic 2022-10-17 14:48:23 -07:00
Gabriel Ebner
7da0dd2fcf fix: remove ` (funBinder|`` 2022-10-17 14:07:16 -07:00
Sebastian Ullrich
ce673e3bb8 chore: add Update changelog action 2022-10-17 18:31:20 +02:00
Sebastian Ullrich
4a99df2d8c chore: CI: exclude "full program" tests from debug/sanitized builds (#1732) 2022-10-17 10:36:01 +02:00
Leonardo de Moura
7b49156270 chore: update stage0 2022-10-16 16:22:05 -07:00
Leonardo de Moura
641fa77738 chore: minimize the number of red-black insert specializations 2022-10-16 16:20:46 -07:00
Leonardo de Moura
ec59bbe15c chore: ensure LCNF pretty printer result supports Format.group 2022-10-16 16:06:08 -07:00
Leonardo de Moura
72c576f62a feat: complete reduceArity pass 2022-10-16 16:00:33 -07:00
Leonardo de Moura
1a02c326e5 chore: fix test 2022-10-16 14:54:07 -07:00
Leonardo de Moura
774a555d3e chore: update stage0 2022-10-16 14:49:55 -07:00
Leonardo de Moura
9244a7a8a5 fix: ensure old and new compiler auxiliary declaration names do not collide 2022-10-16 14:49:55 -07:00
Leonardo de Moura
ab262abdaa chore: update stage0 2022-10-16 14:49:55 -07:00
Leonardo de Moura
40f2247c61 perf: zero cost IR extension startup cost 2022-10-16 14:49:50 -07:00
Leonardo de Moura
defd544d5d feat: add collectUsedParams 2022-10-16 14:20:32 -07:00
Leonardo de Moura
79ed382492 chore: fix test 2022-10-16 09:00:25 -07:00
Leonardo de Moura
4eaf22118a feat: add cse pass at mono phase 2022-10-16 08:58:06 -07:00
Leonardo de Moura
fd46ef01e8 chore: add another floatLetIn pass
See `elabAppFn` for a function that benefits from this extra pass.
2022-10-16 08:51:13 -07:00
Leonardo de Moura
ae627e9a58 chore: remove leftover from old frontend 2022-10-16 08:41:03 -07:00
Leonardo de Moura
c20febff31 feat: add helper Syntax.node* functions 2022-10-16 08:40:01 -07:00
Leonardo de Moura
729fd63b29 fix: incorrect initial array size 2022-10-16 07:48:30 -07:00
Leonardo de Moura
bebce084fa fix: bug at toLCNF.visitMData 2022-10-16 07:38:40 -07:00
Leonardo de Moura
8a81dfb876 feat: add Probe.sortedBySize, Probe.tail, and Probe.head 2022-10-15 20:12:53 -07:00
Leonardo de Moura
4b018cdc72 chore: missing annotations 2022-10-15 19:51:56 -07:00
Leonardo de Moura
9a41680ec9 feat: add Probe.getJps 2022-10-15 19:28:59 -07:00
Leonardo de Moura
dac4e6f214 fix: probing functions were not visiting FunDecl.value 2022-10-15 17:50:18 -07:00
Leonardo de Moura
f9acb7fc9f chore: update stage0 2022-10-15 15:48:09 -07:00
Leonardo de Moura
b4d850502d fix: avoid join point that takes closure at seqToCode 2022-10-15 15:48:02 -07:00
Leonardo de Moura
61813d60c6 test: for join point taking closure as parameter 2022-10-15 12:05:53 -07:00
Leonardo de Moura
3df13bb7b4 chore: update stage0 2022-10-15 11:59:28 -07:00
Leonardo de Moura
4d9483d1fa fix: if inlined code returns a function and has more than one exit point, create an auxiliary function instead of a join point that takes a closure as argument 2022-10-15 11:56:52 -07:00
Leonardo de Moura
53b995386d fix: avoid [anonymous] at LCNF binder names 2022-10-15 11:56:52 -07:00
Henrik Böving
741fac924a chore: inline control primitives 2022-10-15 10:48:47 -07:00
Leonardo de Moura
34e5ac3013 chore: update stage0 2022-10-15 08:55:15 -07:00
Leonardo de Moura
376c541e9a feat: do not generate code for declarations that will be specialized 2022-10-15 08:54:46 -07:00
Leonardo de Moura
359dc77664 refactor: move isTemplateLike to LCNF/Basic.lean 2022-10-15 08:51:20 -07:00
Leonardo de Moura
3505b60a22 feat: probing helper functions 2022-10-15 08:51:20 -07:00
Siddharth
48b6fee467 chore: remove stray STATIC in src/shell (#1736) 2022-10-15 14:27:13 +02:00
Leonardo de Moura
1eda0fd734 chore: missing annotation 2022-10-14 20:38:06 -07:00
Leonardo de Moura
6378283fa8 feat: add Probe.toString 2022-10-14 19:21:56 -07:00
Henrik Böving
38788a72be feat: basic compiler probing framework with examples 2022-10-14 19:09:35 -07:00
Gabriel Ebner
05694a11f3 chore: update stage0 2022-10-14 13:39:26 -07:00
Sebastian Ullrich
1ddfb72106 chore: Nix: handle huge packages 2022-10-14 22:21:08 +02:00
Sebastian Ullrich
616d562d73 feat: lean --deps-json --stdin 2022-10-14 22:20:44 +02:00
Gabriel Ebner
045a71ab33 hack: ignore maxCoeSize for monad coercions 2022-10-14 12:08:10 -07:00
Gabriel Ebner
1c561c39a8 feat: function coercions with unification 2022-10-14 12:08:10 -07:00
Mario Carneiro
019f1a173a feat: also unexpand Array.empty 2022-10-14 08:51:45 -07:00
Mario Carneiro
0acdaddcf2 feat: unexpander for mkArray0 2022-10-14 08:51:45 -07:00
Leonardo de Moura
dab88ae943 chore: update stage0 2022-10-14 08:45:30 -07:00
Leonardo de Moura
3f076fc836 perf: missing annotations and helper instances 2022-10-14 08:42:50 -07:00
Leonardo de Moura
0a126b7702 perf: better support for "inlineable" instances 2022-10-14 08:42:50 -07:00
Leonardo de Moura
1bb67918f8 chore: cleanup eagerLambdaLifting and add notes 2022-10-14 08:42:50 -07:00
Siddharth
e3f064ef87 Bump up to LLVM 15 (#1691) 2022-10-14 14:43:13 +00:00
Sebastian Ullrich
bc1a2dcaf2 chore: update RELEASES.md 2022-10-14 16:18:27 +02:00
Rishikesh Vaishnav
76c4693c95 fix: improve fuzzy-matching heuristics (#1710) 2022-10-14 16:17:14 +02:00
Sebastian Ullrich
f7651de424 chore: CI: avoid skipped dependencies hellhole 2022-10-14 13:28:17 +02:00
Sebastian Ullrich
cf24f559b6 chore: CI: make jobs actually cancellable 2022-10-14 13:28:17 +02:00
Mario Carneiro
4c1ed9e2bc fix: hovers in appUnexpander attr 2022-10-14 10:06:12 +02:00
Leonardo de Moura
31f2acd97a chore: cleanup trace messages 2022-10-13 18:56:17 -07:00
Leonardo de Moura
19301c09c6 chore: remove unnecessary match 2022-10-13 18:56:17 -07:00
Mario Carneiro
857e452281 feat: optional doc comment for register_simp_attr 2022-10-13 18:52:56 -07:00
Leonardo de Moura
6ed89a4ceb chore: revert cross module lambda lifting cache
It adds almost 50Mb to the .olean files.
2022-10-13 18:42:52 -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
828aea48f4 chore: CI: cancel outdated workflows 2022-10-13 21:45:46 +02:00
Sebastian Ullrich
6b8fa76265 test: benchmark workspace symbols search 2022-10-13 21:41:58 +02:00
Leonardo de Moura
ac9d65b17b feat: cache lambda lifting 2022-10-13 11:24:14 -07:00
Sebastian Ullrich
50a0c9bda7 chore: Nix: remove dead ileans 2022-10-13 18:12:55 +02:00
Leonardo de Moura
66c593a322 chore: update stage0 2022-10-13 08:22:11 -07:00
Leonardo de Moura
518123b191 feat: more conservative SpecParamInfo inference 2022-10-13 08:20:55 -07:00
Leonardo de Moura
407c744ae5 chore: add workarounds for old code generator
It is a bit ironic that the new code generator should contain
workarounds for the old one.
2022-10-13 07:09:19 -07:00
Sebastian Ullrich
02560aab73 chore: nicer pp.raw.showInfo output 2022-10-13 15:50:22 +02:00
Leonardo de Moura
dfd95c712e chore: fix tests 2022-10-13 06:16:56 -07:00
Leonardo de Moura
886ed9b2e3 fix: remove function expected error at LCNF 2022-10-13 06:16:25 -07:00
Leonardo de Moura
c33b5b6588 chore: remove unnecessary eqvTypes 2022-10-13 06:08:51 -07:00
Leonardo de Moura
aae12d5ee2 chore: update stage0 2022-10-13 06:03:15 -07:00
Leonardo de Moura
bc2b891e7e refactor: remove type compatibility sanity checks at LCNF Check.lean
See new note at `Check.lean` for details.
2022-10-13 06:01:41 -07:00
Leonardo de Moura
4ac802dd9a chore: fix test 2022-10-13 04:31:46 -07:00
Leonardo de Moura
637a3e6331 chore: update stage0 2022-10-13 04:27:12 -07:00
Leonardo de Moura
1f54c0126c doc: add note at Decl.simp 2022-10-13 04:26:05 -07:00
Leonardo de Moura
2563fda777 feat: enable eager lambda lifting 2022-10-13 04:22:19 -07:00
Leonardo de Moura
0966f14233 fix: local function declarations size may be 0 2022-10-13 03:34:14 -07:00
Leonardo de Moura
2675c0647b feat: detect unreachable cases alternatives at LCNF simp 2022-10-13 02:49:55 -07:00
Leonardo de Moura
8039c15351 chore: update stage0 2022-10-13 02:09:14 -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
Sebastian Ullrich
e7b90b489a fix: stabilize unused variables linter output 2022-10-13 10:46:53 +02:00
Leonardo de Moura
870de844dc chore: annotate relevant monadic code with [alwaysInline]
TODO: after we delete old code generator, we should replace
`@[alwaysInline, inline]` with `@[alwaysInline]`.

Remainder: we want the old code generator to ignore `@[alwaysInline]`
annotations, in particular, the new ones on `instance` commands that
are actually annotations for the instance methods.
2022-10-12 19:48:02 -07:00
Gabriel Ebner
38d3e37c75 perf: improve Unhygienic.run code 2022-10-12 19:36:05 -07:00
Leonardo de Moura
3d2ba4f3d0 chore: update stage0 2022-10-12 17:11:53 -07:00
Leonardo de Moura
b9f174604d feat: check new alwaysInline attribute 2022-10-12 16:55:16 -07:00
Leonardo de Moura
49a6f8c105 chore: add horrible hack for Decidable in the new code generator
cc @gebner
2022-10-12 16:53:29 -07:00
Leonardo de Moura
7308fa0e7d feat: ensure lambda lifter is creating unused names 2022-10-12 16:35:55 -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
5606b4e59e feat: add [alwaysInline] attribute
We are planning to ignore the `[inline]` attribute when the "inlining
quota" has been exhausted in the new code generator.
2022-10-12 16:08:37 -07:00
Chris Lovett
a6b847430d fix: highlight of deriving instance (#1717) 2022-10-12 14:24:16 -07:00
Gabriel Ebner
fb6cb05465 feat: support let_fun in new compiler 2022-10-12 11:52:28 -07:00
Gabriel Ebner
79569c9003 chore: replace let by have in stx matches 2022-10-12 11:52:28 -07:00
Sebastian Ullrich
18a4b277fc test: more fair qsort.ml benchmark 2022-10-12 20:22:55 +02:00
Mario Carneiro
c06cffa54f refactor: rename isExitCommand -> isTerminalCommand 2022-10-12 11:11:31 -07:00
Mario Carneiro
8dfae9eb38 feat: import command stub 2022-10-12 11:11:31 -07:00
Leonardo de Moura
aa845dee98 feat: cache lambda lifted functions 2022-10-11 21:28:03 -07:00
Leonardo de Moura
767bda2c28 chore: preparing to change the semantics of @[inline] instance
In the new code generator, we are going to lambda lift the instance
methods before saving the code at the end of the base phase. The goal is to make instance
ligth weight and cheap to inline. The anotation `@[inline]` is going
to be an annotation for the lambda lifted methods.
2022-10-11 20:35:56 -07:00
Gabriel Ebner
1de142a20b chore: update release notes 2022-10-11 17:24:35 -07:00
Gabriel Ebner
f58b26b4b0 chore: update LeanInk 2022-10-11 17:24:35 -07:00
Gabriel Ebner
15d7744cca chore: fix tests 2022-10-11 17:24:35 -07:00
Gabriel Ebner
c8bb2ea3cf chore: post-bootstrap cleanup 2022-10-11 17:24:35 -07:00
Gabriel Ebner
2649b4facd chore: update stage0 2022-10-11 17:24:35 -07:00
Gabriel Ebner
6593bd98b3 chore: add test for 1692 2022-10-11 17:24:35 -07:00
Gabriel Ebner
ba57ad3480 feat: add implementation-detail hypotheses 2022-10-11 17:24:35 -07:00
Gabriel Ebner
45c4f2faa0 refactor: remove _aux_discr 2022-10-11 17:24:35 -07:00
Gabriel Ebner
0d3d05bd3a feat: clear% 2022-10-11 17:24:35 -07:00
Mario Carneiro
f4b04216eb feat: go to duplicate definition 2022-10-11 10:07:49 +02:00
Chris Lovett
664e62e8c5 doc: add question mark to LEAN_IDENT_RE (#1713) 2022-10-11 10:04:56 +02:00
Leonardo de Moura
02a3dcb1dd feat: hash for LCNF.Code 2022-10-10 20:34:12 -07:00
Leonardo de Moura
525b4f761c chore: fix tests 2022-10-10 17:48:32 -07:00
Leonardo de Moura
1b4cfbe94b chore: update stage0 2022-10-10 17:23:01 -07:00
Leonardo de Moura
3f24ce71ab feat: add another floatLetIn pass at mono phase 2022-10-10 17:19:40 -07:00
Leonardo de Moura
a153519992 chore: update stage0 2022-10-10 17:09:23 -07:00
Gabriel Ebner
1742c79afe chore: remove auxDecl binder info 2022-10-10 16:30:16 -07:00
Henrik Böving
dd3c0f77f1 feat: FloatLetIn compiler pass 2022-10-10 23:56:20 +02:00
Henrik Böving
d132551829 feat: extend FVarUtil framework 2022-10-10 23:32:36 +02:00
Henrik Böving
e15e6bfaee chore: address PR comments 2022-10-10 23:32:36 +02:00
Leonardo de Moura
7b3709e28a chore: simplify proof in test for #1711
TODO: improve support for instance implicit arguments at `congr`
2022-10-10 07:29:53 -07:00
Leonardo de Moura
0041de5d1d fix: congr tactic should not try to synthesize instance implicit arguments that have been inferred when applying congr theorem
see #1711
2022-10-10 07:24:27 -07:00
Leonardo de Moura
fb4200e633 chore: fix tests 2022-10-09 21:51:51 -07:00
Leonardo de Moura
b20e208867 chore: pretty print LCNF cases result type 2022-10-09 20:13:17 -07:00
Leonardo de Moura
3313500056 chore: update stage0 2022-10-09 18:38:57 -07:00
Leonardo de Moura
6f023a44ad fix: let _x.i := _x.j simplification at LCNF simp 2022-10-09 18:38:28 -07:00
Leonardo de Moura
72d3840f0c feat: add simpCast? 2022-10-09 18:29:12 -07:00
Leonardo de Moura
6c5475725e feat: (lcCast _ _ g) a_1 ... a_n => g a_1 ... a_n if type correct 2022-10-09 17:45:15 -07:00
Leonardo de Moura
30bd019a7f chore: simplify SimpValue.lean 2022-10-09 17:35:13 -07:00
Leonardo de Moura
e4b97e1698 chore: update stage0 2022-10-09 16:48:20 -07:00
Leonardo de Moura
54944819a0 feat: add simpCastCast? 2022-10-09 16:43:33 -07:00
Leonardo de Moura
cd303cd8e5 fix: do not apply simpAppApp? over cast 2022-10-09 16:43:10 -07:00
Leonardo de Moura
cf313d2101 chore: improve eqvTypes 2022-10-09 16:42:55 -07:00
Leonardo de Moura
43fe67c41a chore: helper pass for debugging purposes 2022-10-09 16:41:54 -07:00
Leonardo de Moura
b87838115f chore: update stage0 2022-10-09 15:35:54 -07:00
Leonardo de Moura
9feb4d8ab7 fix: do not generate code for [extern] functions 2022-10-09 15:35:29 -07:00
Leonardo de Moura
2e09ac16b1 chore: update stage0 2022-10-09 13:01:42 -07:00
Leonardo de Moura
11fcdb7bf4 feat: add cast at exit points if necessary when inlining code 2022-10-09 13:01:10 -07:00
Leonardo de Moura
ef2d17120c chore: fix note 2022-10-09 12:25:45 -07:00
Leonardo de Moura
2d3c17cd53 chore: update stage0 2022-10-09 12:12:40 -07:00
Leonardo de Moura
cc09afc5e1 fix: type error introducing when inlining LCNF functions
This issue has been reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Annoying.20LCNF.20errors/near/303142516
2022-10-09 12:10:11 -07:00
Leonardo de Moura
f61ec4929f chore: add low-level normExprCore 2022-10-09 12:10:11 -07:00
Leonardo de Moura
263be54dcf chore: fix tests 2022-10-09 12:10:11 -07:00
Leonardo de Moura
e81673366a chore: remove leftover 2022-10-09 12:10:11 -07:00
Leonardo de Moura
613c8027d7 fix: missing instantiateParamsLevelParams 2022-10-09 12:10:11 -07:00
Leonardo de Moura
827ef94486 feat: add eqvTypes 2022-10-09 12:10:11 -07:00
Leonardo de Moura
c14d07fe2e feat: include def/fun/jp resulting type in the LCNF pretty printer 2022-10-09 12:10:11 -07:00
Leonardo de Moura
eeb98d9cf4 refactor: rename FixedArgs => FixedParams 2022-10-09 12:10:11 -07:00
Leonardo de Moura
37a61568bc feat: improve fixed parameter analyzer 2022-10-09 12:10:11 -07:00
Mario Carneiro
d4219c9d70 fix: List.Mem should have two parameters 2022-10-09 05:46:52 -07:00
Leonardo de Moura
5ef9a2ac7d chore: update stage0 2022-10-08 19:53:58 -07:00
Leonardo de Moura
8e6cb25cbf chore: temporarily disable eager lambda lifting
We need a better heuristic for deciding which functions in instances
should be eagerly lambda lifted. Otherwise, it will have to keep
chasing which instances we have to annotate with `[inline]`.
2022-10-08 19:51:19 -07:00
Leonardo de Moura
1148392f45 fix: Closure.lean 2022-10-08 19:51:19 -07:00
Leonardo de Moura
2efb1dbdf1 doc: lambda lifting 2022-10-08 19:51:19 -07:00
Leonardo de Moura
b7d4fd03a3 feat: eager lambda lifting 2022-10-08 19:51:19 -07:00
Leonardo de Moura
878e72b2f9 feat: lambda lifting 2022-10-08 19:51:19 -07:00
Leonardo de Moura
3c90b2fd3e feat: add Decl.save 2022-10-08 19:51:19 -07:00
Sebastian Ullrich
48d3bbdde9 fix: explicit drive letter normalization in FilePath <-> URI conversions 2022-10-08 10:12:11 -07:00
Sebastian Ullrich
8d34cc15cf fix: path normalization should not case-normalize entire path 2022-10-08 10:12:11 -07:00
Leonardo de Moura
56002e1b33 fix: fixes #1707 2022-10-08 07:58:56 -07:00
Leonardo de Moura
7874c03c27 chore: style 2022-10-08 07:49:27 -07:00
Leonardo de Moura
6bc4144409 fix: fixes #1549 2022-10-08 07:41:49 -07:00
Leonardo de Moura
e3ec468e3b fix: fixes #1650 2022-10-07 19:00:23 -07:00
Leonardo de Moura
cf2ea445fe fix: fixes #1681 2022-10-07 18:36:25 -07:00
Leonardo de Moura
79683c4bf6 chore: missing imports 2022-10-07 18:11:19 -07:00
Chris Lovett
3eeb064d83 fix: Clear Diagnostics when file is closed (#1591) 2022-10-07 17:28:15 -07:00
Leonardo de Moura
45974229d2 feat: reactivate extendJoinPointContext at mono phase
closes #1686

cc @hargoniX
2022-10-07 16:27:44 -07:00
Leonardo de Moura
15ad5254a1 chore: update stage0 2022-10-07 16:08:14 -07:00
Leonardo de Moura
9eb641e7da feat: reuse specialized functions between different compilation units 2022-10-07 16:07:17 -07:00
Leonardo de Moura
f11e44910b refactor: add Closure.lean
This module will also be used by the lambda lifter.
2022-10-07 15:56:10 -07:00
Leonardo de Moura
e7a36f32f1 refactor: add MonadScope class
We are going to use it to implement the lambda lifting pass too.
2022-10-07 14:59:59 -07:00
Leonardo de Moura
1b8e310ada fix: fixes #1674 2022-10-07 13:33:41 -07:00
Leonardo de Moura
5c74bc1324 fix: fixes #1705 2022-10-07 13:11:26 -07:00
David Renshaw
5c7cf76575 doc: fix link to initialization section in ffi section
The current link goes to doc/dev#init, where there is nothing
about initialization. This PR fixes the link so that it points
to the initialization section lower down on the ffi page.
2022-10-07 19:11:59 +02:00
David Renshaw
4fa1a496b3 doc: Lean USize maps to C++ size_t, not usize_t
usize_t is not a standard C++ type.

See src/include/lean/lean.h for translations between USize and size_t.
2022-10-07 17:51:58 +02:00
E.W.Ayers
d22916fdcd feat: improve expression diff
Added recursion cases to the diff algorithm for projections and mdata.
Previously, these would be rendered as the entire expression being different but we can do better
by checking if the recursion args are the same.

With mdata, these are entirely ignored by the diff algorithm.
2022-10-07 12:45:00 +02:00
Leonardo de Moura
5b1aac7b8f fix: avoid nontermination on non-utf8 input
This is not a perfect solution, but ensures the non-termination does
not happen. The changes also make it easier to prove termination in
the future.

TODO: validate UTF8 input?

closes #1690
2022-10-06 17:45:21 -07:00
Sebastian Ullrich
d417c0238a doc: normalize Init.Conv docs 2022-10-06 17:27:33 -07:00
Sebastian Ullrich
5b7e6661f9 chore: more RBMap cleanup 2022-10-06 17:26:43 -07:00
Sebastian Ullrich
6f4cea6dba feat: add rbmap_fbip benchmark 2022-10-06 17:26:43 -07:00
Leonardo de Moura
7dfc51ce7c chore: update stage0 2022-10-06 17:22:08 -07:00
Mario Carneiro
391aef5cd7 feat: automatic extension names 2022-10-06 17:19:30 -07:00
Ed Ayers
7fabdf95d6 refactor: diffTag → diffStatus
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2022-10-06 13:06:31 -07:00
E.W.Ayers
506abff532 fix: replace highlight with diffTag 2022-10-06 13:06:31 -07:00
E.W.Ayers
7c8fcb3233 fix: rm instance TypeName String because it is unused 2022-10-06 11:00:43 -07:00
E.W.Ayers
7f8c45b6f3 feat: make CustomInfo use Dynamic instead of Json
A little easier to use than the previous CustomInfo.
2022-10-06 11:00:43 -07:00
Leonardo de Moura
9996686690 feat: display mono phase code 2022-10-06 07:48:59 -07:00
Leonardo de Moura
150022fe13 chore: update stage0 2022-10-06 07:42:24 -07:00
Leonardo de Moura
0577993d61 chore: fix tests 2022-10-06 07:41:48 -07:00
Leonardo de Moura
87caf6d38a fix: bug at toMonoType 2022-10-06 07:41:36 -07:00
Leonardo de Moura
e99ffefeda chore: update stage0 2022-10-06 07:27:47 -07:00
Leonardo de Moura
acd2836cb5 feat: add saveMono pass to normalize mono phase free variable ids
Motivation: control .olean size
2022-10-06 07:24:30 -07:00
Leonardo de Moura
d9fcfd71d9 fix: missing test 2022-10-06 07:18:27 -07:00
Leonardo de Moura
73ee2d92aa fix: constructor parameter validation for mono phase 2022-10-06 06:57:06 -07:00
Leonardo de Moura
faa30bccb2 feat: activate toMono compiler pass
It increases the .olean sizes.
2022-10-06 06:23:08 -07:00
Leonardo de Moura
80bf4f3334 fix: erase type (and type former) parameters occurrences at toMono 2022-10-06 06:23:08 -07:00
Leonardo de Moura
23182882d4 fix: erase universe levels at toMono 2022-10-06 06:23:08 -07:00
Leonardo de Moura
d409ad75b5 fix: bug at trivialStructToMono 2022-10-06 06:23:08 -07:00
Leonardo de Moura
08bfb7060d feat: add support for trivial structures, Decidable, and constructors at toMono 2022-10-06 05:33:13 -07:00
Leonardo de Moura
a0894dedbb feat: add phaseOut field to Pass
We need it for passes that move the code from one phase to another.

See `toMono` pass.

cc @hargoniX
2022-10-06 03:29:21 -07:00
Leonardo de Moura
b172ba8a34 feat: add toMono pass
It has to activate by default yet.
2022-10-05 10:39:41 -07:00
Leonardo de Moura
254e28bd99 chore: update stage0 2022-10-05 10:33:51 -07:00
Leonardo de Moura
e64e877e8f feat: add Decl.toMono skeleton 2022-10-05 10:33:01 -07:00
Leonardo de Moura
9f76da2b7f feat: add env extension for the mono phase 2022-10-05 10:31:52 -07:00
Leonardo de Moura
c6b3ebdd85 feat: detect trivial structures and add extension for storing mono phase types 2022-10-05 08:55:44 -07:00
Leonardo de Moura
00f6f83379 refactor: add BaseTypes.lean 2022-10-05 07:27:39 -07:00
Leonardo de Moura
ee59048bfb chore: remove dead declaration
We have merged `lcErased` and `lcAny` in the new code generator.
2022-10-05 05:17:31 -07:00
Leonardo de Moura
6288181656 chore: fix test 2022-10-05 05:01:42 -07:00
Leonardo de Moura
efc42efe49 chore: update stage0 2022-10-05 04:47:13 -07:00
Leonardo de Moura
913ca41129 refactor: merge lcAny and lcErased
`lcErased` is a superset of `lcAny` anyway, and we didn't find ways of
using the distinction to generate better code.
2022-10-05 04:46:52 -07:00
Leonardo de Moura
ebdbdc1043 chore: temporarily disable extendJoinPointContext
see #1686
2022-10-04 17:41:41 -07:00
Leonardo de Moura
f63734cba4 chore: unexpanders for Name.mkStr* and Array.mkArray*
closes #1675
2022-10-04 17:18:36 -07:00
Leonardo de Moura
e9d5dfc689 chore: closes #1683 2022-10-04 16:46:08 -07:00
Mario Carneiro
d56708c0e5 fix: handle multi namespace/section in foldingRange and documentSymbol (#1680) 2022-10-04 17:37:52 +00:00
Leonardo de Moura
ee603ab741 feat: sort refine new goals using the order they were created
Potential problem: if elaboration of subterms is delayed the order the new metavariables are created may not match the order they
appear in the `.lean` file. We should tell users to prefer tagged goals.

closes #1682
2022-10-04 06:54:14 -07:00
Leonardo de Moura
adeab12beb feat: add support for Iff.rec and Iff.casesOn to new code generator
closes #1684
2022-10-04 06:32:49 -07:00
Sebastian Ullrich
8ed831101e chore: benchmark new compiler 2022-10-04 05:03:54 -07:00
Leonardo de Moura
c4db085ac1 fix: missing dependency check at simpJpCases? 2022-10-03 19:39:10 -07:00
Leonardo de Moura
b3aff375f0 feat: add CodeDecl.dependsOn 2022-10-03 19:36:26 -07:00
Leonardo de Moura
da4812659c feat: use DiscrM to implement simpJpCases? 2022-10-03 19:13:31 -07:00
Leonardo de Moura
ddbf4c01eb refactor: add DiscrM.lean 2022-10-03 19:00:30 -07:00
Leonardo de Moura
f0be5439e6 feat: JpCases for join points with multiple parameters 2022-10-03 18:35:16 -07:00
Mario Carneiro
12deab6516 feat: RBMap simplifications 2022-10-03 17:08:55 -07:00
Henrik Böving
eaab29712d feat: extend join point context pass 2022-10-03 17:03:22 -07:00
Leonardo de Moura
fed7ff27e8 fix: issue reported on Zulip
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Annoying.20LCNF.20errors/near/302056742
2022-10-03 09:51:32 -07:00
Leonardo de Moura
dc6f635f41 refactor: add LCNF/Internalize.lean 2022-10-03 09:18:11 -07:00
Leonardo de Moura
e44fd19074 doc: Semantic highlighting
Many thanks for Patrick Massot for providing the new section at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/semantic.20highlighting.20doc/near/294953547
2022-10-02 08:37:15 -07:00
Leonardo de Moura
7857995df4 fix: fixes #1673 2022-10-02 08:23:14 -07:00
Leonardo de Moura
31d59e337b fix: LCNF any type issue
This fixes an issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Annoying.20LCNF.20errors/near/301935406
2022-10-02 08:09:13 -07:00
Leonardo de Moura
190a1331bd feat: add toMonoType 2022-10-01 20:44:31 -07:00
Leonardo de Moura
1ce9e30403 refactor: extension for storing LCNF types for declarations that do not have code associated with them 2022-10-01 20:44:31 -07:00
Leonardo de Moura
d50253d57a chore: comment indentation issue 2022-10-01 20:44:31 -07:00
pcpthm
96b49261e6 fix: derive Repr missing a comma 2022-10-01 07:17:57 -07:00
Leonardo de Moura
9fdcfebb97 chore: update stage0 2022-09-30 20:52:31 -07:00
Leonardo de Moura
15909f209f feat: inline small declarations not tagged with [noinline] 2022-09-30 20:51:37 -07:00
Leonardo de Moura
72506c81ea chore: trace.Compiler.simp.inline 2022-09-30 20:21:34 -07:00
Leonardo de Moura
18b5ff9e78 chore: propagate recursive flag during code specialization 2022-09-30 20:01:18 -07:00
Leonardo de Moura
9fda3d973d feat: add trace option trace.Compiler.saveBase 2022-09-30 19:50:33 -07:00
Leonardo de Moura
0e18b4318c feat: online inline recursive functions if they are tagged with [inlineIfReduce] 2022-09-30 19:39:12 -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
Mario Carneiro
7a6d41ad58 doc: add addTermInfo docstring 2022-09-30 15:18:06 -07:00
Mario Carneiro
9aa57f9959 fix: .ident hover in patterns 2022-09-30 15:18:06 -07:00
Leonardo de Moura
c7fad1815c chore: update release notes 2022-09-30 09:31:03 -07:00
Leonardo de Moura
955a251bfc chore: update stage0 2022-09-29 18:57:43 -07:00
Leonardo de Moura
fb1a603e60 feat: add another CSE pass before saveBase 2022-09-29 18:56:20 -07:00
Leonardo de Moura
5be1628cdd chore: update stage0 2022-09-29 17:40:59 -07:00
Leonardo de Moura
589701c540 chore: update stage0 2022-09-29 17:37:42 -07:00
Leonardo de Moura
5746338c15 fix: mark Lean.Name.mkStr* functions as [reducible]
This is needed for type checking `TSyntax`.
2022-09-29 17:36:30 -07: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
595734b936 chore: remove workaround
It is now implemented at `Quote (Array _)`
2022-09-29 17:12:48 -07:00
Leonardo de Moura
764170f966 chore: update stage0 2022-09-29 17:00:07 -07:00
Leonardo de Moura
2209a1983b chore: update stage0 2022-09-29 16:57:05 -07:00
Leonardo de Moura
126da8185d feat: more compact quotations
Trying to control the generated code size.
2022-09-29 16:56:43 -07:00
Leonardo de Moura
b4454902c1 feat: LCNF Code.forEachExpr and Decl.forEachExpr 2022-09-29 15:50:49 -07:00
Leonardo de Moura
13edf0e9cc feat: add forEachModuleDecl and forEachMainModuleDecl 2022-09-29 14:16:10 -07:00
Leonardo de Moura
ded7216a12 chore: update stage0 2022-09-29 12:49:45 -07:00
Leonardo de Moura
bb1e94de82 feat: normalize free variable ids before saving LCNF code in the environment 2022-09-29 12:48:21 -07:00
Leonardo de Moura
8cca2ea24e fix: refresh LCNF parameter binder names 2022-09-29 12:46:53 -07:00
Leonardo de Moura
e5494e7a49 fix: eta-expansion at compatibleTypes
It fixes issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Annoying.20LCNF.20errors/near/301424293
2022-09-29 11:02:06 -07:00
Mario Carneiro
1463c9c440 doc: add comment about pattern LHS info nesting 2022-09-29 19:07:18 +02:00
Mario Carneiro
66040a9803 feat: clearer info tree formatting 2022-09-29 19:07:18 +02:00
Mario Carneiro
7a6f7cb0ac fix: induction info tree nesting 2022-09-29 19:07:18 +02:00
Mario Carneiro
73f44ccb7b feat: hover for cases/induction case names 2022-09-29 19:07:18 +02:00
Sebastian Ullrich
9e6814b09e doc: fix inline docs 2022-09-29 09:36:28 +02:00
Leonardo de Moura
cfc19acd83 chore: update stage0 2022-09-28 22:02:38 -07:00
Leonardo de Moura
5c925f9345 feat: add functions to create small arrays and use them in the constant folder
It reduces the code generated for functions using a bunch
of quotations. For example, the size of
`Lean.Elab.Term.Do.ToTerm.matchNestedTermResult` went from 2348 to 1507
2022-09-28 22:00:50 -07:00
Leonardo de Moura
f8f70d5e63 chore: update stage0 2022-09-28 21:15:22 -07:00
Leonardo de Moura
6bc6522d86 feat: constructor => discriminant optimization 2022-09-28 21:14:19 -07:00
Leonardo de Moura
3dc6c859eb chore: update stage0 2022-09-28 19:21:11 -07:00
Leonardo de Moura
73ebaf8499 feat: improve visitLambda at toLCNF 2022-09-28 19:17:28 -07:00
Sebastian Ullrich
71e647049f refactor: lexOrd should not be an instance 2022-09-28 15:57:01 -07:00
Sebastian Ullrich
d0a002ffff fix: prefer longer parse even if unsuccessful 2022-09-28 15:57:01 -07:00
Leonardo de Moura
94c2ec38d5 feat: implement cast TODO
fixes issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Annoying.20LCNF.20errors/near/301269857
2022-09-28 15:40:53 -07:00
Leonardo de Moura
970331de05 chore: avoid a.getAppFn.isAnyType idiom 2022-09-28 15:34:09 -07:00
Mario Carneiro
1c992fde37 chore: add some tests 2022-09-28 14:24:44 -07:00
Mario Carneiro
db110f5dfe fix: preserve tags in simp conv 2022-09-28 14:24:44 -07:00
Mario Carneiro
2a748d3035 fix: conv case => should close the goal conv-style 2022-09-28 14:24:44 -07:00
Mario Carneiro
6f8e861158 fix: case names in congr conv 2022-09-28 14:24:44 -07:00
Mario Carneiro
b6a58d13e1 fix: LHS goals should be pre-whnf'd 2022-09-28 14:24:44 -07:00
Mario Carneiro
b8ed329a5d feat: add dsimp conv <- mathlib4
Co-authored-by: Moritz Doll <doll@uni-bremen.de>
2022-09-28 14:24:44 -07:00
Mario Carneiro
a09934c693 feat: more conv goal structuring tactics 2022-09-28 14:24:44 -07:00
tydeu
37811b2104 chore: update Lean version 2022-09-28 16:15:46 -04:00
tydeu
4811ba7850 Merge remote-tracking branch 'digama0/std_ns' 2022-09-28 16:03:27 -04:00
Ed Ayers
10971a413a feat: fromJson? derivations now say where a parsing error occurred (#1656) 2022-09-28 09:15:26 +00:00
Ed Ayers
22bb798995 feat: datatypes for LSP code actions (#1654) 2022-09-28 09:07:39 +00: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
002c7d2f22 feat: configuration options for the code generator 2022-09-27 16:26:49 -07:00
Leonardo de Moura
135790f41a fix: missing eraseCode at inlineProjInst?
Fixes issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/LCNF.20local.20context.20contains.20unused.20local.20variable.20declaratio/near/301102923
2022-09-27 16:26:49 -07:00
Leonardo de Moura
65c307a7b7 feat: add environment extension for constant folder
TODO: add command/attribute for conveniently installing folders
2022-09-27 16:26:49 -07:00
Sebastian Ullrich
a03749cbe4 fix: findReferences should find only original syntax 2022-09-27 22:09:54 +02:00
Mario Carneiro
d843e2a418 chore: add docs and test 2022-09-27 22:09:54 +02:00
Mario Carneiro
2270e8cd53 fix: ignore unused anonymous have variables 2022-09-27 22:09:54 +02:00
Mario Carneiro
6bf01ebd30 feat: use have token span for implicit this 2022-09-27 22:09:54 +02:00
Mario Carneiro
969eefe79b fix: let _ := should not introduce a variable called "_" 2022-09-27 22:09:54 +02:00
Mario Carneiro
280d8c9c9b feat: add (canonical := true) option in Syntax 2022-09-27 22:09:54 +02:00
Ed Ayers
64e7f25ffe doc: apply suggestions from code review
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2022-09-27 11:37:49 -07:00
E.W.Ayers
8e085fb637 doc: some documentation for Message.lean 2022-09-27 11:37:49 -07:00
Patrick Massot
f0c8e6fa2d doc: add docstrings in PersistentExtension
Add docstring to functions with non-obvious persistence properties. See the discussion at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/HashMap.20extension/near/300784691
2022-09-27 10:34:09 -07:00
Leonardo de Moura
f067382f52 chore: remove old exports 2022-09-27 07:44:38 -07:00
Leonardo de Moura
8596e4af88 fix: mark code as simplified 2022-09-26 21:27:45 -07:00
Leonardo de Moura
193e3fd184 feat: add basic String folding 2022-09-26 21:23:08 -07:00
Leonardo de Moura
e6f5b3758c feat: precompute folders 2022-09-26 21:10:38 -07:00
Leonardo de Moura
1e75001405 feat: preserve user provided names at LCNF Simp
It helps preserving let-declaration names in pure code, but it is not
very useful for monadic let-decls (e.g., `let x <- act`). The binder
names are often lost we eliminating the abstraction layers.
2022-09-26 21:04:13 -07:00
Leonardo de Moura
24e584cf00 feat: add Renaming.lean 2022-09-26 21:04:13 -07:00
Henrik Böving
2958b8a7f5 feat: basic constant folder
supports:
- arithmetic operations:
  - folding full constants
  - folding neutral elements
  - folding annihilators
- List.toArray
2022-09-26 21:03:47 -07:00
Leonardo de Moura
3abfa1f981 chore: update stage0 2022-09-26 08:17:02 -07:00
Leonardo de Moura
73d5e12ac5 fix: baseExt must not use SimplePersistentEnvExtension
We invoke `Decl.saveBase` more than once when we update a declaration.
2022-09-26 08:15:47 -07:00
Leonardo de Moura
37513595b9 chore: update stage0 2022-09-26 07:49:39 -07:00
Leonardo de Moura
ba619be393 fix: apply macroInline again after inlineMatchers 2022-09-26 07:31:27 -07:00
Leonardo de Moura
837ce4374c feat: use reduceJpArity after successful simpJpCases? 2022-09-26 07:25:29 -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
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
bbac49e925 feat: add collectJpCasesInfo
Collect statistics for implementing new optimization that will replace `isCasesOnCases?`
2022-09-25 20:57:24 -07:00
Mario Carneiro
9b9998f5c8 feat: pattern (occs := ...) conv 2022-09-25 19:52:56 -07:00
Leonardo de Moura
dadfe84c15 doc: update const2ModIdx docstring 2022-09-25 14:06:07 -07:00
Leonardo de Moura
236885e72e chore: remove Stage1 2022-09-25 13:17:50 -07:00
Leonardo de Moura
b558a59944 chore: update stage0 2022-09-25 07:13:00 -07:00
Leonardo de Moura
91e27668ae doc: release notes 2022-09-25 07:06:50 -07:00
Mario Carneiro
5644bd7a3f feat: show decl module in hover 2022-09-25 06:43:48 -07:00
Mario Carneiro
121b18f40a chore: add test 2022-09-25 06:42:20 -07:00
Mario Carneiro
fa13d7321f feat: generalize e = x at h 2022-09-25 06:42:20 -07:00
Mario Carneiro
b287658dc3 chore: add test with <->, discharger, contextual, conditional 2022-09-25 06:40:56 -07:00
Mario Carneiro
47930c6fd1 fix: fix tests 2022-09-25 06:40:56 -07:00
Mario Carneiro
84497c1d09 feat: sort simp lemmas by application order 2022-09-25 06:40:56 -07:00
Mario Carneiro
afca560bda chore: revert builtin flag on Origin 2022-09-25 06:40:56 -07:00
Mario Carneiro
86b9af549f chore: update stage0 2022-09-25 06:40:56 -07:00
Mario Carneiro
b739186e98 feat: use a structured type for simp theorem Origin 2022-09-25 06:40:56 -07:00
Mario Carneiro
97bcc7fd7c feat: add ForM -> ForIn adapter 2022-09-25 06:40:56 -07:00
Mario Carneiro
9550db0e3b chore: remove fvarIdToLemmaId 2022-09-25 06:40:56 -07:00
Mario Carneiro
606328aceb feat: improve simp theorem tracing 2022-09-25 06:40:56 -07:00
Mario Carneiro
c3ce32a4e9 chore: update stage0 2022-09-25 06:40:56 -07:00
Mario Carneiro
9a9f3263d4 feat: add tactic.simp.trace option 2022-09-25 06:40:56 -07:00
Mario Carneiro
7dc0e1aa7d fix: tweak formatter spacing for tactics 2022-09-25 06:40:56 -07:00
Mario Carneiro
0961561d4e feat: track simp lemmas through the core tactics 2022-09-25 06:40:56 -07:00
Mario Carneiro
687f1c2271 refactor: make simp lemma names mandatory 2022-09-25 06:40:56 -07:00
Leonardo de Moura
afb457ca2a feat: add forEachDecl for LCNF 2022-09-24 20:18:27 -07:00
Leonardo de Moura
cf2b6b80bb chore: update stage0 2022-09-24 20:01:15 -07:00
Leonardo de Moura
f9abcae4e4 chore: simplify tactic macro
The `[inlineIfReduce]` at `List.toArrayAux` is currently very
expensive, and this example produces a deep recursion when inlining
the `List.toArrayAux` applications.
2022-09-24 19:53: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
f7a1429cfd feat: improve ppDecl' 2022-09-24 18:09:43 -07:00
Leonardo de Moura
8299d24cab chore: update stage0 2022-09-24 15:22:30 -07:00
Leonardo de Moura
871644fe8b chore: fix tests 2022-09-24 15:20:44 -07:00
Leonardo de Moura
cd6508ef5f chore: update stage0 2022-09-24 15:02:56 -07:00
Leonardo de Moura
c858aa3088 feat: replace getStage1Decl? with new getDecl? 2022-09-24 15:00:19 -07:00
Leonardo de Moura
f9ba61fc72 chore: update stage0 2022-09-24 14:33:27 -07:00
Leonardo de Moura
ce90e98648 feat: activate new compiler first phase 2022-09-24 14:20:21 -07:00
Leonardo de Moura
33fdde9b22 fix: LCNF compatibleTypes
Missing rules:
`⊤ a` is compatible with anything.
` a` is compatible with anything.
2022-09-24 14:20:21 -07:00
Leonardo de Moura
7ca7139fe8 fix: incorrect [inline] annotation 2022-09-24 14:20:21 -07:00
Leonardo de Moura
e51b078015 fix: incorrect annotations 2022-09-24 14:20:21 -07:00
Leonardo de Moura
6343b97acb feat: display inlining stack when maximum recursion depth has been reached 2022-09-24 14:20:21 -07:00
Leonardo de Moura
7d583f9543 fix: convert _unsafe_rec to original name 2022-09-24 08:19:41 -07:00
Leonardo de Moura
b88bd98afa fix: unreach case for Code.bind 2022-09-24 08:13:17 -07:00
Leonardo de Moura
947811cab8 fix: zero exit points != one exit point 2022-09-24 08:13:17 -07:00
Sebastian Ullrich
3288f437c2 refactor: further simplify RBMap balancing 2022-09-24 14:16:48 +02:00
Sebastian Ullrich
95f2e4e2e0 refactor: cleanup, simplify RBMap balances 2022-09-24 14:16:48 +02:00
Sebastian Ullrich
381a643fd0 chore: make rbmap.hs more similar to other implementations 2022-09-24 14:16:48 +02:00
Sebastian Ullrich
77e42744dd chore: modernize rbmap benchmarks a bit 2022-09-24 14:16:48 +02:00
Sebastian Ullrich
9f29967fb0 chore: add rbmap.library benchmark to bench suite 2022-09-24 12:35:08 +02:00
Ed Ayers
2a6697e077 feat: goal-diffs (#1610) 2022-09-24 11:46:11 +02:00
Mario Carneiro
ebdbc77631 chore: move Std -> Lean namespace 2022-09-24 00:08:26 -04:00
Leonardo de Moura
85c468c853 fix: remove internal name hack at [specialize] and [inline] attributes 2022-09-23 20:25:16 -07:00
Leonardo de Moura
011521013d feat: use phase at inferConstType, save specialization 2022-09-23 16:45:04 -07:00
Leonardo de Moura
0c82e8bd0d feat: make sure base phase contains an entry for each declaration being compiled at `init 2022-09-23 16:31:38 -07:00
Leonardo de Moura
2be8cb93ac feat: store phase at CompilerM context 2022-09-23 16:30:51 -07:00
Leonardo de Moura
c333581689 fix: functions occurring as arguments of other functions are not inlined 2022-09-23 14:43:06 -07:00
Leonardo de Moura
e4f0f4b794 fix: shouldGenerateCode fix for axiom 2022-09-23 14:25:48 -07:00
Leonardo de Moura
1e846ae280 test: for LCNF 2022-09-23 14:02:34 -07:00
Leonardo de Moura
5322aa79f6 fix: apply findJoinPoints before pullFunDecls
`pullFunDecls` affects the effectiveness of `findJoinPoints`
2022-09-23 14:00:24 -07:00
Leonardo de Moura
004822aba4 fix: mixing Lean and LCNF types at toLCNF 2022-09-23 13:56:31 -07:00
Leonardo de Moura
609d241ad4 fix: improve updateFunDeclInfo precision 2022-09-23 13:56:14 -07:00
Leonardo de Moura
0df23b6043 chore: update stage0 2022-09-23 08:18:26 -07:00
Leonardo de Moura
8cf225e9ce fix: PassInstaller staging issue
The builtin pass installer cannot be installed using `[cpass]` because
it will not be activated until we process `Passes.lean`
2022-09-23 08:17:58 -07:00
Leonardo de Moura
c165317b28 feat: add ImportM.runCoreM 2022-09-23 07:52:13 -07:00
Leonardo de Moura
e53ac503da refactor: move PassInstaller to CoreM 2022-09-23 07:22:54 -07:00
Leonardo de Moura
aa17641f18 chore: LCNF imports 2022-09-23 07:05:57 -07:00
Leonardo de Moura
4323205185 fix: support user-defined empty inductives at toLCNF 2022-09-23 05:50:02 -07:00
Leonardo de Moura
0b4590bd69 test: add erased.lean 2022-09-23 05:29:42 -07:00
Leonardo de Moura
eed569153b fix: dependent field issue 2022-09-22 20:38:42 -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
412a05d0d6 fix: ensure cases field parameters do not occur in types 2022-09-22 20:15:39 -07:00
Leonardo de Moura
a7a6103862 feat: add scoped notation for LCNF pretty printer 2022-09-22 17:07:34 -07:00
Leonardo de Moura
c0ac2138f7 fix: ensure inferForallType at LCNF handles universes like the kernel and MetaM 2022-09-22 16:38:16 -07:00
Leonardo de Moura
8c84531330 chore: fix test 2022-09-22 16:10:12 -07:00
Leonardo de Moura
1437b9cd90 fix: non-termination when eta-expanding Eq.ndrec at toLCNF 2022-09-22 16:04:19 -07:00
Leonardo de Moura
f721e44718 fix: simplify compatibleTypes
Add note about "erasure confusion" in LCNF.
2022-09-22 15:15:32 -07:00
Leonardo de Moura
955d3d4ff5 fix: missing case at isErasedCompatible 2022-09-22 14:16:29 -07:00
Leonardo de Moura
096a6fd4fb fix: use eta at compatibleTypes 2022-09-22 13:57:14 -07:00
Leonardo de Moura
1f8d8df3ac fix: compatibleTypes 2022-09-22 12:52:39 -07:00
Mario Carneiro
2ac687b22b feat: if _ : cond then t else e syntax (part 2) 2022-09-22 11:01:08 -07:00
Mario Carneiro
b799271da6 chore: update stage0 2022-09-22 11:01:08 -07:00
Mario Carneiro
b8cf796941 feat: if _ : cond then t else e syntax 2022-09-22 11:01:08 -07:00
Leonardo de Moura
708a777d74 test: add more LCNF tests 2022-09-21 21:12:17 -07:00
Leonardo de Moura
a2bcb3b73e fix: erase propositon formers, add isErasedCompatible, remove approx. from compatibleTypes 2022-09-21 20:47:02 -07:00
Leonardo de Moura
79c8a3879b fix: LCNF compatibleTypes function 2022-09-21 19:14:25 -07:00
Leonardo de Moura
917f87fee4 fix: forward declaration type 2022-09-21 18:40:38 -07:00
Leonardo de Moura
05f0a6c423 fix: skip declarations that do not have a value 2022-09-21 18:40:20 -07:00
Leonardo de Moura
574c75081f chore: update stage0
Make sure we have the new environment extension at stage0
2022-09-21 18:19:23 -07:00
Leonardo de Moura
f362de995b chore: fix tests 2022-09-21 18:17:32 -07:00
Leonardo de Moura
a5abe864f3 chore: prepare to activate new code generator 2022-09-21 18:09:19 -07:00
Leonardo de Moura
9080701126 refactor: move compileDecl, compileDecls, and addDecl to CoreM
The new code generator entry point is in `CoreM`.
2022-09-21 18:09:19 -07:00
Leonardo de Moura
c52203ff57 feat: add baseExt environment extension for storing code generator results 2022-09-21 18:09:19 -07:00
Leonardo de Moura
f9898a1d45 chore: cleanup 2022-09-21 18:09:19 -07:00
Mario Carneiro
9faca046d6 fix: fix test 2022-09-21 18:04:31 -07:00
Mario Carneiro
3f229d5437 fix: add colGt 2022-09-21 18:04:31 -07:00
Mario Carneiro
ef0736c303 feat: multiple delta (part 2) 2022-09-21 18:04:31 -07:00
Mario Carneiro
3067121af7 chore: update stage0 2022-09-21 18:04:31 -07:00
Mario Carneiro
90353d7fd7 feat: multiple delta, delta conv, unfold 2022-09-21 18:04:31 -07:00
Leonardo de Moura
1fb112f84b test: Environment.addExtraName 2022-09-21 15:03:11 -07:00
Sebastian Ullrich
3c6c1c25e4 chore: simplify elan CI setup 2022-09-21 16:36:05 -04:00
Leonardo de Moura
bdad9aaa99 chore: update stage0
Previous commit affect `.olean` format.
2022-09-21 10:59:47 -07:00
Leonardo de Moura
8987de75c1 feat: add Environment.addExtraName 2022-09-21 10:57:39 -07:00
Yuri de Wit
c65a206d6a chore: reintroduced 'important' let paragraph 2022-09-21 07:36:25 -07:00
Yuri de Wit
64a0ec91fa chore: few updates to Expr documentation 2022-09-21 07:36:25 -07:00
Mario Carneiro
b922483ebc chore: remove getElem' delab 2022-09-21 06:21:00 -07:00
Mario Carneiro
20937c3a6c fix: fix test 2022-09-21 06:21:00 -07:00
Mario Carneiro
2aa882a416 chore: remove getElem', use custom delab 2022-09-21 06:21:00 -07:00
Mario Carneiro
553be10b90 fix: getElem' should be an abbrev 2022-09-21 06:21:00 -07:00
Mario Carneiro
3e83e28e8f feat: injections with names 2022-09-20 17:36:35 -07:00
Leonardo de Moura
727ee79f05 fix: exponential blowup at LCNF simp 2022-09-20 17:03:40 -07:00
Leonardo de Moura
a5ac950b54 chore: increase max recursion depth for compiler 2022-09-20 16:58:45 -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
111f6a319c feat: add ppDecl'
It is useful for debugging purposes when we want to pretty print a
declaration before internalizing it.
2022-09-20 16:55:11 -07:00
Leonardo de Moura
17202d0882 fix: missing headBeta 2022-09-20 16:22:37 -07:00
Leonardo de Moura
631c216bab fix: LCNF pretty printer missing parens 2022-09-20 15:51:32 -07:00
Matthias Hetzenberger
278c9bb0e4 fix: a grammatically incorrect sentence in monads/intro.md 2022-09-20 15:51:28 -07:00
tydeu
48688da4b1 chore: update Lean version 2022-09-20 18:34:50 -04:00
tydeu
e55589cc7f Merge remote-tracking branch 'digama0/import_reduction' 2022-09-20 18:34:33 -04:00
Mario Carneiro
a74892a36b feat: multiple case 2022-09-20 14:15:37 -07:00
Mario Carneiro
b71167c11e chore: update stage0 2022-09-20 14:15:37 -07:00
Mario Carneiro
65a861da68 feat: multiple case (part 1) 2022-09-20 14:15:37 -07:00
Leonardo de Moura
772beeeb29 feat: add withAtLeastMaxRecDepth 2022-09-19 22:04:04 -07:00
Leonardo de Moura
4c19fdbb97 fix: normFVarImp bug 2022-09-19 21:41:18 -07:00
Leonardo de Moura
d132efd440 feat: polymorphic Code.bind 2022-09-19 21:41:18 -07:00
Mario Carneiro
356db4e1df fix: simplify termination_by clause 2022-09-19 13:49:20 -07:00
Mario Carneiro
2f8d20a90d fix: fix test 2022-09-19 13:49:20 -07:00
Mario Carneiro
bb23fc0c86 chore: extract termination lemma for reverse 2022-09-19 13:49:20 -07:00
Mario Carneiro
ed6a5bba88 chore: rename insertAt to insertAt! 2022-09-19 13:49:20 -07:00
Mario Carneiro
f8c6306469 feat: remove bounds checks in Array.{reverse, insertAt} 2022-09-19 13:49:20 -07:00
Leonardo de Moura
ad0f8d3258 chore: update stage0 2022-09-19 12:47:44 -07:00
Gabriel Ebner
27525f33fb fix: changes due to requiring colEq 2022-09-19 12:44:43 -07:00
Gabriel Ebner
a351a4be70 feat: use colEq in sepByIndent 2022-09-19 12:44:43 -07:00
Gabriel Ebner
b1bef71d59 feat: colEq parser 2022-09-19 12:44:43 -07:00
Mario Carneiro
61df1e5073 feat: expose that panic α = default 2022-09-19 08:59:08 -07:00
Yuri de Wit
88fc24c58c chore: fixed typos 2022-09-19 08:14:37 -07:00
Sebastian Ullrich
3ef1baae4a doc: refine mdbook docs 2022-09-19 06:30:11 -07:00
Leonardo de Moura
800938065a chore: update stage0 2022-09-18 17:10:58 -07:00
Gabriel Ebner
9113291e9e fix: preserve separators in evalSepByIndentConv 2022-09-18 16:43:23 -07:00
Gabriel Ebner
3add955382 fix: preserve separators in evalSepByIndentTactic 2022-09-18 16:43:23 -07:00
Gabriel Ebner
ee9c9b1312 feat: skip final newline in sepByIndent format 2022-09-18 16:43:23 -07:00
Gabriel Ebner
0e01d855b0 chore: fix test 2022-09-18 16:43:23 -07:00
Gabriel Ebner
ca4dfa5627 chore: update stage0 2022-09-18 16:43:23 -07:00
Gabriel Ebner
193a18e4e3 Revert "hack: support group tactic for bootstrap" 2022-09-18 16:43:23 -07:00
Gabriel Ebner
2b5c1e397a feat: use sepBy1Indent for conv blocks 2022-09-18 16:43:23 -07:00
Gabriel Ebner
7cc70fe375 chore: update stage0 2022-09-18 16:43:23 -07:00
Gabriel Ebner
74a75e75c8 hack: support group tactic for bootstrap 2022-09-18 16:43:23 -07:00
Gabriel Ebner
7356840cbc feat: use sepBy1Indent for tactic blocks 2022-09-18 16:43:23 -07:00
Gabriel Ebner
9b8b7264f8 chore: prepare for bootstrap 2022-09-18 16:43:23 -07:00
Leonardo de Moura
b50a3c72e9 fix: missing headBetas 2022-09-18 15:52:19 -07:00
Leonardo de Moura
4df303900b feat: apply specialize to specialized code recursively 2022-09-18 15:42:44 -07:00
Leonardo de Moura
70f615d074 fix: avoid "unknown constant" error message for auxiliary declarations 2022-09-18 15:39:58 -07:00
Leonardo de Moura
5fbe63cca4 fix: process remaining params 2022-09-18 15:29:41 -07:00
Leonardo de Moura
90b9b0b7e9 chore: move compiler tests to run folder 2022-09-18 15:08:52 -07:00
Leonardo de Moura
05145577fd feat: cache specialization results 2022-09-18 14:53:18 -07:00
Leonardo de Moura
796e9e3bdd feat: eta expand at specializeApp? 2022-09-18 13:21:55 -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
27c504107e feat: universe level parameter helper functions for the compiler 2022-09-17 16:29:44 -07:00
Leonardo de Moura
db6ee72aed chore: typo 2022-09-17 09:55:46 -07:00
Leonardo de Moura
50fe9ceeaa test: more tests for new compiler 2022-09-16 18:00:27 -07:00
Leonardo de Moura
3c6dee8048 fix: LCNF eta expansion bug at Simp.lean 2022-09-16 18:00:27 -07:00
E.W.Ayers
4b562438f8 doc: MetavarContext 2022-09-16 09:13:47 -07:00
E.W.Ayers
993115a937 feat: Kleisli operators 2022-09-16 05:49:56 -07:00
Elias Aebi
085f51ecb9 doc: fix Markdown code-blocks 2022-09-16 05:48:44 -07:00
Leonardo de Moura
abe1f7f6f9 feat: dependency collector for the code specializer 2022-09-15 19:55:37 -07:00
Leonardo de Moura
ef636f6ec5 chore: update stage0 2022-09-15 19:02:37 -07:00
Leonardo de Moura
b77ff79133 fix: put Lean.Server.FileWorker.WidgetRequests back 2022-09-15 19:02:12 -07:00
Leonardo de Moura
c16d4fb926 chore: fix test suite 2022-09-15 18:59:51 -07:00
Leonardo de Moura
d3b0b49c43 feat: improve elabBinRelCore
See new test and comments at `elaBinRelCore`
2022-09-15 15:17:57 -07:00
Mario Carneiro
eac410db4e fix: fix tests 2022-09-15 14:02:38 -07:00
Mario Carneiro
c0812d0673 chore: reorder Elab.MutualDef and Elab.Deriving.Basic 2022-09-15 14:02:38 -07:00
Mario Carneiro
b092d986dc chore: split Lean.Data.Name and NameMap 2022-09-15 14:02:38 -07:00
Mario Carneiro
6392c5b456 chore: import reductions 2022-09-15 14:02:38 -07:00
Yuri de Wit
bbc70c4cf0 fix: fixes #1599 by adding correct indentation 2022-09-15 13:11:51 -07:00
Alex J Best
f2abe87ddf chore: fix a typo in def name getOptionDefaulValue
renamed to getOptionDefaultValue
2022-09-15 11:45:45 -07:00
Leonardo de Moura
10a56bf4a1 fix: fixes #1571
The previous implementation was using the following heuristic
```lean
      -- heuristic: use non-dependent arrows only if possible for whole group to avoid
      -- noisy mix like `(α : Type) → Type → (γ : Type) → ...`.
      let dependent := curNames.any fun n => hasIdent n.getId stxBody
```
The result produced by this heuristic was **not** producing an
accidental name capture, but I agree
it was confusing to have `∀ (a : True), ∃ a, a = a : Prop` instead of
`True → ∃ a, a = a : Prop` since there is no dependency.
AFAICT, all examples affected by this commit have a better output now.

cc @digma0 @kha
2022-09-15 11:16:16 -07:00
Leonardo de Moura
4f1f20bc97 refactor: ToExprM 2022-09-15 07:42:11 -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
Mario Carneiro
032dc4bc8f chore: move NameMap into a separate file 2022-09-14 21:32:25 -04:00
Leonardo de Moura
9e5a818de5 fix: bug at LCNF toDecl 2022-09-14 15:23:34 -07:00
Leonardo de Moura
00e269c93c fix: throw error at ⟨..⟩ notation if constructor is private 2022-09-14 15:02:38 -07:00
Leonardo de Moura
75f166edcc feat: add assertNoFun test 2022-09-14 13:59:09 -07:00
Leonardo de Moura
82bba1c63b feat: add Code.forM 2022-09-14 13:58:57 -07:00
Leonardo de Moura
ef9127487a fix: throw error at {..} notation if constructor is private 2022-09-14 12:05:53 -07:00
Juan Pablo Romero
0742fd6fc3 docs: fix typo in SeqRight docstring 2022-09-14 10:17:15 -07:00
Gabriel Ebner
ed9b5bcb92 fix: make all syntax accessors non-panicking 2022-09-14 10:17:00 -07:00
Mario Carneiro
f6b3890dc5 feat: tail-recursive List.{mapM, foldrM} 2022-09-14 08:31:18 -07:00
Gabriel Ebner
10ff2601c5 fix: term info for inductive ctors 2022-09-14 08:26:17 -07:00
Gabriel Ebner
f1b5fa53f0 chore: use new comment syntax 2022-09-14 08:26:17 -07:00
Gabriel Ebner
b0e059318f chore: update stage0 2022-09-14 08:26:17 -07:00
Gabriel Ebner
e04cecc496 chore: prepare for bootstrap 2022-09-14 08:26:17 -07:00
Gabriel Ebner
59abb9a332 feat: move docstring before | in ctors 2022-09-14 08:26:17 -07:00
Gabriel Ebner
00793fcdd8 chore: remove old bootstrapping hack 2022-09-14 08:26:17 -07:00
Leonardo de Moura
fccb60fb69 feat: support for [inlineIfReduce] at new compiler 2022-09-13 18:23:42 -07:00
Leonardo de Moura
e8246e026d fix: bug at compatibleTypes
Many thanks to @hargoniX
2022-09-13 15:58:06 -07:00
Leonardo de Moura
8f2ab82408 fix: bug at bindCases
Many thanks to @hargoniX
2022-09-13 15:36:46 -07:00
Gabriel Ebner
024a298eb7 chore: use new constructor docstring syntax 2022-09-13 19:11:13 +02:00
Leonardo de Moura
7535c12bc5 test: add frontend meeting examples to test suite 2022-09-13 09:08:38 -07:00
Gabriel Ebner
b4af14d44a fix: deindent docstrings with empty lines 2022-09-13 07:16:12 -07:00
Mario Carneiro
a0fcb660c5 feat: allow multiple source + no expected type 2022-09-13 07:09:08 -07:00
Mario Carneiro
adc215dab9 feat: support {s with ..} 2022-09-13 07:09:08 -07:00
Gabriel Ebner
d67546e388 chore: add test 2022-09-13 06:19:40 -07:00
Gabriel Ebner
ca28b0462c feat: show all missing fields in structure instance 2022-09-13 06:19:40 -07:00
Gabriel Ebner
54e7d31d0f feat: allow empty whereStructInst 2022-09-13 06:19:40 -07:00
Elias Aebi
fea65d9934 doc: fix an example in the Macro Overview 2022-09-13 03:22:38 -07:00
Mario Carneiro
3bb3efdedc feat: allow optional type in example 2022-09-13 03:11:04 -07:00
Mario Carneiro
b4ed2f2bbb doc: document Init.Data.Queue 2022-09-13 03:09:25 -07:00
Sebastian Ullrich
2770b9e98b chore: inheritDoc misbehaves on built-in parsers 2022-09-13 03:08:23 -07:00
Sebastian Ullrich
a4ac7087dc doc: some do extensions 2022-09-13 03:08:23 -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
b2d6caca0a fix: inferProjType at LCNF 2022-09-12 18:27:14 -07:00
Leonardo de Moura
a2631ce037 fix: panic when Syntax.missing
I got a panic error message today in VS Code because of this function.
It is weird because, as far as I can tell, this function is only used by
the `register_simp_attr` macro, and this macro was not being used in
the files I was editing.
I think the fix is resonable for a `Syntax.missing` case.

cc @gebner
2022-09-12 16:10:14 -07:00
Leonardo de Moura
506cf01d94 fix: bug at simpCasesOnCtor? 2022-09-12 16:02:19 -07:00
Leonardo de Moura
b777d411ec feat: add useRaw parameter at constructorApp?
and document this API.
2022-09-12 15:56:36 -07:00
Leonardo de Moura
e08d48c591 feat: track ground let-declarations at Specialize.lean 2022-09-12 14:05:45 -07:00
Leonardo de Moura
ec2372e8d4 feat: add Specialize.lean skeleton 2022-09-11 20:19:44 -07:00
Leonardo de Moura
44c67f72c1 feat: add LCNF/SpecInfo.lean 2022-09-11 20:19:44 -07:00
Leonardo de Moura
54f1193739 chore: add maybeTypeFormerType 2022-09-11 20:19:44 -07:00
Leonardo de Moura
f0d75258ae feat: treat erased arguments as fixed arguments
It also renames `Lean.Expr.erased` => `Lean.Expr.isErased`
2022-09-11 20:19:44 -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
e78820e6a5 feat: add mkFixedArgMap 2022-09-11 20:19:44 -07:00
Elias Aebi
689afdb3b7 doc: enable syntax highlighting for the Macro Overview (#1577) 2022-09-11 08:53:05 -07:00
Mario Carneiro
19a50a32ec chore: remove List.init 2022-09-11 07:21:24 -07:00
Mario Carneiro
2886174dd0 chore: remove map₂, [specialize] zipWith 2022-09-11 07:21:24 -07:00
Mario Carneiro
8017aa1706 fix: use Type u universes in List.foldl 2022-09-11 07:19:30 -07:00
Chris Lovett
1749210a4b doc: fix typos and do some polish on wording (#1568) 2022-09-10 15:13:43 -07:00
Leonardo de Moura
59b4d977b5 chore: fix tests 2022-09-10 15:06:03 -07:00
Henrik Böving
a03ea65d73 refactor: monadic compiler test framework style + new pass manager 2022-09-10 15:00:05 -07:00
Henrik Böving
c6db1099d0 feat: add occurences and phases to PassManager 2022-09-10 14:58:49 -07:00
Leonardo de Moura
ca098d3769 feat: inline applications of the form inline (f ...)
The `inline` identity function is a directive for the compiler.
2022-09-10 13:28:49 -07:00
Leonardo de Moura
1953f5953f chore: dangling file 2022-09-10 13:23:14 -07:00
Leonardo de Moura
f1c150228b fix: fixes #1558 2022-09-09 15:27:51 -07:00
Leonardo de Moura
353eb0dd27 fix: disable auto implicit feature when running tactics
fixes #1569
2022-09-09 15:17:50 -07:00
Leonardo de Moura
9f134cad8e chore: remove leftover
7c3826d3e9
2022-09-09 15:06:47 -07:00
Leonardo de Moura
abf514378b fix: fixes #1575 2022-09-09 15:05:21 -07:00
Leonardo de Moura
7c3826d3e9 fix: fixes #1576 2022-09-09 14:29:48 -07:00
Leonardo de Moura
16534bacc9 chore: re-activate test 2022-09-08 15:23:18 -07:00
Henrik Böving
5514339ffd fix: visit jp bodies in join point finder 2022-09-08 15:21:53 -07:00
Leonardo de Moura
2ec7f14ca8 chore: temporarily disable test to fix build 2022-09-08 14:53:48 -07:00
Leonardo de Moura
e39c3af5bb chore: remove [inline] from parser combinators 2022-09-08 14:50:27 -07:00
Leonardo de Moura
a40118c79d chore: disable eager applyCasesOnImplementedBy
It must be performed at phase 2.
We still want to perform the regular `[implementedBy]` replacements at
phase 1 since they affect code specialization.
2022-09-08 14:50:27 -07:00
Leonardo de Moura
1c188b62cd chore: typo 2022-09-08 14:50:27 -07:00
Gabriel Ebner
fb259f95db feat: remove description argument from register_simp_attr 2022-09-08 14:49:43 -07:00
Leonardo de Moura
5b969b75bd chore: fix build 2022-09-08 14:23:18 -07:00
Henrik Böving
576a4ec2c5 test: basic compiler tests for findJoinPoints 2022-09-08 14:09:14 -07:00
Henrik Böving
f912349a29 fix: compiler test framework style 2022-09-08 14:09:14 -07:00
Henrik Böving
d2f7e724ac feat: findJoinPoints pass 2022-09-08 14:09:14 -07:00
Mario Carneiro
f2254088d1 feat: deriving Repr for TSyntax 2022-09-08 13:14:06 +02:00
Leonardo de Moura
26e304261f fix: PullFunDecls.lean
Use topological sort.
2022-09-07 22:41:05 -07:00
Leonardo de Moura
46b85ec297 chore: update stage0 2022-09-07 20:39:33 -07:00
Leonardo de Moura
0a21603cdc feat: apply implementedBy replacements at second simp pass 2022-09-07 20:38:16 -07:00
Leonardo de Moura
07bdab45d2 feat: apply casesOn implementedBy replacements 2022-09-07 20:37:09 -07:00
Leonardo de Moura
bd21583d4b fix: ComputedFields.lean
`all` fields was not being set correctly.
TODO: check `all` fields in the kernel.
2022-09-07 20:35:59 -07:00
Leonardo de Moura
ea3235c551 fix: skip casesOn recursors at code generation 2022-09-07 18:46:48 -07:00
Leonardo de Moura
5c00708b7f test: specialize attribute tests 2022-09-07 16:32:25 -07:00
Leonardo de Moura
19f5fe6f42 feat: add getSpecializationArgs? 2022-09-07 16:08:45 -07:00
Leonardo de Moura
de0be1d820 chore: update stage0 2022-09-07 15:46:17 -07:00
Leonardo de Moura
55171a893a feat: elaborate specialization arguments 2022-09-07 15:22:56 -07:00
Leonardo de Moura
d0d98bef25 chore: update stage0 2022-09-07 14:53:01 -07:00
Leonardo de Moura
f611a6e52f feat: add specialize attribute parser 2022-09-07 14:50:29 -07:00
Leonardo de Moura
1e135e58a1 chore: update stage0 2022-09-07 13:24:19 -07:00
Leonardo de Moura
735dabdb3f refactor: use ParametricAttribute to implement [specialize] 2022-09-07 13:17:24 -07:00
Leonardo de Moura
04b32eb140 chore: remove noinline and nospecialize from runEval 2022-09-07 13:08:01 -07:00
Leonardo de Moura
661eb39bc8 feat: add inlinePartial config option 2022-09-06 20:46:17 -07:00
Mario Carneiro
21262e5dca chore: move Bootstrap.Data -> Lean.Data 2022-08-29 11:14:25 -04:00
Mario Carneiro
f4bae4cd2a chore: move Std -> Bootstrap 2022-08-29 01:03:08 -04:00
tydeu
f0c79f0954 chore: update Lean version 2022-08-08 18:03:25 -04:00
Leonardo de Moura
1c5ec65260 chore: runTermElabM refactor 2022-08-07 07:30:29 -07:00
tydeu
a7e0e5b50a release: 4.0.0 2022-08-05 22:51:13 -04:00
tydeu
70172158a4 fix: improve targets/facets UX (e.g., errors when type incorrect) 2022-08-05 22:24:32 -04:00
tydeu
5ae0b979e8 doc: update README and some comments 2022-08-05 22:06:32 -04:00
tydeu
4fba6ae385 chore: bump Lean version 2022-08-05 17:42:00 -04:00
tydeu
c6327e66ca chore: bump Lake version 2022-08-05 17:38:27 -04:00
tydeu
ecadca6902 feat: make manifest file configurable
see leanprover/lake#111
2022-08-05 17:31:04 -04:00
tydeu
db39141034 feat: replace extraDepTarget with extraDepTargets 2022-08-05 15:48:23 -04:00
tydeu
a889a7387c test: make test 44 more consistent 2022-08-04 22:23:46 -04:00
tydeu
350e1b810a refactor: split CLI actions into separate file 2022-08-04 21:31:58 -04:00
tydeu
f0ae7bff1e feat: ws.runBuild 2022-08-04 21:19:23 -04:00
tydeu
9121c4dfa8 feat: facet info param + unique names for facet syntax 2022-08-04 19:55:32 -04:00
tydeu
5558ad89a1 refactor: move fetching releases to extraDep build 2022-08-04 18:58:17 -04:00
tydeu
f2bcba7c73 refactor: renames + cleanup 2022-08-04 18:30:53 -04:00
tydeu
b8ed74e89f feat: recursive builds in extern_lib 2022-08-04 16:58:42 -04:00
tydeu
19afb95dd7 chore: test 44 shell script fixes 2022-08-03 00:56:50 -04:00
tydeu
5b81042614 ci: add diffutils to Windows MSYS2 setup 2022-08-03 00:42:30 -04:00
tydeu
56cec0b41c feat: --old to use outdated unchanged modules
closes leanprover/lake#44
2022-08-03 00:35:44 -04:00
tydeu
99a0a1ee1f refactor: remove remainder of Target code 2022-08-02 21:46:51 -04:00
tydeu
93c0b44623 doc: correct require syntax docs 2022-08-02 02:26:42 -04:00
tydeu
65825e4210 refactor; cleanup (primarly resolve code) 2022-08-02 01:58:13 -04:00
tydeu
b022a99027 fix: pass pkg linking args to extern lib linking 2022-08-02 00:13:58 -04:00
tydeu
59585d2374 refactor: cleanup logging API (unify BuildIO with LogIO) 2022-08-01 22:37:07 -04:00
tydeu
d5b6a49054 feat: platform bits in build archive name + related cleanup 2022-08-01 18:50:06 -04:00
tydeu
f4734e35ff feat: inherit deep desp's revision from dep's manifest
closes leanprover/lake#70
2022-07-31 03:16:27 -04:00
tydeu
c0a04de055 feat: store config rev in manifest and warn on change
see leanprover/lake#85
2022-07-29 15:15:39 -04:00
tydeu
aed23307b0 chore: correctly mark version as prerelease 2022-07-29 01:15:39 -04:00
tydeu
3cfc0d9f68 feat: cloud build support 2022-07-28 23:31:39 -04:00
Mario Carneiro
a0400cbe97 feat: verbosity options for logging + neater build progress 2022-07-28 14:45:23 -04:00
tydeu
2d2bed90aa refactor: Lake.Build.Topological tweaks + docs 2022-07-28 02:26:45 -04:00
tydeu
6bb5101256 refactor: pattern TargetConfig off FacetConfig 2022-07-27 19:54:15 -04:00
tydeu
bc8c809d66 refactor; replace ActiveTarget with Job 2022-07-27 16:08:09 -04:00
tydeu
dd30925ba6 chore: fix targets example 2022-07-27 02:46:36 -04:00
tydeu
1c916b755a refactor: reduce use of targets + IndexT cleanup 2022-07-27 00:27:12 -04:00
tydeu
226def8b82 refactor: remove many used Target methods 2022-07-26 23:40:29 -04:00
tydeu
6709a795df fix: apply nameToSharedLib to modTargets too 2022-07-26 23:24:49 -04:00
tydeu
8b402c4ee0 refactor: move info into target task 2022-07-26 21:13:43 -04:00
tydeu
5e3282347e refactor: remove facet target helpers 2022-07-26 15:30:11 -04:00
tydeu
33e05e16be chore: cleanup at recBuildExternalDynlibs 2022-07-26 15:27:01 -04:00
tydeu
a05e35c783 feat: library facets 2022-07-26 15:07:27 -04:00
tydeu
97100dcd02 feat: build all CLI targets in the same build pass 2022-07-25 20:48:31 -04:00
tydeu
f843d29f72 refactor: remove module facet special casing 2022-07-25 15:36:42 -04:00
tydeu
1d2ca29f2a chore: remove package config builtin targets 2022-07-25 14:59:49 -04:00
tydeu
90ba1a6556 chore: start next Lake version 2022-07-25 14:59:39 -04:00
tydeu
afe18ac02e release: 3.2.2 2022-07-24 22:44:36 -04:00
tydeu
48b1ed711a chore: bump Lean version 2022-07-24 22:37:48 -04:00
tydeu
b784f8c3af ci: don't skip after successful duplicate
Old duplicate runs can be lost (e.g., on a force push)
2022-07-24 22:00:39 -04:00
tydeu
dc8097dae6 feat: support pkg/ to disambiguate packages 2022-07-24 21:47:34 -04:00
tydeu
10940bf07b refactor: merge IndexTargets into Index 2022-07-24 21:47:13 -04:00
tydeu
ff23465a04 chore: try to fix meta test script on macOS 2022-07-24 21:43:41 -04:00
tydeu
09e05cc1a9 feat: add do helper for grouping cmds + meta test 2022-07-24 21:43:40 -04:00
tydeu
ac5d83ca15 feat: add meta if helper command for config switchs 2022-07-24 21:43:40 -04:00
tydeu
67775edd18 refactor: make LeanLib.buildModules a proper recursive build 2022-07-24 00:34:57 -04:00
tydeu
abe8e8b1f8 docs: touch-up of Lake.Util.Family comments 2022-07-23 22:07:34 -04:00
tydeu
d68029092a refactor: simplify FacetConifg and build monads ala leanprover/lake#107
closes leanprover/lake#107
2022-07-23 19:39:47 -04:00
tydeu
1256453ad5 refactor: move mod/pkg facets from pkg to ws 2022-07-22 17:56:06 -04:00
Mario Carneiro
fc34cd2b8e chore: convert doc/mod comments from /- to /--//-! 2022-07-22 10:46:14 -04:00
tydeu
6caea9306c feat: resolve depss while loading a pkg 2022-07-22 04:46:44 -04:00
tydeu
a6cc5f3a9d doc: mention types of root(s)/lib/exeName in README
closes leanprover/lake#105
2022-07-20 19:38:09 -04:00
tydeu
aaf3c1e959 refactor: split config elab into its own file 2022-07-15 21:42:20 -04:00
tydeu
695b8f9b5d refactor: move all manifest code to its file + split Package.load 2022-07-15 21:06:55 -04:00
tydeu
ab528009ee refactor: move config loading code into its own directory 2022-07-15 16:38:35 -04:00
tydeu
5f9166c621 test: try to fix sed script for test 104 for MacOS 2022-07-15 15:58:13 -04:00
tydeu
f93a47de69 fix: do not fetch if dep rev matches manifest
also add some warnings on url/manifest mismatch + other minor cleanup

closes leanprover/lake#104
2022-07-15 15:11:27 -04:00
tydeu
23a578c37c refactor: add LawfulCmpEq + post-PR cleanup 2022-07-14 18:11:12 -04:00
tydeu
32f870a994 chore: update Lean version 2022-07-14 15:04:45 -04:00
Gabriel Ebner
f76b488fd5 chore: hash field in Name was dropped 2022-07-14 15:04:45 -04:00
tydeu
5cd2d85515 doc: add trace to glossary + cleanup 2022-07-14 14:47:51 -04:00
tydeu
e498ff1aa8 doc: add glossary of Lake terminology to README
also added missing doc on `LeanLibConifg.srcDir`
2022-07-12 01:43:50 -04:00
tydeu
68b81ca065 refactor: intro Lake.Env & add it to Workspace
also `LakeConfig` -> `LoadConfig`
2022-07-11 23:06:19 -04:00
tydeu
2e38df619c fix: Glob.forEachModuleIn
closes leanprover/lake#102
2022-07-11 15:45:50 -04:00
Sebastian Ullrich
fe5d95e7e3 fix: flake.nix 2022-07-10 22:57:44 +02:00
tydeu
62bdde1548 chore: update Lean version 2022-07-09 15:08:09 -04:00
Sebastian Ullrich
03da79a603 fix: restore script arg syntax 2022-07-09 15:05:19 -04:00
Sebastian Ullrich
1ea2a52448 chore: adapt to simpleBinder removal 2022-07-09 15:05:18 -04:00
Leonardo de Moura
b33aa09384 chore: the for in elaborator now propagates the element type to the body 2022-07-09 14:54:40 -04:00
tydeu
25d3860823 feat: lake exe CLI to run workspace exes
closes leanprover/lake#82
2022-07-09 02:47:01 -04:00
Sebastian Ullrich
b57ca74794 chore: skip elan test if no elan found 2022-07-08 23:05:12 -04:00
Sebastian Ullrich
49a025889a chore: remove redundant declaration in .envrc 2022-07-08 23:05:12 -04:00
Sebastian Ullrich
a45d86cb96 chore: update flake.nix 2022-07-08 23:05:12 -04:00
tydeu
958e3fc4da feat: add shorthands for lake script run/list
closes leanprover/lake#88
2022-07-08 23:03:42 -04:00
tydeu
ca04bf9b43 refactor: reorg cli code some (e.g., split cmds into defs) 2022-07-08 22:51:07 -04:00
tydeu
0fbd7a866a feat: replace __args__ with get_config? + related refactors 2022-07-08 19:00:52 -04:00
tydeu
185e10f6f3 misc: hoist facet name check to load + related bugfixes/refactors 2022-07-07 21:38:55 -04:00
tydeu
c45088b2ea chore: start next Lake version 2022-07-07 21:38:54 -04:00
tydeu
ee59d66268 release: 3.2.1 2022-07-05 19:28:40 -04:00
tydeu
adc6317e7b chore: bump Lean version 2022-07-05 19:15:45 -04:00
tydeu
958f38b31e feat: setup lean/lake env for server even if config has errors 2022-07-05 19:08:47 -04:00
tydeu
0a53ecb768 feat: add module file path helpers 2022-07-05 18:10:37 -04:00
tydeu
44f8e27a29 refactor: LeanExe.facet -> exeFacet 2022-07-05 17:46:44 -04:00
tydeu
3229d5084c fix: properly update deps w/ no branch or dir but no manifest
closes leanprover/lake#94
2022-07-05 17:36:38 -04:00
tydeu
df8085b7c2 fix: don't set LEAN_CC unless necessary + detect src dirs
closes leanprover/lake#93
2022-07-05 15:41:33 -04:00
tydeu
9e87958312 fix: linking libraries on Unix 2022-07-05 03:19:38 -04:00
tydeu
b6dc189f0a feat: augment server env + add dynlib search path
see leanprover/lake#93, closes leanprover/lake#91
2022-07-05 02:45:45 -04:00
tydeu
0875473b13 fix: parameterize CustomData by package and target name 2022-07-04 20:27:10 -04:00
tydeu
7049a8da5f refactor: DynamicType -> FamilyDef
Uses more principled terminology (i.e., its really an open type family)
2022-07-04 17:21:36 -04:00
tydeu
66e807146b chore: bump Lean version 2022-07-04 17:18:44 -04:00
tydeu
bee7e5d323 chore: start next Lake version 2022-07-04 15:39:23 -04:00
Leonardo de Moura
a6d6ae01a0 chore: String.getOp has been removed 2022-07-02 19:39:20 -04:00
tydeu
4f8c51f102 test: use -fPIC in ffi example 2022-07-01 20:25:02 -04:00
tydeu
83b9404d02 chore: don't use ../$LAKE idiom 2022-07-01 20:13:53 -04:00
tydeu
5eb591092d release: 3.2.0 2022-07-01 19:03:46 -04:00
tydeu
c7075f3f99 refactor: remove dead package DSL code 2022-07-01 18:45:50 -04:00
tydeu
2355ce06e7 chore: bump Lean version 2022-07-01 17:47:47 -04:00
tydeu
f0c9b74540 doc: update README 2022-07-01 17:30:38 -04:00
tydeu
906bc3c9c2 refactor: simplify custom target API (for now) 2022-07-01 16:26:35 -04:00
tydeu
8c46d7439a chore: remove some deprecated features + deprecate extraDepTarget 2022-07-01 15:35:45 -04:00
tydeu
b9beeff3ad chore: fix wording 2022-07-01 14:45:44 -04:00
tydeu
a81994871a feat: add build types (e.g., debug, release) 2022-07-01 14:45:19 -04:00
tydeu
2e43c1b6cf fix: keyName regression caused by refactor 2022-07-01 11:18:59 -04:00
tydeu
2f9eefd35a feat: inductive BuildKey + proper custom targets 2022-07-01 04:52:50 -04:00
tydeu
989b5666c9 refactor: remove unnecesssary build key subtypes 2022-07-01 02:54:08 -04:00
tydeu
72f555dd5b fix: properly trace module imports 2022-07-01 02:45:24 -04:00
tydeu
48d595b722 feat: preliminary custom package facets 2022-07-01 00:11:53 -04:00
tydeu
2ccd41ac82 feat: preliminary custom targets 2022-07-01 00:11:44 -04:00
tydeu
24fd2e37e1 chore: update Lean version + adapt to TSyntax 2022-06-30 19:24:18 -04:00
tydeu
74f3e963ff feat: use nativeFacets in exe's recBuild 2022-06-30 01:30:14 -04:00
tydeu
6035ed56ea fix: make root module "private" to the package 2022-06-30 01:26:01 -04:00
tydeu
5dd9042a2c fix: dummy git identity in test to make runner happy 2022-06-29 22:56:19 -04:00
tydeu
e33b5a2095 fix: properly update git packages specified by branch
closes leanprover/lake#84
2022-06-29 22:31:25 -04:00
tydeu
7955d0f73c refactor: typify git repos + log stdout/stderr on git failures
c.f. leanprover/lake#67
2022-06-29 21:58:11 -04:00
tydeu
c6f7a0d654 fix: build o files again to enable incremental rebuilds
This reverts commit 182a5787aabd8924823f2232a518911c81b2b2cd.
2022-06-29 18:05:53 -04:00
tydeu
49384a69bf fix: precompile imports of precompiled imports 2022-06-29 17:06:24 -04:00
tydeu
17a36f89aa fix: use Lake install's olean files over LEAN_PATH 2022-06-29 12:56:49 -04:00
tydeu
7ea0ea3393 fix: use library, not package, for lean root dir 2022-06-29 04:05:35 -04:00
tydeu
f62b017654 feat: user-specified native module facets for libraries 2022-06-29 03:36:05 -04:00
tydeu
85f6d1a402 feat: preliminary custom module facets 2022-06-28 23:39:47 -04:00
tydeu
4d118062b8 chore: add note highlighting perf decision 2022-06-28 14:02:07 -04:00
Mac
a2e39659f9 perf: do not build object files of imports when linking executable 2022-06-28 13:57:23 -04:00
tydeu
5f1eca5954 refactor: minor cleanup 2022-06-28 13:35:20 -04:00
tydeu
a4174a560b refactor: build code cleanup / reorg 2022-06-28 01:01:13 -04:00
tydeu
0e99494611 refactor: move lib/exe targets into the index 2022-06-27 02:07:45 -04:00
tydeu
62815168c6 feat: library-level module configuration 2022-06-26 20:35:23 -04:00
tydeu
c0bc0344b0 refactor: add LeanLib/LeanExe/ExternLib + reorg & cleanup 2022-06-26 18:26:12 -04:00
Mac
a8d1ff5fdc fix: properly link libraries on MacOS 2022-06-25 21:46:01 -04:00
tydeu
6812bae11a feat: link libraries in a path and platform independent way 2022-06-25 19:22:41 -04:00
tydeu
c4580839b5 test: "fix" library loading issues 2022-06-25 17:07:52 -04:00
tydeu
3200b43371 feat: include external libraries in precompilation 2022-06-25 00:35:29 -04:00
tydeu
45ff2dbc9d feat: add isLeanOnly package config
closes leanprover/lake#74
2022-06-24 18:35:14 -04:00
tydeu
961a328bfd fix: report precompiled dynlibs to server
a feature of leanprover/lake#47 I had hetherto missed
2022-06-24 17:04:42 -04:00
tydeu
4f739572c9 refactor: use IndexT at Index.lean 2022-06-24 15:05:41 -04:00
tydeu
241665dc27 refactor: move recurse arg into the monad stack 2022-06-23 23:42:12 -04:00
tydeu
0655233dd2 fix: precompile mods if they want not if their importer wants
closes leanprover/lake#83
2022-06-23 22:45:11 -04:00
tydeu
36fe59f687 test: expand precompile example to test leanprover/lake#83 2022-06-23 22:06:15 -04:00
tydeu
d842158172 refactor: reorg build code into smaller, focused files 2022-06-23 21:27:57 -04:00
tydeu
d3c373478e refactor: generalize module facet build code to any target 2022-06-23 13:19:39 -04:00
tydeu
f7451e025c feat: basic precompiled modules + builtin module facets
closes leanprover/lake#47
2022-06-22 13:20:15 -04:00
tydeu
aa4b82c53f chore: update Lean version 2022-06-17 04:39:47 -04:00
Sebastian Ullrich
dad47195da chore: adapt to where syntax change 2022-06-17 04:39:47 -04:00
Mac
7447cb444c ci: skip duplicate/unnecessary jobs 2022-06-16 18:08:36 -04:00
tydeu
f5126bc82a chore: remove lean-toolchain from version agnostic tests 2022-06-16 17:33:00 -04:00
tydeu
4ffe900d93 chore: update Lean version 2022-06-16 17:33:00 -04:00
Leonardo de Moura
8d854900fd chore: replace constant with opaque 2022-06-16 17:33:00 -04:00
Leonardo de Moura
4b7188e0ce chore: opaque is now a command keyword 2022-06-16 17:33:00 -04:00
tydeu
61926bbb32 chore: fix test 2022-06-16 02:24:46 -04:00
tydeu
eb7979b332 test: add test for leanprover/lake#75 2022-06-16 02:12:40 -04:00
tydeu
02ee011a0e refactor: simplify module target code + related cleanup
closes leanprover/lake#75
2022-06-16 02:04:31 -04:00
tydeu
8dc3133244 chore: use bash shebang in test scripts 2022-06-14 18:56:20 -04:00
tydeu
38fc7192ed chore: fix new shell scripts' premissions 2022-06-14 18:39:04 -04:00
tydeu
8faafb7ef6 test: reorg + regression tests 2022-06-14 18:33:01 -04:00
tydeu
4ff44fb050 fix: don't require know expected type for __dir__/__args__ 2022-06-14 16:59:13 -04:00
tydeu
854b154a5f fix: lake serve fallback regression
closes leanprover/lake#76
2022-06-14 15:54:07 -04:00
tydeu
1996d6710b chore: update Lean version 2022-06-14 13:07:42 -04:00
tydeu
7bbe6cfce8 feat: different package templates 2022-06-13 20:01:43 -04:00
tydeu
7cd0107ae1 chore: start next Lake version 2022-06-13 13:03:32 -04:00
tydeu
8646aa142d release: 3.1.1 2022-06-10 19:41:38 -04:00
tydeu
22ecda20c7 feat: rev opt in git dep + fix path opt in require 2022-06-10 19:28:52 -04:00
tydeu
2f7825e06b chore: start next Lake version 2022-06-10 19:20:32 -04:00
tydeu
bf5c89352d release: 3.1.0 2022-06-10 16:51:58 -04:00
tydeu
7ea84c5961 doc: update defaultFacet description 2022-06-10 16:13:55 -04:00
tydeu
05b4a8fc76 chore: silence some "unused variable" warnings 2022-06-10 15:44:08 -04:00
tydeu
e6e2c2ab72 test: make git example clone local repo 2022-06-10 15:25:34 -04:00
tydeu
144fbaf642 doc: update w/ extern_lib + some cleanup 2022-06-10 15:16:49 -04:00
tydeu
c77d6680a7 feat: allow @[defaultTarget] extern_lib 2022-06-10 14:57:46 -04:00
tydeu
1523e2d729 feat: extend DSL syntax and improve docs 2022-06-10 14:08:40 -04:00
tydeu
66797c4232 chore: bump Lean version 2022-06-10 13:54:52 -04:00
tydeu
e5782adeff feat: replace moreLibTargets w/ new extern_lib syntax 2022-06-10 12:08:58 -04:00
tydeu
8428ef7cd7 chore: improve imports lean-only build condition 2022-06-09 21:08:06 -04:00
tydeu
6f38ebebe9 doc: fix heading 2022-06-09 20:57:20 -04:00
tydeu
1f017deaa0 feat: trim log messages+ simplify MonadLog 2022-06-09 20:53:19 -04:00
tydeu
049259b47f fix: delete duplicate improperly case Ffi.lean 2022-06-09 20:29:44 -04:00
tydeu
5fdf97db20 feat: none package facet to avoid warnings in scripts example 2022-06-09 19:12:29 -04:00
tydeu
964eb5ef10 doc: update with new features + other cleanup 2022-06-09 18:58:43 -04:00
tydeu
108d9852ca chore: deprecate package facets 2022-06-09 16:38:07 -04:00
tydeu
d28cb121b5 feat: packages names don't eat up an identifier 2022-06-09 14:13:54 -04:00
tydeu
9dadf7e0b1 feat: attr to mark targets as package defaults 2022-06-09 12:52:54 -04:00
tydeu
cb6db07bb9 chore: warnings on deprecated features 2022-06-08 18:21:15 -04:00
tydeu
1be19f0ebd fix: another casing error in targets test 2022-06-08 17:53:40 -04:00
tydeu
318b12c710 fix: casing in targets test 2022-06-08 17:42:01 -04:00
tydeu
5ea07ae20e refactor: preserve case in exe root default 2022-06-08 17:37:05 -04:00
tydeu
427ad67d79 fix: include submodules at hasModule + test 2022-06-08 17:34:57 -04:00
tydeu
9c20cad9d8 feat: syntax for defining extra lib & exe targets 2022-06-08 17:06:03 -04:00
tydeu
76383dfccc fix: properly catch CLI errors 2022-06-07 22:38:16 -04:00
tydeu
18b6bf3cf8 fix: exe link args & targets test 2022-06-07 21:27:41 -04:00
tydeu
18eef56322 feat: multi lib & exe targets w/ updated build CLI syntax 2022-06-07 20:48:41 -04:00
tydeu
b6bce412a9 refactor: split lib and exe config from package 2022-06-07 16:48:55 -04:00
tydeu
431cdbb6b7 refactor: MainM code cleanup 2022-06-03 12:57:06 -04:00
tydeu
4bb5b407be refactor: split up DSL.Commands 2022-06-03 11:15:49 -04:00
tydeu
a815d29630 feat: __dir__/`__args__ syntax for config settings 2022-06-03 10:58:42 -04:00
tydeu
1c512bdf20 refactor: merge 'MonadLog and LogMethods` 2022-06-02 19:43:07 -04:00
tydeu
cf5fe7e478 refactor: some CLI code cleanup 2022-06-02 18:56:17 -04:00
tydeu
81ea5049af feat: caption process stdout and stderr
closes leanprover/lake#54
2022-06-01 18:09:39 -04:00
tydeu
c19417b86a feat: new require syntax for package deps 2022-06-01 16:26:39 -04:00
tydeu
94c48d2d29 refactor: cleanup runFrontend 2022-05-25 16:52:41 -04:00
Gabriel Ebner
b50f80c393 perf: cache imported environment 2022-05-25 13:13:38 -04:00
tydeu
55a2395db5 feat: retool configure into update
closes leanprover/lake#69
2022-05-24 13:57:30 -04:00
tydeu
85e3385aaa feat: only update deps in configure + don't ignore manifest.json
closes leanprover/lake#59, leanprover/lake#63
2022-05-23 20:38:54 -04:00
tydeu
c1b4074d54 fix: only write manifest if a package was resolved 2022-05-23 20:28:36 -04:00
tydeu
e8d59a7a6e feat: save resolved packages in a manifest
closes leanprover/lake#31
2022-05-23 19:47:29 -04:00
tydeu
10c444e5ef fix: include moreLeanArgs in module trace
closes leanprover/lake#50
2022-05-19 14:28:00 -04:00
tydeu
e24d6f1181 fix: include Lean version in binary trace
closes leanprover/lake#62
2022-05-19 11:34:01 -04:00
tydeu
9f333147f5 chore: start next Lake version 2022-05-16 11:28:12 -04:00
tydeu
7a499ee09b release: 3.0.1 2022-05-16 11:18:32 -04:00
tydeu
c03b388d6f chore: bump Lean version 2022-05-16 11:12:49 -04:00
Gabriel Ebner
a28c1da704 fix: do not call git checkout unless necessary
See leanprover/lake#63.
2022-05-15 16:13:14 -04:00
Gabriel Ebner
be570305fc perf: do not resolve full git object names 2022-05-15 16:13:14 -04:00
Gabriel Ebner
712b22b46f perf: do not import Lean.Elab.Frontend from Lake 2022-05-15 15:56:50 -04:00
tydeu
0fe9930d67 chore: update Lean version 2022-03-21 09:16:12 -04:00
Leonardo de Moura
2a4684a9ae chore: String.Pos is opaque now
See https://github.com/leanprover/lean4/issues/410

Remark: I did not try to fix the places where the code assumes all
characters have size 1. I marked them with `TODO`s
2022-03-21 09:14:54 -04:00
Sebastian Ullrich
bdd5185a7f fix: serve + print-paths without lakefile 2022-03-21 08:51:59 -04:00
Sebastian Ullrich
65d00098c7 chore: fix List.get use (leanprover/lake#56) 2022-02-16 13:21:33 -05:00
Gabriel Ebner
926a253680 fix: serve: fall back to lean --server on error 2022-02-04 17:30:47 -05:00
Leonardo de Moura
8c40a31573 chore: auto pure was removed 2022-02-03 21:32:27 -05:00
tydeu
0869780376 chore: start next Lake version 2022-02-03 01:24:28 -05:00
tydeu
17ac0d7f94 release: 3.0.0 2022-01-31 06:51:57 -05:00
tydeu
a9793b0a50 feat: add root package to workspace + and use it 2022-01-31 02:24:11 -05:00
tydeu
1c4b5ff3ac test: add package dependency diamond in deps example 2022-01-31 00:52:57 -05:00
tydeu
985bdcb4d0 fix: don't duplicate dep link targets in diamonds
closes  leanprover/lake#43
2022-01-31 00:52:37 -05:00
tydeu
30e3f10c6c chore: ilean code cleanup 2022-01-31 00:04:17 -05:00
Sebastian Ullrich
e6894c058b feat: create .ilean files 2022-01-30 23:46:08 -05:00
tydeu
bffcfde602 refactor: ModuleInfo -> Module 2022-01-30 23:16:08 -05:00
tydeu
705962847d fix: glob bugs + cleanup
closes leanprover/lake#42
2022-01-30 22:49:05 -05:00
Sebastian Ullrich
df1c1cde12 refactor: make LeanPaths usage forward-compatible (leanprover/lake#48) 2022-01-22 20:55:16 -05:00
tydeu
6d7fc7216c fix: get pkg for dep name not mod at buildDepOleans
Bug & fix first reported on Zulip: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Lake.20mathport.20panic
2022-01-18 19:56:23 -05:00
tydeu
2be2466f78 chore: bump Lean version 2022-01-17 15:00:01 -05:00
Leonardo de Moura
4ac34f4cd5 chore: rename PointedType => NonemptyType 2022-01-15 11:42:09 -08:00
tydeu
f3d8fcc85d test: don't check for lean-toolchain generation in init example 2022-01-15 11:35:40 -05:00
Leonardo de Moura
e880dd52a4 chore: PointedType 2022-01-14 20:41:47 -08:00
tydeu
752bc24f78 feat: add args to binary & .o file traces + some cleanup
closes leanprover/lake#41
2021-12-27 12:07:15 -05:00
tydeu
2680e1c66f refactor: generalize computeHash + cleanup 2021-12-27 12:00:09 -05:00
tydeu
5029f30b27 refactor: tweak collectArgs in Cli 2021-12-27 11:00:18 -05:00
tydeu
5102d21cc5 feat: expand script CLI into its own script command 2021-12-24 03:26:34 -05:00
tydeu
2b0989ea28 refactor:: simplify/improve CLI API 2021-12-23 23:43:01 -05:00
tydeu
c9128d1ce6 refactor:: separate build and scheduler monads 2021-12-23 16:25:15 -05:00
tydeu
d4e7e33652 feat: split Lake context from BuildContext and also use it in scripts 2021-12-22 00:39:36 -05:00
tydeu
1b96c466ca refactor: use new version info from Lean + cleanup 2021-12-19 21:59:17 -05:00
tydeu
9ac989f0c9 chore: bump Lean version 2021-12-19 21:47:46 -05:00
tydeu
adcf2df9b5 refactor: async API tweaks 2021-12-19 21:45:42 -05:00
tydeu
8fb9dd8478 fix: consider globbed files local
easiest way to fix mathport builds (for now)
2021-12-16 21:56:10 -05:00
tydeu
34bf090300 fix: build dep's extraDepTarget not root's for each dep 2021-12-16 01:03:21 -05:00
tydeu
d781c3411a feat: add getLeanSysroot and getLeanLibDir 2021-12-15 20:08:14 -05:00
tydeu
f9e789af45 refactir: revamp install path API 2021-12-15 13:44:28 -05:00
tydeu
a23c5feec4 chore: bump Lean version 2021-12-15 11:14:02 -05:00
tydeu
e37cde0def test: reorganize ffi example 2021-12-14 16:45:43 -05:00
tydeu
7199eea687 refactor: cleanup/improve Target utils 2021-12-14 14:12:43 -05:00
tydeu
50a84fcd55 test: add print-paths of dep modules check 2021-12-13 20:27:35 -05:00
tydeu
ac47b4fb01 refactor: remove Package from BuildContext 2021-12-13 19:53:45 -05:00
tydeu
8f4b203b2f refactor: include package in module info
fixes various issues with `lake print-paths` builds
2021-12-13 19:08:06 -05:00
tydeu
e054596cfa chore: bump Lean version 2021-12-13 10:59:53 -05:00
Leonardo de Moura
99bd215dcb chore: where struct instance parser
The parser was modified to fix issue https://github.com/leanprover/lean4/issues/753

cc @tydeu
2021-12-12 08:26:20 -08:00
tydeu
56bae17924 feat: also set LEAN_SYSROOT and LEAN_SRC_PATH with env 2021-12-11 18:19:30 -05:00
tydeu
8b66dbf285 refactor: use error in Load.lean 2021-12-11 17:53:31 -05:00
tydeu
197b8e5c1d feat: better error messages for missing CLI args 2021-12-11 16:47:28 -05:00
tydeu
f0ad325e09 feat: fallback to ar when llvm-ar is not bundled with Lean 2021-12-10 18:30:34 -05:00
Anders Christiansen Sørby
bec311bf48 chore: fix Nix setup (leanprover/lake#38) 2021-12-10 17:59:56 -05:00
Leonardo de Moura
0555e29808 chore: do cannot be used in pure code anymore
cc @tydeu
2021-12-10 13:18:27 -08:00
tydeu
1210589771 feat: build package and deps simultanously 2021-12-05 18:45:58 -05:00
tydeu
5edbd6cf59 refactor: use workspace olean dirs in module targets and print-paths 2021-12-04 16:24:30 -05:00
tydeu
50fa9a0b53 feat: resolve deps immediately and store them in workspace 2021-12-04 16:24:19 -05:00
tydeu
8e728b1159 refactor: split Package and Workspace 2021-12-04 12:58:00 -05:00
tydeu
052d6623f0 refactor: move misc utilities to Util.Extra 2021-12-04 11:27:38 -05:00
tydeu
b996117482 doc: mention options for a package's Git revision in README
closes leanprover/lake#37
2021-12-02 21:37:10 -05:00
tydeu
fcc3e3d93e chore: cleanup 2021-12-02 21:29:16 -05:00
tydeu
a7a980c12d refactor: remove unused branch parameter from Source.git 2021-12-02 21:25:53 -05:00
tydeu
1284616296 refactor: revamp Async API 2021-11-30 11:56:35 -05:00
tydeu
a1368df5c9 chore: fix docstring formatting 2021-11-26 23:47:36 -05:00
tydeu
4b062543ec refactor: simplify trace checking somewhat 2021-11-26 21:53:18 -05:00
tydeu
c830953ded feat: use Lean bundled ar by default for static libs
closes leanprover/lake#35
2021-11-26 18:44:00 -05:00
tydeu
aa524e977c chore: bump Lean version 2021-11-26 18:20:07 -05:00
ammkrn
a727a3de5c fix: syntax/mathlib name in dependencies example
Mathlib4 changed the package name to just `mathlib`. Trying to build
with a dependency name `mathlib4 will now cause an error.
2021-11-25 19:45:45 -05:00
Sebastian Ullrich
91620481a5 fix: adapt to Lean change 2021-11-25 10:01:20 -05:00
tydeu
ca6c5b8c5c feat: add lake env 2021-11-25 06:49:22 -05:00
tydeu
2092850b02 refactor: lake server -> lake serve 2021-11-25 05:29:47 -05:00
tydeu
63bd325b3b refactor: split build CLI into separate file 2021-11-25 04:58:33 -05:00
tydeu
ec8b351445 refactor: generalize some IO-related code
* add `def OptionIO := EIO PUnit`
* add `OptionIOTask` for `OptionIO`
* rename `BuildCoreM` -> `BuildIO`
* rename `Util.LogT` ->  `Util.Log`
* generalize `error` to `MonadError`
* generalize` Cli.build`
2021-11-25 03:22:11 -05:00
tydeu
bb2c720411 doc: fix mathlib link in README 2021-11-21 16:55:29 -05:00
tydeu
8a1e413d5a doc: update README
* Add dependency example (closes leanprover/lake#27)
* Move build instructions to bottom (closes leanprover/lake#28)
* Remove mention of  the `name` option (closes leanprover/lake#29)
* Correct `OpaqueTarget` guidance (closes leanprover/lake#30)
2021-11-20 20:26:23 -05:00
tydeu
0422c0d019 ci: trigger on all branches 2021-11-11 18:51:24 -05:00
tydeu
2be3a23b46 feat: use IO.appPath for exe in LakeInstall 2021-11-11 02:41:23 -05:00
tydeu
40b6ca82b3 fix: include libleanshared in Lean trace
closes leanprover/lake#26
2021-11-11 02:23:54 -05:00
tydeu
36b0d7b60c feat: store current Package in BuildM 2021-11-11 00:10:52 -05:00
tydeu
8d96c2cbe8 refactor: move Workspace/Script code to separate files 2021-11-10 18:46:31 -05:00
tydeu
94d899ad95 refactor: use supportInterpreter in lakefile 2021-11-09 23:43:55 -05:00
tydeu
4c9c0cae30 refactor: use liftExcept in Task.lean 2021-11-09 23:43:23 -05:00
tydeu
445f0db973 chore: bump Lean version 2021-11-09 23:25:36 -05:00
tydeu
331bf0f7f2 refactor: reorganize code folder structure 2021-11-09 22:55:21 -05:00
tydeu
ce7779890b chore: minor Task async code cleanup 2021-11-09 16:49:14 -05:00
tydeu
7bc00f9b29 refactor: generalize IOTask to EIOTask 2021-11-05 19:16:30 -04:00
tydeu
f48d9fccd9 refactor: replace RealM with BaseIO 2021-11-05 17:55:27 -04:00
tydeu
8dfd7fccfc feat: use lean --githash for Lean version checking 2021-11-05 16:22:11 -04:00
tydeu
eb73594ec0 chore: update Lean version 2021-11-05 15:35:46 -04:00
tydeu
8babf3fc70 doc: nclude --help option info in scripts docs 2021-11-05 15:22:57 -04:00
tydeu
57c7e42752 fix: make buildRec target wait for deps 2021-11-05 14:12:58 -04:00
tydeu
ffcf715f30 refactor: allow -h between command and args 2021-11-05 13:53:17 -04:00
tydeu
50dd829d90 feat: add docs for scripts + CLI code cleanup 2021-11-02 13:19:41 -04:00
tydeu
0b0afef09a refactor: split EIO UInt32 from Cli into its own MainM file 2021-11-02 11:23:04 -04:00
tydeu
763ac9a2e8 refactor: pipe proc output to logger 2021-11-02 07:20:29 -04:00
tydeu
182409e0f4 refactor: use LogT at Resolve.lean 2021-11-02 05:35:53 -04:00
tydeu
8a20cafebf chore: fix some overlooked docs 2021-10-29 19:04:21 -04:00
tydeu
ae43e5b2fb feat: add package shared library build / facet 2021-10-29 19:00:02 -04:00
tydeu
d518e3df5b refactor: properly manage errors in the build monad 2021-10-28 13:36:07 -04:00
tydeu
781672e935 refactor: generalize Await signature a little 2021-10-27 12:19:02 -04:00
tydeu
b0991cf96b refactor: cleanup Task code some 2021-10-24 22:04:08 -04:00
tydeu
29f6c0fb5a refactor: split logging from BuildM into its own monad 2021-10-24 17:46:28 -04:00
tydeu
333a86ef5f fix: typing mistakes with CliMethodsRef + cleanup 2021-10-24 17:34:40 -04:00
tydeu
e006f8534d feat: add supportInterpreter config setting
also don't use `--export-all` on Windows anymore
2021-10-23 16:16:09 -04:00
tydeu
168ec3d178 perf: cache lean exe trace in BuildM 2021-10-23 14:36:37 -04:00
tydeu
20788e8237 refactor: separate module olean and c traces 2021-10-23 14:02:31 -04:00
tydeu
74276dd024 refactor: update ofByteArray with new primitives
also rename `getFileHash` to `computeFileHash`
2021-10-23 11:34:01 -04:00
tydeu
521311292d chore: bump Lean version 2021-10-23 11:04:51 -04:00
tydeu
738425b0b1 ci: mssing $ 2021-10-20 16:46:03 -04:00
tydeu
29975edb0e ci: use matrix OS for build artifact name 2021-10-20 16:44:54 -04:00
tydeu
7cbde2c852 ci: switch back to homebrew on macOS 2021-10-19 11:36:36 -04:00
tydeu
c6f6eec4c5 fix; leanmake build 2021-10-19 11:30:24 -04:00
tydeu
aa3f453ebf refactor: cleanup trace code some 2021-10-18 19:38:32 -04:00
tydeu
ffd5bc0f69 refactor: narrow Lean imports 2021-10-18 18:01:31 -04:00
tydeu
bfedab0f9b feat: build C files in print-paths if facet is not oleans 2021-10-18 15:21:43 -04:00
tydeu
4d66b6e4e2 fix: ci: don't use hombrew for MacOS (for now)
Reason: it is missing `lake` (see https://github.com/Homebrew/homebrew-core/pull/87486)
2021-10-18 13:40:50 -04:00
tydeu
44cc860c82 fix: ci: use elan's lake to build (for now)
Reason: `leanmake` build is broken due to bad dep inference
2021-10-18 13:27:58 -04:00
tydeu
53ad51e984 fix: correct the lake lib location of a co-located lake and lean 2021-10-18 12:39:30 -04:00
tydeu
e9443705d5 feat: include hash of lean in module traces
closes leanprover/lake#23
2021-10-18 12:11:56 -04:00
tydeu
d9f53dfec9 refactor: replace leanpkg.toml with a lakefile.lean + build reorg 2021-10-17 13:52:01 -04:00
tydeu
b558536129 feat: add basic lake server CLI 2021-10-13 15:31:49 -04:00
tydeu
4eec17c876 chore: use return at examples/scripts 2021-10-13 14:47:57 -04:00
tydeu
1074aaa5fa chore: fix hasModule error message at parseTargetBaseSpec 2021-10-10 12:52:49 -04:00
tydeu
b8b3f01c96 feat: add option to specify the lean used by Lake
also:
* support `=` for long CLI options
* cleanup some typos in `InstallPath`
2021-10-10 12:37:00 -04:00
tydeu
15a2981804 feat: new build CLI 2021-10-09 19:24:28 -04:00
tydeu
88af2ca4b7 refactor: reorg build package code 2021-10-09 18:48:53 -04:00
tydeu
d494626de6 chore: use Json.compress at print-paths
Reason: server expects JSON to be a single line
2021-10-09 12:04:08 -04:00
tydeu
ae01b5d586 chore: use c++ not cc at examples/fffi 2021-10-09 11:26:21 -04:00
tydeu
8635ce279b refactor: use LeanPaths in print-paths 2021-10-08 21:00:42 -04:00
tydeu
b2822ffab1 chore: bump Lean version 2021-10-08 20:58:53 -04:00
tydeu
427cb0fc7c feat: add inputFileTarget util 2021-10-08 15:26:07 -04:00
tydeu
85efdb159a test: expand examples/ffi to use getLeanIncludeDir 2021-10-08 15:20:23 -04:00
tydeu
8a06d4f529 feat: introduce Workspace which is shared across a pkg and its deps 2021-10-08 14:09:05 -04:00
tydeu
7a3aadd005 feat: add utils for constructing file targets with deps 2021-10-08 12:58:10 -04:00
tydeu
b3b7aa02d1 fix: wait for deps to build on a bare print-paths 2021-10-07 18:30:52 -04:00
tydeu
2e5c7c02f1 refactor: CLI code tweaks 2021-10-07 14:59:00 -04:00
tydeu
1d20cbd3d6 refacttor: check LEAN_SYSROOT rather than LEAN_HOME for Lean 2021-10-07 14:04:18 -04:00
tydeu
9700208501 feat: have print-paths exit silently with code 2 if config missing 2021-10-07 12:40:26 -04:00
tydeu
6cfbd90426 refactor: always pass -O3 and -DNDEBUG when building Lean o files
also add `more` prefix to `leanArgs`/`leancArgs`/`linkArgs`

closes leanprover/lake#19
2021-10-06 21:07:56 -04:00
tydeu
e171925991 chore: update Lean version
fixes leanprover/lake#21
2021-10-06 20:43:36 -04:00
tydeu
0e7a2bae8e refactor: clean up CLI code some 2021-10-06 20:06:03 -04:00
tydeu
429386c4c0 refactor: update print-paths JSON format to match server 2021-10-06 17:52:22 -04:00
tydeu
0f2d6c7fdd feat: use detected Lean install to build packages 2021-10-06 17:38:57 -04:00
tydeu
c32cd22504 feat: store detected Lean/Lake install in BuildContext
includes new `getLeanIncludeDir` for `BuildM` (leanprover/lake#18)
2021-10-06 17:01:52 -04:00
tydeu
0196cbe6a3 refactor: move build execution into CLI 2021-10-06 16:27:49 -04:00
tydeu
93cc196b10 chore: minor code cleanup 2021-10-06 15:22:19 -04:00
tydeu
3bcd18a1c6 refactor: generalize Lean/Lake installation detection 2021-10-05 20:00:30 -04:00
tydeu
4c0734b5f1 feat: use hash traces for o file, static lib, and bin targets
Also rename `.hash` file to `.trace` and add a `package-bootstrap` make job
2021-10-04 19:08:22 -04:00
tydeu
ae144112be refactor: generalize checkModuleTrace 2021-10-04 18:30:24 -04:00
tydeu
e906f39201 refactor: cleanup Compile.lean 2021-10-04 17:51:47 -04:00
tydeu
a9b87adbeb feat: print-paths as a JSON object 2021-10-04 12:50:57 -04:00
tydeu
b2acab81d4 refactor: output print-paths build info to stderr 2021-10-04 12:27:14 -04:00
tydeu
3ab3b69293 chore: minor ccide leanup 2021-10-04 12:25:40 -04:00
tydeu
5b0e264f8c feat: promote scripts from PackageConifg to top level commands 2021-10-03 21:38:22 -04:00
tydeu
583b534e6c refactor: simplify / reorder LeanConfig 2021-10-03 21:20:52 -04:00
tydeu
0ede8f2c4c chore; minor doc cleanup 2021-10-03 17:09:30 -04:00
tydeu
8852c5e236 feat: use an attribute to identify packages in lakefile 2021-10-03 14:13:49 -04:00
tydeu
50f70712a8 feat: add name to package DSL signature 2021-10-03 13:31:09 -04:00
tydeu
3b28d24319 refactor: make package name a Name 2021-10-03 12:42:24 -04:00
tydeu
d533606a86 chore: update examples/git URL 2021-10-03 00:01:56 -04:00
tydeu
557adf9ffc refactor: default binRoot to Main and expand init code 2021-10-02 23:41:55 -04:00
tydeu
0f5dd30880 refactor: use an Array for package depedencies 2021-10-02 21:48:23 -04:00
tydeu
7197f60d9c fix: do not resolve the same dependency multiple times 2021-10-02 21:33:08 -04:00
tydeu
3d76e48181 fix: do not build deep deps multiple times 2021-10-02 16:11:53 -04:00
tydeu
cfc8a2538d refactor: generalize buildTop and failOnImportCycle
Reason: will be useful for upcoming dependency build fix
2021-10-02 14:21:45 -04:00
tydeu
83ccf8a15d test: extend examples/deps to include a deep dependency 2021-10-01 21:23:31 -04:00
tydeu
f187761c2e chore: bump Lean version
Reason: fixes `leanc` on Linux
2021-10-01 21:20:45 -04:00
tydeu
a8d5348f4f chore: bump Lean version
Reason: 816dc1895f may be of use to Lake
2021-09-30 20:56:34 -04:00
tydeu
fe87b064a2 feat: for most CLI commands, error when given more args than expected 2021-09-30 20:37:18 -04:00
tydeu
a21274c302 refactor: make return code part of the CLI + have scripts return code 2021-09-30 20:36:21 -04:00
tydeu
526e6e223e refactor: throw error on build failure
Reason:  `lake` will now exit with code 1 rather than 0 on build failure
2021-09-30 19:24:37 -04:00
tydeu
8cd7efb2d8 chore: post PR cleanup 2021-09-30 16:25:58 -04:00
Anders Christiansen Sørby
cadc812608 feat: add a Nix flakes build setup 2021-09-30 16:13:58 -04:00
tydeu
2b8f0f768c chore: use lake clean for examples/hello 2021-09-30 15:56:46 -04:00
tydeu
628e5e2818 fix: only call removeDirAll if path exists 2021-09-30 15:50:22 -04:00
tydeu
3abf53d196 chore: just build bin in examples/bootstrap
Reason: `bin` now imports the entire `Lake` lib so this is unecessary
2021-09-30 02:20:41 -04:00
tydeu
3b78652547 refactor: prefer build rather than fetch terminology 2021-09-27 02:50:45 -04:00
tydeu
032be7ee2e refactor: generalize buildRBTop 2021-09-27 02:40:24 -04:00
tydeu
a093a38459 refactor: rename package.lean to lakefile.lean 2021-09-26 18:52:31 -04:00
tydeu
6a9997c7ad chore: -O3 not -03 2021-09-25 23:59:13 -04:00
tydeu
ff1e63c719 refactor: default leancArgs to -03, -DNDEBUG (like leanpkg) 2021-09-25 23:57:31 -04:00
tydeu
3f534e1155 refactor: use DSL in examples 2021-09-25 23:53:34 -04:00
tydeu
2e5b4d2221 feat: add simple DSL for package configurations 2021-09-25 23:40:31 -04:00
tydeu
63ad2d7765 chore: bump to v3.0.0-pre 2021-09-25 22:59:15 -04:00
tydeu
a9c0210ef3 refactor: use import Lake in package configurations 2021-09-25 19:36:00 -04:00
tydeu
efadebd5ef refactor: move main into Lake.Main which is not imported by Lake 2021-09-25 19:18:10 -04:00
tydeu
1d052a1b39 fix: update examples/git commit hash 2021-09-25 18:38:42 -04:00
tydeu
4af8135172 refactor: remove the package version field
Reason: It is unused. See https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.5BRFC.5D.20name.2Fversion.20package.20fields/near/254114011 for more discussion of topic.
2021-09-25 18:31:33 -04:00
tydeu
ba8067f3bd refactor: don't use globs to determine local modules + cleanup
Reasion: globs should be submodules of the roots
2021-09-24 01:11:29 -04:00
tydeu
0f0ea57ef5 chore: some cleanup and reorg 2021-09-23 23:12:51 -04:00
tydeu
5b37f1c5c5 feat: split moduleRoot into libRoots and libGlobs
Reason: provide finer grain control over library modules
2021-09-23 21:04:29 -04:00
Mario Carneiro
5007ceae69 feat: add module Glob API 2021-09-23 11:33:10 -04:00
tydeu
6d4360a04d release: 2.1.0 2021-09-22 15:43:07 -04:00
tydeu
194247bb32 chore: bump Lean version 2021-09-22 12:19:51 -04:00
Sebastian Ullrich
abd617b9a5 test: use $LAKE everywhere 2021-09-21 12:17:27 -04:00
tydeu
dfa959ba30 test: add clean* targets to Makefile
closes leanprover/lake#13
2021-09-20 18:14:50 -04:00
Sebastian Ullrich
9b80f69e54 chore: add proper shebang to build.sh & port to sh 2021-09-20 12:53:55 -04:00
tydeu
b4150f61c7 chore: cleanup fromLeanFileUnsafe code 2021-09-19 23:41:14 -04:00
tydeu
1432bd91bb chore: fix ffi-dep shell script permissions 2021-09-19 20:09:56 -04:00
tydeu
9bdd0202b7 test: add ffi-dep example and fix ffi example
see leanprover/lake#8
2021-09-19 20:01:55 -04:00
tydeu
1c0c5a84a4 refactor: merge rootDir into srcDir 2021-09-19 19:59:07 -04:00
tydeu
06a6b9a88c feat: add pure Packager variant 2021-09-19 19:58:30 -04:00
tydeu
9f90c9bb66 feat: don't overwite existing files on init + test
closes leanprover/lake#10
2021-09-17 16:26:25 -04:00
tydeu
fdb9915bcc feat: print usage on bare lake
closes  leanprover/lake#9
2021-09-17 14:54:33 -04:00
tydeu
4b7a98bc38 chore: replace removeDirAll with the proper function 2021-09-16 21:48:21 -04:00
tydeu
b158f1fd8b chore: bump Lean version 2021-09-16 21:43:21 -04:00
tydeu
50a23a3aa5 refactor: print last error message on build failure + cleanup 2021-09-16 18:36:07 -04:00
tydeu
6a3d299378 fix: log trace computation errors at FileTarget
resolves leanprover/lake#7
2021-09-16 18:33:38 -04:00
tydeu
8b83d80956 chore: add mising (Active)Target.with* utilities 2021-09-16 17:03:15 -04:00
tydeu
bf4db86bdd feat: search path now first checks IO.appPath for lean 2021-09-16 16:26:06 -04:00
tydeu
b4dcad59fa test: add alternate binRoot example (called main) 2021-09-16 15:13:11 -04:00
tydeu
3c1185dc9c chore: document package configuration + other minor cleanup 2021-09-16 07:49:56 -04:00
tydeu
f39b1b8378 chore: remove unused MonadLiftT Id instance 2021-09-14 11:18:16 -04:00
tydeu
dd120dbc5a feat: use lean-toolchain file to specify Lean version for package 2021-09-13 15:57:33 -04:00
tydeu
276163afd7 chore: bump to v2.1.0-pre 2021-09-13 15:48:26 -04:00
tydeu
c97eac1e82 release: 2.0.1 2021-09-13 14:57:20 -04:00
tydeu
9285fb6f1d chore: update Lean version 2021-09-13 14:52:19 -04:00
tydeu
58eff66799 chore: merge build-*.sh into build.sh + cleanup README 2021-09-13 14:34:56 -04:00
tydeu
ce46960416 ci: continue even if build upload fails 2021-09-13 13:48:02 -04:00
tydeu
8e8ea4da33 ci: add GitHub Actions workflow 2021-09-13 13:34:03 -04:00
tydeu
eca73809e6 chore: bin/Hello -> bin/hello 2021-09-13 13:28:54 -04:00
tydeu
e3ec2b9e39 chore: revert casing change and instead output lower-cased bin 2021-09-13 13:21:35 -04:00
tydeu
4e61320225 chore: bin/lake -> bin/Lake
Reason: casing matters on Linux
2021-09-13 12:55:36 -04:00
tydeu
e441c40a3d chore: fix typo in Makefile 2021-09-13 12:52:37 -04:00
tydeu
60c749ab1d test: tweak & expand test Makefile 2021-09-13 12:22:11 -04:00
tydeu
0188eb84df chore: add .gitattributes file 2021-09-13 11:55:02 -04:00
tydeu
5caa12c0b0 chore: fix shell script permissions 2021-09-13 11:40:05 -04:00
tydeu
69102b1812 feat: add Hash/MTime -> BuildTrace Coe instances 2021-09-13 09:54:36 -04:00
tydeu
8d3e72d742 release: 2.0 2021-09-05 20:17:23 -04:00
tydeu
f1865d4290 test: remove meanigful version information from bootstrap test 2021-09-05 20:15:46 -04:00
tydeu
22ee974ac8 chore: bump Lean version 2021-09-05 20:04:44 -04:00
tydeu
103e8ab61c test: convert examples' main test.sh into a Makefile 2021-09-05 19:54:39 -04:00
tydeu
f92afee9b4 fix: args bug with CLI 2021-09-05 19:47:13 -04:00
tydeu
d6d395619f chore: cleanup solveDeps 2021-09-05 19:03:41 -04:00
tydeu
09af870b71 feat: add config option for separate binary module root 2021-09-05 19:01:09 -04:00
tydeu
8601c0fe78 refactor: purify BuildModule somewhat + associated cleanup 2021-09-05 18:05:45 -04:00
tydeu
6863bb8095 refactor: ModuleTarget -> ActiveModuleTarget 2021-09-05 16:30:28 -04:00
tydeu
4b9a765cfb refactor PackageTarget -> ActivePackageTarget 2021-09-05 16:29:18 -04:00
tydeu
d4ba706198 refactor: purify BuildBin.lean 2021-09-05 15:37:16 -04:00
tydeu
92696d48f6 feat: use olean instead of lean hash for module targets 2021-09-05 01:01:40 -04:00
tydeu
720ecbd568 refactor: more cleanup (primarly Trace.lean) 2021-09-05 00:31:23 -04:00
tydeu
7129433066 fix: typo in foldArrayAsync 2021-09-04 20:41:03 -04:00
tydeu
3e1cdda87e refactor: make PackageConfig take normal targets 2021-09-04 18:53:21 -04:00
tydeu
0a3457e973 refactor: minor cleanup / tweaks 2021-09-04 18:41:20 -04:00
tydeu
dba37698c8 refactor: rename LakeTrace to BuildTrace 2021-09-04 17:49:08 -04:00
tydeu
80416677d8 refactor: compute trace duing build 2021-09-04 17:45:56 -04:00
tydeu
2d3bec2209 feat: add proper CLI 2021-08-22 11:17:18 -04:00
tydeu
1825e095e1 refactore: rename ModuleM 2021-08-22 03:51:44 -04:00
tydeu
332af4c262 refactor: check hash after verifying module artifact exists 2021-08-22 03:40:09 -04:00
tydeu
4ce8716b99 feat: build and print-paths now build only oleans 2021-08-22 03:23:43 -04:00
tydeu
ac1cc9e62c chore: cleanup 2021-08-22 03:06:33 -04:00
tydeu
80a9685164 refactor add ModuleTargetMap abbreviation 2021-08-22 00:16:18 -04:00
tydeu
ce1ee3c36d refactor: move build failed message into runBuild 2021-08-22 00:07:17 -04:00
tydeu
43d1dfe72c refactor: cleanup opaque target interfaces 2021-08-21 23:52:34 -04:00
tydeu
c843f0b112 chore: cleanup 2021-08-21 22:43:27 -04:00
tydeu
64634dbc32 refactor: change target abstraction (again) 2021-08-21 21:05:52 -04:00
tydeu
d12c4241bf fix: use BuildM in PackageConfig 2021-08-21 20:17:48 -04:00
tydeu
56a78f6eeb feat: use deps' extra lib targets when building parent bin 2021-08-20 01:48:10 -04:00
tydeu
8f7e32d09a refactor: add build monad 2021-08-19 23:21:23 -04:00
tydeu
a371e181d5 refactor: more API tweaks 2021-08-19 12:13:29 -04:00
tydeu
8b74108f6e refactor: remove FilesTarget 2021-08-19 12:05:44 -04:00
tydeu
28320f80ee refactor: minor API tweaks 2021-08-19 12:05:28 -04:00
tydeu
0bfebc1975 refactor: reorganize Async.lean 2021-08-18 21:30:41 -04:00
tydeu
f9d6f57725 refactor: split Build into BuildModule and BuildPackage 2021-08-18 14:46:54 -04:00
tydeu
66a6246136 chore: fix typo 2021-08-18 12:48:58 -04:00
tydeu
81a84d21de feat: add command to verify Lean version 2021-08-17 11:24:32 -04:00
tydeu
dd6634544d misc: add shell scripts for timing Lake builds 2021-08-17 10:34:18 -04:00
tydeu
31abd420ad chore: update Lean version
Some examples (ex. `hello`) may now segfault. See https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Problems.20when.20updating.20Lean/near/249599195.
2021-08-17 10:33:15 -04:00
tydeu
d49c64453d refactor: build with leanmake instead of leanpkg 2021-08-16 09:23:51 -04:00
tydeu
f977ee8b34 refactor: improve async abstraction 2021-08-15 20:41:55 -04:00
tydeu
2757e844dd refactor: add trace abstraction 2021-08-15 20:13:17 -04:00
tydeu
c8b558a2d1 refactor: remove 'build' from Target/Trace/Task file names 2021-08-15 19:16:12 -04:00
tydeu
ddf02cb339 refactor: merge build target into lake target 2021-08-15 19:04:28 -04:00
tydeu
23dd052dc9 refactor: remove BuildTask 2021-08-15 17:14:13 -04:00
tydeu
c1f61d6716 feat add config setting for specificying extra lib targets 2021-08-15 16:12:45 -04:00
tydeu
4f75dd99d1 reefactor: improve async API 2021-08-09 05:04:38 -04:00
tydeu
d0fbc93143 refactor: improve Hash traces 2021-08-06 01:58:41 -04:00
tydeu
609ee22971 refactor: LeanTrace/Target -> LakeTrace/Target 2021-08-06 01:17:17 -04:00
tydeu
81d7511792 refactor: post-async Target API touch-ups 2021-08-06 00:44:46 -04:00
tydeu
859b04bf7f refactor: generalize Target/ActiveTarget beyond IO 2021-08-05 00:45:50 -04:00
tydeu
aa1ca9c4b7 feat: improve Target API 2021-08-04 14:07:28 -04:00
tydeu
a541f2054e refactor: IO BuildTarget task / protect pure 2021-08-04 01:31:47 -04:00
tydeu
ba52b36ef8 chore: more code cleanup 2021-08-01 18:46:48 -04:00
tydeu
3643b8e424 refactor: make Task and task a monad 2021-08-01 18:46:33 -04:00
tydeu
6a6afcd7c0 refactor: spawn ActiveBuildTarget from BuildTarget 2021-08-01 16:50:53 -04:00
tydeu
b8e85f40cd refactor: move afterTarget* into ActiveBuildTarget 2021-08-01 15:40:11 -04:00
tydeu
2d78f4db36 feat: add non-activve targets 2021-08-01 15:17:43 -04:00
tydeu
a52d95b575 refactor: ActiveBuildTarget.buildTask -> task 2021-08-01 14:27:11 -04:00
tydeu
1f51241a8e chore: minor code cleanup 2021-08-01 14:08:00 -04:00
tydeu
293c19d24f feat: include Lean version in Lake usage header 2021-07-31 19:29:26 -04:00
tydeu
448cac6804 chore: bump Lean version 2021-07-28 16:30:48 -04:00
tydeu
ce1f2f4964 feat: add lake clean command 2021-07-28 14:01:44 -04:00
tydeu
d8ac18a807 refactor: add buildDir setting and make bin/lib/ir subdirs of it 2021-07-28 12:23:37 -04:00
tydeu
cce0b3cce5 refactor: minor example tweaks 2021-07-28 10:30:36 -04:00
tydeu
f06b1bbb5c test: add bootstrap example 2021-07-28 10:20:42 -04:00
tydeu
38b260d60f feat: setting to specify alt root dir for package 2021-07-28 09:52:08 -04:00
tydeu
1b5b4edec6 fix: throw error if external process fails 2021-07-28 09:43:38 -04:00
tydeu
29e75cedc6 refactor: add lean_packages to initial package .gitignore 2021-07-28 09:19:40 -04:00
tydeu
91d3df58cd test: add git example 2021-07-28 09:10:14 -04:00
tydeu
bc8c39e802 feat: can depend on subdirectories of dependencies 2021-07-28 09:08:39 -04:00
tydeu
4ae14ac849 refactor: rename 'ext' example to 'ffi' 2021-07-27 07:24:45 -04:00
tydeu
1dabd00d4c test: add new/init example/test 2021-07-26 07:48:49 -04:00
tydeu
bea059796f fix: init git repo in package dir
Fixes leanprover/lake#1
2021-07-26 07:46:41 -04:00
tydeu
b730aacbc8 refactor: BuildTagret -> ActiveBuildTarget 2021-07-24 09:23:46 -04:00
tydeu
0dfd07ed9d chore: add ext example to examples test 2021-07-24 09:08:43 -04:00
tydeu
54bdf64d25 test: add simple extension example 2021-07-24 08:40:46 -04:00
tydeu
0d288b9bd3 feat: add MTimeBuildTarget -> LeanTarget function 2021-07-24 08:40:33 -04:00
tydeu
5770529e09 feat: add non-leanc compile o/bin functions 2021-07-24 08:08:36 -04:00
tydeu
c3e602cedf refactor: moreDepsTarget -> buildMoreDepsTarget 2021-07-24 07:37:39 -04:00
tydeu
67341f478d refactor:: move some magic constants into defs 2021-07-24 07:36:58 -04:00
tydeu
53b95fb455 fix: actually use lib name in the file name 2021-07-17 13:28:40 -04:00
tydeu
81cb2f6ca8 refactor: use modToFilePath in srcRoot and oleanRoot 2021-07-17 13:27:33 -04:00
tydeu
e99d7aab95 refactor: default libName to moduleRoot and don't escape it 2021-07-17 13:09:23 -04:00
tydeu
9e5505b6ca feat: add new and run commands 2021-07-17 13:02:39 -04:00
tydeu
93c9543976 feat: add convenience functions for constructing a LeanTrace 2021-07-15 13:04:31 -04:00
tydeu
b14eef6e06 refactor: split out top / lib / bin build from Build.lean 2021-07-15 12:50:54 -04:00
tydeu
3b2c91f396 refactor: functions for building a specified module root 2021-07-15 12:40:23 -04:00
tydeu
f8a31011a6 feat: add more package configuration settings 2021-07-15 12:21:52 -04:00
tydeu
31fa37dbfe refactor: remove Monad Task instance (for now) 2021-07-14 14:53:52 -04:00
tydeu
e040804678 refactor: split task and trace from target into separate files 2021-07-14 13:35:42 -04:00
tydeu
3ef381bb6c refactor: merge Proc into Compile and cleanup Build 2021-07-14 12:46:07 -04:00
tydeu
758021f03a feat: add hash checking for builds 2021-07-13 20:11:15 -04:00
tydeu
115fdbea98 refactor: simplify mtime checking code 2021-07-13 16:18:42 -04:00
tydeu
4844f8c459 refactor: once again use to lean target mtime in fetch 2021-07-13 13:40:05 -04:00
tydeu
511f34fd53 refactor: simplify Compile.lean 2021-07-12 21:15:08 -04:00
tydeu
c08812e9e1 refactor: merge fetchLeanTarget into fetchAfterDirectLocalImports 2021-07-12 19:40:37 -04:00
tydeu
3b3beec0d4 refactor: clean up buildRBTop and related code 2021-07-11 19:00:51 -04:00
tydeu
d4e3a4f79e fix: bin build now properly waits for dep libs 2021-07-10 23:02:31 -04:00
tydeu
3ad82dcc42 chore: minor code cleanup 2021-07-10 22:40:34 -04:00
tydeu
b290c1ad28 refactor: generalized buildModule and cleaned up `printPaths 2021-07-10 21:19:01 -04:00
tydeu
70d258049e refactor: generalize mtime checking 2021-07-10 16:01:18 -04:00
tydeu
6161d7f2d9 refactor: generalize BuildTarget traces 2021-07-10 13:39:51 -04:00
tydeu
9ce5fa6a6d refactor: generalize build error catching 2021-07-10 13:04:18 -04:00
tydeu
1ccebe9b89 chore: improve shell scripts 2021-07-10 12:36:13 -04:00
tydeu
d1674a6ba0 refactor: rename helloDeps test to deps 2021-07-10 12:23:20 -04:00
tydeu
9da32ce7eb chore: add Packager test 2021-07-10 12:21:52 -04:00
tydeu
042353d862 feat: allow cli arguments to be passed to package.lean 2021-07-10 12:03:49 -04:00
tydeu
16534d3be6 chore: update Lean version 2021-07-09 21:03:16 -04:00
tydeu
ea4cbfae73 feat: deps build in parallel + lib/bin check mtime 2021-07-09 20:49:39 -04:00
tydeu
f97f69b749 refactor: BuildInfo -> BuildTarget 2021-07-09 00:36:46 -04:00
tydeu
a4622f61ca doc: update help command text 2021-07-08 20:58:25 -04:00
tydeu
981db940e8 feat: build packages without make 2021-07-08 19:46:10 -04:00
tydeu
9034b6b79b chore: bump to v2.0-pre 2021-07-08 17:42:17 -04:00
Mac Malone
22dc542445 Release 1.0 2021-06-14 01:42:16 -04:00
Mac Malone
9aa78a5361 More README edits 2021-06-14 01:36:19 -04:00
Mac Malone
f7a858c0de Add search path heading to README 2021-06-14 01:08:35 -04:00
Mac Malone
b7b0217241 Bump Lean version 2021-06-14 01:08:05 -04:00
Mac Malone
2aa3c1e0cb Add test script to hello example 2021-06-14 00:29:09 -04:00
Mac Malone
4532901112 Refactor helloDeps example to have two deps 2021-06-12 22:28:59 -04:00
Mac Malone
9138d37781 Fix dep lib separator 2021-06-12 22:27:19 -04:00
Mac Malone
c0d9917f7c Update to Lean nightly 06-13 2021-06-12 22:01:17 -04:00
Mac Malone
f512a9a934 Auto link dep libs for bin (+ more pkg path helpers) 2021-06-12 21:34:34 -04:00
Mac Malone
ecfd65ffb7 Clean up buildModule code and integrate cycle fix 2021-06-12 20:00:07 -04:00
Mac Malone
93f5368162 Rename build state/result to BuildState/BuildResult 2021-06-11 17:15:31 -04:00
Mac Malone
9b1d958f9c Fixed a typo in the README 2021-06-08 17:40:02 -04:00
Mac Malone
68f0eb16bd Minor LeanConfig code cleanup 2021-06-08 17:18:27 -04:00
Mac Malone
6fad405294 Intelligently initialize Lean search path 2021-06-08 17:17:58 -04:00
Mac Malone
7791b49be9 Add shell scripts for building Lake and its examples 2021-06-07 22:23:54 -04:00
Mac Malone
96870779a2 Add Lake build/run instructions to README 2021-06-07 17:03:51 -04:00
Mac Malone
af7e167dea Bump to v1.0-pre 2021-06-07 06:00:18 -04:00
Mac Malone
8c39a65609 Move .lake-lock into the build directory 2021-06-07 05:55:13 -04:00
Mac Malone
c5c46798fb Extend README 2021-06-07 05:46:08 -04:00
Mac Malone
6fc398133d Rename Leanpkg2 to Lake 2021-06-07 05:42:42 -04:00
Mac Malone
12537427c2 Fix some errors when running leanpkg2 in executable form 2021-06-07 05:30:17 -04:00
Mac Malone
7770d4b421 Removed leftover hack for TOML 2021-06-07 02:38:23 -04:00
Mac Malone
76183aa6d1 Remove TOML code 2021-06-06 23:30:32 -04:00
Mac Malone
0f6b07e434 Remove unused examples/helloDeps/a/leanpkg.toml 2021-06-06 23:06:19 -04:00
Mac Malone
2ba39f56f0 The solved dependency list no longer includes the root package 2021-06-06 23:04:52 -04:00
Mac Malone
6317ab22e7 Only build dependency lib if bin is passed to leanpkg buld 2021-06-06 22:50:40 -04:00
Mac Malone
99d458c646 Update init to produce package.lean 2021-06-06 21:56:58 -04:00
Mac Malone
d066872549 CLI now uses configuration from package.lean' 2021-06-06 21:40:11 -04:00
Mac Malone
8efd56d131 Properly lowercase Package.lean configurations 2021-06-06 19:33:12 -04:00
Mac Malone
6b999dcb21 Refactored away the old notion of a manifest 2021-06-06 19:27:18 -04:00
Mac Malone
3cc0c3e370 Package.lean => package.lean 2021-06-06 16:09:26 -04:00
Mac Malone
07e804ad16 Cleanup TOML manifest code 2021-06-03 16:58:55 -04:00
Mac Malone
3ca6b0bf51 Minor code style cleanup 2021-06-03 15:17:46 -04:00
Mac Malone
bf15f71568 Removed Manifest.path 2021-06-02 18:55:47 -04:00
Mac Malone
158838bf63 Fix local depdir calculation 2021-06-02 18:25:30 -04:00
Mac Malone
9544f3dad8 Refactor materlize / git code 2021-06-02 18:19:31 -04:00
Mac Malone
f2041789b7 Renamed Manifest.lean to Pakcage.lean 2021-06-02 16:02:22 -04:00
Mac Malone
d5d8ff588a Solver now returns Package 2021-06-02 15:21:36 -04:00
Mac Malone
a462864d78 Add cleaner script for 'helloDeps' example 2021-06-02 15:21:07 -04:00
Mac Malone
436d3213de Now built off Lean master 2021-05-30 17:30:33 -04:00
Mac Malone
543656c24b Merge Configure into Build 2021-05-29 22:57:24 -04:00
Mac Malone
ef0135ac9e Add working example expackage with a (local) dependency 2021-05-29 21:29:33 -04:00
Mac Malone
44b9ad2a30 Assorted code cleanup and reogranization 2021-05-29 12:42:05 -04:00
Mac Malone
ea9382643e Builds with buildModules now work as well 2021-05-29 11:27:31 -04:00
Mac Malone
82b368e838 Add README 2021-05-29 09:07:48 -04:00
Mac Malone
84ae7466a4 Update Authors 2021-05-29 09:07:42 -04:00
Mac Malone
93732bc7db Add LICENSE 2021-05-29 09:02:26 -04:00
Mac Malone
404d32c730 Port over Leanpkg and get an example building 2021-05-29 08:54:48 -04:00
Mac Malone
a24d7d593a Initial Commit 2021-05-28 17:13:55 -04:00
6500 changed files with 279399 additions and 40387 deletions

3
.gitattributes vendored
View File

@@ -1,3 +1,6 @@
*.lean text eol=lf
*.expected.out -text
RELEASES.md merge=union
stage0/** binary linguist-generated
# The following file is often manually edited, so do show it in diffs
stage0/src/stdlib_flags.h -binary -linguist-generated

View File

@@ -1,30 +0,0 @@
### Prerequisites
* [ ] Put an X between the brackets on this line if you have done all of the following:
* Checked that your issue isn't already [filed](https://github.com/leanprover/lean4/issues).
* Reduced the issue to a self-contained, reproducible test case.
### Description
[Description of the issue]
### Steps to Reproduce
1. [First Step]
2. [Second Step]
3. [and so on...]
**Expected behavior:** [What you expect to happen]
**Actual behavior:** [What actually happens]
**Reproduces how often:** [What percentage of the time does it reproduce?]
### Versions
You can get this information from copy and pasting the output of `lean --version`,
please include the OS and what version of the OS you're running.
### Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.

51
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,51 @@
---
name: Bug report
about: Create a bug report
title: ''
labels: bug
assignees: ''
---
### Prerequisites
Please put an X between the brackets as you perform the following steps:
* [ ] Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues
* [ ] Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries.
* [ ] Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
### Description
[Clear and concise description of the issue]
### Context
[Broader context that the issue occurred in. If there was any prior discussion on [the Lean Zulip](https://leanprover.zulipchat.com), link it here as well.]
### Steps to Reproduce
1.
2.
3.
**Expected behavior:** [Clear and concise description of what you expect to happen]
**Actual behavior:** [Clear and concise description of what actually happens]
### Versions
[Output of `#version` or `#eval Lean.versionString`]
[OS version, if not using live.lean-lang.org.]
### Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
### Impact
Add :+1: to [issues you consider important](https://github.com/leanprover/lean4/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). If others are impacted by this issue, please ask them to add :+1: to it.

26
.github/ISSUE_TEMPLATE/rfc.md vendored Normal file
View File

@@ -0,0 +1,26 @@
---
name: Request for comments
about: Create a feature proposal
title: 'RFC: '
labels: RFC
assignees: ''
---
### Proposal
Clear and detailed description of the proposal. Consider the following questions:
- **User Experience**: How does this feature improve the user experience?
- **Beneficiaries**: Which Lean users and projects benefit most from this feature/change?
- **Maintainability**: Will this change streamline code maintenance or simplify its structure?
### Community Feedback
Ideas should be discussed on [the Lean Zulip](https://leanprover.zulipchat.com) prior to submitting a proposal. Summarize all prior discussions and link them here.
### Impact
Add :+1: to [issues you consider important](https://github.com/leanprover/lean4/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). If others benefit from the changes in this proposal being added, please ask them to add :+1: to it.

21
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,21 @@
# Read this section before submitting
* Ensure your PR follows the [External Contribution Guidelines](https://github.com/leanprover/lean4/blob/master/CONTRIBUTING.md).
* Please make sure the PR has excellent documentation and tests. If we label it `missing documentation` or `missing tests` then it needs fixing!
* Include the link to your `RFC` or `bug` issue in the description.
* If the issue does not already have approval from a developer, submit the PR as draft.
* The PR title/description will become the commit message. Keep it up-to-date as the PR evolves.
* For `feat/fix` PRs, the first paragraph starting with "This PR" must be present and will become a
changelog entry unless the PR is labeled with `no-changelog`. If the PR does not have this label,
it must instead be categorized with one of the `changelog-*` labels (which will be done by a
reviewer for external PRs).
* A toolchain of the form `leanprover/lean4-pr-releases:pr-release-NNNN` for Linux and M-series Macs will be generated upon build. To generate binaries for Windows and Intel-based Macs as well, write a comment containing `release-ci` on its own line.
* If you rebase your PR onto `nightly-with-mathlib` then CI will test Mathlib against your PR.
* You can manage the `awaiting-review`, `awaiting-author`, and `WIP` labels yourself, by writing a comment containing one of these labels on its own line.
* Remove this section, up to and including the `---` before submitting.
---
This PR <short changelog summary for feat/fix, see above>.
Closes <`RFC` or `bug` issue number fixed by this PR, if any>

8
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
commit-message:
prefix: "chore: CI"

22
.github/workflows/actionlint.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: Actionlint
on:
push:
branches:
- 'master'
paths:
- '.github/**'
pull_request:
paths:
- '.github/**'
merge_group:
jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: actionlint
uses: raven-actions/actionlint@v2
with:
pyflakes: false # we do not use python scripts

26
.github/workflows/backport.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Backport
on:
pull_request_target:
types:
- closed
- labeled
jobs:
backport:
name: Backport
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
- uses: tibdex/backport@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

28
.github/workflows/check-prelude.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Check for modules that should use `prelude`
on: [pull_request]
jobs:
check-prelude:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# the default is to use a virtual merge commit between the PR and master: just use the PR
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: |
src/Lean
src/Std
- name: Check Prelude
run: |
failed_files=""
while IFS= read -r -d '' file; do
if ! grep -q "^prelude$" "$file"; then
failed_files="$failed_files$file\n"
fi
done < <(find src/Lean src/Std -name '*.lean' -print0)
if [ -n "$failed_files" ]; then
echo -e "The following files should use 'prelude':\n$failed_files"
exit 1
fi

57
.github/workflows/check-stage0.yml vendored Normal file
View File

@@ -0,0 +1,57 @@
name: Check for stage0 changes
on:
merge_group:
pull_request:
jobs:
check-stage0-on-queue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
filter: blob:none
fetch-depth: 0
- name: Find base commit
if: github.event_name == 'pull_request'
run: echo "BASE=$(git merge-base origin/${{ github.base_ref }} HEAD)" >> "$GITHUB_ENV"
- name: Identify stage0 changes
run: |
git diff "${BASE:-HEAD^}..HEAD" --name-only -- stage0 |
grep -v -x -F $'stage0/src/stdlib_flags.h\nstage0/src/lean.mk.in' \
> "$RUNNER_TEMP/stage0" || true
if test -s "$RUNNER_TEMP/stage0"
then
echo "CHANGES=yes" >> "$GITHUB_ENV"
else
echo "CHANGES=no" >> "$GITHUB_ENV"
fi
shell: bash
- if: github.event_name == 'pull_request'
name: Set label
uses: actions/github-script@v7
with:
script: |
const { owner, repo, number: issue_number } = context.issue;
if (process.env.CHANGES == 'yes') {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: ['changes-stage0'] }).catch(() => {});
} else {
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: 'changes-stage0' }).catch(() => {});
}
- if: env.CHANGES == 'yes'
name: Report changes
run: |
echo "Found changes to stage0/, please do not merge using the merge queue." | tee "$GITHUB_STEP_SUMMARY"
# shellcheck disable=SC2129
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat "$RUNNER_TEMP/stage0" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
- if: github.event_name == 'merge_group' && env.CHANGES == 'yes'
name: Fail when on the merge queue
run: exit 1

View File

@@ -6,107 +6,275 @@ on:
tags:
- '*'
pull_request:
branches:
- master
merge_group:
schedule:
- cron: '0 7 * * *' # 8AM CET/11PM PT
# for manual re-release of a nightly
workflow_dispatch:
inputs:
action:
description: 'Action'
required: true
default: 'release nightly'
type: choice
options:
- release nightly
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
set-nightly:
# don't schedule nightlies on forks
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4'
# This job determines various settings for the following CI runs; see the `outputs` for details
configure:
runs-on: ubuntu-latest
outputs:
nightly: ${{ steps.set.outputs.nightly }}
# 0: PRs without special label
# 1: PRs with `merge-ci` label, merge queue checks, master commits
# 2: PRs with `release-ci` label, releases (incl. nightlies)
check-level: ${{ steps.set-level.outputs.check-level }}
# The build matrix, dynamically generated here
matrix: ${{ steps.set-matrix.outputs.result }}
# Should we make a nightly release? If so, this output contains the lean version string, else it is empty
nightly: ${{ steps.set-nightly.outputs.nightly }}
# Should this be the CI for a tagged release?
# Yes only if a tag is pushed to the `leanprover` repository, and the tag is "v" followed by a valid semver.
# It sets `set-release.outputs.RELEASE_TAG` to the tag
# and sets `set-release.outputs.{LEAN_VERSION_MAJOR,LEAN_VERSION_MINOR,LEAN_VERSION_PATCH,LEAN_SPECIAL_VERSION_DESC}`
# to the semver components parsed via regex.
LEAN_VERSION_MAJOR: ${{ steps.set-release.outputs.LEAN_VERSION_MAJOR }}
LEAN_VERSION_MINOR: ${{ steps.set-release.outputs.LEAN_VERSION_MINOR }}
LEAN_VERSION_PATCH: ${{ steps.set-release.outputs.LEAN_VERSION_PATCH }}
LEAN_SPECIAL_VERSION_DESC: ${{ steps.set-release.outputs.LEAN_SPECIAL_VERSION_DESC }}
RELEASE_TAG: ${{ steps.set-release.outputs.RELEASE_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
# don't schedule nightlies on forks
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4' || inputs.action == 'release nightly'
- name: Set Nightly
id: set
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4' || inputs.action == 'release nightly'
id: set-nightly
run: |
if [[ -n '${{ secrets.PUSH_NIGHTLY_TOKEN }}' ]]; then
git remote add nightly https://foo:'${{ secrets.PUSH_NIGHTLY_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-nightly.git
git fetch nightly --tags
LEAN_VERSION_STRING="nightly-$(date -u +%F)"
# do nothing if commit already has a different tag
if [[ $(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || echo $LEAN_VERSION_STRING) == $LEAN_VERSION_STRING ]]; then
echo "::set-output name=nightly::$LEAN_VERSION_STRING"
if [[ "$(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || echo "$LEAN_VERSION_STRING")" == "$LEAN_VERSION_STRING" ]]; then
echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT"
fi
fi
- name: Check for official release
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'leanprover/lean4'
id: set-release
run: |
TAG_NAME="${GITHUB_REF##*/}"
# From https://github.com/fsaintjacques/semver-tool/blob/master/src/semver
NAT='0|[1-9][0-9]*'
ALPHANUM='[0-9]*[A-Za-z-][0-9A-Za-z-]*'
IDENT="$NAT|$ALPHANUM"
FIELD='[0-9A-Za-z-]+'
SEMVER_REGEX="\
^[vV]?\
($NAT)\\.($NAT)\\.($NAT)\
(\\-(${IDENT})(\\.(${IDENT}))*)?\
(\\+${FIELD}(\\.${FIELD})*)?$"
if [[ ${TAG_NAME} =~ ${SEMVER_REGEX} ]]; then
echo "Tag ${TAG_NAME} matches SemVer regex, with groups ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]} ${BASH_REMATCH[4]}"
{
echo "LEAN_VERSION_MAJOR=${BASH_REMATCH[1]}"
echo "LEAN_VERSION_MINOR=${BASH_REMATCH[2]}"
echo "LEAN_VERSION_PATCH=${BASH_REMATCH[3]}"
echo "LEAN_SPECIAL_VERSION_DESC=${BASH_REMATCH[4]##-}"
echo "RELEASE_TAG=$TAG_NAME"
} >> "$GITHUB_OUTPUT"
else
echo "Tag ${TAG_NAME} did not match SemVer regex."
fi
- name: Set check level
id: set-level
# We do not use github.event.pull_request.labels.*.name here because
# re-running a run does not update that list, and we do want to be able to
# rerun the workflow run after setting the `release-ci`/`merge-ci` labels.
run: |
check_level=0
if [[ -n "${{ steps.set-nightly.outputs.nightly }}" || -n "${{ steps.set-release.outputs.RELEASE_TAG }}" ]]; then
check_level=2
elif [[ "${{ github.event_name }}" != "pull_request" ]]; then
check_level=1
else
labels="$(gh api repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ github.event.pull_request.number }} --jq '.labels')"
if echo "$labels" | grep -q "release-ci"; then
check_level=2
elif echo "$labels" | grep -q "merge-ci"; then
check_level=1
fi
fi
echo "check-level=$check_level" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- name: Configure build matrix
id: set-matrix
uses: actions/github-script@v7
with:
script: |
const level = ${{ steps.set-level.outputs.check-level }};
console.log(`level: ${level}`);
// use large runners where available (original repo)
let large = ${{ github.repository == 'leanprover/lean4' }};
let matrix = [
{
// portable release build: use channel with older glibc (2.27)
"name": "Linux LLVM",
"os": "ubuntu-latest",
"release": false,
"check-level": 2,
"shell": "nix develop .#oldGlibc -c bash -euxo pipefail {0}",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-x86_64-linux-gnu.tar.zst",
"prepare-llvm": "../script/prepare-llvm-linux.sh lean-llvm*",
"binary-check": "ldd -v",
// foreign code may be linked against more recent glibc
// reverse-ffi needs to be updated to link to LLVM libraries
"CTEST_OPTIONS": "-E 'foreign|leanlaketest_reverse-ffi'",
"CMAKE_OPTIONS": "-DLLVM=ON -DLLVM_CONFIG=${GITHUB_WORKSPACE}/build/llvm-host/bin/llvm-config"
},
{
"name": "Linux release",
"os": large ? "nscloud-ubuntu-22.04-amd64-4x8" : "ubuntu-latest",
"release": true,
"check-level": 0,
"shell": "nix develop .#oldGlibc -c bash -euxo pipefail {0}",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-x86_64-linux-gnu.tar.zst",
"prepare-llvm": "../script/prepare-llvm-linux.sh lean-llvm*",
"binary-check": "ldd -v",
// foreign code may be linked against more recent glibc
"CTEST_OPTIONS": "-E 'foreign'"
},
{
"name": "Linux",
"os": large ? "nscloud-ubuntu-22.04-amd64-4x8" : "ubuntu-latest",
"check-stage3": level >= 2,
"test-speedcenter": level >= 2,
"check-level": 1,
},
{
"name": "Linux Debug",
"os": "ubuntu-latest",
"check-level": 2,
"CMAKE_PRESET": "debug",
// exclude seriously slow tests
"CTEST_OPTIONS": "-E 'interactivetest|leanpkgtest|laketest|benchtest|bv_bitblast_stress'"
},
// TODO: suddenly started failing in CI
/*{
"name": "Linux fsanitize",
"os": "ubuntu-latest",
"check-level": 2,
// turn off custom allocator & symbolic functions to make LSAN do its magic
"CMAKE_PRESET": "sanitize",
// exclude seriously slow/problematic tests (laketests crash)
"CTEST_OPTIONS": "-E 'interactivetest|leanpkgtest|laketest|benchtest'"
},*/
{
"name": "macOS",
"os": "macos-13",
"release": true,
"check-level": 2,
"shell": "bash -euxo pipefail {0}",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-x86_64-apple-darwin.tar.zst",
"prepare-llvm": "../script/prepare-llvm-macos.sh lean-llvm*",
"binary-check": "otool -L",
"tar": "gtar" // https://github.com/actions/runner-images/issues/2619
},
{
"name": "macOS aarch64",
"os": "macos-14",
"CMAKE_OPTIONS": "-DLEAN_INSTALL_SUFFIX=-darwin_aarch64",
"release": true,
"check-level": 0,
"shell": "bash -euxo pipefail {0}",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-aarch64-apple-darwin.tar.zst",
"prepare-llvm": "../script/prepare-llvm-macos.sh lean-llvm*",
"binary-check": "otool -L",
"tar": "gtar" // https://github.com/actions/runner-images/issues/2619
},
{
"name": "Windows",
"os": "windows-2022",
"release": true,
"check-level": 2,
"shell": "msys2 {0}",
"CMAKE_OPTIONS": "-G \"Unix Makefiles\"",
// for reasons unknown, interactivetests are flaky on Windows
"CTEST_OPTIONS": "--repeat until-pass:2",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-x86_64-w64-windows-gnu.tar.zst",
"prepare-llvm": "../script/prepare-llvm-mingw.sh lean-llvm*",
"binary-check": "ldd"
},
{
"name": "Linux aarch64",
"os": "nscloud-ubuntu-22.04-arm64-4x8",
"CMAKE_OPTIONS": "-DLEAN_INSTALL_SUFFIX=-linux_aarch64",
"release": true,
"check-level": 2,
"shell": "nix develop .#oldGlibcAArch -c bash -euxo pipefail {0}",
"llvm-url": "https://github.com/leanprover/lean-llvm/releases/download/15.0.1/lean-llvm-aarch64-linux-gnu.tar.zst",
"prepare-llvm": "../script/prepare-llvm-linux.sh lean-llvm*"
},
{
"name": "Linux 32bit",
"os": "ubuntu-latest",
// Use 32bit on stage0 and stage1 to keep oleans compatible
"CMAKE_OPTIONS": "-DSTAGE0_USE_GMP=OFF -DSTAGE0_LEAN_EXTRA_CXX_FLAGS='-m32' -DSTAGE0_LEANC_OPTS='-m32' -DSTAGE0_MMAP=OFF -DUSE_GMP=OFF -DLEAN_EXTRA_CXX_FLAGS='-m32' -DLEANC_OPTS='-m32' -DMMAP=OFF -DLEAN_INSTALL_SUFFIX=-linux_x86 -DCMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ -DSTAGE0_CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/",
"cmultilib": true,
"release": true,
"check-level": 2,
"cross": true,
"shell": "bash -euxo pipefail {0}"
},
{
"name": "Web Assembly",
"os": "ubuntu-latest",
// Build a native 32bit binary in stage0 and use it to compile the oleans and the wasm build
"CMAKE_OPTIONS": "-DCMAKE_C_COMPILER_WORKS=1 -DSTAGE0_USE_GMP=OFF -DSTAGE0_LEAN_EXTRA_CXX_FLAGS='-m32' -DSTAGE0_LEANC_OPTS='-m32' -DSTAGE0_CMAKE_CXX_COMPILER=clang++ -DSTAGE0_CMAKE_C_COMPILER=clang -DSTAGE0_CMAKE_EXECUTABLE_SUFFIX=\"\" -DUSE_GMP=OFF -DMMAP=OFF -DSTAGE0_MMAP=OFF -DCMAKE_AR=../emsdk/emsdk-main/upstream/emscripten/emar -DCMAKE_TOOLCHAIN_FILE=../emsdk/emsdk-main/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DLEAN_INSTALL_SUFFIX=-linux_wasm32 -DSTAGE0_CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu/",
"wasm": true,
"cmultilib": true,
"release": true,
"check-level": 2,
"cross": true,
"shell": "bash -euxo pipefail {0}",
// Just a few selected tests because wasm is slow
"CTEST_OPTIONS": "-R \"leantest_1007\\.lean|leantest_Format\\.lean|leanruntest\\_1037.lean|leanruntest_ac_rfl\\.lean|leanruntest_tempfile.lean\\.|leanruntest_libuv\\.lean\""
}
];
console.log(`matrix:\n${JSON.stringify(matrix, null, 2)}`)
return matrix.filter((job) => level >= job["check-level"])
build:
needs: set-nightly
# `always` *must* be used to continue even after a dependency has been skipped
if: always() && (github.event_name != 'schedule' || github.repository == 'leanprover/lean4')
needs: [configure]
if: github.event_name != 'schedule' || github.repository == 'leanprover/lean4'
strategy:
matrix:
include: ${{fromJson(needs.configure.outputs.matrix)}}
# complete all jobs
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell || 'nix-shell --run "bash -euxo pipefail {0}"' }}
strategy:
matrix:
include:
# portable release build: use channel with older glibc (2.27)
- name: Linux release
os: ubuntu-latest
release: true
shell: nix-shell --arg pkgsDist "import (fetchTarball \"channel:nixos-19.03\") {{}}" --run "bash -euxo pipefail {0}"
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-linux-gnu.tar.zst
prepare-llvm: ../script/prepare-llvm-linux.sh lean-llvm*
binary-check: ldd -v
# foreign code may be linked against more recent glibc
CTEST_OPTIONS: -E 'foreign|leanlaketest_git'
- name: Linux
os: ubuntu-latest
check-stage3: true
test-speedcenter: true
- name: Linux Debug
os: ubuntu-latest
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Debug
- name: Linux fsanitize
os: ubuntu-latest
# turn off custom allocator & symbolic functions to make LSAN do its magic
CMAKE_OPTIONS: -DLEAN_EXTRA_CXX_FLAGS=-fsanitize=address,undefined -DLEANC_EXTRA_FLAGS='-fsanitize=address,undefined -fsanitize-link-c++-runtime' -DSMALL_ALLOCATOR=OFF -DBSYMBOLIC=OFF
# exclude problematic tests
CTEST_OPTIONS: -E laketest
- name: macOS
os: macos-latest
release: true
shell: bash -euxo pipefail {0}
CMAKE_OPTIONS: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-apple-darwin.tar.zst
prepare-llvm: ../script/prepare-llvm-macos.sh lean-llvm*
binary-check: otool -L
tar: gtar # https://github.com/actions/runner-images/issues/2619
- name: macOS aarch64
os: macos-latest
release: true
cross: true
shell: bash -euxo pipefail {0}
CMAKE_OPTIONS: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DUSE_GMP=OFF -DLEAN_INSTALL_SUFFIX=-darwin_aarch64
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-aarch64-apple-darwin.tar.zst https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-apple-darwin.tar.zst
prepare-llvm: EXTRA_FLAGS=--target=aarch64-apple-darwin ../script/prepare-llvm-macos.sh lean-llvm-aarch64-* lean-llvm-x86_64-*
binary-check: otool -L
tar: gtar # https://github.com/actions/runner-images/issues/2619
- name: Windows
os: windows-2022
release: true
shell: msys2 {0}
CMAKE_OPTIONS: -G "Unix Makefiles"
# for reasons unknown, interactivetests are flaky on Windows
CTEST_OPTIONS: --repeat until-pass:2
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-w64-windows-gnu.tar.zst
prepare-llvm: ../script/prepare-llvm-mingw.sh lean-llvm*
binary-check: ldd
- name: Linux aarch64
os: ubuntu-latest
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=$GMP -DLEAN_INSTALL_SUFFIX=-linux_aarch64
release: true
cross: true
shell: nix-shell --arg pkgsDist "import (fetchTarball \"channel:nixos-19.03\") {{ localSystem.config = \"aarch64-unknown-linux-gnu\"; }}" --run "bash -euxo pipefail {0}"
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-linux-gnu.tar.zst https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-aarch64-linux-gnu.tar.zst
prepare-llvm: EXTRA_FLAGS=--target=aarch64-unknown-linux-gnu ../script/prepare-llvm-linux.sh lean-llvm-aarch64-* lean-llvm-x86_64-*
# complete all jobs
fail-fast: false
shell: ${{ matrix.shell || 'nix develop -c bash -euxo pipefail {0}' }}
name: ${{ matrix.name }}
env:
# must be inside workspace
@@ -119,73 +287,123 @@ jobs:
LSAN_OPTIONS: max_leaks=10
# somehow MinGW clang64 (or cmake?) defaults to `g++` even though it doesn't exist
CXX: c++
MACOSX_DEPLOYMENT_TARGET: 10.15
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install Nix
uses: cachix/install-nix-action@v15
if: matrix.os == 'ubuntu-latest'
uses: DeterminateSystems/nix-installer-action@main
if: runner.os == 'Linux' && !matrix.cmultilib
- name: Install MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: clang64
# `:p` means prefix with appropriate msystem prefix
pacboy: "make python cmake:p clang:p ccache:p gmp:p git zip unzip diffutils binutils tree zstd:p tar"
if: matrix.os == 'windows-2022'
# `:` means do not prefix with msystem
pacboy: "make: python: cmake clang ccache gmp libuv git: zip: unzip: diffutils: binutils: tree: zstd tar:"
if: runner.os == 'Windows'
- name: Install Brew Packages
run: |
brew install ccache tree zstd coreutils
if: matrix.os == 'macos-latest'
brew install ccache tree zstd coreutils gmp libuv
if: runner.os == 'macOS'
- name: Checkout
uses: actions/checkout@v4
with:
# the default is to use a virtual merge commit between the PR and master: just use the PR
ref: ${{ github.event.pull_request.head.sha }}
# Do check out some CI-relevant files from virtual merge commit to accommodate CI changes on
# master (as the workflow files themselves are always taken from the merge)
# (needs to be after "Install *" to use the right shell)
- name: CI Merge Checkout
run: |
git fetch --depth=1 origin ${{ github.sha }}
git checkout FETCH_HEAD flake.nix flake.lock
if: github.event_name == 'pull_request'
# (needs to be after "Checkout" so files don't get overridden)
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.44
actions-cache-folder: emsdk
if: matrix.wasm
- name: Install 32bit c libs
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib ccache libuv1-dev:i386
if: matrix.cmultilib
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: .ccache
key: ${{ matrix.name }}-build-v3-${{ github.sha }}
key: ${{ matrix.name }}-build-v3-${{ github.event.pull_request.head.sha }}
# fall back to (latest) previous cache
restore-keys: |
${{ matrix.name }}-build-v3
save-always: true
# open nix-shell once for initial setup
- name: Setup
run: |
# open nix-shell once for initial setup
true
if: matrix.os == 'ubuntu-latest'
ccache --zero-stats
if: runner.os == 'Linux'
- name: Set up NPROC
run: |
echo "NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)" >> $GITHUB_ENV
- name: Build
run: |
mkdir build
cd build
OPTIONS=()
# arguments passed to `cmake`
# this also enables githash embedding into stage 1 library
OPTIONS=(-DCHECK_OLEAN_VERSION=ON)
OPTIONS+=(-DLEAN_EXTRA_MAKE_OPTS=-DwarningAsError=true)
if [[ -n '${{ matrix.cross_target }}' ]]; then
# used by `prepare-llvm`
export EXTRA_FLAGS=--target=${{ matrix.cross_target }}
OPTIONS+=(-DLEAN_PLATFORM_TARGET=${{ matrix.cross_target }})
fi
if [[ -n '${{ matrix.prepare-llvm }}' ]]; then
wget -q ${{ matrix.llvm-url }}
PREPARE="$(${{ matrix.prepare-llvm }})"
eval "OPTIONS+=($PREPARE)"
fi
if [[ -n '${{ matrix.release }}' && -n '${{ needs.set-nightly.outputs.nightly }}' ]]; then
OPTIONS+=(-DLEAN_SPECIAL_VERSION_DESC=${{ needs.set-nightly.outputs.nightly }})
if [[ -n '${{ matrix.release }}' && -n '${{ needs.configure.outputs.nightly }}' ]]; then
OPTIONS+=(-DLEAN_SPECIAL_VERSION_DESC=${{ needs.configure.outputs.nightly }})
fi
if [[ -n '${{ matrix.release }}' && -n '${{ needs.configure.outputs.RELEASE_TAG }}' ]]; then
OPTIONS+=(-DLEAN_VERSION_MAJOR=${{ needs.configure.outputs.LEAN_VERSION_MAJOR }})
OPTIONS+=(-DLEAN_VERSION_MINOR=${{ needs.configure.outputs.LEAN_VERSION_MINOR }})
OPTIONS+=(-DLEAN_VERSION_PATCH=${{ needs.configure.outputs.LEAN_VERSION_PATCH }})
OPTIONS+=(-DLEAN_VERSION_IS_RELEASE=1)
OPTIONS+=(-DLEAN_SPECIAL_VERSION_DESC=${{ needs.configure.outputs.LEAN_SPECIAL_VERSION_DESC }})
fi
# contortion to support empty OPTIONS with old macOS bash
cmake .. ${{ matrix.CMAKE_OPTIONS }} ${OPTIONS[@]+"${OPTIONS[@]}"} -DLEAN_INSTALL_PREFIX=$PWD/..
make -j4
make install
cmake .. --preset ${{ matrix.CMAKE_PRESET || 'release' }} -B . ${{ matrix.CMAKE_OPTIONS }} ${OPTIONS[@]+"${OPTIONS[@]}"} -DLEAN_INSTALL_PREFIX=$PWD/..
time make -j$NPROC
- name: Install
run: |
make -C build install
- name: Check Binaries
run: ${{ matrix.binary-check }} lean-*/bin/* || true
- name: Count binary symbols
run: |
for f in lean-*/bin/*; do
echo "$f: $(nm $f | grep " T " | wc -l) exported symbols"
done
if: matrix.name == 'Windows'
- name: List Install Tree
run: |
# omit contents of Init/, ...
tree --du -h lean-* | grep -E ' (Init|Lean|Lake|LICENSE|[a-z])'
tree --du -h lean-*-* | grep -E ' (Init|Lean|Lake|LICENSE|[a-z])'
- name: Pack
run: |
dir=$(echo lean-*)
dir=$(echo lean-*-*)
mkdir pack
# high-compression tar.zst + zip for release, fast tar.zst otherwise
if [[ '${{ startsWith(github.ref, 'refs/tags/v') && matrix.release }}' == true || -n '${{ needs.set-nightly.outputs.nightly }}' ]]; then
if [[ '${{ startsWith(github.ref, 'refs/tags/') && matrix.release }}' == true || -n '${{ needs.configure.outputs.nightly }}' || -n '${{ needs.configure.outputs.RELEASE_TAG }}' ]]; then
${{ matrix.tar || 'tar' }} cf - $dir | zstd -T0 --no-progress -19 -o pack/$dir.tar.zst
zip -rq pack/$dir.zip $dir
else
${{ matrix.tar || 'tar' }} cf - $dir | zstd -T0 --no-progress -o pack/$dir.tar.zst
fi
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: matrix.release
with:
name: build-${{ matrix.name }}
@@ -195,94 +413,146 @@ jobs:
build/stage1/bin/lean --stats src/Lean.lean
if: ${{ !matrix.cross }}
- name: Test
id: test
run: |
cd build/stage1
# exclude nonreproducible test
ctest -j4 --output-on-failure -E leanlaketest_git ${{ matrix.CTEST_OPTIONS }} < /dev/null
if: ${{ !matrix.cross }}
time ctest --preset ${{ matrix.CMAKE_PRESET || 'release' }} --test-dir build/stage1 -j$NPROC --output-junit test-results.xml ${{ matrix.CTEST_OPTIONS }}
if: (matrix.wasm || !matrix.cross) && needs.configure.outputs.check-level >= 1
- name: Test Summary
uses: test-summary/action@v2
with:
paths: build/stage1/test-results.xml
# prefix `if` above with `always` so it's run even if tests failed
if: always() && steps.test.conclusion != 'skipped'
- name: Check Test Binary
run: ${{ matrix.binary-check }} tests/compiler/534.lean.out
if: ${{ !matrix.cross }}
if: (!matrix.cross) && steps.test.conclusion != 'skipped'
- name: Build Stage 2
run: |
cd build
make -j4 stage2
if: matrix.build-stage2 || matrix.check-stage3
make -C build -j$NPROC stage2
if: matrix.test-speedcenter
- name: Check Stage 3
run: |
cd build
make -j4 check-stage3
if: matrix.check-stage3
make -C build -j$NPROC check-stage3
if: matrix.test-speedcenter
- name: Test Speedcenter Benchmarks
run: |
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
# Necessary for some timing metrics but does not work on Namespace runners
# and we just want to test that the benchmarks run at all here
#echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
export BUILD=$PWD/build PATH=$PWD/build/stage1/bin:$PATH
cd tests/bench
nix shell .#temci -c temci exec --config speedcenter.yaml --included_blocks fast --runs 1
if: matrix.test-speedcenter
- name: Check rebootstrap
run: |
cd build
make update-stage0 && make -j4
if: matrix.name == 'Linux'
# clean rebuild in case of Makefile changes
make -C build update-stage0 && rm -rf build/stage* && make -C build -j$NPROC
if: matrix.name == 'Linux' && needs.configure.outputs.check-level >= 1
- name: CCache stats
run: ccache -s
# This job collects results from all the matrix jobs
# This can be made the "required" job, instead of listing each
# matrix job separately
all-done:
name: Build matrix complete
runs-on: ubuntu-latest
needs: build
# mark as merely cancelled not failed if builds are cancelled
if: ${{ !cancelled() }}
steps:
- if: ${{ contains(needs.*.result, 'failure') && github.repository == 'leanprover/lean4' && github.ref_name == 'master' }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_BOT_KEY }}
email: "github-actions-bot@lean-fro.zulipchat.com"
organization-url: "https://lean-fro.zulipchat.com"
to: "infrastructure"
topic: "Github actions"
type: "stream"
content: |
A build of `${{ github.ref_name }}`, triggered by event `${{ github.event_name }}`, [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
- if: contains(needs.*.result, 'failure')
uses: actions/github-script@v7
with:
script: |
core.setFailed('Some jobs failed')
# This job creates releases from tags
# (whether they are "unofficial" releases for experiments, or official releases when the tag is "v" followed by a semver string.)
# We do not attempt to automatically construct a changelog here:
# unofficial releases don't need them, and official release notes will be written by a human.
release:
# When GitHub says "If a job fails, all jobs that need it are skipped unless
# the jobs use a conditional expression that causes the job to continue.", don't believe
# their lies. It's actually the entire closure (i.e. including `set-nightly`) that
# must succeed for subsequent to be run without `always()`.
if: always() && needs.build.result == 'success' && startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: artifacts/*/*
fail_on_unmatched_files: true
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') || contains(github.ref, '-rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update release.lean-lang.org
run: |
gh workflow -R leanprover/release-index run update-index.yml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_INDEX_TOKEN }}
# This job creates nightly releases during the cron job.
# It is responsible for creating the tag, and automatically generating a changelog.
release-nightly:
needs: [set-nightly, build]
if: needs.set-nightly.outputs.nightly
needs: [configure, build]
if: needs.configure.outputs.nightly
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# needed for tagging
fetch-depth: 0
token: ${{ secrets.PUSH_NIGHTLY_TOKEN }}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare Nightly Release
run: |
git remote add nightly https://foo:'${{ secrets.PUSH_NIGHTLY_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-nightly.git
git fetch nightly --tags
git tag ${{ needs.set-nightly.outputs.nightly }}
git push nightly ${{ needs.set-nightly.outputs.nightly }}
last_tag=$(git describe HEAD^ --abbrev=0 --tags)
git tag "${{ needs.configure.outputs.nightly }}"
git push nightly "${{ needs.configure.outputs.nightly }}"
git push -f origin refs/tags/${{ needs.configure.outputs.nightly }}:refs/heads/nightly
last_tag="$(git log HEAD^ --simplify-by-decoration --pretty="format:%d" | grep -o "nightly-[-0-9]*" | head -n 1)"
echo -e "*Changes since ${last_tag}:*\n\n" > diff.md
git show $last_tag:RELEASES.md > old.md
git show "$last_tag":RELEASES.md > old.md
#./script/diff_changelogs.py old.md doc/changes.md >> diff.md
diff --changed-group-format='%>' --unchanged-group-format='' old.md RELEASES.md >> diff.md || true
echo -e "\n*Full commit log*\n" >> diff.md
git log --oneline $last_tag..HEAD | sed 's/^/* /' >> diff.md
git log --oneline "$last_tag"..HEAD | sed 's/^/* /' >> diff.md
- name: Release Nightly
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body_path: diff.md
prerelease: true
files: artifacts/*/*
fail_on_unmatched_files: true
tag_name: ${{ needs.set-nightly.outputs.nightly }}
tag_name: ${{ needs.configure.outputs.nightly }}
repository: ${{ github.repository_owner }}/lean4-nightly
env:
GITHUB_TOKEN: ${{ secrets.PUSH_NIGHTLY_TOKEN }}
- name: Update release.lean-lang.org
run: |
gh workflow -R leanprover/release-index run update-index.yml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_INDEX_TOKEN }}
- name: Update toolchain on mathlib4's nightly-testing branch
run: |
gh workflow -R leanprover-community/mathlib4 run nightly_bump_toolchain.yml
env:
GITHUB_TOKEN: ${{ secrets.MATHLIB4_BOT }}

20
.github/workflows/copyright-header.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Check for copyright header
on: [pull_request]
jobs:
check-lean-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify .lean files start with a copyright header.
run: |
FILES=$(find ./src -type d \( -path "./src/lake/examples" -o -path "./src/lake/tests" \) -prune -o -type f -name "*.lean" -exec perl -ne 'BEGIN { $/ = undef; } print "$ARGV\n" if !m{\A/-\nCopyright}; exit;' {} \;)
if [ -n "$FILES" ]; then
echo "Found .lean files which do not have a copyright header:"
echo "$FILES"
exit 1
else
echo "All copyright headers present."
fi

34
.github/workflows/jira.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Jira sync
on:
issues:
types: [closed]
jobs:
jira-sync:
runs-on: ubuntu-latest
steps:
- name: Move Jira issue to Done
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
run: |
issue_number=${{ github.event.issue.number }}
jira_issue_key=$(curl -s -u "${JIRA_USERNAME}:${JIRA_API_TOKEN}" \
-X GET -H "Content-Type: application/json" \
"${JIRA_BASE_URL}/rest/api/2/search?jql=summary~\"${issue_number}\"" | \
jq -r '.issues[0].key')
if [ -z "$jira_issue_key" ]; then
exit
fi
curl -s -u "${JIRA_USERNAME}:${JIRA_API_TOKEN}" \
-X POST -H "Content-Type: application/json" \
--data "{\"transition\": {\"id\": \"41\"}}" \
"${JIRA_BASE_URL}/rest/api/2/issue/${jira_issue_key}/transitions"
echo "Moved Jira issue ${jira_issue_key} to Done"

View File

@@ -0,0 +1,67 @@
# This workflow allows any user to add one of the `awaiting-review`, `awaiting-author`, `WIP`,
# `release-ci`, or a `changelog-XXX` label by commenting on the PR or issue.
# If any labels from the set {`awaiting-review`, `awaiting-author`, `WIP`} are added, other labels
# from that set are removed automatically at the same time.
# Similarly, if any `changelog-XXX` label is added, other `changelog-YYY` labels are removed.
name: Label PR based on Comment
on:
issue_comment:
types: [created]
jobs:
update-label:
if: github.event.issue.pull_request != null && (contains(github.event.comment.body, 'awaiting-review') || contains(github.event.comment.body, 'awaiting-author') || contains(github.event.comment.body, 'WIP') || contains(github.event.comment.body, 'release-ci') || contains(github.event.comment.body, 'changelog-'))
runs-on: ubuntu-latest
steps:
- name: Add label based on comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo, number: issue_number } = context.issue;
const commentLines = context.payload.comment.body.split('\r\n');
const awaitingReview = commentLines.includes('awaiting-review');
const awaitingAuthor = commentLines.includes('awaiting-author');
const wip = commentLines.includes('WIP');
const releaseCI = commentLines.includes('release-ci');
const changelogMatch = commentLines.find(line => line.startsWith('changelog-'));
if (awaitingReview || awaitingAuthor || wip) {
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: 'awaiting-review' }).catch(() => {});
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: 'awaiting-author' }).catch(() => {});
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: 'WIP' }).catch(() => {});
}
if (awaitingReview) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: ['awaiting-review'] });
}
if (awaitingAuthor) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: ['awaiting-author'] });
}
if (wip) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: ['WIP'] });
}
if (releaseCI) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: ['release-ci'] });
}
if (changelogMatch) {
const changelogLabel = changelogMatch.trim();
const { data: existingLabels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number });
const changelogLabels = existingLabels.filter(label => label.name.startsWith('changelog-'));
// Remove all other changelog labels
for (const label of changelogLabels) {
if (label.name !== changelogLabel) {
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: label.name }).catch(() => {});
}
}
// Add the new changelog label
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [changelogLabel] });
}

View File

@@ -6,103 +6,137 @@ on:
tags:
- '*'
pull_request:
branches:
- master
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# see ci.yml
configure:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.result }}
steps:
- name: Configure build matrix
id: set-matrix
uses: actions/github-script@v7
with:
script: |
let large = ${{ github.repository == 'leanprover/lean4' }};
let matrix = [
{
"name": "Nix Linux",
"os": large ? "nscloud-ubuntu-22.04-amd64-8x8" : "ubuntu-latest",
}
];
console.log(`matrix:\n${JSON.stringify(matrix, null, 2)}`);
return matrix;
Build:
needs: [configure]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: nix -v --experimental-features "nix-command flakes" run .#ciShell -- bash -euxo pipefail {0}
shell: nix run .#ciShell -- bash -euxo pipefail {0}
strategy:
matrix:
include:
- name: Nix Linux
os: ubuntu-latest
#- name: Nix macOS
# os: macos-latest
include: ${{fromJson(needs.configure.outputs.matrix)}}
# complete all jobs
fail-fast: false
name: ${{ matrix.name }}
env:
NIX_BUILD_ARGS: -v --print-build-logs --fallback
NIX_BUILD_ARGS: --print-build-logs --fallback
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v15
uses: actions/checkout@v4
with:
# https://github.com/NixOS/nix/issues/6572
install_url: https://releases.nixos.org/nix/nix-2.7.0/install
extra_nix_config: |
extra-sandbox-paths = /nix/var/cache/ccache
substituters = file://${{ github.workspace }}/nix-store-cache-copy?priority=10&trusted=true https://cache.nixos.org
# the default is to use a virtual merge commit between the PR and master: just use the PR
ref: ${{ github.event.pull_request.head.sha }}
- name: Set Up Nix Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: nix-store-cache
key: ${{ matrix.name }}-nix-store-cache-${{ github.sha }}
# fall back to (latest) previous cache
restore-keys: |
${{ matrix.name }}-nix-store-cache
save-always: true
- name: Further Set Up Nix Cache
shell: bash -euxo pipefail {0}
run: |
# Nix seems to mutate the cache, so make a copy
cp -r nix-store-cache nix-store-cache-copy || true
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-sandbox-paths = /nix/var/cache/ccache?
substituters = file://${{ github.workspace }}/nix-store-cache-copy?priority=10&trusted=true https://cache.nixos.org
- name: Prepare CCache Cache
shell: bash -euxo pipefail {0}
run: |
sudo mkdir -m0770 -p /nix/var/cache/ccache
sudo chown -R $USER /nix/var/cache/ccache
- name: Setup CCache Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /nix/var/cache/ccache
key: ${{ matrix.name }}-nix-ccache-${{ github.sha }}
# fall back to (latest) previous cache
restore-keys: |
${{ matrix.name }}-nix-ccache
save-always: true
- name: Further Set Up CCache Cache
shell: bash -euxo pipefail {0}
run: |
sudo chown -R root:nixbld /nix/var/cache
sudo chmod -R 770 /nix/var/cache
- name: Install Cachix
uses: cachix/cachix-action@v10
with:
name: lean4
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
skipPush: true # we push specific outputs only
- name: Build
run: |
# .o files are not a runtime dependency on macOS because of lack of thin archives
nix build $NIX_BUILD_ARGS .#stage0 .#stage1.lean-all .#Lean.oTree .#iTree .#modDepsFiles -o push-build
nix build $NIX_BUILD_ARGS .#cacheRoots -o push-build
- name: Test
run: |
nix build $NIX_BUILD_ARGS .#test -o push-test
nix build --keep-failed $NIX_BUILD_ARGS .#test -o push-test || (ln -s /tmp/nix-build-*/build/source/src/build ./push-test; false)
- name: Test Summary
uses: test-summary/action@v2
with:
paths: push-test/test-results.xml
if: always()
continue-on-error: true
- name: Build manual
run: |
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc#{lean-mdbook,leanInk,alectryon,test} -o push-doc
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc#{lean-mdbook,leanInk,alectryon,inked} -o push-doc
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc
# https://github.com/netlify/cli/issues/1809
cp -r --dereference ./result ./dist
if: matrix.name == 'Nix Linux'
- name: Push to Cachix
run: |
[ -z "${{ secrets.CACHIX_AUTH_TOKEN }}" ] || cachix push -j4 lean4 ./push-* || true
- name: Rebuild Nix Store Cache
run: |
rm -rf nix-store-cache || true
nix copy ./push-* --to file://$PWD/nix-store-cache?compression=none
- name: Publish manual
uses: peaceiris/actions-gh-pages@v3
- id: deploy-info
name: Compute Deployment Metadata
run: |
set -e
python3 -c 'import base64; print("alias="+base64.urlsafe_b64encode(bytes.fromhex("${{github.sha}}")).decode("utf-8").rstrip("="))' >> "$GITHUB_OUTPUT"
echo "message=`git log -1 --pretty=format:"%s"`" >> "$GITHUB_OUTPUT"
- name: Publish manual to Netlify
uses: nwtgck/actions-netlify@v3.0
id: publish-manual
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./result
destination_dir: ./doc
if: matrix.name == 'Nix Linux' && github.ref == 'refs/heads/master' && github.event_name == 'push'
publish-dir: ./dist
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: |
${{ github.event_name == 'pull_request' && format('pr#{0}: {1}', github.event.number, github.event.pull_request.title) || format('ref/{0}: {1}', github.ref_name, steps.deploy-info.outputs.message) }}
alias: ${{ steps.deploy-info.outputs.alias }}
enable-commit-comment: false
enable-pull-request-comment: false
github-deployment-environment: "lean-lang.org/lean4/doc"
fails-without-credentials: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: "b8e805d2-7e9b-4f80-91fb-a84d72fc4a68"
- name: Fixup CCache Cache
run: |
sudo chown -R $USER /nix/var/cache
- name: CCache stats
run: CCACHE_DIR=/nix/var/cache/ccache nix run .#nixpkgs.ccache -- -s

25
.github/workflows/pr-body.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Check PR body for changelog convention
on:
merge_group:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, converted_to_draft, ready_for_review]
jobs:
check-pr-body:
runs-on: ubuntu-latest
steps:
- name: Check PR body
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { title, body, labels, draft } = context.payload.pull_request;
if (!draft && /^(feat|fix):/.test(title) && !labels.some(label => label.name == "changelog-no")) {
if (!labels.some(label => label.name.startsWith("changelog-"))) {
core.setFailed('feat/fix PR must have a `changelog-*` label');
}
if (!/^This PR [^<]/.test(body)) {
core.setFailed('feat/fix PR must have changelog summary starting with "This PR ..." as first line.');
}
}

350
.github/workflows/pr-release.yml vendored Normal file
View File

@@ -0,0 +1,350 @@
# Push a release to the lean4-pr-releases repository, whenever someone pushes to a PR branch.
# This needs to run with the `secrets.PR_RELEASES_TOKEN` token available,
# but PR branches will generally come from forks,
# so it is not possible to run this using the `pull_request` or `pull_request_target` workflows.
# Instead we use `workflow_run`, which essentially allows us to escalate privileges
# (but only runs the CI as described in the `master` branch, not in the PR branch).
# The main specification/documentation for this workflow is at
# https://leanprover-community.github.io/contribute/tags_and_branches.html
# Keep that in sync!
name: PR release
on:
workflow_run: # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
workflows: [CI]
types: [completed]
jobs:
on-success:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.repository == 'leanprover/lean4'
steps:
- name: Retrieve information about the original workflow
uses: potiuk/get-workflow-origin@v1_1 # https://github.com/marketplace/actions/get-workflow-origin
# This action is deprecated and archived, but it seems hard to find a better solution for getting the PR number
# see https://github.com/orgs/community/discussions/25220 for some discussion
id: workflow-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- name: Download artifact from the previous workflow.
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
id: download-artifact
uses: dawidd6/action-download-artifact@v6 # https://github.com/marketplace/actions/download-workflow-artifact
with:
run_id: ${{ github.event.workflow_run.id }}
path: artifacts
name: build-.*
name_is_regexp: true
- name: Push tag
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
run: |
git init --bare lean4.git
git -C lean4.git remote add origin https://github.com/${{ github.repository_owner }}/lean4.git
git -C lean4.git fetch -n origin master
git -C lean4.git fetch -n origin "${{ steps.workflow-info.outputs.sourceHeadSha }}"
git -C lean4.git tag -f pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }} "${{ steps.workflow-info.outputs.sourceHeadSha }}"
git -C lean4.git remote add pr-releases https://foo:'${{ secrets.PR_RELEASES_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-pr-releases.git
git -C lean4.git push -f pr-releases pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}
- name: Delete existing release if present
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
run: |
# Try to delete any existing release for the current PR.
gh release delete --repo ${{ github.repository_owner }}/lean4-pr-releases pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }} -y || true
env:
GH_TOKEN: ${{ secrets.PR_RELEASES_TOKEN }}
- name: Release
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
uses: softprops/action-gh-release@v2
with:
name: Release for PR ${{ steps.workflow-info.outputs.pullRequestNumber }}
# There are coredumps files here as well, but all in deeper subdirectories.
files: artifacts/*/*
fail_on_unmatched_files: true
draft: false
tag_name: pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}
repository: ${{ github.repository_owner }}/lean4-pr-releases
env:
# The token used here must have `workflow` privileges.
GITHUB_TOKEN: ${{ secrets.PR_RELEASES_TOKEN }}
- name: Report release status
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ steps.workflow-info.outputs.sourceHeadSha }}",
state: "success",
context: "PR toolchain",
description: "${{ github.repository_owner }}/lean4-pr-releases:pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}",
});
- name: Add label
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.addLabels({
issue_number: ${{ steps.workflow-info.outputs.pullRequestNumber }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['toolchain-available']
})
# Next, determine the most recent nightly release in this PR's history.
- name: Find most recent nightly in feature branch
id: most-recent-nightly-tag
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
run: |
git -C lean4.git remote add nightly https://github.com/leanprover/lean4-nightly.git
git -C lean4.git fetch nightly '+refs/tags/nightly-*:refs/tags/nightly-*'
git -C lean4.git tag --merged "${{ steps.workflow-info.outputs.sourceHeadSha }}" --list "nightly-*" \
| sort -rV | head -n 1 | sed "s/^nightly-*/MOST_RECENT_NIGHTLY=/" | tee -a "$GITHUB_ENV"
- name: 'Setup jq'
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
uses: dcarbone/install-jq-action@v2.1.0
# Check that the most recently nightly coincides with 'git merge-base HEAD master'
- name: Check merge-base and nightly-testing-YYYY-MM-DD
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
id: ready
run: |
echo "Most recent nightly release in your branch: $MOST_RECENT_NIGHTLY"
NIGHTLY_SHA=$(git -C lean4.git rev-parse "nightly-$MOST_RECENT_NIGHTLY^{commit}")
echo "SHA of most recent nightly release: $NIGHTLY_SHA"
MERGE_BASE_SHA=$(git -C lean4.git merge-base origin/master "${{ steps.workflow-info.outputs.sourceHeadSha }}")
echo "SHA of merge-base: $MERGE_BASE_SHA"
if [ "$NIGHTLY_SHA" = "$MERGE_BASE_SHA" ]; then
echo "The merge base of this PR coincides with the nightly release"
BATTERIES_REMOTE_TAGS="$(git ls-remote https://github.com/leanprover-community/batteries.git nightly-testing-"$MOST_RECENT_NIGHTLY")"
MATHLIB_REMOTE_TAGS="$(git ls-remote https://github.com/leanprover-community/mathlib4.git nightly-testing-"$MOST_RECENT_NIGHTLY")"
if [[ -n "$BATTERIES_REMOTE_TAGS" ]]; then
echo "... and Batteries has a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag."
MESSAGE=""
if [[ -n "$MATHLIB_REMOTE_TAGS" ]]; then
echo "... and Mathlib has a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag."
else
echo "... but Mathlib does not yet have a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag."
MESSAGE="- ❗ Mathlib CI can not be attempted yet, as the \`nightly-testing-$MOST_RECENT_NIGHTLY\` tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto \`nightly-with-mathlib\`, Mathlib CI should run now."
fi
else
echo "... but Batteries does not yet have a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag."
MESSAGE="- ❗ Batteries CI can not be attempted yet, as the \`nightly-testing-$MOST_RECENT_NIGHTLY\` tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto \`nightly-with-mathlib\`, Batteries CI should run now."
fi
else
echo "The most recently nightly tag on this branch has SHA: $NIGHTLY_SHA"
echo "but 'git merge-base origin/master HEAD' reported: $MERGE_BASE_SHA"
git -C lean4.git log -10 origin/master
git -C lean4.git fetch origin nightly-with-mathlib
NIGHTLY_WITH_MATHLIB_SHA="$(git -C lean4.git rev-parse "origin/nightly-with-mathlib")"
MESSAGE="- ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the \`nightly-with-mathlib\` branch. Try \`git rebase $MERGE_BASE_SHA --onto $NIGHTLY_WITH_MATHLIB_SHA\`."
fi
if [[ -n "$MESSAGE" ]]; then
echo "Checking existing messages"
# The code for updating comments is duplicated in mathlib's
# scripts/lean-pr-testing-comments.sh
# so keep in sync
# Use GitHub API to check if a comment already exists
existing_comment="$(curl --retry 3 --location --silent \
-H "Authorization: token ${{ secrets.MATHLIB4_COMMENT_BOT }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/leanprover/lean4/issues/${{ steps.workflow-info.outputs.pullRequestNumber }}/comments" \
| jq 'first(.[] | select(.body | test("^- . Mathlib") or startswith("Mathlib CI status")) | select(.user.login == "leanprover-community-bot"))')"
existing_comment_id="$(echo "$existing_comment" | jq -r .id)"
existing_comment_body="$(echo "$existing_comment" | jq -r .body)"
if [[ "$existing_comment_body" != *"$MESSAGE"* ]]; then
MESSAGE="$MESSAGE ($(date "+%Y-%m-%d %H:%M:%S"))"
echo "Posting message to the comments: $MESSAGE"
# Append new result to the existing comment or post a new comment
# It's essential we use the MATHLIB4_COMMENT_BOT token here, so that Mathlib CI can subsequently edit the comment.
if [ -z "$existing_comment_id" ]; then
INTRO="Mathlib CI status ([docs](https://leanprover-community.github.io/contribute/tags_and_branches.html)):"
# Post new comment with a bullet point
echo "Posting as new comment at leanprover/lean4/issues/${{ steps.workflow-info.outputs.pullRequestNumber }}/comments"
curl -L -s \
-X POST \
-H "Authorization: token ${{ secrets.MATHLIB4_COMMENT_BOT }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "$(jq --null-input --arg intro "$INTRO" --arg val "$MESSAGE" '{"body":($intro + "\n" + $val)}')" \
"https://api.github.com/repos/leanprover/lean4/issues/${{ steps.workflow-info.outputs.pullRequestNumber }}/comments"
else
# Append new result to the existing comment
echo "Appending to existing comment at leanprover/lean4/issues/${{ steps.workflow-info.outputs.pullRequestNumber }}/comments"
curl -L -s \
-X PATCH \
-H "Authorization: token ${{ secrets.MATHLIB4_COMMENT_BOT }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "$(jq --null-input --arg existing "$existing_comment_body" --arg message "$MESSAGE" '{"body":($existing + "\n" + $message)}')" \
"https://api.github.com/repos/leanprover/lean4/issues/comments/$existing_comment_id"
fi
else
echo "The message already exists in the comment body."
fi
echo "mathlib_ready=false" >> "$GITHUB_OUTPUT"
else
echo "mathlib_ready=true" >> "$GITHUB_OUTPUT"
fi
- name: Report mathlib base
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' }}
uses: actions/github-script@v7
with:
script: |
const description =
process.env.MOST_RECENT_NIGHTLY ?
"nightly-" + process.env.MOST_RECENT_NIGHTLY :
"not branched off nightly";
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ steps.workflow-info.outputs.sourceHeadSha }}",
state: "success",
context: "PR branched off:",
description: description,
});
# We next automatically create a Batteries branch using this toolchain.
# Batteries doesn't itself have a mechanism to report results of CI from this branch back to Lean
# Instead this is taken care of by Mathlib CI, which will fail if Batteries fails.
- name: Cleanup workspace
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
run: |
sudo rm -rf ./*
# Checkout the Batteries repository with all branches
- name: Checkout Batteries repository
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
uses: actions/checkout@v4
with:
repository: leanprover-community/batteries
token: ${{ secrets.MATHLIB4_BOT }}
ref: nightly-testing
fetch-depth: 0 # This ensures we check out all tags and branches.
- name: Check if tag exists
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
id: check_batteries_tag
run: |
git config user.name "leanprover-community-mathlib4-bot"
git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com"
if git ls-remote --heads --tags --exit-code origin "nightly-testing-${MOST_RECENT_NIGHTLY}" >/dev/null; then
BASE="nightly-testing-${MOST_RECENT_NIGHTLY}"
else
echo "This shouldn't be possible: couldn't find a 'nightly-testing-${MOST_RECENT_NIGHTLY}' tag at Batteries. Falling back to 'nightly-testing'."
BASE=nightly-testing
fi
echo "Using base branch: $BASE"
EXISTS="$(git ls-remote --heads origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | wc -l)"
echo "Branch exists: $EXISTS"
if [ "$EXISTS" = "0" ]; then
echo "Branch does not exist, creating it."
git switch -c lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} "$BASE"
echo "leanprover/lean4-pr-releases:pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}" > lean-toolchain
git add lean-toolchain
git commit -m "Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}"
else
echo "Branch already exists, pushing an empty commit."
git switch lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }}
# The Batteries `nightly-testing` or `nightly-testing-YYYY-MM-DD` branch may have moved since this branch was created, so merge their changes.
# (This should no longer be possible once `nightly-testing-YYYY-MM-DD` is a tag, but it is still safe to merge.)
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}"
fi
- name: Push changes
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
run: |
git push origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }}
# We next automatically create a Mathlib branch using this toolchain.
# Mathlib CI will be responsible for reporting back success or failure
# to the PR comments asynchronously.
- name: Cleanup workspace
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
run: |
sudo rm -rf ./*
# Checkout the mathlib4 repository with all branches
- name: Checkout mathlib4 repository
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
uses: actions/checkout@v4
with:
repository: leanprover-community/mathlib4
token: ${{ secrets.MATHLIB4_BOT }}
ref: nightly-testing
fetch-depth: 0 # This ensures we check out all tags and branches.
- name: install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.0.0/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"
- name: Check if tag exists
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
id: check_mathlib_tag
run: |
git config user.name "leanprover-community-mathlib4-bot"
git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com"
if git ls-remote --heads --tags --exit-code origin "nightly-testing-${MOST_RECENT_NIGHTLY}" >/dev/null; then
BASE="nightly-testing-${MOST_RECENT_NIGHTLY}"
else
echo "This shouldn't be possible: couldn't find a 'nightly-testing-${MOST_RECENT_NIGHTLY}' branch at Mathlib. Falling back to 'nightly-testing'."
BASE=nightly-testing
fi
echo "Using base tag: $BASE"
EXISTS="$(git ls-remote --heads origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | wc -l)"
echo "Branch exists: $EXISTS"
if [ "$EXISTS" = "0" ]; then
echo "Branch does not exist, creating it."
git switch -c lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} "$BASE"
echo "leanprover/lean4-pr-releases:pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}" > lean-toolchain
git add lean-toolchain
sed -i 's,require "leanprover-community" / "batteries" @ git ".\+",require "leanprover-community" / "batteries" @ git "lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }}",' lakefile.lean
lake update batteries
git add lakefile.lean lake-manifest.json
git commit -m "Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}"
else
echo "Branch already exists, merging $BASE and bumping Batteries."
git switch lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }}
# The Mathlib `nightly-testing` branch or `nightly-testing-YYYY-MM-DD` tag may have moved since this branch was created, so merge their changes.
# (This should no longer be possible once `nightly-testing-YYYY-MM-DD` is a tag, but it is still safe to merge.)
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories
lake update batteries
git add lake-manifest.json
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}"
fi
- name: Push changes
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true'
run: |
git push origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }}

20
.github/workflows/pr-title.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Check PR title for commit convention
on:
merge_group:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
check-pr-title:
runs-on: ubuntu-latest
steps:
- name: Check PR title
uses: actions/github-script@v7
with:
script: |
const msg = context.payload.pull_request? context.payload.pull_request.title : context.payload.merge_group.head_commit.message;
console.log(`Message: ${msg}`)
if (!/^(feat|fix|doc|style|refactor|test|chore|perf): .*[^.]($|\n\n)/.test(msg)) {
core.setFailed('PR title does not follow the Commit Convention (https://leanprover.github.io/lean4/doc/dev/commit_convention.html).');
}

View File

@@ -1,31 +0,0 @@
name: sanity-check opened PRs
on:
# needs read/write GH token, do *not* execute arbitrary code from PR
pull_request_target:
types: [opened]
jobs:
check-pr:
runs-on: ubuntu-latest
steps:
- name: Check Commit Message
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: commits } = await github.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
console.log(commits[0].commit.message);
// check first commit only (and only once) since later commits might be intended to be squashed away
if (!/^(feat|fix|doc|style|refactor|test|chore|perf): .*[^.]($|\n\n)/.test(commits[0].commit.message)) {
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'Thanks for your contribution! Please make sure to follow our [Commit Convention](https://leanprover.github.io/lean4/doc/dev/commit_convention.html).',
});
}

35
.github/workflows/restart-on-label.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Restart by label
on:
pull_request_target:
types:
- unlabeled
- labeled
jobs:
restart-on-label:
runs-on: ubuntu-latest
if: contains(github.event.label.name, 'merge-ci') || contains(github.event.label.name, 'release-ci')
steps:
- run: |
# Finding latest CI workflow run on current pull request
# (unfortunately cannot search by PR number, only base branch,
# and that is't even unique given PRs from forks, but the risk
# of confusion is low and the danger is mild)
echo "Trying to find a run with branch $head_ref and commit $head_sha"
run_id="$(gh run list -e pull_request -b "$head_ref" -c "$head_sha" \
--workflow 'CI' --limit 1 --json databaseId --jq '.[0].databaseId')"
echo "Run id: ${run_id}"
gh run view "$run_id"
echo "Cancelling (just in case)"
gh run cancel "$run_id" || echo "(failed)"
echo "Waiting for 30s"
sleep 30
gh run view "$run_id"
echo "Rerunning"
gh run rerun "$run_id"
gh run view "$run_id"
shell: bash
env:
head_ref: ${{ github.head_ref }}
head_sha: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}

20
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: 'Label stale PRs'
on:
schedule:
- cron: '30 1 * * *'
workflow_dispatch:
permissions:
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
days-before-stale: -1
days-before-pr-stale: 30
days-before-close: -1
stale-pr-label: 'stale'
only-labels: 'awaiting-author'

78
.github/workflows/update-stage0.yml vendored Normal file
View File

@@ -0,0 +1,78 @@
name: Update stage0
# This action will update stage0 on master as soon as
# src/stdlib_flags.h and stage0/src/stdlib_flags.h
# are out of sync there, or when manually triggered.
# The update bypasses the merge queue to be quick.
# Also see <doc/dev/bootstrap.md>.
on:
push:
branches:
- 'master'
workflow_dispatch:
concurrency:
group: stage0
cancel-in-progress: true
jobs:
update-stage0:
runs-on: ubuntu-latest
steps:
# This action should push to an otherwise protected branch, so it
# uses a deploy key with write permissions, as suggested at
# https://stackoverflow.com/a/76135647/946226
- uses: actions/checkout@v4
with:
ssh-key: ${{secrets.STAGE0_SSH_KEY}}
- run: echo "should_update_stage0=yes" >> "$GITHUB_ENV"
- name: Check if automatic update is needed
if: github.event_name == 'push'
run: |
if diff -u src/stdlib_flags.h stage0/src/stdlib_flags.h
then
echo "src/stdlib_flags.h and stage0/src/stdlib_flags.h agree, nothing to do"
echo "should_update_stage0=no" >> "$GITHUB_ENV"
fi
- name: Setup git user
if: env.should_update_stage0 == 'yes'
run: |
git config --global user.name "Lean stage0 autoupdater"
git config --global user.email "<>"
# Would be nice, but does not work yet:
# https://github.com/DeterminateSystems/magic-nix-cache/issues/39
# This action does not run that often and building runs in a few minutes, so ok for now
#- if: env.should_update_stage0 == 'yes'
# uses: DeterminateSystems/magic-nix-cache-action@v2
- if: env.should_update_stage0 == 'yes'
name: Restore Build Cache
uses: actions/cache/restore@v4
with:
path: nix-store-cache
key: Nix Linux-nix-store-cache-${{ github.sha }}
# fall back to (latest) previous cache
restore-keys: |
Nix Linux-nix-store-cache
- if: env.should_update_stage0 == 'yes'
name: Further Set Up Nix Cache
shell: bash -euxo pipefail {0}
run: |
# Nix seems to mutate the cache, so make a copy
cp -r nix-store-cache nix-store-cache-copy || true
- if: env.should_update_stage0 == 'yes'
name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
substituters = file://${{ github.workspace }}/nix-store-cache-copy?priority=10&trusted=true https://cache.nixos.org
- if: env.should_update_stage0 == 'yes'
run: nix run .#update-stage0-commit
- if: env.should_update_stage0 == 'yes'
run: git show --stat
- if: env.should_update_stage0 == 'yes' && github.event_name == 'push'
name: Sanity check # to avoid loops
run: |
diff -u src/stdlib_flags.h stage0/src/stdlib_flags.h || exit 1
- if: env.should_update_stage0 == 'yes'
run: git push origin

9
.gitignore vendored
View File

@@ -2,7 +2,12 @@
\#*
.#*
*.lock
build
.lake
lake-manifest.json
/build
/src/lakefile.toml
/tests/lakefile.toml
/lakefile.toml
GPATH
GRTAGS
GSYMS
@@ -25,4 +30,4 @@ fwIn.txt
fwOut.txt
wdErr.txt
wdIn.txt
wdOut.txt
wdOut.txt

4
.gitmodules vendored
View File

@@ -1,4 +0,0 @@
[submodule "lake"]
path = src/lake
url = https://github.com/leanprover/lake.git
ignore = untracked

View File

@@ -1,7 +0,0 @@
{
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"[markdown]": {
"rewrap.wrappingColumn": 70
}
}

View File

@@ -11,10 +11,13 @@ foreach(var ${vars})
list(APPEND STAGE0_ARGS "-D${CMAKE_MATCH_1}=${${var}}")
elseif("${currentHelpString}" MATCHES "No help, variable specified on the command line." OR "${currentHelpString}" STREQUAL "")
list(APPEND CL_ARGS "-D${var}=${${var}}")
if("${var}" STREQUAL "USE_GMP")
if("${var}" MATCHES "USE_GMP|CHECK_OLEAN_VERSION")
# must forward options that generate incompatible .olean format
list(APPEND STAGE0_ARGS "-D${var}=${${var}}")
endif()
if("${var}" MATCHES "LLVM*")
list(APPEND STAGE0_ARGS "-D${var}=${${var}}")
endif()
elseif(("${var}" MATCHES "CMAKE_.*") AND NOT ("${var}" MATCHES "CMAKE_BUILD_TYPE") AND NOT ("${var}" MATCHES "CMAKE_HOME_DIRECTORY"))
list(APPEND PLATFORM_ARGS "-D${var}=${${var}}")
endif()
@@ -23,28 +26,46 @@ endforeach()
include(ExternalProject)
project(LEAN CXX C)
if("${CMAKE_SYSTEM_NAME}" MATCHES "Emscripten")
# For Emscripten, we build GMP before any of the stages and reuse it in all of them.
set(GMP_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/gmp-root)
set(EMSCRIPTEN_FLAGS "-s ALLOW_MEMORY_GROWTH=1 -s MAIN_MODULE=1 -O3")
ExternalProject_Add(
gmp
URL https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2
URL_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND emconfigure ./configure "CFLAGS=${EMSCRIPTEN_FLAGS}" --host=wasm32-unknown-emscripten --disable-assembly --prefix=${GMP_INSTALL_PREFIX}
BUILD_COMMAND emmake make -j4
INSTALL_COMMAND emmake make install
)
set(EXTRA_DEPENDS "gmp")
list(APPEND CL_ARGS "-DGMP_INSTALL_PREFIX=${GMP_INSTALL_PREFIX}")
list(APPEND PLATFORM_ARGS "-DGMP_INSTALL_PREFIX=${GMP_INSTALL_PREFIX}")
if(NOT (DEFINED STAGE0_CMAKE_EXECUTABLE_SUFFIX))
set(STAGE0_CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}")
endif()
# Don't do anything with cadical on wasm
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
# On CI Linux, we source cadical from Nix instead; see flake.nix
find_program(CADICAL cadical)
if(NOT CADICAL)
set(CADICAL_CXX c++)
find_program(CCACHE ccache)
if(CCACHE)
set(CADICAL_CXX "${CCACHE} ${CADICAL_CXX}")
endif()
# missing stdio locking API on Windows
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
string(APPEND CADICAL_CXXFLAGS " -DNUNLOCKED")
endif()
ExternalProject_add(cadical
PREFIX cadical
GIT_REPOSITORY https://github.com/arminbiere/cadical
GIT_TAG rel-1.9.5
CONFIGURE_COMMAND ""
# https://github.com/arminbiere/cadical/blob/master/BUILD.md#manual-build
BUILD_COMMAND $(MAKE) -f ${CMAKE_SOURCE_DIR}/src/cadical.mk CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} CXX=${CADICAL_CXX} CXXFLAGS=${CADICAL_CXXFLAGS}
BUILD_IN_SOURCE ON
INSTALL_COMMAND "")
set(CADICAL ${CMAKE_BINARY_DIR}/cadical/cadical${CMAKE_EXECUTABLE_SUFFIX} CACHE FILEPATH "path to cadical binary" FORCE)
set(EXTRA_DEPENDS "cadical")
endif()
list(APPEND CL_ARGS -DCADICAL=${CADICAL})
endif()
ExternalProject_add(stage0
SOURCE_DIR "${LEAN_SOURCE_DIR}/stage0"
SOURCE_SUBDIR src
BINARY_DIR stage0
# do not rebuild stage0 when git hash changes; it's not from this commit anyway
# (however, `CHECK_OLEAN_VERSION=ON` in CI will override this as we need to
# embed the githash into the stage 1 library built by stage 0)
CMAKE_ARGS -DSTAGE=0 -DUSE_GITHASH=OFF ${PLATFORM_ARGS} ${STAGE0_ARGS}
BUILD_ALWAYS ON # cmake doesn't auto-detect changes without a download method
INSTALL_COMMAND "" # skip install
@@ -54,7 +75,7 @@ ExternalProject_add(stage1
SOURCE_DIR "${LEAN_SOURCE_DIR}"
SOURCE_SUBDIR src
BINARY_DIR stage1
CMAKE_ARGS -DSTAGE=1 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage0 ${CL_ARGS}
CMAKE_ARGS -DSTAGE=1 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage0 -DPREV_STAGE_CMAKE_EXECUTABLE_SUFFIX=${STAGE0_CMAKE_EXECUTABLE_SUFFIX} ${CL_ARGS}
BUILD_ALWAYS ON
INSTALL_COMMAND ""
DEPENDS stage0
@@ -63,7 +84,7 @@ ExternalProject_add(stage2
SOURCE_DIR "${LEAN_SOURCE_DIR}"
SOURCE_SUBDIR src
BINARY_DIR stage2
CMAKE_ARGS -DSTAGE=2 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage1 ${CL_ARGS}
CMAKE_ARGS -DSTAGE=2 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage1 -DPREV_STAGE_CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} ${CL_ARGS}
BUILD_ALWAYS ON
INSTALL_COMMAND ""
DEPENDS stage1
@@ -73,7 +94,7 @@ ExternalProject_add(stage3
SOURCE_DIR "${LEAN_SOURCE_DIR}"
SOURCE_SUBDIR src
BINARY_DIR stage3
CMAKE_ARGS -DSTAGE=3 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage2 ${CL_ARGS}
CMAKE_ARGS -DSTAGE=3 -DPREV_STAGE=${CMAKE_BINARY_DIR}/stage2 -DPREV_STAGE_CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} ${CL_ARGS}
BUILD_ALWAYS ON
INSTALL_COMMAND ""
DEPENDS stage2
@@ -86,6 +107,10 @@ add_custom_target(update-stage0
COMMAND $(MAKE) -C stage1 update-stage0
DEPENDS stage1)
add_custom_target(update-stage0-commit
COMMAND $(MAKE) -C stage1 update-stage0-commit
DEPENDS stage1)
add_custom_target(test
COMMAND $(MAKE) -C stage1 test
DEPENDS stage1)

83
CMakePresets.json Normal file
View File

@@ -0,0 +1,83 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 10,
"patch": 0
},
"configurePresets": [
{
"name": "release",
"displayName": "Default development optimized build config",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/release"
},
{
"name": "debug",
"displayName": "Debug build config",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/debug"
},
{
"name": "sanitize",
"displayName": "Sanitize build config",
"cacheVariables": {
"LEAN_EXTRA_CXX_FLAGS": "-fsanitize=address,undefined",
"LEANC_EXTRA_FLAGS": "-fsanitize=address,undefined -fsanitize-link-c++-runtime",
"SMALL_ALLOCATOR": "OFF",
"BSYMBOLIC": "OFF"
},
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/sanitize"
},
{
"name": "sandebug",
"inherits": ["debug", "sanitize"],
"displayName": "Sanitize+debug build config",
"binaryDir": "${sourceDir}/build/sandebug"
}
],
"buildPresets": [
{
"name": "release",
"configurePreset": "release"
},
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "sanitize",
"configurePreset": "sanitize"
},
{
"name": "sandebug",
"configurePreset": "sandebug"
}
],
"testPresets": [
{
"name": "release",
"configurePreset": "release",
"output": {"outputOnFailure": true, "shortProgress": true}
},
{
"name": "debug",
"configurePreset": "debug",
"inherits": "release"
},
{
"name": "sanitize",
"configurePreset": "sanitize",
"inherits": "release"
},
{
"name": "sandebug",
"configurePreset": "sandebug",
"inherits": "release"
}
]
}

48
CODEOWNERS Normal file
View File

@@ -0,0 +1,48 @@
# Code Owners
#
# Documents responsible people per component.
# Listed persons will automatically be asked by GitHub to review a PR touching these paths.
# If multiple names are listed, a review by any of them is considered sufficient by default.
/.github/ @Kha @kim-em
/RELEASES.md @kim-em
/src/kernel/ @leodemoura
/src/lake/ @tydeu
/src/Lean/Compiler/ @leodemoura
/src/Lean/Data/Lsp/ @mhuisi
/src/Lean/Elab/Deriving/ @kim-em
/src/Lean/Elab/Tactic/ @kim-em
/src/Lean/Language/ @Kha
/src/Lean/Meta/Tactic/ @leodemoura
/src/Lean/Parser/ @Kha
/src/Lean/PrettyPrinter/ @Kha
/src/Lean/PrettyPrinter/Delaborator/ @kmill
/src/Lean/Server/ @mhuisi
/src/Lean/Widget/ @Vtec234
/src/Init/Data/ @kim-em
/src/Init/Data/Array/Lemmas.lean @digama0
/src/Init/Data/List/Lemmas.lean @digama0
/src/Init/Data/List/BasicAux.lean @digama0
/src/Init/Data/Array/Subarray.lean @david-christiansen
/src/Lean/Elab/Tactic/RCases.lean @digama0
/src/Init/RCases.lean @digama0
/src/Lean/Elab/Tactic/Ext.lean @digama0
/src/Init/Ext.lean @digama0
/src/Lean/Elab/Tactic/Simpa.lean @digama0
/src/Lean/Elab/Tactic/NormCast.lean @digama0
/src/Lean/Meta/Tactic/NormCast.lean @digama0
/src/Lean/Meta/Tactic/TryThis.lean @digama0
/src/Lean/Elab/Tactic/SimpTrace.lean @digama0
/src/Lean/Elab/Tactic/NoMatch.lean @digama0
/src/Lean/Elab/Tactic/ShowTerm.lean @digama0
/src/Lean/Elab/Tactic/Repeat.lean @digama0
/src/Lean/Meta/Tactic/Repeat.lean @digama0
/src/Lean/Meta/CoeAttr.lean @digama0
/src/Lean/Elab/GuardMsgs.lean @digama0
/src/Lean/Elab/Tactic/Guard.lean @digama0
/src/Init/Guard.lean @digama0
/src/Lean/Server/CodeActions/ @digama0
/src/Std/ @TwoFX
/src/Std/Tactic/BVDecide/ @hargoniX
/src/Lean/Elab/Tactic/BVDecide/ @hargoniX
/src/Std/Sat/ @hargoniX

View File

@@ -1,57 +1,93 @@
# Contribution Guidelines
External Contribution Guidelines
============
Thank you for your interest in contributing to Lean! There are many ways to contribute and we appreciate all of them.
In the past, we accepted most pull requests. This practice produced hard to maintain code, performance problems, and bugs. In order to improve the quality and maintainability of our codebase, we've established the following guidelines for external contributions.
## Bug reports
Helpful links
-------
Bug reports as new issues are always welcome. Please check the existing [issues](https://github.com/leanprover/lean4/issues) first.
Reduce the issue to a self-contained, reproducible test case.
If you have the chance, before reporting a bug, please search existing issues, as it's possible that
someone else has already reported your error.
If you're not sure if something is a bug or not, feel free to file a bug anyway. You may also want to discuss it with the Lean
community using the [lean4 Zulip channel](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4).
* [Development Setup](./doc/dev/index.md)
* [Testing](./doc/dev/testing.md)
* [Commit convention](./doc/dev/commit_convention.md)
## Simple fixes
Before You Submit a Pull Request (PR):
-------
Simple fixes for **typos and clear bugs** are welcome.
**Start with an Issue**: Before submitting a PR, always open an issue discussing the problem you wish to solve or the feature you'd like to add. Use the prefix `RFC:` (request for comments) if you are proposing a new feature. Ask for feedback from other users. Take the time to summarize all the feedback. This allows the maintainers to evaluate your proposal more efficiently. When creating a RFC, consider the following questions:
## Documentation
- **User Experience**: How does this feature improve the user experience?
Tutorial-like examples are very welcome.
They are useful for finding rough edges and bugs in Lean 4, for highlighting new features, and for showing how to use Lean.
If you want to store your tutorial in the Lean 4 repository to make sure future changes will not break it, we suggest the following workflow:
* Contact one of the Lean developers on Zulip, and check whether your tutorial is a good match for the Lean 4 repository.
* Send bug reports and report rough edges. We will work with you until the tutorial looks great.
* Add plenty of comments and make sure others will be able to follow it.
* Create a pull request in the Lean 4 repository. After merging, we will link it to the official documentation and make sure it becomes part of our test suite.
- **Beneficiaries**: Which Lean users and projects do benefit most from this feature/change?
You can use `.lean` or `.md` files to create your tutorial. The `.md` files are ideal when you want to format your prose using markdown. For an example, see [this `.md` file](https://github.com/leanprover/lean4/blob/master/doc/lean3changes.md).
- **Community Feedback**: Have you sought feedback or insights from other Lean users?
Contributions to the reference manual are also welcome, but since Lean 4 is changing rapidly, please contact us first using Zulip
to find out which parts are stable enough to document. We will work with you to get this kind of
pull request merged. We are also happy to meet using Zoom, Skype or Google hangout to coordinate this kind of effort.
- **Maintainability**: Will this change streamline code maintenance or simplify its structure?
As Lean 4 matures, other forms of documentation (e.g., doc-strings) will be welcome too.
**Understand the Project**: Familiarize yourself with the project, existing issues, and latest commits. Ensure your contribution aligns with the project's direction and priorities.
## "Help wanted"
**Stay Updated**: Regularly fetch and merge changes from the main branch to ensure your branch is up-to-date and can be smoothly integrated.
For issues marked as [`help wanted`](https://github.com/leanprover/lean4/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22), pull requests (PR) are welcome and we will work with you to get a PR merged. Some of these issues are nontrivial. If you are interested, please consider adding comments to the issue and/or messaging the Lean developers in [Zulip](https://leanprover.zulipchat.com/#).
**Help wanted**: We have issues tagged with ["help wanted"](https://github.com/leanprover/lean4/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22), if you want to contribute to the project, please take a look at them. If you are interested in one of them, post comments, ask questions, and engage with the core developers there.
## Unexpected Pull Requests
Quality Over Quantity:
-----
We have very few core developers, and we cannot review arbitrary pull requests (PRs). Moreover, many features involve subtle tradeoffs, and it may require significant time and energy to even assess a proposed design. We suggest the following workflow:
**Focused Changes**: Each PR should address a single, clearly-defined issue or feature. Avoid making multiple unrelated changes in a single PR.
* First, discuss your idea with the Lean community on Zulip. Ask the community to help collect examples, document the requirements, and detect complications.
* If there is broad support, create a detailed issue for it on the Lean 4 repository at GitHub, and tag the issue with `RFC`.
* Ask the community for help documenting the requirements, and for collecting examples and concerns.
* Wait for one of the core developers to give you a "go ahead". At this point, the core developers will work with you to make sure your PR gets merged.
**Write Tests**: Every new feature or bug fix should come with relevant tests. This ensures the robustness and reliability of the contribution.
We don't want to waste your time by you implementing a feature and then us not being able to merge it.
**Documentation**: Update relevant documentation, including comments in the code, to explain the logic and reasoning behind your changes.
## How to Contribute
Coding Standards:
----
* Always follow the [commit convention](https://leanprover.github.io/lean4/doc/dev/commit_convention.html).
* Follow the style of the surrounding code. When in doubt, look at other files using the particular syntax as well.
* Make sure your code is documented.
* New features or bug fixes should come with appropriate tests.
* Ensure all tests work before submitting a PR; see [Development Setup](https://leanprover.github.io/lean4/doc/make/index.html#development-setup) and [Fixing Tests](https://leanprover.github.io/lean4/doc/dev/fixing_tests.html).
**Follow the Code Style**: Ensure that your code follows the established coding style of the project.
**Lean on Lean**: Use Lean's built-in features and libraries effectively, avoiding reinventions.
**Performance**: Make sure that your changes do not introduce performance regressions. If possible, optimize the solution for speed and resource usage.
PR Submission:
---
**Descriptive Title and Summary**: The PR title should briefly explain the purpose of the PR. The summary should give more detailed information on what changes are made and why. Links to Zulip threads are not acceptable as a summary. You are responsible for summarizing the discussion, and getting support for it.
**Follow the commit convention**: Pull requests are squash merged, and the
commit message is taken from the pull request title and body, so make sure they adhere to the [commit convention](https://github.com/leanprover/lean4/blob/master/doc/dev/commit_convention.md). Put questions and extra information, which should not be part of the final commit message, into a first comment rather than the Pull Request description.
Because the change will be squashed, there is no need to polish the commit messages and history on the branch.
**Link to Relevant Issues**: Reference any issues that your PR addresses to provide context.
**Stay Responsive**: Once the PR is submitted, stay responsive to feedback and be prepared to make necessary revisions. We will close any PR that has been inactive (no response or updates from the submitter) for more than a month.
Reviews and Feedback:
----
The lean4 repo is managed by the Lean FRO's *triage team* that aims to provide initial feedback on new bug reports, PRs, and RFCs weekly.
This feedback generally consists of prioritizing the ticket using one of the following categories:
* label `P-high`: We will work on this issue
* label `P-medium`: We may work on this issue if we find the time
* label `P-low`: We are not planning to work on this issue
* *closed*: This issue is already fixed, it is not an issue, or is not sufficiently compatible with our roadmap for the project and we will not work on it nor accept external contributions on it
For *bug reports*, the listed priority reflects our commitment to fixing the issue.
It is generally indicative but not necessarily identical to the priority an external contribution addressing this bug would receive.
For *PRs* and *RFCs*, the priority reflects our commitment to reviewing them and getting them to an acceptable state.
Accepted RFCs are marked with the label `RFC accepted` and afterwards assigned a new "implementation" priority as with bug reports.
General guidelines for interacting with reviews and feedback:
**Be Patient**: Given the limited number of full-time maintainers and the volume of PRs, reviews may take some time.
**Engage Constructively**: Always approach feedback positively and constructively. Remember, reviews are about ensuring the best quality for the project, not personal criticism.
**Continuous Integration**: Ensure that all CI checks pass on your PR. Failed checks will delay the review process. The maintainers will not check PRs containing failures.
What to Expect:
----
**Not All PRs Get Merged**: While we appreciate every contribution, not all PRs will be merged. Ensure your changes align with the project's goals and quality standards.
**Feedback is a Gift**: It helps improve the project and can also help you grow as a developer or contributor.
**Community Involvement**: Engage with the Lean community on our communication channels. This can lead to better collaboration and understanding of the project's direction.

View File

@@ -1341,3 +1341,33 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
==============================================================================
CaDiCaL is under the MIT License:
==============================================================================
MIT License
Copyright (c) 2016-2021 Armin Biere, Johannes Kepler University Linz, Austria
Copyright (c) 2020-2021 Mathias Fleury, Johannes Kepler University Linz, Austria
Copyright (c) 2020-2021 Nils Froleyks, Johannes Kepler University Linz, Austria
Copyright (c) 2022-2024 Katalin Fazekas, Vienna University of Technology, Austria
Copyright (c) 2021-2024 Armin Biere, University of Freiburg, Germany
Copyright (c) 2021-2024 Mathias Fleury, University of Freiburg, Germany
Copyright (c) 2023-2024 Florian Pollitt, University of Freiburg, Germany
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,22 +1,20 @@
This is the repository for **Lean 4**, which is currently being released as milestone releases towards a first stable release.
[Lean 3](https://github.com/leanprover/lean) is still the latest stable release.
This is the repository for **Lean 4**.
# About
- [Quickstart](https://github.com/leanprover/lean4/blob/master/doc/quickstart.md)
- [Walkthrough installation video](https://www.youtube.com/watch?v=yZo6k48L0VY)
- [Quick tour video](https://youtu.be/zyXtbb_eYbY)
- [Homepage](https://leanprover.github.io)
- [Theorem Proving Tutorial](https://leanprover.github.io/theorem_proving_in_lean4/)
- [Functional Programming in Lean](https://leanprover.github.io/functional_programming_in_lean/) **first chapter is available!**
- [Manual](https://leanprover.github.io/lean4/doc/)
- [Quickstart](https://lean-lang.org/lean4/doc/quickstart.html)
- [Homepage](https://lean-lang.org)
- [Theorem Proving Tutorial](https://lean-lang.org/theorem_proving_in_lean4/)
- [Functional Programming in Lean](https://lean-lang.org/functional_programming_in_lean/)
- [Manual](https://lean-lang.org/lean4/doc/)
- [Release notes](RELEASES.md) starting at v4.0.0-m3
- [Examples](https://leanprover.github.io/lean4/doc/examples.html)
- [FAQ](https://leanprover.github.io/lean4/doc/faq.html)
- [Examples](https://lean-lang.org/lean4/doc/examples.html)
- [External Contribution Guidelines](CONTRIBUTING.md)
- [FAQ](https://lean-lang.org/lean4/doc/faq.html)
# Installation
See [Setting Up Lean](https://leanprover.github.io/lean4/doc/setup.html).
See [Setting Up Lean](https://lean-lang.org/lean4/doc/setup.html).
# Contributing
@@ -24,4 +22,4 @@ Please read our [Contribution Guidelines](CONTRIBUTING.md) first.
# Building from Source
See [Building Lean](https://leanprover.github.io/lean4/doc/make/index.html).
See [Building Lean](https://lean-lang.org/lean4/doc/make/index.html) (documentation source: [doc/make/index.md](doc/make/index.md)).

File diff suppressed because it is too large Load Diff

1
debug.log Normal file
View File

@@ -0,0 +1 @@
[0829/202002.254:ERROR:crashpad_client_win.cc(868)] not connected

View File

@@ -1,9 +0,0 @@
# used for `nix-shell https://github.com/leanprover/lean4/archive/master.tar.gz -A nix`
{ nix = (import ./shell.nix {}).nix; } //
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz";
sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; }
) {
src = ./.;
}).defaultNix

View File

@@ -1,4 +1,4 @@
open Std
open Batteries
open Lean
inductive BoolExpr where

View File

@@ -75,6 +75,7 @@
- [Significant Changes from Lean 3](./lean3changes.md)
- [Syntax Highlighting Lean in LaTeX](./syntax_highlight_in_latex.md)
- [User Widgets](examples/widgets.lean.md)
- [Semantic Highlighting](./semantic_highlighting.md)
# Development
@@ -84,10 +85,10 @@
- [macOS Setup](./make/osx-10.9.md)
- [Windows MSYS2 Setup](./make/msys2.md)
- [Windows with WSL](./make/wsl.md)
- [Nix Setup (*Experimental*)](./make/nix.md)
- [Bootstrapping](./dev/bootstrap.md)
- [Testing](./dev/testing.md)
- [Debugging](./dev/debugging.md)
- [Commit Convention](./dev/commit_convention.md)
- [Release checklist](./dev/release_checklist.md)
- [Building This Manual](./dev/mdbook.md)
- [Foreign Function Interface](./dev/ffi.md)

View File

@@ -43,3 +43,5 @@ set_option autoImplicit false
-- def compose (g : β → γ) (f : α → β) (x : α) : γ :=
-- g (f x)
```
The Lean language server provides [semantic highlighting](./semantic_highlighting.md) information to editors, and it provides
visual feedback whether an identifier has been interpreted as an auto bound implicit argument.

View File

@@ -11,4 +11,4 @@ the following command executes a simple set of examples
% bin/lean examples/ex.lean
For more information on Lean and supported editors, please see https://leanprover.github.io/documentation/.
For more information on Lean and supported editors, please see https://lean-lang.org/documentation/.

View File

@@ -1 +1,11 @@
# Characters
A value of type `Char`, also known as a character, is a [Unicode scalar value](https://www.unicode.org/glossary/#unicode_scalar_value). It is represented using an unsigned 32-bit integer and is statically guaranteed to be a valid Unicode scalar value.
Syntactically, character literals are enclosed in single quotes.
```lean
#eval 'a' -- 'a'
#eval '' -- '∀'
```
Characters are ordered and can be decidably compared using the relational operators `=`, `<`, `≤`, `>`, `≥`.

File diff suppressed because it is too large Load Diff

View File

@@ -65,19 +65,59 @@ You now have a Lean binary and library that include your changes, though their
own compilation was not influenced by them, that you can use to test your
changes on test programs whose compilation *will* be influenced by the changes.
## Updating stage0
Finally, when we want to use new language features in the library, we need to
update the stage 0 compiler, which can be done via `make -C stageN update-stage0`.
`make update-stage0` without `-C` defaults to stage1.
update the archived C source code of the stage 0 compiler in `stage0/src`.
The github repository will automatically update stage0 on `master` once
`src/stdlib_flags.h` and `stage0/src/stdlib_flags.h` are out of sync.
If you have write access to the lean4 repository, you can also manually
trigger that process, for example to be able to use new features in the compiler itself.
You can do that on <https://github.com/leanprover/lean4/actions/workflows/update-stage0.yml>
or using Github CLI with
```
gh workflow run update-stage0.yml
```
Leaving stage0 updates to the CI automation is preferable, but should you need
to do it locally, you can use `make update-stage0-commit` in `build/release` to
update `stage0` from `stage1` or `make -C stageN update-stage0-commit` to
update from another stage. This command will automatically stage the updated files
and introduce a commit,so make sure to commit your work before that.
If you rebased the branch (either onto a newer version of `master`, or fixing
up some commits prior to the stage0 update, recreate the stage0 update commits.
The script `script/rebase-stage0.sh` can be used for that.
The CI should prevent PRs with changes to stage0 (besides `stdlib_flags.h`)
from entering `master` through the (squashing!) merge queue, and label such PRs
with the `changes-stage0` label. Such PRs should have a cleaned up history,
with separate stage0 update commits; then coordinate with the admins to merge
your PR using rebase merge, bypassing the merge queue.
## Further Bootstrapping Complications
As written above, changes in meta code in the current stage usually will only
affect later stages. This is an issue in two specific cases.
* For the special case of *quotations*, it is desirable to have changes in builtin parsers affect them immediately: when the changes in the parser become active in the next stage, builtin macros implemented via quotations should generate syntax trees compatible with the new parser, and quotation patterns in builtin macros and elaborators should be able to match syntax created by the new parser and macros.
Since quotations capture the syntax tree structure during execution of the current stage and turn it into code for the next stage, we need to run the current stage's builtin parsers in quotations via the interpreter for this to work.
Caveats:
* We activate this behavior by default when building stage 1 by setting `-Dinternal.parseQuotWithCurrentStage=true`.
We force-disable it inside `macro/macro_rules/elab/elab_rules` via `suppressInsideQuot` as they are guaranteed not to run in the next stage and may need to be run in the current one, so the stage 0 parser is the correct one to use for them.
It may be necessary to extend this disabling to functions that contain quotations and are (exclusively) used by one of the mentioned commands. A function using quotations should never be used by both builtin and non-builtin macros/elaborators. Example: https://github.com/leanprover/lean4/blob/f70b7e5722da6101572869d87832494e2f8534b7/src/Lean/Elab/Tactic/Config.lean#L118-L122
* The parser needs to be reachable via an `import` statement, otherwise the version of the previous stage will silently be used.
* Only the parser code (`Parser.fn`) is affected; all metadata such as leading tokens is taken from the previous stage.
For an example, see https://github.com/leanprover/lean4/commit/f9dcbbddc48ccab22c7674ba20c5f409823b4cc1#diff-371387aed38bb02bf7761084fd9460e4168ae16d1ffe5de041b47d3ad2d22422R13
* For *non-builtin* meta code such as `notation`s or `macro`s in
`Notation.lean`, we expect changes to affect the current file and all later
files of the same stage immediately, just like outside the stdlib. To ensure
this, we need to build the stage using `-Dinterpreter.prefer_native=false` -
this, we build stage 1 using `-Dinterpreter.prefer_native=false` -
otherwise, when executing a macro, the interpreter would notice that there is
already a native symbol available for this function and run it instead of the
new IR, but the symbol is from the previous stage!
@@ -95,26 +135,11 @@ affect later stages. This is an issue in two specific cases.
further stages (e.g. after an `update-stage0`) will then need to be compiled
with the flag set to `false` again since they will expect the new signature.
For an example, see https://github.com/leanprover/lean4/commit/da4c46370d85add64ef7ca5e7cc4638b62823fbb.
When enabling `prefer_native`, we usually want to *disable* `parseQuotWithCurrentStage` as it would otherwise make quotations use the interpreter after all.
However, there is a specific case where we want to set both options to `true`: when we make changes to a non-builtin parser like `simp` that has a builtin elaborator, we cannot have the new parser be active outside of quotations in stage 1 as the builtin elaborator from stage 0 would not understand them; on the other hand, we need quotations in e.g. the builtin `simp` elaborator to produce the new syntax in the next stage.
As this issue usually affects only tactics, enabling `debug.byAsSorry` instead of `prefer_native` can be a simpler solution.
* For the special case of *quotations*, it is desirable to have changes in
built-in parsers affect them immediately: when the changes in the parser
become active in the next stage, macros implemented via quotations should
generate syntax trees compatible with the new parser, and quotation patterns
in macro and elaborators should be able to match syntax created by the new
parser and macros. Since quotations capture the syntax tree structure during
execution of the current stage and turn it into code for the next stage, we
need to run the current stage's built-in parsers in quotation via the
interpreter for this to work. Caveats:
* Since interpreting full parsers is not nearly as cheap and we rarely change
built-in syntax, this needs to be opted in using `-Dinternal.parseQuotWithCurrentStage=true`.
* The parser needs to be reachable via an `import` statement, otherwise the
version of the previous stage will silently be used.
* Only the parser code (`Parser.fn`) is affected; all metadata such as leading
tokens is taken from the previous stage.
For an example, see https://github.com/leanprover/lean4/commit/f9dcbbddc48ccab22c7674ba20c5f409823b4cc1#diff-371387aed38bb02bf7761084fd9460e4168ae16d1ffe5de041b47d3ad2d22422
(from before the flag defaulted to `false`).
For a `prefer_native` example, see https://github.com/leanprover/lean4/commit/da4c46370d85add64ef7ca5e7cc4638b62823fbb.
To modify either of these flags both for building and editing the stdlib, adjust
the code in `stage0/src/stdlib_flags.h`. The flags will automatically be reset

View File

@@ -1,10 +1,15 @@
Git Commit Convention
=====================
We are using the following convention for writing git-commit messages.
It is based on the one from AngularJS project([doc][angularjs-doc],
We are using the following convention for writing git commit messages. For pull
requests, make sure the pull request title and description follow this
convention, as the squash-merge commit will inherit title and body from the
pull request.
This convention is based on the one from the AngularJS project ([doc][angularjs-doc],
[commits][angularjs-git]).
[angularjs-git]: https://github.com/angular/angular.js/commits/master
[angularjs-doc]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#

View File

@@ -5,7 +5,7 @@ Some notes on how to debug Lean, which may also be applicable to debugging Lean
## Tracing
In `CoreM` and derived monads, we use `trace![traceCls] "msg with {interpolations}"` to fill the structured trace viewable with `set_option trace.traceCls true`.
In `CoreM` and derived monads, we use `trace[traceCls] "msg with {interpolations}"` to fill the structured trace viewable with `set_option trace.traceCls true`.
New trace classes have to be registered using `registerTraceClass` first.
Notable trace classes:
@@ -22,7 +22,9 @@ Notable trace classes:
In pure contexts or when execution is aborted before the messages are finally printed, one can instead use the term `dbg_trace "msg with {interpolations}"; val` (`;` can also be replaced by a newline), which will print the message to stderr before evaluating `val`. `dbgTraceVal val` can be used as a shorthand for `dbg_trace "{val}"; val`.
Note that if the return value is not actually used, the trace code is silently dropped as well.
In the language server, stderr output is buffered and shown as messages after a command has been elaborated, unless the option `server.stderrAsMessages` is deactivated.
By default, such stderr output is buffered and shown as messages after a command has been elaborated, which is necessary to ensure deterministic ordering of messages under parallelism.
If Lean aborts the process before it can finish the command or takes too long to do that, using `-DstderrAsMessages=false` avoids this buffering and shows `dbg_trace` output (but not `trace`s or other diagnostics) immediately.
## Debuggers

View File

@@ -11,6 +11,8 @@ There are two primary attributes for interoperating with other languages:
It can also be used with `def` to provide an internal definition, but ensuring consistency of both definitions is up to the user.
* `@[export sym] def leanSym : ...` exports `leanSym` under the unmangled symbol name `sym`.
For simple examples of how to call foreign code from Lean and vice versa, see <https://github.com/leanprover/lean4/blob/master/src/lake/examples/ffi> and <https://github.com/leanprover/lean4/blob/master/src/lake/examples/reverse-ffi>, respectively.
## The Lean ABI
The Lean Application Binary Interface (ABI) describes how the signature of a Lean declaration is encoded as a native calling convention.
@@ -21,7 +23,7 @@ If `n` is 0, the corresponding C declaration is
extern s sym;
```
where `s` is the C translation of `β` as specified in the next section.
In the case of an `@[extern]` definition, the symbol's value is guaranteed to be initialized only after calling the Lean module's initializer or that of an importing module; see [Initialization](.#init).
In the case of an `@[extern]` definition, the symbol's value is guaranteed to be initialized only after calling the Lean module's initializer or that of an importing module; see [Initialization](#initialization).
If `n` is greater than 0, the corresponding C declaration is
```c
@@ -32,7 +34,7 @@ In the case of `@[extern]` all *irrelevant* types are removed first; see next se
### Translating Types from Lean to C
* The integer types `UInt8`, ..., `UInt64`, `USize` are represented by the C types `uint8_t`, ..., `uint64_t`, `usize_t`, respectively
* The integer types `UInt8`, ..., `UInt64`, `USize` are represented by the C types `uint8_t`, ..., `uint64_t`, `size_t`, respectively
* `Char` is represented by `uint32_t`
* `Float` is represented by `double`
* An *enum* inductive type of at least 2 and at most 2^32 constructors, each of which with no parameters, is represented by the first type of `uint8_t`, `uint16_t`, `uint32_t` that is sufficient to represent all constructor indices.
@@ -45,16 +47,65 @@ In the case of `@[extern]` all *irrelevant* types are removed first; see next se
* it has a single constructor with a single parameter of *relevant* type
is represented by the representation of that parameter's type.
For example, `{ x : α // p }`, the `Subtype` structure of a value of type `α` and an irrelevant proof, is represented by the representation of `α`.
* `Nat` is represented by `lean_object *`.
Its runtime value is either a pointer to an opaque bignum object or, if the lowest bit of the "pointer" is 1 (`lean_is_scalar`), an encoded unboxed natural number (`lean_box`/`lean_unbox`).
* A universe `Sort u`, type constructor `... → Sort u`, or proposition `p : Prop` is *irrelevant* and is either statically erased (see above) or represented as a `lean_object *` with the runtime value `lean_box(0)`
* Any other type is represented by `lean_object *`.
Its runtime value is a pointer to an object of a subtype of `lean_object` (see respective declarations in `lean.h`) or the unboxed value `lean_box(cidx)` for the `cidx`th constructor of an inductive type if this constructor does not have any relevant parameters.
Its runtime value is a pointer to an object of a subtype of `lean_object` (see the "Inductive types" section below) or the unboxed value `lean_box(cidx)` for the `cidx`th constructor of an inductive type if this constructor does not have any relevant parameters.
Example: the runtime value of `u : Unit` is always `lean_box(0)`.
#### Inductive types
For inductive types which are in the fallback `lean_object *` case above and not trivial constructors, the type is stored as a `lean_ctor_object`, and `lean_is_ctor` will return true. A `lean_ctor_object` stores the constructor index in the header, and the fields are stored in the `m_objs` portion of the object.
The memory order of the fields is derived from the types and order of the fields in the declaration. They are ordered as follows:
* Non-scalar fields stored as `lean_object *`
* Fields of type `USize`
* Other scalar fields, in decreasing order by size
Within each group the fields are ordered in declaration order. **Warning**: Trivial wrapper types still count toward a field being treated as non-scalar for this purpose.
* To access fields of the first kind, use `lean_ctor_get(val, i)` to get the `i`th non-scalar field.
* To access `USize` fields, use `lean_ctor_get_usize(val, n+i)` to get the `i`th usize field and `n` is the total number of fields of the first kind.
* To access other scalar fields, use `lean_ctor_get_uintN(val, off)` or `lean_ctor_get_usize(val, off)` as appropriate. Here `off` is the byte offset of the field in the structure, starting at `n*sizeof(void*)` where `n` is the number of fields of the first two kinds.
For example, a structure such as
```lean
structure S where
ptr_1 : Array Nat
usize_1 : USize
sc64_1 : UInt64
ptr_2 : { x : UInt64 // x > 0 } -- wrappers don't count as scalars
sc64_2 : Float -- `Float` is 64 bit
sc8_1 : Bool
sc16_1 : UInt16
sc8_2 : UInt8
sc64_3 : UInt64
usize_2 : USize
ptr_3 : Char -- trivial wrapper around `UInt32`
sc32_1 : UInt32
sc16_2 : UInt16
```
would get re-sorted into the following memory order:
* `S.ptr_1` - `lean_ctor_get(val, 0)`
* `S.ptr_2` - `lean_ctor_get(val, 1)`
* `S.ptr_3` - `lean_ctor_get(val, 2)`
* `S.usize_1` - `lean_ctor_get_usize(val, 3)`
* `S.usize_2` - `lean_ctor_get_usize(val, 4)`
* `S.sc64_1` - `lean_ctor_get_uint64(val, sizeof(void*)*5)`
* `S.sc64_2` - `lean_ctor_get_float(val, sizeof(void*)*5 + 8)`
* `S.sc64_3` - `lean_ctor_get_uint64(val, sizeof(void*)*5 + 16)`
* `S.sc32_1` - `lean_ctor_get_uint32(val, sizeof(void*)*5 + 24)`
* `S.sc16_1` - `lean_ctor_get_uint16(val, sizeof(void*)*5 + 28)`
* `S.sc16_2` - `lean_ctor_get_uint16(val, sizeof(void*)*5 + 30)`
* `S.sc8_1` - `lean_ctor_get_uint8(val, sizeof(void*)*5 + 32)`
* `S.sc8_2` - `lean_ctor_get_uint8(val, sizeof(void*)*5 + 33)`
### Borrowing
By default, all `lean_object *` parameters of an `@[extern]` function are considered *owned*, i.e. the external code is passed a "virtual RC token" and is responsible for passing this token along to another consuming function (exactly once) or freeing it via `lean_dec`.
@@ -70,13 +121,13 @@ When including Lean code as part of a larger program, modules must be *initializ
Module initialization entails
* initialization of all "constants" (nullary functions), including closed terms lifted out of other functions
* execution of all `[init]` functions
* execution of all `[builtinInit]` functions, if the `builtin` parameter of the module initializer has been set
* execution of all `[builtin_init]` functions, if the `builtin` parameter of the module initializer has been set
The module initializer is automatically run with the `builtin` flag for executables compiled from Lean code and for "plugins" loaded with `lean --plugin`.
For all other modules imported by `lean`, the initializer is run without `builtin`.
Thus `[init]` functions are run iff their module is imported, regardless of whether they have native code available or not, while `[builtinInit]` functions are only run for native executable or plugins, regardless of whether their module is imported or not.
Thus `[init]` functions are run iff their module is imported, regardless of whether they have native code available or not, while `[builtin_init]` functions are only run for native executable or plugins, regardless of whether their module is imported or not.
`lean` uses built-in initializers for e.g. registering basic parsers that should be available even without importing their module (which is necessary for bootstrapping).
The initializer for module `A.B` is called `initialize_A_B` and will automatically initialize any imported modules.
Module initializers are idempotent (when run with the same `builtin` flag), but not thread-safe.
Together with initialization of the Lean runtime, you should execute code like the following exactly once before accessing any Lean declarations:
@@ -109,6 +160,15 @@ if (lean_io_result_is_ok(res)) {
lean_io_mark_end_initialization();
```
In addition, any other thread not spawned by the Lean runtime itself must be initialized for Lean use by calling
```c
void lean_initialize_thread();
```
and should be finalized in order to free all thread-local resources by calling
```c
void lean_finalize_thread();
```
## `@[extern]` in the Interpreter
The interpreter can run Lean declarations for which symbols are available in loaded shared libraries, which includes `@[extern]` declarations.
@@ -119,4 +179,4 @@ Thus to e.g. run `#eval` on such a declaration, you need to
Note that it is not sufficient to load the foreign library containing the external symbol because the interpreter depends on code that is emitted for each `@[extern]` declaration.
Thus it is not possible to interpret an `@[extern]` declaration in the same file.
See `tests/compiler/foreign` for an example.
See [`tests/compiler/foreign`](https://github.com/leanprover/lean4/tree/master/tests/compiler/foreign/) for an example.

View File

@@ -1,6 +1,6 @@
# Development Workflow
If you want to make changes to Lean itself, start by [building Lean](../make/index.html) from a clean checkout to make sure that everything is set up correctly.
If you want to make changes to Lean itself, start by [building Lean](../make/index.md) from a clean checkout to make sure that everything is set up correctly.
After that, read on below to find out how to set up your editor for changing the Lean source code, followed by further sections of the development manual where applicable such as on the [test suite](testing.md) and [commit convention](commit_convention.md).
If you are planning to make any changes that may affect the compilation of Lean itself, e.g. changes to the parser, elaborator, or compiler, you should first read about the [bootstrapping pipeline](bootstrap.md).
@@ -30,20 +30,14 @@ powershell -f elan-init.ps1 --default-toolchain none
del elan-init.ps1
```
You can use `elan toolchain link` to give a specific stage build
directory a reference name, then use `elan override set` to associate
such a name to the current directory. We usually want to use `stage0`
for editing files in `src` and `stage1` for everything else (e.g.
tests).
The `lean-toolchain` files in the Lean 4 repository are set up to use the `lean4-stage0`
toolchain for editing files in `src` and the `lean4` toolchain for editing files in `tests`.
Run the following commands to make `lean4` point at `stage1` and `lean4-stage0` point at `stage0`:
```bash
# in the Lean rootdir
elan toolchain link lean4 build/release/stage1
elan toolchain link lean4-stage0 build/release/stage0
# make `lean` etc. point to stage1 in the rootdir and subdirs
elan override set lean4
cd src
# make `lean` etc. point to stage0 anywhere inside `src`
elan override set lean4-stage0
```
You can also use the `+toolchain` shorthand (e.g. `lean +lean4-debug`) to switch
@@ -57,3 +51,32 @@ You might find that debugging through elan, e.g. via `gdb lean`, disables some
things like symbol autocompletion because at first only the elan proxy binary
is loaded. You can instead pass the explicit path to `bin/lean` in your build
folder to gdb, or use `gdb $(elan which lean)`.
It is also possible to generate releases that others can use,
simply by pushing a tag to your fork of the Lean 4 github repository
(and waiting about an hour; check the `Actions` tab for completion).
If you push `my-tag` to a fork in your github account `my_name`,
you can then put `my_name/lean4:my-tag` in your `lean-toolchain` file in a project using `lake`.
(You must use a tag name that does not start with a numeral, or contain `_`).
### VS Code
There is a `lean.code-workspace` file that correctly sets up VS Code with workspace roots for the stage0/stage1 setup described above as well as with other settings.
You should always load it when working on Lean, such as by invoking
```
code lean.code-workspace
```
on the command line.
### `ccache`
Lean's build process uses [`ccache`](https://ccache.dev/) if it is
installed to speed up recompilation of the generated C code. Without
`ccache`, you'll likely spend more time than necessary waiting on
rebuilds - it's a good idea to make sure it's installed.
### `prelude`
Unlike most Lean projects, all submodules of the `Lean` module begin with the
`prelude` keyword. This disables the automated import of `Init`, meaning that
developers need to figure out their own subset of `Init` to import. This is done
such that changing files in `Init` doesn't force a full rebuild of `Lean`.

View File

@@ -1,7 +1,7 @@
# Documentation
The Lean `doc` folder contains the [Lean Manual](https://leanprover.github.io/lean4/doc/) and is
authored in a combination of markdown (*.md) files and literate Lean files. The .lean files are
The Lean `doc` folder contains the [Lean Manual](https://lean-lang.org/lean4/doc/) and is
authored in a combination of markdown (`*.md`) files and literate Lean files. The .lean files are
preprocessed using a tool called [LeanInk](https://github.com/leanprover/leanink) and
[Alectryon](https://github.com/Kha/alectryon) which produces a generated markdown file. We then run
`mdbook` on the result to generate the html pages.
@@ -53,25 +53,28 @@ Then run the following:
cargo install --git https://github.com/leanprover/mdBook mdbook
```
1. Clone https://github.com/leanprover/LeanInk.git and run `lake build` then copy the resulting
executable to your `$HOME/.elan/bin` folder or `%USERPROFILE%\.elan\bin` so Alectryon can find it
there.
1. Clone https://github.com/leanprover/LeanInk.git and run `lake build` then make the resulting
binary available to Alectryon using e.g.
```bash
# make `leanInk` available in the current shell
export PATH=$PWD/build/bin:$PATH
```
1. Create a Python 3.10 environment.
1. Install the following packages:
1. Install Alectryon:
```
python3 -m pip install git+https://github.com/Kha/alectryon.git@typeid
```
1. Now you are ready to process the *.lean files using Alectryon as follows:
1. Now you are ready to process the `*.lean` files using Alectryon as follows:
```
cd lean4/doc
alectryon --frontend lean4+markup examples\palindromes.lean --backend webpage -o palindromes.lean.md
alectryon --frontend lean4+markup examples/palindromes.lean --backend webpage -o palindromes.lean.md
```
And repeat this for the other .lean files you care about or write a script to process them all.
Repeat this for the other .lean files you care about or write a script to process them all.
1. Now you can build the book using:
```
@@ -80,7 +83,7 @@ And repeat this for the other .lean files you care about or write a script to pr
```
This will put the HTML in a `out` folder so you can load `out/index.html` in your web browser and
it should look like https://leanprover.github.io/lean4/doc/.
it should look like https://lean-lang.org/lean4/doc/.
1. It is also handy to use e.g. [`mdbook watch`](https://rust-lang.github.io/mdBook/cli/watch.html)
in the `doc/` folder so that it keeps the html up to date while you are editing.

View File

@@ -0,0 +1,262 @@
# Releasing a stable version
This checklist walks you through releasing a stable version.
See below for the checklist for release candidates.
We'll use `v4.6.0` as the intended release version as a running example.
- One week before the planned release, ensure that
(1) someone has written the release notes and
(2) someone has written the first draft of the release blog post.
If there is any material in `./releases_drafts/` on the `releases/v4.6.0` branch, then the release notes are not done.
(See the section "Writing the release notes".)
- `git checkout releases/v4.6.0`
(This branch should already exist, from the release candidates.)
- `git pull`
- In `src/CMakeLists.txt`, verify you see
- `set(LEAN_VERSION_MINOR 6)` (for whichever `6` is appropriate)
- `set(LEAN_VERSION_IS_RELEASE 1)`
- (both of these should already be in place from the release candidates)
- `git tag v4.6.0`
- `git push $REMOTE v4.6.0`, where `$REMOTE` is the upstream Lean repository (e.g., `origin`, `upstream`)
- Now wait, while CI runs.
- You can monitor this at `https://github.com/leanprover/lean4/actions/workflows/ci.yml`,
looking for the `v4.6.0` tag.
- This step can take up to an hour.
- If you are intending to cut the next release candidate on the same day,
you may want to start on the release candidate checklist now.
- Go to https://github.com/leanprover/lean4/releases and verify that the `v4.6.0` release appears.
- Edit the release notes on Github to select the "Set as the latest release".
- Follow the instructions in creating a release candidate for the "GitHub release notes" step,
now that we have a written `RELEASES.md` section.
Do a quick sanity check.
- Next, we will move a curated list of downstream repos to the latest stable release.
- For each of the repositories listed below:
- Make a PR to `master`/`main` changing the toolchain to `v4.6.0`
- Update the toolchain file
- In the Lakefile, if there are dependencies on specific version tags of dependencies that you've already pushed as part of this process, update them to the new tag.
If they depend on `main` or `master`, don't change this; you've just updated the dependency, so it will work and be saved in the manifest
- Run `lake update`
- The PR title should be "chore: bump toolchain to v4.6.0".
- Merge the PR once CI completes.
- Create the tag `v4.6.0` from `master`/`main` and push it.
- Merge the tag `v4.6.0` into the `stable` branch and push it.
- We do this for the repositories:
- [lean4checker](https://github.com/leanprover/lean4checker)
- No dependencies
- Toolchain bump PR
- Create and push the tag
- Merge the tag into `stable`
- [Batteries](https://github.com/leanprover-community/batteries)
- No dependencies
- Toolchain bump PR
- Create and push the tag
- Merge the tag into `stable`
- [ProofWidgets4](https://github.com/leanprover-community/ProofWidgets4)
- Dependencies: `Batteries`
- Note on versions and branches:
- `ProofWidgets` uses a sequential version tagging scheme, e.g. `v0.0.29`,
which does not refer to the toolchain being used.
- Make a new release in this sequence after merging the toolchain bump PR.
- `ProofWidgets` does not maintain a `stable` branch.
- Toolchain bump PR
- Create and push the tag, following the version convention of the repository
- [Aesop](https://github.com/leanprover-community/aesop)
- Dependencies: `Batteries`
- Toolchain bump PR including updated Lake manifest
- Create and push the tag
- Merge the tag into `stable`
- [doc-gen4](https://github.com/leanprover/doc-gen4)
- Dependencies: exist, but they're not part of the release workflow
- Toolchain bump PR including updated Lake manifest
- Create and push the tag
- There is no `stable` branch; skip this step
- [Verso](https://github.com/leanprover/verso)
- Dependencies: exist, but they're not part of the release workflow
- The `SubVerso` dependency should be compatible with _every_ Lean release simultaneously, rather than following this workflow
- Toolchain bump PR including updated Lake manifest
- Create and push the tag
- There is no `stable` branch; skip this step
- [import-graph](https://github.com/leanprover-community/import-graph)
- Toolchain bump PR including updated Lake manifest
- Create and push the tag
- There is no `stable` branch; skip this step
- [Mathlib](https://github.com/leanprover-community/mathlib4)
- Dependencies: `Aesop`, `ProofWidgets4`, `lean4checker`, `Batteries`, `doc-gen4`, `import-graph`
- Toolchain bump PR notes:
- In addition to updating the `lean-toolchain` and `lakefile.lean`,
in `.github/workflows/lean4checker.yml` update the line
`git checkout v4.6.0` to the appropriate tag.
- Push the PR branch to the main Mathlib repository rather than a fork, or CI may not work reliably
- Create and push the tag
- Create a new branch from the tag, push it, and open a pull request against `stable`.
Coordinate with a Mathlib maintainer to get this merged.
- [REPL](https://github.com/leanprover-community/repl)
- Dependencies: `Mathlib` (for test code)
- Note that there are two copies of `lean-toolchain`/`lakefile.lean`:
in the root, and in `test/Mathlib/`. Edit both, and run `lake update` in both directories.
- Toolchain bump PR including updated Lake manifest
- Create and push the tag
- Merge the tag into `stable`
- The `v4.6.0` section of `RELEASES.md` is out of sync between
`releases/v4.6.0` and `master`. This should be reconciled:
- Replace the `v4.6.0` section on `master` with the `v4.6.0` section on `releases/v4.6.0`
and commit this to `master`.
- Merge the release announcement PR for the Lean website - it will be deployed automatically
- Finally, make an announcement!
This should go in https://leanprover.zulipchat.com/#narrow/stream/113486-announce, with topic `v4.6.0`.
Please see previous announcements for suggested language.
You will want a few bullet points for main topics from the release notes.
Link to the blog post from the Zulip announcement.
- Make sure that whoever is handling social media knows the release is out.
## Optimistic(?) time estimates:
- Initial checks and push the tag: 30 minutes.
- Waiting for the release: 60 minutes.
- Fixing release notes: 10 minutes.
- Bumping toolchains in downstream repositories, up to creating the Mathlib PR: 30 minutes.
- Waiting for Mathlib CI and bors: 120 minutes.
- Finalizing Mathlib tags and stable branch, and updating REPL: 15 minutes.
- Posting announcement and/or blog post: 20 minutes.
# Creating a release candidate.
This checklist walks you through creating the first release candidate for a version of Lean.
We'll use `v4.7.0-rc1` as the intended release version in this example.
- Decide which nightly release you want to turn into a release candidate.
We will use `nightly-2024-02-29` in this example.
- It is essential that Batteries and Mathlib already have reviewed branches compatible with this nightly.
- Check that both Batteries and Mathlib's `bump/v4.7.0` branch contain `nightly-2024-02-29`
in their `lean-toolchain`.
- The steps required to reach that state are beyond the scope of this checklist, but see below!
- Create the release branch from this nightly tag:
```
git remote add nightly https://github.com/leanprover/lean4-nightly.git
git fetch nightly tag nightly-2024-02-29
git checkout nightly-2024-02-29
git checkout -b releases/v4.7.0
```
- In `RELEASES.md` replace `Development in progress` in the `v4.7.0` section with `Release notes to be written.`
- We will rely on automatically generated release notes for release candidates,
and the written release notes will be used for stable versions only.
It is essential to choose the nightly that will become the release candidate as early as possible, to avoid confusion.
- In `src/CMakeLists.txt`,
- verify that you see `set(LEAN_VERSION_MINOR 7)` (for whichever `7` is appropriate); this should already have been updated when the development cycle began.
- `set(LEAN_VERSION_IS_RELEASE 1)` (this should be a change; on `master` and nightly releases it is always `0`).
- Commit your changes to `src/CMakeLists.txt`, and push.
- `git tag v4.7.0-rc1`
- `git push origin v4.7.0-rc1`
- Ping the FRO Zulip that release notes need to be written. The release notes do not block completing the rest of this checklist.
- Now wait, while CI runs.
- You can monitor this at `https://github.com/leanprover/lean4/actions/workflows/ci.yml`, looking for the `v4.7.0-rc1` tag.
- This step can take up to an hour.
- (GitHub release notes) Once the release appears at https://github.com/leanprover/lean4/releases/
- Verify that the release is marked as a prerelease (this should have been done automatically by the CI release job).
- In the "previous tag" dropdown, select `v4.6.0`, and click "Generate release notes".
This will add a list of all the commits since the last stable version.
- Delete "update stage0" commits, and anything with a completely inscrutable commit message.
- Next, we will move a curated list of downstream repos to the release candidate.
- This assumes that for each repository either:
* There is already a *reviewed* branch `bump/v4.7.0` containing the required adaptations.
The preparation of this branch is beyond the scope of this document.
* The repository does not need any changes to move to the new version.
- For each of the target repositories:
- If the repository does not need any changes (i.e. `bump/v4.7.0` does not exist) then create
a new PR updating `lean-toolchain` to `leanprover/lean4:v4.7.0-rc1` and running `lake update`.
- Otherwise:
- Checkout the `bump/v4.7.0` branch.
- Verify that the `lean-toolchain` is set to the nightly from which the release candidate was created.
- `git merge origin/master`
- Change the `lean-toolchain` to `leanprover/lean4:v4.7.0-rc1`
- In `lakefile.lean`, change any dependencies which were using `nightly-testing` or `bump/v4.7.0` branches
back to `master` or `main`, and run `lake update` for those dependencies.
- Run `lake build` to ensure that dependencies are found (but it's okay to stop it after a moment).
- `git commit`
- `git push`
- Open a PR from `bump/v4.7.0` to `master`, and either merge it yourself after CI, if appropriate,
or notify the maintainers that it is ready to go.
- Once the PR has been merged, tag `master` with `v4.7.0-rc1` and push this tag.
- We do this for the same list of repositories as for stable releases, see above.
As above, there are dependencies between these, and so the process above is iterative.
It greatly helps if you can merge the `bump/v4.7.0` PRs yourself!
It is essential for Mathlib CI that you then create the next `bump/v4.8.0` branch
for the next development cycle.
Set the `lean-toolchain` file on this branch to same `nightly` you used for this release.
- For Batteries/Aesop/Mathlib, which maintain a `nightly-testing` branch, make sure there is a tag
`nightly-testing-2024-02-29` with date corresponding to the nightly used for the release
(create it if not), and then on the `nightly-testing` branch `git reset --hard master`, and force push.
- Make an announcement!
This should go in https://leanprover.zulipchat.com/#narrow/stream/113486-announce, with topic `v4.7.0-rc1`.
Please see previous announcements for suggested language.
You will want a few bullet points for main topics from the release notes.
Please also make sure that whoever is handling social media knows the release is out.
- Begin the next development cycle (i.e. for `v4.8.0`) on the Lean repository, by making a PR that:
- Updates `src/CMakeLists.txt` to say `set(LEAN_VERSION_MINOR 8)`
- Replaces the "release notes will be copied" text in the `v4.6.0` section of `RELEASES.md` with the
finalized release notes from the `releases/v4.6.0` branch.
- Replaces the "development in progress" in the `v4.7.0` section of `RELEASES.md` with
```
Release candidate, release notes will be copied from the branch `releases/v4.7.0` once completed.
```
and inserts the following section before that section:
```
v4.8.0
----------
Development in progress.
```
- Removes all the entries from the `./releases_drafts/` folder.
- Titled "chore: begin development cycle for v4.8.0"
## Time estimates:
Slightly longer than the corresponding steps for a stable release.
Similar process, but more things go wrong.
In particular, updating the downstream repositories is significantly more work
(because we need to merge existing `bump/v4.7.0` branches, not just update a toolchain).
# Preparing `bump/v4.7.0` branches
While not part of the release process per se,
this is a brief summary of the work that goes into updating Batteries/Aesop/Mathlib to new versions.
Please read https://leanprover-community.github.io/contribute/tags_and_branches.html
* Each repo has an unreviewed `nightly-testing` branch that
receives commits automatically from `master`, and
has its toolchain updated automatically for every nightly.
(Note: the aesop branch is not automated, and is updated on an as needed basis.)
As a consequence this branch is often broken.
A bot posts in the (private!) "Mathlib reviewers" stream on Zulip about the status of these branches.
* We fix the breakages by committing directly to `nightly-testing`: there is no PR process.
* This can either be done by the person managing this process directly,
or by soliciting assistance from authors of files, or generally helpful people on Zulip!
* Each repo has a `bump/v4.7.0` which accumulates reviewed changes adapting to new versions.
* Once `nightly-testing` is working on a given nightly, say `nightly-2024-02-15`, we will create a PR to `bump/v4.7.0`.
* For Mathlib, there is a script in `scripts/create-adaptation-pr.sh` that automates this process.
* For Batteries and Aesop it is currently manual.
* For all of these repositories, the process is the same:
* Make sure `bump/v4.7.0` is up to date with `master` (by merging `master`, no PR necessary)
* Create from `bump/v4.7.0` a `bump/nightly-2024-02-15` branch.
* In that branch, `git merge nightly-testing` to bring across changes from `nightly-testing`.
* Sanity check changes, commit, and make a PR to `bump/v4.7.0` from the `bump/nightly-2024-02-15` branch.
* Solicit review, merge the PR into `bump/v4.7.0`.
* It is always okay to merge in the following directions:
`master` -> `bump/v4.7.0` -> `bump/nightly-2024-02-15` -> `nightly-testing`.
Please remember to push any merges you make to intermediate steps!
# Writing the release notes
We are currently trying a system where release notes are compiled all at once from someone looking through the commit history.
The exact steps are a work in progress.
Here is the general idea:
* The work is done right on the `releases/v4.6.0` branch sometime after it is created but before the stable release is made.
The release notes for `v4.6.0` will later be copied to `master` when we begin a new development cycle.
* There can be material for release notes entries in commit messages.
* There can also be pre-written entries in `./releases_drafts`, which should be all incorporated in the release notes and then deleted from the branch.
See `./releases_drafts/README.md` for more information.
* The release notes should be written from a downstream expert user's point of view.
This section will be updated when the next release notes are written (for `v4.10.0`).

View File

@@ -5,7 +5,6 @@ After [building Lean](../make/index.md) you can run all the tests using
cd build/release
make test ARGS=-j4
```
Change the 4 to the maximum number of parallel tests you want to
allow. The best choice is the number of CPU cores on your machine as
the tests are mostly CPU bound. You can find the number of processors
@@ -17,6 +16,12 @@ adding the `-C stageN` argument. The default when run as above is stage 1. The
Lean tests will automatically use that stage's corresponding Lean
executables
Running `make test` will not pick up new test files; run
```bash
cmake build/release/stage1
```
to update the list of tests.
You can also use `ctest` directly if you are in the right folder. So
to run stage1 tests with a 300 second timeout run this:
@@ -24,6 +29,9 @@ to run stage1 tests with a 300 second timeout run this:
cd build/release/stage1
ctest -j 4 --output-on-failure --timeout 300
```
Useful `ctest` flags are `-R <name of test>` to run a single test, and
`--rerun-failed` to run all tests that failed during the last run.
You can also pass `ctest` flags via `make test ARGS="--rerun-failed"`.
To get verbose output from ctest pass the `--verbose` command line
option. Test output is normally suppressed and only summary
@@ -33,17 +41,17 @@ information is displayed. This option will show all test output.
All these tests are included by [src/shell/CMakeLists.txt](https://github.com/leanprover/lean4/blob/master/src/shell/CMakeLists.txt):
- `tests/lean`: contains tests that come equipped with a
.lean.expected.out file. The driver script `test_single.sh` runs
- [`tests/lean`](https://github.com/leanprover/lean4/tree/master/tests/lean/): contains tests that come equipped with a
.lean.expected.out file. The driver script [`test_single.sh`](https://github.com/leanprover/lean4/tree/master/tests/lean/test_single.sh) runs
each test and checks the actual output (*.produced.out) with the
checked in expected output.
- `tests/lean/run`: contains tests that are run through the lean
- [`tests/lean/run`](https://github.com/leanprover/lean4/tree/master/tests/lean/run/): contains tests that are run through the lean
command line one file at a time. These tests only look for error
codes and do not check the expected output even though output is
produced, it is ignored.
- `tests/lean/interactive`: are designed to test server requests at a
- [`tests/lean/interactive`](https://github.com/leanprover/lean4/tree/master/tests/lean/interactive/): are designed to test server requests at a
given position in the input file. Each .lean file contains comments
that indicate how to simulate a client request at that position.
using a `--^` point to the line position. Example:
@@ -53,7 +61,7 @@ All these tests are included by [src/shell/CMakeLists.txt](https://github.com/le
Bla.
--^ textDocument/completion
```
In this example, the test driver `test_single.sh` will simulate an
In this example, the test driver [`test_single.sh`](https://github.com/leanprover/lean4/tree/master/tests/lean/interactive/test_single.sh) will simulate an
auto-completion request at `Bla.`. The expected output is stored in
a .lean.expected.out in the json format that is part of the
[Language Server
@@ -70,23 +78,33 @@ All these tests are included by [src/shell/CMakeLists.txt](https://github.com/le
--^ collectDiagnostics
```
- `tests/lean/server`: Tests more of the Lean `--server` protocol.
- [`tests/lean/server`](https://github.com/leanprover/lean4/tree/master/tests/lean/server/): Tests more of the Lean `--server` protocol.
There are just a few of them, and it uses .log files containing
JSON.
- `tests/compiler`: contains tests that will run the Lean compiler and
- [`tests/compiler`](https://github.com/leanprover/lean4/tree/master/tests/compiler/): contains tests that will run the Lean compiler and
build an executable that is executed and the output is compared to
the .lean.expected.out file. This test also contains a subfolder
`foreign` which shows how to extend Lean using C++.
[`foreign`](https://github.com/leanprover/lean4/tree/master/tests/compiler/foreign/) which shows how to extend Lean using C++.
- `tests/lean/trust0`: tests that run Lean in a mode that Lean doesn't
- [`tests/lean/trust0`](https://github.com/leanprover/lean4/tree/master/tests/lean/trust0): tests that run Lean in a mode that Lean doesn't
even trust the .olean files (i.e., trust 0).
- `tests/bench`: contains performance tests.
- [`tests/bench`](https://github.com/leanprover/lean4/tree/master/tests/bench/): contains performance tests.
- `tests/plugin`: tests that compiled Lean code can be loaded into
- [`tests/plugin`](https://github.com/leanprover/lean4/tree/master/tests/plugin/): tests that compiled Lean code can be loaded into
`lean` via the `--plugin` command line option.
## Writing Good Tests
Every test file should contain:
* an initial `/-! -/` module docstring summarizing the test's purpose
* a module docstring for each test section that describes what is tested
and, if not 100% clear, why that is the desirable behavior
At the time of writing, most tests do not follow these new guidelines yet.
For an example of a conforming test, see [`tests/lean/1971.lean`](https://github.com/leanprover/lean4/tree/master/tests/lean/1971.lean).
## Fixing Tests
When the Lean source code or the standard library are modified, some of the
@@ -101,7 +119,7 @@ First, we must install [meld](http://meldmerge.org/). On Ubuntu, we can do it by
sudo apt-get install meld
```
Now, suppose `bad_class.lean` test is broken. We can see the problem by going to `test/lean` directory and
Now, suppose `bad_class.lean` test is broken. We can see the problem by going to [`tests/lean`](https://github.com/leanprover/lean4/tree/master/tests/lean) directory and
executing
```
@@ -114,8 +132,3 @@ outputs. `meld` can also be used to repair the problems.
In Emacs, we can also execute `M-x lean4-diff-test-file` to check/diff the file of the current buffer.
To mass-copy all `.produced.out` files to the respective `.expected.out` file, use `tests/lean/copy-produced`.
When using the Nix setup, add `--keep-failed` to the `nix build` call and then call
```sh
tests/lean/copy-produced <build-dir>/source/tests/lean
```
instead where `<build-dir>` is the path printed out by `nix build`.

View File

@@ -0,0 +1,22 @@
/- "Hello world" -/
#eval "hello" ++ " " ++ "world"
-- "hello world"
#check true
-- Bool
def x := 10
#eval x + 2
-- 12
def double (x : Int) := 2*x
#eval double 3
-- 6
#check double
-- Int → Int
example : double 4 = 8 := rfl

View File

@@ -0,0 +1,19 @@
/- Dependent pattern matching -/
inductive Vector (α : Type u) : Nat Type u
| nil : Vector α 0
| cons : α Vector α n Vector α (n+1)
infix:67 "::" => Vector.cons
def Vector.zip : Vector α n Vector β n Vector (α × β) n
| nil, nil => nil
| a::as, b::bs => (a, b) :: zip as bs
#print Vector.zip
/-
def Vector.zip.{u_1, u_2} : {α : Type u_1} → {n : Nat} → {β : Type u_2} → Vector α n → Vector β n → Vector (α × β) n :=
fun {α} {n} {β} x x_1 =>
Vector.brecOn (motive := fun {n} x => {β : Type u_2} → Vector β n → Vector (α × β) n) x
...
-/

View File

@@ -0,0 +1,22 @@
/- Structures -/
structure Point where
x : Int := 0
y : Int := 0
deriving Repr
#eval Point.x (Point.mk 10 20)
-- 10
#eval { x := 10, y := 20 : Point }
def p : Point := { y := 20 }
#eval p.x
#eval p.y
#eval { p with x := 5 }
-- { x := 5, y := 20 }
structure Point3D extends Point where
z : Int

View File

@@ -0,0 +1,28 @@
/- Type classes -/
namespace Example
class ToString (α : Type u) where
toString : α String
#check @ToString.toString
-- {α : Type u_1} → [self : ToString α] → α → String
instance : ToString String where
toString s := s
instance : ToString Bool where
toString b := if b then "true" else "false"
#eval ToString.toString "hello"
export ToString (toString)
#eval toString true
-- "true"
-- #eval toString (true, "hello") -- Error
instance [ToString α] [ToString β] : ToString (α × β) where
toString p := "(" ++ toString p.1 ++ ", " ++ toString p.2 ++ ")"
#eval toString (true, "hello")
-- "(true, hello)"
end Example

View File

@@ -0,0 +1,44 @@
/- Type classes are heavily used in Lean -/
namespace Example
class Mul (α : Type u) where
mul : α α α
infixl:70 " * " => Mul.mul
def double [Mul α] (a : α) := a * a
class Semigroup (α : Type u) extends Mul α where
mul_assoc : a b c : α, (a * b) * c = a * (b * c)
instance : Semigroup Nat where
mul := Nat.mul
mul_assoc := Nat.mul_assoc
#eval double 5
class Functor (f : Type u Type v) : Type (max (u+1) v) where
map : (α β) f α f β
infixr:100 " <$> " => Functor.map
class LawfulFunctor (f : Type u Type v) [Functor f] : Prop where
id_map (x : f α) : id <$> x = x
comp_map (g : α β) (h : β γ) (x : f α) :(h g) <$> x = h <$> g <$> x
end Example
/-
`Deriving instances automatically`
We have seen `deriving Repr` in a few examples.
It is an instance generator.
Lean comes equipped with generators for the following classes.
`Repr`, `Inhabited`, `BEq`, `DecidableEq`,
`Hashable`, `Ord`, `FromToJson`, `SizeOf`
-/
inductive Tree (α : Type u) where
| leaf (val : α)
| node (left right : Tree α)
deriving DecidableEq, Ord, Inhabited, Repr

View File

@@ -0,0 +1,31 @@
/- Tactics -/
example : p q p q p := by
intro hp hq
apply And.intro
exact hp
apply And.intro
exact hq
exact hp
example : p q p q p := by
intro hp hq; apply And.intro hp; exact And.intro hq hp
/- Structuring proofs -/
example : p q p q p := by
intro hp hq
apply And.intro
case left => exact hp
case right =>
apply And.intro
case left => exact hq
case right => exact hp
example : p q p q p := by
intro hp hq
apply And.intro
. exact hp
. apply And.intro
. exact hq
. exact hp

View File

@@ -0,0 +1,19 @@
/- intro tactic variants -/
example (p q : α Prop) : ( x, p x q x) x, q x p x := by
intro h
match h with
| Exists.intro w (And.intro hp hq) => exact Exists.intro w (And.intro hq hp)
example (p q : α Prop) : ( x, p x q x) x, q x p x := by
intro (Exists.intro _ (And.intro hp hq))
exact Exists.intro _ (And.intro hq hp)
example (p q : α Prop) : ( x, p x q x) x, q x p x := by
intro _, hp, hq
exact _, hq, hp
example (α : Type) (p q : α Prop) : ( x, p x q x) x, q x p x := by
intro
| _, .inl h => exact _, .inr h
| _, .inr h => exact _, .inl h

View File

@@ -0,0 +1,12 @@
/- Inaccessible names -/
example : x y : Nat, x = y y = x := by
intros
apply Eq.symm
assumption
example : x y : Nat, x = y y = x := by
intros
apply Eq.symm
rename_i a b hab
exact hab

View File

@@ -0,0 +1,19 @@
/- More tactics -/
example (p q : Nat Prop) : ( x, p x q x) x, q x p x := by
intro h
cases h with
| intro x hpq =>
cases hpq with
| intro hp hq =>
exists x
example : p q q p := by
intro p
cases p
constructor <;> assumption
example : p ¬ p q := by
intro h
cases h
contradiction

View File

@@ -0,0 +1,20 @@
/- Structuring proofs (cont.) -/
example : p (q r) (p q) (p r) := by
intro h
have hp : p := h.left
have hqr : q r := h.right
show (p q) (p r)
cases hqr with
| inl hq => exact Or.inl hp, hq
| inr hr => exact Or.inr hp, hr
example : p (q r) (p q) (p r) := by
intro hp, hqr
cases hqr with
| inl hq =>
have := And.intro hp hq
apply Or.inl; exact this
| inr hr =>
have := And.intro hp hr
apply Or.inr; exact this

View File

@@ -0,0 +1,10 @@
/- Tactic combinators -/
example : p q r p ((p q) r) (q r p) := by
intros
repeat (any_goals constructor)
all_goals assumption
example : p q r p ((p q) r) (q r p) := by
intros
repeat (any_goals (first | assumption | constructor))

View File

@@ -0,0 +1,14 @@
/- First-class functions -/
def twice (f : Nat Nat) (a : Nat) :=
f (f a)
#check twice
-- (Nat → Nat) → Nat → Nat
#eval twice (fun x => x + 2) 10
theorem twice_add_2 (a : Nat) : twice (fun x => x + 2) a = a + 4 := rfl
-- `(· + 2)` is syntax sugar for `(fun x => x + 2)`.
#eval twice (· + 2) 10

View File

@@ -0,0 +1,22 @@
/- Rewriting -/
example (f : Nat Nat) (k : Nat) (h₁ : f 0 = 0) (h₂ : k = 0) : f k = 0 := by
rw [h₂] -- replace k with 0
rw [h₁] -- replace f 0 with 0
example (f : Nat Nat) (k : Nat) (h₁ : f 0 = 0) (h₂ : k = 0) : f k = 0 := by
rw [h₂, h₁]
example (f : Nat Nat) (a b : Nat) (h₁ : a = b) (h₂ : f a = 0) : f b = 0 := by
rw [ h₁, h₂]
example (f : Nat Nat) (a : Nat) (h : 0 + a = 0) : f a = f 0 := by
rw [Nat.zero_add] at h
rw [h]
def Tuple (α : Type) (n : Nat) :=
{ as : List α // as.length = n }
example (n : Nat) (h : n = 0) (t : Tuple α n) : Tuple α 0 := by
rw [h] at t
exact t

View File

@@ -0,0 +1,21 @@
/- Simplifier -/
example (p : Nat Prop) : (x + 0) * (0 + y * 1 + z * 0) = x * y := by
simp
example (p : Nat Prop) (h : p (x * y)) : p ((x + 0) * (0 + y * 1 + z * 0)) := by
simp; assumption
example (p : Nat Prop) (h : p ((x + 0) * (0 + y * 1 + z * 0))) : p (x * y) := by
simp at h; assumption
def f (m n : Nat) : Nat :=
m + n + m
example (h : n = 1) (h' : 0 = m) : (f m n) = n := by
simp [h, h', f]
example (p : Nat Prop) (h₁ : x + 0 = x') (h₂ : y + 0 = y')
: x + y + 0 = x' + y' := by
simp at *
simp [*]

View File

@@ -0,0 +1,13 @@
/- Simplifier -/
def mk_symm (xs : List α) :=
xs ++ xs.reverse
@[simp] theorem reverse_mk_symm : (mk_symm xs).reverse = mk_symm xs := by
simp [mk_symm]
theorem tst : (xs ++ mk_symm ys).reverse = mk_symm ys ++ xs.reverse := by
simp
#print tst
-- Lean reverse_mk_symm, and List.reverse_append

View File

@@ -0,0 +1,26 @@
/- split tactic -/
def f (x y z : Nat) : Nat :=
match x, y, z with
| 5, _, _ => y
| _, 5, _ => y
| _, _, 5 => y
| _, _, _ => 1
example : x 5 y 5 z 5 z = w f x y w = 1 := by
intros
simp [f]
split
. contradiction
. contradiction
. contradiction
. rfl
def g (xs ys : List Nat) : Nat :=
match xs, ys with
| [a, b], _ => a+b+1
| _, [b, c] => b+1
| _, _ => 1
example (xs ys : List Nat) (h : g xs ys = 0) : False := by
unfold g at h; split at h <;> simp_arith at h

View File

@@ -0,0 +1,9 @@
/- induction tactic -/
example (as : List α) (a : α) : (as.concat a).length = as.length + 1 := by
induction as with
| nil => rfl
| cons _ xs ih => simp [List.concat, ih]
example (as : List α) (a : α) : (as.concat a).length = as.length + 1 := by
induction as <;> simp! [*]

View File

@@ -0,0 +1,59 @@
/- Enumerated types -/
inductive Weekday where
| sunday | monday | tuesday | wednesday
| thursday | friday | saturday
#check Weekday.sunday
-- Weekday
open Weekday
#check sunday
def natOfWeekday (d : Weekday) : Nat :=
match d with
| sunday => 1
| monday => 2
| tuesday => 3
| wednesday => 4
| thursday => 5
| friday => 6
| saturday => 7
def Weekday.next (d : Weekday) : Weekday :=
match d with
| sunday => monday
| monday => tuesday
| tuesday => wednesday
| wednesday => thursday
| thursday => friday
| friday => saturday
| saturday => sunday
def Weekday.previous : Weekday Weekday
| sunday => saturday
| monday => sunday
| tuesday => monday
| wednesday => tuesday
| thursday => wednesday
| friday => thursday
| saturday => friday
/- Proving theorems using tactics -/
theorem Weekday.next_previous (d : Weekday) : d.next.previous = d :=
match d with
| sunday => rfl
| monday => rfl
| tuesday => rfl
| wednesday => rfl
| thursday => rfl
| friday => rfl
| saturday => rfl
theorem Weekday.next_previous' (d : Weekday) : d.next.previous = d := by -- switch to tactic mode
cases d -- Creates 7 goals
rfl; rfl; rfl; rfl; rfl; rfl; rfl
theorem Weekday.next_previous'' (d : Weekday) : d.next.previous = d := by
cases d <;> rfl

View File

@@ -0,0 +1,20 @@
/- What is the type of Nat? -/
#check 0
-- Nat
#check Nat
-- Type
#check Type
-- Type 1
#check Type 1
-- Type 2
#check Eq.refl 2
-- 2 = 2
#check 2 = 2
-- Prop
#check Prop
-- Type
example : Prop = Sort 0 := rfl
example : Type = Sort 1 := rfl
example : Type 1 = Sort 2 := rfl

View File

@@ -0,0 +1,21 @@
/- Implicit arguments and universe polymorphism -/
def f (α β : Sort u) (a : α) (b : β) : α := a
#eval f Nat String 1 "hello"
-- 1
def g {α β : Sort u} (a : α) (b : β) : α := a
#eval g 1 "hello"
def h (a : α) (b : β) : α := a
#check g
-- ?m.1 → ?m.2 → ?m.1
#check @g
-- {α β : Sort u} → α → β → α
#check @h
-- {α : Sort u_1} → {β : Sort u_2} → α → β → α
#check g (α := Nat) (β := String)
-- Nat → String → Nat

View File

@@ -0,0 +1,14 @@
/- Inductive Types -/
inductive Tree (β : Type v) where
| leaf
| node (left : Tree β) (key : Nat) (value : β) (right : Tree β)
deriving Repr
#eval Tree.node .leaf 10 true .leaf
-- Tree.node Tree.leaf 10 true Tree.leaf
inductive Vector (α : Type u) : Nat Type u
| nil : Vector α 0
| cons : α Vector α n Vector α (n+1)

View File

@@ -0,0 +1,25 @@
/- Recursive functions -/
#print Nat -- Nat is an inductive datatype
def fib (n : Nat) : Nat :=
match n with
| 0 => 1
| 1 => 1
| n+2 => fib (n+1) + fib n
example : fib 5 = 8 := rfl
example : fib (n+2) = fib (n+1) + fib n := rfl
#print fib
/-
def fib : Nat → Nat :=
fun n =>
Nat.brecOn n fun n f =>
(match (motive := (n : Nat) → Nat.below n → Nat) n with
| 0 => fun x => 1
| 1 => fun x => 1
| Nat.succ (Nat.succ n) => fun x => x.fst.fst + x.fst.snd.fst.fst)
f
-/

View File

@@ -0,0 +1,25 @@
/- Well-founded recursion -/
def ack : Nat Nat Nat
| 0, y => y+1
| x+1, 0 => ack x 1
| x+1, y+1 => ack x (ack (x+1) y)
termination_by x y => (x, y)
def sum (a : Array Int) : Int :=
let rec go (i : Nat) :=
if _ : i < a.size then
a[i] + go (i+1)
else
0
termination_by a.size - i
go 0
set_option pp.proofs true
#print sum.go
/-
def sum.go : Array Int → Nat → Int :=
fun a =>
WellFounded.fix (sum.go.proof_1 a) fun i a_1 =>
if h : i < Array.size a then Array.getOp a i + a_1 (i + 1) (sum.go.proof_2 a i h) else 0
-/

View File

@@ -0,0 +1,44 @@
/- Mutual recursion -/
inductive Term where
| const : String Term
| app : String List Term Term
namespace Term
mutual
def numConsts : Term Nat
| const _ => 1
| app _ cs => numConstsLst cs
def numConstsLst : List Term Nat
| [] => 0
| c :: cs => numConsts c + numConstsLst cs
end
mutual
def replaceConst (a b : String) : Term Term
| const c => if a = c then const b else const c
| app f cs => app f (replaceConstLst a b cs)
def replaceConstLst (a b : String) : List Term List Term
| [] => []
| c :: cs => replaceConst a b c :: replaceConstLst a b cs
end
/- Mutual recursion in theorems -/
mutual
theorem numConsts_replaceConst (a b : String) (e : Term)
: numConsts (replaceConst a b e) = numConsts e := by
match e with
| const c => simp [replaceConst]; split <;> simp [numConsts]
| app f cs => simp [replaceConst, numConsts, numConsts_replaceConstLst a b cs]
theorem numConsts_replaceConstLst (a b : String) (es : List Term)
: numConstsLst (replaceConstLst a b es) = numConstsLst es := by
match es with
| [] => simp [replaceConstLst, numConstsLst]
| c :: cs =>
simp [replaceConstLst, numConstsLst, numConsts_replaceConst a b c,
numConsts_replaceConstLst a b cs]
end

View File

@@ -4,43 +4,42 @@ open Lean Meta
def ctor (mvarId : MVarId) (idx : Nat) : MetaM (List MVarId) := do
/- Set `MetaM` context using `mvarId` -/
withMVarContext mvarId do
mvarId.withContext do
/- Fail if the metavariable is already assigned. -/
checkNotAssigned mvarId `ctor
mvarId.checkNotAssigned `ctor
/- Retrieve the target type, instantiateMVars, and use `whnf`. -/
let target getMVarType' mvarId
let target mvarId.getType'
let .const declName us := target.getAppFn
| throwTacticEx `ctor mvarId "target is not an inductive datatype"
let .inductInfo { ctors, .. } getConstInfo declName
| throwTacticEx `ctor mvarId "target is not an inductive datatype"
if idx = 0 then
throwTacticEx `ctor mvarId "invalid index, it must be > 0"
throwTacticEx `ctor mvarId "invalid index, it must be > 0"
else if h : idx - 1 < ctors.length then
apply mvarId (.const ctors[idx - 1] us)
mvarId.apply (.const ctors[idx - 1] us)
else
throwTacticEx `ctor mvarId "invalid index, inductive datatype has only {ctors.length} contructors"
throwTacticEx `ctor mvarId "invalid index, inductive datatype has only {ctors.length} constructors"
open Elab Tactic
elab "ctor" idx:num : tactic =>
elab "ctor" idx:num : tactic =>
liftMetaTactic (ctor · idx.getNat)
example (p : Prop) : p := by
example (p : Prop) : p := by
ctor 1 -- Error
example (h : q) : p q := by
example (h : q) : p q := by
ctor 0 -- Error
exact h
example (h : q) : p q := by
example (h : q) : p q := by
ctor 3 -- Error
exact h
example (h : q) : p q := by
example (h : q) : p q := by
ctor 2
exact h
example (h : q) : p q := by
example (h : q) : p q := by
ctor 1
exact h -- Error
exact h -- Error

View File

@@ -5,15 +5,15 @@ open Lean Meta
def ex1 (declName : Name) : MetaM Unit := do
let info getConstInfo declName
IO.println s!"{declName} : {← ppExpr info.type}"
if let some val := info.value? then
if let some val := info.value? then
IO.println s!"{declName} : {← ppExpr val}"
#eval ex1 ``Nat
def ex2 (declName : Name) : MetaM Unit := do
let info getConstInfo declName
trace[Meta.debug] "{declName} : {info.type}"
if let some val := info.value? then
if let some val := info.value? then
trace[Meta.debug] "{declName} : {val}"
#eval ex2 ``Add.add
@@ -30,9 +30,9 @@ def ex3 (declName : Name) : MetaM Unit := do
trace[Meta.debug] "{x} : {← inferType x}"
def myMin [LT α] [DecidableRel (α := α) (·<·)] (a b : α) : α :=
if a < b then
if a < b then
a
else
else
b
set_option trace.Meta.debug true in
@@ -40,7 +40,7 @@ set_option trace.Meta.debug true in
def ex4 : MetaM Unit := do
let nat := mkConst ``Nat
withLocalDeclD `a nat fun a =>
withLocalDeclD `a nat fun a =>
withLocalDeclD `b nat fun b => do
let e mkAppM ``HAdd.hAdd #[a, b]
trace[Meta.debug] "{e} : {← inferType e}"
@@ -66,15 +66,17 @@ open Elab Term
def ex5 : TermElabM Unit := do
let nat := Lean.mkConst ``Nat
withLocalDeclD `a nat fun a => do
withLocalDeclD `a nat fun a => do
withLocalDeclD `b nat fun b => do
let ab mkAppM ``HAdd.hAdd #[a, b]
let stx `(fun x => if x < 10 then $( exprToSyntax ab) + x else x + $( exprToSyntax a))
let abStx exprToSyntax ab
let aStx exprToSyntax a
let stx `(fun x => if x < 10 then $abStx + x else x + $aStx)
let e elabTerm stx none
trace[Meta.debug] "{e} : {← inferType e}"
let e := mkApp e (mkNatLit 5)
let e whnf e
trace[Meta.debug] "{e}"
set_option trace.Meta.debug true in
#eval ex5

View File

@@ -4,16 +4,16 @@ def ack : Nat → Nat → Nat
| 0, y => y+1
| x+1, 0 => ack x 1
| x+1, y+1 => ack x (ack (x+1) y)
termination_by ack x y => (x, y)
termination_by x y => (x, y)
def sum (a : Array Int) : Int :=
let rec go (i : Nat) :=
if i < a.size then
if _ : i < a.size then
a[i] + go (i+1)
else
0
termination_by a.size - i
go 0
termination_by go i => a.size - i
set_option pp.proofs true
#print sum.go

View File

@@ -5,7 +5,7 @@ If the type of keys can be totally ordered -- that is, it supports a well-behave
then maps can be implemented with binary search trees (BSTs). Insert and lookup operations on BSTs take time
proportional to the height of the tree. If the tree is balanced, the operations therefore take logarithmic time.
This example is based on a similar example found in the ["Sofware Foundations"](https://softwarefoundations.cis.upenn.edu/vfa-current/SearchTree.html)
This example is based on a similar example found in the ["Software Foundations"](https://softwarefoundations.cis.upenn.edu/vfa-current/SearchTree.html)
book (volume 3).
-/
@@ -81,9 +81,9 @@ def Tree.toList (t : Tree β) : List (Nat × β) :=
|>.toList
/-!
The implemention of `Tree.toList` is inefficient because of how it uses the `++` operator.
The implementation of `Tree.toList` is inefficient because of how it uses the `++` operator.
On a balanced tree its running time is linearithmic, because it does a linear number of
concatentations at each level of the tree. On an unbalanced tree it's quadratic time.
concatenations at each level of the tree. On an unbalanced tree it's quadratic time.
Here's a tail-recursive implementation than runs in linear time, regardless of whether the tree is balanced:
-/
def Tree.toListTR (t : Tree β) : List (Nat × β) :=
@@ -114,9 +114,9 @@ concatenating all goals produced by `tac'`. In this theorem, we use it to apply
The `simp` parameters `toListTR.go` and `toList` instruct the simplifier to try to reduce
and/or apply auto generated equation theorems for these two functions.
The parameter `*` intructs the simplifier to use any equation in a goal as rewriting rules.
The parameter `*` instructs the simplifier to use any equation in a goal as rewriting rules.
In this particular case, `simp` uses the induction hypotheses as rewriting rules.
Finally, the parameter `List.append_assoc` intructs the simplifier to use the
Finally, the parameter `List.append_assoc` instructs the simplifier to use the
`List.append_assoc` theorem as a rewriting rule.
-/
theorem Tree.toList_eq_toListTR (t : Tree β)
@@ -176,7 +176,8 @@ The modifier `local` specifies the scope of the macro.
/-- The `have_eq lhs rhs` tactic (tries to) prove that `lhs = rhs`,
and then replaces `lhs` with `rhs`. -/
local macro "have_eq " lhs:term:max rhs:term:max : tactic =>
`((have h : $lhs = $rhs :=
`(tactic|
(have h : $lhs = $rhs :=
-- TODO: replace with linarith
by simp_arith at *; apply Nat.le_antisymm <;> assumption
try subst $lhs))
@@ -185,13 +186,13 @@ local macro "have_eq " lhs:term:max rhs:term:max : tactic =>
The `by_cases' e` is just the regular `by_cases` followed by `simp` using all
hypotheses in the current goal as rewriting rules.
Recall that the `by_cases` tactic creates two goals. One where we have `h : e` and
another one containing `h : ¬ e`. The simplier uses the `h` to rewrite `e` to `True`
another one containing `h : ¬ e`. The simplifier uses the `h` to rewrite `e` to `True`
in the first subgoal, and `e` to `False` in the second. This is particularly
useful if `e` is the condition of an `if`-statement.
-/
/-- `by_cases' e` is a shorthand form `by_cases e <;> simp[*]` -/
local macro "by_cases' " e:term : tactic =>
`(by_cases $e <;> simp [*])
`(tactic| by_cases $e <;> simp [*])
/-!
@@ -276,14 +277,13 @@ theorem BinTree.find_insert (b : BinTree β) (k : Nat) (v : β)
. by_cases' key < k
cases h; apply ihr; assumption
theorem BinTree.find_insert_of_ne (b : BinTree β) (h : k k') (v : β)
theorem BinTree.find_insert_of_ne (b : BinTree β) (ne : k k') (v : β)
: (b.insert k v).find? k' = b.find? k' := by
let t, h := b; simp
induction t with simp
| leaf =>
split <;> simp <;> split <;> simp
have_eq k k'
contradiction
intros le
exact Nat.lt_of_le_of_ne le ne
| node left key value right ihl ihr =>
let .node hl hr bl br := h
specialize ihl bl

1
doc/examples/compiler/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
build

View File

@@ -149,10 +149,10 @@ We now define the constant folding optimization that traverses a term if replace
/-!
The correctness of the `Term.constFold` is proved using induction, case-analysis, and the term simplifier.
We prove all cases but the one for `plus` using `simp [*]`. This tactic instructs the term simplifier to
use hypotheses such as `a = b` as rewriting/simplications rules.
use hypotheses such as `a = b` as rewriting/simplifications rules.
We use the `split` to break the nested `match` expression in the `plus` case into two cases.
The local variables `iha` and `ihb` are the induction hypotheses for `a` and `b`.
The modifier `←` in a term simplifier argument instructs the term simplier to use the equation as a rewriting rule in
The modifier `←` in a term simplifier argument instructs the term simplifier to use the equation as a rewriting rule in
the "reverse direction". That is, given `h : a = b`, `← h` instructs the term simplifier to rewrite `b` subterms to `a`.
-/
theorem Term.constFold_sound (e : Term ctx ty) : e.constFold.denote env = e.denote env := by

View File

@@ -12,17 +12,17 @@ Remark: this example is based on an example found in the Idris manual.
Vectors
--------
A `Vector` is a list of size `n` whose elements belong to a type `α`.
A `Vec` is a list of size `n` whose elements belong to a type `α`.
-/
inductive Vector (α : Type u) : Nat Type u
| nil : Vector α 0
| cons : α Vector α n Vector α (n+1)
inductive Vec (α : Type u) : Nat Type u
| nil : Vec α 0
| cons : α Vec α n Vec α (n+1)
/-!
We can overload the `List.cons` notation `::` and use it to create `Vector`s.
We can overload the `List.cons` notation `::` and use it to create `Vec`s.
-/
infix:67 " :: " => Vector.cons
infix:67 " :: " => Vec.cons
/-!
Now, we define the types of our simple functional language.
@@ -50,11 +50,11 @@ the builtin instance for `Add Int` as the solution.
/-!
Expressions are indexed by the types of the local variables, and the type of the expression itself.
-/
inductive HasType : Fin n Vector Ty n Ty Type where
inductive HasType : Fin n Vec Ty n Ty Type where
| stop : HasType 0 (ty :: ctx) ty
| pop : HasType k ctx ty HasType k.succ (u :: ctx) ty
inductive Expr : Vector Ty n Ty Type where
inductive Expr : Vec Ty n Ty Type where
| var : HasType i ctx ty Expr ctx ty
| val : Int Expr ctx Ty.int
| lam : Expr (a :: ctx) ty Expr ctx (Ty.fn a ty)
@@ -83,7 +83,7 @@ In practice, this means we use `stop` to refer to the most recently defined vari
A value `Expr.val` carries a concrete representation of an integer.
A lambda `Expr.lam` creates a function. In the scope of a function ot type `Ty.fn a ty`, there is a
A lambda `Expr.lam` creates a function. In the scope of a function of type `Ty.fn a ty`, there is a
new local variable of type `a`.
A function application `Expr.app` produces a value of type `ty` given a function from `a` to `ty` and a value of type `a`.
@@ -102,8 +102,8 @@ indexed over the types in scope. Since an environment is just another form of li
to the vector of local variable types, we overload again the notation `::` so that we can use the usual list syntax.
Given a proof that a variable is defined in the context, we can then produce a value from the environment.
-/
inductive Env : Vector Ty n Type where
| nil : Env Vector.nil
inductive Env : Vec Ty n Type where
| nil : Env Vec.nil
| cons : Ty.interp a Env ctx Env (a :: ctx)
infix:67 " :: " => Env.cons
@@ -139,7 +139,7 @@ def add : Expr ctx (Ty.fn Ty.int (Ty.fn Ty.int Ty.int)) :=
More interestingly, a factorial function fact (e.g. `fun x => if (x == 0) then 1 else (fact (x-1) * x)`), can be written as.
Note that this is a recursive (non-terminating) definition. For every input value, the interpreter terminates, but the
definition itself is non-terminating. We use two tricks to make sure Lean accepts it. First, we use the auxiliary constructor
`Expr.delay` to delay its unfolding. Second, we add the annotation `decreasing_by sorry` which can be viwed as
`Expr.delay` to delay its unfolding. Second, we add the annotation `decreasing_by sorry` which can be viewed as
"trust me, this recursive definition makes sense". Recall that `sorry` is an unsound axiom in Lean.
-/
@@ -149,4 +149,4 @@ def fact : Expr ctx (Ty.fn Ty.int Ty.int) :=
(op (·*·) (delay fun _ => app fact (op (·-·) (var stop) (val 1))) (var stop)))
decreasing_by sorry
#eval fact.interp Env.nil 10
#eval! fact.interp Env.nil 10

View File

@@ -82,7 +82,7 @@ theorem List.palindrome_ind (motive : List α → Prop)
have ih := palindrome_ind motive h₁ h₂ h₃ (a₂::as').dropLast
have : [a₁] ++ (a₂::as').dropLast ++ [(a₂::as').last (by simp)] = a₁::a₂::as' := by simp
this h₃ _ _ _ ih
termination_by _ as => as.length
termination_by as.length
/-!
We use our new induction principle to prove that if `as.reverse = as`, then `Palindrome as` holds.

View File

@@ -225,10 +225,10 @@ We now define the constant folding optimization that traverses a term if replace
/-!
The correctness of the `constFold` is proved using induction, case-analysis, and the term simplifier.
We prove all cases but the one for `plus` using `simp [*]`. This tactic instructs the term simplifier to
use hypotheses such as `a = b` as rewriting/simplications rules.
use hypotheses such as `a = b` as rewriting/simplifications rules.
We use the `split` to break the nested `match` expression in the `plus` case into two cases.
The local variables `iha` and `ihb` are the induction hypotheses for `a` and `b`.
The modifier `←` in a term simplifier argument instructs the term simplier to use the equation as a rewriting rule in
The modifier `←` in a term simplifier argument instructs the term simplifier to use the equation as a rewriting rule in
the "reverse direction. That is, given `h : a = b`, `← h` instructs the term simplifier to rewrite `b` subterms to `a`.
-/
theorem constFold_sound (e : Term' Ty.denote ty) : denote (constFold e) = denote e := by

View File

@@ -29,7 +29,7 @@ inductive HasType : Expr → Ty → Prop
/-!
We can easily show that if `e` has type `t₁` and type `t₂`, then `t₁` and `t₂` must be equal
by using the the `cases` tactic. This tactic creates a new subgoal for every constructor,
by using the `cases` tactic. This tactic creates a new subgoal for every constructor,
and automatically discharges unreachable cases. The tactic combinator `tac₁ <;> tac₂` applies
`tac₂` to each subgoal produced by `tac₁`. Then, the tactic `rfl` is used to close all produced
goals using reflexivity.
@@ -38,7 +38,7 @@ theorem HasType.det (h₁ : HasType e t₁) (h₂ : HasType e t₂) : t₁ = t
cases h₁ <;> cases h₂ <;> rfl
/-!
The inductive type `Maybe p` has two contructors: `found a h` and `unknown`.
The inductive type `Maybe p` has two constructors: `found a h` and `unknown`.
The former contains an element `a : α` and a proof that `a` satisfies the predicate `p`.
The constructor `unknown` is used to encode "failure".
-/
@@ -82,9 +82,7 @@ theorem Expr.typeCheck_correct (h₁ : HasType e ty) (h₂ : e.typeCheck ≠ .un
/-!
Now, we prove that if `Expr.typeCheck e` returns `Maybe.unknown`, then forall `ty`, `HasType e ty` does not hold.
The notation `e.typeCheck` is sugar for `Expr.typeCheck e`. Lean can infer this because we explicitly said that `e` has type `Expr`.
The proof is by induction on `e` and case analysis. The tactic `rename_i` is used to to rename "inaccessible" variables.
We say a variable is inaccessible if it is introduced by a tactic (e.g., `cases`) or has been shadowed by another variable introduced
by the user. Note that the tactic `simp [typeCheck]` is applied to all goal generated by the `induction` tactic, and closes
The proof is by induction on `e` and case analysis. Note that the tactic `simp [typeCheck]` is applied to all goal generated by the `induction` tactic, and closes
the cases corresponding to the constructors `Expr.nat` and `Expr.bool`.
-/
theorem Expr.typeCheck_complete {e : Expr} : e.typeCheck = .unknown ¬ HasType e ty := by

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
source ../../tests/common.sh
exec_check lean -j 0 -Dlinter.all=false "$f"
exec_check lean -Dlinter.all=false "$f"

View File

@@ -4,76 +4,97 @@ open Lean Widget
/-!
# The user-widgets system
Proving and programming are inherently interactive tasks. Lots of mathematical objects and data
structures are visual in nature. *User widgets* let you associate custom interactive UIs with
sections of a Lean document. User widgets are rendered in the Lean infoview.
Proving and programming are inherently interactive tasks.
Lots of mathematical objects and data structures are visual in nature.
*User widgets* let you associate custom interactive UIs
with sections of a Lean document.
User widgets are rendered in the Lean infoview.
![Rubik's cube](../images/widgets_rubiks.png)
## Trying it out
To try it out, simply type in the following code and place your cursor over the `#widget` command.
To try it out, type in the following code and place your cursor over the `#widget` command.
You can also [view this manual entry in the online editor](https://live.lean-lang.org/#url=https%3A%2F%2Fraw.githubusercontent.com%2Fleanprover%2Flean4%2Fmaster%2Fdoc%2Fexamples%2Fwidgets.lean).
-/
@[widget]
def helloWidget : UserWidgetDefinition where
name := "Hello"
@[widget_module]
def helloWidget : Widget.Module where
javascript := "
import * as React from 'react';
export default function(props) {
const name = props.name || 'world'
return React.createElement('p', {}, name + '!')
return React.createElement('p', {}, 'Hello ' + name + '!')
}"
#widget helloWidget .null
#widget helloWidget
/-!
If you want to dive into a full sample right away, check out
[`RubiksCube`](https://github.com/leanprover/lean4-samples/blob/main/RubiksCube/).
[`Rubiks`](https://github.com/leanprover-community/ProofWidgets4/blob/main/ProofWidgets/Demos/Rubiks.lean).
This sample uses higher-level widget components from the ProofWidgets library.
Below, we'll explain the system piece by piece.
⚠️ WARNING: All of the user widget APIs are **unstable** and subject to breaking changes.
## Widget sources and instances
## Widget modules and instances
A *widget source* is a valid JavaScript [ESModule](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
which exports a [React component](https://reactjs.org/docs/components-and-props.html). To access
React, the module must use `import * as React from 'react'`. Our first example of a widget source
is of course the value of `helloWidget.javascript`.
A [widget module](https://leanprover-community.github.io/mathlib4_docs/Lean/Widget/UserWidget.html#Lean.Widget.Module)
is a valid JavaScript [ESModule](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
that can execute in the Lean infoview.
Most widget modules export a [React component](https://reactjs.org/docs/components-and-props.html)
as the piece of user interface to be rendered.
To access React, the module can use `import * as React from 'react'`.
Our first example of a widget module is `helloWidget` above.
Widget modules must be registered with the `@[widget_module]` attribute.
We can register a widget source with the `@[widget]` attribute, giving it a friendlier name
in the `name` field. This is bundled together in a `UserWidgetDefinition`.
A *widget instance* is then the identifier of a `UserWidgetDefinition` (so `` `helloWidget ``,
not `"Hello"`) associated with a range of positions in the Lean source code. Widget instances
are stored in the *infotree* in the same manner as other information about the source file
such as the type of every expression. In our example, the `#widget` command stores a widget instance
with the entire line as its range. We can think of a widget instance as an instruction for the
infoview: "when the user places their cursor here, please render the following widget".
Every widget instance also contains a `props : Json` value. This value is passed as an argument
to the React component. In our first invocation of `#widget`, we set it to `.null`. Try out what
happens when you type in:
A [widget instance](https://leanprover-community.github.io/mathlib4_docs/Lean/Widget/Types.html#Lean.Widget.WidgetInstance)
is then the identifier of a widget module (e.g. `` `helloWidget ``)
bundled with a value for its props.
This value is passed as the argument to the React component.
In our first invocation of `#widget`, we set it to `.null`.
Try out what happens when you type in:
-/
#widget helloWidget (Json.mkObj [("name", "<your name here>")])
structure HelloWidgetProps where
name? : Option String := none
deriving Server.RpcEncodable
#widget helloWidget with { name? := "<your name here>" : HelloWidgetProps }
/-!
💡 NOTE: The RPC system presented below does not depend on JavaScript. However the primary use case
is the web-based infoview in VSCode.
Under the hood, widget instances are associated with a range of positions in the source file.
Widget instances are stored in the *infotree*
in the same manner as other information about the source file
such as the type of every expression.
In our example, the `#widget` command stores a widget instance
with the entire line as its range.
One can think of the infotree entry as an instruction for the infoview:
"when the user places their cursor here, please render the following widget".
-/
/-!
## Querying the Lean server
Besides enabling us to create cool client-side visualizations, user widgets come with the ability
to communicate with the Lean server. Thanks to this, they have the same metaprogramming capabilities
as custom elaborators or the tactic framework. To see this in action, let's implement a `#check`
command as a web input form. This example assumes some familiarity with React.
💡 NOTE: The RPC system presented below does not depend on JavaScript.
However, the primary use case is the web-based infoview in VSCode.
The first thing we'll need is to create an *RPC method*. Meaning "Remote Procedure Call", this
is basically a Lean function callable from widget code (possibly remotely over the internet).
Besides enabling us to create cool client-side visualizations,
user widgets have the ability to communicate with the Lean server.
Thanks to this, they have the same metaprogramming capabilities
as custom elaborators or the tactic framework.
To see this in action, let's implement a `#check` command as a web input form.
This example assumes some familiarity with React.
The first thing we'll need is to create an *RPC method*.
Meaning "Remote Procedure Call",this is a Lean function callable from widget code
(possibly remotely over the internet).
Our method will take in the `name : Name` of a constant in the environment and return its type.
By convention, we represent the input data as a `structure`. Since it will be sent over from JavaScript,
we need `FromJson` and `ToJson`. We'll see below why the position field is needed.
By convention, we represent the input data as a `structure`.
Since it will be sent over from JavaScript,
we need `FromJson` and `ToJson` instance.
We'll see why the position field is needed later.
-/
structure GetTypeParams where
@@ -84,103 +105,142 @@ structure GetTypeParams where
deriving FromJson, ToJson
/-!
After its arguments, we define the `getType` method. Every RPC method executes in the `RequestM`
monad and must return a `RequestTask α` where `α` is its "actual" return type. The `Task` is so
that requests can be handled concurrently. A first guess for `α` might be `Expr`. However,
expressions in general can be large objects which depend on an `Environment` and `LocalContext`.
Thus we cannot directly serialize an `Expr` and send it to the widget. Instead, there are two
options:
- One is to send a *reference* which points to an object residing on the server. From JavaScript's
point of view, references are entirely opaque, but they can be sent back to other RPC methods for
further processing.
- Two is to pretty-print the expression and send its textual representation called `CodeWithInfos`.
This representation contains extra data which the infoview uses for interactivity. We take this
strategy here.
After its argument structure, we define the `getType` method.
RPCs method execute in the `RequestM` monad and must return a `RequestTask α`
where `α` is the "actual" return type.
The `Task` is so that requests can be handled concurrently.
As a first guess, we'd use `Expr` as `α`.
However, expressions in general can be large objects
which depend on an `Environment` and `LocalContext`.
Thus we cannot directly serialize an `Expr` and send it to JavaScript.
Instead, there are two options:
RPC methods execute in the context of a file, but not any particular `Environment` so they don't
know about the available `def`initions and `theorem`s. Thus, we need to pass in a position at which
we want to use the local `Environment`. This is why we store it in `GetTypeParams`. The `withWaitFindSnapAtPos`
method launches a concurrent computation whose job is to find such an `Environment` and a bit
more information for us, in the form of a `snap : Snapshot`. With this in hand, we can call
`MetaM` procedures to find out the type of `name` and pretty-print it.
- One is to send a *reference* which points to an object residing on the server.
From JavaScript's point of view, references are entirely opaque,
but they can be sent back to other RPC methods for further processing.
- The other is to pretty-print the expression and send its textual representation called `CodeWithInfos`.
This representation contains extra data which the infoview uses for interactivity.
We take this strategy here.
RPC methods execute in the context of a file,
but not of any particular `Environment`,
so they don't know about the available `def`initions and `theorem`s.
Thus, we need to pass in a position at which we want to use the local `Environment`.
This is why we store it in `GetTypeParams`.
The `withWaitFindSnapAtPos` method launches a concurrent computation
whose job is to find such an `Environment` for us,
in the form of a `snap : Snapshot`.
With this in hand, we can call `MetaM` procedures
to find out the type of `name` and pretty-print it.
-/
open Server RequestM in
@[serverRpcMethod]
@[server_rpc_method]
def getType (params : GetTypeParams) : RequestM (RequestTask CodeWithInfos) :=
withWaitFindSnapAtPos params.pos fun snap => do
runTermElabM snap do
let name resolveGlobalConstNoOverloadCore params.name
let some c Meta.getConst? name
| throwThe RequestError .invalidParams, s!"no constant named '{name}'"
let c try getConstInfo name
catch _ => throwThe RequestError .invalidParams, s!"no constant named '{name}'"
Widget.ppExprTagged c.type
/-!
## Using infoview components
Now that we have all we need on the server side, let's write the widget source. By importing
`@leanprover/infoview`, widgets can render UI components used to implement the infoview itself.
For example, the `<InteractiveCode>` component displays expressions with `term : type` tooltips
as seen in the goal view. We will use it to implement our custom `#check` display.
Now that we have all we need on the server side, let's write the widget module.
By importing `@leanprover/infoview`, widgets can render UI components used to implement the infoview itself.
For example, the `<InteractiveCode>` component displays expressions
with `term : type` tooltips as seen in the goal view.
We will use it to implement our custom `#check` display.
⚠️ WARNING: Like the other widget APIs, the infoview JS API is **unstable** and subject to breaking changes.
The code below demonstrates useful parts of the API. To make RPC method calls, we use the `RpcContext`.
The `useAsync` helper packs the results of a call into a `status` enum, the returned `val`ue in case
the call was successful, and otherwise an `err`or. Based on the `status` we either display
an `InteractiveCode`, or `mapRpcError` the error in order to turn it into a readable message.
The code below demonstrates useful parts of the API.
To make RPC method calls, we invoke the `useRpcSession` hook.
The `useAsync` helper packs the results of an RPC call into an `AsyncState` structure
which indicates whether the call has resolved successfully,
has returned an error, or is still in-flight.
Based on this we either display an `InteractiveCode` component with the result,
`mapRpcError` the error in order to turn it into a readable message,
or show a `Loading..` message, respectively.
-/
@[widget]
def checkWidget : UserWidgetDefinition where
name := "#check as a service"
@[widget_module]
def checkWidget : Widget.Module where
javascript := "
import * as React from 'react';
const e = React.createElement;
import { RpcContext, InteractiveCode, useAsync, mapRpcError } from '@leanprover/infoview';
import { useRpcSession, InteractiveCode, useAsync, mapRpcError } from '@leanprover/infoview';
export default function(props) {
const rs = React.useContext(RpcContext)
const rs = useRpcSession()
const [name, setName] = React.useState('getType')
const [status, val, err] = useAsync(() =>
const st = useAsync(() =>
rs.call('getType', { name, pos: props.pos }), [name, rs, props.pos])
const type = status === 'fulfilled' ? val && e(InteractiveCode, {fmt: val})
: status === 'rejected' ? e('p', null, mapRpcError(err).message)
: e('p', null, 'Loading..')
const type = st.state === 'resolved' ? st.value && e(InteractiveCode, {fmt: st.value})
: st.state === 'rejected' ? e('p', null, mapRpcError(st.error).message)
: e('p', null, 'Loading..')
const onChange = (event) => { setName(event.target.value) }
return e('div', null,
e('input', { value: name, onChange }),
' : ',
type)
e('input', { value: name, onChange }), ' : ', type)
}
"
/-!
Finally we can try out the widget.
We can now try out the widget.
-/
#widget checkWidget .null
#widget checkWidget
/-!
![`#check` as a service](../images/widgets_caas.png)
## Building widget sources
While typing JavaScript inline is fine for a simple example, for real developments we want to use
packages from NPM, a proper build system, and JSX. Thus, most actual widget sources are built with
Lake and NPM. They consist of multiple files and may import libraries which don't work as ESModules
by default. On the other hand a widget source must be a single, self-contained ESModule in the form
of a string. Readers familiar with web development may already have guessed that to obtain such a
string, we need a *bundler*. Two popular choices are [`rollup.js`](https://rollupjs.org/guide/en/)
and [`esbuild`](https://esbuild.github.io/). If we go with `rollup.js`, to make a widget work with
the infoview we need to:
While typing JavaScript inline is fine for a simple example,
for real developments we want to use packages from NPM, a proper build system, and JSX.
Thus, most actual widget sources are built with Lake and NPM.
They consist of multiple files and may import libraries which don't work as ESModules by default.
On the other hand a widget module must be a single, self-contained ESModule in the form of a string.
Readers familiar with web development may already have guessed that to obtain such a string, we need a *bundler*.
Two popular choices are [`rollup.js`](https://rollupjs.org/guide/en/)
and [`esbuild`](https://esbuild.github.io/).
If we go with `rollup.js`, to make a widget work with the infoview we need to:
- Set [`output.format`](https://rollupjs.org/guide/en/#outputformat) to `'es'`.
- [Externalize](https://rollupjs.org/guide/en/#external) `react`, `react-dom`, `@leanprover/infoview`.
These libraries are already loaded by the infoview so they should not be bundled.
In the RubiksCube sample, we provide a working `rollup.js` build configuration in
[rollup.config.js](https://github.com/leanprover/lean4-samples/blob/main/RubiksCube/widget/rollup.config.js).
ProofWidgets provides a working `rollup.js` build configuration in
[rollup.config.js](https://github.com/leanprover-community/ProofWidgets4/blob/main/widget/rollup.config.js).
## Inserting text
Besides making RPC calls, widgets can instruct the editor to carry out certain actions.
We can insert text, copy text to the clipboard, or highlight a certain location in the document.
To do this, use the `EditorContext` React context.
This will return an `EditorConnection`
whose `api` field contains a number of methods that interact with the editor.
The full API can be viewed [here](https://github.com/leanprover/vscode-lean4/blob/master/lean4-infoview-api/src/infoviewApi.ts#L52).
-/
@[widget_module]
def insertTextWidget : Widget.Module where
javascript := "
import * as React from 'react';
const e = React.createElement;
import { EditorContext } from '@leanprover/infoview';
export default function(props) {
const editorConnection = React.useContext(EditorContext)
function onClick() {
editorConnection.api.insertText('-- hello!!!', 'above')
}
return e('div', null, e('button', { value: name, onClick }, 'insert'))
}
"
#widget insertTextWidget

View File

@@ -396,7 +396,7 @@ Every expression in Lean has a natural computational interpretation, unless it i
* *β-reduction* : An expression ``(λ x, t) s`` β-reduces to ``t[s/x]``, that is, the result of replacing ``x`` by ``s`` in ``t``.
* *ζ-reduction* : An expression ``let x := s in t`` ζ-reduces to ``t[s/x]``.
* *δ-reduction* : If ``c`` is a defined constant with definition ``t``, then ``c`` δ-reduces to to ``t``.
* *δ-reduction* : If ``c`` is a defined constant with definition ``t``, then ``c`` δ-reduces to ``t``.
* *ι-reduction* : When a function defined by recursion on an inductive type is applied to an element given by an explicit constructor, the result ι-reduces to the specified function value, as described in [Inductive Types](inductive.md).
The reduction relation is transitive, which is to say, is ``s`` reduces to ``s'`` and ``t`` reduces to ``t'``, then ``s t`` reduces to ``s' t'``, ``λ x, s`` reduces to ``λ x, s'``, and so on. If ``s`` and ``t`` reduce to a common term, they are said to be *definitionally equal*. Definitional equality is defined to be the smallest equivalence relation that satisfies all these properties and also includes α-equivalence and the following two relations:
@@ -406,7 +406,7 @@ The reduction relation is transitive, which is to say, is ``s`` reduces to ``s'`
This last fact reflects the intuition that once we have proved a proposition ``p``, we only care that is has been proved; the proof does nothing more than witness the fact that ``p`` is true.
Definitional equality is a strong notion of equalty of values. Lean's logical foundations sanction treating definitionally equal terms as being the same when checking that a term is well-typed and/or that it has a given type.
Definitional equality is a strong notion of equality of values. Lean's logical foundations sanction treating definitionally equal terms as being the same when checking that a term is well-typed and/or that it has a given type.
The reduction relation is believed to be strongly normalizing, which is to say, every sequence of reductions applied to a term will eventually terminate. The property guarantees that Lean's type-checking algorithm terminates, at least in principle. The consistency of Lean and its soundness with respect to set-theoretic semantics do not depend on either of these properties.

View File

@@ -7,15 +7,6 @@ Lean is a new open source theorem prover being developed at Microsoft Research.
It is a research project that aims to bridge the gap between interactive and automated theorem proving.
Lean can be also used as a programming language. Actually, some Lean features are implemented in Lean itself.
### Are pull requests welcome?
In the past, we accepted most pull requests. This practice produced hard to maintain code, performance problems, and bugs.
It takes time to review a pull request and make sure it is correct, useful and is not in conflict with our plans.
Small bug fixes (few lines of code) are always welcome. Any other kind of unrequested pull request is not.
Thus, before implementing a feature or modifying the system, please ask whether the change is welcome or not.
We have issues tagged with ["help wanted"](https://github.com/leanprover/lean4/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22), if you want to contribute to the project, please take a look at them.
If you are interested in one of them, post comments, ask questions, and engage with the core developers there.
### Should I use Lean?
Lean is under heavy development, and we are constantly trying new
@@ -36,7 +27,7 @@ It is a good place to interact with other Lean users.
### Should I use Lean to teach a course?
Lean has been used to teach courses on logic, type theory and programming languages at CMU and the University of Washington.
The lecture notes for the CMU course [Logic and Proof](https://leanprover.github.io/logic_and_proof) are available online,
The lecture notes for the CMU course [Logic and Proof](https://lean-lang.org/logic_and_proof) are available online,
but they are for Lean 3.
If you decide to teach a course using Lean, we suggest you prepare all material before the beginning of the course, and
make sure that Lean attends all your needs. You should not expect we will fix bugs and/or add features needed for your course.
@@ -56,7 +47,7 @@ We expect similar independent checkers will be built for Lean 4.
We use [GitHub](https://github.com/leanprover/lean4/issues) to track bugs and new features.
Bug reports are always welcome, but nitpicking issues are not (e.g., the error message is confusing).
See also our [contribution guidelines](../CONTRIBUTING.md).
See also our [contribution guidelines](https://github.com/leanprover/lean4/blob/master/CONTRIBUTING.md).
### Is it Lean, LEAN, or L∃∀N?

159
doc/flake.lock generated
View File

@@ -18,12 +18,15 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@@ -35,14 +38,12 @@
"lean": {
"inputs": {
"flake-utils": "flake-utils",
"lean-stage0": "lean-stage0",
"lean4-mode": "lean4-mode",
"nix": "nix",
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs",
"nixpkgs-old": "nixpkgs-old"
},
"locked": {
"lastModified": 0,
"narHash": "sha256-AfBkKX6Ahb9YbZke+eWLmsUk1Z9BwdJ1CpIoPY8Msx8=",
"narHash": "sha256-saRAtQ6VautVXKDw1XH35qwP0KEBKTKZbg/TRa4N9Vw=",
"path": "../.",
"type": "path"
},
@@ -51,69 +52,23 @@
"type": "path"
}
},
"lean-stage0": {
"locked": {
"lastModified": 0,
"narHash": "sha256-3K/43lSW4WIHNG+HHVKCD1odS63mHuaQ4ueHyTIkcls=",
"owner": "leanprover",
"repo": "lean4",
"rev": "0000000000000000000000000000000000000000",
"type": "github"
},
"original": {
"owner": "leanprover",
"repo": "lean4",
"type": "github"
}
},
"lean4-mode": {
"flake": false,
"locked": {
"lastModified": 1647694750,
"narHash": "sha256-0rV61KhevG9IAjZDN2Ts2VS65fiUAPAezbf282u7yy8=",
"owner": "leanprover",
"repo": "lean4-mode",
"rev": "c016c7aeee92564836355083664c49ed57024427",
"type": "github"
},
"original": {
"owner": "leanprover",
"repo": "lean4-mode",
"type": "github"
}
},
"leanInk": {
"flake": false,
"locked": {
"lastModified": 1656863690,
"narHash": "sha256-9tmynTTeJGhYZaltS4xhSJgLTpe7Ta1ofV6U1SA/5V4=",
"lastModified": 1704976501,
"narHash": "sha256-FSBUsbX0HxakSnYRYzRBDN2YKmH9EkA0q9p7TSPEJTI=",
"owner": "leanprover",
"repo": "LeanInk",
"rev": "4b5e606ea8cc54c2447ce48706f8ec1d133d19e9",
"rev": "51821e3c2c032c88e4b2956483899d373ec090c4",
"type": "github"
},
"original": {
"owner": "leanprover",
"ref": "refs/pull/57/merge",
"repo": "LeanInk",
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"mdBook": {
"flake": false,
"locked": {
@@ -130,63 +85,13 @@
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": "nixpkgs",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1648022028,
"narHash": "sha256-HtwmifW6STPcym+3uJ4YavgTKTYVIoiQHg3f0wXOm+Q=",
"owner": "NixOS",
"repo": "nix",
"rev": "98ce1a21b7d959c5575fac566c8699e91703a9f7",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1632864508,
"narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=",
"lastModified": 1710889954,
"narHash": "sha256-Pr6F5Pmd7JnNEMHHmspZ0qVqIBVxyZ13ik1pJtm2QXk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "82891b5e2c2359d7e58d08849e4c89511ab94234",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-21.05-small",
"type": "indirect"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"id": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648219316,
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"rev": "7872526e9c5332274ea5932a0c3270d6e4724f3b",
"type": "github"
},
"original": {
@@ -196,6 +101,23 @@
"type": "github"
}
},
"nixpkgs-old": {
"flake": false,
"locked": {
"lastModified": 1581379743,
"narHash": "sha256-i1XCn9rKuLjvCdu2UeXKzGLF6IuQePQKFt4hEKRU5oc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-19.03",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"alectryon": "alectryon",
@@ -207,6 +129,21 @@
"leanInk": "leanInk",
"mdBook": "mdBook"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@@ -4,20 +4,20 @@
inputs.lean.url = path:../.;
inputs.flake-utils.follows = "lean/flake-utils";
inputs.mdBook = {
url = github:leanprover/mdBook;
url = "github:leanprover/mdBook";
flake = false;
};
inputs.alectryon = {
url = github:Kha/alectryon/typeid;
url = "github:Kha/alectryon/typeid";
flake = false;
};
inputs.leanInk = {
url = github:leanprover/LeanInk;
url = "github:leanprover/LeanInk/refs/pull/57/merge";
flake = false;
};
outputs = inputs@{ self, ... }: inputs.flake-utils.lib.eachDefaultSystem (system:
with inputs.lean.packages.${system}; with nixpkgs;
with inputs.lean.packages.${system}.deprecated; with nixpkgs;
let
doc-src = lib.sourceByRegex ../. ["doc.*" "tests(/lean(/beginEndAsMacro.lean)?)?"];
in {
@@ -27,7 +27,7 @@
src = inputs.mdBook;
cargoDeps = drv.cargoDeps.overrideAttrs (_: {
inherit src;
outputHash = "sha256-mhTWHs/bsmm3FH59SkUxBTl5lEH2Rlz/aF9CuBTu1TE=";
outputHash = "sha256-CO3A9Kpp4sIvkT9X3p+GTidazk7Fn4jf0AP2PINN44A=";
});
doCheck = false;
});
@@ -44,21 +44,6 @@
mdbook build -d $out
'';
};
# We use a separate derivation instead of `checkPhase` so we can push it but not `doc` to the binary cache
test = stdenv.mkDerivation {
name ="lean-doc-test";
src = doc-src;
buildInputs = [ lean-mdbook stage1.Lean.lean-package strace ];
patchPhase = ''
cd doc
patchShebangs test
'';
buildPhase = ''
mdbook test
touch $out
'';
dontInstall = true;
};
leanInk = (buildLeanPackage {
name = "Main";
src = inputs.leanInk;
@@ -78,22 +63,30 @@
(with python3Packages; [ pygments dominate beautifulsoup4 docutils ]);
doCheck = false;
};
renderLean = name: file: runCommandNoCC "${name}.md" { buildInputs = [ alectryon ]; } ''
mkdir -p $(basename $out/${name})
alectryon --frontend lean4+markup ${file} --backend webpage -o $out/${name}.md
'';
listFilesRecursiveRel = root: dir: lib.flatten (lib.mapAttrsToList (name: type:
if type == "directory" then
listFilesRecursiveRel root ("${dir}/${name}")
else
dir + "/${name}"
) (builtins.readDir "${root}/${dir}"));
renderDir = dir: let
inputs = builtins.filter (n: builtins.match ".*\.lean" n != null) (listFilesRecursiveRel dir ".");
outputs = lib.genAttrs inputs (n: renderLean n "${dir}/${n}");
in
outputs // symlinkJoin { inherit name; paths = lib.attrValues outputs; };
inked = renderDir ./.;
renderLeanMod = mod: mod.overrideAttrs (final: prev: {
name = "${prev.name}.md";
buildInputs = prev.buildInputs ++ [ alectryon ];
outputs = [ "out" ];
buildCommand = ''
dir=$(dirname $relpath)
mkdir -p $dir out/$dir
if [ -d $src ]; then cp -r $src/. $dir/; else cp $src $leanPath; fi
alectryon --frontend lean4+markup $leanPath --backend webpage -o $out/$leanPath.md
'';
});
renderPackage = pkg: symlinkJoin {
name = "${pkg.name}-mds";
paths = map renderLeanMod (lib.attrValues pkg.mods);
};
literate = buildLeanPackage {
name = "literate";
src = ./.;
roots = [
{ mod = "examples"; glob = "submodules"; }
{ mod = "monads"; glob = "submodules"; }
];
};
inked = renderPackage literate;
doc = book;
};
defaultPackage = self.packages.${system}.doc;

View File

@@ -1,7 +1,7 @@
Functional Programming in Lean
=======================
The goal of [this book](https://leanprover.github.io/functional_programming_in_lean/) is to be an accessible introduction to using Lean 4 as a programming language.
The goal of [this book](https://lean-lang.org/functional_programming_in_lean/) is to be an accessible introduction to using Lean 4 as a programming language.
It should be useful both to people who want to use Lean as a general-purpose programming language and to mathematicians who want to develop larger-scale proof automation but do not have a background in functional programming.
It does not assume any background with functional programming, though it's probably not a good first book on programming in general.
New content will be added once per month until it's done.

View File

@@ -32,8 +32,8 @@ def fact x :=
#eval fact 100
```
By default, Lean only accepts total functions. The `partial` keyword should be used when Lean cannot
establish that a function always terminates.
By default, Lean only accepts total functions.
The `partial` keyword may be used to define a recursive function without a termination proof; `partial` functions compute in compiled programs, but are opaque in proofs and during type checking.
```lean
partial def g (x : Nat) (p : Nat -> Bool) : Nat :=
if p x then

View File

@@ -1143,7 +1143,7 @@ hljs.registerLanguage("lean", function(hljs) {
'sorry admit',
};
var LEAN_IDENT_RE = /[A-Za-z_][\\w\u207F-\u209C\u1D62-\u1D6A\u2079\'0-9]*/;
var LEAN_IDENT_RE = /[A-Za-z_][\\w\u207F-\u209C\u1D62-\u1D6A\u2079\'0-9?]*/;
var DASH_COMMENT = hljs.COMMENT('--', '$');
var MULTI_LINE_COMMENT = hljs.COMMENT('/-[^-]', '-/');
@@ -1167,7 +1167,7 @@ hljs.registerLanguage("lean", function(hljs) {
var LEAN_DEFINITION = {
className: 'theorem',
beginKeywords: 'def theorem lemma class instance structure',
begin: '\\b(def|theorem|lemma|class|structure|(?<!deriving\\s+)instance)\\b',
end: ':= | where',
excludeEnd: true,
contains: [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
doc/images/setup_guide.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -1,3 +1,3 @@
# Inductive Types
[Theorem Proving in Lean](https://leanprover.github.io/theorem_proving_in_lean4/inductive_types.html) has a chapter about inductive datatypes.
[Theorem Proving in Lean](https://lean-lang.org/theorem_proving_in_lean4/inductive_types.html) has a chapter about inductive datatypes.

View File

@@ -13,7 +13,7 @@ Recall that nonnegative numerals are considered to be a `Nat` if there are no ty
The operator `/` for `Int` implements integer division.
```lean
#eval -10 / 4 -- -2
#eval -10 / 4 -- -3
```
Similar to `Nat`, the internal representation of `Int` is optimized. Small integers are

View File

@@ -1,100 +0,0 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.theorem
~~~~~~~~~~~~~~~~~~~~~~~
Lexers for theorem-proving languages.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from pygments.lexer import RegexLexer, default, words
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation, Generic
__all__ = ['Lean4Lexer']
class Lean4Lexer(RegexLexer):
"""
For the `Lean 4 <https://github.com/leanprover/lean4>`_
theorem prover.
.. versionadded:: 2.0
"""
name = 'Lean4'
aliases = ['lean4']
filenames = ['*.lean']
mimetypes = ['text/x-lean']
flags = re.MULTILINE | re.UNICODE
keywords1 = (
'import', 'abbreviation', 'opaque_hint', 'tactic_hint', 'definition',
'renaming', 'inline', 'hiding', 'parameter', 'lemma', 'variable',
'theorem', 'axiom', 'inductive', 'structure', 'universe', 'alias',
'help', 'options', 'precedence', 'postfix', 'prefix',
'infix', 'infixl', 'infixr', 'notation', '#eval',
'#check', '#reduce', '#exit', 'coercion', 'end', 'private', 'using', 'namespace',
'including', 'instance', 'section', 'context', 'protected', 'expose',
'export', 'set_option', 'extends', 'open', 'example',
'constant', 'constants', 'print', 'opaque', 'reducible', 'irreducible',
'def', 'macro', 'elab', 'syntax', 'macro_rules', 'reduce', 'where',
'abbrev', 'noncomputable', 'class', 'attribute', 'synth', 'mutual',
)
keywords2 = (
'forall', 'fun', 'Pi', 'obtain', 'from', 'have', 'show', 'assume',
'take', 'let', 'if', 'else', 'then', 'by', 'in', 'with', 'begin',
'proof', 'qed', 'calc', 'match', 'nomatch', 'do', 'at',
)
keywords3 = (
# Sorts
'Type', 'Prop', 'Sort',
)
operators = (
u'!=', u'#', u'&', u'&&', u'*', u'+', u'-', u'/', u'@', u'!', u'`',
u'-.', u'->', u'.', u'..', u'...', u'::', u':>', u';', u';;', u'<',
u'<-', u'=', u'==', u'>', u'_', u'|', u'||', u'~', u'=>', u'<=', u'>=',
u'/\\', u'\\/', u'', u'Π', u'λ', u'', u'', u'', u'', u'', u'',
u'¬', u'⁻¹', u'', u'', u'', u'', u'', u'', u'', u'×', u'',
u'', u'', u'', u'',
)
punctuation = (u'(', u')', u':', u'{', u'}', u'[', u']', u'', u'',
u':=', u',')
tokens = {
'root': [
(r'\s+', Text),
(r'/-', Comment, 'comment'),
(r'--.*?$', Comment.Single),
(words(keywords1, prefix=r'\b', suffix=r'\b'), Keyword.Namespace),
(words(keywords2, prefix=r'\b', suffix=r'\b'), Keyword),
(words(keywords3, prefix=r'\b', suffix=r'\b'), Keyword.Type),
(words(operators), Name.Builtin.Pseudo),
(words(punctuation), Operator),
(u"[A-Za-z_\u03b1-\u03ba\u03bc-\u03fb\u1f00-\u1ffe\u2100-\u214f]"
u"[A-Za-z_'\u03b1-\u03ba\u03bc-\u03fb\u1f00-\u1ffe\u2070-\u2079"
u"\u207f-\u2089\u2090-\u209c\u2100-\u214f0-9]*", Name),
(r'\d+', Number.Integer),
(r'"', String.Double, 'string'),
(r'[~?][a-z][\w\']*:', Name.Variable)
],
'comment': [
# Multiline Comments
(r'[^/-]', Comment.Multiline),
(r'/-', Comment.Multiline, '#push'),
(r'-/', Comment.Multiline, '#pop'),
(r'[/-]', Comment.Multiline)
],
'string': [
(r'[^\\"]+', String.Double),
(r'\\[n"\\]', String.Escape),
('"', String.Double, '#pop'),
],
}

View File

@@ -4,7 +4,7 @@
\lstdefinelanguage{lean} {
% Anything betweeen $ becomes LaTeX math mode
% Anything between $ becomes LaTeX math mode
mathescape=false,
% Comments may or not include Latex commands
texcl=false,
@@ -201,6 +201,7 @@ literate=
{}{{\ensuremath{_n}}}1
{}{{\ensuremath{_m}}}1
{}{{\ensuremath{_p}}}1
{}{{\ensuremath{\uparrow}}}1
{}{{\ensuremath{\downarrow}}}1
@@ -264,7 +265,7 @@ columns=[l]fullflexible,
% Style for (listings') identifiers
identifierstyle={\ttfamily\color{black}},
% Note : highlighting of Coq identifiers is done through a new
% delimiter definition through an lstset at the begining of the
% delimiter definition through an lstset at the beginning of the
% document. Don't know how to do better.
% Style for declaration keywords

View File

@@ -42,7 +42,7 @@ def Sum.str : Option Nat → String :=
## Implicit lambdas
In Lean 3 stdlib, we find many [instances](https://github.com/leanprover/lean/blob/master/library/init/category/reader.lean#L39) of the dreadful `@`+`_` idiom.
It is often used when we the expected type is a function type with implicit arguments,
It is often used when the expected type is a function type with implicit arguments,
and we have a constant (`reader_t.pure` in the example) which also takes implicit arguments. In Lean 4, the elaborator automatically introduces lambdas
for consuming implicit arguments. We are still exploring this feature and analyzing its impact, but the experience so far has been very positive. As an example,
here is the example in the link above using Lean 4 implicit lambdas.
@@ -85,7 +85,7 @@ def id5 : {α : Type} → αα :=
## Sugar for simple functions
In Lean 3, we can create simple functions from infix operators by using parentheses. For example, `(+1)` is sugar for `fun x, x + 1`. In Lean 4, we generalize this notation using `·` As a placeholder. Here are a few examples:
In Lean 3, we can create simple functions from infix operators by using parentheses. For example, `(+1)` is sugar for `fun x, x + 1`. In Lean 4, we generalize this notation using `·` as a placeholder. Here are a few examples:
```lean
# namespace ex3
@@ -196,6 +196,8 @@ example (f : Nat → Nat) (a b c : Nat) : f (a + b + c) = f (a + (b + c)) :=
congrArg f (Nat.add_assoc ..)
```
In Lean 4, writing `f(x)` in place of `f x` is no longer allowed, you must use whitespace between the function and its arguments (e.g., `f (x)`).
## Dependent function types
Given `α : Type` and `β : α → Type`, `(x : α) → β x` denotes the type of functions `f` with the property that,
@@ -287,11 +289,11 @@ Lean execution runtime. For example, we cannot prove in Lean that arrays have a
the runtime used to execute Lean programs guarantees that an array cannot have more than 2^64 (2^32) elements
in a 64-bit (32-bit) machine. We can take advantage of this fact to provide a more efficient implementation for
array functions. However, the efficient version would not be very useful if it can only be used in
unsafe code. Thus, Lean 4 provides the attribute `@[implementedBy functionName]`. The idea is to provide
unsafe code. Thus, Lean 4 provides the attribute `@[implemented_by functionName]`. The idea is to provide
an unsafe (and potentially more efficient) version of a safe definition or constant. The function `f`
at the attribute `@[implementedBy f]` is very similar to an extern/foreign function,
at the attribute `@[implemented_by f]` is very similar to an extern/foreign function,
the key difference is that it is implemented in Lean itself. Again, the logical soundness of the system
cannot be compromised by using the attribute `implementedBy`, but if the implementation is incorrect your
cannot be compromised by using the attribute `implemented_by`, but if the implementation is incorrect your
program may crash at runtime. In the following example, we define `withPtrUnsafe a k h` which
executes `k` using the memory address where `a` is stored in memory. The argument `h` is proof
that `k` is a constant function. Then, we "seal" this unsafe implementation at `withPtr`. The proof `h`
@@ -302,7 +304,7 @@ unsafe
def withPtrUnsafe {α β : Type} (a : α) (k : USize β) (h : u, k u = k 0) : β :=
k (ptrAddrUnsafe a)
@[implementedBy withPtrUnsafe]
@[implemented_by withPtrUnsafe]
def withPtr {α β : Type} (a : α) (k : USize β) (h : u, k u = k 0) : β :=
k 0
```
@@ -340,8 +342,7 @@ partial def f (x : Nat) : IO Unit := do
These are changes to the library which may trip up Lean 3 users:
- `Option` and `List` are no longer monads. Instead there is `OptionM`. This was done to avoid some performance traps. For example `o₁ <|> o₂` where `o₁ o₂ : Option α` will evaluate both `o₁` and `o₂` even if `o₁` evaluates to `some x`. This can be a problem if `o₂` requires a lot of compute to evaluate. A zulip discussion on this design choice is [here](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Option.20do.20notation.20regression.3F).
- `List` is no longer a monad.
## Style changes

Some files were not shown because too many files have changed in this diff Show More