2014-01-05 20:05:08 +00:00
|
|
|
|
import Nat
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
variable Int : Type
|
|
|
|
|
alias ℤ : Int
|
|
|
|
|
builtin nat_to_int : Nat → Int
|
|
|
|
|
coercion nat_to_int
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
namespace Int
|
|
|
|
|
builtin numeral
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
builtin add : Int → Int → Int
|
|
|
|
|
infixl 65 + : add
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
builtin mul : Int → Int → Int
|
|
|
|
|
infixl 70 * : mul
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
builtin div : Int → Int → Int
|
|
|
|
|
infixl 70 div : div
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
builtin le : Int → Int → Bool
|
|
|
|
|
infix 50 <= : le
|
|
|
|
|
infix 50 ≤ : le
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition ge (a b : Int) : Bool := b ≤ a
|
|
|
|
|
infix 50 >= : ge
|
|
|
|
|
infix 50 ≥ : ge
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition lt (a b : Int) : Bool := ¬ (a ≥ b)
|
|
|
|
|
infix 50 < : lt
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition gt (a b : Int) : Bool := ¬ (a ≤ b)
|
|
|
|
|
infix 50 > : gt
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition sub (a b : Int) : Int := a + -1 * b
|
|
|
|
|
infixl 65 - : sub
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition neg (a : Int) : Int := -1 * a
|
|
|
|
|
notation 75 - _ : neg
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition mod (a b : Int) : Int := a - b * (a div b)
|
|
|
|
|
infixl 70 mod : mod
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition divides (a b : Int) : Bool := (b mod a) = 0
|
|
|
|
|
infix 50 | : divides
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition abs (a : Int) : Int := if (0 ≤ a) a (- a)
|
|
|
|
|
notation 55 | _ | : abs
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-06 05:45:31 +00:00
|
|
|
|
set::opaque sub true
|
|
|
|
|
set::opaque neg true
|
|
|
|
|
set::opaque mod true
|
|
|
|
|
set::opaque divides true
|
|
|
|
|
set::opaque abs true
|
|
|
|
|
set::opaque ge true
|
|
|
|
|
set::opaque lt true
|
|
|
|
|
set::opaque gt true
|
2014-01-05 20:05:08 +00:00
|
|
|
|
end
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
namespace Nat
|
|
|
|
|
definition sub (a b : Nat) : Int := nat_to_int a - nat_to_int b
|
|
|
|
|
infixl 65 - : sub
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition neg (a : Nat) : Int := - (nat_to_int a)
|
|
|
|
|
notation 75 - _ : neg
|
2013-12-30 11:29:20 +00:00
|
|
|
|
|
2014-01-06 05:45:31 +00:00
|
|
|
|
set::opaque sub true
|
|
|
|
|
set::opaque neg true
|
2014-01-05 20:05:08 +00:00
|
|
|
|
end
|