Enable automatic coercion from 'char const *' to hierachical name

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-08-09 14:29:30 -07:00
parent c6d0afcc40
commit 3d9f9a12d1
4 changed files with 2 additions and 17 deletions

View file

@ -32,7 +32,6 @@ inline expr abstract_p(expr const & e, expr const & s) { return abstract_p(e, 1,
\brief Create a lambda expression (lambda (x : t) b), the term b is abstracted using abstract(b, constant(x)).
*/
inline expr Fun(name const & n, expr const & t, expr const & b) { return mk_lambda(n, t, abstract(b, mk_constant(n))); }
inline expr Fun(char const * n, expr const & t, expr const & b) { return Fun(name(n), t, b); }
inline expr Fun(expr const & n, expr const & t, expr const & b) { return mk_lambda(const_name(n), t, abstract(b, n)); }
inline expr Fun(std::pair<expr const &, expr const &> const & p, expr const & b) { return Fun(p.first, p.second, b); }
expr Fun(std::initializer_list<std::pair<expr const &, expr const &>> const & l, expr const & b);
@ -41,7 +40,6 @@ inline expr Fun(std::pair<expr const &, expr const &> const & p, expr const & b)
\brief Create a Pi expression (pi (x : t) b), the term b is abstracted using abstract(b, constant(x)).
*/
inline expr Pi(name const & n, expr const & t, expr const & b) { return mk_pi(n, t, abstract(b, mk_constant(n))); }
inline expr Pi(char const * n, expr const & t, expr const & b) { return Pi(name(n), t, b); }
inline expr Pi(expr const & n, expr const & t, expr const & b) { return mk_pi(const_name(n), t, abstract(b, n)); }
inline expr Pi(std::pair<expr const &, expr const &> const & p, expr const & b) { return Pi(p.first, p.second, b); }
expr Pi(std::initializer_list<std::pair<expr const &, expr const &>> const & l, expr const & b);

View file

@ -38,8 +38,6 @@ public:
*/
level define_uvar(name const & n, level const & l);
level define_uvar(name const & n) { return define_uvar(n, level()); }
level define_uvar(char const * n, level const & l) { return define_uvar(name(n), l); }
level define_uvar(char const * n) { return define_uvar(name(n), level()); }
/**
\brief Return true iff the constraint l1 >= l2 is implied by the constraints
@ -55,7 +53,6 @@ public:
Throw an exception if variable is not defined in this environment.
*/
level get_uvar(name const & n) const;
level get_uvar(char const * n) const { return get_uvar(name(n)); }
/**
\brief Create a child environment. This environment will only allow "read-only" operations until
@ -163,9 +160,7 @@ public:
If opaque == true, then definition is not used by normalizer.
*/
void add_definition(name const & n, expr const & t, expr const & v, bool opaque = false);
void add_definition(char const * n, expr const & t, expr const & v, bool opaque = false) { add_definition(name(n), t, v, opaque); }
void add_theorem(name const & n, expr const & t, expr const & v);
void add_theorem(char const * n, expr const & t, expr const & v) { add_theorem(name(n), t, v); }
/**
\brief Add a new definition n : infer_type(v) := v.
@ -173,16 +168,13 @@ public:
If opaque == true, then definition is not used by normalizer.
*/
void add_definition(name const & n, expr const & v, bool opaque = false);
void add_definition(char const * n, expr const & v, bool opaque = false) { add_definition(name(n), v, opaque); }
/**
\brief Add a new fact (Axiom or Fact) to the environment.
It throws an exception if there is already an object with the given name.
*/
void add_axiom(name const & n, expr const & t);
void add_axiom(char const * n, expr const & t) { add_axiom(name(n), t); }
void add_var(name const & n, expr const & t);
void add_var(char const * n, expr const & t) { add_var(name(n), t); }
/**
\brief Return the object with the given name.

View file

@ -257,9 +257,7 @@ inline bool is_abstraction(expr const & e) { return is_lambda(e) || is_pi(e); }
inline expr mk_var(unsigned idx) { return expr(new expr_var(idx)); }
inline expr Var(unsigned idx) { return mk_var(idx); }
inline expr mk_constant(name const & n) { return expr(new expr_const(n)); }
inline expr mk_constant(char const * n) { return mk_constant(name(n)); }
inline expr Const(name const & n) { return mk_constant(n); }
inline expr Const(char const * n) { return mk_constant(n); }
inline expr mk_value(value & v) { return expr(new expr_value(v)); }
inline expr to_expr(value & v) { return mk_value(v); }
expr mk_app(unsigned num_args, expr const * args);
@ -271,14 +269,11 @@ inline expr mk_app(expr const & e1, expr const & e2, expr const & e3, expr const
inline expr mk_eq(expr const & l, expr const & r) { return expr(new expr_eq(l, r)); }
inline expr Eq(expr const & l, expr const & r) { return mk_eq(l, r); }
inline expr mk_lambda(name const & n, expr const & t, expr const & e) { return expr(new expr_lambda(n, t, e)); }
inline expr mk_lambda(char const * n, expr const & t, expr const & e) { return mk_lambda(name(n), t, e); }
inline expr mk_pi(name const & n, expr const & t, expr const & e) { return expr(new expr_pi(n, t, e)); }
inline expr mk_pi(char const * n, expr const & t, expr const & e) { return mk_pi(name(n), t, e); }
inline expr arrow(expr const & t, expr const & e) { return mk_pi(name("_"), t, e); }
inline expr operator>>(expr const & t, expr const & e) { return arrow(t, e); }
inline expr mk_let(name const & n, expr const & v, expr const & e) { return expr(new expr_let(n, v, e)); }
inline expr mk_let(char const * n, expr const & v, expr const & e) { return mk_let(name(n), v, e); }
inline expr Let(char const * n, expr const & v, expr const & e) { return mk_let(n, v, e); }
inline expr Let(name const & n, expr const & v, expr const & e) { return mk_let(n, v, e); }
inline expr mk_type(level const & l) { return expr(new expr_type(l)); }
expr mk_type();
inline expr Type(level const & l) { return mk_type(l); }

View file

@ -22,7 +22,7 @@ class name {
explicit name(imp * p);
public:
name();
explicit name(char const * name);
name(char const * name);
explicit name(unsigned k);
name(name const & prefix, char const * name);
name(name const & prefix, unsigned k);