lean4-htt/tests/lean/run/2942.lean
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

68 lines
1.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
# `congr` conv tactic with "over-applied" functions
-/
/-!
The function `g` is "over-applied". Previously, conv-mode `congr` failed.
-/
/--
info: case a
a b : Nat
g : {α : Type} → αα
f : Nat → Nat
h : a = b
| f
case a
a b : Nat
g : {α : Type} → αα
f : Nat → Nat
h : a = b
| a
-/
#guard_msgs in
example (a b : Nat) (g : {α : Type} → αα) (f : Nat → Nat) (h : a = b) : g f a = g f b := by
conv =>
lhs
congr
trace_state
· rfl
· rw [h]
example (a b : Nat) (g : {α : Type} → αα) (f : Nat → Nat) (h : a = b) : g f a = g f b := by
conv =>
lhs
arg 2
rw [h]
/-!
While we are here, test `arg` too via `enter`.
-/
/--
info: a b : Nat
g : {α : Type} → αα
f : Nat → Nat
h : a = b
| a
---
info: a b : Nat
g : {α : Type} → αα
f : Nat → Nat
h : a = b
| f
---
info: a b : Nat
g : {α : Type} → αα
f : Nat → Nat
h : a = b
| a
-/
#guard_msgs in
example (a b : Nat) (g : {α : Type} → αα) (f : Nat → Nat) (h : a = b) : g f a = g f b := by
conv =>
conv => enter [1,2]; trace_state
conv => enter [1,1]; trace_state
conv => enter [1,@3]; trace_state
conv => fail_if_success enter [1,@1] -- cannot select the `Type` argument due to dependence.
rw [h]