2014-01-13 01:45:24 +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 "util/lua.h"
|
|
|
|
#include "kernel/expr.h"
|
2014-01-19 18:32:06 +00:00
|
|
|
#include "kernel/environment.h"
|
2014-01-13 01:45:24 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-01-14 02:06:23 +00:00
|
|
|
/**
|
|
|
|
\brief Matching for higher-order patterns. Return true iff \c t matches the higher-order pattern \c p.
|
|
|
|
The substitution is stored in \c subst.
|
|
|
|
|
|
|
|
\c subst is an assignment for the free variables occurring in \c p.
|
|
|
|
|
|
|
|
The free variables occurring in \c t are treated as constants.
|
|
|
|
|
|
|
|
We say non-free variables occurring in \c p and \c t are "locally bound".
|
|
|
|
|
|
|
|
\c p is a higher-order pattern when in all applications in \c p
|
2014-01-25 18:08:53 +00:00
|
|
|
1- A free variable is not the function OR
|
2014-01-14 02:06:23 +00:00
|
|
|
2- A free variable is the function, but all other arguments are distinct locally bound variables.
|
|
|
|
|
|
|
|
\pre \c subst must be big enough to store all free variables occurring in subst
|
2014-01-19 18:32:06 +00:00
|
|
|
|
|
|
|
If an environment is provided, then a constant \c c matches a term \c t if
|
|
|
|
\c c is definitionally equal to \c t.
|
2014-01-28 08:50:27 +00:00
|
|
|
|
2014-01-29 04:30:47 +00:00
|
|
|
If a metavariable environment is provided, then it is provided to lift/lower
|
|
|
|
free variables procedures to be able to minimize the size of the local context.
|
|
|
|
|
2014-01-28 08:50:27 +00:00
|
|
|
If name_subst is different from nullptr, then the procedure stores in name_subst
|
|
|
|
a mapping for binder names. It maps the binder names used in the pattern \c p into
|
|
|
|
the binder names used in \c t.
|
2014-01-14 02:06:23 +00:00
|
|
|
*/
|
2014-01-19 18:32:06 +00:00
|
|
|
bool hop_match(expr const & p, expr const & t, buffer<optional<expr>> & subst,
|
2014-01-28 08:50:27 +00:00
|
|
|
optional<ro_environment> const & env = optional<ro_environment>(),
|
2014-01-29 04:30:47 +00:00
|
|
|
optional<ro_metavar_env> const & menv = optional<ro_metavar_env>(),
|
2014-01-28 08:50:27 +00:00
|
|
|
name_map<name> * name_subst = nullptr);
|
2014-01-13 01:45:24 +00:00
|
|
|
void open_hop_match(lua_State * L);
|
|
|
|
}
|