FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaRes/src/atp/TestGenerator.java at master · eprover/JavaRes · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
eprover
/
JavaRes
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaRes
/
src
/
atp
/
TestGenerator.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
185 lines (164 loc) · 7.27 KB
Breadcrumbs
JavaRes
/
src
/
atp
/
TestGenerator.java
Copy path
File metadata and controls
185 lines (164 loc) · 7.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package
atp
;
/*
Copyright 2010-2011 Adam Pease, apease@articulatesoftware.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program ; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
*/
import
java
.
io
.*;
import
java
.
util
.*;
import
java
.
text
.*;
public
class
TestGenerator
{
public
static
long
time
=
0
;
public
static
String
SZSresult
=
""
;
public
static
int
depthLimit
=
1
;
public
static
int
gensymCount
=
0
;
/** ***************************************************************
*/
public
static
Clause
instantiateGensyms
(
Clause
c
) {
ArrayList
<
Term
>
vars
=
c
.
collectVars
();
if
(
vars
.
size
() <
1
)
return
null
;
Substitutions
subst
=
new
Substitutions
();
for
(
int
i
=
0
;
i
<
vars
.
size
();
i
++) {
String
newConst
=
"Gensym"
+
Integer
.
toString
(
gensymCount
++);
subst
.
subst
.
put
(
vars
.
get
(
i
),
Term
.
string2Term
(
newConst
));
}
return
c
.
substitute
(
subst
);
}
/** ***************************************************************
*/
public
static
boolean
containsBadTerms
(
Clause
c
) {
System
.
out
.
println
(
"INFO in TestGenerator.containsBadTerms(): checking: "
+
c
);
ArrayList
<
String
>
terms
=
c
.
getConstantStrings
();
System
.
out
.
println
(
"INFO in TestGenerator.containsBadTerms(): with terms: "
+
terms
);
if
(
terms
.
contains
(
"s__ListOrderFn"
) ||
terms
.
contains
(
"s__ListLengthFn"
) ||
terms
.
contains
(
"s__ListFn_2"
) ||
terms
.
contains
(
"s__ListFn_3"
) ||
terms
.
contains
(
"s__ListFn_4"
) ||
terms
.
contains
(
"s__ListFn_5"
) ||
terms
.
contains
(
"s__ListLengthFn"
) ||
terms
.
contains
(
"s__initialList"
))
return
true
;
return
false
;
}
/** ***************************************************************
*/
public
static
Clause
seed
(
ClauseSet
cs
) {
Random
randomGenerator
=
new
Random
(
System
.
currentTimeMillis
());
int
randomInt
=
0
;
int
safetyCounter
=
0
;
Clause
c
=
null
;
ArrayList
<
Term
>
vars
=
null
;
do
{
randomInt
=
randomGenerator
.
nextInt
(
cs
.
clauses
.
size
());
c
=
cs
.
clauses
.
get
(
randomInt
);
//System.out.println("INFO in TestGenerator.seed(): checking potential seed: " + c);
vars
=
c
.
collectVars
();
}
while
((
c
.
literals
.
size
() !=
1
||
vars
.
size
() <
1
||
containsBadTerms
(
c
)) &&
safetyCounter
++ <
10000
);
if
(
safetyCounter
>=
10000
)
return
null
;
System
.
out
.
println
(
"# Chosen Seed: "
+
c
);
c
.
literals
.
get
(
0
).
negated
= !
c
.
literals
.
get
(
0
).
negated
;
/*
Substitutions subst = new Substitutions();
for (int i = 0; i < vars.size(); i++) {
String newConst = "Gensym" + Integer.toString(gensymCount++);
subst.subst.put(vars.get(i),Term.string2Term(newConst));
}
c = c.substitute(subst);
*/
System
.
out
.
println
(
"# Seed: "
+
c
);
return
c
;
}
/** ***************************************************************
*/
public
static
Clause
saturateGen
(
ProofState
state
,
int
seconds
) {
System
.
out
.
println
(
"INFO in TestGenerator.saturate()"
);
long
t1
=
System
.
currentTimeMillis
();
int
count
=
0
;
while
(
state
.
unprocessed
.
length
() >
0
) {
count
++;
Clause
res
=
state
.
processClause
();
if
(
res
!=
null
) {
time
=
System
.
currentTimeMillis
() -
t1
;
return
res
;
}
if
(
count
>
1000
) {
count
=
0
;
Clause
given_clause
=
state
.
unprocessed
.
selectBest
();
System
.
out
.
println
(
"# Checking: "
+
given_clause
.
toStringDiag
());
if
(
given_clause
.
depth
>
depthLimit
) {
given_clause
=
state
.
unprocessed
.
extractBest
();
System
.
out
.
println
(
"# Checking with good depth: "
+
given_clause
);
given_clause
=
instantiateGensyms
(
given_clause
);
if
(
given_clause
!=
null
) {
state
.
unprocessed
.
addClause
(
given_clause
);
System
.
out
.
println
(
"# asserting: "
+
given_clause
);
}
}
}
if
(((
System
.
currentTimeMillis
() -
t1
) /
1000.0
) >
seconds
) {
SZSresult
=
"timeout"
;
time
=
System
.
currentTimeMillis
() -
t1
;
return
null
;
}
}
return
null
;
}
/** ***************************************************************
*/
public
static
ProofState
processTestFile
(
String
filename
,
HashMap
<
String
,
String
>
opts
,
ArrayList
<
EvalStructure
>
evals
) {
int
timeout
=
Prover2
.
getTimeout
(
opts
);
ClauseSet
cs
=
Formula
.
file2clauses
(
filename
,
timeout
);
if
(
opts
.
containsKey
(
"verbose"
))
System
.
out
.
println
(
cs
);
else
System
.
out
.
println
(
"# INFO in TestGenerator.processTestFile(): completed file read"
);
if
(
cs
!=
null
) {
EvalStructure
eval
=
evals
.
get
(
0
);
Clause
c
=
seed
(
cs
);
if
(
c
==
null
) {
System
.
out
.
println
(
"# INFO in TestGenerator.processTestFile(): failed to generate seed."
);
return
null
;
}
cs
.
add
(
c
);
ProofState
state
=
new
ProofState
(
cs
,
evals
.
get
(
0
));
Prover2
.
setStateOptions
(
state
,
opts
);
state
.
filename
=
filename
;
state
.
evalFunctionName
=
eval
.
name
;
System
.
out
.
println
(
"# INFO in TestGenerator.processTestFile(): start saturation"
);
state
.
res
=
saturateGen
(
state
,
timeout
);
if
(
state
.
res
!=
null
)
return
state
;
else
return
null
;
}
return
null
;
}
/** ***************************************************************
* Test method for this class.
*/
public
static
void
main
(
String
[]
args
) {
if
(!
Term
.
emptyString
(
args
[
0
])) {
ClauseEvaluationFunction
.
setupEvaluationFunctions
();
ArrayList
<
EvalStructure
>
evals
=
null
;
HashMap
<
String
,
String
>
opts
=
Prover2
.
processOptions
(
args
);
// canonicalize options
if
(
opts
==
null
) {
System
.
out
.
println
(
"Error in Prover2.main(): bad command line options."
);
return
;
}
evals
=
new
ArrayList
<
EvalStructure
>();
evals
.
add
(
ClauseEvaluationFunction
.
PickGiven5
);
ProofState
state
=
processTestFile
(
opts
.
get
(
"filename"
),
opts
,
evals
);
if
(
state
!=
null
)
Prover2
.
printStateResults
(
opts
,
state
,
null
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL