Skip to content

Commit 531ba96

Browse files
Fix equality infix printing + parsing issues
1 parent 4a6bbbb commit 531ba96

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

lisa-examples/src/main/scala/TPTPSolver.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ object TPTPSolver extends lisa.Main {
1919

2020
class ProblemSolverResults(val problem: Problem, val solverName: String, val solverStatus: String, val proofCode: String, val proofType: ProofType)
2121

22+
val spc = Seq("PRP", "FOF") // type of problems we want to extract and solve
23+
// val spc = Seq("CNF") // almost no CNF problems are solved by Tableau, TODO: investigate why
24+
25+
// We limit the execution time to solve each problem
26+
val timeoutTableau = .1.second
27+
val timeoutTautology = .1.second
28+
2229
val exportOnlySolvedProblems = true
2330
val exportOptimizedProofs = true
2431
val exportBySolverProofs = true
2532

2633
val jsonResultsPath: String = "/home/auguste/Documents/EPFL/PhD/Projects/lisa/lisa-examples/src/main/resources/TPTPResults.json"
2734
val TPTPProblemPath: String = "/home/auguste/Documents/EPFL/PhD/Projects/TPTP-v8.2.0/Problems/"
2835

29-
val spc = Seq("PRP", "FOF") // type of problems we want to extract and solve
30-
// val spc = Seq("CNF") // almost no CNF problems are solved by Tableau, TODO: investigate why
31-
32-
// val d = new File(TPTPProblemPath)
33-
// val libraries = d.listFiles.filter(_.isDirectory)
34-
// val probfiles = libraries.flatMap(_.listFiles).filter(_.isFile)
35-
36-
val d = new File(TPTPProblemPath + "SYN/")
37-
val probfiles = d.listFiles.filter(_.isFile)
36+
val d = new File(TPTPProblemPath)
37+
val libraries = d.listFiles.filter(_.isDirectory)
38+
val probfiles = libraries.flatMap(_.listFiles).filter(_.isFile)
3839

39-
// We limit the execution time to solve each problem
40-
val timeoutTableau = .1.second
41-
val timeoutTautology = .1.second
40+
// val d = new File(TPTPProblemPath + "SYN/")
41+
// val probfiles = d.listFiles.filter(_.isFile)
4242

4343
var nbProblemsExtracted = 0
4444
var nbProblemsSolved = Map("Tableau" -> 0, "Tautology" -> 0)
@@ -120,8 +120,8 @@ object TPTPSolver extends lisa.Main {
120120
"problemFile" -> r.problem.file,
121121
"solver" -> r.solverName,
122122
"solverStatus" -> r.solverStatus,
123-
"solverProofCode" -> r.proofCode,
124-
"proofType" -> r.proofType.getClass.getSimpleName.stripSuffix("$")
123+
"proofType" -> r.proofType.getClass.getSimpleName.stripSuffix("$"),
124+
"solverProofCode" -> r.proofCode
125125
)
126126
),
127127
jsonWriter,

lisa-utils/src/main/scala/lisa/fol/Common.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ trait Common {
610610
def rename(newid: Identifier): ConstantPredicateLabel[N] = ConstantPredicateLabel(newid, arity)
611611
def freshRename(taken: Iterable[Identifier]): ConstantPredicateLabel[N] = rename(K.freshId(taken, id))
612612
override def toString(): String = id
613-
def mkString(args: Seq[Term]): String = if (infix) (args(0).toStringSeparated() + " " + toString() + " " + args(1).toStringSeparated()) else toString() + "(" + args.mkString(", ") + ")"
613+
def mkString(args: Seq[Term]): String =
614+
if (infix) ("(" + args(0).toStringSeparated() + " " + toString() + " " + args(1).toStringSeparated() + ")") else toString() + "(" + args.mkString(", ") + ")"
614615
override def mkStringSeparated(args: Seq[Term]): String = if (infix) "(" + mkString(args) + ")" else mkString(args)
615616
}
616617
object ConstantPredicateLabel {

lisa-utils/src/main/scala/lisa/fol/FOLHelpers.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ object FOLHelpers {
8484
case cl: K.SchematicConnectorLabel => asFrontLabel(cl)
8585
def asFrontLabel[N <: Arity](cpl: K.ConstantAtomicLabel): ConstantAtomicLabelOfArity[N] = cpl.arity.asInstanceOf[N] match
8686
case n: 0 => ConstantFormula(cpl.id)
87-
case n: N => ConstantPredicateLabel(cpl.id, cpl.arity.asInstanceOf)
87+
case n: N =>
88+
if (cpl.id == Identifier("="))
89+
ConstantPredicateLabel.infix("===", cpl.arity.asInstanceOf)
90+
else
91+
ConstantPredicateLabel(cpl.id, cpl.arity.asInstanceOf)
8892
def asFrontLabel(sfl: K.SchematicFormulaLabel): SchematicAtomicLabel[?] | SchematicConnectorLabel[?] =
8993
sfl match
9094
case v: K.VariableFormulaLabel => asFrontLabel(v)

lisa-utils/src/main/scala/lisa/utils/tptp/KernelParser.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ object KernelParser {
2727
*/
2828
def parseToKernel(formula: String): K.Formula = convertToKernel(Parser.fof(formula))
2929

30-
def cleanVarname(f: String): String = f.replaceAll(Identifier.counterSeparator.toString, "")
30+
def cleanVarname(f: String): String =
31+
val forbiddenChars = Identifier.forbiddenChars ++ Set('\\', '/', '\'', '"', '`', '.', ',', ';', ':', '!', '%', '^', '&', '*', '|', '-', '+', '=', '<', '>', '~', '@', '#')
32+
// replace all the forbidden chars + whitespaces by '0'
33+
f.map(c => if (forbiddenChars.contains(c) || c.isWhitespace) then '0' else c)
3134

3235
/**
3336
* @param formula a tptp formula in leo parser
@@ -96,7 +99,7 @@ object KernelParser {
9699
else K.SchematicFunctionLabel(cleanVarname(f), args.size),
97100
args map convertTermToKernel
98101
)
99-
case CNF.Variable(name) => K.VariableTerm(K.VariableLabel(name))
102+
case CNF.Variable(name) => K.VariableTerm(K.VariableLabel(cleanVarname(name)))
100103
case CNF.DistinctObject(name) => ???
101104
}
102105

@@ -111,7 +114,7 @@ object KernelParser {
111114
else K.SchematicFunctionLabel(cleanVarname(f), args.size),
112115
args map convertTermToKernel
113116
)
114-
case FOF.Variable(name) => K.VariableTerm(K.VariableLabel(name))
117+
case FOF.Variable(name) => K.VariableTerm(K.VariableLabel(cleanVarname(name)))
115118
case FOF.DistinctObject(name) => ???
116119
case FOF.NumberTerm(value) => ???
117120
}
@@ -171,7 +174,7 @@ object KernelParser {
171174
if (problem.spc.contains("CNF")) problem.formulas.map(_.formula) |- ()
172175
else
173176
problem.formulas.foldLeft[LK.Sequent](() |- ())((s, f) =>
174-
if (f._1 == "axiom") s +<< f._3
177+
if (Set("axiom", "hypothesis", "lemma").contains(f._1)) s +<< f._3
175178
else if (f._1 == "conjecture" && s.right.isEmpty) s +>> f._3
176179
else throw Exception("Can only agglomerate axioms and one conjecture into a sequents")
177180
)

0 commit comments

Comments
 (0)