2014-08-01 00:48:51 +00:00
|
|
|
|
----------------------------------------------------------------------------------------------------
|
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-08-01 00:48:51 +00:00
|
|
|
|
----------------------------------------------------------------------------------------------------
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
2014-08-12 00:35:25 +00:00
|
|
|
|
import general_notation .prop
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
|
|
-- implication
|
|
|
|
|
-- -----------
|
2014-06-16 22:50:27 +00:00
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
abbreviation imp (a b : Prop) : Prop := a → b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- true and false
|
|
|
|
|
-- --------------
|
|
|
|
|
|
2014-07-25 18:24:01 +00:00
|
|
|
|
inductive false : Prop
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem false_elim (c : Prop) (H : false) : c :=
|
|
|
|
|
false_rec c H
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
inductive true : Prop :=
|
2014-06-28 07:29:42 +00:00
|
|
|
|
| trivial : true
|
|
|
|
|
|
2014-07-25 05:14:15 +00:00
|
|
|
|
abbreviation not (a : Prop) := a → false
|
2014-07-04 04:37:56 +00:00
|
|
|
|
prefix `¬`:40 := not
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- not
|
|
|
|
|
-- ---
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_intro {a : Prop} (H : a → false) : ¬a := H
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_elim {a : Prop} (H1 : ¬a) (H2 : a) : false := H1 H2
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem absurd {a : Prop} (H1 : a) (H2 : ¬a) : false := H2 H1
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_not_intro {a : Prop} (Ha : a) : ¬¬a :=
|
|
|
|
|
assume Hna : ¬a, absurd Ha Hna
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem mt {a b : Prop} (H1 : a → b) (H2 : ¬b) : ¬a :=
|
|
|
|
|
assume Ha : a, absurd (H1 Ha) H2
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem absurd_elim {a : Prop} (b : Prop) (H1 : a) (H2 : ¬a) : b :=
|
|
|
|
|
false_elim b (absurd H1 H2)
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem absurd_not_true (H : ¬true) : false :=
|
|
|
|
|
absurd trivial H
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_false_trivial : ¬false :=
|
|
|
|
|
assume H : false, H
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_implies_left {a b : Prop} (H : ¬(a → b)) : ¬¬a :=
|
|
|
|
|
assume Hna : ¬a, absurd (assume Ha : a, absurd_elim b Ha Hna) H
|
2014-07-13 02:05:17 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem not_implies_right {a b : Prop} (H : ¬(a → b)) : ¬b :=
|
|
|
|
|
assume Hb : b, absurd (assume Ha : a, Hb) H
|
2014-07-13 02:05:17 +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-06-28 07:29:42 +00:00
|
|
|
|
| and_intro : a → b → and a b
|
|
|
|
|
|
2014-07-01 23:55:41 +00:00
|
|
|
|
infixr `/\`:35 := and
|
|
|
|
|
infixr `∧`:35 := 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-06-28 07:29:42 +00:00
|
|
|
|
| or_intro_left : a → or a b
|
|
|
|
|
| or_intro_right : b → or a b
|
|
|
|
|
|
2014-07-01 23:55:41 +00:00
|
|
|
|
infixr `\/`:30 := or
|
|
|
|
|
infixr `∨`:30 := 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 :=
|
|
|
|
|
or_elim H1 (assume Ha, absurd_elim b 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 :=
|
|
|
|
|
or_elim H1 (assume Ha, Ha) (assume Hb, absurd_elim a 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
|
|
|
|
|
(assume Ha, absurd_elim _ Ha Hna)
|
|
|
|
|
(assume Hb, absurd_elim _ 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-07-29 02:58:57 +00:00
|
|
|
|
theorem imp_or_left {a b c : Prop} (H1 : a ∨ c) (H : a → b) : b ∨ c :=
|
|
|
|
|
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-07-29 02:58:57 +00:00
|
|
|
|
theorem imp_or_right {a b c : Prop} (H1 : c ∨ a) (H : a → b) : c ∨ b :=
|
|
|
|
|
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-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-07-28 15:48:26 +00:00
|
|
|
|
infix `<->`:25 := iff
|
2014-07-19 08:29:04 +00:00
|
|
|
|
infix `↔`:25 := iff
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
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-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_elim_left {a b : Prop} (H : a ↔ b) : a → b :=
|
|
|
|
|
iff_elim (assume H1 H2, H1) H
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_elim_right {a b : Prop} (H : a ↔ b) : b → a :=
|
|
|
|
|
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-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_trans {a b c : Prop} (H1 : a ↔ b) (H2 : b ↔ c) : a ↔ c :=
|
|
|
|
|
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-07-29 02:58:57 +00:00
|
|
|
|
theorem iff_symm {a b : Prop} (H : a ↔ b) : b ↔ a :=
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
calc_trans iff_trans
|
|
|
|
|
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- comm and assoc for and / or
|
|
|
|
|
-- ---------------------------
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem and_comm (a b : Prop) : a ∧ b ↔ b ∧ a :=
|
|
|
|
|
iff_intro (λH, and_swap H) (λH, and_swap H)
|
|
|
|
|
|
|
|
|
|
theorem and_assoc (a b c : Prop) : (a ∧ b) ∧ c ↔ a ∧ (b ∧ c) :=
|
|
|
|
|
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)))
|
|
|
|
|
|
|
|
|
|
theorem or_comm (a b : Prop) : a ∨ b ↔ b ∨ a :=
|
|
|
|
|
iff_intro (λH, or_swap H) (λH, or_swap H)
|
|
|
|
|
|
|
|
|
|
theorem or_assoc (a b c : Prop) : (a ∨ b) ∨ c ↔ a ∨ (b ∨ c) :=
|
|
|
|
|
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)))
|