Zulip Chat Archive
Stream: new members
Topic: rewriting `forall m in S`
Ralf Stephan (May 21 2024 at 14:44):
What do I need to know, in order to understand why the first example below works, but not the second?
import Mathlib
open Nat
example (P : Prop) (S T : Set ℕ) (h' : ∀ m ∈ S, P)
(h : S = T) : ∀ m ∈ T, P := by
rw [←h]
exact h'
example (P : Prop) (S : Set ℕ) (L : List ℕ) (h' : ∀ m ∈ S, P)
(h : m ∈ S ↔ m ∈ L) : ∀ m ∈ L, P := by
rw [←h]
exact h'
Yaël Dillies (May 21 2024 at 14:46):
Write set_option autoImplicit false
before the examples
Ralf Stephan (May 21 2024 at 14:49):
So, (m : ℕ)
is missing but it still doesn't work.
tactic 'rewrite' failed, did not find instance of the pattern in the target expression
m ∈ L
P: Prop
m: ℕ
S: Set ℕ
L: List ℕ
h': ∀ m ∈ S, P
h: m ∈ S ↔ m ∈ L
⊢ ∀ m ∈ L, P
Riccardo Brasca (May 21 2024 at 14:50):
What do you think your h : m ∈ S ↔ m ∈ L
mean? What is m
?
Yaël Dillies (May 21 2024 at 14:51):
Let me rewrite your new statement a bit:
example (P : Prop) (S : Set ℕ) (L : List ℕ) (m : ℕ) (h' : ∀ l ∈ S, P)
(h : m ∈ S ↔ m ∈ L) : ∀ l ∈ L, P :=
Yaël Dillies (May 21 2024 at 14:51):
Do you see the issue?
Ralf Stephan (May 21 2024 at 14:53):
m
is a variable? The statement is a bi-implication?
Yaël Dillies (May 21 2024 at 14:54):
Yes, but does it have anything to do with the l
in your ∀ l ∈ L
binder?
Ralf Stephan (May 21 2024 at 14:54):
Giving m
via `rw [←h m]
also doesn't work.
Riccardo Brasca (May 21 2024 at 14:55):
Do you want ∀ m, m ∈ S ↔ m ∈ L
?
Ralf Stephan (May 21 2024 at 14:56):
isn't that implicit?
Riccardo Brasca (May 21 2024 at 14:57):
No, if you look at the infoview for
example (P : Prop) (S : Set ℕ) (L : List ℕ) (h' : ∀ m ∈ S, P)
(h : m ∈ S ↔ m ∈ L) : ∀ m ∈ L, P := by
you see that Lean created a natural number called m
to make sense of h : m ∈ S ↔ m ∈ L
.
Riccardo Brasca (May 21 2024 at 14:58):
But this m
is fixed
Ralf Stephan (May 21 2024 at 15:04):
It looks to me that ∀ m, m ∈ S ↔ m ∈ L
behaves like m ∈ S ↔ m ∈ L
. Do you say that the goal cannot be matched, and the rewrite not be done?
Riccardo Brasca (May 21 2024 at 15:05):
If you dont write the ∀
binder, Lean just assumes that this double implication holds for one specific number. This is exactly the same difference between ∀ m, m ∈ S ↔ m ∈ L
and 37 ∈ S ↔ 37 ∈ L
.
Riccardo Brasca (May 21 2024 at 15:08):
Your goal at the beginning is ∀ m ∈ L, P
. The natural strategy here is to start with intro x
. Now the goal is x ∈ L → P, so we do another intro hx
. Now you have to prove P
, and you have a number x
such that x ∈ L
. You want to use that m ∈ S ↔ m ∈ L
to obtain that x ∈ s
, but x
and m
are completely unrelated.
Ralf Stephan (May 21 2024 at 15:11):
I keep forgetting that intro
splits off conditions also from forall statements. Thanks. That is embarrassing.
Ralf Stephan (May 21 2024 at 15:19):
hint
wouldn't suggest intro
either. Wouldn't that be useful?
Riccardo Brasca (May 21 2024 at 15:26):
I don't understand the question, hint
suggests intro
for me.
Ralf Stephan (May 21 2024 at 15:43):
In the original code, agreed. Not here, though:
import Mathlib
set_option autoImplicit false
example (P : Prop) (S : Set ℕ) (L : List ℕ) (h' : ∀ m ∈ S, P)
(h : ∀ m, m ∈ S ↔ m ∈ L) : ∀ m ∈ L, P := by
hint
Last updated: May 02 2025 at 03:31 UTC