lean4-htt/src
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
..
bin
cmake chore: more libuv search patterns for the speedcenter (#5008) 2024-08-13 10:40:09 +02:00
include/lean chore: rename Array.data to Array.toList 2024-09-10 15:24:23 +10:00
Init chore: upstream List.fold lemmas (#5519) 2024-09-29 07:21:32 +00:00
initialize fix: explicitly initialize Std in lean_initialize (#4668) 2024-07-06 13:17:30 +00:00
kernel chore: fix spelling mistakes in non-Lean files (#5430) 2024-09-23 21:11:20 +00:00
lake refactor: lake: switch new/init default to TOML (#5504) 2024-09-28 06:28:50 +00:00
Lean feat: let simp apply rules with higher-order patterns (#5479) 2024-09-29 07:26:48 +00:00
library chore: remove repeated words (#5438) 2024-09-24 03:40:11 +00:00
runtime chore: fix spelling mistakes in non-Lean files (#5430) 2024-09-23 21:11:20 +00:00
shell chore: avoid rebuilding leanmanifest in each build (#5057) 2024-08-15 14:55:36 +00:00
Std chore: rename List.maximum? to max? (#5518) 2024-09-29 06:23:24 +00:00
util fix: typo in run_new_frontend signature (#4685) 2024-09-25 05:42:48 +00:00
cadical.mk feat: ship cadical (#4325) 2024-08-23 09:13:27 +00:00
CMakeLists.txt chore: restore Lake build 2024-09-10 15:24:23 +10:00
config.h.in
githash.h.in
Init.lean feat: grind normalization theorems (#4164) 2024-05-14 19:19:38 +00:00
lakefile.toml.in feat: introduce Std (#4499) 2024-06-21 07:08:45 +00:00
lean-toolchain
Lean.lean feat: propagate maxHeartbeats to kernel (#4113) 2024-05-09 17:44:19 +00:00
lean.mk.in fix: split libleanshared on Windows to avoid symbol limit 2024-08-12 14:14:42 +02:00
Leanc.lean feat: expose flags for the bundled C compiler (#4477) 2024-06-22 01:23:33 +00:00
Std.lean chore: move Lean.Data.Parsec to Std.Internal.Parsec (#5115) 2024-08-21 15:26:17 +00:00
stdlib.make.in fix: do not link to Lake_shared with absolute path (#5286) 2024-09-09 11:11:00 +00:00
stdlib_flags.h chore: unset parseQuotWithCurrentStage in stage1’s src/stdlib_flags.h (#4537) 2024-06-23 09:44:14 +00:00
version.h.in