Commit graph

21042 commits

Author SHA1 Message Date
Gabriel Ebner
e37f209c1a fix: unify types in calc 2023-01-27 13:38:42 -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
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
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
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
43c5ab802f fix: show tactic info on canonical by 2023-01-18 10:23:37 +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
Siddharth Bhat
ae4f2de951 fix: metadata codegen for LLVM 2023-01-12 17:39:56 +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
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
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
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
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
9a236e70dc fix: fixes #2009 2023-01-04 10:32:03 -08:00
Leonardo de Moura
0739c9ccd7 chore: revert workaround 2023-01-04 09:02: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