author | blanchet |
Thu, 14 Nov 2013 15:57:48 +0100 | |
changeset 54432 | 68f8bd1641da |
parent 53555 | 12251bc889f1 |
permissions | -rw-r--r-- |
50222 | 1 |
# Title: HOL/Tools/Sledgehammer/MaSh/src/readData.py |
2 |
# Author: Daniel Kuehlwein, ICIS, Radboud University Nijmegen |
|
3 |
# Copyright 2012 |
|
4 |
# |
|
5 |
# All functions to read the Isabelle output. |
|
6 |
||
50220 | 7 |
''' |
8 |
All functions to read the Isabelle output. |
|
9 |
||
10 |
Created on July 9, 2012 |
|
11 |
||
12 |
@author: Daniel Kuehlwein |
|
13 |
''' |
|
14 |
||
15 |
import sys,logging |
|
16 |
||
17 |
def create_dependencies_dict(nameIdDict,inputFile): |
|
18 |
logger = logging.getLogger('create_dependencies_dict') |
|
19 |
dependenciesDict = {} |
|
20 |
IS = open(inputFile,'r') |
|
21 |
for line in IS: |
|
22 |
line = line.split(':') |
|
50388 | 23 |
name = line[0] |
50220 | 24 |
# Name Id |
25 |
if not nameIdDict.has_key(name): |
|
26 |
logger.warning('%s is missing in nameIdDict. Aborting.',name) |
|
27 |
sys.exit(-1) |
|
28 |
||
29 |
nameId = nameIdDict[name] |
|
50388 | 30 |
dependenciesIds = [nameIdDict[f.strip()] for f in line[1].split()] |
50220 | 31 |
# Store results, add p proves p |
54432
68f8bd1641da
have MaSh support nameless facts (i.e. proofs) and use that support
blanchet
parents:
53555
diff
changeset
|
32 |
if nameId == 0: |
68f8bd1641da
have MaSh support nameless facts (i.e. proofs) and use that support
blanchet
parents:
53555
diff
changeset
|
33 |
dependenciesDict[nameId] = dependenciesIds |
68f8bd1641da
have MaSh support nameless facts (i.e. proofs) and use that support
blanchet
parents:
53555
diff
changeset
|
34 |
else: |
68f8bd1641da
have MaSh support nameless facts (i.e. proofs) and use that support
blanchet
parents:
53555
diff
changeset
|
35 |
dependenciesDict[nameId] = [nameId] + dependenciesIds |
50220 | 36 |
IS.close() |
37 |
return dependenciesDict |
|
38 |
||
39 |
def create_accessible_dict(nameIdDict,idNameDict,maxNameId,inputFile): |
|
40 |
logger = logging.getLogger('create_accessible_dict') |
|
41 |
accessibleDict = {} |
|
42 |
IS = open(inputFile,'r') |
|
43 |
for line in IS: |
|
44 |
line = line.split(':') |
|
50388 | 45 |
name = line[0] |
50220 | 46 |
# Name Id |
47 |
if not nameIdDict.has_key(name): |
|
48 |
logger.warning('%s is missing in nameIdDict. Adding it as theory.',name) |
|
49 |
nameIdDict[name] = maxNameId |
|
50 |
idNameDict[maxNameId] = name |
|
51 |
nameId = maxNameId |
|
50388 | 52 |
maxNameId += 1 |
50220 | 53 |
else: |
54 |
nameId = nameIdDict[name] |
|
55 |
accessibleStrings = line[1].split() |
|
56 |
accessibleDict[nameId] = [nameIdDict[a.strip()] for a in accessibleStrings] |
|
57 |
IS.close() |
|
58 |
return accessibleDict,maxNameId |