Apply coding style

This commit is contained in:
Soonho Kong 2013-09-13 16:14:24 -07:00
parent 99eaff0b4f
commit bc60b47295
42 changed files with 445 additions and 428 deletions

View file

@ -6,6 +6,7 @@ Author: Leonardo de Moura
*/
#pragma once
#include <memory>
#include <vector>
#include "kernel/environment.h"
#include "library/state.h"
#include "frontends/lean/operator_info.h"

View file

@ -41,7 +41,7 @@ void init_builtin_notation(frontend & f) {
f.add_infix("\u2265", 50, mk_nat_ge_fn()); // ≥
f.add_infix("<", 50, mk_nat_lt_fn());
f.add_infix(">", 50, mk_nat_gt_fn());
f.add_mixfixc({"|","|"}, 55, mk_nat_id_fn()); // absolute value for naturals is the identity function
f.add_mixfixc({"|", "|"}, 55, mk_nat_id_fn()); // absolute value for naturals is the identity function
f.add_infixl("+", 65, mk_int_add_fn());
f.add_infixl("-", 65, mk_int_sub_fn());
@ -50,7 +50,7 @@ void init_builtin_notation(frontend & f) {
f.add_infixl("div", 70, mk_int_div_fn());
f.add_infixl("mod", 70, mk_int_mod_fn());
f.add_infix("|", 50, mk_int_divides_fn());
f.add_mixfixc({"|","|"}, 55, mk_int_abs_fn());
f.add_mixfixc({"|", "|"}, 55, mk_int_abs_fn());
f.add_infix("<=", 50, mk_int_le_fn());
f.add_infix("\u2264", 50, mk_int_le_fn()); // ≤
f.add_infix(">=", 50, mk_int_ge_fn());
@ -63,7 +63,7 @@ void init_builtin_notation(frontend & f) {
f.add_prefix("-", 75, mk_real_neg_fn());
f.add_infixl("*", 70, mk_real_mul_fn());
f.add_infixl("/", 70, mk_real_div_fn());
f.add_mixfixc({"|","|"}, 55, mk_real_abs_fn());
f.add_mixfixc({"|", "|"}, 55, mk_real_abs_fn());
f.add_infix("<=", 50, mk_real_le_fn());
f.add_infix("\u2264", 50, mk_real_le_fn()); // ≤
f.add_infix(">=", 50, mk_real_ge_fn());

View file

@ -1,4 +1,3 @@
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
@ -36,7 +35,6 @@ struct operator_info::imp {
m_precedence == other.m_precedence &&
m_op_parts == other.m_op_parts;
}
};
operator_info::operator_info(imp * p):m_ptr(p) {}

View file

@ -469,7 +469,7 @@ class parser::imp {
this method has been used when parsing mixfix operators.
*/
void check_op_part(name const & op_part) {
if(!curr_is_identifier() || curr_name() != op_part)
if (!curr_is_identifier() || curr_name() != op_part)
throw parser_error(sstream() << "invalid mixfix operator application, '" << op_part << "' expected", pos());
next();
}
@ -569,7 +569,7 @@ class parser::imp {
} else {
return mk_constant(obj.get_name());
}
} if (k == object_kind::Builtin) {
} else if (k == object_kind::Builtin) {
return obj.get_value();
} else {
throw parser_error(sstream() << "invalid object reference, object '" << id << "' is not an expression.", p);

View file

@ -1048,7 +1048,7 @@ class pp_fn {
result r;
if (is_choice(e)) {
return pp_choice(e, depth);
} if (is_lower(e)) {
} else if (is_lower(e)) {
r = pp_lower(e, depth);
} else if (is_lift(e)) {
r = pp_lift(e, depth);

File diff suppressed because it is too large Load diff

View file

@ -61,7 +61,7 @@ inline expr bIf(expr const & c, expr const & t, expr const & e) { return mk_bool
expr mk_implies_fn();
/** \brief Return the term (e1 => e2) */
inline expr mk_implies(expr const & e1, expr const & e2) { return mk_app(mk_implies_fn(), e1, e2); }
inline expr mk_implies(unsigned num_args, expr const * args) { lean_assert(num_args>=2); return mk_bin_rop(mk_implies_fn(), False, num_args, args); }
inline expr mk_implies(unsigned num_args, expr const * args) { lean_assert(num_args >= 2); return mk_bin_rop(mk_implies_fn(), False, num_args, args); }
inline expr Implies(expr const & e1, expr const & e2) { return mk_implies(e1, e2); }
inline expr Implies(std::initializer_list<expr> const & l) { return mk_implies(l.size(), l.begin()); }

View file

@ -157,7 +157,7 @@ struct environment::imp {
}
}
m_constraints.push_back(constraint(u, v, d));
for (constraint const & c: to_add) {
for (constraint const & c : to_add) {
m_constraints.push_back(c);
}
}

View file

@ -5,9 +5,10 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <algorithm>
#include <atomic>
#include <iostream>
#include <limits>
#include <atomic>
#include <utility>
#include "util/rc.h"
#include "util/name.h"

View file

@ -6,6 +6,7 @@ Author: Leonardo de Moura
*/
#pragma once
#include <iostream>
#include <algorithm>
#include "util/name.h"
#include "util/sexpr/format.h"
#include "util/sexpr/options.h"

View file

@ -32,7 +32,7 @@ public:
P is a "post-processing" functional object that is applied to each
pair (old, new)
*/
template<typename F, typename P=default_replace_postprocessor>
template<typename F, typename P = default_replace_postprocessor>
class replace_fn {
static_assert(std::is_same<typename std::result_of<F(expr const &, unsigned)>::type, expr>::value,
"replace_fn: return type of F is not expr");

View file

@ -11,11 +11,16 @@ Author: Leonardo de Moura
#include "library/printer.h"
#include "frontends/lean/parser.h"
#include "version.h"
using namespace lean;
using lean::interruptable_ptr;
using lean::shell;
using lean::frontend;
using lean::scoped_set_interruptable_ptr;
using lean::parser;
static interruptable_ptr<shell> g_lean_shell;
static void on_ctrl_c(int) {
static void on_ctrl_c(int i) {
g_lean_shell.set_interrupt(true);
}

View file

@ -192,9 +192,9 @@ static void tst6() {
env.add_var("list", Type() >> Type());
env.add_var("nil", Pi({A, Type()}, lst(A)));
env.add_var("cons", Pi({{A, Type()}, {a, A}, {l, lst(A)}}, lst(A)));
env.add_var("f", lst(N>>N) >> Bool);
env.add_var("f", lst(N >> N) >> Bool);
success(Fun({a, _}, f(cons(_, a, cons(_, a, nil(_))))),
Fun({a, N>>N}, f(cons(N>>N, a, cons(N>>N, a, nil(N>>N))))), env);
Fun({a, N >> N}, f(cons(N >> N, a, cons(N >> N, a, nil(N >> N))))), env);
}
static void tst7() {

View file

@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <vector>
#include "util/test.h"
#include "kernel/environment.h"
#include "kernel/kernel_exception.h"

View file

@ -1,3 +1,9 @@
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Soonho Kong
*/
#include <string>
using std::cout;
@ -9,7 +15,7 @@ template <typename T1, typename T2, typename F>
void check_interval_bop(std::string const & fname, std::string const & varname, interval<T1> i, T2 c, interval<T1> r, F f) {
cout << fname << "(" << varname << " " << i << ", " << c << ") = ";
cout << r << endl;
if(!i.is_lower_inf()) {
if (!i.is_lower_inf()) {
T1 ll = i.lower();
T1 lu = i.lower();
numeric_traits<T1>::set_rounding(false);
@ -22,7 +28,7 @@ void check_interval_bop(std::string const & fname, std::string const & varname,
lean_assert(r.is_lower_inf() ||
((r.lower() <= lu) && (r.is_upper_inf() || (lu <= r.upper()))));
}
if(!i.is_upper_inf()) {
if (!i.is_upper_inf()) {
T1 ul = i.upper();
T1 uu = i.upper();
numeric_traits<T1>::set_rounding(false);
@ -42,7 +48,7 @@ void check_interval_uop(std::string const & fname, std::string const & varname,
cout.precision(30);
cout << fname << "(" << varname << " " << i << ") = ";
cout << r << endl;
if(!i.is_lower_inf()) {
if (!i.is_lower_inf()) {
T ll = i.lower();
T lu = i.lower();
numeric_traits<T>::set_rounding(false);
@ -55,7 +61,7 @@ void check_interval_uop(std::string const & fname, std::string const & varname,
lean_assert(r.is_lower_inf() ||
((r.lower() <= lu) && (r.is_upper_inf() || (lu <= r.upper()))));
}
if(!i.is_upper_inf()) {
if (!i.is_upper_inf()) {
T ul = i.upper();
T uu = i.upper();
numeric_traits<T>::set_rounding(false);

View file

@ -301,16 +301,16 @@ static void double_interval_inf2() {
lean_assert(c4 - inf == inf); lean_assert(inf - c4 == inf);
lean_assert(zero - inf == inf); lean_assert(inf - zero == inf);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero);lean_assert(inf * zero == zero);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero); lean_assert(inf * zero == zero);
}
static void double_interval_trans() {

View file

@ -301,16 +301,16 @@ static void float_interval_inf2() {
lean_assert(c4 - inf == inf); lean_assert(inf - c4 == inf);
lean_assert(zero - inf == inf); lean_assert(inf - zero == inf);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero);lean_assert(inf * zero == zero);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero); lean_assert(inf * zero == zero);
}
static void float_interval_trans() {

View file

@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <vector>
#include <algorithm>
#include "util/test.h"
#include "util/trace.h"
#include "util/numerics/double.h"

View file

@ -301,16 +301,16 @@ static void mpfp_interval_inf2() {
lean_assert(c4 - inf == inf); lean_assert(inf - c4 == inf);
lean_assert(zero - inf == inf); lean_assert(inf - zero == inf);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero);lean_assert(inf * zero == zero);
lean_assert(i1 * inf == inf); lean_assert(inf * i1 == inf);
lean_assert(i2 * inf == inf); lean_assert(inf * i2 == inf);
lean_assert(i3 * inf == inf); lean_assert(inf * i3 == inf);
lean_assert(i4 * inf == inf); lean_assert(inf * i4 == inf);
lean_assert(i5 * inf == inf); lean_assert(inf * i5 == inf);
lean_assert(c1 * inf == inf); lean_assert(inf * c1 == inf);
lean_assert(c2 * inf == inf); lean_assert(inf * c2 == inf);
lean_assert(c3 * inf == inf); lean_assert(inf * c3 == inf);
lean_assert(c4 * inf == inf); lean_assert(inf * c4 == inf);
lean_assert(zero * inf == zero); lean_assert(inf * zero == zero);
}
static void mpfp_interval_trans() {

View file

@ -6,6 +6,8 @@ Author: Leonardo de Moura
Soonho Kong
*/
#include <algorithm>
#include <utility>
#include <vector>
#include "util/test.h"
#include "kernel/expr.h"
#include "kernel/expr_sets.h"

View file

@ -7,6 +7,8 @@ Author: Soonho Kong
#include <vector>
#include <algorithm>
#include <sstream>
#include <utility>
#include <string>
#include "util/test.h"
#include "util/numerics/mpq.h"
#include "util/sexpr/format.h"

View file

@ -8,7 +8,7 @@ Author: Leonardo de Moura
#include <sstream>
#include "util/test.h"
#include "util/name.h"
using namespace lean;
using namespace lean;
static void tst1() {
name n("foo");

View file

@ -43,5 +43,4 @@ static void tst1() {
int main() {
tst1();
return has_violations() ? 1 : 0;
}

View file

@ -71,24 +71,25 @@ static void driver(unsigned max_sz, unsigned max_val, unsigned num_ops, double u
std::deque<int> q1;
pdeque<int> q2;
pdeque<int> q3;
unsigned int seed;
std::vector<pdeque<int>> copies;
for (unsigned i = 0; i < num_ops; i++) {
double f = static_cast<double>(std::rand() % 10000) / 10000.0;
double f = static_cast<double>(rand_r(&seed) % 10000) / 10000.0;
if (f < copy_freq)
copies.push_back(q3);
// read random positions of q3
if (!empty(q3)) {
for (int j = 0; j < rand() % 5; j++) {
unsigned idx = rand() % size(q3);
for (int j = 0; j < rand_r(&seed) % 5; j++) {
unsigned idx = rand_r(&seed) % size(q3);
lean_assert(q3[idx] == q1[idx]);
}
}
f = static_cast<double>(std::rand() % 10000) / 10000.0;
f = static_cast<double>(rand_r(&seed) % 10000) / 10000.0;
if (f < updt_freq) {
if (q1.size() >= max_sz)
continue;
int v = std::rand() % max_val;
switch (std::rand() % 3) {
int v = rand_r(&seed) % max_val;
switch (rand_r(&seed) % 3) {
case 0:
q1.push_front(v);
q2 = push_front(q2, v);
@ -101,7 +102,7 @@ static void driver(unsigned max_sz, unsigned max_val, unsigned num_ops, double u
break;
default:
if (!empty(q2)) {
unsigned idx = rand() % size(q2);
unsigned idx = rand_r(&seed) % size(q2);
q1[idx] = v;
q2[idx] = v;
q3[idx] = v;
@ -113,7 +114,7 @@ static void driver(unsigned max_sz, unsigned max_val, unsigned num_ops, double u
} else {
if (q1.size() == 0)
continue;
if (std::rand() % 2 == 0) {
if (rand_r(&seed) % 2 == 0) {
lean_assert(front(q2) == q1.front());
lean_assert(front(q3) == q1.front());
q1.pop_front();
@ -159,7 +160,7 @@ static void tst2() {
}
#ifdef PDEQUE_PERF_TEST
#include "timeit.h"
#include "util/timeit.h"
static void perf_deque(unsigned n) {
std::deque<int> q;

View file

@ -6,6 +6,7 @@ Author: Leonardo de Moura
*/
#include <iostream>
#include <cstdlib>
#include <vector>
#include "util/test.h"
#include "util/pvector.h"
#include "util/timeit.h"
@ -65,26 +66,27 @@ static void driver(unsigned max_sz, unsigned max_val, unsigned num_ops, double u
std::vector<int> v1;
pvector<int> v2;
pvector<int> v3;
unsigned int seed;
std::vector<pvector<int>> copies;
for (unsigned i = 0; i < num_ops; i++) {
double f = static_cast<double>(std::rand() % 10000) / 10000.0;
double f = static_cast<double>(rand_r(&seed) % 10000) / 10000.0;
if (f < copy_freq) {
copies.push_back(v2);
}
f = static_cast<double>(std::rand() % 10000) / 10000.0;
f = static_cast<double>(rand_r(&seed) % 10000) / 10000.0;
// read random positions of v3
if (!empty(v3)) {
for (int j = 0; j < rand() % 5; j++) {
unsigned idx = rand() % size(v3);
for (int j = 0; j < rand_r(&seed) % 5; j++) {
unsigned idx = rand_r(&seed) % size(v3);
lean_assert(v3[idx] == v1[idx]);
}
}
if (f < updt_freq) {
if (v1.size() >= max_sz)
continue;
int a = std::rand() % max_val;
if (!empty(v2) && rand()%2 == 0) {
unsigned idx = rand() % size(v2);
int a = rand_r(&seed) % max_val;
if (!empty(v2) && rand_r(&seed)%2 == 0) {
unsigned idx = rand_r(&seed) % size(v2);
v1[idx] = a;
v2[idx] = a;
v3[idx] = a;

View file

@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <sstream>
#include <string>
#include "util/name.h"
#include "util/test.h"
#include "util/numerics/mpq.h"

View file

@ -16,7 +16,7 @@ namespace lean {
This collection is useful when writing functions that need
temporary storage.
*/
template<typename T, unsigned INITIAL_SIZE=16>
template<typename T, unsigned INITIAL_SIZE = 16>
class buffer {
protected:
T * m_buffer;
@ -116,13 +116,12 @@ public:
push_back(elems[i]);
}
void resize(unsigned nsz, T const & elem=T()) {
void resize(unsigned nsz, T const & elem = T()) {
unsigned sz = size();
if (nsz > sz) {
for (unsigned i = sz; i < nsz; i++)
push_back(elem);
}
else if (nsz < sz) {
} else if (nsz < sz) {
for (unsigned i = nsz; i < sz; i++)
pop_back();
}

View file

@ -67,7 +67,7 @@ void invoke_debugger() {
#endif
char result;
std::cin >> result;
switch(result) {
switch (result) {
case 'C':
case 'c':
return;

View file

@ -7,15 +7,15 @@ Author: Leonardo de Moura
namespace lean {
void mix(unsigned & a, unsigned & b, unsigned & c) {
a -= b; a -= c; a ^= (c>>13);
b -= c; b -= a; b ^= (a<<8);
c -= a; c -= b; c ^= (b>>13);
a -= b; a -= c; a ^= (c>>12);
b -= c; b -= a; b ^= (a<<16);
c -= a; c -= b; c ^= (b>>5);
a -= b; a -= c; a ^= (c>>3);
b -= c; b -= a; b ^= (a<<10);
c -= a; c -= b; c ^= (b>>15);
a -= b; a -= c; a ^= (c >> 13);
b -= c; b -= a; b ^= (a << 8);
c -= a; c -= b; c ^= (b >> 13);
a -= b; a -= c; a ^= (c >> 12);
b -= c; b -= a; b ^= (a << 16);
c -= a; c -= b; c ^= (b >> 5);
a -= b; a -= c; a ^= (c >> 3);
b -= c; b -= a; b ^= (a << 10);
c -= a; c -= b; c ^= (b >> 15);
}
// Bob Jenkin's hash function.
@ -39,19 +39,19 @@ unsigned hash_str(unsigned length, char const * str, unsigned init_value) {
/*------------------------------------- handle the last 11 bytes */
c += length;
switch(len) {
switch (len) {
/* all the case statements fall through */
case 11: c+=((unsigned)str[10]<<24);
case 10: c+=((unsigned)str[9]<<16);
case 9 : c+=((unsigned)str[8]<<8);
case 11: c+=((unsigned)str[10] << 24);
case 10: c+=((unsigned)str[9] << 16);
case 9 : c+=((unsigned)str[8] << 8);
/* the first byte of c is reserved for the length */
case 8 : b+=((unsigned)str[7]<<24);
case 7 : b+=((unsigned)str[6]<<16);
case 6 : b+=((unsigned)str[5]<<8);
case 8 : b+=((unsigned)str[7] << 24);
case 7 : b+=((unsigned)str[6] << 16);
case 6 : b+=((unsigned)str[5] << 8);
case 5 : b+=str[4];
case 4 : a+=((unsigned)str[3]<<24);
case 3 : a+=((unsigned)str[2]<<16);
case 2 : a+=((unsigned)str[1]<<8);
case 4 : a+=((unsigned)str[3] << 24);
case 3 : a+=((unsigned)str[2] << 16);
case 2 : a+=((unsigned)str[1] << 8);
case 1 : a+=str[0];
/* case 0: nothing left to add */
}

View file

@ -91,7 +91,7 @@ name::name() {
name::name(name const & prefix, char const * name) {
size_t sz = strlen(name);
lean_assert(sz < 1u<<31);
lean_assert(sz < (1u << 31));
char * mem = new char[sizeof(imp) + sz + 1];
m_ptr = new (mem) imp(true, prefix.m_ptr);
std::memcpy(mem + sizeof(imp), name, sz + 1);

View file

@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <algorithm>
#include "util/bit_tricks.h"
#include "util/numerics/mpz.h"
#include "util/numerics/mpq.h"

View file

@ -41,7 +41,7 @@ inline unsigned necessary_digits(mpfr_prec_t p) {
std::ostream & operator<<(std::ostream & out, mpfp const & v) {
char * s = nullptr;
char format[128];
sprintf(format, "%%.%dRNg", necessary_digits(mpfr_get_prec(v.m_val)));
snprintf(format, sizeof(format), "%%.%dRNg", necessary_digits(mpfr_get_prec(v.m_val)));
mpfr_asprintf(&s, format, v.m_val);
std::string str = std::string(s);
mpfr_free_str(s);

View file

@ -204,7 +204,7 @@ public:
friend int cmp(mpfp const & a, mpf_t const & b ) { return mpfr_cmp_f (a.m_val, b); }
friend int cmp(mpfp const & a, mpz const & b ) { return mpfr_cmp_z (a.m_val, zval(b)); }
friend int cmp(mpfp const & a, mpq const & b ) { return mpfr_cmp_q (a.m_val, qval(b)); }
//friend int cmp(mpfp const & a, mpbq const & b) { return mpfr_cmp_(a.m_val, b); }
// friend int cmp(mpfp const & a, mpbq const & b) { return mpfr_cmp_(a.m_val, b); }
friend bool operator<(mpfp const & a, mpfp const & b ) { return cmp(a, b) < 0; }
friend bool operator<(mpfp const & a, mpz const & b ) { return cmp(a, b) < 0; }

View file

@ -218,7 +218,6 @@ public:
decimal(mpq const & val, unsigned prec = 10):m_val(val), m_prec(prec) {}
friend std::ostream & operator<<(std::ostream & out, decimal const & d) { display_decimal(out, d.m_val, d.m_prec); return out; }
};
};
template<>

View file

@ -156,7 +156,7 @@ class pdeque {
*/
static void flat_core(cell * c, std::deque<T> & r) {
lean_assert(r.empty());
switch(c->kind()) {
switch (c->kind()) {
case cell_kind::PushBack:
flat_core(to_push_back(c).m_prev, r);
r.push_back(to_push_back(c).m_val);

View file

@ -131,7 +131,7 @@ class pvector {
*/
static void flat_core(cell * c, std::vector<T> & r) {
lean_assert(r.empty());
switch(c->kind()) {
switch (c->kind()) {
case cell_kind::PushBack:
flat_core(to_push(c).m_prev, r);
r.push_back(to_push(c).m_val);
@ -390,7 +390,7 @@ void pvector<T>::cell::dealloc() {
template<typename T>
unsigned pvector<T>::cell::size() const {
switch(kind()) {
switch (kind()) {
case cell_kind::PushBack: case cell_kind::PopBack: case cell_kind::Set:
return static_cast<delta_cell const *>(this)->m_size;
case cell_kind::Root:
@ -402,7 +402,7 @@ unsigned pvector<T>::cell::size() const {
template<typename T>
unsigned pvector<T>::cell::quota() const {
switch(kind()) {
switch (kind()) {
case cell_kind::PushBack: case cell_kind::PopBack: case cell_kind::Set:
return static_cast<delta_cell const *>(this)->m_quota;
case cell_kind::Root: {

View file

@ -35,7 +35,7 @@ void dec_ref() { if (dec_ref_core()) dealloc(); }
auto new_ptr = Arg.m_ptr; \
if (m_ptr) \
m_ptr->dec_ref(); \
m_ptr = new_ptr; \
m_ptr = new_ptr; \
return *this;
#define LEAN_MOVE_REF(T, Arg) \

View file

@ -89,7 +89,7 @@ std::ostream & layout(std::ostream & out, bool colors, sexpr const & s) {
case format::format_kind::TEXT:
{
sexpr const & v = cdr(s);
if(is_string(v)) {
if (is_string(v)) {
out << to_string(v);
} else {
out << v;
@ -277,7 +277,7 @@ int format::space_upto_line_break(sexpr const & s, int available, bool & found_n
{
sexpr list = sexpr_compose_list(s);
int len = 0;
while(!is_nil(list) && !found_newline) {
while (!is_nil(list) && !found_newline) {
sexpr const & h = car(list);
list = cdr(list);
len += space_upto_line_break(h, available, found_newline);
@ -311,7 +311,7 @@ sexpr format::be(unsigned w, unsigned k, sexpr const & s) {
/* s = (i, v) :: z, where h has the type int x format */
/* ret = list of format */
if(is_nil(s)) {
if (is_nil(s)) {
return sexpr{};
}

View file

@ -92,7 +92,7 @@ private:
lean_assert(sexpr_kind(s) == format_kind::TEXT);
std::stringstream ss;
sexpr const & content = cdr(s);
if(is_string(content)) {
if (is_string(content)) {
ss << to_string(content);
} else {
ss << content;
@ -177,8 +177,7 @@ public:
m_value = std::accumulate(it, l.end(), m_value,
[](sexpr const & result, const format f) {
return sexpr_compose({result, f.m_value});
}
);
});
}
format_kind kind() const {
@ -246,14 +245,12 @@ format wrap(format const & f1, format const & f2);
// is_iterator
template<typename T, typename = void>
struct is_iterator
{
static constexpr bool value = false;
struct is_iterator {
static constexpr bool value = false;
};
template<typename T>
struct is_iterator<T, typename std::enable_if<!std::is_same<typename std::iterator_traits<T>::value_type, void>::value>::type>
{
static constexpr bool value = true;
struct is_iterator<T, typename std::enable_if<!std::is_same<typename std::iterator_traits<T>::value_type, void>::value>::type> {
static constexpr bool value = true;
};
template <class InputIterator, typename F>
@ -264,7 +261,7 @@ format folddoc(InputIterator first, InputIterator last, F f) {
static_assert(std::is_same<typename std::result_of<F(typename std::iterator_traits<InputIterator>::value_type,
format)>::type, format>::value,
"folddoc: return type of f is not format");
if(first == last) { return format(); }
if (first == last) { return format(); }
return f(*first, folddoc(first + 1, last, f));
}
template <class InputIterator>

View file

@ -6,7 +6,8 @@ Author: Leonardo de Moura
*/
#pragma once
#include <map>
#include "options.h"
#include <string>
#include "util/sexpr/options.h"
namespace lean {
/**

View file

@ -32,19 +32,19 @@ public:
bool contains(name const & n) const;
bool contains(char const * n) const;
bool get_bool(name const & n, bool default_value=false) const;
int get_int(name const & n, int default_value=0) const;
unsigned get_unsigned(name const & n, unsigned default_value=0) const;
double get_double(name const & n, double default_value=0.0) const;
char const * get_string(name const & n, char const * default_value=nullptr) const;
sexpr get_sexpr(name const & n, sexpr const & default_value=sexpr()) const;
bool get_bool(name const & n, bool default_value = false) const;
int get_int(name const & n, int default_value = 0) const;
unsigned get_unsigned(name const & n, unsigned default_value = 0) const;
double get_double(name const & n, double default_value = 0.0) const;
char const * get_string(name const & n, char const * default_value = nullptr) const;
sexpr get_sexpr(name const & n, sexpr const & default_value = sexpr()) const;
bool get_bool(char const * n, bool default_value=false) const;
int get_int(char const * n, int default_value=0) const;
unsigned get_unsigned(char const * n, unsigned default_value=0) const;
double get_double(char const * n, double default_value=0.0) const;
char const * get_string(char const * n, char const * default_value=nullptr) const;
sexpr get_sexpr(char const * n, sexpr const & default_value=sexpr()) const;
bool get_bool(char const * n, bool default_value = false) const;
int get_int(char const * n, int default_value = 0) const;
unsigned get_unsigned(char const * n, unsigned default_value = 0) const;
double get_double(char const * n, double default_value = 0.0) const;
char const * get_string(char const * n, char const * default_value = nullptr) const;
sexpr get_sexpr(char const * n, sexpr const & default_value = sexpr()) const;
options update(name const & n, sexpr const & v) const;
template<typename T> options update(name const & n, T v) const { return update(n, sexpr(v)); }

View file

@ -83,7 +83,6 @@ public:
friend bool is_eqp(sexpr const & a, sexpr const & b) { return a.m_ptr == b.m_ptr; }
friend std::ostream & operator<<(std::ostream & out, sexpr const & s);
};
/** \brief Return the nil S-expression */