2013-07-23 02:31:27 +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-07-24 19:24:49 +00:00
|
|
|
#include <memory>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "kernel/expr.h"
|
2013-07-23 02:31:27 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2013-07-24 19:24:49 +00:00
|
|
|
/**
|
|
|
|
\brief Functional object for creating expressions with maximally
|
|
|
|
shared sub-expressions.
|
|
|
|
*/
|
|
|
|
class max_sharing_fn {
|
|
|
|
struct imp;
|
|
|
|
friend expr max_sharing(expr const & a);
|
2013-09-17 21:42:44 +00:00
|
|
|
std::unique_ptr<imp> m_ptr;
|
2013-07-24 19:24:49 +00:00
|
|
|
public:
|
|
|
|
max_sharing_fn();
|
|
|
|
~max_sharing_fn();
|
|
|
|
|
|
|
|
expr operator()(expr const & a);
|
|
|
|
|
2014-04-23 01:30:07 +00:00
|
|
|
/** \brief Return true iff \c a was already processed by this object. */
|
|
|
|
bool already_processed(expr const & a) const;
|
|
|
|
|
|
|
|
/** \brief Clear the cache. */
|
2013-07-24 19:24:49 +00:00
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
2013-07-23 02:31:27 +00:00
|
|
|
/**
|
2013-07-23 15:59:39 +00:00
|
|
|
\brief The resultant expression is structurally identical to the input one, but
|
|
|
|
it uses maximally shared sub-expressions.
|
2013-07-23 02:31:27 +00:00
|
|
|
*/
|
2013-07-23 15:59:39 +00:00
|
|
|
expr max_sharing(expr const & a);
|
2013-07-23 02:31:27 +00:00
|
|
|
}
|