<commit_before>package proof.validator;

import org.json.JSONArray;
import org.json.JSONObject;

import proof.data.Graph;
import proof.data.reader.GraphReader;
import proof.exception.InvalidProofException;
import proof.util.Config;

/**
 * The main validator for validating a complete log file.
 *
 * @author <NAME>
 *
 */
public class MainValidator implements Validator<JSONObject> {

  private final static GraphReader graphReader = new GraphReader();

  /**
   * Validates a whole log file as provided by the OCM logger.
   */
  @Override
  public void validate(JSONObject object) throws InvalidProofException {
    Graph graph = graphReader.read(object.getJSONObject("graph"));

    if (object.getJSONObject("solution").getBoolean("trivial")) {
      Config.get().logger.print("validating supposedly trivial lower bound");
      if (graph.getClaimedLowerBound() > 1) {
        throw new InvalidProofException("The claimed lower bound of "
            + graph.getClaimedLowerBound() + " is non-trivial.");
      }
      Config.get().logger.println("  ..OK");
    } else {
      JSONArray leaves = object.getJSONObject("solution").getJSONArray("leaves");
      BranchCoverageValidator coverageValidator = new BranchCoverageValidator(graph);

      Config.get().logger.print("branch coverage");
      coverageValidator.validate(leaves);
      Config.get().logger.println("  ..OK");

      for (int i = 0; i < leaves.length(); i++) {
        Config.get().logger.println("branch " + (i + 1) + " of " + leaves.length());<commit_msg>Lower Bounds by Euler, Pach&Todt<commit_after>package proof.validator;

import org.json.JSONArray;
import org.json.JSONObject;

import proof.data.Graph;
import proof.data.reader.GraphReader;
import proof.exception.InvalidProofException;
import proof.util.Config;

/**
 * The main validator for validating a complete log file.
 *
 * @author <NAME>
 *
 */
public class MainValidator implements Validator<JSONObject> {

  private final static GraphReader graphReader = new GraphReader();

  /**
   * Validates a whole log file as provided by the OCM logger.
   */
  @Override
  public void validate(JSONObject object) throws InvalidProofException {
    Graph graph = graphReader.read(object.getJSONObject("graph"));

    if (object.getJSONObject("solution").getBoolean("trivial")) {
      Config.get().logger.print("validating supposedly trivial lower bound");

      boolean valid = false;

      if (graph.getClaimedLowerBound() <= 1) {
        valid = true;
        Config.get().logger.println(" ..OK (bound is less than 2)");
      } else if (graph.getClaimedLowerBound() == 6 + graph.getNumberOfEdges() - 3
          * graph.getNumberOfNodes()) {
        valid = true;
        Config.get().logger.println(" ..OK (bound follows from Euler's polyhedron formula)");
      } else if (graph.getClaimedLowerBound() == Math.ceil(Math.pow(graph.getNumberOfEdges(), 3)
          / (33.75 * Math.pow(graph.getNumberOfNodes(), 2)) - 3 * graph.getNumberOfNodes())) {
        valid = true;
        Config.get().logger.println(" ..OK (bound follows from the formula by Pach & Todt)");
      }

      if (!valid) {
        throw new InvalidProofException("The claimed lower bound of "
            + graph.getClaimedLowerBound() + " is non-trivial.");
      }
      Config.get().logger.println("  ..OK");
    } else {
      JSONArray leaves = object.getJSONObject("solution").getJSONArray("leaves");
      BranchCoverageValidator coverageValidator = new BranchCoverageValidator(graph);

      Config.get().logger.print("branch coverage");
      coverageValidator.validate(leaves);
      Config.get().logger.println("  ..OK");

      for (int i = 0; i < leaves.length(); i++) {
        Config.get().logger.println("branch " + (i + 1) + " of " + leaves.length());
{'fraction_non_alphanumeric': 0.13555732062483453, 'fraction_numerical': 0.004236166269526079, 'mean_word_length': 3.455188679245283, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3826510', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1048, 'n_words': 266}