aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/rsacomb/SkolemStrategy.scala
blob: a2ad0a12321be588e7793ac2a445b2427a58756e (plain) (blame)
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
package rsacomb

import tech.oxfordsemantic.jrdfox.logic.Datatype
import tech.oxfordsemantic.jrdfox.logic.expression.{Literal, IRI}

sealed trait SkolemStrategy

object SkolemStrategy {
  // TODO: might want to use something else other than `hashCode` as a
  // function to generate a fresh function/constant

  /* No skolemization at all.
   *
   * From
   *    ∃R.A ⊑ B
   * to
   *    R(x,y), B(y) -> B(x)
   */
  case object None extends SkolemStrategy

  /* Functional skolemization
   *
   * From
   *    A ⊑ ∃R.B
   * to
   *    A(x) -> R(x,f(x)), B(f(x))
   * for f, fresh function associated with the input axiom
   *
   * In RDFox this can represented combining the BIND operator with the
   * SKOLEM operator as such:
   *    A(x), BIND(y, SKOLEM("f", x)) -> R(x,y), B(y)
   * The first argument of a SKOLEM call is a literal string (ideally
   * identifing the simulated function name).
   *
   * NOTE: this requirement for the SKOLEM operator is not enforced by
   * RDFox, that will fail silently if omitted.
   */
  case class Standard(func: Literal) extends SkolemStrategy
  object Standard {
    def apply(axiom: String) =
      new Standard(
        Literal.create(genFunctionString(axiom), Datatype.XSD_STRING)
      )
    def genFunctionString(str: String) = "f_" ++ str.hashCode.toString
  }

  /* Constant skolemization
   *
   * From
   *    A ⊑ ∃R.B
   * to
   *    A(y) -> R(x,c), B(c)
   * for c, fresh constant associated with the input axiom
   */
  case class Constant(const: IRI) extends SkolemStrategy
  object Constant {
    def apply(axiom: String) =
      new Constant(IRI.create(genConstantString(axiom)))
    def genConstantString(str: String) = "c_" ++ str.hashCode.toString
  }

  /* (RSA) Constant skolemization
   * This is a special skolemization option to introduce additional atoms for RSA
   * checking algorithm.
   *
   * From
   *    A ⊑ ∃R.B
   * to
   *    A(y) -> R(x,c), PE(x,c), B(c)
   * for c, fresh constant associated with the input axiom and PE an internal predicate.
   */
  case class ConstantRSA(const: IRI) extends SkolemStrategy
  object ConstantRSA {
    def apply(axiom: String) =
      new ConstantRSA(IRI.create(genConstantString(axiom)))
    def genConstantString(str: String) = "c_" ++ str.hashCode.toString
  }
}