fix(library): rename congr class to congruence

This commit is contained in:
Jeremy Avigad 2014-08-29 23:54:28 -04:00 committed by Leonardo de Moura
parent 6ffd719c1a
commit 39825d2dc9
4 changed files with 63 additions and 57 deletions

View file

@ -49,8 +49,8 @@ propext
(assume H, eq_to_iff H)
using relation
theorem iff_congr [instance] (P : Prop → Prop) : congr iff iff P :=
congr_mk
theorem iff_congruence [instance] (P : Prop → Prop) : congruence iff iff P :=
congruence_mk
(take (a b : Prop),
assume H : a ↔ b,
show P a ↔ P b, from eq_to_iff (subst (iff_to_eq H) (refl (P a))))

View file

@ -29,7 +29,7 @@ end
theorem test4 (a b c d e : Prop) (H1 : a ↔ b) : (a c → ¬(d → a)) ↔ (b c → ¬(d → b)) :=
congr.infer iff iff (λa, (a c → ¬(d → a))) H1
congruence.infer iff iff (λa, (a c → ¬(d → a))) H1
section

View file

@ -1,6 +1,9 @@
--- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
--- Released under Apache 2.0 license as described in the file LICENSE.
--- Author: Jeremy Avigad
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Author: Jeremy Avigad
-- logic.core.instances
-- ====================
import logic.core.connectives struc.relation
@ -11,51 +14,51 @@ using relation
-- Congruences for logic
-- ---------------------
theorem congr_not : congr iff iff not :=
congr_mk
theorem congruence_not : congruence iff iff not :=
congruence_mk
(take a b,
assume H : a ↔ b, iff_intro
(assume H1 : ¬a, assume H2 : b, H1 (iff_elim_right H H2))
(assume H1 : ¬b, assume H2 : a, H1 (iff_elim_left H H2)))
theorem congr_and : congr2 iff iff iff and :=
congr2_mk
theorem congruence_and : congruence2 iff iff iff and :=
congruence2_mk
(take a1 b1 a2 b2,
assume H1 : a1 ↔ b1, assume H2 : a2 ↔ b2,
iff_intro
(assume H3 : a1 ∧ a2, and_imp_and H3 (iff_elim_left H1) (iff_elim_left H2))
(assume H3 : b1 ∧ b2, and_imp_and H3 (iff_elim_right H1) (iff_elim_right H2)))
theorem congr_or : congr2 iff iff iff or :=
congr2_mk
theorem congruence_or : congruence2 iff iff iff or :=
congruence2_mk
(take a1 b1 a2 b2,
assume H1 : a1 ↔ b1, assume H2 : a2 ↔ b2,
iff_intro
(assume H3 : a1 a2, or_imp_or H3 (iff_elim_left H1) (iff_elim_left H2))
(assume H3 : b1 b2, or_imp_or H3 (iff_elim_right H1) (iff_elim_right H2)))
theorem congr_imp : congr2 iff iff iff imp :=
congr2_mk
theorem congruence_imp : congruence2 iff iff iff imp :=
congruence2_mk
(take a1 b1 a2 b2,
assume H1 : a1 ↔ b1, assume H2 : a2 ↔ b2,
iff_intro
(assume H3 : a1 → a2, assume Hb1 : b1, iff_elim_left H2 (H3 ((iff_elim_right H1) Hb1)))
(assume H3 : b1 → b2, assume Ha1 : a1, iff_elim_right H2 (H3 ((iff_elim_left H1) Ha1))))
theorem congr_iff : congr2 iff iff iff iff :=
congr2_mk
theorem congruence_iff : congruence2 iff iff iff iff :=
congruence2_mk
(take a1 b1 a2 b2,
assume H1 : a1 ↔ b1, assume H2 : a2 ↔ b2,
iff_intro
(assume H3 : a1 ↔ a2, iff_trans (iff_symm H1) (iff_trans H3 H2))
(assume H3 : b1 ↔ b2, iff_trans H1 (iff_trans H3 (iff_symm H2))))
-- theorem congr_const_iff [instance] := congr.const iff iff_refl
definition congr_not_compose [instance] := congr.compose congr_not
definition congr_and_compose [instance] := congr.compose21 congr_and
definition congr_or_compose [instance] := congr.compose21 congr_or
definition congr_implies_compose [instance] := congr.compose21 congr_imp
definition congr_iff_compose [instance] := congr.compose21 congr_iff
-- theorem congruence_const_iff [instance] := congruence.const iff iff_refl
definition congruence_not_compose [instance] := congruence.compose congruence_not
definition congruence_and_compose [instance] := congruence.compose21 congruence_and
definition congruence_or_compose [instance] := congruence.compose21 congruence_or
definition congruence_implies_compose [instance] := congruence.compose21 congruence_imp
definition congruence_iff_compose [instance] := congruence.compose21 congruence_iff
-- Generalized substitution
-- ------------------------
@ -65,8 +68,8 @@ definition congr_iff_compose [instance] := congr.compose21 congr_iff
namespace general_operations
theorem subst {T : Type} (R : T → T → Prop) ⦃P : T → Prop⦄ {C : congr R iff P}
{a b : T} (H : R a b) (H1 : P a) : P b := iff_elim_left (congr.app C H) H1
theorem subst {T : Type} (R : T → T → Prop) ⦃P : T → Prop⦄ {C : congruence R iff P}
{a b : T} (H : R a b) (H1 : P a) : P b := iff_elim_left (congruence.app C H) H1
end general_operations
@ -110,7 +113,7 @@ relation.mp_like_mk (iff_elim_left H)
-- Substition for iff
-- ------------------
theorem subst_iff {P : Prop → Prop} {C : congr iff iff P} {a b : Prop} (H : a ↔ b) (H1 : P a) :
theorem subst_iff {P : Prop → Prop} {C : congruence iff iff P} {a b : Prop} (H : a ↔ b) (H1 : P a) :
P b :=
@general_operations.subst Prop iff P C a b H H1

View file

@ -2,6 +2,9 @@
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Author: Jeremy Avigad
-- struc.relation
-- ==============
import logic.core.prop
@ -99,72 +102,72 @@ instance is_PER.is_transitive
-- Congruence for unary and binary functions
-- -----------------------------------------
inductive congr {T1 : Type} (R1 : T1 → T1 → Prop) {T2 : Type} (R2 : T2 → T2 → Prop)
inductive congruence {T1 : Type} (R1 : T1 → T1 → Prop) {T2 : Type} (R2 : T2 → T2 → Prop)
(f : T1 → T2) : Prop :=
congr_mk : (∀x y, R1 x y → R2 (f x) (f y)) → congr R1 R2 f
congruence_mk : (∀x y, R1 x y → R2 (f x) (f y)) → congruence R1 R2 f
-- for binary functions
inductive congr2 {T1 : Type} (R1 : T1 → T1 → Prop) {T2 : Type} (R2 : T2 → T2 → Prop)
inductive congruence2 {T1 : Type} (R1 : T1 → T1 → Prop) {T2 : Type} (R2 : T2 → T2 → Prop)
{T3 : Type} (R3 : T3 → T3 → Prop) (f : T1 → T2 → T3) : Prop :=
congr2_mk : (∀(x1 y1 : T1) (x2 y2 : T2), R1 x1 y1 → R2 x2 y2 → R3 (f x1 x2) (f y1 y2)) →
congr2 R1 R2 R3 f
congruence2_mk : (∀(x1 y1 : T1) (x2 y2 : T2), R1 x1 y1 → R2 x2 y2 → R3 (f x1 x2) (f y1 y2)) →
congruence2 R1 R2 R3 f
namespace congr
namespace congruence
abbreviation app {T1 : Type} {R1 : T1 → T1 → Prop} {T2 : Type} {R2 : T2 → T2 → Prop}
{f : T1 → T2} (C : congr R1 R2 f) ⦃x y : T1⦄ : R1 x y → R2 (f x) (f y) :=
congr_rec (λu, u) C x y
{f : T1 → T2} (C : congruence R1 R2 f) ⦃x y : T1⦄ : R1 x y → R2 (f x) (f y) :=
congruence_rec (λu, u) C x y
theorem infer {T1 : Type} (R1 : T1 → T1 → Prop) {T2 : Type} (R2 : T2 → T2 → Prop)
(f : T1 → T2) {C : congr R1 R2 f} ⦃x y : T1⦄ : R1 x y → R2 (f x) (f y) :=
congr_rec (λu, u) C x y
(f : T1 → T2) {C : congruence R1 R2 f} ⦃x y : T1⦄ : R1 x y → R2 (f x) (f y) :=
congruence_rec (λu, u) C x y
abbreviation app2 {T1 : Type} {R1 : T1 → T1 → Prop} {T2 : Type} {R2 : T2 → T2 → Prop}
{T3 : Type} {R3 : T3 → T3 → Prop}
{f : T1 → T2 → T3} (C : congr2 R1 R2 R3 f) ⦃x1 y1 : T1⦄ ⦃x2 y2 : T2⦄ :
{f : T1 → T2 → T3} (C : congruence2 R1 R2 R3 f) ⦃x1 y1 : T1⦄ ⦃x2 y2 : T2⦄ :
R1 x1 y1 → R2 x2 y2 → R3 (f x1 x2) (f y1 y2) :=
congr2_rec (λu, u) C x1 y1 x2 y2
congruence2_rec (λu, u) C x1 y1 x2 y2
-- ### general tools to build instances
theorem compose
{T2 : Type} {R2 : T2 → T2 → Prop}
{T3 : Type} {R3 : T3 → T3 → Prop}
{g : T2 → T3} (C2 : congr R2 R3 g)
{g : T2 → T3} (C2 : congruence R2 R3 g)
⦃T1 : Type⦄ {R1 : T1 → T1 → Prop}
{f : T1 → T2} (C1 : congr R1 R2 f) :
congr R1 R3 (λx, g (f x)) :=
congr_mk (λx1 x2 H, app C2 (app C1 H))
{f : T1 → T2} (C1 : congruence R1 R2 f) :
congruence R1 R3 (λx, g (f x)) :=
congruence_mk (λx1 x2 H, app C2 (app C1 H))
theorem compose21
{T2 : Type} {R2 : T2 → T2 → Prop}
{T3 : Type} {R3 : T3 → T3 → Prop}
{T4 : Type} {R4 : T4 → T4 → Prop}
{g : T2 → T3 → T4} (C3 : congr2 R2 R3 R4 g)
{g : T2 → T3 → T4} (C3 : congruence2 R2 R3 R4 g)
⦃T1 : Type⦄ {R1 : T1 → T1 → Prop}
{f1 : T1 → T2} (C1 : congr R1 R2 f1)
{f2 : T1 → T3} (C2 : congr R1 R3 f2) :
congr R1 R4 (λx, g (f1 x) (f2 x)) :=
congr_mk (λx1 x2 H, app2 C3 (app C1 H) (app C2 H))
{f1 : T1 → T2} (C1 : congruence R1 R2 f1)
{f2 : T1 → T3} (C2 : congruence R1 R3 f2) :
congruence R1 R4 (λx, g (f1 x) (f2 x)) :=
congruence_mk (λx1 x2 H, app2 C3 (app C1 H) (app C2 H))
theorem const {T2 : Type} (R2 : T2 → T2 → Prop) (H : relation.reflexive R2)
⦃T1 : Type⦄ (R1 : T1 → T1 → Prop) (c : T2) :
congr R1 R2 (λu : T1, c) :=
congr_mk (λx y H1, H c)
congruence R1 R2 (λu : T1, c) :=
congruence_mk (λx y H1, H c)
end congr
end congruence
-- Notice these can't be in the congr namespace, if we want it visible without
-- using congr.
-- Notice these can't be in the congruence namespace, if we want it visible without
-- using congruence.
theorem congr_const [instance] {T2 : Type} (R2 : T2 → T2 → Prop)
theorem congruence_const [instance] {T2 : Type} (R2 : T2 → T2 → Prop)
{C : is_reflexive R2} ⦃T1 : Type⦄ (R1 : T1 → T1 → Prop) (c : T2) :
congr R1 R2 (λu : T1, c) :=
congr.const R2 (is_reflexive.app C) R1 c
congruence R1 R2 (λu : T1, c) :=
congruence.const R2 (is_reflexive.app C) R1 c
theorem congr_trivial [instance] {T : Type} (R : T → T → Prop) :
congr R R (λu, u) :=
congr_mk (λx y H, H)
theorem congruence_trivial [instance] {T : Type} (R : T → T → Prop) :
congruence R R (λu, u) :=
congruence_mk (λx y H, H)
-- Relations that can be coerced to functions / implications