lean2/src/builtin/Int.lean
Leonardo de Moura 8c956280d9 chore(frontends/lean): rename setoption and setopaque commands to set::option and set::opaque
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-06 11:41:03 -08:00

68 lines
No EOL
1.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Nat
variable Int : Type
alias : Int
builtin nat_to_int : Nat → Int
coercion nat_to_int
namespace Int
builtin numeral
builtin add : Int → Int → Int
infixl 65 + : add
builtin mul : Int → Int → Int
infixl 70 * : mul
builtin div : Int → Int → Int
infixl 70 div : div
builtin le : Int → Int → Bool
infix 50 <= : le
infix 50 ≤ : le
definition ge (a b : Int) : Bool := b ≤ a
infix 50 >= : ge
infix 50 ≥ : ge
definition lt (a b : Int) : Bool := ¬ (a ≥ b)
infix 50 < : lt
definition gt (a b : Int) : Bool := ¬ (a ≤ b)
infix 50 > : gt
definition sub (a b : Int) : Int := a + -1 * b
infixl 65 - : sub
definition neg (a : Int) : Int := -1 * a
notation 75 - _ : neg
definition mod (a b : Int) : Int := a - b * (a div b)
infixl 70 mod : mod
definition divides (a b : Int) : Bool := (b mod a) = 0
infix 50 | : divides
definition abs (a : Int) : Int := if (0 ≤ a) a (- a)
notation 55 | _ | : abs
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
end
namespace Nat
definition sub (a b : Nat) : Int := nat_to_int a - nat_to_int b
infixl 65 - : sub
definition neg (a : Nat) : Int := - (nat_to_int a)
notation 75 - _ : neg
set::opaque sub true
set::opaque neg true
end