2014-12-01 04:34:12 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
2014-12-15 21:13:04 +00:00
|
|
|
|
|
|
|
Module: logic.eq
|
2014-12-01 04:34:12 +00:00
|
|
|
Authors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
Additional declarations/theorems about equality. See also init.datatypes and init.logic.
|
2014-12-01 04:34:12 +00:00
|
|
|
-/
|
2014-08-22 23:36:47 +00:00
|
|
|
|
2014-10-02 00:51:17 +00:00
|
|
|
open eq.ops
|
2014-08-27 00:30:27 +00:00
|
|
|
|
2014-09-04 23:36:06 +00:00
|
|
|
namespace eq
|
2014-11-04 00:22:30 +00:00
|
|
|
variables {A B : Type} {a a' a₁ a₂ a₃ a₄ : A}
|
2014-12-12 21:20:27 +00:00
|
|
|
|
|
|
|
theorem irrel (H₁ H₂ : a = a') : H₁ = H₂ :=
|
|
|
|
!proof_irrel
|
|
|
|
|
|
|
|
theorem id_refl (H₁ : a = a) : H₁ = (eq.refl a) :=
|
|
|
|
rfl
|
|
|
|
|
2015-02-11 20:49:27 +00:00
|
|
|
theorem rec_on_id {B : A → Type} (H : a = a) (b : B a) : eq.rec_on H b = b :=
|
2014-10-10 21:52:21 +00:00
|
|
|
rfl
|
2014-09-10 02:15:11 +00:00
|
|
|
|
2015-02-11 20:49:27 +00:00
|
|
|
theorem rec_on_constant (H : a = a') {B : Type} (b : B) : eq.rec_on H b = b :=
|
2015-05-09 16:49:41 +00:00
|
|
|
eq.drec_on H rfl
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2015-02-11 20:49:27 +00:00
|
|
|
theorem rec_on_constant2 (H₁ : a₁ = a₂) (H₂ : a₃ = a₄) (b : B) : eq.rec_on H₁ b = eq.rec_on H₂ b :=
|
2015-01-26 16:28:13 +00:00
|
|
|
rec_on_constant H₁ b ⬝ (rec_on_constant H₂ b)⁻¹
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
theorem rec_on_irrel_arg {f : A → B} {D : B → Type} (H : a = a') (H' : f a = f a') (b : D (f a)) :
|
2015-02-11 20:49:27 +00:00
|
|
|
eq.rec_on H b = eq.rec_on H' b :=
|
2015-05-09 16:49:41 +00:00
|
|
|
eq.drec_on H (λ(H' : f a = f a), !rec_on_id⁻¹) H'
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem rec_on_irrel {a a' : A} {D : A → Type} (H H' : a = a') (b : D a) :
|
2015-05-09 16:49:41 +00:00
|
|
|
eq.drec_on H b = eq.drec_on H' b :=
|
2015-01-14 01:12:21 +00:00
|
|
|
proof_irrel H H' ▸ rfl
|
2014-11-04 00:22:30 +00:00
|
|
|
|
|
|
|
theorem rec_on_compose {a b c : A} {P : A → Type} (H₁ : a = b) (H₂ : b = c)
|
2015-02-11 20:49:27 +00:00
|
|
|
(u : P a) : eq.rec_on H₂ (eq.rec_on H₁ u) = eq.rec_on (trans H₁ H₂) u :=
|
|
|
|
(show ∀ H₂ : b = c, eq.rec_on H₂ (eq.rec_on H₁ u) = eq.rec_on (trans H₁ H₂) u,
|
2015-05-09 16:49:41 +00:00
|
|
|
from eq.drec_on H₂ (take (H₂ : b = b), rec_on_id H₂ _))
|
2014-10-05 17:19:50 +00:00
|
|
|
H₂
|
2014-09-04 23:36:06 +00:00
|
|
|
end eq
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-09-26 23:36:04 +00:00
|
|
|
open eq
|
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
section
|
|
|
|
variables {A B C D E F : Type}
|
2014-11-04 00:22:30 +00:00
|
|
|
variables {a a' : A} {b b' : B} {c c' : C} {d d' : D} {e e' : E}
|
2014-10-05 17:19:50 +00:00
|
|
|
|
|
|
|
theorem congr_fun {B : A → Type} {f g : Π x, B x} (H : f = g) (a : A) : f a = g a :=
|
|
|
|
H ▸ rfl
|
|
|
|
|
|
|
|
theorem congr_arg (f : A → B) (H : a = a') : f a = f a' :=
|
|
|
|
H ▸ rfl
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem congr_arg2 (f : A → B → C) (Ha : a = a') (Hb : b = b') : f a b = f a' b' :=
|
|
|
|
congr (congr_arg f Ha) Hb
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem congr_arg3 (f : A → B → C → D) (Ha : a = a') (Hb : b = b') (Hc : c = c')
|
2014-11-04 00:22:30 +00:00
|
|
|
: f a b c = f a' b' c' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
congr (congr_arg2 f Ha Hb) Hc
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
theorem congr_arg4 (f : A → B → C → D → E) (Ha : a = a') (Hb : b = b') (Hc : c = c') (Hd : d = d')
|
|
|
|
: f a b c d = f a' b' c' d' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
congr (congr_arg3 f Ha Hb Hc) Hd
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem congr_arg5 (f : A → B → C → D → E → F)
|
|
|
|
(Ha : a = a') (Hb : b = b') (Hc : c = c') (Hd : d = d') (He : e = e')
|
2014-11-04 00:22:30 +00:00
|
|
|
: f a b c d e = f a' b' c' d' e' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
congr (congr_arg4 f Ha Hb Hc Hd) He
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem congr2 (f f' : A → B → C) (Hf : f = f') (Ha : a = a') (Hb : b = b') : f a b = f' a' b' :=
|
|
|
|
Hf ▸ congr_arg2 f Ha Hb
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem congr3 (f f' : A → B → C → D) (Hf : f = f') (Ha : a = a') (Hb : b = b') (Hc : c = c')
|
2014-11-04 00:22:30 +00:00
|
|
|
: f a b c = f' a' b' c' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
Hf ▸ congr_arg3 f Ha Hb Hc
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem congr4 (f f' : A → B → C → D → E)
|
2014-11-04 00:22:30 +00:00
|
|
|
(Hf : f = f') (Ha : a = a') (Hb : b = b') (Hc : c = c') (Hd : d = d')
|
|
|
|
: f a b c d = f' a' b' c' d' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
Hf ▸ congr_arg4 f Ha Hb Hc Hd
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-12-01 04:34:12 +00:00
|
|
|
theorem congr5 (f f' : A → B → C → D → E → F)
|
2014-11-04 00:22:30 +00:00
|
|
|
(Hf : f = f') (Ha : a = a') (Hb : b = b') (Hc : c = c') (Hd : d = d') (He : e = e')
|
|
|
|
: f a b c d e = f' a' b' c' d' e' :=
|
2014-10-05 17:19:50 +00:00
|
|
|
Hf ▸ congr_arg5 f Ha Hb Hc Hd He
|
|
|
|
end
|
2014-09-26 23:36:04 +00:00
|
|
|
|
2014-08-01 00:48:51 +00:00
|
|
|
theorem equal_f {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) : ∀x, f x = g x :=
|
2014-08-20 02:32:44 +00:00
|
|
|
take x, congr_fun H x
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
section
|
|
|
|
variables {a b c : Prop}
|
|
|
|
|
|
|
|
theorem eqmp (H₁ : a = b) (H₂ : a) : b :=
|
|
|
|
H₁ ▸ H₂
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem eqmpr (H₁ : a = b) (H₂ : b) : a :=
|
|
|
|
H₁⁻¹ ▸ H₂
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem imp_trans (H₁ : a → b) (H₂ : b → c) : a → c :=
|
|
|
|
assume Ha, H₂ (H₁ Ha)
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem imp_eq_trans (H₁ : a → b) (H₂ : b = c) : a → c :=
|
|
|
|
assume Ha, H₂ ▸ (H₁ Ha)
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem eq_imp_trans (H₁ : a = b) (H₂ : b → c) : a → c :=
|
|
|
|
assume Ha, H₂ (H₁ ▸ Ha)
|
|
|
|
end
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
section
|
|
|
|
variables {p : Prop}
|
|
|
|
|
|
|
|
theorem p_ne_false : p → p ≠ false :=
|
|
|
|
assume (Hp : p) (Heq : p = false), Heq ▸ Hp
|
2014-08-04 05:58:12 +00:00
|
|
|
|
2014-10-05 17:19:50 +00:00
|
|
|
theorem p_ne_true : ¬p → p ≠ true :=
|
|
|
|
assume (Hnp : ¬p) (Heq : p = true), absurd trivial (Heq ▸ Hnp)
|
|
|
|
end
|
2014-09-05 01:41:06 +00:00
|
|
|
|
|
|
|
theorem true_ne_false : ¬true = false :=
|
|
|
|
assume H : true = false,
|
|
|
|
H ▸ trivial
|