File tree Expand file tree Collapse file tree 4 files changed +239
-113
lines changed
Expand file tree Collapse file tree 4 files changed +239
-113
lines changed Original file line number Diff line number Diff line change @@ -398,3 +398,51 @@ theorem properOrIff: Proper (Iff ⟹ Iff ⟹ Iff) Or :=
398398@[grewrite]
399399theorem properNotIff : Proper (Iff ⟹ Iff) Not :=
400400 ⟨fun _ _ h => by simp [h]⟩
401+
402+ def setEq : List α → List α → Prop :=
403+ fun l1 l2 => ∀ x, x ∈ l1 <-> x ∈ l2
404+
405+ instance setEqEquivalence {α : Type } : Equivalence (@setEq α) where
406+ refl := fun l1 x => Iff.rfl -- Reflexivity: l1 ≈ l1
407+ symm := by -- Symmetry: If l1 ≈ l2, then l2 ≈ l1
408+ intro x y hxy
409+ unfold setEq
410+ intro a
411+ apply Iff.symm
412+ exact hxy a
413+ trans := by
414+ intro x y z hxy hyz
415+ unfold setEq at *
416+ intro a
417+ apply Iff.intro
418+ intro hx
419+ rw [hxy a] at hx
420+ rw [hyz a] at hx
421+ assumption
422+ intro hy
423+ rw [← hyz a] at hy
424+ rw [← hxy a] at hy
425+ assumption
426+
427+ def addElem {α : Type } (x : α) (l : List α) : List α :=
428+ x :: l
429+
430+ @[grewrite]
431+ theorem addElemProper {α : Type } (x : α) : @Proper (List α → List α) (setEq ⟹ setEq) (addElem x) := by
432+ constructor
433+ unfold respectful
434+ intro l1 l2 heq x
435+ simp [addElem]
436+ constructor
437+ · intro hx
438+ cases hx with
439+ | inl => left; assumption
440+ | inr h' =>
441+ right; exact (heq x).mp h'
442+ · intro hx
443+ cases hx with
444+ | inl => left; assumption
445+ | inr h' => right; exact (heq x).mpr h'
446+
447+ initialize
448+ Lean.registerTraceClass `Meta.Tactic.grewrite
You can’t perform that action at this time.
0 commit comments