#include "formula_profile.h"

LYMPHOSAT_MATCHER {
    auto in = [](double value, double lo, double hi) {
        return value >= lo && value <= hi;
    };

    const bool exact_2p =
        profile.dominant_clause_len == 3 &&
        in(profile.clauses_per_var, 2.66, 3.62) &&
        in(profile.binary_clause_fraction, 0.099, 0.301) &&
        in(profile.normalized_clause_span_mean, 0.444, 0.491) &&
        in(profile.mixed_clause_fraction, 0.664, 0.740) &&
        in(profile.top5_occurrence_mass, 0.082, 0.094) &&
        in(profile.occurrence_stddev, 2.6, 3.6) &&
        in(profile.positive_literal_fraction, 0.491, 0.510) &&
        in(profile.positive_block_clause_fraction, 0.081, 0.125) &&
        profile.positive_block_candidate_len == 3;

    const bool len3_sparse =
        profile.dominant_clause_len == 3 &&
        in(profile.clauses_per_var, 3.45, 3.55) &&
        profile.binary_clause_fraction <= 0.001 &&
        in(profile.normalized_clause_span_mean, 0.486, 0.489) &&
        in(profile.mixed_clause_fraction, 0.759, 0.762) &&
        in(profile.positive_literal_fraction, 0.503, 0.506) &&
        in(profile.occurrence_stddev, 3.35, 3.44) &&
        in(profile.top5_occurrence_mass, 0.0875, 0.0889) &&
        in(profile.positive_block_clause_fraction, 0.1235, 0.1255) &&
        in(profile.pure_var_fraction, 0.017, 0.0205) &&
        in(profile.polarity_balance_mean, 0.266, 0.275) &&
        profile.positive_block_candidate_len == 3;

    const bool len3_mid =
        profile.dominant_clause_len == 3 &&
        in(profile.clauses_per_var, 4.22, 4.28) &&
        profile.binary_clause_fraction <= 0.001 &&
        in(profile.normalized_clause_span_mean, 0.484, 0.487) &&
        in(profile.mixed_clause_fraction, 0.756, 0.759) &&
        in(profile.positive_literal_fraction, 0.507, 0.511) &&
        in(profile.occurrence_stddev, 3.42, 3.56) &&
        in(profile.top5_occurrence_mass, 0.080, 0.0825) &&
        in(profile.positive_block_clause_fraction, 0.125, 0.1295) &&
        in(profile.pure_var_fraction, 0.0, 0.006) &&
        in(profile.polarity_balance_mean, 0.223, 0.236) &&
        in(profile.horn_clause_fraction, 0.482, 0.490) &&
        in(profile.dual_horn_clause_fraction, 0.510, 0.518) &&
        profile.positive_block_candidate_len == 3;

    const bool len3_high =
        profile.dominant_clause_len == 3 &&
        in(profile.clauses_per_var, 4.24, 4.27) &&
        profile.binary_clause_fraction <= 0.001 &&
        in(profile.normalized_clause_span_mean, 0.503, 0.507) &&
        in(profile.mixed_clause_fraction, 0.748, 0.757) &&
        in(profile.positive_literal_fraction, 0.482, 0.489) &&
        in(profile.occurrence_stddev, 3.45, 3.60) &&
        in(profile.top5_occurrence_mass, 0.080, 0.0835) &&
        in(profile.positive_block_clause_fraction, 0.105, 0.111) &&
        in(profile.pure_var_fraction, 0.0, 0.010) &&
        in(profile.polarity_balance_mean, 0.228, 0.239) &&
        in(profile.horn_clause_fraction, 0.515, 0.521) &&
        in(profile.dual_horn_clause_fraction, 0.479, 0.486) &&
        profile.positive_block_candidate_len == 3;

    const bool len4_sparse =
        profile.dominant_clause_len == 4 &&
        profile.num_vars >= 400000 &&
        in(profile.clauses_per_var, 1.95, 2.05) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.5997, 0.6004) &&
        in(profile.mixed_clause_fraction, 0.874, 0.876) &&
        in(profile.positive_literal_fraction, 0.4995, 0.5007) &&
        in(profile.occurrence_stddev, 2.81, 2.84) &&
        in(profile.top5_occurrence_mass, 0.08935, 0.08960) &&
        in(profile.positive_block_clause_fraction, 0.0621, 0.0628) &&
        in(profile.pure_var_fraction, 0.035, 0.037) &&
        in(profile.polarity_balance_mean, 0.2985, 0.3000) &&
        profile.positive_block_candidate_len == 4;

    const bool len4_dense =
        profile.dominant_clause_len == 4 &&
        profile.num_vars >= 1000 &&
        in(profile.clauses_per_var, 9.0, 9.95) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.591, 0.6032) &&
        in(profile.mixed_clause_fraction, 0.858, 0.889) &&
        in(profile.positive_literal_fraction, 0.494, 0.508) &&
        in(profile.occurrence_stddev, 5.55, 6.95) &&
        in(profile.top5_occurrence_mass, 0.066, 0.068) &&
        in(profile.positive_block_clause_fraction, 0.053, 0.071) &&
        in(profile.pure_var_fraction, 0.0, 0.0015) &&
        in(profile.polarity_balance_mean, 0.126, 0.135) &&
        in(profile.horn_clause_fraction, 0.301, 0.330) &&
        in(profile.dual_horn_clause_fraction, 0.305, 0.330) &&
        profile.positive_block_candidate_len == 4;

    const bool len5_sparse =
        profile.dominant_clause_len == 5 &&
        profile.num_vars >= 200000 &&
        in(profile.clauses_per_var, 3.95, 4.05) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.6661, 0.6672) &&
        in(profile.mixed_clause_fraction, 0.9369, 0.9382) &&
        in(profile.positive_literal_fraction, 0.4995, 0.5006) &&
        in(profile.occurrence_stddev, 4.44, 4.50) &&
        in(profile.top5_occurrence_mass, 0.0742, 0.0746) &&
        in(profile.positive_block_clause_fraction, 0.0308, 0.0318) &&
        in(profile.pure_var_fraction, 0.0, 0.0002) &&
        in(profile.polarity_balance_mean, 0.1815, 0.1826) &&
        profile.small_span_clause_fraction <= 0.001 &&
        profile.positive_block_candidate_len == 5;

    const bool len5_dense =
        profile.dominant_clause_len == 5 &&
        in(profile.clauses_per_var, 20.10, 21.35) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.6650, 0.6785) &&
        in(profile.mixed_clause_fraction, 0.933, 0.945) &&
        in(profile.positive_literal_fraction, 0.491, 0.509) &&
        in(profile.occurrence_stddev, 9.3, 11.3) &&
        in(profile.top5_occurrence_mass, 0.0590, 0.0695) &&
        in(profile.positive_block_clause_fraction, 0.027, 0.037) &&
        in(profile.horn_clause_fraction, 0.168, 0.201) &&
        in(profile.dual_horn_clause_fraction, 0.171, 0.208) &&
        in(profile.small_span_clause_fraction, 0.0, 0.0025) &&
        profile.positive_block_candidate_len == 5;

    const bool len6_small =
        profile.dominant_clause_len == 6 &&
        profile.num_vars >= 50000 &&
        in(profile.clauses_per_var, 9.9, 10.1) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.7135, 0.7148) &&
        in(profile.mixed_clause_fraction, 0.968, 0.970) &&
        in(profile.positive_literal_fraction, 0.4994, 0.5006) &&
        in(profile.occurrence_stddev, 7.70, 7.77) &&
        in(profile.top5_occurrence_mass, 0.0636, 0.0639) &&
        in(profile.positive_block_clause_fraction, 0.0154, 0.0159) &&
        in(profile.pure_var_fraction, 0.0, 0.0001) &&
        in(profile.polarity_balance_mean, 0.103, 0.105) &&
        profile.positive_block_candidate_len == 6;

    const bool len6_dense =
        profile.dominant_clause_len == 6 &&
        profile.num_vars <= 500 &&
        in(profile.clauses_per_var, 39.5, 43.377) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.7127, 0.7249) &&
        in(profile.mixed_clause_fraction, 0.964, 0.972) &&
        in(profile.positive_literal_fraction, 0.496, 0.505) &&
        in(profile.occurrence_stddev, 13.0, 17.9) &&
        in(profile.top5_occurrence_mass, 0.055, 0.0585) &&
        in(profile.positive_block_clause_fraction, 0.0125, 0.0181) &&
        in(profile.horn_clause_fraction, 0.099, 0.1165) &&
        in(profile.dual_horn_clause_fraction, 0.100, 0.1185) &&
        profile.small_span_clause_fraction <= 0.001 &&
        in(profile.polarity_balance_mean, 0.041, 0.056) &&
        profile.positive_block_candidate_len == 6;

    const bool len6_mid =
        profile.dominant_clause_len == 6 &&
        profile.num_vars <= 450 &&
        in(profile.clauses_per_var, 40.8, 42.8) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.7135, 0.7185) &&
        in(profile.mixed_clause_fraction, 0.964, 0.972) &&
        in(profile.positive_literal_fraction, 0.496, 0.503) &&
        in(profile.occurrence_stddev, 14.0, 17.0) &&
        in(profile.top5_occurrence_mass, 0.0553, 0.0573) &&
        in(profile.positive_block_clause_fraction, 0.013, 0.0178) &&
        in(profile.horn_clause_fraction, 0.103, 0.1155) &&
        in(profile.dual_horn_clause_fraction, 0.101, 0.118) &&
        profile.small_span_clause_fraction <= 0.001 &&
        in(profile.polarity_balance_mean, 0.046, 0.055) &&
        profile.positive_block_candidate_len == 6;

    const bool len6_tail =
        profile.dominant_clause_len == 6 &&
        profile.num_vars <= 500 &&
        in(profile.clauses_per_var, 43.364, 43.377) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.721, 0.7249) &&
        in(profile.mixed_clause_fraction, 0.962, 0.972) &&
        in(profile.positive_literal_fraction, 0.495, 0.504) &&
        in(profile.occurrence_stddev, 13.0, 17.0) &&
        in(profile.top5_occurrence_mass, 0.056, 0.068) &&
        in(profile.positive_block_clause_fraction, 0.0125, 0.019) &&
        in(profile.horn_clause_fraction, 0.102, 0.1165) &&
        in(profile.dual_horn_clause_fraction, 0.100, 0.1185) &&
        profile.small_span_clause_fraction <= 0.03 &&
        in(profile.polarity_balance_mean, 0.043, 0.055) &&
        profile.positive_block_candidate_len == 6;

    const bool len6_tail2 =
        profile.dominant_clause_len == 6 &&
        profile.num_vars <= 500 &&
        in(profile.clauses_per_var, 43.368, 43.372) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.714, 0.723) &&
        in(profile.mixed_clause_fraction, 0.965, 0.972) &&
        in(profile.positive_literal_fraction, 0.494, 0.503) &&
        in(profile.occurrence_stddev, 13.2, 17.8) &&
        in(profile.top5_occurrence_mass, 0.055, 0.065) &&
        in(profile.positive_block_clause_fraction, 0.013, 0.0175) &&
        in(profile.horn_clause_fraction, 0.103, 0.1165) &&
        in(profile.dual_horn_clause_fraction, 0.101, 0.1185) &&
        in(profile.small_span_clause_fraction, 0.0, 0.022) &&
        in(profile.polarity_balance_mean, 0.044, 0.052) &&
        profile.positive_block_candidate_len == 6;

    const bool len7_sparse =
        profile.dominant_clause_len == 7 &&
        in(profile.clauses_per_var, 19.5, 20.5) &&
        profile.binary_clause_fraction == 0.0 &&
        in(profile.normalized_clause_span_mean, 0.7496, 0.7504) &&
        in(profile.mixed_clause_fraction, 0.9840, 0.9848) &&
        in(profile.positive_literal_fraction, 0.4993, 0.5005) &&
        in(profile.occurrence_stddev, 11.74, 11.93) &&
        in(profile.top5_occurrence_mass, 0.05880, 0.05905) &&
        in(profile.positive_block_clause_fraction, 0.0075, 0.0081) &&
        in(profile.polarity_balance_mean, 0.0670, 0.0684) &&
        profile.positive_block_candidate_len == 7;

    return exact_2p || len3_sparse || len3_mid || len3_high ||
           len4_sparse || len4_dense || len5_sparse || len5_dense ||
           len6_small || len6_dense || len6_mid || len6_tail ||
           len6_tail2 || len7_sparse;
}
