Zulip Chat Archive
Stream: new members
Topic: set_like type of element
Winston Yin (Jun 22 2021 at 08:43):
I have an instance of set_like (some_class A) A
. If p : some_class A
, how can I get a : ↥p
from x : A
with x ∈ p
and vice versa?
Winston Yin (Jun 22 2021 at 08:46):
I feel like I could do such a thing intuitively, but let me know if I'm thinking about this wrong
Winston Yin (Jun 22 2021 at 08:53):
As an example:
variables
{k : Type*} {M : Type*}
[semiring k] [add_comm_monoid M] [module k M]
{p : submodule k M}
lemma lem1 (x : M) (h : x ∈ p) : p := sorry
def def2 (a : p) : M := sorry
lemma lem2 (a : p) : def2 a ∈ p := sorry
Winston Yin (Jun 22 2021 at 08:58):
I managed to answer my own question...
lemma lem1 (x : M) (h : x ∈ p) : p := ⟨x, h⟩
def def2 (a : p) : M := by {cases a, exact a_val}
lemma lem2 (a : p) : def2 a ∈ p := by {cases a, exact a_property}
Eric Wieser (Jun 22 2021 at 09:01):
More idiomatic would be:
def def2 (a : p) : M := a -- coercion happens here
lemma lem2 (a : p) : def2 a ∈ p := a.prop
Last updated: Dec 20 2023 at 11:08 UTC