def dump(subproofs_data, args):
    print('%d synthetic proofs extracted' % len(subproofs_data))
    if subproofs_data == []:
        return
    for i, subprf in enumerate(subproofs_data):
        subproofs_data[i]['name'] = args.proof
    dirname = dst_filename(args.file, args.data_path) + '-SUBPROOFS/'
    json.dump(subproofs_data, open(os.path.join(dirname, args.proof + '.json'), 'wt'))
Exemple #2
0
def dump(subproofs_data, args):
    print("%d synthetic proofs extracted" % len(subproofs_data))
    if subproofs_data == []:
        return
    for i, subprf in enumerate(subproofs_data):
        subproofs_data[i]["name"] = args.proof
    dirname = dst_filename(args.file, args.data_path) + "-SUBPROOFS/"
    json.dump(subproofs_data,
              open(os.path.join(dirname, args.proof + ".json"), "wt"))
Exemple #3
0
def process_file(filename):
    # extract a Coq file
    db_path = dst_filename(filename, args.data_path) + "-sexp_cache"
    try:
        os.makedirs(os.path.split(db_path)[0])
    except os.error:
        pass
    sexp_cache = SexpCache(db_path)
    file_data = check_file(filename, sexp_cache, args)
    dump(file_data, args)
Exemple #4
0
def process_file(filename):
    # extract a Coq file

    coq_filename = os.path.splitext(filename)[0] + '.v'
    fields = coq_filename.split(os.path.sep)
    file_data_filename = os.path.sep.join(fields[2:])
    file_data_coq_project = fields[1]
    path = os.path.join(args.data_path, file_data_coq_project,
                        file_data_filename)[:-2]
    if os.path.isfile(path + '.json'):
        return

    db_path = dst_filename(filename, args.data_path) + '-sexp_cache'
    try:
        os.makedirs(os.path.split(db_path)[0])
    except os.error:
        pass
    sexp_cache = SexpCache(db_path)
    try:
        file_data = check_file(filename, sexp_cache, args)
    except:
        print(path + ' failed')
        return
    dump(file_data, args)
Exemple #5
0
    arg_parser.add_argument("--proof", type=str, help="The proof to extract")
    arg_parser.add_argument(
        "--max_length",
        type=int,
        default=4,
        help="The maximum length for synthetic proofs",
    )
    arg_parser.add_argument("--timeout",
                            type=int,
                            default=3600,
                            help="Timeout for SerAPI")
    arg_parser.add_argument("--data_path", type=str, default="./data")
    args = arg_parser.parse_args()
    print(args)

    human_proof_file = (dst_filename(args.file, args.data_path) + "-PROOFS/" +
                        args.proof + ".json")
    if not os.path.exists(human_proof_file):
        print("%s does not exist. Exiting.." % human_proof_file)
        sys.exit(0)
    dirname = dst_filename(args.file, args.data_path) + "-SUBPROOFS/"
    try:
        os.makedirs(dirname)
    except os.error:
        pass
    db_path = os.path.join(dirname, args.proof + "_sexp_cache")
    sexp_cache = SexpCache(db_path)

    file_data = json.load(
        open(dst_filename(args.file, args.data_path) + ".json"))
    subproofs_data = get_subproofs(human_proof_file, file_data["vernac_cmds"],
Exemple #6
0
def dump(proof_data, args):
    dirname = dst_filename(args.file, args.data_path) + '-PROOFS'
    json.dump(proof_data, open(os.path.join(dirname, args.proof + '.json'), 'wt'))
Exemple #7
0
def dump(proof_data, args):
    dirname = dst_filename(args.file, args.data_path) + '-PROOFS'
    json.dump(proof_data, open(os.path.join(dirname, args.proof + '.json'), 'wt'))
  
  
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(100000)
    import argparse
    arg_parser = argparse.ArgumentParser(description='Extract the proofs from Coq source code')
    arg_parser.add_argument('--debug', action='store_true')
    arg_parser.add_argument('--file', type=str, help='The meta file to process')
    arg_parser.add_argument('--proof', type=str, help='The proof to extract')
    arg_parser.add_argument('--timeout', type=int, default=600, help='Timeout for SerAPI')
    arg_parser.add_argument('--data_path', type=str, default='./data')
    args = arg_parser.parse_args()
    print(args)

    dirname = dst_filename(args.file, args.data_path) + '-PROOFS'
    try:
        os.makedirs(dirname)
    except os.error:
         pass
    db_path = os.path.join(dirname, args.proof + '-sexp_cache')
    sexp_cache = SexpCache(db_path)

    proof_data = get_proof(sexp_cache, args)
    if proof_data is not None:
        dump(proof_data, args)
Exemple #8
0
def dump(proof_data, args):
    dirname = dst_filename(args.file, args.data_path) + "-PROOFS"
    json.dump(proof_data,
              open(os.path.join(dirname, args.proof + ".json"), "wt"))
    arg_parser.add_argument('--proof', type=str, help='The proof to extract')
    arg_parser.add_argument('--max_length',
                            type=int,
                            default=4,
                            help='The maximum length for synthetic proofs')
    arg_parser.add_argument('--timeout',
                            type=int,
                            default=3600,
                            help='Timeout for SerAPI')
    arg_parser.add_argument('--data_path', type=str, default='./data2')
    args = arg_parser.parse_args()
    print(args)

    # warning this is not needed because there is no synthetic proofs included in proof_steps

    human_proof_file = dst_filename(
        args.file, args.data_path) + '-PROOFS/' + args.proof + '.json'
    if not os.path.exists(human_proof_file):
        print('%s does not exist. Exiting..' % human_proof_file)
        sys.exit(0)
    dirname = dst_filename(args.file, args.data_path) + '-SUBPROOFS/'
    try:
        os.makedirs(dirname)
    except os.error:
        pass
    db_path = os.path.join(dirname, args.proof + '_sexp_cache')
    sexp_cache = SexpCache(db_path)

    file_data = json.load(
        open(dst_filename(args.file, args.data_path) + '.json'))
    subproofs_data = get_subproofs(human_proof_file, file_data['vernac_cmds'],
                                   sexp_cache, args)
Exemple #10
0
def dump(proof_data, args):
    dirname = dst_filename(args.file, args.data_path) + '-PROOFS'
    with open(os.path.join(dirname, args.proof + '.json'), 'wt') as json_data:
        json.dump(proof_data, json_data)
        print('dump ' + args.proof)