Add unicode name for the types: Nat, Int and Real

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-09-04 09:03:41 -07:00
parent d41160f8a5
commit be7fa0932a
7 changed files with 42 additions and 34 deletions

View file

@ -11,11 +11,19 @@ Author: Leonardo de Moura
#include "environment.h" #include "environment.h"
namespace lean { namespace lean {
class num_type_value : public type_value {
name m_unicode;
public:
num_type_value(name const & n, name const & u):type_value(n), m_unicode(u) {}
virtual ~num_type_value() {}
virtual name get_unicode_name() const { return m_unicode; }
};
// ======================================= // =======================================
// Natural numbers // Natural numbers
class nat_type_value : public type_value { class nat_type_value : public num_type_value {
public: public:
nat_type_value():type_value("Nat") {} nat_type_value():num_type_value("Nat", "\u2115") /* */ {}
}; };
expr const Nat = mk_value(*(new nat_type_value())); expr const Nat = mk_value(*(new nat_type_value()));
expr mk_nat_type() { return Nat; } expr mk_nat_type() { return Nat; }
@ -99,9 +107,9 @@ MK_CONSTANT(nat_id_fn, name({"Nat", "id"}));
// ======================================= // =======================================
// Integers // Integers
class int_type_value : public type_value { class int_type_value : public num_type_value {
public: public:
int_type_value():type_value("Int") {} int_type_value():num_type_value("Int", "\u2124") /* */ {}
}; };
expr const Int = mk_value(*(new int_type_value())); expr const Int = mk_value(*(new int_type_value()));
expr mk_int_type() { return Int; } expr mk_int_type() { return Int; }
@ -199,9 +207,9 @@ MK_CONSTANT(int_gt_fn, name({"Int", "gt"}));
// ======================================= // =======================================
// Reals // Reals
class real_type_value : public type_value { class real_type_value : public num_type_value {
public: public:
real_type_value():type_value("Real") {} real_type_value():num_type_value("Real", "\u211D") /* */ {}
}; };
expr const Real = mk_value(*(new real_type_value())); expr const Real = mk_value(*(new real_type_value()));
expr mk_real_type() { return Real; } expr mk_real_type() { return Real; }

View file

@ -1,11 +1,11 @@
Set: pp::colors Set: pp::colors
Set: pp::unicode Set: pp::unicode
Nat
Nat
Int
-10 -10
5 5
Int
Assumed: x Assumed: x
Assumed: n Assumed: n
Assumed: m Assumed: m

View file

@ -6,7 +6,7 @@
2 2
Assumed: y Assumed: y
if Int (0 ≤ -3 + y) (-3 + y) (-1 * (-3 + y)) if (0 ≤ -3 + y) (-3 + y) (-1 * (-3 + y))
| x + y | > x | x + y | > x
Set: lean::pp::notation Set: lean::pp::notation
Int::gt (Int::abs (Int::add x y)) x Int::gt (Int::abs (Int::add x y)) x

View file

@ -1,30 +1,30 @@
Set: pp::colors Set: pp::colors
Set: pp::unicode Set: pp::unicode
Assumed: f Assumed: f
∀ a : Int, (f a a) > 0 ∀ a : , (f a a) > 0
∀ a b : Int, (f a b) > 0 ∀ a b : , (f a b) > 0
Assumed: g Assumed: g
∀ (a : Int) (b : Real), (g a b) > 0 ∀ (a : ) (b : ), (g a b) > 0
∀ a b : Int, (g a (f a b)) > 0 ∀ a b : , (g a (f a b)) > 0
Set: lean::pp::coercion Set: lean::pp::coercion
∀ a b : Int, (g a (int_to_real (f a b))) > (nat_to_int 0) ∀ a b : , (g a (int_to_real (f a b))) > (nat_to_int 0)
λ a : Nat, a + 1 λ a : , a + 1
Error (line: 10, pos: 18) ambiguous overloads Error (line: 10, pos: 18) ambiguous overloads
Candidates: Candidates:
Real::add : Real → Real → Real Real::add :
Int::add : Int → Int → Int Int::add :
Nat::add : Nat → Nat → Nat Nat::add :
Arguments: Arguments:
a : lift:0:2 ?M0 a : lift:0:2 ?M0
b : lift:0:1 ?M2 b : lift:0:1 ?M2
λ a b c : Int, a + c + b λ a b c : , a + c + b
Error (line: 17, pos: 19) ambiguous overloads Error (line: 17, pos: 19) ambiguous overloads
Candidates: Candidates:
Real::add : Real → Real → Real Real::add :
Int::add : Int → Int → Int Int::add :
Nat::add : Nat → Nat → Nat Nat::add :
Arguments: Arguments:
a : lift:0:2 ?M0 a : lift:0:2 ?M0
b : lift:0:1 ?M2 b : lift:0:1 ?M2
Assumed: x Assumed: x
λ a b : Int, a + x + b λ a b : , a + x + b

View file

@ -2,11 +2,11 @@
Set: pp::unicode Set: pp::unicode
Error (line: 1, pos: 10) application type mismatch, none of the overloads can be used Error (line: 1, pos: 10) application type mismatch, none of the overloads can be used
Candidates: Candidates:
Real::add : Real → Real → Real Real::add :
Int::add : Int → Int → Int Int::add :
Nat::add : Nat → Nat → Nat Nat::add :
Arguments: Arguments:
1 : Nat 1 :
: Bool : Bool
Assumed: R Assumed: R
Assumed: T Assumed: T

View file

@ -1,7 +1,7 @@
Set: pp::colors Set: pp::colors
Set: pp::unicode Set: pp::unicode
Int → Int → Int
Assumed: f Assumed: f
f 0 f 0
Int → Int
Int

View file

@ -3,5 +3,5 @@
Π (A : Type) (a : A), A Π (A : Type) (a : A), A
Assumed: g Assumed: g
Defined: f Defined: f
f Nat 10 f 10
f Int (- 10) f (- 10)