2014-08-25 02:58:48 +00:00
|
|
|
import logic
|
2014-07-07 04:36:23 +00:00
|
|
|
|
2014-09-06 18:05:07 +00:00
|
|
|
context
|
2014-10-09 14:13:06 +00:00
|
|
|
variable {A : Type}
|
|
|
|
variable f : A → A → A
|
|
|
|
variable one : A
|
|
|
|
variable inv : A → A
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `*` := f
|
2014-07-07 04:36:23 +00:00
|
|
|
postfix `^-1`:100 := inv
|
|
|
|
definition is_assoc := ∀ a b c, (a*b)*c = a*b*c
|
|
|
|
definition is_id := ∀ a, a*one = a
|
|
|
|
definition is_inv := ∀ a, a*a^-1 = one
|
|
|
|
end
|
|
|
|
|
2014-10-08 01:02:15 +00:00
|
|
|
inductive group_struct [class] (A : Type) : Type :=
|
2014-09-04 23:36:06 +00:00
|
|
|
mk : Π (mul : A → A → A) (one : A) (inv : A → A), is_assoc mul → is_id mul one → is_inv mul one inv → group_struct A
|
2014-07-07 04:36:23 +00:00
|
|
|
|
|
|
|
inductive group : Type :=
|
2014-09-04 23:36:06 +00:00
|
|
|
mk : Π (A : Type), group_struct A → group
|
2014-07-07 04:36:23 +00:00
|
|
|
|
|
|
|
definition carrier (g : group) : Type
|
2014-09-04 22:03:59 +00:00
|
|
|
:= group.rec (λ c s, c) g
|
2014-07-07 04:36:23 +00:00
|
|
|
|
2014-07-07 04:54:16 +00:00
|
|
|
coercion carrier
|
|
|
|
|
2014-07-07 04:36:23 +00:00
|
|
|
definition group_to_struct [instance] (g : group) : group_struct (carrier g)
|
2014-09-04 22:03:59 +00:00
|
|
|
:= group.rec (λ (A : Type) (s : group_struct A), s) g
|
2014-07-07 04:36:23 +00:00
|
|
|
|
|
|
|
check group_struct
|
|
|
|
|
2014-10-12 20:06:00 +00:00
|
|
|
definition mul {A : Type} [s : group_struct A] (a b : A) : A
|
2014-09-04 22:03:59 +00:00
|
|
|
:= group_struct.rec (λ mul one inv h1 h2 h3, mul) s a b
|
2014-07-07 04:36:23 +00:00
|
|
|
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `*` := mul
|
2014-07-07 04:36:23 +00:00
|
|
|
|
|
|
|
section
|
2014-10-09 14:13:06 +00:00
|
|
|
variable G1 : group
|
|
|
|
variable G2 : group
|
|
|
|
variables a b c : G2
|
|
|
|
variables d e : G1
|
2014-07-07 04:36:23 +00:00
|
|
|
check a * b * b
|
|
|
|
check d * e
|
|
|
|
end
|
|
|
|
|
2014-10-02 23:20:52 +00:00
|
|
|
constant G : group.{1}
|
|
|
|
constants a b : G
|
2014-07-07 04:54:16 +00:00
|
|
|
definition val : G := a*b
|
|
|
|
check val
|
|
|
|
|
2014-10-02 23:20:52 +00:00
|
|
|
constant pos_real : Type.{1}
|
|
|
|
constant rmul : pos_real → pos_real → pos_real
|
|
|
|
constant rone : pos_real
|
|
|
|
constant rinv : pos_real → pos_real
|
2014-07-07 04:36:23 +00:00
|
|
|
axiom H1 : is_assoc rmul
|
|
|
|
axiom H2 : is_id rmul rone
|
|
|
|
axiom H3 : is_inv rmul rone rinv
|
|
|
|
|
2014-09-17 21:39:05 +00:00
|
|
|
definition real_group_struct [instance] : group_struct pos_real
|
2014-09-04 23:36:06 +00:00
|
|
|
:= group_struct.mk rmul rone rinv H1 H2 H3
|
2014-07-07 04:36:23 +00:00
|
|
|
|
2014-10-02 23:20:52 +00:00
|
|
|
constants x y : pos_real
|
2014-07-07 04:36:23 +00:00
|
|
|
check x * y
|
2014-07-14 01:53:02 +00:00
|
|
|
set_option pp.implicit true
|
|
|
|
print "---------------"
|
2014-07-07 04:36:23 +00:00
|
|
|
theorem T (a b : pos_real): (rmul a b) = a*b
|
2014-09-04 23:36:06 +00:00
|
|
|
:= eq.refl (rmul a b)
|