refactor(library/blast): move blast options to separate module

This commit is contained in:
Leonardo de Moura 2015-11-10 11:03:54 -08:00
parent f1c2a88e17
commit b76cdb1c68
5 changed files with 76 additions and 37 deletions

View file

@ -1,2 +1,3 @@
add_library(blast OBJECT expr.cpp state.cpp blast.cpp blast_tactic.cpp
init_module.cpp simplifier.cpp assumption.cpp intros.cpp proof_expr.cpp)
init_module.cpp simplifier.cpp assumption.cpp intros.cpp proof_expr.cpp
options.cpp)

View file

@ -6,7 +6,6 @@ Author: Leonardo de Moura
*/
#include <vector>
#include "util/sstream.h"
#include "util/sexpr/option_declarations.h"
#include "kernel/for_each_fn.h"
#include "kernel/type_checker.h"
#include "library/replace_visitor.h"
@ -24,38 +23,14 @@ Author: Leonardo de Moura
#include "library/blast/assumption.h"
#include "library/blast/intros.h"
#include "library/blast/proof_expr.h"
#include "library/blast/options.h"
#include "library/blast/blast_exception.h"
#ifndef LEAN_DEFAULT_BLAST_MAX_DEPTH
#define LEAN_DEFAULT_BLAST_MAX_DEPTH 128
#endif
#ifndef LEAN_DEFAULT_BLAST_INIT_DEPTH
#define LEAN_DEFAULT_BLAST_INIT_DEPTH 1
#endif
#ifndef LEAN_DEFAULT_BLAST_INC_DEPTH
#define LEAN_DEFAULT_BLAST_INC_DEPTH 5
#endif
namespace lean {
namespace blast {
static name * g_prefix = nullptr;
static name * g_tmp_prefix = nullptr;
/* Options */
static name * g_blast_max_depth = nullptr;
static name * g_blast_init_depth = nullptr;
static name * g_blast_inc_depth = nullptr;
unsigned get_blast_max_depth(options const & o) {
return o.get_unsigned(*g_blast_max_depth, LEAN_DEFAULT_BLAST_MAX_DEPTH);
}
unsigned get_blast_init_depth(options const & o) {
return o.get_unsigned(*g_blast_init_depth, LEAN_DEFAULT_BLAST_INIT_DEPTH);
}
unsigned get_blast_inc_depth(options const & o) {
return o.get_unsigned(*g_blast_inc_depth, LEAN_DEFAULT_BLAST_INC_DEPTH);
}
class blastenv {
friend class scope_assignment;
typedef std::vector<tmp_type_context *> tmp_type_context_pool;
@ -829,16 +804,6 @@ optional<expr> blast_goal(environment const & env, io_state const & ios, list<na
void initialize_blast() {
blast::g_prefix = new name(name::mk_internal_unique_name());
blast::g_tmp_prefix = new name(name::mk_internal_unique_name());
blast::g_blast_max_depth = new name{"blast", "max_depth"};
blast::g_blast_init_depth = new name{"blast", "init_depth"};
blast::g_blast_inc_depth = new name{"blast", "inc_depth"};
register_unsigned_option(*blast::g_blast_max_depth, LEAN_DEFAULT_BLAST_MAX_DEPTH,
"(blast) max search depth for blast");
register_unsigned_option(*blast::g_blast_init_depth, LEAN_DEFAULT_BLAST_INIT_DEPTH,
"(blast) initial search depth for blast (remark: blast uses iteration deepening)");
register_unsigned_option(*blast::g_blast_inc_depth, LEAN_DEFAULT_BLAST_INC_DEPTH,
"(blast) search depth increment for blast (remark: blast uses iteration deepening)");
}
void finalize_blast() {
delete blast::g_prefix;

View file

@ -9,9 +9,11 @@ Author: Leonardo de Moura
#include "library/blast/blast.h"
#include "library/blast/blast_tactic.h"
#include "library/blast/simplifier.h"
#include "library/blast/options.h"
namespace lean {
void initialize_blast_module() {
blast::initialize_options();
blast::initialize_expr();
blast::initialize_state();
initialize_blast();
@ -24,5 +26,6 @@ void finalize_blast_module() {
finalize_blast();
blast::finalize_state();
blast::finalize_expr();
blast::finalize_options();
}
}

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "util/sexpr/option_declarations.h"
#ifndef LEAN_DEFAULT_BLAST_MAX_DEPTH
#define LEAN_DEFAULT_BLAST_MAX_DEPTH 128
#endif
#ifndef LEAN_DEFAULT_BLAST_INIT_DEPTH
#define LEAN_DEFAULT_BLAST_INIT_DEPTH 1
#endif
#ifndef LEAN_DEFAULT_BLAST_INC_DEPTH
#define LEAN_DEFAULT_BLAST_INC_DEPTH 5
#endif
namespace lean {
namespace blast {
/* Options */
static name * g_blast_max_depth = nullptr;
static name * g_blast_init_depth = nullptr;
static name * g_blast_inc_depth = nullptr;
unsigned get_blast_max_depth(options const & o) {
return o.get_unsigned(*g_blast_max_depth, LEAN_DEFAULT_BLAST_MAX_DEPTH);
}
unsigned get_blast_init_depth(options const & o) {
return o.get_unsigned(*g_blast_init_depth, LEAN_DEFAULT_BLAST_INIT_DEPTH);
}
unsigned get_blast_inc_depth(options const & o) {
return o.get_unsigned(*g_blast_inc_depth, LEAN_DEFAULT_BLAST_INC_DEPTH);
}
void initialize_options() {
g_blast_max_depth = new name{"blast", "max_depth"};
g_blast_init_depth = new name{"blast", "init_depth"};
g_blast_inc_depth = new name{"blast", "inc_depth"};
register_unsigned_option(*blast::g_blast_max_depth, LEAN_DEFAULT_BLAST_MAX_DEPTH,
"(blast) max search depth for blast");
register_unsigned_option(*blast::g_blast_init_depth, LEAN_DEFAULT_BLAST_INIT_DEPTH,
"(blast) initial search depth for blast (remark: blast uses iteration deepening)");
register_unsigned_option(*blast::g_blast_inc_depth, LEAN_DEFAULT_BLAST_INC_DEPTH,
"(blast) search depth increment for blast (remark: blast uses iteration deepening)");
}
void finalize_options() {
delete g_blast_max_depth;
delete g_blast_init_depth;
delete g_blast_inc_depth;
}
}}

View file

@ -0,0 +1,17 @@
/*
Copyright (c) 2015 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/sexpr/options.h"
namespace lean {
namespace blast {
unsigned get_blast_max_depth(options const & o);
unsigned get_blast_init_depth(options const & o);
unsigned get_blast_inc_depth(options const & o);
void initialize_options();
void finalize_options();
}}