From 4cf3d32e0ce73cb7be472c113c25c2855286d7ca Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 19 Aug 2014 16:28:58 -0700 Subject: [PATCH] chore(*): create alias for std::pair Signed-off-by: Leonardo de Moura --- src/frontends/lean/calc.cpp | 4 ++-- src/frontends/lean/elaborator.cpp | 2 +- src/frontends/lean/local_decls.h | 2 +- src/frontends/lean/notation_cmd.cpp | 2 +- src/frontends/lean/parse_table.cpp | 14 +++++++------- src/frontends/lean/parse_table.h | 2 +- src/frontends/lean/parser.cpp | 2 +- src/frontends/lean/parser_bindings.cpp | 2 +- src/frontends/lean/pp.h | 3 ++- src/frontends/lean/structure_cmd.cpp | 2 +- src/frontends/lean/token_table.cpp | 7 ++++--- src/kernel/expr.h | 4 ++-- src/kernel/expr_sets.h | 2 +- src/kernel/for_each_fn.cpp | 2 +- src/kernel/formatter.cpp | 2 +- src/kernel/formatter.h | 4 ++-- src/kernel/inductive/inductive.h | 2 +- src/kernel/level.cpp | 2 +- src/kernel/metavar.cpp | 4 ++-- src/kernel/metavar.h | 14 +++++++------- src/kernel/pos_info_provider.h | 2 +- src/kernel/record/record.h | 2 +- src/kernel/type_checker.cpp | 2 +- src/kernel/type_checker.h | 4 ++-- src/library/coercion.cpp | 6 +++--- src/library/error_handling/error_handling.cpp | 17 ----------------- src/library/expr_pair.h | 2 +- src/library/level_names.cpp | 2 +- src/library/level_names.h | 4 ++-- src/library/match.cpp | 2 +- src/library/module.cpp | 2 +- src/library/private.cpp | 2 +- src/library/private.h | 2 +- src/library/rewriter/rewriter.cpp | 1 - src/library/simplifier/congr.cpp | 4 ++-- src/library/tactic/tactic.cpp | 2 +- src/library/tactic/tactic.h | 2 +- src/library/unifier.cpp | 4 ++-- src/tests/util/format.cpp | 4 ++-- src/tests/util/list.cpp | 2 +- src/util/lazy_list.h | 3 ++- src/util/list_fn.h | 4 ++-- src/util/lua_pair.h | 14 +++++++------- src/util/name.h | 3 ++- src/util/pair.h | 5 ++++- src/util/polynomial/polynomial.h | 4 ++-- src/util/rb_map.h | 2 +- src/util/scoped_map.h | 7 ++++--- src/util/scoped_set.h | 7 ++++--- src/util/sexpr/format.cpp | 6 +++--- src/util/sexpr/format.h | 4 ++-- src/util/splay_map.h | 2 +- src/util/thread_script_state.cpp | 2 +- 53 files changed, 100 insertions(+), 109 deletions(-) diff --git a/src/frontends/lean/calc.cpp b/src/frontends/lean/calc.cpp index 437685c4a..045243e8e 100644 --- a/src/frontends/lean/calc.cpp +++ b/src/frontends/lean/calc.cpp @@ -23,7 +23,7 @@ Author: Leonardo de Moura namespace lean { struct calc_ext : public environment_extension { - typedef rb_map, name_quick_cmp> refl_table; + typedef rb_map, name_quick_cmp> refl_table; typedef rb_map, name_pair_quick_cmp> trans_table; optional m_subst; unsigned m_subst_num_args; @@ -175,7 +175,7 @@ void register_calc_cmds(cmd_table & r) { } typedef std::tuple calc_pred; -typedef std::pair calc_step; +typedef pair calc_step; inline name const & pred_op(calc_pred const & p) { return std::get<0>(p); } inline expr const & pred_lhs(calc_pred const & p) { return std::get<1>(p); } inline expr const & pred_rhs(calc_pred const & p) { return std::get<2>(p); } diff --git a/src/frontends/lean/elaborator.cpp b/src/frontends/lean/elaborator.cpp index 2cfaa23de..cb1dd07bb 100644 --- a/src/frontends/lean/elaborator.cpp +++ b/src/frontends/lean/elaborator.cpp @@ -711,7 +711,7 @@ public: The result is a pair new_f, f_type, where new_f is the new value for \c f, and \c f_type is its type (and a Pi-expression) */ - std::pair ensure_fun(expr f) { + pair ensure_fun(expr f) { expr f_type = infer_type(f); if (!is_pi(f_type)) f_type = whnf(f_type); diff --git a/src/frontends/lean/local_decls.h b/src/frontends/lean/local_decls.h index 53dedb61d..dca7a74a1 100644 --- a/src/frontends/lean/local_decls.h +++ b/src/frontends/lean/local_decls.h @@ -19,7 +19,7 @@ namespace lean { */ template class local_decls { - typedef rb_map, name_quick_cmp> map; + typedef rb_map, name_quick_cmp> map; typedef list>> scopes; map m_map; unsigned m_counter; diff --git a/src/frontends/lean/notation_cmd.cpp b/src/frontends/lean/notation_cmd.cpp index d6cf0bc23..f5d9fdff9 100644 --- a/src/frontends/lean/notation_cmd.cpp +++ b/src/frontends/lean/notation_cmd.cpp @@ -81,7 +81,7 @@ using notation::mk_ext_lua_action; using notation::transition; using notation::action; -static std::pair> parse_mixfix_notation(parser & p, mixfix_kind k, bool overload) { +static pair> parse_mixfix_notation(parser & p, mixfix_kind k, bool overload) { std::string tk = parse_symbol(p, "invalid notation declaration, quoted symbol or identifier expected"); optional prec; if (p.curr_is_token(g_colon)) { diff --git a/src/frontends/lean/parse_table.cpp b/src/frontends/lean/parse_table.cpp index fb47b3951..0898603e3 100644 --- a/src/frontends/lean/parse_table.cpp +++ b/src/frontends/lean/parse_table.cpp @@ -264,9 +264,9 @@ transition replace(transition const & t, std::function const } struct parse_table::cell { - bool m_nud; - list m_accept; - rb_map, name_quick_cmp> m_children; + bool m_nud; + list m_accept; + rb_map, name_quick_cmp> m_children; MK_LEAN_RC(); // Declare m_rc counter void dealloc() { delete this; } cell(bool nud = true):m_nud(nud), m_rc(1) {} @@ -280,12 +280,12 @@ parse_table::parse_table(parse_table && s):m_ptr(s.m_ptr) { s.m_ptr = nullptr; } parse_table::~parse_table() { if (m_ptr) m_ptr->dec_ref(); } parse_table & parse_table::operator=(parse_table const & s) { LEAN_COPY_REF(s); } parse_table & parse_table::operator=(parse_table && s) { LEAN_MOVE_REF(s); } -optional> parse_table::find(name const & tk) const { +optional> parse_table::find(name const & tk) const { auto * it = m_ptr->m_children.find(tk); if (it) - return optional>(*it); + return optional>(*it); else - return optional>(); + return optional>(); } list const & parse_table::is_accepting() const { @@ -355,7 +355,7 @@ parse_table parse_table::add(unsigned num, transition const * ts, expr const & a void parse_table::for_each(buffer & ts, std::function const &)> const & fn) const { if (!is_nil(m_ptr->m_accept)) fn(ts.size(), ts.data(), m_ptr->m_accept); - m_ptr->m_children.for_each([&](name const & k, std::pair const & p) { + m_ptr->m_children.for_each([&](name const & k, pair const & p) { ts.push_back(transition(k, p.first)); p.second.for_each(ts, fn); ts.pop_back(); diff --git a/src/frontends/lean/parse_table.h b/src/frontends/lean/parse_table.h index f57524967..630d85c6c 100644 --- a/src/frontends/lean/parse_table.h +++ b/src/frontends/lean/parse_table.h @@ -130,7 +130,7 @@ public: return add(ts.size(), ts.begin(), a, true); } parse_table merge(parse_table const & s, bool overload) const; - optional> find(name const & tk) const; + optional> find(name const & tk) const; list const & is_accepting() const; void for_each(std::function const &)> const & fn) const; diff --git a/src/frontends/lean/parser.cpp b/src/frontends/lean/parser.cpp index ad2ed6c2c..fd839689e 100644 --- a/src/frontends/lean/parser.cpp +++ b/src/frontends/lean/parser.cpp @@ -705,7 +705,7 @@ expr parser::parse_binder() { represents the type of the identifiers. */ void parser::parse_binder_block(buffer & r, binder_info const & bi) { - buffer> names; + buffer> names; while (curr_is_identifier()) { auto p = pos(); names.emplace_back(p, check_atomic_id_next("invalid binder, atomic identifier expected")); diff --git a/src/frontends/lean/parser_bindings.cpp b/src/frontends/lean/parser_bindings.cpp index 44298f3ef..0a6b21583 100644 --- a/src/frontends/lean/parser_bindings.cpp +++ b/src/frontends/lean/parser_bindings.cpp @@ -47,7 +47,7 @@ static unsigned to_rbp(lua_State * L, int idx) { return idx < nargs ? 0 : lua_tointeger(L, idx); } -typedef std::pair> local_scope_cell; +typedef pair> local_scope_cell; typedef std::shared_ptr local_scope; DECL_UDATA(local_scope); static const struct luaL_Reg local_scope_m[] = { diff --git a/src/frontends/lean/pp.h b/src/frontends/lean/pp.h index 659a9dcd4..ff2a63499 100644 --- a/src/frontends/lean/pp.h +++ b/src/frontends/lean/pp.h @@ -7,6 +7,7 @@ Author: Leonardo de Moura #pragma once #include #include +#include "util/pair.h" #include "util/name_map.h" #include "util/name_set.h" #include "util/sexpr/options.h" @@ -17,7 +18,7 @@ Author: Leonardo de Moura namespace lean { class pretty_fn { public: - typedef std::pair result; + typedef pair result; private: environment m_env; type_checker m_tc; diff --git a/src/frontends/lean/structure_cmd.cpp b/src/frontends/lean/structure_cmd.cpp index 951a1e936..bd09ca6a7 100644 --- a/src/frontends/lean/structure_cmd.cpp +++ b/src/frontends/lean/structure_cmd.cpp @@ -35,7 +35,7 @@ static name g_tmp_prefix = name::mk_internal_unique_name(); struct structure_cmd_fn { typedef std::unique_ptr type_checker_ptr; - typedef std::vector> rename_vector; + typedef std::vector> rename_vector; parser & m_p; environment m_env; name_generator m_ngen; diff --git a/src/frontends/lean/token_table.cpp b/src/frontends/lean/token_table.cpp index 765392668..bc9c56803 100644 --- a/src/frontends/lean/token_table.cpp +++ b/src/frontends/lean/token_table.cpp @@ -6,6 +6,7 @@ Author: Leonardo de Moura */ #include #include +#include "util/pair.h" #include "frontends/lean/token_table.h" namespace lean { @@ -64,7 +65,7 @@ static char const * g_cup = "\u2294"; token_table init_token_table() { token_table t; - std::pair builtin[] = + pair builtin[] = {{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"have", 0}, {"show", 0}, {"obtain", 0}, {"by", 0}, {"then", 0}, {"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec}, {"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec}, {"Type'", g_max_prec}, @@ -80,11 +81,11 @@ token_table init_token_table() { "exit", "set_option", "using", "calc_subst", "calc_refl", "calc_trans", "tactic_hint", "add_proof_qed", "set_proof_qed", "instance", "#erase_cache", nullptr}; - std::pair aliases[] = + pair aliases[] = {{g_lambda_unicode, "fun"}, {"forall", "Pi"}, {g_forall_unicode, "Pi"}, {g_pi_unicode, "Pi"}, {nullptr, nullptr}}; - std::pair cmd_aliases[] = + pair cmd_aliases[] = {{"parameter", "variable"}, {"parameters", "variables"}, {"lemma", "theorem"}, {"hypothesis", "axiom"}, {"conjecture", "axiom"}, {"corollary", "theorem"}, {nullptr, nullptr}}; diff --git a/src/kernel/expr.h b/src/kernel/expr.h index f71e7fa9b..454ceca97 100644 --- a/src/kernel/expr.h +++ b/src/kernel/expr.h @@ -634,8 +634,8 @@ inline name const & named_expr_name(expr const & e) { return is_constant(e) ? co // ======================================= // Expression+Offset -typedef std::pair expr_offset; -typedef std::pair expr_cell_offset; +typedef pair expr_offset; +typedef pair expr_cell_offset; // ======================================= // ======================================= diff --git a/src/kernel/expr_sets.h b/src/kernel/expr_sets.h index c3b9b7a53..0a0aaaae8 100644 --- a/src/kernel/expr_sets.h +++ b/src/kernel/expr_sets.h @@ -38,7 +38,7 @@ typedef std::unordered_set expr_cell_pair; +typedef pair expr_cell_pair; struct expr_cell_pair_hash { unsigned operator()(expr_cell_pair const & p) const { return hash(p.first->hash_alloc(), p.second->hash_alloc()); } }; diff --git a/src/kernel/for_each_fn.cpp b/src/kernel/for_each_fn.cpp index b6cb2a452..a858d2d9f 100644 --- a/src/kernel/for_each_fn.cpp +++ b/src/kernel/for_each_fn.cpp @@ -53,7 +53,7 @@ class for_each_fn { std::function m_f; // NOLINT void apply(expr const & e, unsigned offset) { - buffer> todo; + buffer> todo; todo.emplace_back(e, offset); while (true) { begin_loop: diff --git a/src/kernel/formatter.cpp b/src/kernel/formatter.cpp index e1fdc6e32..fbc061569 100644 --- a/src/kernel/formatter.cpp +++ b/src/kernel/formatter.cpp @@ -38,7 +38,7 @@ bool is_internal_name(name n) { } static name g_x("x"); -std::pair binding_body_fresh(expr const & b, bool preserve_type) { +pair binding_body_fresh(expr const & b, bool preserve_type) { lean_assert(is_binding(b)); name n = binding_name(b); if (is_internal_name(n)) diff --git a/src/kernel/formatter.h b/src/kernel/formatter.h index 0507ac59e..ce015708d 100644 --- a/src/kernel/formatter.h +++ b/src/kernel/formatter.h @@ -22,10 +22,10 @@ bool is_used_name(expr const & t, name const & n); \remark If preserve_type is false, then the local constant will not use binding_domain. */ -std::pair binding_body_fresh(expr const & b, bool preserve_type = false); +pair binding_body_fresh(expr const & b, bool preserve_type = false); /** \brief Return the body of the let-expression \c l, where variable #0 is replaced by a local constant with a "fresh" name. */ -std::pair let_body_fresh(expr const & l, bool preserve_type = false); +pair let_body_fresh(expr const & l, bool preserve_type = false); class formatter { std::function m_fn; diff --git a/src/kernel/inductive/inductive.h b/src/kernel/inductive/inductive.h index fc58f51a7..a33760a67 100644 --- a/src/kernel/inductive/inductive.h +++ b/src/kernel/inductive/inductive.h @@ -22,7 +22,7 @@ public: }; /** \brief Introduction rule */ -typedef std::pair intro_rule; +typedef pair intro_rule; inline name const & intro_rule_name(intro_rule const & r) { return r.first; } inline expr const & intro_rule_type(intro_rule const & r) { return r.second; } diff --git a/src/kernel/level.cpp b/src/kernel/level.cpp index 2d843e150..cda304343 100644 --- a/src/kernel/level.cpp +++ b/src/kernel/level.cpp @@ -196,7 +196,7 @@ level mk_succ(level const & l) { } /** \brief Convert (succ^k l) into (l, k). If l is not a succ, then return (l, 0) */ -std::pair to_offset(level l) { +pair to_offset(level l) { unsigned k = 0; while (is_succ(l)) { l = succ_of(l); diff --git a/src/kernel/metavar.cpp b/src/kernel/metavar.cpp index 3345b0604..65640d19a 100644 --- a/src/kernel/metavar.cpp +++ b/src/kernel/metavar.cpp @@ -63,7 +63,7 @@ void substitution::assign(name const & m, level const & l, justification const & m_level_jsts.insert(m, j); } -std::pair substitution::instantiate_metavars(level const & l, bool use_jst) { +pair substitution::instantiate_metavars(level const & l, bool use_jst) { if (!has_meta(l)) return mk_pair(l, justification()); justification j; @@ -189,7 +189,7 @@ public: justification const & get_justification() const { return m_jst; } }; -std::pair substitution::instantiate_metavars_core(expr const & e, bool inst_local_types) { +pair substitution::instantiate_metavars_core(expr const & e, bool inst_local_types) { if (!has_metavar(e)) { return mk_pair(e, justification()); } else { diff --git a/src/kernel/metavar.h b/src/kernel/metavar.h index a07ffbb5f..5abcc9c4c 100644 --- a/src/kernel/metavar.h +++ b/src/kernel/metavar.h @@ -24,15 +24,15 @@ class substitution { jst_map m_level_jsts; friend class instantiate_metavars_fn; - std::pair instantiate_metavars(level const & l, bool use_jst); + pair instantiate_metavars(level const & l, bool use_jst); expr instantiate_metavars_wo_jst(expr const & e, bool inst_local_types); - std::pair instantiate_metavars_core(expr const & e, bool inst_local_types); + pair instantiate_metavars_core(expr const & e, bool inst_local_types); bool occurs_expr_core(name const & m, expr const & e, name_set & visited) const; public: substitution(); - typedef optional> opt_expr_jst; - typedef optional> opt_level_jst; + typedef optional> opt_expr_jst; + typedef optional> opt_level_jst; bool is_expr_assigned(name const & m) const; opt_expr_jst get_expr_assignment(name const & m) const; @@ -54,14 +54,14 @@ public: void assign(level const & m, level const & t, justification const & j) { assign(meta_id(m), t, j); } void assign(level const & m, level const & t) { assign(m, t, justification ()); } - std::pair instantiate_metavars(level const & l) { return instantiate_metavars(l, true); } + pair instantiate_metavars(level const & l) { return instantiate_metavars(l, true); } /** \brief Instantiate metavariables occurring in \c e, by default this method does not visit the types of local constants. For substituting the metavariables occurring in local constants, use instantiate_metavars_all. */ - std::pair instantiate_metavars(expr const & e) { return instantiate_metavars_core(e, false); } + pair instantiate_metavars(expr const & e) { return instantiate_metavars_core(e, false); } /** \brief \c see instantiate_metavars */ - std::pair instantiate_metavars_all(expr const & e) { return instantiate_metavars_core(e, true); } + pair instantiate_metavars_all(expr const & e) { return instantiate_metavars_core(e, true); } /** \brief Similar to \c instantiate_metavars, but does not compute a justification for the substitutions. */ expr instantiate(expr const & e) { return instantiate_metavars_wo_jst(e, false); } /** \brief Similar to instantiate, but also substitute metavariables occurring in the types of local constansts */ diff --git a/src/kernel/pos_info_provider.h b/src/kernel/pos_info_provider.h index e273ed193..5b3fa3b7b 100644 --- a/src/kernel/pos_info_provider.h +++ b/src/kernel/pos_info_provider.h @@ -10,7 +10,7 @@ Author: Leonardo de Moura #include "kernel/expr.h" namespace lean { -typedef std::pair pos_info; //!< Line and column information +typedef pair pos_info; //!< Line and column information /** \brief Abstract class for providing expression position information (line number and column). */ diff --git a/src/kernel/record/record.h b/src/kernel/record/record.h index 411cc2239..4c5e9f972 100644 --- a/src/kernel/record/record.h +++ b/src/kernel/record/record.h @@ -12,7 +12,7 @@ Author: Leonardo de Moura #include "kernel/environment.h" namespace lean { namespace record { -typedef std::pair field; +typedef pair field; inline name const & field_name(field const & f) { return f.first; } inline expr const & field_type(field const & f) { return f.second; } diff --git a/src/kernel/type_checker.cpp b/src/kernel/type_checker.cpp index b4d1d88b0..881b9beb9 100644 --- a/src/kernel/type_checker.cpp +++ b/src/kernel/type_checker.cpp @@ -95,7 +95,7 @@ optional type_checker::expand_macro(expr const & m) { \brief Return the body of the given binder, where the free variable #0 is replaced with a fresh local constant. It also returns the fresh local constant. */ -std::pair type_checker::open_binding_body(expr const & e) { +pair type_checker::open_binding_body(expr const & e) { expr local = mk_local(m_gen.next(), binding_name(e), binding_domain(e), binding_info(e)); return mk_pair(instantiate(binding_body(e), local), local); } diff --git a/src/kernel/type_checker.h b/src/kernel/type_checker.h index dbef878e1..18673aedb 100644 --- a/src/kernel/type_checker.h +++ b/src/kernel/type_checker.h @@ -85,12 +85,12 @@ class type_checker { level_param_names const * m_params; buffer m_cs; // temporary cache of constraints unsigned m_cs_qhead; - buffer> m_trail; + buffer> m_trail; friend class converter; // allow converter to access the following methods name mk_fresh_name() { return m_gen.next(); } optional expand_macro(expr const & m); - std::pair open_binding_body(expr const & e); + pair open_binding_body(expr const & e); void add_cnstr(constraint const & c); expr ensure_sort_core(expr e, expr const & s); expr ensure_pi_core(expr e, expr const & s); diff --git a/src/library/coercion.cpp b/src/library/coercion.cpp index 14a268499..c5c26c5b5 100644 --- a/src/library/coercion.cpp +++ b/src/library/coercion.cpp @@ -69,7 +69,7 @@ struct coercion_info { struct coercion_state { rb_map, name_quick_cmp> m_coercion_info; // m_from and m_to contain "direct" coercions - rb_map>, name_quick_cmp> m_from; // map user-class -> list of (class, coercion-fun) + rb_map>, name_quick_cmp> m_from; // map user-class -> list of (class, coercion-fun) rb_map, coercion_class_cmp_fn> m_to; rb_tree m_coercions; coercion_info get_info(name const & from, coercion_class const & to) { @@ -155,7 +155,7 @@ optional type_to_coercion_class(expr const & t) { } } -typedef list> arrows; +typedef list> arrows; static bool contains(arrows const & a, name const & C, coercion_class const & D) { return std::find(a.begin(), a.end(), mk_pair(C, D)) != a.end(); } @@ -308,7 +308,7 @@ coercion_state add_coercion(environment const & env, io_state const & ios, coerc } } -typedef std::pair coercion_entry; +typedef pair coercion_entry; struct coercion_config { typedef coercion_state state; typedef coercion_entry entry; diff --git a/src/library/error_handling/error_handling.cpp b/src/library/error_handling/error_handling.cpp index 3023364e8..14dcc0ede 100644 --- a/src/library/error_handling/error_handling.cpp +++ b/src/library/error_handling/error_handling.cpp @@ -87,23 +87,6 @@ static void display_error(io_state_stream const & ios, pos_info_provider const * ios << " " << mk_pair(j.pp(fmt, p, ex.get_substitution()), opts) << endl; } -// struct delta_pos_info_provider : public pos_info_provider { -// unsigned m_delta; -// std::string m_file_name; -// pos_info_provider const & m_provider; -// delta_pos_info_provider(unsigned d, char const * fname, pos_info_provider const & p):m_delta(d), m_file_name(fname), m_provider(p) {} -// virtual std::pair get_pos_info(expr const & e) const { -// auto r = m_provider.get_pos_info(e); -// return mk_pair(r.first + m_delta, r.second); -// } -// virtual char const * get_file_name() const { return m_file_name.c_str(); } -// virtual std::pair get_some_pos() const { -// auto r = m_provider.get_some_pos(); -// return mk_pair(r.first + m_delta, r.second); -// } -// }; - - static void display_error(io_state_stream const & ios, pos_info_provider const * p, script_exception const & ex) { if (p) { char const * msg = ex.get_msg(); diff --git a/src/library/expr_pair.h b/src/library/expr_pair.h index bc30a4c19..d2806adbe 100644 --- a/src/library/expr_pair.h +++ b/src/library/expr_pair.h @@ -11,7 +11,7 @@ Author: Leonardo de Moura #include "library/expr_lt.h" namespace lean { -typedef std::pair expr_pair; +typedef pair expr_pair; /** \brief Functional object for hashing expression pairs. */ struct expr_pair_hash { unsigned operator()(expr_pair const & p) const { return hash(p.first.hash(), p.second.hash()); } diff --git a/src/library/level_names.cpp b/src/library/level_names.cpp index 5a08f229e..db69751b0 100644 --- a/src/library/level_names.cpp +++ b/src/library/level_names.cpp @@ -116,7 +116,7 @@ using inductive::intro_rule; using inductive::intro_rule_name; using inductive::intro_rule_type; -std::pair> sanitize_level_params(level_param_names const & ls, list const & decls) { +pair> sanitize_level_params(level_param_names const & ls, list const & decls) { name_set globals; for (auto const & d : decls) { collect_global_levels(inductive_decl_type(d), globals); diff --git a/src/library/level_names.h b/src/library/level_names.h index edd53467d..c9f850d09 100644 --- a/src/library/level_names.h +++ b/src/library/level_names.h @@ -18,6 +18,6 @@ declaration sanitize_level_params(declaration const & d); \brief Return new level parameters and inductive decls equivalent to \c decls, but where level parameter names do not conflict with global parameter names also used in \c decls. */ -std::pair> sanitize_level_params(level_param_names const & ls, - list const & decls); +pair> sanitize_level_params(level_param_names const & ls, + list const & decls); } diff --git a/src/library/match.cpp b/src/library/match.cpp index 1136e1292..d6991413f 100644 --- a/src/library/match.cpp +++ b/src/library/match.cpp @@ -38,7 +38,7 @@ class match_fn : public match_context { name_generator m_ngen; name_map * m_name_subst; match_plugin const * m_plugin; - buffer> m_stack; + buffer> m_stack; buffer m_scopes; void push() { diff --git a/src/library/module.cpp b/src/library/module.cpp index 5e581a090..fa585fed4 100644 --- a/src/library/module.cpp +++ b/src/library/module.cpp @@ -33,7 +33,7 @@ corrupted_file_exception::corrupted_file_exception(std::string const & fname): exception(sstream() << "failed to import '" << fname << "', file is corrupted") { } -typedef std::pair> writer; +typedef pair> writer; struct module_ext : public environment_extension { list m_direct_imports; diff --git a/src/library/private.cpp b/src/library/private.cpp index 109eeeb7d..57ca654ae 100644 --- a/src/library/private.cpp +++ b/src/library/private.cpp @@ -40,7 +40,7 @@ static environment preserve_private_data(environment const & env, name const & r return module::add(env, g_prv_key, [=](serializer & s) { s << n << r; }); } -std::pair add_private_name(environment const & env, name const & n, optional const & extra_hash) { +pair add_private_name(environment const & env, name const & n, optional const & extra_hash) { private_ext ext = get_extension(env); unsigned h = hash(n.hash(), ext.m_counter); if (extra_hash) diff --git a/src/library/private.h b/src/library/private.h index ae47f4e4e..19ae68edd 100644 --- a/src/library/private.h +++ b/src/library/private.h @@ -21,7 +21,7 @@ namespace lean { The mapping between \c n and the "hidden" name is saved in the .olean files. */ -std::pair add_private_name(environment const & env, name const & n, optional const & base_hash); +pair add_private_name(environment const & env, name const & n, optional const & base_hash); /** \brief Return the user name associated with the hidden name \c n. diff --git a/src/library/rewriter/rewriter.cpp b/src/library/rewriter/rewriter.cpp index 73285591e..1a1a27c77 100644 --- a/src/library/rewriter/rewriter.cpp +++ b/src/library/rewriter/rewriter.cpp @@ -24,7 +24,6 @@ using std::endl; using std::initializer_list; using std::make_pair; using std::ostream; -using std::pair; namespace lean { diff --git a/src/library/simplifier/congr.cpp b/src/library/simplifier/congr.cpp index c0736969d..8ef76fe41 100644 --- a/src/library/simplifier/congr.cpp +++ b/src/library/simplifier/congr.cpp @@ -49,7 +49,7 @@ static buffer::iterator find_arg_info(buffer & arg_i }); } -static std::pair find_hypothesis(buffer & arg_infos, unsigned vidx, unsigned num) { +static pair find_hypothesis(buffer & arg_infos, unsigned vidx, unsigned num) { for (auto const & info : arg_infos) { if (vidx == info.get_pos_at_proof()) { return mk_pair(info.get_arg_pos(), false); @@ -162,7 +162,7 @@ congr_theorem_info check_congr_theorem(ro_environment const & env, expr const & << " does not match conclusion of the theorem"); if (!it->m_proof_proof_pos) { bool ctx_pos; - std::pair p; + pair p; if (is_var(abst_domain(d))) { ctx_pos = true; p = find_hypothesis(arg_infos, num - var_idx(abst_domain(d)) - 1, num); diff --git a/src/library/tactic/tactic.cpp b/src/library/tactic/tactic.cpp index c462bfeb4..1462f8430 100644 --- a/src/library/tactic/tactic.cpp +++ b/src/library/tactic/tactic.cpp @@ -103,7 +103,7 @@ tactic trace_tactic(char const * msg) { return trace_tactic(std::string(msg)); } -tactic trace_state_tactic(std::string const & fname, std::pair const & pos) { +tactic trace_state_tactic(std::string const & fname, pair const & pos) { return tactic1([=](environment const & env, io_state const & ios, proof_state const & s) -> proof_state { diagnostic(env, ios) << fname << ":" << pos.first << ":" << pos.second << ": proof state\n" << s << endl; diff --git a/src/library/tactic/tactic.h b/src/library/tactic/tactic.h index b9de389a1..fee055c6c 100644 --- a/src/library/tactic/tactic.h +++ b/src/library/tactic/tactic.h @@ -52,7 +52,7 @@ class sstream; tactic trace_tactic(sstream const & msg); tactic trace_tactic(std::string const & msg); /** \brief Return a tactic that just displays the input state in the diagnostic channel. */ -tactic trace_state_tactic(std::string const & fname, std::pair const & pos); +tactic trace_state_tactic(std::string const & fname, pair const & pos); tactic trace_state_tactic(); /** \brief Create a tactic that applies \c t, but suppressing diagnostic messages. */ tactic suppress_trace(tactic const & t); diff --git a/src/library/unifier.cpp b/src/library/unifier.cpp index 5ad2c11fa..3558dbccc 100644 --- a/src/library/unifier.cpp +++ b/src/library/unifier.cpp @@ -241,7 +241,7 @@ cnstr_group get_choice_cnstr_group(constraint const & c) { /** \brief Auxiliary functional object for implementing simultaneous higher-order unification */ struct unifier_fn { - typedef std::pair cnstr; // constraint + idx + typedef pair cnstr; // constraint + idx struct cnstr_cmp { int operator()(cnstr const & c1, cnstr const & c2) const { return c1.second < c2.second ? -1 : (c1.second == c2.second ? 0 : 1); } }; @@ -653,7 +653,7 @@ struct unifier_fn { return is_eq_cnstr(c) && is_eq_deltas(cnstr_lhs_expr(c), cnstr_rhs_expr(c)); } - std::pair instantiate_metavars(constraint const & c) { + pair instantiate_metavars(constraint const & c) { if (is_eq_cnstr(c)) { auto lhs_jst = m_subst.instantiate_metavars(cnstr_lhs_expr(c)); auto rhs_jst = m_subst.instantiate_metavars(cnstr_rhs_expr(c)); diff --git a/src/tests/util/format.cpp b/src/tests/util/format.cpp index 7b6f33b18..225c400c5 100644 --- a/src/tests/util/format.cpp +++ b/src/tests/util/format.cpp @@ -41,7 +41,7 @@ static void tst1() { format("c"), format("d")}); - std::vector > v = + std::vector> v = {{"f1", f1}, {"f2", f2}, {"f3", f3}, @@ -57,7 +57,7 @@ static void tst1() { }; std::for_each(v.begin(), v.end(), - [](std::pair const & p) { + [](pair const & p) { cout << "---- " << p.first << " ----------" << endl << p.second << endl << "--------------------" << endl << endl; diff --git a/src/tests/util/list.cpp b/src/tests/util/list.cpp index e70a81f2f..12135b612 100644 --- a/src/tests/util/list.cpp +++ b/src/tests/util/list.cpp @@ -148,7 +148,7 @@ static void tst11(int sz, int num) { } static void tst12() { - list> l; + list> l; lean_assert(is_nil(l)); l.emplace_front(20, "world"); l.emplace_front(10, "hello"); diff --git a/src/util/lazy_list.h b/src/util/lazy_list.h index 9511d734f..174fbad51 100644 --- a/src/util/lazy_list.h +++ b/src/util/lazy_list.h @@ -9,6 +9,7 @@ Author: Leonardo de Moura #include "util/debug.h" #include "util/rc.h" #include "util/optional.h" +#include "util/pair.h" namespace lean { /** @@ -17,7 +18,7 @@ namespace lean { template class lazy_list { public: - typedef optional> maybe_pair; // head and tail pair + typedef optional> maybe_pair; // head and tail pair private: class cell_base { MK_LEAN_RC(); diff --git a/src/util/list_fn.h b/src/util/list_fn.h index f14d7c446..f7804b392 100644 --- a/src/util/list_fn.h +++ b/src/util/list_fn.h @@ -66,7 +66,7 @@ list reverse(list const & l) { append(l1, l2) == l */ template -std::pair, list> split(list const & l) { +pair, list> split(list const & l) { if (is_nil(l)) { return mk_pair(l, l); } else if (is_nil(cdr(l))) { @@ -87,7 +87,7 @@ std::pair, list> split(list const & l) { append(l1, reverse(l2)) == l */ template -std::pair, list> split_reverse_second(list const & l) { +pair, list> split_reverse_second(list const & l) { if (is_nil(l)) { return mk_pair(l, l); } else if (is_nil(cdr(l))) { diff --git a/src/util/lua_pair.h b/src/util/lua_pair.h index 0dacb274e..e6488d0a4 100644 --- a/src/util/lua_pair.h +++ b/src/util/lua_pair.h @@ -10,9 +10,9 @@ Author: Leonardo de Moura namespace lean { #define DEFINE_LUA_PAIR_CORE(T1, PushVal1, ToVal1, T2, PushVal2, ToVal2, MK_Name, IS_Name) \ -typedef std::pair pair_ ## T1 ## _ ## T2; \ +typedef pair pair_ ## T1 ## _ ## T2; \ DECL_UDATA(pair_ ## T1 ## _ ## T2) \ -std::pair to_pair_ ## T1 ## _ ## T2 ## _ext(lua_State * L, int idx) { \ +pair to_pair_ ## T1 ## _ ## T2 ## _ext(lua_State * L, int idx) { \ if (is_pair_ ## T1 ## _ ## T2(L, idx)) { \ return to_pair_ ## T1 ## _ ## T2(L, idx); \ } else if (lua_istable(L, idx)) { \ @@ -22,14 +22,14 @@ std::pair to_pair_ ## T1 ## _ ## T2 ## _ext(lua_State * L, int idx) { \ throw exception(sstream() << "arg #" << idx << " must be a table of size 2"); \ lua_rawgeti(L, -1, 1); \ lua_rawgeti(L, -2, 2); \ - std::pair r(ToVal1(L, -2), ToVal2(L, -1)); \ + pair r(ToVal1(L, -2), ToVal2(L, -1)); \ lua_pop(L, 3); \ return r; \ } else { \ throw exception(sstream() << "arg #" << idx << " must be a pair or a Lua table"); \ } \ } \ -static int pair_ ## T1 ## _ ## T2 ## _mk(lua_State * L) { return push_pair_ ## T1 ## _ ## T2(L, std::pair(ToVal1(L, 1), ToVal2(L, 2))); } \ +static int pair_ ## T1 ## _ ## T2 ## _mk(lua_State * L) { return push_pair_ ## T1 ## _ ## T2(L, pair(ToVal1(L, 1), ToVal2(L, 2))); } \ static int pair_ ## T1 ## _ ## T2 ## _first(lua_State * L) { return PushVal1(L, to_pair_ ## T1 ## _ ## T2(L, 1).first); } \ static int pair_ ## T1 ## _ ## T2 ## _second(lua_State * L) { return PushVal2(L, to_pair_ ## T1 ## _ ## T2(L, 1).second); } \ static const struct luaL_Reg pair_ ## T1 ## _ ## T2 ## _m[] = { \ @@ -53,7 +53,7 @@ static void open_pair_ ## T1 ## _ ## T2 (lua_State * L) { \ // A Pair (T, T) #define DEFINE_LUA_HOMO_PAIR(T, PushVal, ToVal) DEFINE_LUA_PAIR_CORE(T, PushVal, ToVal, T, PushVal, ToVal, "pair_" #T, "is_pair_" #T) \ static void open_pair_ ## T(lua_State * L) { open_pair_ ## T ## _ ## T(L); } \ -std::pair & to_pair_ ## T(lua_State * L, int idx) { return to_pair_ ## T ## _ ## T(L, idx); } \ -std::pair to_pair_ ## T ## _ext(lua_State * L, int idx) { return to_pair_ ## T ## _ ## T ## _ext(L, idx); } \ -int push_pair_ ## T(lua_State * L, std::pair const & p) { return push_pair_ ## T ## _ ## T(L, p); } +pair & to_pair_ ## T(lua_State * L, int idx) { return to_pair_ ## T ## _ ## T(L, idx); } \ +pair to_pair_ ## T ## _ext(lua_State * L, int idx) { return to_pair_ ## T ## _ ## T ## _ext(L, idx); } \ +int push_pair_ ## T(lua_State * L, pair const & p) { return push_pair_ ## T ## _ ## T(L, p); } } diff --git a/src/util/name.h b/src/util/name.h index 3fec74209..3d1910941 100644 --- a/src/util/name.h +++ b/src/util/name.h @@ -10,6 +10,7 @@ Author: Leonardo de Moura #include #include #include +#include "util/pair.h" #include "util/lua.h" #include "util/serializer.h" #include "util/optional.h" @@ -171,7 +172,7 @@ inline bool independent(name const & a, name const & b) { return !is_prefix_of(a, b) && !is_prefix_of(b, a); } -typedef std::pair name_pair; +typedef pair name_pair; struct name_pair_quick_cmp { int operator()(name_pair const & p1, name_pair const & p2) const { int r = cmp(p1.first, p2.first); diff --git a/src/util/pair.h b/src/util/pair.h index ccf1fb2a3..92e681ae7 100644 --- a/src/util/pair.h +++ b/src/util/pair.h @@ -8,9 +8,12 @@ Author: Leonardo de Moura #include namespace lean { +template +using pair = typename std::pair; + /** \brief Alias for make_pair */ template -inline std::pair mk_pair(T1 const & v1, T2 const & v2) { +inline pair mk_pair(T1 const & v1, T2 const & v2) { return std::make_pair(v1, v2); } } diff --git a/src/util/polynomial/polynomial.h b/src/util/polynomial/polynomial.h index 27b5cbfb1..2dd5c5c40 100644 --- a/src/util/polynomial/polynomial.h +++ b/src/util/polynomial/polynomial.h @@ -10,10 +10,10 @@ Author: Leonardo de Moura namespace lean { -class power : public std::pair { +class power : public pair { public: typedef unsigned var; - power(var v, unsigned d):std::pair(v, d) {} + power(var v, unsigned d):pair(v, d) {} var get_var() const { return first; } void set_var(var x) { first = x; } unsigned degree() const { return second; } diff --git a/src/util/rb_map.h b/src/util/rb_map.h index e097b294a..fe959cc58 100644 --- a/src/util/rb_map.h +++ b/src/util/rb_map.h @@ -17,7 +17,7 @@ namespace lean { template class rb_map : public CMP { public: - typedef std::pair entry; + typedef pair entry; private: struct entry_cmp : public CMP { entry_cmp(CMP const & c):CMP(c) {} diff --git a/src/util/scoped_map.h b/src/util/scoped_map.h index a5e976e4a..3524960d9 100644 --- a/src/util/scoped_map.h +++ b/src/util/scoped_map.h @@ -11,6 +11,7 @@ Author: Leonardo de Moura #include #include #include "util/debug.h" +#include "util/pair.h" #ifndef LEAN_SCOPED_MAP_INITIAL_BUCKET_SIZE #define LEAN_SCOPED_MAP_INITIAL_BUCKET_SIZE 8 @@ -26,9 +27,9 @@ class scoped_map { typedef typename map::size_type size_type; typedef typename map::value_type value_type; enum class action_kind { Insert, Replace, Erase }; - map m_map; - std::vector> m_actions; - std::vector m_scopes; + map m_map; + std::vector> m_actions; + std::vector m_scopes; public: explicit scoped_map(size_type bucket_count = LEAN_SCOPED_MAP_INITIAL_BUCKET_SIZE, const Hash& hash = Hash(), diff --git a/src/util/scoped_set.h b/src/util/scoped_set.h index f9d9ce78e..256da1041 100644 --- a/src/util/scoped_set.h +++ b/src/util/scoped_set.h @@ -10,6 +10,7 @@ Author: Leonardo de Moura #include #include #include "util/debug.h" +#include "util/pair.h" #ifndef LEAN_SCOPED_SET_INITIAL_BUCKET_SIZE #define LEAN_SCOPED_SET_INITIAL_BUCKET_SIZE 8 @@ -24,9 +25,9 @@ class scoped_set { typedef std::unordered_set set; typedef typename set::size_type size_type; enum class action_kind { Insert, Erase }; - set m_set; - std::vector> m_actions; - std::vector m_scopes; + set m_set; + std::vector> m_actions; + std::vector m_scopes; public: explicit scoped_set(size_type bucket_count = LEAN_SCOPED_SET_INITIAL_BUCKET_SIZE, const Hash& hash = Hash(), diff --git a/src/util/sexpr/format.cpp b/src/util/sexpr/format.cpp index ed62ac299..0fbed3efa 100644 --- a/src/util/sexpr/format.cpp +++ b/src/util/sexpr/format.cpp @@ -194,7 +194,7 @@ struct space_exceeded {}; /** \brief Return true iff the space upto line break fits in the available space. */ -bool format::space_upto_line_break_list_exceeded(sexpr const & s, int available, std::vector> const & todo) { +bool format::space_upto_line_break_list_exceeded(sexpr const & s, int available, std::vector> const & todo) { try { bool found_newline = false; available -= space_upto_line_break(s, available, found_newline); @@ -271,7 +271,7 @@ format operator^(format const & f1, format const & f2) { std::ostream & format::pretty(std::ostream & out, unsigned w, bool colors, format const & f) { unsigned pos = 0; - std::vector> todo; + std::vector> todo; todo.push_back(std::make_pair(f.m_value, 0)); while (!todo.empty()) { auto pair = todo.back(); @@ -346,7 +346,7 @@ std::ostream & operator<<(std::ostream & out, format const & f) { return pretty(out, LEAN_DEFAULT_PP_WIDTH, LEAN_DEFAULT_PP_COLORS, f); } -std::ostream & operator<<(std::ostream & out, std::pair const & p) { +std::ostream & operator<<(std::ostream & out, pair const & p) { return pretty(out, p.second, p.first); } diff --git a/src/util/sexpr/format.h b/src/util/sexpr/format.h index bf79deb0e..2a18de6a1 100644 --- a/src/util/sexpr/format.h +++ b/src/util/sexpr/format.h @@ -125,7 +125,7 @@ private: } // Functions used inside of pretty printing - static bool space_upto_line_break_list_exceeded(sexpr const & s, int available, std::vector> const & todo); + static bool space_upto_line_break_list_exceeded(sexpr const & s, int available, std::vector> const & todo); static int space_upto_line_break(sexpr const & s, int available, bool & found); static bool is_fnil(format const & f) { @@ -217,7 +217,7 @@ public: friend std::ostream & pretty(std::ostream & out, options const & o, format const & f); friend std::ostream & operator<<(std::ostream & out, format const & f); - friend std::ostream & operator<<(std::ostream & out, std::pair const & p); + friend std::ostream & operator<<(std::ostream & out, pair const & p); /** \brief Return true iff f is just a name */ friend bool is_name(format const & f) { return format::is_text(f) && ::lean::is_name(cdr(f.m_value)); } diff --git a/src/util/splay_map.h b/src/util/splay_map.h index a19d623eb..e3465b9e6 100644 --- a/src/util/splay_map.h +++ b/src/util/splay_map.h @@ -17,7 +17,7 @@ namespace lean { template class splay_map : public CMP { public: - typedef std::pair entry; + typedef pair entry; private: struct entry_cmp : public CMP { entry_cmp(CMP const & c):CMP(c) {} diff --git a/src/util/thread_script_state.cpp b/src/util/thread_script_state.cpp index 2e65ca725..a937a599c 100644 --- a/src/util/thread_script_state.cpp +++ b/src/util/thread_script_state.cpp @@ -13,7 +13,7 @@ Author: Leonardo de Moura namespace lean { static mutex g_code_mutex; -static std::vector> g_code; +static std::vector> g_code; static mutex g_state_mutex; static std::vector g_states; static std::vector g_available_states;