示例#1
0
 def check_status(self):
   status = io_util.load_text_proto(self.status_filename(),
                                    loop_pb2.LoopStatus, 'Status file')
   if (status.name != self.status.name or
       status.last_finished_round != self.status.last_finished_round or
       status.current_round != self.status.current_round or
       status.running_controller != self.running_controller):
     logging.fatal('Inconsistent status between stored status and disk')
示例#2
0
    def write_final_stats(self):
        """Log and write final aggregated statistics to file system."""
        fname = self.aggregate_stat_filename + '-00000-of-00001.pbtxt'
        aggregate_stat = io_util.load_text_proto(
            fname, deephol_stat_pb2.ProofAggregateStat, 'aggregate statistics')
        if aggregate_stat is None:
            tf.logging.warning('Could not read aggregate statistics "%s"',
                               fname)
            return
        tf.logging.info('Stats:\n%s',
                        stats.aggregate_stat_to_string(aggregate_stat))
        open_goals = file_lines_set(self.open_goals_filename +
                                    '-00000-of-00001.txt')
        proven_goals = file_lines_set(self.proven_goals_filename +
                                      '-00000-of-00001.txt')
        never_proven = open_goals - proven_goals
        num_open_goals = len(never_proven)
        num_proven_goals = len(proven_goals)
        tf.logging.info('Open goals: %d', num_open_goals)
        tf.logging.info('Proved goals: %d', num_proven_goals)
        perc_proven = 100.0 * num_proven_goals / float(num_open_goals +
                                                       num_proven_goals)
        tf.logging.info('Percentage proven: %.2f', perc_proven)
        with gfile.Open(self.proven_stats_filename, 'w') as f:
            f.write('%d %d %.2f\n' %
                    (num_open_goals, num_proven_goals, perc_proven))
        with gfile.Open(self.pretty_stats_filename, 'w') as f:
            f.write('%s\n' % stats.detailed_statistics(aggregate_stat))

        # Write cactus plot
        if aggregate_stat.proof_closed_after_millis:
            cactus_data = list(aggregate_stat.proof_closed_after_millis)
            cactus_data.sort()
            with gfile.Open(self.cactus_data_filename, 'w') as f:
                f.write('\n'.join(map(str, cactus_data)))
            fig = plot.figure()
            plot.xlabel('Number of proofs closed')
            plot.ylabel('Wall clock time in s')
            plot.plot([ms * .001 for ms in cactus_data])  # convert to seconds
            buf = io.BytesIO()
            fig.savefig(buf, format='pdf', bbox_inches='tight')
            with gfile.Open(self.cactus_plot_filename, 'wb') as f:
                f.write(buf.getvalue())
示例#3
0
def get_task_list(prover_tasks_file: Optional[str],
                  prover_task_list_file: Optional[str],
                  theorem_db: Optional[proof_assistant_pb2.TheoremDatabase],
                  splits, library_tags) -> List[proof_assistant_pb2.ProverTask]:
  """Get a list of theorem from either sources.

  Whichever parameter is specified first is used as a source for the
  tasks.

  Args:
    prover_tasks_file: File name for a text file with multiple ProverTasks in
      each line or a recordio file depending on the extension.
    prover_task_list_file: File name for a text protobuf prover_tasks_file.
    theorem_db: TheoremDatabase object.
    splits: List of splits to be considered. The list will be filtered for the
      splits that are not specified.
    library_tags: List of strings for the library tags to be processed. If
      empty, then all library tags are allowed.

  Returns:
    List of tasks extracted.
  """
  if prover_tasks_file:
    tf.logging.info('Loading tasks from tasks file "%s".', prover_tasks_file)
    return [
        task for task in io_util.read_protos(prover_tasks_file,
                                             proof_assistant_pb2.ProverTask)
        if is_thm_included(task.goals[0], splits, library_tags)
    ]
  elif prover_task_list_file:
    tf.logging.info('Loading tasks from task list file "%s".',
                    prover_tasks_file)
    task_list = io_util.load_text_proto(prover_task_list_file,
                                        proof_assistant_pb2.ProverTaskList,
                                        'prover task list')
    return [
        task for task in task_list.tasks
        if is_thm_included(task.goals[0], splits, library_tags)
    ]
  else:
    tf.logging.info('Generating task list for theorem database.')
    return create_tasks_for_theorem_db(theorem_db, splits, library_tags)
def main(argv):
    runner.program_started()
    if len(argv) > 1:
        raise app.UsageError('Too many command-line arguments.')
    assert FLAGS.root is not None, 'Required flag --root is missing.'
    config = io_util.load_text_proto(FLAGS.config, loop_pb2.LoopConfig)
    if (not FLAGS.rounds and not FLAGS.initial_examples
            and not config.inherited_proof_logs):
        logging.fatal('Loop setup requires either initial examples '
                      'or inherited proof logs')
    controller_fingerprint = loop_meta.create_fingerprint()
    meta = loop_meta.LoopMeta(FLAGS.root, config, controller_fingerprint,
                              False)
    assert meta.status, 'Could not read status'
    loop = loop_pipeline.LoopPipeline(meta, config)
    if not FLAGS.rounds:
        logging.info('Setting up loop...')
        loop.setup_examples(FLAGS.initial_examples)
    else:
        for _ in xrange(FLAGS.rounds):
            loop.perform_round(FLAGS.initial_examples)
示例#5
0
 def read_status(self):
   self.status = io_util.load_text_proto(self.status_filename(),
                                         loop_pb2.LoopStatus, 'Status file')
示例#6
0
def get_task_list(prover_tasks_file: Optional[str],
                  prover_task_list_file: Optional[str],
                  tasks_by_fingerprint: Optional[Text],
                  theorem_db: Optional[proof_assistant_pb2.TheoremDatabase],
                  splits, library_tags) -> List[proof_assistant_pb2.ProverTask]:
  """Get a list of theorem from either sources.

  Whichever parameter is specified first is used as a source for the
  tasks.

  Args:
    prover_tasks_file: File name for a text file with multiple ProverTasks in
      each line or a recordio file depending on the extension.
    prover_task_list_file: File name for a text protobuf prover_tasks_file.
    tasks_by_fingerprint: Comma-separated list of fingerprints from the theorem
      database to generate a prover task for.
    theorem_db: TheoremDatabase object.
    splits: List of splits to be considered. The list will be filtered for the
      splits that are not specified.
    library_tags: List of strings for the library tags to be processed. If
      empty, then all library tags are allowed.

  Returns:
    List of tasks extracted.
  """
  if prover_tasks_file:
    tf.logging.info('Loading tasks from tasks file "%s".', prover_tasks_file)
    return [
        task for task in io_util.read_protos(prover_tasks_file,
                                             proof_assistant_pb2.ProverTask)
        if is_thm_included(task.goals[0], splits, library_tags)
    ]
  elif prover_task_list_file:
    tf.logging.info('Loading tasks from task list file "%s".',
                    prover_tasks_file)
    task_list = io_util.load_text_proto(prover_task_list_file,
                                        proof_assistant_pb2.ProverTaskList,
                                        'prover task list')
    return [
        task for task in task_list.tasks
        if is_thm_included(task.goals[0], splits, library_tags)
    ]
  elif tasks_by_fingerprint:
    if not theorem_db:
      tf.logging.fatal('Require a theorem database to create prover tasks from '
                       'fingerprints.')
    tf.logging.info('Generating task list for fingerprint(s) %s',
                    tasks_by_fingerprint)
    fingerprints = set([int(fp) for fp in tasks_by_fingerprint.split(',')])
    theorems = []
    for thm in theorem_db.theorems:
      fingerprint = theorem_fingerprint.Fingerprint(thm)
      if fingerprint in fingerprints:
        fingerprints.remove(fingerprint)
        theorems.append(thm)
    if fingerprints:
      tf.logging.error('Some fingerprints could not be found in theorem db: %s',
                       str(fingerprints))
    return [
        make_prover_task_for_goal(thm, thm, theorem_db.name) for thm in theorems
    ]
  else:
    tf.logging.info('Generating task list for theorem database.')
    return create_tasks_for_theorem_db(theorem_db, splits, library_tags)