lean2/src/builtin/Real.lean
Leonardo de Moura 7726ccad28 chore(builtin): rename nat, int and real modules to Nat, Int and Real.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 13:52:25 -08:00

44 lines
957 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) a (- a).
Notation 55 | _ | : abs.
EndNamespace.