lean4-htt/tests
Leonardo de Moura e56351da7a
fix: pattern unification/matching in Sym (#11976)
This PR adds missing type checking for pattern variables during pattern
matching/unification to prevent incorrect matches.

Previously, the pattern matcher could incorrectly match expressions even
when pattern variable types were incompatible with the matched subterm
types. For example, a pattern like `x` where `x : BitVec 0` could match
any term, ignoring the specific type constraint on `x`.

This PR introduces a two-phase type checking approach:

1. **Static analysis** (`mkCheckTypeMask`): Identifies which pattern
variables require type checking based on their syntactic position.
Variables that appear only as arguments to function applications skip
checking (the application structure already constrains their types),
while variables in function position, binder contexts, or standalone
positions must be checked.

2. **Runtime validation**: During matching, when a pattern variable is
assigned, its type is checked against the matched subterm's type if
flagged by the mask. Checking uses `withReducible` to balance soundness
and performance.

The PR also adds helper functions for debugging (`Sym.mkMethods`,
`Sym.simpWith`, `Sym.simpGoal`) and fixes a minor issue where
`Theorem.rewrite` could return `.step` with identical expressions
instead of `.rfl`.Body:
2026-01-12 02:25:26 +00:00
..
bench perf: optimize congruence proof construction in Sym.simp (#11974) 2026-01-11 23:00:19 +00:00
bench-radar chore: measure dynamic symbols in benchmarks (#11568) 2025-12-11 16:10:27 +00:00
compiler chore: minor String API improvements (#11439) 2025-12-01 11:44:14 +00:00
elabissues
ir
lake fix: lake: meta import transitivity (#11683) 2025-12-16 08:28:52 +00:00
lean fix: pattern unification/matching in Sym (#11976) 2026-01-12 02:25:26 +00:00
pkg feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
playground
plugin
simpperf
.gitignore
common.sh feat: re-integrate lean4checker as leanchecker (#11887) 2026-01-08 09:41:33 +00:00
lakefile.toml feat: module system is no longer experimental (#11637) 2025-12-12 21:20:26 +00:00
lean-toolchain