lean4-htt/tests/lean/run/subset.lean
Matthew Robert Ballard b54a9ec9b9
feat: swap arguments to Membership.mem (#5020)
We swap the arguments for `Membership.mem` so that when proceeded by a
`SetLike` coercion, as is often the case in Mathlib, the resulting
expression is recognized as eta expanded and reduce for many
computations. The most beneficial outcome is that the discrimination
tree keys for instances and simp lemmas concerning subsets become more
robust resulting in more efficient searches.

Closes `RFC` #4932

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
Co-authored-by: Henrik Böving <hargonix@gmail.com>
2024-08-26 12:35:47 +00:00

39 lines
879 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def Set (α : Type u) := α → Prop
def setOf {α : Type u} (p : α → Prop) : Set α :=
p
namespace Set
protected def mem (s : Set α) (a : α) :=
s a
instance : Membership α (Set α) :=
⟨Set.mem⟩
theorem ext {a b : Set α} (h : ∀ (x : α), x ∈ a ↔ x ∈ b) : a = b :=
funext (fun x => propext (h x))
protected def subset (s₁ s₂ : Set α) :=
∀ {a}, a ∈ s₁ → a ∈ s₂
class Subset (α : Type u) where
/-- Subset relation: `a ⊆ b` -/
subset : αα → Prop
/-- Subset relation: `a ⊆ b` -/
infix:50 " ⊆ " => Subset.subset
instance : Subset (Set α) :=
⟨Set.subset⟩
instance : EmptyCollection (Set α) :=
⟨λ _ => False⟩
example (U : Type) (A B : Set U) : A ⊆ B → A = A :=
fun h =>
match @h with | (h : A ⊆ B) => sorry
example (U : Type) (A B : Set U) : A ⊆ B → A = A := by
intro (h : A ⊆ B)
sorry