@@ -31,22 +31,34 @@ object Struct:
31
31
private case class StructImpl (functor : Atom , arguments : Term * ) extends Struct :
32
32
override val arity : Int = arguments.size
33
33
34
- trait Rule extends Struct :
35
- val head : Struct
34
+ trait Clause extends Struct :
35
+ val head : Option [Struct ]
36
+ val body : Term
37
+
38
+ trait Directive extends Clause :
39
+ override val head : Option [Struct ] = None
40
+
41
+ trait Rule extends Clause :
42
+ val head : Option [Struct ]
36
43
val body : Term
37
44
final override val functor : Atom = CLAUSE
38
45
final override val arity : Int = 2
39
- final override val arguments : Seq [Term ] = Seq (head, body)
40
- final override def isGround : Boolean = head.isGround && body.isGround
41
- final override def variables : Seq [Variable ] = head.variables ++ body.variables
42
46
43
47
object Rule :
44
48
def apply (head : Struct , args : Term * ): Rule = RuleImpl (head, Conjunction .wrapIfNecessary(args* ))
45
- private case class RuleImpl (head : Struct , body : Term ) extends Rule
49
+ private case class RuleImpl (_head : Struct , body : Term ) extends Rule :
50
+ override val head : Option [Struct ] = Option (_head)
51
+ override val arguments : Seq [Term ] = Seq (head.get, body)
52
+ override def isGround : Boolean = head.get.isGround && body.isGround
53
+ override def variables : Seq [Variable ] = head.get.variables ++ body.variables
46
54
47
55
trait Fact extends Rule :
48
56
override val body : Term = Atom (" true" )
49
57
50
58
object Fact :
51
59
def apply (head : Struct ): Fact = FactImpl (head)
52
- private case class FactImpl (head : Struct ) extends Fact
60
+ private case class FactImpl (_head : Struct ) extends Fact :
61
+ override val head : Option [Struct ] = Option (_head)
62
+ override val arguments : Seq [Term ] = Seq (head.get)
63
+ override def isGround : Boolean = head.get.isGround
64
+ override def variables : Seq [Variable ] = head.get.variables
0 commit comments