2014-08-25 02:58:48 +00:00
|
|
|
import logic
|
2014-11-23 01:34:05 +00:00
|
|
|
namespace experiment
|
2014-07-07 16:31:42 +00:00
|
|
|
namespace algebra
|
2014-10-08 01:02:15 +00:00
|
|
|
inductive mul_struct [class] (A : Type) : Type :=
|
2014-09-04 23:36:06 +00:00
|
|
|
mk : (A → A → A) → mul_struct A
|
2014-07-07 16:31:42 +00:00
|
|
|
|
2014-10-12 20:06:00 +00:00
|
|
|
definition mul {A : Type} [s : mul_struct A] (a b : A)
|
2014-09-04 22:03:59 +00:00
|
|
|
:= mul_struct.rec (λ f, f) s a b
|
2014-07-07 16:31:42 +00:00
|
|
|
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `*` := mul
|
2014-08-07 23:59:08 +00:00
|
|
|
end algebra
|
2014-07-07 16:31:42 +00:00
|
|
|
|
2014-10-08 01:02:15 +00:00
|
|
|
open algebra
|
2014-07-07 16:31:42 +00:00
|
|
|
namespace nat
|
|
|
|
inductive nat : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
zero : nat,
|
|
|
|
succ : nat → nat
|
2014-07-07 16:31:42 +00:00
|
|
|
|
2014-10-02 23:20:52 +00:00
|
|
|
constant mul : nat → nat → nat
|
|
|
|
constant add : nat → nat → nat
|
2014-07-07 16:31:42 +00:00
|
|
|
|
|
|
|
definition mul_struct [instance] : algebra.mul_struct nat
|
2014-09-04 23:36:06 +00:00
|
|
|
:= algebra.mul_struct.mk mul
|
2014-08-07 23:59:08 +00:00
|
|
|
end nat
|
2014-07-07 16:31:42 +00:00
|
|
|
|
|
|
|
section
|
2014-09-03 23:00:38 +00:00
|
|
|
open algebra nat
|
2014-10-09 14:13:06 +00:00
|
|
|
variables a b c : nat
|
2014-07-07 16:31:42 +00:00
|
|
|
check a * b * c
|
2014-07-13 21:39:16 +00:00
|
|
|
definition tst1 : nat := a * b * c
|
2014-07-07 16:31:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
section
|
2014-09-03 23:00:38 +00:00
|
|
|
open [notation] algebra
|
|
|
|
open nat
|
2014-11-23 01:34:05 +00:00
|
|
|
-- check mul_struct nat << This is an error, we opened only the notation from algebra
|
2014-10-09 14:13:06 +00:00
|
|
|
variables a b c : nat
|
2014-07-07 16:31:42 +00:00
|
|
|
check a * b * c
|
2014-07-13 21:39:16 +00:00
|
|
|
definition tst2 : nat := a * b * c
|
2014-07-07 16:31:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
section
|
2014-09-03 23:00:38 +00:00
|
|
|
open nat
|
2014-11-23 01:34:05 +00:00
|
|
|
-- check mul_struct nat << This is an error, we opened only the notation from algebra
|
2014-10-09 14:13:06 +00:00
|
|
|
variables a b c : nat
|
2014-11-23 01:34:05 +00:00
|
|
|
check a*b*c
|
|
|
|
definition tst3 : nat := #nat a*b*c
|
2014-07-07 16:31:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
section
|
2014-09-03 23:00:38 +00:00
|
|
|
open nat
|
2014-07-13 21:39:16 +00:00
|
|
|
set_option pp.implicit true
|
2014-07-07 16:31:42 +00:00
|
|
|
definition add_struct [instance] : algebra.mul_struct nat
|
2014-09-04 23:36:06 +00:00
|
|
|
:= algebra.mul_struct.mk add
|
2014-07-07 16:31:42 +00:00
|
|
|
|
2014-10-09 14:13:06 +00:00
|
|
|
variables a b c : nat
|
2014-11-23 01:34:05 +00:00
|
|
|
check #experiment.algebra a*b*c -- << is open add instead of mul
|
|
|
|
definition tst4 : nat := #experiment.algebra a*b*c
|
2014-07-07 16:31:42 +00:00
|
|
|
end
|
2014-11-23 01:34:05 +00:00
|
|
|
end experiment
|