2015-06-19 00:57:17 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "kernel/environment.h"
|
|
|
|
namespace lean {
|
2015-07-01 23:01:40 +00:00
|
|
|
struct tc_edge {
|
|
|
|
name m_from;
|
|
|
|
name m_cnst; // constant representing the edge in the environment
|
|
|
|
name m_to;
|
|
|
|
tc_edge(name const & from, name const & e, name const & to):
|
|
|
|
m_from(from), m_cnst(e), m_to(to) {}
|
|
|
|
};
|
|
|
|
|
2015-06-19 00:57:17 +00:00
|
|
|
/** \brief Transitive closed multigraph */
|
|
|
|
class tc_multigraph {
|
2015-06-21 03:23:34 +00:00
|
|
|
name m_kind;
|
2015-06-19 00:57:17 +00:00
|
|
|
name_map<list<pair<name, name>>> m_successors;
|
|
|
|
name_map<list<name>> m_predecessors;
|
|
|
|
name_map<name> m_edges;
|
2015-06-21 03:23:34 +00:00
|
|
|
pair<name, name> validate(environment const & env, name const & e, unsigned num_args);
|
|
|
|
friend struct add_edge_fn;
|
2015-06-19 00:57:17 +00:00
|
|
|
public:
|
2015-06-21 03:23:34 +00:00
|
|
|
tc_multigraph(name const & kind):m_kind(kind) {}
|
2015-07-01 23:01:40 +00:00
|
|
|
/** \brief Add a new edge, and return updated environment, and list of transitive edges added to the graph. */
|
|
|
|
pair<environment, list<tc_edge>> add(environment const & env, name const & src, name const & e, name const & tgt);
|
2015-06-30 00:45:08 +00:00
|
|
|
void add1(environment const & env, name const & src, name const & e, name const & tgt);
|
2015-06-19 00:57:17 +00:00
|
|
|
void erase(name const & e);
|
|
|
|
bool is_edge(name const & e) const;
|
|
|
|
bool is_node(name const & c) const;
|
|
|
|
list<pair<name, name>> get_successors(name const & c) const;
|
|
|
|
list<name> get_predecessors(name const & c) const;
|
|
|
|
};
|
|
|
|
}
|