2014-08-07 18:36:44 +00:00
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
|
--- Copyright (c) 2014 Jeremy Avigad. All rights reserved.
|
2014-07-27 20:18:33 +00:00
|
|
|
|
--- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
--- Author: Jeremy Avigad, Leonardo de Moura
|
2014-08-01 01:40:09 +00:00
|
|
|
|
----------------------------------------------------------------------------------------------------
|
2014-08-26 05:54:44 +00:00
|
|
|
|
import data.bool
|
2014-08-20 02:32:44 +00:00
|
|
|
|
using eq_ops bool
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
|
|
|
|
namespace set
|
2014-08-26 05:54:44 +00:00
|
|
|
|
definition set (T : Type) :=
|
|
|
|
|
T → bool
|
|
|
|
|
definition mem {T : Type} (x : T) (s : set T) :=
|
|
|
|
|
(s x) = tt
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infix `∈` := mem
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
definition eqv {T : Type} (A B : set T) : Prop :=
|
|
|
|
|
∀x, x ∈ A ↔ x ∈ B
|
|
|
|
|
infixl `∼`:50 := eqv
|
|
|
|
|
|
|
|
|
|
theorem eqv_refl {T : Type} (A : set T) : A ∼ A :=
|
|
|
|
|
take x, iff_rfl
|
|
|
|
|
|
|
|
|
|
theorem eqv_symm {T : Type} {A B : set T} (H : A ∼ B) : B ∼ A :=
|
|
|
|
|
take x, iff_symm (H x)
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem eqv_trans {T : Type} {A B C : set T} (H1 : A ∼ B) (H2 : B ∼ C) : A ∼ C :=
|
|
|
|
|
take x, iff_trans (H1 x) (H2 x)
|
|
|
|
|
|
|
|
|
|
definition empty {T : Type} : set T :=
|
|
|
|
|
λx, ff
|
2014-08-22 23:36:47 +00:00
|
|
|
|
notation `∅` := empty
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem mem_empty {T : Type} (x : T) : ¬ (x ∈ ∅) :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
assume H : x ∈ ∅, absurd H ff_ne_tt
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
definition univ {T : Type} : set T :=
|
|
|
|
|
λx, tt
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem mem_univ {T : Type} (x : T) : x ∈ univ :=
|
|
|
|
|
rfl
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
definition inter {T : Type} (A B : set T) : set T :=
|
|
|
|
|
λx, A x && B x
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infixl `∩` := inter
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem mem_inter {T : Type} (x : T) (A B : set T) : x ∈ A ∩ B ↔ (x ∈ A ∧ x ∈ B) :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
|
|
|
|
(assume H, and_intro (band_eq_tt_elim_left H) (band_eq_tt_elim_right H))
|
|
|
|
|
(assume H,
|
|
|
|
|
have e1 : A x = tt, from and_elim_left H,
|
|
|
|
|
have e2 : B x = tt, from and_elim_right H,
|
|
|
|
|
show A x && B x = tt, from e1⁻¹ ▸ e2⁻¹ ▸ band_tt_left tt)
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem inter_id {T : Type} (A : set T) : A ∩ A ∼ A :=
|
|
|
|
|
take x, band_id (A x) ▸ iff_rfl
|
|
|
|
|
|
|
|
|
|
theorem inter_empty_right {T : Type} (A : set T) : A ∩ ∅ ∼ ∅ :=
|
|
|
|
|
take x, band_ff_right (A x) ▸ iff_rfl
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem inter_empty_left {T : Type} (A : set T) : ∅ ∩ A ∼ ∅ :=
|
|
|
|
|
take x, band_ff_left (A x) ▸ iff_rfl
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem inter_comm {T : Type} (A B : set T) : A ∩ B ∼ B ∩ A :=
|
|
|
|
|
take x, band_comm (A x) (B x) ▸ iff_rfl
|
|
|
|
|
|
|
|
|
|
theorem inter_assoc {T : Type} (A B C : set T) : (A ∩ B) ∩ C ∼ A ∩ (B ∩ C) :=
|
|
|
|
|
take x, band_assoc (A x) (B x) (C x) ▸ iff_rfl
|
|
|
|
|
|
|
|
|
|
definition union {T : Type} (A B : set T) : set T :=
|
|
|
|
|
λx, A x || B x
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infixl `∪` := union
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem mem_union {T : Type} (x : T) (A B : set T) : x ∈ A ∪ B ↔ (x ∈ A ∨ x ∈ B) :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
|
|
|
|
(assume H, bor_to_or H)
|
|
|
|
|
(assume H, or_elim H
|
|
|
|
|
(assume Ha : A x = tt,
|
|
|
|
|
show A x || B x = tt, from Ha⁻¹ ▸ bor_tt_left (B x))
|
|
|
|
|
(assume Hb : B x = tt,
|
|
|
|
|
show A x || B x = tt, from Hb⁻¹ ▸ bor_tt_right (A x)))
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem union_id {T : Type} (A : set T) : A ∪ A ∼ A :=
|
|
|
|
|
take x, bor_id (A x) ▸ iff_rfl
|
|
|
|
|
|
|
|
|
|
theorem union_empty_right {T : Type} (A : set T) : A ∪ ∅ ∼ A :=
|
|
|
|
|
take x, bor_ff_right (A x) ▸ iff_rfl
|
|
|
|
|
|
|
|
|
|
theorem union_empty_left {T : Type} (A : set T) : ∅ ∪ A ∼ A :=
|
|
|
|
|
take x, bor_ff_left (A x) ▸ iff_rfl
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem union_comm {T : Type} (A B : set T) : A ∪ B ∼ B ∪ A :=
|
|
|
|
|
take x, bor_comm (A x) (B x) ▸ iff_rfl
|
2014-07-27 20:18:33 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem union_assoc {T : Type} (A B C : set T) : (A ∪ B) ∪ C ∼ A ∪ (B ∪ C) :=
|
|
|
|
|
take x, bor_assoc (A x) (B x) (C x) ▸ iff_rfl
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2014-08-07 23:59:08 +00:00
|
|
|
|
end set
|