Zulip Chat Archive
Stream: new members
Topic: How to rewrite match case
MrQubo (Jan 24 2025 at 11:44):
Screenshot_20250124_124222.png
inductive Lam : ∀ (_ : Nat) (_ : Prop), Type
| bvar : ∀ {n}, (m : Nat) → (_ : m < n := by omega) → (p : Prop := True) → Lam n p
| fvar : ∀ {n}, String → Lam n False
| app : ∀ {n p q r}, Lam n p → Lam n q → (_ : r → p ∧ q := by simp_all) → Lam n r
| lam : ∀ {n p r}, Lam n.succ p → (_ : r → p := by simp_all) → Lam n r
deriving Repr
open Lam
def forgetClosed {n p} (t : Lam n p) : Lam n False :=
match ht : t with
| bvar m h p => bvar m h False
| fvar name => by
<here>
| app f arg _ => app f arg
| lam body _ => lam body
How can I rewrite t
to Lam n False
? I.e., how can I name anonymous hypothesis p = False
, or how can I use this anonymous hypothesis in rewrite.
Ruben Van de Velde (Jan 24 2025 at 11:59):
Maybe rename_i hp
Aaron Liu (Jan 24 2025 at 11:59):
What are you trying to accomplish? The goal state at <here>
is
n : Nat
p : Prop
t : Lam n p
name : String
h✝ : p = False
ht : HEq t (fvar name)
⊢ Lam n False
What do you want to try to turn this into?
MrQubo (Jan 24 2025 at 12:05):
I want to do rw [h✝] at t; exact t
basically.
Aaron Liu (Jan 24 2025 at 12:07):
This works:
| fvar name => ‹p = False› ▸ t
MrQubo (Jan 24 2025 at 12:11):
Ruben Van de Velde said:
Maybe
rename_i hp
I've read that the names of inaccessible names aren't guaranteed to be preserved across lean version. Is order of inaccessible names guaranteed though?
Edward van de Meent (Jan 24 2025 at 12:14):
i think it's decently consistent?
MrQubo (Jan 24 2025 at 12:15):
Aaron Liu said:
This works:
| fvar name => ‹p = False› ▸ t
Thanks! I think I understand what \f<>
does, but how can I find what \t
does?
Edward van de Meent (Jan 24 2025 at 12:15):
perhaps easier:
def forgetClosed {n p} : Lam n p → Lam n False
| bvar m h p => bvar m h False
| fvar name => fvar name
| app f arg _ => app f arg
| lam body _ => lam body
MrQubo (Jan 24 2025 at 12:16):
Edward van de Meent said:
perhaps easier:
def forgetClosed {n p} : Lam n p → Lam n False | bvar m h p => bvar m h False | fvar name => fvar name | app f arg _ => app f arg | lam body _ => lam body
Oh, wait, it does work. I thought I've tried it and it didn't.
Edward van de Meent (Jan 24 2025 at 12:18):
also a possibility:
def forgetClosed {n p} (t : Lam n p) : Lam n False :=
match t with
| bvar m h p => bvar m h False
| t'@(fvar name) => t'
| app f arg _ => app f arg
| lam body _ => lam body
MrQubo (Jan 24 2025 at 12:23):
MrQubo said:
Aaron Liu said:
This works:
| fvar name => ‹p = False› ▸ t
Thanks! I think I understand what
\f<>
does, but how can I find what\t
does?
Hm, okay, found it. In neovim I had to put (‹p = False› ▸ t)
in parentheses, and then run vim.lsp.buf.hover()
with my cursor on ▸
.
Last updated: May 02 2025 at 03:31 UTC