#include "formula_profile.h"

LYMPHOSAT_MATCHER {
    const auto& p = profile;

    // SGI family: dense directed encodings with length-2 positive blocks.
    const bool dir_pocket =
        p.all_positive_clause_fraction >= 0.2 &&
        p.binary_clause_fraction > 0.99947 &&
        p.positive_block_candidate_len == 2 &&
        p.exactly_one_intra_pair_coverage == 0 &&
        p.normalized_clause_span_mean > 0.32 &&
        p.small_span_clause_fraction > 0.03 &&
        p.binary_graph_degree_mean < 200;

    // SGI family: tiny-log encodings with no binary clauses.
    const bool log_pocket =
        p.binary_clause_fraction == 0 &&
        p.positive_block_candidate_len == 10 &&
        p.avg_clause_len > 9.9 &&
        p.normalized_clause_span_mean > 0.79 &&
        p.exactly_one_intra_pair_coverage == 0 &&
        p.all_positive_clause_fraction < 0.01 &&
        p.clauses_seen < 100000 &&
        p.small_span_clause_fraction < 0.1;

    // SGI family: low-positive srhd variants with moderate block length.
    const bool srhd_low_degree_pocket =
        p.exactly_one_intra_pair_coverage == 1 &&
        p.binary_clause_fraction > 0.9995 &&
        p.all_positive_clause_fraction < 0.001 &&
        (p.positive_block_candidate_len == 22 ||
         p.positive_block_candidate_len == 32) &&
        p.normalized_clause_span_mean >= 0.29 &&
        p.normalized_clause_span_mean <= 0.315 &&
        p.binary_graph_degree_mean < 200;

    // SGI family: higher-degree srhd variants.
    const bool srhd_high_degree_pocket =
        p.exactly_one_intra_pair_coverage == 1 &&
        p.binary_clause_fraction > 0.9997 &&
        p.all_positive_clause_fraction < 0.001 &&
        p.positive_block_candidate_len >= 37 &&
        p.normalized_clause_span_mean >= 0.289 &&
        p.normalized_clause_span_mean <= 0.342 &&
        p.binary_graph_degree_mean >= 200;

    // SGI family: exact-one exact graph-encoding pocket with candidate length 23-28.
    const bool srhd_mid_pocket =
        p.exactly_one_intra_pair_coverage == 1 &&
        p.binary_clause_fraction > 0.998 &&
        p.all_positive_clause_fraction < 0.002 &&
        p.positive_block_candidate_len >= 23 &&
        p.positive_block_candidate_len <= 28 &&
        p.normalized_clause_span_mean >= 0.23 &&
        p.normalized_clause_span_mean <= 0.30 &&
        p.small_span_clause_fraction >= 0.15 &&
        p.small_span_clause_fraction <= 0.35 &&
        p.binary_graph_degree_mean < 170;

    // SGI family: one rare srhd variant with length-2 positive blocks.
    const bool srhd_pair_pocket =
        p.exactly_one_intra_pair_coverage == 0 &&
        p.binary_clause_fraction > 0.9999 &&
        p.all_positive_clause_fraction < 0.001 &&
        p.positive_block_candidate_len == 2 &&
        p.normalized_clause_span_mean >= 0.29 &&
        p.normalized_clause_span_mean <= 0.31 &&
        p.binary_graph_degree_mean > 200;

    // SGI family: structural variants with exact-one coverage and block lengths 20-30.
    const bool satsgi_pocket =
        p.exactly_one_intra_pair_coverage == 1 &&
        p.positive_block_candidate_len >= 20 &&
        p.positive_block_candidate_len <= 30 &&
        p.binary_clause_fraction > 0.997 &&
        p.normalized_clause_span_mean >= 0.167 &&
        p.normalized_clause_span_mean <= 0.175 &&
        p.small_span_clause_fraction > 0.4 &&
        p.small_span_clause_fraction < 0.55;

    // SGI family: new-difficult variants.
    const bool newdiff_pocket =
        p.exactly_one_intra_pair_coverage == 1 &&
        p.binary_clause_fraction > 0.9985 &&
        p.all_positive_clause_fraction < 0.0012 &&
        p.positive_block_candidate_len >= 20 &&
        p.positive_block_candidate_len <= 28 &&
        p.normalized_clause_span_mean >= 0.277 &&
        p.normalized_clause_span_mean <= 0.299 &&
        p.small_span_clause_fraction >= 0.17 &&
        p.small_span_clause_fraction <= 0.25 &&
        p.binary_graph_degree_mean >= 85 &&
        p.binary_graph_degree_mean <= 140 &&
        p.num_vars <= 800;

    // SI2 family: large-clause encodings.
    const bool si2_pocket =
        p.avg_clause_len >= 13 &&
        p.avg_clause_len <= 15.5 &&
        p.binary_clause_fraction >= 0.13 &&
        p.binary_clause_fraction <= 0.35 &&
        p.dominant_clause_len >= 16 &&
        p.dominant_clause_len <= 20 &&
        p.positive_block_candidate_len >= 4 &&
        p.positive_block_candidate_len <= 11 &&
        p.normalized_clause_span_mean < 0.14;

    const bool si2_len4_pocket =
        p.avg_clause_len >= 13 &&
        p.avg_clause_len <= 14 &&
        p.binary_clause_fraction >= 0.25 &&
        p.binary_clause_fraction <= 0.30 &&
        p.dominant_clause_len >= 16 &&
        p.dominant_clause_len <= 20 &&
        p.positive_block_candidate_len == 4 &&
        p.normalized_clause_span_mean < 0.12 &&
        p.exactly_one_intra_pair_coverage == 0;

    const bool si2_len11_pocket =
        p.avg_clause_len >= 13 &&
        p.avg_clause_len <= 15.5 &&
        p.binary_clause_fraction >= 0.25 &&
        p.binary_clause_fraction <= 0.35 &&
        p.dominant_clause_len >= 16 &&
        p.dominant_clause_len <= 20 &&
        p.positive_block_candidate_len == 11 &&
        p.normalized_clause_span_mean < 0.14 &&
        p.exactly_one_intra_pair_coverage < 0.2;

    // Subisomorphism pocket: compact binary-heavy encodings with 2-candidate blocks.
    const bool subiso_pocket =
        p.positive_block_candidate_len == 2 &&
        p.exactly_one_intra_pair_coverage == 0 &&
        p.binary_clause_fraction > 0.93 &&
        p.avg_clause_len > 2.3 &&
        p.avg_clause_len < 2.8 &&
        p.all_positive_clause_fraction < 0.002 &&
        p.all_negative_clause_fraction > 0.85 &&
        p.small_span_clause_fraction > 0.05;

    return dir_pocket || log_pocket || srhd_low_degree_pocket ||
           srhd_high_degree_pocket || srhd_mid_pocket || srhd_pair_pocket ||
           satsgi_pocket || newdiff_pocket || si2_pocket || si2_len4_pocket ||
           si2_len11_pocket || subiso_pocket;
}
