00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00040 #ifndef __NUSMV_CORE_COMPILE_COMPILE_H__
00041 #define __NUSMV_CORE_COMPILE_COMPILE_H__
00042
00043 #include "nusmv/core/be/be.h"
00044 #include "nusmv/core/cinit/NuSMVEnv.h"
00045 #include "nusmv/core/compile/compileUtil.h"
00046 #include "nusmv/core/compile/FlatHierarchy.h"
00047 #include "nusmv/core/compile/PredicateExtractor.h"
00048 #include "nusmv/core/compile/PredicateNormaliser.h"
00049 #include "nusmv/core/compile/symb_table/SymbLayer.h"
00050 #include "nusmv/core/compile/symb_table/SymbTable.h"
00051 #include "nusmv/core/dd/dd.h"
00052 #include "nusmv/core/enc/bdd/BddEnc.h"
00053 #include "nusmv/core/fsm/FsmBuilder.h"
00054 #include "nusmv/core/fsm/sexp/BoolSexpFsm.h"
00055 #include "nusmv/core/fsm/sexp/SexpFsm.h"
00056 #include "nusmv/core/hrc/HrcNode.h"
00057 #include "nusmv/core/node/node.h"
00058 #include "nusmv/core/prop/Prop.h"
00059 #include "nusmv/core/set/set.h"
00060 #include "nusmv/core/utils/NodeList.h"
00061 #include "nusmv/core/utils/assoc.h"
00062 #include "nusmv/core/utils/utils.h"
00063 #include "nusmv/core/wff/ExprMgr.h"
00064 #include "nusmv/core/node/anonymizers/NodeAnonymizerBase.h"
00065
00066
00067
00068
00069
00075 #define ENV_FLAG_FLATTENER_INITIALIZED "flattener_initialized"
00076
00082 #define ENV_PROC_SELECTOR_VNAME "proc_selector_vname"
00083
00084
00085
00086
00087
00094 typedef struct cmp_struct* cmp_struct_ptr;
00095
00101 typedef enum {
00102 State_Variables_Instantiation_Mode,
00103 Frozen_Variables_Instantiation_Mode,
00104 Input_Variables_Instantiation_Mode
00105 } Instantiation_Variables_Mode_Type;
00106
00112 typedef enum {
00113 State_Functions_Instantiation_Mode,
00114 Frozen_Functions_Instantiation_Mode
00115 } Instantiation_Functions_Mode_Type;
00116
00122 typedef enum {ST_Notype, ST_Ctl, ST_Ltl, ST_Invar, ST_Compute} Spec_Type;
00123
00129 typedef enum {SS_Nostatus, SS_Unchecked, SS_True, SS_False, SS_Wrong, SS_Number} Spec_Status;
00130
00137 typedef struct _Fsm_SexpRec Fsm_SexpRec;
00138 typedef struct _Fsm_SexpRec * Fsm_SexpPtr;
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00154 #define MODEL_LAYER_NAME "model"
00155
00162 #define DETERM_LAYER_NAME "determ"
00163
00170 #define INLINING_LAYER_NAME "inlining"
00171
00179 #define PROCESS_SELECTOR_VAR_NAME "_process_selector_"
00180
00187 #define RUNNING_SYMBOL "running"
00188
00194 #define MODEL_LAYERS_CLASS "Model Class"
00195
00201 #define ARTIFACTS_LAYERS_CLASS "Artifacts Class"
00202
00203
00204
00205
00206
00213 void Compile_init(NuSMVEnv_ptr env);
00214
00220 void Compile_quit(NuSMVEnv_ptr env);
00221
00231 void CompileFlatten_init_flattener(NuSMVEnv_ptr env);
00232
00243 void CompileFlatten_quit_flattener(NuSMVEnv_ptr env);
00244
00252 void CompileFlatten_hash_module(const NuSMVEnv_ptr env,
00253 node_ptr parsed_module);
00254
00295 FlatHierarchy_ptr
00296 Compile_FlattenHierarchy(const NuSMVEnv_ptr env,
00297 const SymbTable_ptr symb_table,
00298 SymbLayer_ptr layer,
00299 node_ptr, node_ptr, node_ptr,
00300 boolean create_process_variable,
00301 boolean calc_vars_constr,
00302 boolean expand_bounded_arrays,
00303 HrcNode_ptr hrc_result);
00304
00326 void Compile_CheckAssigns(const SymbTable_ptr, node_ptr);
00327
00333 void Compile_check_case(const SymbTable_ptr, node_ptr expr);
00334
00341 void Compile_check_next(const SymbTable_ptr st,
00342 node_ptr expr, node_ptr context,
00343 boolean is_one_next_allowed);
00344
00353 void Compile_check_input_next(const SymbTable_ptr st,
00354 node_ptr expr, node_ptr context);
00355
00383 node_ptr
00384 CompileFlatten_concat_contexts(const NuSMVEnv_ptr env,
00385 node_ptr ctx1, node_ptr ctx2);
00386
00393 node_ptr
00394 CompileFlatten_expand_range(const NuSMVEnv_ptr env,
00395 int a, int b);
00396
00408 node_ptr
00409 CompileFlatten_resolve_number(SymbTable_ptr symb_table,
00410 node_ptr n, node_ptr context);
00411
00428 node_ptr
00429 CompileFlatten_resolve_define_chains(const SymbTable_ptr symb_table,
00430 node_ptr expr, node_ptr context);
00431
00437 void insert_module_hash(const NuSMVEnv_ptr env, node_ptr x,
00438 node_ptr y);
00439
00445 node_ptr lookup_module_hash(const NuSMVEnv_ptr env, node_ptr x);
00446
00455 void compileCheckForInputVars(SymbTable_ptr, FlatHierarchy_ptr hierarchy);
00456
00462 int cmp_struct_get_read_model(cmp_struct_ptr cmp);
00463
00469 void cmp_struct_set_read_model(cmp_struct_ptr cmp);
00470
00476 void cmp_struct_unset_read_model(cmp_struct_ptr cmp);
00477
00483 int cmp_struct_get_hrc_built(cmp_struct_ptr cmp);
00484
00490 void cmp_struct_set_hrc_built(cmp_struct_ptr cmp);
00491
00497 int cmp_struct_get_flatten_hrc(cmp_struct_ptr cmp);
00498
00504 void cmp_struct_set_flatten_hrc(cmp_struct_ptr cmp);
00505
00511 int cmp_struct_get_encode_variables(cmp_struct_ptr cmp);
00512
00518 void cmp_struct_set_encode_variables(cmp_struct_ptr cmp);
00519
00525 int cmp_struct_get_process_selector(cmp_struct_ptr cmp);
00526
00532 void cmp_struct_set_process_selector(cmp_struct_ptr cmp);
00533
00539 int cmp_struct_get_build_frames(cmp_struct_ptr cmp);
00540
00546 void cmp_struct_set_build_frames(cmp_struct_ptr cmp);
00547
00553 int cmp_struct_get_build_model(cmp_struct_ptr cmp);
00554
00560 void cmp_struct_set_build_model(cmp_struct_ptr cmp);
00561
00567 int cmp_struct_get_build_flat_model(cmp_struct_ptr cmp);
00568
00574 void cmp_struct_set_build_flat_model(cmp_struct_ptr cmp);
00575
00581 int cmp_struct_get_build_bool_model(cmp_struct_ptr cmp);
00582
00588 void cmp_struct_set_build_bool_model(cmp_struct_ptr cmp);
00589
00595 int cmp_struct_get_fairness(cmp_struct_ptr cmp);
00596
00602 void cmp_struct_set_fairness(cmp_struct_ptr cmp);
00603
00609 int cmp_struct_get_coi(cmp_struct_ptr cmp);
00610
00616 void cmp_struct_set_coi(cmp_struct_ptr cmp);
00617
00623 int cmp_struct_get_bmc_init(cmp_struct_ptr cmp);
00624
00630 void cmp_struct_set_bmc_init(cmp_struct_ptr cmp);
00631
00637 void cmp_struct_unset_bmc_init(cmp_struct_ptr cmp);
00638
00644 int cmp_struct_get_bmc_setup(cmp_struct_ptr cmp);
00645
00651 void cmp_struct_set_bmc_setup(cmp_struct_ptr cmp);
00652
00658 void cmp_struct_unset_bmc_setup(cmp_struct_ptr cmp);
00659
00667 Expr_ptr
00668 Compile_compile_simpwff_from_string(NuSMVEnv_ptr env,
00669 const SymbTable_ptr st,
00670 const char* str_formula);
00671
00679 Expr_ptr
00680 Compile_compile_nextwff_from_string(NuSMVEnv_ptr,
00681 const SymbTable_ptr st,
00682 const char* str_formula);
00683
00691 Expr_ptr
00692 Compile_compile_spec_from_string(NuSMVEnv_ptr env,
00693 const SymbTable_ptr st,
00694 const char* str_formula,
00695 const Prop_Type prop_type);
00696
00706 node_ptr
00707 Compile_FlattenSexp(const SymbTable_ptr symb_table, node_ptr, node_ptr);
00708
00716 node_ptr
00717 Compile_FlattenSexpExpandDefine(const SymbTable_ptr symb_table,
00718 node_ptr, node_ptr);
00719
00725 void
00726 Compile_WriteFlattenModel(const NuSMVEnv_ptr env,
00727 FILE* out,
00728 const SymbTable_ptr st,
00729 const array_t* layer_names,
00730 const char* fsm_name,
00731 FlatHierarchy_ptr hierarchy,
00732 boolean force_flattening);
00733
00741 void
00742 Compile_WriteRestrictedFlattenModel(const NuSMVEnv_ptr env,
00743 FILE* out,
00744 const SymbTable_ptr st,
00745 const array_t* layer_names,
00746 const char* fsm_name,
00747 FlatHierarchy_ptr hierarchy,
00748 boolean force_flattening);
00749
00755 void
00756 Compile_WriteObfuscatedFlattenModel(const NuSMVEnv_ptr env,
00757 FILE* out,
00758 const SymbTable_ptr st,
00759 const array_t* layer_names,
00760 const char* fsm_name,
00761 FlatHierarchy_ptr hierarchy,
00762 boolean print_map,
00763 boolean force_flattening,
00764 NodeAnonymizerBase_ptr anonymizer);
00765
00778 void
00779 Compile_WriteFlattenFsm(const NuSMVEnv_ptr env,
00780 FILE* out,
00781 const SymbTable_ptr symb_table,
00782 const array_t* layer_names,
00783 const char* fsm_name,
00784 FlatHierarchy_ptr hierarchy,
00785 boolean force_flattening);
00786
00792 void
00793 Compile_WriteFlattenModel_udg(const NuSMVEnv_ptr env,
00794 FILE* out,
00795 const SymbTable_ptr st,
00796 const array_t* layer_names,
00797 const char* fsm_name,
00798 FlatHierarchy_ptr hierarchy);
00799
00806 void
00807 Compile_WriteFlattenSpecs(const NuSMVEnv_ptr env,
00808 FILE* out,
00809 const SymbTable_ptr st,
00810 FlatHierarchy_ptr hierarchy,
00811 boolean force_flattening);
00812
00818 void
00819 Compile_WriteBoolModel(const NuSMVEnv_ptr env,
00820 FILE* out,
00821 BddEnc_ptr enc,
00822 NodeList_ptr layers,
00823 const char* fsm_name,
00824 BoolSexpFsm_ptr bool_sexp_fsm,
00825 boolean force_flattening);
00826
00837 void
00838 Compile_WriteBoolFsm(const NuSMVEnv_ptr env,
00839 FILE* out,
00840 const SymbTable_ptr symb_table,
00841 NodeList_ptr layers,
00842 const char* fsm_name,
00843 BoolSexpFsm_ptr bool_sexp_fsm,
00844 boolean force_flattening);
00845
00858 void
00859 Compile_WriteBoolSpecs(const NuSMVEnv_ptr env,
00860 FILE* out,
00861 BddEnc_ptr enc,
00862 FlatHierarchy_ptr hierarchy);
00863
00882 boolean Compile_is_expr_booleanizable(const SymbTable_ptr st,
00883 node_ptr expr,
00884 boolean word_booleanizable,
00885 hash_ptr cache);
00886
00915 Expr_ptr Compile_expr2bexpr(BddEnc_ptr enc,
00916 SymbLayer_ptr det_layer,
00917 Expr_ptr expr);
00918
00942 Expr_ptr Compile_detexpr2bexpr(BddEnc_ptr enc, Expr_ptr expr);
00943
00981 Expr_ptr
00982 Compile_detexpr2bexpr_list(BddEnc_ptr enc, Expr_ptr expr);
00983
01000 Set_t
01001 Formula_GetDependencies(const SymbTable_ptr, node_ptr, node_ptr);
01002
01021 Set_t
01022 Formula_GetDependenciesByType(const SymbTable_ptr, node_ptr, node_ptr,
01023 SymbFilterType, boolean);
01024
01025
01034 Set_t
01035 Formulae_GetDependenciesByType(const SymbTable_ptr, node_ptr, node_ptr, node_ptr,
01036 SymbFilterType, boolean);
01037
01045 Set_t
01046 Formula_GetConstants(const SymbTable_ptr symb_table,
01047 node_ptr formula, node_ptr context);
01048
01056 Set_t
01057 Formulae_GetDependencies(const SymbTable_ptr, node_ptr, node_ptr,
01058 node_ptr);
01059
01069 Set_t ComputeCOIFixpoint(const SymbTable_ptr symb_table,
01070 const FlatHierarchy_ptr hierarchy,
01071 const Expr_ptr expression,
01072 const int steps,
01073 boolean* reached_fixpoint);
01074
01082 Set_t ComputeCOI(const SymbTable_ptr,
01083 const FlatHierarchy_ptr, Set_t);
01084
01096 node_ptr
01097 Flatten_GetDefinition(const SymbTable_ptr symb_table, node_ptr atom,
01098 const boolean expand_defines);
01099
01111 void Flatten_remove_symbol_info(const NuSMVEnv_ptr env, node_ptr name);
01112
01120 node_ptr
01121 CompileFlatten_normalise_value_list(const NuSMVEnv_ptr env,
01122 node_ptr old_value_list);
01123
01146 SymbType_ptr
01147 Compile_InstantiateType(SymbTable_ptr st, SymbLayer_ptr layer,
01148 node_ptr name, node_ptr type,
01149 node_ptr context,
01150 boolean expand_bounded_arrays);
01151
01176 boolean
01177 Compile_DeclareVariable(SymbTable_ptr symb_table, SymbLayer_ptr layer,
01178 node_ptr name, SymbType_ptr type,
01179 node_ptr context,
01180 Instantiation_Variables_Mode_Type mode);
01181
01202 boolean
01203 Compile_DeclareFunction(SymbTable_ptr symb_table, SymbLayer_ptr layer,
01204 node_ptr name, SymbType_ptr type,
01205 node_ptr context,
01206 Instantiation_Functions_Mode_Type mode);
01207
01213 node_ptr Compile_make_dag_info(const NuSMVEnv_ptr env,
01214 node_ptr expr, hash_ptr hash);
01215
01221 node_ptr Compile_convert_to_dag(const NuSMVEnv_ptr env,
01222 SymbTable_ptr symb_table,
01223 node_ptr expr,
01224 hash_ptr hash,
01225 hash_ptr defines);
01226
01233 void Compile_write_dag_defines(const NuSMVEnv_ptr env,
01234 FILE* out, hash_ptr defines);
01235
01263 void Compile_declare_dag_defines_in_layer(SymbLayer_ptr layer,
01264 hash_ptr defines);
01265
01266
01272 void Compile_destroy_dag_info(const NuSMVEnv_ptr env,
01273 hash_ptr dag_info, hash_ptr defines);
01274
01284 void Compile_print_array_define(const NuSMVEnv_ptr env, FILE* out, const node_ptr n);
01285
01295 HrcNode_ptr Compile_hrc_from_parse_tree(const NuSMVEnv_ptr env,
01296 NodeMgr_ptr nomgr,
01297 node_ptr mod_name,
01298 node_ptr parse_tree);
01299
01309 void Compile_fill_hrc_from_mod_body(const NuSMVEnv_ptr env,
01310 NodeMgr_ptr nomgr,
01311 node_ptr mod_body,
01312 HrcNode_ptr hrc_result,
01313 hash_ptr mod_defs);
01314
01315
01316
01326 int
01327 CompileFlatten_flatten_smv(NuSMVEnv_ptr env,
01328 boolean calc_vars_constrains,
01329 boolean expand_bounded_arrays);
01330
01336 void
01337 Compile_show_vars(const NuSMVEnv_ptr env, const boolean total_only,
01338 const boolean defs_only, const boolean vars_only,
01339 const boolean statevars, const boolean frozenvars,
01340 const boolean inputvars, const OStream_ptr ostream,
01341 const boolean verbose);
01342
01348 int Compile_write_model_flat_bool(const NuSMVEnv_ptr env,
01349 const char* output_file,
01350 FILE* ofileid);
01351
01363 void Compile_print_predicates(const NuSMVEnv_ptr env);
01364
01370 int Compile_create_flat_model(NuSMVEnv_ptr env);
01371
01381 int Compile_create_boolean_model(NuSMVEnv_ptr env);
01382
01383
01384
01392 Expr_ptr
01393 Compile_remove_assignments(const NuSMVEnv_ptr env, Expr_ptr expr);
01394
01400 void Compile_write_coi_prop_fsm(const NuSMVEnv_ptr env,
01401 FlatHierarchy_ptr fh,
01402 Set_t cone, Set_t props,
01403 OStream_ptr output_file);
01404
01410 void Compile_write_coi_prop(const NuSMVEnv_ptr env,
01411 Set_t cone, Set_t props,
01412 OStream_ptr output_file);
01413
01419 void Compile_print_summary(const NuSMVEnv_ptr env,
01420 OStream_ptr file, SymbTable_ptr st,
01421 NodeList_ptr list, const char * str,
01422 boolean limit_output);
01423
01430 int Compile_get_bits(const SymbTable_ptr st, const NodeList_ptr lst);
01431
01440 void Compile_write_global_coi_fsm(NuSMVEnv_ptr env,
01441 FlatHierarchy_ptr hierarchy,
01442 Prop_Type prop_type,
01443 OStream_ptr output_file);
01444
01457 int Compile_write_properties_coi(NuSMVEnv_ptr env,
01458 FlatHierarchy_ptr hierarchy,
01459 Prop_Type prop_type,
01460 boolean only_dump_coi,
01461 const char* file_name);
01462
01479 void Compile_print_type(const NuSMVEnv_ptr env,
01480 OStream_ptr file, node_ptr ntype,
01481 int threshold);
01482
01496 node_ptr Compile_get_var_type(const NuSMVEnv_ptr env,
01497 SymbType_ptr type);
01498
01511 void Compile_WriteFlattenFsm_udg(const NuSMVEnv_ptr env,
01512 FILE* out,
01513 const SymbTable_ptr st,
01514 const array_t* layer_names,
01515 const char* fsm_name,
01516 FlatHierarchy_ptr hierarchy);
01517
01524 void Compile_WriteFlattenSpecs_udg(const NuSMVEnv_ptr env,
01525 FILE* out,
01526 const SymbTable_ptr st,
01527 FlatHierarchy_ptr hierarchy);
01528
01534 void Compile_WriteBoolModel_udg(const NuSMVEnv_ptr env,
01535 FILE* out,
01536 BddEnc_ptr enc,
01537 NodeList_ptr layers,
01538 const char* fsm_name,
01539 BoolSexpFsm_ptr bool_sexp_fsm);
01540
01551 void Compile_WriteBoolFsm_udg(const NuSMVEnv_ptr env,
01552 FILE* out, const SymbTable_ptr st,
01553 NodeList_ptr layers, const char* fsm_name,
01554 BoolSexpFsm_ptr bool_sexp_fsm);
01555
01568 void Compile_WriteBoolSpecs_udg(const NuSMVEnv_ptr env, FILE* out,
01569 BddEnc_ptr enc,
01570 FlatHierarchy_ptr hierarchy);
01571
01577 node_ptr Compile_make_dag_info_udg(const NuSMVEnv_ptr env,
01578 node_ptr expr, hash_ptr hash);
01579
01585 node_ptr Compile_convert_to_dag_udg(const NuSMVEnv_ptr env,
01586 SymbTable_ptr symb_table,
01587 node_ptr expr,
01588 hash_ptr dag_hash,
01589 hash_ptr defines);
01590
01597 void Compile_print_array_define_udg(const NuSMVEnv_ptr env,
01598 FILE* out,
01599 const node_ptr n);
01600
01601
01602
01626 void Compile_ProcessHierarchy(const NuSMVEnv_ptr env,
01627 SymbTable_ptr symb_table,
01628 SymbLayer_ptr layer,
01629 FlatHierarchy_ptr hierachy,
01630 node_ptr name,
01631 boolean create_process_variables,
01632 boolean calc_vars_constr);
01633
01644 int Compile_print_usage(NuSMVEnv_ptr env, OStream_ptr file);
01645
01651 int Compile_print_fsm_stats(NuSMVEnv_ptr env,
01652 BddFsm_ptr fsm,
01653 FILE* outstream,
01654 boolean printPreds);
01655
01656
01657
01658 int Compile_encode_variables(NuSMVEnv_ptr env,
01659 char* input_order_file_name,
01660 boolean bdd_enc_enum_only);
01661 int Compile_build_model(NuSMVEnv_ptr env,
01662 TransType partition_method);
01663
01671 int Compile_check_if_flattening_was_built(const NuSMVEnv_ptr env,
01672 FILE* err);
01673
01681 int Compile_check_if_encoding_was_built(const NuSMVEnv_ptr env,
01682 FILE* err);
01683
01691 int Compile_check_if_model_layer_is_in_bddenc(const NuSMVEnv_ptr env,
01692 FILE* err);
01693
01702 int Compile_check_if_flat_model_was_built(const NuSMVEnv_ptr env,
01703 FILE* err,
01704 boolean forced);
01705
01714 int Compile_check_if_bool_model_was_built(const NuSMVEnv_ptr env,
01715 FILE* err,
01716 boolean forced);
01717
01726 int Compile_check_if_model_was_built(const NuSMVEnv_ptr env,
01727 FILE* err,
01728 boolean forced);
01729
01730 #endif