14c3e11289
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
/*
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Leonardo de Moura
|
|
*/
|
|
#include "library/bin_op.h"
|
|
|
|
namespace lean {
|
|
expr mk_bin_rop(expr const & op, expr const & unit, unsigned num_args, expr const * args) {
|
|
if (num_args == 0) {
|
|
return unit;
|
|
} else {
|
|
expr r = args[num_args - 1];
|
|
unsigned i = num_args - 1;
|
|
while (i > 0) {
|
|
--i;
|
|
r = mk_app({op, args[i], r});
|
|
}
|
|
return r;
|
|
}
|
|
}
|
|
expr mk_bin_rop(expr const & op, expr const & unit, std::initializer_list<expr> const & l) {
|
|
return mk_bin_rop(op, unit, l.size(), l.begin());
|
|
}
|
|
|
|
expr mk_bin_lop(expr const & op, expr const & unit, unsigned num_args, expr const * args) {
|
|
if (num_args == 0) {
|
|
return unit;
|
|
} else {
|
|
expr r = args[0];
|
|
for (unsigned i = 1; i < num_args; i++) {
|
|
r = mk_app({op, r, args[i]});
|
|
}
|
|
return r;
|
|
}
|
|
}
|
|
expr mk_bin_lop(expr const & op, expr const & unit, std::initializer_list<expr> const & l) {
|
|
return mk_bin_lop(op, unit, l.size(), l.begin());
|
|
}
|
|
}
|