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