2014-08-01 00:48:51 +00:00
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
-- Authors: Leonardo de Moura, Jeremy Avigad
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
|
|
-- logic.connectives.eq
|
|
|
|
-- ====================
|
|
|
|
|
|
|
|
-- Equality.
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-28 00:46:07 +00:00
|
|
|
import .prop
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
-- eq
|
|
|
|
-- --
|
|
|
|
|
|
|
|
inductive eq {A : Type} (a : A) : A → Prop :=
|
2014-08-22 22:46:10 +00:00
|
|
|
refl : eq a a
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
infix `=` := eq
|
|
|
|
notation `rfl` := refl _
|
2014-08-17 21:41:23 +00:00
|
|
|
|
|
|
|
theorem eq_id_refl {A : Type} {a : A} (H1 : a = a) : H1 = (refl a) := rfl
|
|
|
|
|
|
|
|
theorem eq_irrel {A : Type} {a b : A} (H1 H2 : a = b) : H1 = H2 := rfl
|
2014-08-15 03:12:54 +00:00
|
|
|
|
2014-08-01 00:48:51 +00:00
|
|
|
theorem subst {A : Type} {a b : A} {P : A → Prop} (H1 : a = b) (H2 : P a) : P b :=
|
|
|
|
eq_rec H2 H1
|
|
|
|
|
|
|
|
theorem trans {A : Type} {a b c : A} (H1 : a = b) (H2 : b = c) : a = c :=
|
|
|
|
subst H2 H1
|
|
|
|
|
|
|
|
calc_subst subst
|
|
|
|
calc_refl refl
|
|
|
|
calc_trans trans
|
|
|
|
|
2014-08-15 03:12:54 +00:00
|
|
|
theorem symm {A : Type} {a b : A} (H : a = b) : b = a :=
|
|
|
|
subst H (refl a)
|
|
|
|
|
2014-08-27 00:30:27 +00:00
|
|
|
namespace eq_ops
|
|
|
|
postfix `⁻¹` := symm
|
|
|
|
infixr `⬝` := trans
|
|
|
|
infixr `▸` := subst
|
|
|
|
end eq_ops
|
|
|
|
using eq_ops
|
|
|
|
|
2014-08-01 00:48:51 +00:00
|
|
|
theorem true_ne_false : ¬true = false :=
|
|
|
|
assume H : true = false,
|
|
|
|
subst H trivial
|
|
|
|
|
2014-08-15 03:12:54 +00:00
|
|
|
-- eq_rec with arguments swapped, for transporting an element of a dependent type
|
|
|
|
definition eq_rec_on {A : Type} {a1 a2 : A} {B : A → Type} (H1 : a1 = a2) (H2 : B a1) : B a2 :=
|
|
|
|
eq_rec H2 H1
|
|
|
|
|
2014-08-17 21:41:23 +00:00
|
|
|
theorem eq_rec_on_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : eq_rec_on H b = b :=
|
2014-08-27 00:30:27 +00:00
|
|
|
refl (eq_rec_on rfl b)
|
2014-08-15 03:12:54 +00:00
|
|
|
|
2014-08-17 21:41:23 +00:00
|
|
|
theorem eq_rec_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : eq_rec b H = b :=
|
|
|
|
eq_rec_on_id H b
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
theorem eq_rec_on_compose {A : Type} {a b c : A} {P : A → Type} (H1 : a = b) (H2 : b = c)
|
|
|
|
(u : P a) :
|
2014-08-17 21:41:23 +00:00
|
|
|
eq_rec_on H2 (eq_rec_on H1 u) = eq_rec_on (trans H1 H2) u :=
|
|
|
|
(show ∀(H2 : b = c), eq_rec_on H2 (eq_rec_on H1 u) = eq_rec_on (trans H1 H2) u,
|
|
|
|
from eq_rec_on H2 (take (H2 : b = b), eq_rec_on_id H2 _))
|
|
|
|
H2
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-20 02:32:44 +00:00
|
|
|
theorem congr_fun {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) (a : A) : f a = g a :=
|
2014-08-01 00:48:51 +00:00
|
|
|
H ▸ refl (f a)
|
|
|
|
|
2014-08-20 02:32:44 +00:00
|
|
|
theorem congr_arg {A : Type} {B : Type} {a b : A} (f : A → B) (H : a = b) : f a = f b :=
|
2014-08-01 00:48:51 +00:00
|
|
|
H ▸ refl (f a)
|
|
|
|
|
2014-08-22 23:36:47 +00:00
|
|
|
theorem congr {A : Type} {B : Type} {f g : A → B} {a b : A} (H1 : f = g) (H2 : a = b) :
|
|
|
|
f a = g b :=
|
2014-08-01 00:48:51 +00:00
|
|
|
H1 ▸ H2 ▸ refl (f a)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
theorem not_congr {a b : Prop} (H : a = b) : (¬a) = (¬b) :=
|
2014-08-20 02:32:44 +00:00
|
|
|
congr_arg not H
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
theorem eqmp {a b : Prop} (H1 : a = b) (H2 : a) : b :=
|
|
|
|
H1 ▸ H2
|
|
|
|
|
|
|
|
theorem eqmpr {a b : Prop} (H1 : a = b) (H2 : b) : a :=
|
2014-08-22 23:36:47 +00:00
|
|
|
H1⁻¹ ▸ H2
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-30 03:45:57 +00:00
|
|
|
theorem eq_true_elim {a : Prop} (H : a = true) : a :=
|
2014-08-22 23:36:47 +00:00
|
|
|
H⁻¹ ▸ trivial
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-30 03:45:57 +00:00
|
|
|
theorem eq_false_elim {a : Prop} (H : a = false) : ¬a :=
|
2014-08-22 23:36:47 +00:00
|
|
|
assume Ha : a, H ▸ Ha
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
theorem imp_trans {a b c : Prop} (H1 : a → b) (H2 : b → c) : a → c :=
|
|
|
|
assume Ha, H2 (H1 Ha)
|
|
|
|
|
|
|
|
theorem imp_eq_trans {a b c : Prop} (H1 : a → b) (H2 : b = c) : a → c :=
|
2014-08-22 23:36:47 +00:00
|
|
|
assume Ha, H2 ▸ (H1 Ha)
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
theorem eq_imp_trans {a b c : Prop} (H1 : a = b) (H2 : b → c) : a → c :=
|
2014-08-22 23:36:47 +00:00
|
|
|
assume Ha, H2 (H1 ▸ Ha)
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- ne
|
|
|
|
-- --
|
|
|
|
|
|
|
|
definition ne [inline] {A : Type} (a b : A) := ¬(a = b)
|
2014-08-22 23:36:47 +00:00
|
|
|
infix `≠` := ne
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
theorem ne_intro {A : Type} {a b : A} (H : a = b → false) : a ≠ b := H
|
|
|
|
|
|
|
|
theorem ne_elim {A : Type} {a b : A} (H1 : a ≠ b) (H2 : a = b) : false := H1 H2
|
|
|
|
|
|
|
|
theorem a_neq_a_elim {A : Type} {a : A} (H : a ≠ a) : false := H (refl a)
|
|
|
|
|
|
|
|
theorem ne_irrefl {A : Type} {a : A} (H : a ≠ a) : false := H (refl a)
|
|
|
|
|
|
|
|
theorem ne_symm {A : Type} {a b : A} (H : a ≠ b) : b ≠ a :=
|
|
|
|
assume H1 : b = a, H (H1⁻¹)
|
|
|
|
|
2014-08-04 05:58:12 +00:00
|
|
|
theorem eq_ne_trans {A : Type} {a b c : A} (H1 : a = b) (H2 : b ≠ c) : a ≠ c :=
|
|
|
|
H1⁻¹ ▸ H2
|
2014-08-01 00:48:51 +00:00
|
|
|
|
2014-08-04 05:58:12 +00:00
|
|
|
theorem ne_eq_trans {A : Type} {a b c : A} (H1 : a ≠ b) (H2 : b = c) : a ≠ c :=
|
|
|
|
H2 ▸ H1
|
2014-08-01 00:48:51 +00:00
|
|
|
|
|
|
|
calc_trans eq_ne_trans
|
2014-08-04 05:58:12 +00:00
|
|
|
calc_trans ne_eq_trans
|
|
|
|
|
|
|
|
theorem p_ne_false {p : Prop} (Hp : p) : p ≠ false :=
|
|
|
|
assume Heq : p = false, Heq ▸ Hp
|
|
|
|
|
|
|
|
theorem p_ne_true {p : Prop} (Hnp : ¬p) : p ≠ true :=
|
2014-08-28 01:34:09 +00:00
|
|
|
assume Heq : p = true, absurd trivial (Heq ▸ Hnp)
|