2013-11-21 01:02:41 +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 <utility>
|
|
|
|
#include <vector>
|
2013-11-27 03:15:49 +00:00
|
|
|
#include "util/lua.h"
|
2013-11-21 01:02:41 +00:00
|
|
|
#include "util/list.h"
|
|
|
|
#include "util/name.h"
|
2013-11-22 00:44:31 +00:00
|
|
|
#include "kernel/formatter.h"
|
2013-11-21 01:02:41 +00:00
|
|
|
#include "kernel/expr.h"
|
|
|
|
#include "kernel/context.h"
|
|
|
|
#include "kernel/environment.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2013-11-25 09:06:11 +00:00
|
|
|
typedef std::pair<name, expr> hypothesis;
|
|
|
|
typedef list<hypothesis> hypotheses;
|
2013-11-21 01:02:41 +00:00
|
|
|
class goal {
|
2013-11-25 09:06:11 +00:00
|
|
|
hypotheses m_hypotheses;
|
|
|
|
expr m_conclusion;
|
2013-11-21 01:02:41 +00:00
|
|
|
public:
|
2013-11-21 23:31:55 +00:00
|
|
|
goal() {}
|
2013-11-25 09:06:11 +00:00
|
|
|
goal(hypotheses const & hs, expr const & c);
|
|
|
|
hypotheses const & get_hypotheses() const { return m_hypotheses; }
|
2013-11-21 01:02:41 +00:00
|
|
|
expr const & get_conclusion() const { return m_conclusion; }
|
2013-11-22 00:44:31 +00:00
|
|
|
format pp(formatter const & fmt, options const & opts) const;
|
2013-11-25 00:29:04 +00:00
|
|
|
name mk_unique_hypothesis_name(name const & suggestion) const;
|
2013-11-21 01:02:41 +00:00
|
|
|
};
|
|
|
|
|
2013-11-25 09:06:11 +00:00
|
|
|
inline goal update(goal const & g, expr const & c) { return goal(g.get_hypotheses(), c); }
|
|
|
|
inline goal update(goal const & g, hypotheses const & hs) { return goal(hs, g.get_conclusion()); }
|
|
|
|
inline goal update(goal const & g, buffer<hypothesis> const & hs) { return goal(to_list(hs.begin(), hs.end()), g.get_conclusion()); }
|
|
|
|
inline hypotheses add_hypothesis(name const & h_name, expr const & h, hypotheses const & hs) {
|
|
|
|
return cons(mk_pair(h_name, h), hs);
|
|
|
|
}
|
|
|
|
inline hypotheses add_hypothesis(hypothesis const & h, hypotheses const & hs) {
|
|
|
|
return cons(h, hs);
|
|
|
|
}
|
|
|
|
|
2013-11-21 01:02:41 +00:00
|
|
|
/**
|
|
|
|
\brief Functor for converting a proof for a goal \c g produced using <tt>to_goal(env, ctx, T)</tt>
|
|
|
|
into a term of type \c t.
|
|
|
|
|
|
|
|
That is, the goal was created to synthesize a proof term for a proposition/type \c T in a
|
|
|
|
context \c ctx. This functor allows us to convert a proof for \c g into a term/expression \c p
|
|
|
|
s.t. <tt>ctx |- p : T</t>
|
|
|
|
*/
|
|
|
|
class goal_proof_fn {
|
2013-12-13 00:33:31 +00:00
|
|
|
friend std::pair<goal, goal_proof_fn> to_goal(ro_environment const & env, context const & ctx, expr const & t);
|
2013-11-21 01:02:41 +00:00
|
|
|
std::vector<expr> m_constants;
|
|
|
|
goal_proof_fn(std::vector<expr> && constants);
|
|
|
|
public:
|
2013-11-21 20:34:37 +00:00
|
|
|
expr operator()(expr const & pr) const;
|
2013-11-21 01:02:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Convert the synthesis problem <tt>ctx |- ?p : T</tt> into a goal,
|
|
|
|
where \c T is a proposition (i.e., has type Boolean), and \c ?p is a proof we want to synthesize.
|
|
|
|
|
|
|
|
We can use tactics for solving the resultant goal, and the functor \c goal_proof_fn
|
|
|
|
to convert the proof for the goal into the proof term \c ?p.
|
|
|
|
*/
|
2013-12-13 00:33:31 +00:00
|
|
|
std::pair<goal, goal_proof_fn> to_goal(ro_environment const & env, context const & ctx, expr const & t);
|
2013-11-27 03:15:49 +00:00
|
|
|
|
|
|
|
UDATA_DEFS_CORE(hypotheses)
|
|
|
|
UDATA_DEFS(goal)
|
|
|
|
void open_goal(lua_State * L);
|
2013-11-21 01:02:41 +00:00
|
|
|
}
|