lean4-htt/src/Lean
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
..
Compiler refactor: more idiomatic syntax for if h: (#5567) 2024-10-01 15:23:54 +00:00
Data chore: remove repeated words (#5438) 2024-09-24 03:40:11 +00:00
DocString fix: Lake: brittle dependency on env ext name 2024-10-07 13:26:07 +02:00
Elab feat: decide! tactic for using kernel reduction (#5665) 2024-10-11 06:40:57 +00:00
Language fix: worker: make sure to always report some recent range as progress when waiting (#5428) 2024-09-23 15:52:52 +00:00
Linter chore: deprecate := variants of inductive and structure (#5542) 2024-10-11 05:54:18 +00:00
Meta feat: decide! tactic for using kernel reduction (#5665) 2024-10-11 06:40:57 +00:00
Parser feat: decide! tactic for using kernel reduction (#5665) 2024-10-11 06:40:57 +00:00
ParserCompiler feat: reserved names (#3675) 2024-03-15 00:33:22 +00:00
PrettyPrinter feat: add option pp.mvars.delayed (#5643) 2024-10-08 17:48:52 +00:00
Server feat: whitespace tactic completion & tactic completion docs (#5666) 2024-10-10 13:28:34 +00:00
Util chore: remove mention of Lean.withSeconds (#5481) 2024-09-26 18:15:58 +00:00
Widget feat: use incrementality for completion in tactic blocks (#5205) 2024-09-09 12:08:37 +00:00
AddDecl.lean fix: adapt kernel interruption to new cancellation system (#4584) 2024-07-01 14:52:42 +00:00
Attributes.lean refactor: dead code AttributeExtensionOLeanEntry.decl (#5496) 2024-10-01 13:34:12 +00:00
AuxRecursor.lean refactor: IndGroupInst.brecOn (#4787) 2024-07-19 10:20:50 +00:00
BuiltinDocAttr.lean feat: more infrastructure for tactic documentation (#4490) 2024-06-21 12:49:30 +00:00
Class.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Compiler.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
CoreM.lean fix: use MessageData.tagged to mark maxHeartbeat exceptions (#5566) 2024-10-09 02:08:50 +00:00
Data.lean chore: move Lean.Data.Parsec to Std.Internal.Parsec (#5115) 2024-08-21 15:26:17 +00:00
Declaration.lean chore: fix spelling mistakes in src/Lean/ (#5426) 2024-09-23 14:56:59 +00:00
DeclarationRange.lean fix: call hierarchy into (builtin_)initialize (#5560) 2024-10-03 12:03:44 +00:00
DocString.lean feat: more infrastructure for tactic documentation (#4490) 2024-06-21 12:49:30 +00:00
Elab.lean feat: better #eval command (#5627) 2024-10-08 20:51:46 +00:00
Environment.lean feat: expose Kernel.check for debugging purposes (#5412) 2024-10-01 21:28:02 +00:00
Exception.lean fix: use MessageData.tagged to mark maxHeartbeat exceptions (#5566) 2024-10-09 02:08:50 +00:00
Expr.lean chore: fix spelling mistakes in src/Lean/ (#5426) 2024-09-23 14:56:59 +00:00
HeadIndex.lean chore: fix linter errors (#4502) 2024-06-19 18:24:08 +00:00
Hygiene.lean chore: remove the coercion from String to Name (#3589) 2024-03-21 23:46:03 +00:00
ImportingFlag.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
InternalExceptionId.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
KeyedDeclsAttribute.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
LabelAttribute.lean chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
LazyInitExtension.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Level.lean chore: deprecate Lean.HashMap and Lean.HashSet (#4954) 2024-08-08 12:46:10 +00:00
Linter.lean feat: omit (#5000) 2024-08-21 13:22:34 +00:00
LoadDynlib.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
LocalContext.lean refactor: more idiomatic syntax for if h: (#5567) 2024-10-01 15:23:54 +00:00
Log.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Message.lean chore: remove repeated words (#5438) 2024-09-24 03:40:11 +00:00
Meta.lean feat: improve set_option diagnostics true (#4031) 2024-04-30 05:07:03 +00:00
MetavarContext.lean chore: fix typos in Lean.MetavarContext (#5476) 2024-09-26 00:25:03 +00:00
Modifiers.lean refactor: constructions: modify environment in lean world (#4474) 2024-06-19 08:58:53 +00:00
MonadEnv.lean refactor: use indVal.numNested or indVal.numTypeFormers where applicable (#4734) 2024-07-12 22:07:25 +00:00
Parser.lean feat: more infrastructure for tactic documentation (#4490) 2024-06-21 12:49:30 +00:00
ParserCompiler.lean refactor: Offset.lean and related files (#3614) 2024-03-05 19:40:15 -08:00
PrettyPrinter.lean chore: use Expr.numObjs instead of lean_expr_size_shared (#5239) 2024-09-02 21:26:00 +00:00
ProjFns.lean fix: modify projection instance binder info (#5376) 2024-09-20 06:03:59 +00:00
ReducibilityAttrs.lean chore: fix linter errors (#4502) 2024-06-19 18:24:08 +00:00
Replay.lean chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
ReservedNameAction.lean fix: FunInd: support structural recursion on reflexive types (#4327) 2024-06-05 07:54:48 +00:00
ResolveName.lean chore: fix spelling mistakes in src/Lean/ (#5426) 2024-09-23 14:56:59 +00:00
Runtime.lean feat: link LibUV (#4963) 2024-08-12 12:33:24 +00:00
ScopedEnvExtension.lean feat: flexible reducibility attributes 2024-04-29 05:46:11 +02:00
Server.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Structure.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
SubExpr.lean fix: use correct expr positions when delaborating match patterns (#4034) 2024-05-01 12:02:10 +00:00
Syntax.lean refactor: move Synax.hasIdent, shake dependencies (#4766) 2024-07-16 21:19:26 +00:00
ToExpr.lean chore: upstream Zero and NeZero 2024-09-10 19:30:09 +10:00
Util.lean feat: localize universe metavariable errors at let bindings and fun binders (#5402) 2024-09-24 05:30:42 +00:00
Widget.lean perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00