Zulip Chat Archive
Stream: new members
Topic: Faster Way to prove all possible elements in a set
Colin Jones ⚛️ (Oct 18 2024 at 13:26):
Would there be a way to prove that mwe is a closed / finite set, such as:
def mwe := { s : String // s.length == 2 && s.dropWhile "AB".toList.contains == ""}
example (y : mwe) : y = ⟨"AA", by rfl⟩ ∨ y = ⟨"AB", by rfl⟩ ∨ y = ⟨"BA", by rfl⟩ ∨ y = ⟨"BB", by rfl⟩
:= by
obtain ⟨val, property⟩ := y
simp only [String.toList, ↓Char.isValue]
sorry
Kevin Buzzard (Oct 18 2024 at 17:24):
What do you mean by a closed set? This is a term coming from topology, but there is no topological space in sight. For finiteness, there are several ways to state this: which one are you interested? In short, can you ask your question with a #mwe rather than in words?
Eric Wieser (Oct 18 2024 at 17:29):
I think what you're trying to show is Fintype mwe
?
Eric Wieser (Oct 18 2024 at 17:30):
Or perhaps, (Set.univ : Set mwe) = {⟨"AA", by rfl⟩, ⟨"AB", by rfl⟩, ⟨"BA", by rfl⟩, ⟨"BB", by rfl⟩}
, but that's a weaker result
Colin Jones ⚛️ (Oct 19 2024 at 13:06):
Yes sorry I shouldn't use the word "closed set". Rather I want to show it is finite and only has those elements within it.
Colin Jones ⚛️ (Oct 19 2024 at 13:07):
Exactly as the example says shown above. Would this be possible?
Colin Jones ⚛️ (Oct 19 2024 at 13:08):
Eric Wieser said:
Or perhaps,
(Set.univ : Set mwe) = {⟨"AA", by rfl⟩, ⟨"AB", by rfl⟩, ⟨"BA", by rfl⟩, ⟨"BB", by rfl⟩}
, but that's a weaker result
Something like this, but to show that if y is an element of mwe it can only be those four items, nothing else
Colin Jones ⚛️ (Oct 20 2024 at 02:00):
Is there a way to do this combinatorially?
Colin Jones ⚛️ (Oct 20 2024 at 02:01):
Or to prove that the mwe type only has four possible members?
Colin Jones ⚛️ (Oct 20 2024 at 02:19):
Is there a faster way to prove this?
def mwe' := {s : String // s ∈ ({"A", "B", "C"} : Set String)}
def A : mwe' := ⟨"A", by simp only [Set.mem_insert_iff, Set.mem_singleton_iff, String.reduceEq,
or_false]⟩
def B : mwe' := ⟨"B", by simp only [Set.mem_insert_iff, String.reduceEq, Set.mem_singleton_iff,
or_false, or_true]⟩
def C : mwe' := ⟨"C", by simp only [Set.mem_insert_iff, String.reduceEq, Set.mem_singleton_iff,
or_true]⟩
example (x : mwe') : x = A ∨ x = B ∨ x = C := by
obtain ⟨h, property⟩ := x
rw [A, B, C]
rcases property
left
simp_all
rename_i property
rcases property
right
left
simp_all
rename_i property
right
right
simp only [Set.mem_singleton_iff] at property
simp_all
Kyle Miller (Oct 20 2024 at 02:23):
def mwe' := {s : String // s ∈ ({"A", "B", "C"} : Set String)}
def A : mwe' := ⟨"A", by decide⟩
def B : mwe' := ⟨"B", by decide⟩
def C : mwe' := ⟨"C", by decide⟩
example (x : mwe') : x = A ∨ x = B ∨ x = C := by
obtain ⟨s, h⟩ := x
simpa [A, B, C, mwe'] using h
Kevin Buzzard (Oct 20 2024 at 07:23):
(I have no idea about the API for String.dropWhile or contains, so I can't answer)
Notification Bot (Oct 20 2024 at 11:17):
10 messages were moved here from #new members > Trouble with a String Matching Function by Eric Wieser.
Eric Wieser (Oct 20 2024 at 11:18):
(I've merged two threads since I think they're basicaly the same idea)
Last updated: May 02 2025 at 03:31 UTC