2014-06-30 18:44:47 +00:00
|
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
2014-07-19 08:29:04 +00:00
|
|
|
|
-- Authors: Leonardo de Moura, Jeremy Avigad
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
2014-08-28 00:46:07 +00:00
|
|
|
|
import general_notation .eq
|
2014-08-20 02:32:44 +00:00
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
-- and
|
|
|
|
|
-- ---
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
inductive and (a b : Prop) : Prop :=
|
2014-08-22 22:46:10 +00:00
|
|
|
|
and_intro : a → b → and a b
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infixr `/\` := and
|
|
|
|
|
infixr `∧` := and
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
theorem and_elim {a b c : Prop} (H1 : a ∧ b) (H2 : a → b → c) : c :=
|
|
|
|
|
and_rec H2 H1
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_elim_left {a b : Prop} (H : a ∧ b) : a :=
|
|
|
|
|
and_rec (λa b, a) H
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_elim_right {a b : Prop} (H : a ∧ b) : b :=
|
|
|
|
|
and_rec (λa b, b) H
|
2014-07-19 08:29:04 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_swap {a b : Prop} (H : a ∧ b) : b ∧ a :=
|
|
|
|
|
and_intro (and_elim_right H) (and_elim_left H)
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_not_left {a : Prop} (b : Prop) (Hna : ¬a) : ¬(a ∧ b) :=
|
|
|
|
|
assume H : a ∧ b, absurd (and_elim_left H) Hna
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_not_right (a : Prop) {b : Prop} (Hnb : ¬b) : ¬(a ∧ b) :=
|
|
|
|
|
assume H : a ∧ b, absurd (and_elim_right H) Hnb
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
theorem and_imp_and {a b c d : Prop} (H1 : a ∧ b) (H2 : a → c) (H3 : b → d) : c ∧ d :=
|
|
|
|
|
and_elim H1 (assume Ha : a, assume Hb : b, and_intro (H2 Ha) (H3 Hb))
|
|
|
|
|
|
|
|
|
|
theorem imp_and_left {a b c : Prop} (H1 : a ∧ c) (H : a → b) : b ∧ c :=
|
|
|
|
|
and_elim H1 (assume Ha : a, assume Hc : c, and_intro (H Ha) Hc)
|
|
|
|
|
|
|
|
|
|
theorem imp_and_right {a b c : Prop} (H1 : c ∧ a) (H : a → b) : c ∧ b :=
|
|
|
|
|
and_elim H1 (assume Hc : c, assume Ha : a, and_intro Hc (H Ha))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- or
|
|
|
|
|
-- --
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
inductive or (a b : Prop) : Prop :=
|
2014-08-22 22:46:10 +00:00
|
|
|
|
or_intro_left : a → or a b,
|
|
|
|
|
or_intro_right : b → or a b
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infixr `\/` := or
|
|
|
|
|
infixr `∨` := or
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-28 00:25:57 +00:00
|
|
|
|
theorem or_inl {a b : Prop} (Ha : a) : a ∨ b := or_intro_left b Ha
|
|
|
|
|
theorem or_inr {a b : Prop} (Hb : b) : a ∨ b := or_intro_right a Hb
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem or_elim {a b c : Prop} (H1 : a ∨ b) (H2 : a → c) (H3 : b → c) : c :=
|
|
|
|
|
or_rec H2 H3 H1
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem resolve_right {a b : Prop} (H1 : a ∨ b) (H2 : ¬a) : b :=
|
2014-08-28 01:34:09 +00:00
|
|
|
|
or_elim H1 (assume Ha, absurd Ha H2) (assume Hb, Hb)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem resolve_left {a b : Prop} (H1 : a ∨ b) (H2 : ¬b) : a :=
|
2014-08-28 01:34:09 +00:00
|
|
|
|
or_elim H1 (assume Ha, Ha) (assume Hb, absurd Hb H2)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem or_swap {a b : Prop} (H : a ∨ b) : b ∨ a :=
|
|
|
|
|
or_elim H (assume Ha, or_inr Ha) (assume Hb, or_inl Hb)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem or_not_intro {a b : Prop} (Hna : ¬a) (Hnb : ¬b) : ¬(a ∨ b) :=
|
|
|
|
|
assume H : a ∨ b, or_elim H
|
2014-08-28 01:34:09 +00:00
|
|
|
|
(assume Ha, absurd Ha Hna)
|
|
|
|
|
(assume Hb, absurd Hb Hnb)
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem or_imp_or {a b c d : Prop} (H1 : a ∨ b) (H2 : a → c) (H3 : b → d) : c ∨ d :=
|
|
|
|
|
or_elim H1
|
|
|
|
|
(assume Ha : a, or_inl (H2 Ha))
|
|
|
|
|
(assume Hb : b, or_inr (H3 Hb))
|
2014-07-24 19:29:23 +00:00
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
|
theorem or_imp_or_left {a b c : Prop} (H1 : a ∨ c) (H : a → b) : b ∨ c :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
or_elim H1
|
|
|
|
|
(assume H2 : a, or_inl (H H2))
|
|
|
|
|
(assume H2 : c, or_inr H2)
|
2014-07-24 19:29:23 +00:00
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
|
theorem or_imp_or_right {a b c : Prop} (H1 : c ∨ a) (H : a → b) : c ∨ b :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
or_elim H1
|
|
|
|
|
(assume H2 : c, or_inl H2)
|
|
|
|
|
(assume H2 : a, or_inr (H H2))
|
2014-07-24 19:29:23 +00:00
|
|
|
|
|
2014-08-27 00:30:59 +00:00
|
|
|
|
theorem not_not_em {p : Prop} : ¬¬(p ∨ ¬p) :=
|
|
|
|
|
assume not_em : ¬(p ∨ ¬p),
|
|
|
|
|
have Hnp : ¬p, from
|
|
|
|
|
assume Hp : p, absurd (or_inl Hp) not_em,
|
|
|
|
|
absurd (or_inr Hnp) not_em
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- iff
|
|
|
|
|
-- ---
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
definition iff (a b : Prop) := (a → b) ∧ (b → a)
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infix `<->` := iff
|
|
|
|
|
infix `↔` := iff
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-08-28 00:46:07 +00:00
|
|
|
|
theorem iff_def {a b : Prop} : (a ↔ b) = ((a → b) ∧ (b → a)) := rfl
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_intro {a b : Prop} (H1 : a → b) (H2 : b → a) : a ↔ b := and_intro H1 H2
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_elim {a b c : Prop} (H1 : (a → b) → (b → a) → c) (H2 : a ↔ b) : c := and_rec H1 H2
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-08-22 01:39:38 +00:00
|
|
|
|
theorem iff_elim_left {a b : Prop} (H : a ↔ b) : a → b :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_elim (assume H1 H2, H1) H
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-08-22 01:39:38 +00:00
|
|
|
|
abbreviation iff_mp := @iff_elim_left
|
2014-08-20 22:49:44 +00:00
|
|
|
|
|
2014-08-22 01:39:38 +00:00
|
|
|
|
theorem iff_elim_right {a b : Prop} (H : a ↔ b) : b → a :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_elim (assume H1 H2, H2) H
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_flip_sign {a b : Prop} (H1 : a ↔ b) : ¬a ↔ ¬b :=
|
|
|
|
|
iff_intro
|
|
|
|
|
(assume Hna, mt (iff_elim_right H1) Hna)
|
|
|
|
|
(assume Hnb, mt (iff_elim_left H1) Hnb)
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_refl (a : Prop) : a ↔ a :=
|
|
|
|
|
iff_intro (assume H, H) (assume H, H)
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-08-26 05:54:44 +00:00
|
|
|
|
theorem iff_rfl {a : Prop} : a ↔ a :=
|
|
|
|
|
iff_refl a
|
|
|
|
|
|
2014-08-22 01:39:38 +00:00
|
|
|
|
theorem iff_trans {a b c : Prop} (H1 : a ↔ b) (H2 : b ↔ c) : a ↔ c :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
2014-07-31 21:05:33 +00:00
|
|
|
|
(assume Ha, iff_elim_left H2 (iff_elim_left H1 Ha))
|
|
|
|
|
(assume Hc, iff_elim_right H1 (iff_elim_right H2 Hc))
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-08-22 01:39:38 +00:00
|
|
|
|
theorem iff_symm {a b : Prop} (H : a ↔ b) : b ↔ a :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
2014-07-31 21:05:33 +00:00
|
|
|
|
(assume Hb, iff_elim_right H Hb)
|
|
|
|
|
(assume Ha, iff_elim_left H Ha)
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-08-22 20:23:45 +00:00
|
|
|
|
calc_refl iff_refl
|
2014-07-21 04:10:30 +00:00
|
|
|
|
calc_trans iff_trans
|
|
|
|
|
|
2014-08-30 03:45:57 +00:00
|
|
|
|
theorem iff_true_elim {a : Prop} (H : a ↔ true) : a :=
|
|
|
|
|
iff_mp (iff_symm H) trivial
|
|
|
|
|
|
|
|
|
|
theorem iff_false_elim {a : Prop} (H : a ↔ false) : ¬a :=
|
|
|
|
|
assume Ha : a, iff_mp H Ha
|
|
|
|
|
|
2014-08-28 00:46:07 +00:00
|
|
|
|
theorem eq_to_iff {a b : Prop} (H : a = b) : a ↔ b :=
|
|
|
|
|
iff_intro (λ Ha, subst H Ha) (λ Hb, subst (symm H) Hb)
|
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- comm and assoc for and / or
|
|
|
|
|
-- ---------------------------
|
|
|
|
|
|
2014-08-28 18:10:04 +00:00
|
|
|
|
theorem and_comm {a b : Prop} : a ∧ b ↔ b ∧ a :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro (λH, and_swap H) (λH, and_swap H)
|
|
|
|
|
|
2014-08-28 18:10:04 +00:00
|
|
|
|
theorem and_assoc {a b c : Prop} : (a ∧ b) ∧ c ↔ a ∧ (b ∧ c) :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
|
|
|
|
(assume H, and_intro
|
|
|
|
|
(and_elim_left (and_elim_left H))
|
|
|
|
|
(and_intro (and_elim_right (and_elim_left H)) (and_elim_right H)))
|
|
|
|
|
(assume H, and_intro
|
|
|
|
|
(and_intro (and_elim_left H) (and_elim_left (and_elim_right H)))
|
|
|
|
|
(and_elim_right (and_elim_right H)))
|
|
|
|
|
|
2014-08-28 18:10:04 +00:00
|
|
|
|
theorem or_comm {a b : Prop} : a ∨ b ↔ b ∨ a :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro (λH, or_swap H) (λH, or_swap H)
|
|
|
|
|
|
2014-08-28 18:10:04 +00:00
|
|
|
|
theorem or_assoc {a b c : Prop} : (a ∨ b) ∨ c ↔ a ∨ (b ∨ c) :=
|
2014-07-29 02:58:57 +00:00
|
|
|
|
iff_intro
|
|
|
|
|
(assume H, or_elim H
|
|
|
|
|
(assume H1, or_elim H1
|
|
|
|
|
(assume Ha, or_inl Ha)
|
|
|
|
|
(assume Hb, or_inr (or_inl Hb)))
|
|
|
|
|
(assume Hc, or_inr (or_inr Hc)))
|
|
|
|
|
(assume H, or_elim H
|
|
|
|
|
(assume Ha, (or_inl (or_inl Ha)))
|
|
|
|
|
(assume H1, or_elim H1
|
|
|
|
|
(assume Hb, or_inl (or_inr Hb))
|
|
|
|
|
(assume Hc, or_inr Hc)))
|