Zulip Chat Archive
Stream: general
Topic: Explicit name for prop `x = (a,b)` in `match ... | x@(a,b)`
nrs (Dec 15 2024 at 02:52):
Can I give an explicit name to the proposition arising from match ... with | x@(a, b), ... => ... | ..., y@(c, d) => ...
stating that x = (a, b)
or y = (c, d)
in term mode? Instead of entering tactic mode to rename_i
afterwards
Mario Carneiro (Dec 15 2024 at 02:53):
match h : ...
nrs (Dec 15 2024 at 02:55):
hm, but does that not only work with matches of the form x@(a,b) => ...
? sorry the title is a bit misleading, could not fit enough examples
Mario Carneiro (Dec 15 2024 at 02:56):
no?
Kyle Miller (Dec 15 2024 at 02:58):
(an #mwe with a representative example would make this easy to answer)
nrs (Dec 15 2024 at 03:00):
For instance, this will introduce two inaccessible names:
def prodmatch (prod : Nat × Unit × (Nat ⊕ Nat) × (Unit × Nat)) : Nat :=
match ha : prod with
| x@⟨nat, u, sum, y@⟨ub, natb⟩⟩ => _
Kyle Miller (Dec 15 2024 at 03:02):
def prodmatch (prod : Nat × Unit × (Nat ⊕ Nat) × (Unit × Nat)) : Nat :=
match prod with
| x@hx:⟨nat, u, sum, y@hy:⟨ub, natb⟩⟩ => _
nrs (Dec 15 2024 at 03:02):
very cool! thanks a lot!!
Frederick Pu (Dec 15 2024 at 04:24):
sorry to intrude but what is this @ operator do?
Mario Carneiro (Dec 15 2024 at 04:29):
it "names" the subpattern
Mario Carneiro (Dec 15 2024 at 04:30):
so inside the match x
will be bound to the original expression and y
will be bound to the Unit × Nat
subterm
Frederick Pu (Dec 15 2024 at 20:21):
k cool
Last updated: May 02 2025 at 03:31 UTC