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-09-05 04:25:21 +00:00
|
|
|
|
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-09-05 00:44:53 +00:00
|
|
|
|
namespace and
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem elim {a b c : Prop} (H₁ : a ∧ b) (H₂ : a → b → c) : c :=
|
|
|
|
|
rec H₂ H₁
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem elim_left {a b : Prop} (H : a ∧ b) : a :=
|
|
|
|
|
rec (λa b, a) H
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem elim_right {a b : Prop} (H : a ∧ b) : b :=
|
|
|
|
|
rec (λa b, b) H
|
2014-07-19 08:29:04 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem swap {a b : Prop} (H : a ∧ b) : b ∧ a :=
|
|
|
|
|
intro (elim_right H) (elim_left H)
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem not_left {a : Prop} (b : Prop) (Hna : ¬a) : ¬(a ∧ b) :=
|
|
|
|
|
assume H : a ∧ b, absurd (elim_left H) Hna
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem not_right (a : Prop) {b : Prop} (Hnb : ¬b) : ¬(a ∧ b) :=
|
|
|
|
|
assume H : a ∧ b, absurd (elim_right H) Hnb
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_and {a b c d : Prop} (H₁ : a ∧ b) (H₂ : a → c) (H₃ : b → d) : c ∧ d :=
|
|
|
|
|
elim H₁ (assume Ha : a, assume Hb : b, intro (H₂ Ha) (H₃ Hb))
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_left {a b c : Prop} (H₁ : a ∧ c) (H : a → b) : b ∧ c :=
|
|
|
|
|
elim H₁ (assume Ha : a, assume Hc : c, intro (H Ha) Hc)
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_right {a b c : Prop} (H₁ : c ∧ a) (H : a → b) : c ∧ b :=
|
|
|
|
|
elim H₁ (assume Hc : c, assume Ha : a, intro Hc (H Ha))
|
2014-09-05 00:44:53 +00:00
|
|
|
|
end and
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- or
|
|
|
|
|
-- --
|
2014-07-22 16:43:18 +00:00
|
|
|
|
inductive or (a b : Prop) : Prop :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
intro_left : a → or a b,
|
|
|
|
|
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-09-05 04:25:21 +00:00
|
|
|
|
namespace or
|
|
|
|
|
theorem inl {a b : Prop} (Ha : a) : a ∨ b :=
|
|
|
|
|
intro_left b Ha
|
|
|
|
|
|
|
|
|
|
theorem inr {a b : Prop} (Hb : b) : a ∨ b :=
|
|
|
|
|
intro_right a Hb
|
2014-07-28 00:25:57 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem elim {a b c : Prop} (H₁ : a ∨ b) (H₂ : a → c) (H₃ : b → c) : c :=
|
|
|
|
|
rec H₂ H₃ H₁
|
2014-06-28 07:29:42 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem elim3 {a b c d : Prop} (H : a ∨ b ∨ c) (Ha : a → d) (Hb : b → d) (Hc : c → d) : d :=
|
2014-09-05 05:43:30 +00:00
|
|
|
|
elim H Ha (assume H₂, elim H₂ Hb Hc)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem resolve_right {a b : Prop} (H₁ : a ∨ b) (H₂ : ¬a) : b :=
|
|
|
|
|
elim H₁ (assume Ha, absurd Ha H₂) (assume Hb, Hb)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem resolve_left {a b : Prop} (H₁ : a ∨ b) (H₂ : ¬b) : a :=
|
|
|
|
|
elim H₁ (assume Ha, Ha) (assume Hb, absurd Hb H₂)
|
2014-07-01 01:01:31 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem swap {a b : Prop} (H : a ∨ b) : b ∨ a :=
|
|
|
|
|
elim H (assume Ha, inr Ha) (assume Hb, inl Hb)
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem not_intro {a b : Prop} (Hna : ¬a) (Hnb : ¬b) : ¬(a ∨ b) :=
|
|
|
|
|
assume H : a ∨ b, elim H
|
|
|
|
|
(assume Ha, absurd Ha Hna)
|
|
|
|
|
(assume Hb, absurd Hb Hnb)
|
2014-07-24 19:29:23 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_or {a b c d : Prop} (H₁ : a ∨ b) (H₂ : a → c) (H₃ : b → d) : c ∨ d :=
|
|
|
|
|
elim H₁
|
|
|
|
|
(assume Ha : a, inl (H₂ Ha))
|
|
|
|
|
(assume Hb : b, inr (H₃ Hb))
|
2014-07-24 19:29:23 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_or_left {a b c : Prop} (H₁ : a ∨ c) (H : a → b) : b ∨ c :=
|
|
|
|
|
elim H₁
|
|
|
|
|
(assume H₂ : a, inl (H H₂))
|
|
|
|
|
(assume H₂ : c, inr H₂)
|
2014-09-05 04:25:21 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem imp_or_right {a b c : Prop} (H₁ : c ∨ a) (H : a → b) : c ∨ b :=
|
|
|
|
|
elim H₁
|
|
|
|
|
(assume H₂ : c, inl H₂)
|
|
|
|
|
(assume H₂ : a, inr (H H₂))
|
2014-09-05 04:25:21 +00:00
|
|
|
|
end or
|
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
|
2014-09-05 04:25:21 +00:00
|
|
|
|
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-09-05 04:25:21 +00:00
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
|
infix `<->` := iff
|
|
|
|
|
infix `↔` := iff
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
namespace iff
|
|
|
|
|
theorem def {a b : Prop} : (a ↔ b) = ((a → b) ∧ (b → a)) :=
|
|
|
|
|
rfl
|
2014-08-28 00:46:07 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem intro {a b : Prop} (H₁ : a → b) (H₂ : b → a) : a ↔ b :=
|
|
|
|
|
and.intro H₁ H₂
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem elim {a b c : Prop} (H₁ : (a → b) → (b → a) → c) (H₂ : a ↔ b) : c :=
|
|
|
|
|
and.rec H₁ H₂
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem elim_left {a b : Prop} (H : a ↔ b) : a → b :=
|
2014-09-05 05:43:30 +00:00
|
|
|
|
elim (assume H₁ H₂, H₁) H
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
abbreviation mp := @elim_left
|
2014-08-20 22:49:44 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem elim_right {a b : Prop} (H : a ↔ b) : b → a :=
|
2014-09-05 05:43:30 +00:00
|
|
|
|
elim (assume H₁ H₂, H₂) H
|
2014-06-30 05:56:38 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem flip_sign {a b : Prop} (H₁ : a ↔ b) : ¬a ↔ ¬b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
intro
|
2014-09-05 05:43:30 +00:00
|
|
|
|
(assume Hna, mt (elim_right H₁) Hna)
|
|
|
|
|
(assume Hnb, mt (elim_left H₁) Hnb)
|
2014-07-19 19:09:47 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem refl (a : Prop) : a ↔ a :=
|
|
|
|
|
intro (assume H, H) (assume H, H)
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem rfl {a : Prop} : a ↔ a :=
|
|
|
|
|
refl a
|
2014-08-26 05:54:44 +00:00
|
|
|
|
|
2014-09-05 05:43:30 +00:00
|
|
|
|
theorem trans {a b c : Prop} (H₁ : a ↔ b) (H₂ : b ↔ c) : a ↔ c :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
intro
|
2014-09-05 05:43:30 +00:00
|
|
|
|
(assume Ha, elim_left H₂ (elim_left H₁ Ha))
|
|
|
|
|
(assume Hc, elim_right H₁ (elim_right H₂ Hc))
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem symm {a b : Prop} (H : a ↔ b) : b ↔ a :=
|
|
|
|
|
intro
|
|
|
|
|
(assume Hb, elim_right H Hb)
|
|
|
|
|
(assume Ha, elim_left H Ha)
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem true_elim {a : Prop} (H : a ↔ true) : a :=
|
|
|
|
|
mp (symm H) trivial
|
2014-07-21 04:10:30 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
theorem false_elim {a : Prop} (H : a ↔ false) : ¬a :=
|
|
|
|
|
assume Ha : a, mp H Ha
|
|
|
|
|
end iff
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
calc_refl iff.refl
|
|
|
|
|
calc_trans iff.trans
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-09-05 01:41:06 +00:00
|
|
|
|
open eq_ops
|
2014-08-28 00:46:07 +00:00
|
|
|
|
|
2014-09-05 01:41:06 +00:00
|
|
|
|
theorem eq_to_iff {a b : Prop} (H : a = b) : a ↔ b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro (λ Ha, H ▸ Ha) (λ Hb, H⁻¹ ▸ Hb)
|
2014-07-31 21:05:33 +00:00
|
|
|
|
|
|
|
|
|
-- comm and assoc for and / or
|
|
|
|
|
-- ---------------------------
|
|
|
|
|
|
2014-09-05 04:25:21 +00:00
|
|
|
|
namespace and
|
|
|
|
|
theorem comm {a b : Prop} : a ∧ b ↔ b ∧ a :=
|
|
|
|
|
iff.intro (λH, swap H) (λH, swap H)
|
|
|
|
|
|
|
|
|
|
theorem assoc {a b c : Prop} : (a ∧ b) ∧ c ↔ a ∧ (b ∧ c) :=
|
|
|
|
|
iff.intro
|
|
|
|
|
(assume H, intro
|
|
|
|
|
(elim_left (elim_left H))
|
|
|
|
|
(intro (elim_right (elim_left H)) (elim_right H)))
|
|
|
|
|
(assume H, intro
|
|
|
|
|
(intro (elim_left H) (elim_left (elim_right H)))
|
|
|
|
|
(elim_right (elim_right H)))
|
|
|
|
|
end and
|
|
|
|
|
|
|
|
|
|
namespace or
|
|
|
|
|
theorem comm {a b : Prop} : a ∨ b ↔ b ∨ a :=
|
|
|
|
|
iff.intro (λH, swap H) (λH, swap H)
|
|
|
|
|
|
|
|
|
|
theorem assoc {a b c : Prop} : (a ∨ b) ∨ c ↔ a ∨ (b ∨ c) :=
|
|
|
|
|
iff.intro
|
|
|
|
|
(assume H, elim H
|
2014-09-05 05:43:30 +00:00
|
|
|
|
(assume H₁, elim H₁
|
2014-09-05 04:25:21 +00:00
|
|
|
|
(assume Ha, inl Ha)
|
|
|
|
|
(assume Hb, inr (inl Hb)))
|
|
|
|
|
(assume Hc, inr (inr Hc)))
|
|
|
|
|
(assume H, elim H
|
|
|
|
|
(assume Ha, (inl (inl Ha)))
|
2014-09-05 05:43:30 +00:00
|
|
|
|
(assume H₁, elim H₁
|
2014-09-05 04:25:21 +00:00
|
|
|
|
(assume Hb, inl (inr Hb))
|
|
|
|
|
(assume Hc, inr Hc)))
|
|
|
|
|
end or
|