order.symm_diff

# Symmetric difference and bi-implication #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras.

## Examples #

Some examples are

• The symmetric difference of two sets is the set of elements that are in either but not both.
• The symmetric difference on propositions is xor.
• The symmetric difference on bool is bxor.
• The equivalence of propositions. Two propositions are equivalent if they imply each other.
• The symmetric difference translates to addition when considering a Boolean algebra as a Boolean ring.

## Main declarations #

• symm_diff: The symmetric difference operator, defined as (a \ b) ⊔ (b \ a)
• bihimp: The bi-implication operator, defined as (b ⇨ a) ⊓ (a ⇨ b)

In generalized Boolean algebras, the symmetric difference operator is:

• symm_diff_comm: commutative, and
• symm_diff_assoc: associative.

## Notations #

• a ∆ b: symm_diff a b
• a ⇔ b: bihimp a b

## References #

The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A Proof from the Book" by John McCuan:

## Tags #

boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication, Heyting

def symm_diff {α : Type u_2} [has_sup α] [has_sdiff α] (a b : α) :
α

The symmetric difference operator on a type with ⊔ and \ is (A \ B) ⊔ (B \ A).

Equations
Instances for symm_diff
def bihimp {α : Type u_2} [has_inf α] [has_himp α] (a b : α) :
α

The Heyting bi-implication is (b ⇨ a) ⊓ (a ⇨ b). This generalizes equivalence of propositions.

Equations
Instances for bihimp
theorem symm_diff_def {α : Type u_2} [has_sup α] [has_sdiff α] (a b : α) :
a b = a \ b b \ a
theorem bihimp_def {α : Type u_2} [has_inf α] [has_himp α] (a b : α) :
a b = (b a) (a b)
theorem symm_diff_eq_xor (p q : Prop) :
p q = xor p q
@[simp]
theorem bihimp_iff_iff {p q : Prop} :
p q (p q)
@[simp]
theorem bool.symm_diff_eq_bxor (p q : bool) :
p q = bxor p q
@[simp]
theorem to_dual_symm_diff {α : Type u_2} (a b : α) :
@[simp]
theorem of_dual_bihimp {α : Type u_2} (a b : αᵒᵈ) :
theorem symm_diff_comm {α : Type u_2} (a b : α) :
a b = b a
@[protected, instance]
def symm_diff_is_comm {α : Type u_2}  :
@[simp]
theorem symm_diff_self {α : Type u_2} (a : α) :
a a =
@[simp]
theorem symm_diff_bot {α : Type u_2} (a : α) :
a = a
@[simp]
theorem bot_symm_diff {α : Type u_2} (a : α) :
a = a
@[simp]
theorem symm_diff_eq_bot {α : Type u_2} {a b : α} :
a b = a = b
theorem symm_diff_of_le {α : Type u_2} {a b : α} (h : a b) :
a b = b \ a
theorem symm_diff_of_ge {α : Type u_2} {a b : α} (h : b a) :
a b = a \ b
theorem symm_diff_le {α : Type u_2} {a b c : α} (ha : a b c) (hb : b a c) :
a b c
theorem symm_diff_le_iff {α : Type u_2} {a b c : α} :
a b c a b c b a c
@[simp]
theorem symm_diff_le_sup {α : Type u_2} {a b : α} :
a b a b
theorem symm_diff_eq_sup_sdiff_inf {α : Type u_2} (a b : α) :
a b = (a b) \ (a b)
theorem disjoint.symm_diff_eq_sup {α : Type u_2} {a b : α} (h : b) :
a b = a b
theorem symm_diff_sdiff {α : Type u_2} (a b c : α) :
a b \ c = a \ (b c) b \ (a c)
@[simp]
theorem symm_diff_sdiff_inf {α : Type u_2} (a b : α) :
a b \ (a b) = a b
@[simp]
theorem symm_diff_sdiff_eq_sup {α : Type u_2} (a b : α) :
a (b \ a) = a b
@[simp]
theorem sdiff_symm_diff_eq_sup {α : Type u_2} (a b : α) :
(a \ b) b = a b
@[simp]
theorem symm_diff_sup_inf {α : Type u_2} (a b : α) :
a b a b = a b
@[simp]
theorem inf_sup_symm_diff {α : Type u_2} (a b : α) :
a b a b = a b
@[simp]
theorem symm_diff_symm_diff_inf {α : Type u_2} (a b : α) :
a b (a b) = a b
@[simp]
theorem inf_symm_diff_symm_diff {α : Type u_2} (a b : α) :
(a b) (a b) = a b
theorem symm_diff_triangle {α : Type u_2} (a b c : α) :
a c a b b c
@[simp]
theorem to_dual_bihimp {α : Type u_2} (a b : α) :
@[simp]
theorem of_dual_symm_diff {α : Type u_2} (a b : αᵒᵈ) :
theorem bihimp_comm {α : Type u_2} (a b : α) :
a b = b a
@[protected, instance]
def bihimp_is_comm {α : Type u_2}  :
@[simp]
theorem bihimp_self {α : Type u_2} (a : α) :
a a =
@[simp]
theorem bihimp_top {α : Type u_2} (a : α) :
a = a
@[simp]
theorem top_bihimp {α : Type u_2} (a : α) :
a = a
@[simp]
theorem bihimp_eq_top {α : Type u_2} {a b : α} :
a b = a = b
theorem bihimp_of_le {α : Type u_2} {a b : α} (h : a b) :
a b = b a
theorem bihimp_of_ge {α : Type u_2} {a b : α} (h : b a) :
a b = a b
theorem le_bihimp {α : Type u_2} {a b c : α} (hb : a b c) (hc : a c b) :
a b c
theorem le_bihimp_iff {α : Type u_2} {a b c : α} :
a b c a b c a c b
@[simp]
theorem inf_le_bihimp {α : Type u_2} {a b : α} :
a b a b
theorem bihimp_eq_inf_himp_inf {α : Type u_2} (a b : α) :
a b = a b a b
theorem codisjoint.bihimp_eq_inf {α : Type u_2} {a b : α} (h : b) :
a b = a b
theorem himp_bihimp {α : Type u_2} (a b c : α) :
a b c = (a c b) (a b c)
@[simp]
theorem sup_himp_bihimp {α : Type u_2} (a b : α) :
a b a b = a b
@[simp]
theorem bihimp_himp_eq_inf {α : Type u_2} (a b : α) :
a (a b) = a b
@[simp]
theorem himp_bihimp_eq_inf {α : Type u_2} (a b : α) :
(b a) b = a b
@[simp]
theorem bihimp_inf_sup {α : Type u_2} (a b : α) :
a b (a b) = a b
@[simp]
theorem sup_inf_bihimp {α : Type u_2} (a b : α) :
(a b) a b = a b
@[simp]
theorem bihimp_bihimp_sup {α : Type u_2} (a b : α) :
a b (a b) = a b
@[simp]
theorem sup_bihimp_bihimp {α : Type u_2} (a b : α) :
(a b) (a b) = a b
theorem bihimp_triangle {α : Type u_2} (a b c : α) :
a b b c a c
@[simp]
theorem symm_diff_top' {α : Type u_2} (a : α) :
@[simp]
theorem top_symm_diff' {α : Type u_2} (a : α) :
@[simp]
theorem hnot_symm_diff_self {α : Type u_2} (a : α) :
(a) a =
@[simp]
theorem symm_diff_hnot_self {α : Type u_2} (a : α) :
theorem is_compl.symm_diff_eq_top {α : Type u_2} {a b : α} (h : b) :
a b =
@[simp]
theorem bihimp_bot {α : Type u_2} (a : α) :
@[simp]
theorem bot_bihimp {α : Type u_2} (a : α) :
@[simp]
theorem compl_bihimp_self {α : Type u_2} (a : α) :
@[simp]
theorem bihimp_hnot_self {α : Type u_2} (a : α) :
theorem is_compl.bihimp_eq_bot {α : Type u_2} {a b : α} (h : b) :
a b =
@[simp]
theorem sup_sdiff_symm_diff {α : Type u_2} (a b : α) :
(a b) \ a b = a b
theorem disjoint_symm_diff_inf {α : Type u_2} (a b : α) :
disjoint (a b) (a b)
theorem inf_symm_diff_distrib_left {α : Type u_2} (a b c : α) :
a b c = (a b) (a c)
theorem inf_symm_diff_distrib_right {α : Type u_2} (a b c : α) :
a b c = (a c) (b c)
theorem sdiff_symm_diff {α : Type u_2} (a b c : α) :
c \ a b = c a b c \ a c \ b
theorem sdiff_symm_diff' {α : Type u_2} (a b c : α) :
c \ a b = c a b c \ (a b)
@[simp]
theorem symm_diff_sdiff_left {α : Type u_2} (a b : α) :
a b \ a = b \ a
@[simp]
theorem symm_diff_sdiff_right {α : Type u_2} (a b : α) :
a b \ b = a \ b
@[simp]
theorem sdiff_symm_diff_left {α : Type u_2} (a b : α) :
a \ a b = a b
@[simp]
theorem sdiff_symm_diff_right {α : Type u_2} (a b : α) :
b \ a b = a b
theorem symm_diff_eq_sup {α : Type u_2} (a b : α) :
a b = a b b
@[simp]
theorem le_symm_diff_iff_left {α : Type u_2} (a b : α) :
a a b b
@[simp]
theorem le_symm_diff_iff_right {α : Type u_2} (a b : α) :
b a b b
theorem symm_diff_symm_diff_left {α : Type u_2} (a b c : α) :
a b c = a \ (b c) b \ (a c) c \ (a b) a b c
theorem symm_diff_symm_diff_right {α : Type u_2} (a b c : α) :
a (b c) = a \ (b c) b \ (a c) c \ (a b) a b c
theorem symm_diff_assoc {α : Type u_2} (a b c : α) :
a b c = a (b c)
@[protected, instance]
def symm_diff_is_assoc {α : Type u_2}  :
theorem symm_diff_left_comm {α : Type u_2} (a b c : α) :
a (b c) = b (a c)
theorem symm_diff_right_comm {α : Type u_2} (a b c : α) :
a b c = a c b
theorem symm_diff_symm_diff_symm_diff_comm {α : Type u_2} (a b c d : α) :
a b (c d) = a c (b d)
@[simp]
theorem symm_diff_symm_diff_cancel_left {α : Type u_2} (a b : α) :
a (a b) = b
@[simp]
theorem symm_diff_symm_diff_cancel_right {α : Type u_2} (a b : α) :
b a a = b
@[simp]
theorem symm_diff_symm_diff_self' {α : Type u_2} (a b : α) :
a b a = b
theorem symm_diff_left_involutive {α : Type u_2} (a : α) :
function.involutive (λ (_x : α), _x a)
theorem symm_diff_right_involutive {α : Type u_2} (a : α) :
theorem symm_diff_left_injective {α : Type u_2} (a : α) :
function.injective (λ (_x : α), _x a)
theorem symm_diff_right_injective {α : Type u_2} (a : α) :
theorem symm_diff_left_surjective {α : Type u_2} (a : α) :
function.surjective (λ (_x : α), _x a)
theorem symm_diff_right_surjective {α : Type u_2} (a : α) :
@[simp]
theorem symm_diff_left_inj {α : Type u_2} {a b c : α} :
a b = c b a = c
@[simp]
theorem symm_diff_right_inj {α : Type u_2} {a b c : α} :
a b = a c b = c
@[simp]
theorem symm_diff_eq_left {α : Type u_2} {a b : α} :
a b = a b =
@[simp]
theorem symm_diff_eq_right {α : Type u_2} {a b : α} :
a b = b a =
@[protected]
theorem disjoint.symm_diff_left {α : Type u_2} {a b c : α} (ha : c) (hb : c) :
disjoint (a b) c
@[protected]
theorem disjoint.symm_diff_right {α : Type u_2} {a b c : α} (ha : b) (hb : c) :
(b c)
theorem symm_diff_eq_iff_sdiff_eq {α : Type u_2} {a b c : α} (ha : a c) :
a b = c c \ a = b
@[simp]
theorem inf_himp_bihimp {α : Type u_2} (a b : α) :
a b a b = a b
theorem codisjoint_bihimp_sup {α : Type u_2} (a b : α) :
codisjoint (a b) (a b)
@[simp]
theorem himp_bihimp_left {α : Type u_2} (a b : α) :
a a b = a b
@[simp]
theorem himp_bihimp_right {α : Type u_2} (a b : α) :
b a b = b a
@[simp]
theorem bihimp_himp_left {α : Type u_2} (a b : α) :
a b a = a b
@[simp]
theorem bihimp_himp_right {α : Type u_2} (a b : α) :
a b b = a b
@[simp]
theorem bihimp_eq_inf {α : Type u_2} (a b : α) :
a b = a b b
@[simp]
theorem bihimp_le_iff_left {α : Type u_2} (a b : α) :
a b a b
@[simp]
theorem bihimp_le_iff_right {α : Type u_2} (a b : α) :
a b b b
theorem bihimp_assoc {α : Type u_2} (a b c : α) :
a b c = a (b c)
@[protected, instance]
def bihimp_is_assoc {α : Type u_2}  :
theorem bihimp_left_comm {α : Type u_2} (a b c : α) :
a (b c) = b (a c)
theorem bihimp_right_comm {α : Type u_2} (a b c : α) :
a b c = a c b
theorem bihimp_bihimp_bihimp_comm {α : Type u_2} (a b c d : α) :
a b (c d) = a c (b d)
@[simp]
theorem bihimp_bihimp_cancel_left {α : Type u_2} (a b : α) :
a (a b) = b
@[simp]
theorem bihimp_bihimp_cancel_right {α : Type u_2} (a b : α) :
b a a = b
@[simp]
theorem bihimp_bihimp_self {α : Type u_2} (a b : α) :
a b a = b
theorem bihimp_left_involutive {α : Type u_2} (a : α) :
function.involutive (λ (_x : α), _x a)
theorem bihimp_right_involutive {α : Type u_2} (a : α) :
theorem bihimp_left_injective {α : Type u_2} (a : α) :
function.injective (λ (_x : α), _x a)
theorem bihimp_right_injective {α : Type u_2} (a : α) :
theorem bihimp_left_surjective {α : Type u_2} (a : α) :
function.surjective (λ (_x : α), _x a)
theorem bihimp_right_surjective {α : Type u_2} (a : α) :
@[simp]
theorem bihimp_left_inj {α : Type u_2} {a b c : α} :
a b = c b a = c
@[simp]
theorem bihimp_right_inj {α : Type u_2} {a b c : α} :
a b = a c b = c
@[simp]
theorem bihimp_eq_left {α : Type u_2} {a b : α} :
a b = a b =
@[simp]
theorem bihimp_eq_right {α : Type u_2} {a b : α} :
a b = b a =
@[protected]
theorem codisjoint.bihimp_left {α : Type u_2} {a b c : α} (ha : c) (hb : c) :
codisjoint (a b) c
@[protected]
theorem codisjoint.bihimp_right {α : Type u_2} {a b c : α} (ha : b) (hb : c) :
(b c)
theorem symm_diff_eq {α : Type u_2} (a b : α) :
a b = a b b a
theorem bihimp_eq {α : Type u_2} (a b : α) :
a b = (a b) (b a)
theorem symm_diff_eq' {α : Type u_2} (a b : α) :
a b = (a b) (a b)
theorem bihimp_eq' {α : Type u_2} (a b : α) :
a b = a b a b
theorem symm_diff_top {α : Type u_2} (a : α) :
theorem top_symm_diff {α : Type u_2} (a : α) :
@[simp]
theorem compl_symm_diff {α : Type u_2} (a b : α) :
(a b) = a b
@[simp]
theorem compl_bihimp {α : Type u_2} (a b : α) :
(a b) = a b
@[simp]
theorem compl_symm_diff_compl {α : Type u_2} (a b : α) :
a b = a b
@[simp]
theorem compl_bihimp_compl {α : Type u_2} (a b : α) :
a b = a b
@[simp]
theorem symm_diff_eq_top {α : Type u_2} (a b : α) :
a b = b
@[simp]
theorem bihimp_eq_bot {α : Type u_2} (a b : α) :
a b = b
@[simp]
theorem compl_symm_diff_self {α : Type u_2} (a : α) :
@[simp]
theorem symm_diff_compl_self {α : Type u_2} (a : α) :
theorem symm_diff_symm_diff_right' {α : Type u_2} (a b c : α) :
a (b c) = a b c a b c a b c a b c
theorem disjoint.le_symm_diff_sup_symm_diff_left {α : Type u_2} {a b c : α} (h : b) :
c a c b c
theorem disjoint.le_symm_diff_sup_symm_diff_right {α : Type u_2} {a b c : α} (h : c) :
a a b a c
theorem codisjoint.bihimp_inf_bihimp_le_left {α : Type u_2} {a b c : α} (h : b) :
a c b c c
theorem codisjoint.bihimp_inf_bihimp_le_right {α : Type u_2} {a b c : α} (h : c) :
a b a c a

### Prod #

@[simp]
theorem symm_diff_fst {α : Type u_2} {β : Type u_3} (a b : α × β) :
(a b).fst = a.fst b.fst
@[simp]
theorem symm_diff_snd {α : Type u_2} {β : Type u_3} (a b : α × β) :
(a b).snd = a.snd b.snd
@[simp]
theorem bihimp_fst {α : Type u_2} {β : Type u_3} (a b : α × β) :
(a b).fst = a.fst b.fst
@[simp]
theorem bihimp_snd {α : Type u_2} {β : Type u_3} (a b : α × β) :
(a b).snd = a.snd b.snd

### Pi #

theorem pi.symm_diff_def {ι : Type u_1} {π : ι Type u_4} [Π (i : ι), ] (a b : Π (i : ι), π i) :
a b = λ (i : ι), a i b i
theorem pi.bihimp_def {ι : Type u_1} {π : ι Type u_4} [Π (i : ι), ] (a b : Π (i : ι), π i) :
a b = λ (i : ι), a i b i
@[simp]
theorem pi.symm_diff_apply {ι : Type u_1} {π : ι Type u_4} [Π (i : ι), ] (a b : Π (i : ι), π i) (i : ι) :
(a b) i = a i b i
@[simp]
theorem pi.bihimp_apply {ι : Type u_1} {π : ι Type u_4} [Π (i : ι), ] (a b : Π (i : ι), π i) (i : ι) :
(a b) i = a i b i