2013-09-01 23:59:15 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2013-09-13 10:35:29 +00:00
|
|
|
#include <utility>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/hash.h"
|
|
|
|
#include "kernel/expr.h"
|
2014-06-17 19:14:22 +00:00
|
|
|
#include "library/expr_lt.h"
|
2013-09-01 23:59:15 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-08-19 23:28:58 +00:00
|
|
|
typedef pair<expr, expr> expr_pair;
|
2013-09-01 23:59:15 +00:00
|
|
|
/** \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()); }
|
|
|
|
};
|
2013-11-14 10:31:54 +00:00
|
|
|
/** \brief Functional object for hashing expression pairs (based on their allocation time). */
|
|
|
|
struct expr_pair_hash_alloc {
|
|
|
|
unsigned operator()(expr_pair const & p) const { return hash(p.first.hash_alloc(), p.second.hash_alloc()); }
|
|
|
|
};
|
2013-09-01 23:59:15 +00:00
|
|
|
/** \brief Functional object for comparing expression pairs. */
|
|
|
|
struct expr_pair_eq {
|
2014-07-15 03:11:27 +00:00
|
|
|
bool operator()(expr_pair const & p1, expr_pair const & p2) const { return p1.first == p2.first && p1.second == p2.second; }
|
2013-09-01 23:59:15 +00:00
|
|
|
};
|
|
|
|
/** \brief Functional object for comparing expression pairs using pointer equality. */
|
|
|
|
struct expr_pair_eqp {
|
2014-07-15 03:11:27 +00:00
|
|
|
bool operator()(expr_pair const & p1, expr_pair const & p2) const { return is_eqp(p1.first, p2.first) && is_eqp(p1.second, p2.second); }
|
2013-09-01 23:59:15 +00:00
|
|
|
};
|
2014-06-17 19:14:22 +00:00
|
|
|
inline bool is_lt(expr_pair const & p1, expr_pair const & p2, bool use_hash) {
|
|
|
|
return is_lt(p1.first, p2.first, use_hash) || (p1.first == p2.first && is_lt(p1.second, p2.second, use_hash));
|
|
|
|
}
|
|
|
|
struct expr_pair_quick_cmp {
|
|
|
|
int operator()(expr_pair const & p1, expr_pair const & p2) const { return is_lt(p1, p2, true) ? -1 : (p1 == p2 ? 0 : 1); }
|
|
|
|
};
|
2013-09-01 23:59:15 +00:00
|
|
|
}
|