2014-12-12 04:14:53 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Authors: Jeremy Avigad, Leonardo de Moura
|
|
|
|
|
2015-12-08 17:57:55 +00:00
|
|
|
Various multiplicative and additive structures. Partially modeled on Isabelle's library.
|
2014-12-12 04:14:53 +00:00
|
|
|
-/
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
import algebra.inf_group
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-12-08 17:57:55 +00:00
|
|
|
open eq eq.ops -- note: ⁻¹ will be overloaded
|
2015-12-09 05:02:05 +00:00
|
|
|
open binary algebra is_trunc
|
2015-12-08 17:57:55 +00:00
|
|
|
set_option class.force_new true
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
variable {A : Type}
|
|
|
|
|
|
|
|
/- semigroup -/
|
|
|
|
|
2015-12-08 17:57:55 +00:00
|
|
|
namespace algebra
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure is_set_structure [class] (A : Type) :=
|
|
|
|
(is_set_carrier : is_set A)
|
2015-03-19 14:21:54 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
attribute is_set_structure.is_set_carrier [instance] [priority 950]
|
2015-12-09 05:02:05 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure semigroup [class] (A : Type) extends is_set_structure A, inf_semigroup A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure comm_semigroup [class] (A : Type) extends semigroup A, comm_inf_semigroup A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure left_cancel_semigroup [class] (A : Type) extends semigroup A, left_cancel_inf_semigroup A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure right_cancel_semigroup [class] (A : Type) extends semigroup A, right_cancel_inf_semigroup A
|
2015-06-15 11:16:30 +00:00
|
|
|
|
2014-12-12 04:14:53 +00:00
|
|
|
/- additive semigroup -/
|
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_semigroup [class] : Type → Type := semigroup
|
|
|
|
|
|
|
|
definition add_semigroup.is_set_carrier [instance] [priority 900] (A : Type) [H : add_semigroup A] :
|
|
|
|
is_set A :=
|
2017-02-02 22:23:23 +00:00
|
|
|
@is_set_structure.is_set_carrier A (@semigroup.to_is_set_structure A H)
|
2015-12-09 05:02:05 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_inf_semigroup_of_add_semigroup [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_semigroup A] : add_inf_semigroup A :=
|
|
|
|
@semigroup.to_inf_semigroup A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_comm_semigroup [class] : Type → Type := comm_semigroup
|
|
|
|
|
|
|
|
definition add_semigroup_of_add_comm_semigroup [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_comm_semigroup A] : add_semigroup A :=
|
|
|
|
@comm_semigroup.to_semigroup A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_comm_inf_semigroup_of_add_comm_semigroup [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_comm_semigroup A] : add_comm_inf_semigroup A :=
|
|
|
|
@comm_semigroup.to_comm_inf_semigroup A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_left_cancel_semigroup [class] : Type → Type := left_cancel_semigroup
|
|
|
|
|
|
|
|
definition add_semigroup_of_add_left_cancel_semigroup [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_left_cancel_semigroup A] : add_semigroup A :=
|
|
|
|
@left_cancel_semigroup.to_semigroup A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_left_cancel_inf_semigroup_of_add_left_cancel_semigroup [reducible] [trans_instance]
|
|
|
|
(A : Type) [H : add_left_cancel_semigroup A] : add_left_cancel_inf_semigroup A :=
|
|
|
|
@left_cancel_semigroup.to_left_cancel_inf_semigroup A H
|
2015-06-15 11:16:30 +00:00
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_right_cancel_semigroup [class] : Type → Type := right_cancel_semigroup
|
|
|
|
|
|
|
|
definition add_semigroup_of_add_right_cancel_semigroup [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_right_cancel_semigroup A] : add_semigroup A :=
|
|
|
|
@right_cancel_semigroup.to_semigroup A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_right_cancel_inf_semigroup_of_add_right_cancel_semigroup [reducible] [trans_instance]
|
|
|
|
(A : Type) [H : add_right_cancel_semigroup A] : add_right_cancel_inf_semigroup A :=
|
|
|
|
@right_cancel_semigroup.to_right_cancel_inf_semigroup A H
|
2015-06-15 11:16:30 +00:00
|
|
|
|
2014-12-12 04:14:53 +00:00
|
|
|
/- monoid -/
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure monoid [class] (A : Type) extends semigroup A, inf_monoid A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure comm_monoid [class] (A : Type) extends monoid A, comm_semigroup A, comm_inf_monoid A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
/- additive monoid -/
|
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_monoid [class] : Type → Type := monoid
|
|
|
|
|
|
|
|
definition add_semigroup_of_add_monoid [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_monoid A] : add_semigroup A :=
|
|
|
|
@monoid.to_semigroup A H
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_inf_monoid_of_add_monoid [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_monoid A] : add_inf_monoid A :=
|
|
|
|
@monoid.to_inf_monoid A H
|
2016-09-19 18:41:21 +00:00
|
|
|
|
|
|
|
definition add_comm_monoid [class] : Type → Type := comm_monoid
|
|
|
|
|
|
|
|
definition add_monoid_of_add_comm_monoid [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_comm_monoid A] : add_monoid A :=
|
|
|
|
@comm_monoid.to_monoid A H
|
|
|
|
|
|
|
|
definition add_comm_semigroup_of_add_comm_monoid [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_comm_monoid A] : add_comm_semigroup A :=
|
|
|
|
@comm_monoid.to_comm_semigroup A H
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_comm_inf_monoid_of_add_comm_monoid [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_comm_monoid A] : add_comm_inf_monoid A :=
|
|
|
|
@comm_monoid.to_comm_inf_monoid A H
|
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_monoid.to_monoid {A : Type} [s : add_monoid A] : monoid A := s
|
|
|
|
definition add_comm_monoid.to_comm_monoid {A : Type} [s : add_comm_monoid A] : comm_monoid A := s
|
|
|
|
definition monoid.to_add_monoid {A : Type} [s : monoid A] : add_monoid A := s
|
|
|
|
definition comm_monoid.to_add_comm_monoid {A : Type} [s : comm_monoid A] : add_comm_monoid A := s
|
2016-09-17 22:37:49 +00:00
|
|
|
|
2014-12-12 04:14:53 +00:00
|
|
|
/- group -/
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure group [class] (A : Type) extends monoid A, inf_group A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
section group
|
|
|
|
|
|
|
|
variable [s : group A]
|
|
|
|
include s
|
|
|
|
|
2016-02-25 22:30:00 +00:00
|
|
|
definition group.to_left_cancel_semigroup [trans_instance] : left_cancel_semigroup A :=
|
2015-05-05 21:25:35 +00:00
|
|
|
⦃ left_cancel_semigroup, s,
|
2017-02-02 22:23:23 +00:00
|
|
|
mul_left_cancel := @mul_left_cancel A _ ⦄
|
2015-05-05 21:25:35 +00:00
|
|
|
|
2016-02-25 22:30:00 +00:00
|
|
|
definition group.to_right_cancel_semigroup [trans_instance] : right_cancel_semigroup A :=
|
2015-05-05 21:25:35 +00:00
|
|
|
⦃ right_cancel_semigroup, s,
|
2017-02-02 22:23:23 +00:00
|
|
|
mul_right_cancel := @mul_right_cancel A _ ⦄
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
end group
|
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
structure ab_group [class] (A : Type) extends group A, comm_monoid A, ab_inf_group A
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
/- additive group -/
|
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_group [class] : Type → Type := group
|
|
|
|
|
|
|
|
definition add_semigroup_of_add_group [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_group A] : add_monoid A :=
|
|
|
|
@group.to_monoid A H
|
2015-12-08 17:57:55 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_inf_group_of_add_group [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_group A] : add_inf_group A :=
|
|
|
|
@group.to_inf_group A H
|
2015-12-08 17:57:55 +00:00
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_group.to_group {A : Type} [s : add_group A] : group A := s
|
|
|
|
definition group.to_add_group {A : Type} [s : group A] : add_group A := s
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
section add_group
|
|
|
|
|
|
|
|
variables [s : add_group A]
|
|
|
|
include s
|
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_group.to_add_left_cancel_semigroup [reducible] [trans_instance] :
|
|
|
|
add_left_cancel_semigroup A :=
|
|
|
|
@group.to_left_cancel_semigroup A s
|
2015-05-05 21:25:35 +00:00
|
|
|
|
2016-09-19 18:41:21 +00:00
|
|
|
definition add_group.to_add_right_cancel_semigroup [reducible] [trans_instance] :
|
|
|
|
add_right_cancel_semigroup A :=
|
|
|
|
@group.to_right_cancel_semigroup A s
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
end add_group
|
|
|
|
|
2016-11-24 05:13:05 +00:00
|
|
|
definition add_ab_group [class] : Type → Type := ab_group
|
2016-09-19 18:41:21 +00:00
|
|
|
|
2016-11-24 05:13:05 +00:00
|
|
|
definition add_group_of_add_ab_group [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_ab_group A] : add_group A :=
|
|
|
|
@ab_group.to_group A H
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2016-11-24 05:13:05 +00:00
|
|
|
definition add_comm_monoid_of_add_ab_group [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_ab_group A] : add_comm_monoid A :=
|
|
|
|
@ab_group.to_comm_monoid A H
|
2016-09-17 22:37:49 +00:00
|
|
|
|
2017-02-02 22:23:23 +00:00
|
|
|
definition add_ab_inf_group_of_add_ab_group [reducible] [trans_instance] (A : Type)
|
|
|
|
[H : add_ab_group A] : add_ab_inf_group A :=
|
|
|
|
@ab_group.to_ab_inf_group A H
|
|
|
|
|
2016-11-24 05:13:05 +00:00
|
|
|
definition add_ab_group.to_ab_group {A : Type} [s : add_ab_group A] : ab_group A := s
|
|
|
|
definition ab_group.to_add_ab_group {A : Type} [s : ab_group A] : add_ab_group A := s
|
2016-09-17 22:37:49 +00:00
|
|
|
|
2015-05-14 02:01:48 +00:00
|
|
|
definition group_of_add_group (A : Type) [G : add_group A] : group A :=
|
|
|
|
⦃group,
|
|
|
|
mul := has_add.add,
|
|
|
|
mul_assoc := add.assoc,
|
|
|
|
one := !has_zero.zero,
|
|
|
|
one_mul := zero_add,
|
|
|
|
mul_one := add_zero,
|
|
|
|
inv := has_neg.neg,
|
2015-12-09 05:02:05 +00:00
|
|
|
mul_left_inv := add.left_inv,
|
2016-02-15 20:18:07 +00:00
|
|
|
is_set_carrier := _⦄
|
2015-12-08 17:57:55 +00:00
|
|
|
|
2015-05-05 21:25:35 +00:00
|
|
|
end algebra
|
2015-12-08 17:57:55 +00:00
|
|
|
open algebra
|