refactor(library/logic/core/eq): cleanup

This commit is contained in:
Leonardo de Moura 2014-09-09 19:15:11 -07:00
parent b4d765ff2e
commit 9ac5f28b03

View file

@ -19,20 +19,20 @@ infix `=` := eq
abbreviation rfl {A : Type} {a : A} := eq.refl a abbreviation rfl {A : Type} {a : A} := eq.refl a
namespace eq namespace eq
theorem id_refl {A : Type} {a : A} (H1 : a = a) : H1 = (eq.refl a) := theorem id_refl {A : Type} {a : A} (H1 : a = a) : H1 = (eq.refl a) :=
rfl rfl
theorem irrel {A : Type} {a b : A} (H1 H2 : a = b) : H1 = H2 := theorem irrel {A : Type} {a b : A} (H1 H2 : a = b) : H1 = H2 :=
rfl rfl
theorem subst {A : Type} {a b : A} {P : A → Prop} (H1 : a = b) (H2 : P a) : P b := theorem subst {A : Type} {a b : A} {P : A → Prop} (H1 : a = b) (H2 : P a) : P b :=
rec H2 H1 rec H2 H1
theorem trans {A : Type} {a b c : A} (H1 : a = b) (H2 : b = c) : a = c := theorem trans {A : Type} {a b c : A} (H1 : a = b) (H2 : b = c) : a = c :=
subst H2 H1 subst H2 H1
theorem symm {A : Type} {a b : A} (H : a = b) : b = a := theorem symm {A : Type} {a b : A} (H : a = b) : b = a :=
subst H (refl a) subst H (refl a)
end eq end eq
calc_subst eq.subst calc_subst eq.subst
@ -47,33 +47,33 @@ end eq_ops
open eq_ops open eq_ops
namespace eq namespace eq
-- eq_rec with arguments swapped, for transporting an element of a dependent type -- eq_rec with arguments swapped, for transporting an element of a dependent type
definition rec_on {A : Type} {a1 a2 : A} {B : A → Type} (H1 : a1 = a2) (H2 : B a1) : B a2 := definition rec_on {A : Type} {a1 a2 : A} {B : A → Type} (H1 : a1 = a2) (H2 : B a1) : B a2 :=
eq.rec H2 H1 eq.rec H2 H1
theorem rec_on_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : rec_on H b = b := theorem rec_on_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : rec_on H b = b :=
refl (rec_on rfl b) refl (rec_on rfl b)
theorem rec_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : rec b H = b := theorem rec_id {A : Type} {a : A} {B : A → Type} (H : a = a) (b : B a) : rec b H = b :=
rec_on_id H b rec_on_id H b
theorem rec_on_compose {A : Type} {a b c : A} {P : A → Type} (H1 : a = b) (H2 : b = c) theorem rec_on_compose {A : Type} {a b c : A} {P : A → Type} (H1 : a = b) (H2 : b = c)
(u : P a) : (u : P a) :
rec_on H2 (rec_on H1 u) = rec_on (trans H1 H2) u := rec_on H2 (rec_on H1 u) = rec_on (trans H1 H2) u :=
(show ∀(H2 : b = c), rec_on H2 (rec_on H1 u) = rec_on (trans H1 H2) u, (show ∀(H2 : b = c), rec_on H2 (rec_on H1 u) = rec_on (trans H1 H2) u,
from rec_on H2 (take (H2 : b = b), rec_on_id H2 _)) from rec_on H2 (take (H2 : b = b), rec_on_id H2 _))
H2 H2
end eq end eq
theorem congr_fun {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) (a : A) : f a = g a := theorem congr_fun {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) (a : A) : f a = g a :=
H ▸ eq.refl (f a) H ▸ rfl
theorem congr_arg {A : Type} {B : Type} {a b : A} (f : A → B) (H : a = b) : f a = f b := theorem congr_arg {A : Type} {B : Type} {a b : A} (f : A → B) (H : a = b) : f a = f b :=
H ▸ eq.refl (f a) H ▸ rfl
theorem congr {A : Type} {B : Type} {f g : A → B} {a b : A} (H1 : f = g) (H2 : a = b) : theorem congr {A : Type} {B : Type} {f g : A → B} {a b : A} (H1 : f = g) (H2 : a = b) :
f a = g b := f a = g b :=
H1 ▸ H2 ▸ eq.refl (f a) H1 ▸ H2 ▸ rfl
theorem equal_f {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) : ∀x, f x = g x := theorem equal_f {A : Type} {B : A → Type} {f g : Π x, B x} (H : f = g) : ∀x, f x = g x :=
take x, congr_fun H x take x, congr_fun H x
@ -106,17 +106,17 @@ definition ne [inline] {A : Type} (a b : A) := ¬(a = b)
infix `≠` := ne infix `≠` := ne
namespace ne namespace ne
theorem intro {A : Type} {a b : A} (H : a = b → false) : a ≠ b := theorem intro {A : Type} {a b : A} (H : a = b → false) : a ≠ b :=
H H
theorem elim {A : Type} {a b : A} (H1 : a ≠ b) (H2 : a = b) : false := theorem elim {A : Type} {a b : A} (H1 : a ≠ b) (H2 : a = b) : false :=
H1 H2 H1 H2
theorem irrefl {A : Type} {a : A} (H : a ≠ a) : false := theorem irrefl {A : Type} {a : A} (H : a ≠ a) : false :=
H rfl H rfl
theorem symm {A : Type} {a b : A} (H : a ≠ b) : b ≠ a := theorem symm {A : Type} {a b : A} (H : a ≠ b) : b ≠ a :=
assume H1 : b = a, H (H1⁻¹) assume H1 : b = a, H (H1⁻¹)
end ne end ne
theorem a_neq_a_elim {A : Type} {a : A} (H : a ≠ a) : false := theorem a_neq_a_elim {A : Type} {a : A} (H : a ≠ a) : false :=