feat(library/bin_app): add simpler is_bin_app predicate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
7c0cc3111a
commit
e644419463
2 changed files with 7 additions and 1 deletions
|
@ -7,8 +7,12 @@ Author: Leonardo de Moura
|
|||
#include "library/bin_app.h"
|
||||
|
||||
namespace lean {
|
||||
bool is_bin_app(expr const & t, expr const & f) {
|
||||
return is_app(t) && is_app(app_fn(t)) && app_fn(app_fn(t)) == f;
|
||||
}
|
||||
|
||||
bool is_bin_app(expr const & t, expr const & f, expr & lhs, expr & rhs) {
|
||||
if (is_app(t) && is_app(app_fn(t)) && app_fn(app_fn(t)) == f) {
|
||||
if (is_bin_app(t, f)) {
|
||||
lhs = app_arg(app_fn(t));
|
||||
rhs = app_arg(t);
|
||||
return true;
|
||||
|
|
|
@ -8,6 +8,8 @@ Author: Leonardo de Moura
|
|||
#include "kernel/expr.h"
|
||||
|
||||
namespace lean {
|
||||
/** \brief Return true iff \c t is of the form <tt>((f s1) s2)</tt> */
|
||||
bool is_bin_app(expr const & t, expr const & f);
|
||||
/** \brief Return true iff \c t is of the form <tt>((f s1) s2)</tt>, if the result is true, then store a1 -> lhs, a2 -> rhs */
|
||||
bool is_bin_app(expr const & t, expr const & f, expr & lhs, expr & rhs);
|
||||
|
||||
|
|
Loading…
Reference in a new issue