#include "formula_profile.h"

#include <initializer_list>

LYMPHOSAT_MATCHER {
    const auto is_count = [](std::uint64_t value,
                             std::initializer_list<std::uint64_t> values) {
        for (std::uint64_t candidate : values) {
            if (value == candidate) {
                return true;
            }
        }
        return false;
    };

    const bool low_polarity_balance = profile.polarity_balance_mean <= 0.08;
    const bool high_polarity_balance = profile.polarity_balance_mean >= 0.45;

    if (profile.dominant_clause_len == 3 &&
        profile.positive_block_candidate_len == 3 &&
        low_polarity_balance &&
        profile.occurrence_stddev >= 0.5 &&
        is_count(profile.clauses_seen, {875, 1049, 1050, 1225, 1259, 1399, 1400, 1575, 1750, 1925, 2100, 2275, 2450})) {
        return true;
    }

    if (profile.dominant_clause_len == 3 &&
        profile.positive_block_candidate_len == 3 &&
        low_polarity_balance &&
        profile.occurrence_stddev >= 0.5 &&
        is_count(profile.clauses_seen, {1050, 1060, 1260, 1271, 1272, 1638, 1653, 2184, 2204, 2730, 2756})) {
        return true;
    }

    if (profile.dominant_clause_len == 3 &&
        profile.positive_block_candidate_len == 3 &&
        low_polarity_balance &&
        profile.occurrence_stddev >= 0.5 &&
        is_count(profile.clauses_seen, {1104, 1119, 1120, 1123, 1127, 1324, 1722, 1799, 2298, 2872})) {
        return true;
    }

    if (profile.dominant_clause_len == 4 &&
        profile.positive_block_candidate_len == 4 &&
        low_polarity_balance &&
        profile.occurrence_stddev <= 1.0 &&
        is_count(profile.clauses_seen, {709, 887, 1064, 1242, 1350, 1419, 1575, 1774, 1799, 1800, 2129, 2700})) {
        return true;
    }

    if (profile.dominant_clause_len == 4 &&
        profile.positive_block_candidate_len == 4 &&
        low_polarity_balance &&
        profile.occurrence_stddev <= 1.0 &&
        profile.clauses_seen == 1800) {
        return true;
    }

    if (profile.binary_clause_fraction >= 0.864 &&
        profile.binary_clause_fraction <= 0.875 &&
        profile.dominant_clause_len == 2 &&
        profile.positive_block_candidate_len == 2 &&
        high_polarity_balance &&
        profile.occurrence_stddev >= 0.65 &&
        profile.occurrence_stddev <= 0.9 &&
        is_count(profile.clauses_seen, {193, 197, 279, 280, 391, 399, 404, 486, 489, 492})) {
        return true;
    }

    return false;
}
