2013-07-30 07:25:19 +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
|
|
|
|
#include "expr.h"
|
|
|
|
#include "list.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2013-07-30 08:39:29 +00:00
|
|
|
class context_entry;
|
|
|
|
typedef list<context_entry> context;
|
2013-07-30 07:25:19 +00:00
|
|
|
class context_entry {
|
2013-07-30 08:39:29 +00:00
|
|
|
name m_name;
|
2013-08-14 19:11:08 +00:00
|
|
|
expr m_domain;
|
2013-07-30 08:39:29 +00:00
|
|
|
expr m_body;
|
2013-08-14 19:11:08 +00:00
|
|
|
friend context extend(context const & c, name const & n, expr const & d, expr const & b);
|
|
|
|
friend context extend(context const & c, name const & n, expr const & d);
|
|
|
|
context_entry(name const & n, expr const & d, expr const & b):m_name(n), m_domain(d), m_body(b) {}
|
|
|
|
context_entry(name const & n, expr const & d):m_name(n), m_domain(d) {}
|
2013-07-30 08:39:29 +00:00
|
|
|
public:
|
2013-07-30 07:25:19 +00:00
|
|
|
~context_entry() {}
|
2013-08-14 19:11:08 +00:00
|
|
|
name const & get_name() const { return m_name; }
|
|
|
|
expr const & get_domain() const { return m_domain; }
|
|
|
|
expr const & get_body() const { return m_body; }
|
2013-07-30 07:25:19 +00:00
|
|
|
};
|
2013-07-30 08:39:29 +00:00
|
|
|
context const & lookup(context const & c, unsigned i);
|
2013-08-14 19:11:08 +00:00
|
|
|
inline context extend(context const & c, name const & n, expr const & d, expr const & b) {
|
|
|
|
return context(context_entry(n, d, b), c);
|
2013-07-30 08:39:29 +00:00
|
|
|
}
|
2013-08-14 19:11:08 +00:00
|
|
|
inline context extend(context const & c, name const & n, expr const & d) {
|
|
|
|
return context(context_entry(n, d), c);
|
2013-07-30 08:39:29 +00:00
|
|
|
}
|
2013-08-05 01:26:01 +00:00
|
|
|
inline bool empty(context const & c) {
|
|
|
|
return is_nil(c);
|
|
|
|
}
|
2013-08-14 02:12:23 +00:00
|
|
|
class expr_formatter;
|
|
|
|
format pp(expr_formatter & f, context const & c);
|
2013-07-30 08:39:29 +00:00
|
|
|
std::ostream & operator<<(std::ostream & out, context const & c);
|
2013-07-30 07:25:19 +00:00
|
|
|
}
|