2013-07-29 05:34:39 +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 <iostream>
|
2013-09-13 23:14:24 +00:00
|
|
|
#include <algorithm>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/name.h"
|
|
|
|
#include "util/sexpr/format.h"
|
|
|
|
#include "util/sexpr/options.h"
|
2013-07-29 05:34:39 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
class environment;
|
|
|
|
struct level_cell;
|
|
|
|
enum class level_kind { UVar, Lift, Max };
|
|
|
|
/**
|
|
|
|
\brief Universe level.
|
|
|
|
*/
|
|
|
|
class level {
|
|
|
|
friend class environment;
|
|
|
|
level_cell * m_ptr;
|
2013-07-30 02:44:26 +00:00
|
|
|
/** \brief Private constructor used by the environment to create a new universe variable named \c n with internal id \c u. */
|
2013-08-02 01:52:28 +00:00
|
|
|
level(level const & l, unsigned k);
|
|
|
|
level(level_cell * ptr);
|
|
|
|
friend level to_level(level_cell * c);
|
|
|
|
friend level_cell * to_cell(level const & l);
|
|
|
|
friend level operator+(level const & l, unsigned k);
|
2013-07-29 05:34:39 +00:00
|
|
|
public:
|
2013-07-30 02:44:26 +00:00
|
|
|
/** \brief Universe 0 */
|
2013-07-29 05:34:39 +00:00
|
|
|
level();
|
2013-08-05 22:17:58 +00:00
|
|
|
level(name const & n);
|
2013-07-29 05:34:39 +00:00
|
|
|
level(level const & l);
|
|
|
|
level(level&& s);
|
|
|
|
~level();
|
|
|
|
|
2013-07-30 02:44:26 +00:00
|
|
|
unsigned hash() const;
|
|
|
|
|
2013-08-08 02:10:12 +00:00
|
|
|
bool is_bottom() const;
|
|
|
|
|
2013-07-29 05:34:39 +00:00
|
|
|
friend level_kind kind (level const & l);
|
|
|
|
friend name const & uvar_name (level const & l);
|
|
|
|
friend level const & lift_of (level const & l);
|
|
|
|
friend unsigned lift_offset(level const & l);
|
2013-08-02 01:52:28 +00:00
|
|
|
friend unsigned max_size (level const & l);
|
|
|
|
friend level const & max_level (level const & l, unsigned i);
|
2013-07-29 05:34:39 +00:00
|
|
|
|
|
|
|
level & operator=(level const & l);
|
|
|
|
level & operator=(level&& l);
|
|
|
|
|
|
|
|
friend bool operator==(level const & l1, level const & l2);
|
|
|
|
friend bool operator!=(level const & l1, level const & l2) { return !operator==(l1, l2); }
|
2013-09-24 19:16:32 +00:00
|
|
|
friend bool operator<(level const & l1, level const & l2);
|
2013-07-29 05:34:39 +00:00
|
|
|
friend void swap(level & l1, level & l2) { std::swap(l1, l2); }
|
|
|
|
|
|
|
|
friend std::ostream & operator<<(std::ostream & out, level const & l);
|
|
|
|
};
|
2013-08-02 01:52:28 +00:00
|
|
|
|
|
|
|
level max(level const & l1, level const & l2);
|
|
|
|
level max(std::initializer_list<level> const & l);
|
|
|
|
level operator+(level const & l, unsigned k);
|
|
|
|
|
2013-11-13 21:54:03 +00:00
|
|
|
inline bool is_bottom(level const & l) { return l.is_bottom(); }
|
|
|
|
inline bool is_uvar(level const & l) { return kind(l) == level_kind::UVar; }
|
|
|
|
inline bool is_lift(level const & l) { return kind(l) == level_kind::Lift; }
|
|
|
|
inline bool is_max (level const & l) { return kind(l) == level_kind::Max; }
|
2013-08-02 01:52:28 +00:00
|
|
|
|
2013-09-04 06:15:37 +00:00
|
|
|
/** \brief Return a */
|
2013-08-02 01:52:28 +00:00
|
|
|
inline level const * max_begin_levels(level const & l) { return &max_level(l, 0); }
|
|
|
|
inline level const * max_end_levels(level const & l) { return max_begin_levels(l) + max_size(l); }
|
2013-08-08 02:10:12 +00:00
|
|
|
|
2013-09-04 06:15:37 +00:00
|
|
|
/** \brief Pretty print the given level expression, unicode characters are used if \c unicode is \c true. */
|
2013-09-03 17:09:19 +00:00
|
|
|
format pp(level const & l, bool unicode);
|
2013-09-04 06:15:37 +00:00
|
|
|
/** \brief Pretty print the given level expression using the given configuration options. */
|
2013-09-03 17:09:19 +00:00
|
|
|
format pp(level const & l, options const & opts = options());
|
2013-07-29 05:34:39 +00:00
|
|
|
}
|
2013-08-19 01:25:34 +00:00
|
|
|
void print(lean::level const & l);
|