2014-08-19 01:08:45 +00:00
|
|
|
import data.num
|
2014-09-04 23:36:06 +00:00
|
|
|
|
2014-12-01 05:16:01 +00:00
|
|
|
namespace play
|
2014-10-02 23:20:52 +00:00
|
|
|
constants int nat real : Type.{1}
|
|
|
|
constant nat_add : nat → nat → nat
|
|
|
|
constant int_add : int → int → int
|
|
|
|
constant real_add : real → real → real
|
2014-08-19 01:08:45 +00:00
|
|
|
|
2014-10-08 01:02:15 +00:00
|
|
|
inductive add_struct [class] (A : Type) :=
|
2014-08-22 22:46:10 +00:00
|
|
|
mk : (A → A → A) → add_struct A
|
2014-08-19 01:08:45 +00:00
|
|
|
|
|
|
|
definition add {A : Type} {S : add_struct A} (a b : A) : A :=
|
2014-09-04 22:03:59 +00:00
|
|
|
add_struct.rec (λ m, m) S a b
|
2014-08-19 01:08:45 +00:00
|
|
|
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `+` := add
|
2014-08-19 01:08:45 +00:00
|
|
|
|
2014-09-04 23:36:06 +00:00
|
|
|
definition add_nat_struct [instance] : add_struct nat := add_struct.mk nat_add
|
|
|
|
definition add_int_struct [instance] : add_struct int := add_struct.mk int_add
|
|
|
|
definition add_real_struct [instance] : add_struct real := add_struct.mk real_add
|
2014-08-19 01:08:45 +00:00
|
|
|
|
2014-10-02 23:20:52 +00:00
|
|
|
constants n m : nat
|
|
|
|
constants i j : int
|
|
|
|
constants x y : real
|
|
|
|
constant num_to_nat : num → nat
|
|
|
|
constant nat_to_int : nat → int
|
|
|
|
constant int_to_real : int → real
|
2015-01-25 04:23:21 +00:00
|
|
|
attribute num_to_nat [coercion]
|
|
|
|
attribute nat_to_int [coercion]
|
|
|
|
attribute int_to_real [coercion]
|
2014-08-19 01:08:45 +00:00
|
|
|
|
|
|
|
set_option pp.implicit true
|
2014-09-08 15:30:08 +00:00
|
|
|
set_option pp.coercions true
|
2014-08-19 01:08:45 +00:00
|
|
|
check n + m
|
|
|
|
check i + j
|
|
|
|
check x + y
|
|
|
|
check i + n
|
|
|
|
check i + x
|
|
|
|
check n + i
|
|
|
|
check x + i
|
|
|
|
check n + x
|
|
|
|
check x + n
|
|
|
|
check x + i + n
|
|
|
|
check n + 0
|
|
|
|
check 0 + n
|
|
|
|
check 0 + i
|
|
|
|
check i + 0
|
|
|
|
check 0 + x
|
|
|
|
check x + 0
|
2014-08-28 00:55:42 +00:00
|
|
|
namespace foo
|
2014-10-02 23:20:52 +00:00
|
|
|
constant eq {A : Type} : A → A → Prop
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `=` := eq
|
2014-09-17 21:39:05 +00:00
|
|
|
definition id (A : Type) (a : A) := a
|
2014-08-19 01:08:45 +00:00
|
|
|
notation A `=` B `:` C := @eq C A B
|
|
|
|
check nat_to_int n + nat_to_int m = (n + m) : int
|
2014-08-28 00:55:42 +00:00
|
|
|
end foo
|
2014-12-01 05:16:01 +00:00
|
|
|
end play
|