lean2/src/builtin/Real.lean
Leonardo de Moura 759aa61f70 refactor(builtin/kernel): define if-then-else using Hilbert's operator
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-30 19:28:42 -08:00

44 lines
926 B
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 Int
variable Real : Type
alias : Real
builtin int_to_real : Int → Real
coercion int_to_real
definition nat_to_real (a : Nat) : Real := int_to_real (nat_to_int a)
coercion nat_to_real
namespace Real
builtin numeral
builtin add : Real → Real → Real
infixl 65 + : add
builtin mul : Real → Real → Real
infixl 70 * : mul
builtin div : Real → Real → Real
infixl 70 / : div
builtin le : Real → Real → Bool
infix 50 <= : le
infix 50 ≤ : le
definition ge (a b : Real) : Bool := b ≤ a
infix 50 >= : ge
infix 50 ≥ : ge
definition lt (a b : Real) : Bool := ¬ (a ≥ b)
infix 50 < : lt
definition gt (a b : Real) : Bool := ¬ (a ≤ b)
infix 50 > : gt
definition sub (a b : Real) : Real := a + -1.0 * b
infixl 65 - : sub
definition neg (a : Real) : Real := -1.0 * a
notation 75 - _ : neg
definition abs (a : Real) : Real := if (0.0 ≤ a) then a else (- a)
notation 55 | _ | : abs
end