Skip to content

Commit 5c6e103

Browse files
author
Alexander Steen
committed
add check that defaults to HOL embedding if extended specifications are given that are not supported by the FOL embedding
1 parent 13c500b commit 5c6e103

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ thf(advanced,logic,(
110110
$quantification == $cumulative,
111111
$modalities ==
112112
[ $modal_system_S5,
113-
[#a] == $modal_system_KB,
114-
[#b] == $modal_system_K ] ] )).
113+
{$box(#a)} == $modal_system_KB,
114+
{$box(#b)} == $modal_system_K ] ] )).
115115
```
116116
Here box operator a is system KB, box operator b is K. Of course, also lists of axiom schemes can be used. All further modal operators are S5 (if existent).
117117

embedding-runtime/src/main/scala/leo/modules/embeddings/ModalEmbedding.scala

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ object ModalEmbedding extends Embedding {
3636
val maybeSpec = getLogicSpecFromProblem(problem.formulas)
3737
maybeSpec match {
3838
case Some(spec) if spec.formulaType == TPTP.AnnotatedFormula.FormulaType.TFF =>
39-
System.err.println(s"%%% First-order input detected, using modal-logic-to-TFF embedding (redirected from embedding '$$$name' to embedding '${FirstOrderManySortedToTXFEmbedding.name}' version ${FirstOrderManySortedToTXFEmbedding.version}). Use flag -p FORCE_HIGHERORDER if you want to have THF output instead.")
40-
/* create new parameter set */
41-
var parameters: Set[FirstOrderManySortedToTXFEmbedding.FOMLToTXFEmbeddingParameter.Value] = Set.empty
42-
if (embeddingOptions.contains(ModalEmbeddingOption.POLYMORPHIC)) parameters = parameters + FOMLToTXFEmbeddingParameter.POLYMORPHIC
43-
if (embeddingOptions.contains(ModalEmbeddingOption.EMPTYDOMAINS)) parameters = parameters + FOMLToTXFEmbeddingParameter.EMPTYDOMAINS
44-
if (embeddingOptions.contains(ModalEmbeddingOption.LOCALEXTENSION)) parameters = parameters + FOMLToTXFEmbeddingParameter.LOCALEXTENSION
45-
FirstOrderManySortedToTXFEmbedding.apply(problem, parameters)
39+
// Fallback to HOL embedding if problem
40+
// contains extended specification entries (interaction axioms, meta-axioms, etc....)
41+
if (testSpecForExtendedEntries(spec)) new ModalEmbeddingImpl(problem, embeddingOptions).apply()
42+
else {
43+
System.err.println(s"%%% First-order input detected, using modal-logic-to-TFF embedding (redirected from embedding '$$$name' to embedding '${FirstOrderManySortedToTXFEmbedding.name}' version ${FirstOrderManySortedToTXFEmbedding.version}). Use flag -p FORCE_HIGHERORDER if you want to have THF output instead.")
44+
/* create new parameter set */
45+
var parameters: Set[FirstOrderManySortedToTXFEmbedding.FOMLToTXFEmbeddingParameter.Value] = Set.empty
46+
if (embeddingOptions.contains(ModalEmbeddingOption.POLYMORPHIC)) parameters = parameters + FOMLToTXFEmbeddingParameter.POLYMORPHIC
47+
if (embeddingOptions.contains(ModalEmbeddingOption.EMPTYDOMAINS)) parameters = parameters + FOMLToTXFEmbeddingParameter.EMPTYDOMAINS
48+
if (embeddingOptions.contains(ModalEmbeddingOption.LOCALEXTENSION)) parameters = parameters + FOMLToTXFEmbeddingParameter.LOCALEXTENSION
49+
FirstOrderManySortedToTXFEmbedding.apply(problem, parameters)
50+
}
4651
case _ => new ModalEmbeddingImpl(problem, embeddingOptions).apply()
4752
}
4853
}
@@ -1446,4 +1451,22 @@ object ModalEmbedding extends Embedding {
14461451

14471452
}
14481453

1454+
// Check if the logic spec contains interactions or other meta-axioms/-properties.
1455+
private[this] def testSpecForExtendedEntries(spec: TPTP.AnnotatedFormula): Boolean = {
1456+
import leo.modules.tptputils.SyntaxTransform.transformAnnotatedFormula
1457+
val specTHF = transformAnnotatedFormula(TPTP.AnnotatedFormula.FormulaType.THF, spec)
1458+
var result = false
1459+
specTHF.formula match {
1460+
case THF.Logical(THF.BinaryFormula(THF.==, THF.FunctionTerm(name, Seq()), THF.Tuple(spec0))) if Seq("$modal", "$alethic_modal", "$deontic_modal", "$epistemic_modal") contains name =>
1461+
spec0 foreach {
1462+
case THF.BinaryFormula(THF.==, THF.FunctionTerm("$modalities", Seq()), rhs) =>
1463+
val (_, _, mapFormulas, metaAxioms) = parseTHFModalSpecRHS(rhs)
1464+
if (mapFormulas.nonEmpty || metaAxioms.nonEmpty) result = true
1465+
case _ => () // NOP
1466+
}
1467+
result
1468+
case _ => false
1469+
}
1470+
}
1471+
14491472
}

0 commit comments

Comments
 (0)