Example #1
0
void SMTConfig::parseConfig ( char * f )
{
  FILE * filein = NULL;
  // Open configuration file
  if ( ( filein = fopen( f, "rt" ) ) == NULL )
  {
    // No configuration file is found. Print out
    // the current configuration
    // cerr << "# " << endl;
    cerr << "# WARNING: No configuration file " << f << ". Dumping default setting to " << f << endl;
    ofstream fileout( f );
    printConfig( fileout );
    fileout.close( );
  }
  else
  {
    int line = 0;

    while ( !feof( filein ) )
    {
      line ++;
      char buf[ 128 ];
      char * res = fgets( buf, 128, filein );
      (void)res;
      // Stop if finished
      if ( feof( filein ) )
        break;
      // Skip comments
      if ( buf[ 0 ] == '#' )
        continue;

      char tmpbuf[ 32 ];

      // GENERIC CONFIGURATION
           if ( sscanf( buf, "incremental %d\n"              , &incremental )                   == 1 );
      else if ( sscanf( buf, "produce_stats %d\n"            , &produce_stats )                 == 1 );
      else if ( sscanf( buf, "produce_models %d\n"           , &produce_models )                == 1 );
      else if ( sscanf( buf, "produce_proofs %d\n"           , &produce_proofs )                == 1 );
      else if ( sscanf( buf, "produce_inter %d\n"            , &produce_inter )                 == 1 );
      else if ( sscanf( buf, "regular_output_channel %s\n"   , tmpbuf )                         == 1 )
        setRegularOutputChannel( tmpbuf );
      else if ( sscanf( buf, "diagnostic_output_channel %s\n", tmpbuf )                         == 1 )
        setDiagnosticOutputChannel( tmpbuf );
      else if ( sscanf( buf, "dump_formula %d\n"             , &dump_formula )                  == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                , &verbosity )                     == 1 );
      else if ( sscanf( buf, "certification_level %d\n"      , &certification_level )                     == 1 );
      else if ( sscanf( buf, "certifying_solver %s\n"        , certifying_solver )                     == 1 );
      // SAT SOLVER CONFIGURATION
      else if ( sscanf( buf, "sat_theory_propagation %d\n"   , &(sat_theory_propagation))       == 1 );
      else if ( sscanf( buf, "sat_polarity_mode %d\n"        , &(sat_polarity_mode))            == 1 );
      else if ( sscanf( buf, "sat_initial_skip_step %lf\n"   , &(sat_initial_skip_step))        == 1 );
      else if ( sscanf( buf, "sat_skip_step_factor %lf\n"    , &(sat_skip_step_factor))         == 1 );
      else if ( sscanf( buf, "sat_restart_first %d\n"        , &(sat_restart_first))            == 1 );
      else if ( sscanf( buf, "sat_restart_increment %lf\n"   , &(sat_restart_inc))              == 1 );
      else if ( sscanf( buf, "sat_use_luby_restart %d\n"     , &(sat_use_luby_restart))         == 1 );
      else if ( sscanf( buf, "sat_learn_up_to_size %d\n"     , &(sat_learn_up_to_size))         == 1 );
      else if ( sscanf( buf, "sat_temporary_learn %d\n"      , &(sat_temporary_learn))          == 1 );
      else if ( sscanf( buf, "sat_preprocess_booleans %d\n"  , &(sat_preprocess_booleans))      == 1 );
      else if ( sscanf( buf, "sat_preprocess_theory %d\n"    , &(sat_preprocess_theory))        == 1 );
      else if ( sscanf( buf, "sat_centrality %d\n"           , &(sat_centrality))               == 1 );
      else if ( sscanf( buf, "sat_trade_off %d\n"            , &(sat_trade_off))                == 1 );
      else if ( sscanf( buf, "sat_minimize_conflicts %d\n"   , &(sat_minimize_conflicts))       == 1 );
      else if ( sscanf( buf, "sat_dump_cnf %d\n"             , &(sat_dump_cnf))                 == 1 );
      else if ( sscanf( buf, "sat_dump_rnd_inter %d\n"       , &(sat_dump_rnd_inter))           == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc %d\n"             , &(sat_lazy_dtc))                 == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc_burst %d\n"       , &(sat_lazy_dtc_burst))           == 1 );
      // PROOF PRODUCTION CONFIGURATION
      else if ( sscanf( buf, "proof_reduce %d\n"             , &(proof_reduce))                 == 1 );
      else if ( sscanf( buf, "proof_ratio_red_solv %lf\n"    , &(proof_ratio_red_solv))         == 1 );
      else if ( sscanf( buf, "proof_red_time %lf\n"          , &(proof_red_time))               == 1 );
      else if ( sscanf( buf, "proof_red_trans %d\n"          , &(proof_red_trans))              == 1 );
      else if ( sscanf( buf, "proof_reorder_pivots %d\n"     , &(proof_reorder_pivots))         == 1 );
      else if ( sscanf( buf, "proof_remove_mixed %d\n"       , &(proof_remove_mixed))           == 1 );
      else if ( sscanf( buf, "proof_use_sym_inter %d\n"      , &(proof_use_sym_inter))          == 1 );
      else if ( sscanf( buf, "proof_certify_inter %d\n"      , &(proof_certify_inter))          == 1 );
      // EUF SOLVER CONFIGURATION
      else if ( sscanf( buf, "uf_disable %d\n"               , &(uf_disable))                   == 1 );
      else if ( sscanf( buf, "uf_theory_propagation %d\n"    , &(uf_theory_propagation))        == 1 );
      // BV SOLVER CONFIGURATION
      else if ( sscanf( buf, "bv_disable %d\n"               , &(bv_disable))                   == 1 );
      else if ( sscanf( buf, "bv_theory_propagation %d\n"    , &(bv_theory_propagation))        == 1 );
      // DL SOLVER CONFIGURATION
      else if ( sscanf( buf, "dl_disable %d\n"               , &(dl_disable))                   == 1 );
      else if ( sscanf( buf, "dl_theory_propagation %d\n"    , &(dl_theory_propagation))        == 1 );
      // LRA SOLVER CONFIGURATION
      else if ( sscanf( buf, "lra_disable %d\n"              , &(lra_disable))                  == 1 );
      else if ( sscanf( buf, "lra_theory_propagation %d\n"   , &(lra_theory_propagation))       == 1 );
      else if ( sscanf( buf, "lra_poly_deduct_size %d\n"     , &(lra_poly_deduct_size))         == 1 );
      else if ( sscanf( buf, "lra_gaussian_elim %d\n"        , &(lra_gaussian_elim))            == 1 );
      else if ( sscanf( buf, "lra_integer_solver %d\n"       , &(lra_integer_solver))           == 1 );
      else if ( sscanf( buf, "lra_check_on_assert %d\n"      , &(lra_check_on_assert))          == 1 );
      else
      {
        opensmt_error2( "unrecognized option ", buf );
      }
    }

    // Close
    fclose( filein );
  }

  if ( produce_stats )  stats_out.open( "stats.out" );
}
Example #2
0
void Config::parseConfig ( char * f )
{
  FILE * filein = NULL;
  // Open configuration file
  if ( ( filein = fopen( f, "rt" ) ) == NULL )
  {
    // No configuration file is found. Print out
    // the current configuration
    cerr << "# WARNING: No configuration file " << f << ". Dumping default setting to " << f << endl;
    ofstream fileout( f );
    printConfig( fileout );
    fileout.close( );
  }
  else
  {
    int line = 0;

    while ( !feof( filein ) )
    {
      line ++;
      char buf[ 128 ];
      char * res = fgets( buf, 128, filein );
      (void)res;
      // Stop if finished
      if ( feof( filein ) )
	break;
      // Skip comments
      if ( buf[ 0 ] == '#' )
	continue;

      char tmpbuf[ 32 ];

      // GENERIC CONFIGURATION
	   if ( sscanf( buf, "incremental %d\n"                   , &incremental )                    == 1 );
      else if ( sscanf( buf, "produce_stats %d\n"                 , &produce_stats )                  == 1 );
      else if ( sscanf( buf, "print_stats %d\n"                   , &print_stats )                    == 1 );
      else if ( sscanf( buf, "print_proofs_smtlib2 %d\n"          , &print_proofs_smtlib2 )           == 1 );
      else if ( sscanf( buf, "print_proofs_dotty %d\n"            , &print_proofs_dotty )             == 1 );
      else if ( sscanf( buf, "produce_models %d\n"                , &produce_models )                 == 1 )
      {
#ifndef PRODUCE_PROOF
	if ( produce_proofs != 0 )
	  opensmt_error( "You must configure code with --enable-proof to produce proofs" );
#endif
      }
      else if ( sscanf( buf, "produce_inter %d\n"                 , &produce_inter )                  == 1 )
      {
#ifndef PRODUCE_PROOF
	if ( produce_inter != 0 )
	  opensmt_error( "You must configure code with --enable-proof to produce interpolants" );
#endif
      }
      else if ( sscanf( buf, "regular_output_channel %s\n"        , tmpbuf )                          == 1 )
	setRegularOutputChannel( tmpbuf );
      else if ( sscanf( buf, "diagnostic_output_channel %s\n"     , tmpbuf )                          == 1 )
	setDiagnosticOutputChannel( tmpbuf );                                                         
      else if ( sscanf( buf, "dump_formula %d\n"                  , &dump_formula )                   == 1 );
      else if ( sscanf( buf, "dump_log %d\n"                      , &dump_log )                       == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                     , &verbosity )                      == 1 );
      else if ( sscanf( buf, "print_success %d\n"                 , &print_success )                  == 1 );
      else if ( sscanf( buf, "certification_level %d\n"           , &certification_level )            == 1 );
      else if ( sscanf( buf, "certifying_solver %s\n"             , certifying_solver )               == 1 );
      else if ( sscanf( buf, "split_equalities %d\n"              , &split_equalities )               == 1 );
      // SAT SOLVER CONFIGURATION                                                                     
      else if ( sscanf( buf, "sat_theory_propagation %d\n"        , &(sat_theory_propagation))        == 1 );
      else if ( sscanf( buf, "sat_polarity_mode %d\n"             , &(sat_polarity_mode))             == 1 );
      else if ( sscanf( buf, "sat_initial_skip_step %lf\n"        , &(sat_initial_skip_step))         == 1 );
      else if ( sscanf( buf, "sat_skip_step_factor %lf\n"         , &(sat_skip_step_factor))          == 1 );
      else if ( sscanf( buf, "sat_restart_first %d\n"             , &(sat_restart_first))             == 1 );
      else if ( sscanf( buf, "sat_restart_increment %lf\n"        , &(sat_restart_inc))               == 1 );
      else if ( sscanf( buf, "sat_use_luby_restart %d\n"          , &(sat_use_luby_restart))          == 1 );
      else if ( sscanf( buf, "sat_learn_up_to_size %d\n"          , &(sat_learn_up_to_size))          == 1 );
      else if ( sscanf( buf, "sat_temporary_learn %d\n"           , &(sat_temporary_learn))           == 1 );
      else if ( sscanf( buf, "sat_preprocess_booleans %d\n"       , &(sat_preprocess_booleans))       == 1 );
      else if ( sscanf( buf, "sat_preprocess_theory %d\n"         , &(sat_preprocess_theory))         == 1 );
      else if ( sscanf( buf, "sat_centrality %d\n"                , &(sat_centrality))                == 1 );
      else if ( sscanf( buf, "sat_trade_off %d\n"                 , &(sat_trade_off))                 == 1 );
      else if ( sscanf( buf, "sat_minimize_conflicts %d\n"        , &(sat_minimize_conflicts))        == 1 );
      else if ( sscanf( buf, "sat_dump_cnf %d\n"                  , &(sat_dump_cnf))                  == 1 );
      else if ( sscanf( buf, "sat_dump_rnd_inter %d\n"            , &(sat_dump_rnd_inter))            == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc %d\n"                  , &(sat_lazy_dtc))                  == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc_burst %d\n"            , &(sat_lazy_dtc_burst))            == 1 );
      // PROOF PRODUCTION CONFIGURATION                                                               
      else if ( sscanf( buf, "proof_reduce %d\n"                  , &(proof_reduce))                  == 1 );
      else if ( sscanf( buf, "proof_random_seed %d\n"             , &(proof_random_seed))             == 1 );
      else if ( sscanf( buf, "proof_ratio_red_solv %lf\n"         , &(proof_ratio_red_solv))          == 1 );
      else if ( sscanf( buf, "proof_red_time %lf\n"               , &(proof_red_time))                == 1 );
      else if ( sscanf( buf, "proof_num_graph_traversals %d\n"    , &(proof_num_graph_traversals))    == 1 );
      else if ( sscanf( buf, "proof_red_trans %d\n"               , &(proof_red_trans))               == 1 );
      else if ( sscanf( buf, "proof_reorder_pivots %d\n"          , &(proof_reorder_pivots))          == 1 );
      else if ( sscanf( buf, "proof_reduce_while_reordering %d\n" , &(proof_reduce_while_reordering)) == 1 );
      else if ( sscanf( buf, "proof_random_context_analysis %d\n" , &(proof_random_context_analysis)) == 1 );
      else if ( sscanf( buf, "proof_random_swap_application %d\n" , &(proof_random_swap_application)) == 1 );
      else if ( sscanf( buf, "proof_remove_mixed %d\n"            , &(proof_remove_mixed))            == 1 );
      else if ( sscanf( buf, "proof_set_inter_algo %d\n"          , &(proof_set_inter_algo))          == 1 );
      else if ( sscanf( buf, "proof_certify_inter %d\n"           , &(proof_certify_inter))           == 1 );
      // EUF SOLVER CONFIGURATION                                                                     
      else if ( sscanf( buf, "uf_disable %d\n"                    , &(uf_disable))                    == 1 );
      else if ( sscanf( buf, "uf_theory_propagation %d\n"         , &(uf_theory_propagation))         == 1 );
      // BV SOLVER CONFIGURATION                                                                            
      else if ( sscanf( buf, "bv_disable %d\n"                    , &(bv_disable))                    == 1 );
      else if ( sscanf( buf, "bv_theory_propagation %d\n"         , &(bv_theory_propagation))         == 1 );
      // DL SOLVER CONFIGURATION                                                                            
      else if ( sscanf( buf, "dl_disable %d\n"                    , &(dl_disable))                    == 1 );
      else if ( sscanf( buf, "dl_theory_propagation %d\n"         , &(dl_theory_propagation))         == 1 );
      // LRA SOLVER CONFIGURATION                                                                           
      else if ( sscanf( buf, "lra_disable %d\n"                   , &(lra_disable))                   == 1 );
      else if ( sscanf( buf, "lra_theory_propagation %d\n"        , &(lra_theory_propagation))        == 1 );
      else if ( sscanf( buf, "lra_poly_deduct_size %d\n"          , &(lra_poly_deduct_size))          == 1 );
      else if ( sscanf( buf, "lra_gaussian_elim %d\n"             , &(lra_gaussian_elim))             == 1 );
      else if ( sscanf( buf, "lra_integer_solver %d\n"            , &(lra_integer_solver))            == 1 );
      else if ( sscanf( buf, "lra_check_on_assert %d\n"           , &(lra_check_on_assert))           == 1 );
      // MCMT related options
      else if ( sscanf( buf, "node_limit %d\n"                    , &(node_limit))                    == 1 );
      else if ( sscanf( buf, "depth_limit %d\n"                   , &(depth_limit))                   == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                     , &(verbosity))                     == 1 );      
      else if ( sscanf( buf, "simpl_level %d\n"                   , &(simpl_level))                   == 1 );      
      else if ( sscanf( buf, "e_simpl_level %d\n"                 , &(e_simpl_level))                 == 1 );      
      else if ( sscanf( buf, "fix_point_strategy %d\n"            , &(fix_point_strategy))            == 1 );
      else if ( sscanf( buf, "fix_point_period %d\n"              , &(fix_point_period))              == 1 );
      else if ( sscanf( buf, "check_compatible %d\n"              , &(check_compatible))              == 1 );
      else if ( sscanf( buf, "invariant_nodes %d\n"               , &(invariant_nodes))               == 1 );
      else if ( (report_tex            = (strcmp( buf, "tex\n" )                      == 0)) );
      else if ( (flex_fix_point        = (strcmp( buf, "flex_fix_point\n" )           == 0)) );
      else if ( (predicate_abstr       = (strcmp( buf, "predicate_abstr\n" )          == 0)) );
      else if ( (constant_abstr        = (strcmp( buf, "constant_abstr\n" )           == 0)) ); 
      else if ( (log                   = (strcmp( buf, "log\n" )                      == 0)) );
      else if ( (weak_fix_point        = (strcmp( buf, "weak_fix_point\n" )           == 0)) );
      else if ( (incr_fix_point        = (strcmp( buf, "incr_fix_point\n" )           == 0)) ); 
      else if ( (breadth_search        = (strcmp( buf, "breadth_search\n" )           == 0)) );
      else if ( (breadth_search        = (strcmp( buf, "depth_search\n" )             == 0)) );
      else if ( (full_inv_search       = (strcmp( buf, "full_inv_search\n" )          == 0)) );
      else if ( (parsing_tests         = (strcmp( buf, "parsing_tests\n" )            == 0)) );  
      else if ( (simplify_preimages    = (strcmp( buf, "simplify_preimages\n" )       == 0)) );  
      else if ( (report                = (strcmp( buf, "report\n" )                   == 0)) );  
      else if ( (optimization          = (strcmp( buf, "optimization\n" )             == 0)) ); 
      else if ( (iterative             = (strcmp( buf, "iterative\n" )                == 0)) ); 
      else if ( (invariant_pattern     = (strcmp( buf, "invariant_pattern\n" )        == 0)) ); 
      else if ( (classic_invariant     = (strcmp( buf, "invariant\n" )                == 0)) ); 
      else if ( (counterexample        = (strcmp( buf, "counterexample\n" )           == 0)) ); 
      else if ( (generate_invariants   = (strcmp( buf, "generate_invariants\n" )      == 0)) ); 
      else
      {
	opensmt_error2( "unrecognized option ", buf );
      }
    }

    if ( invariant_pattern || classic_invariant )
    {
      global_invariant = true;
    }

    // Close
    fclose( filein );
  }

  if ( produce_stats ) stats_out.open( ".stats.out" );
  if ( dump_log )      log_out.open( ".opensmt_log.smt2" );
}