0

I have a logiql file with many "complicated" rules.

Here are some examples:

tuple1(x), tuple2(x), function1[y, z] = x <- in_tuple1(x), in_tuple2(x, y), in_tuple3[x, y] = z.

tuple1(x,y) <- (in_tuple1(x,z), in_tuple2(y,z)); in_tuple2(x,y)

For my purposes it would be much better to have only rules in the simple form: only one derived tuple per rule and no "OR" combinations of rules.

Does logicblox offer some intermediate representation output that only consists of the simpler rules?

meow
  • 27
  • 4

1 Answers1

1

I think there are intermediate representations created, but I don't know how to unearth them. Even if I did, I think my first advice would be to write the simpler rules you want.

I'm quite confident that the first example can be re-written as follows.

Example 1 Before

tuple1(x),
tuple2(x),
function1[y, z] = x
<-
  in_tuple1(x),
  in_tuple2(x, y),
  in_tuple3[x, y] = z.

Example 1 After

tuple1(x) <- in_tuple1(x), in_tuple2(x, y), in_tuple3[x, y] = _.
tuple2(x) <- in_tuple1(x), in_tuple2(x, y), in_tuple3[x, y] = _.
/** alternatively
  tuple1(x) <- function1[_, _] = x.
  tuple2(x) <- function1[_, _] = x.
**/

function1[y, z] = x
<-
  in_tuple1(x),
  in_tuple2(x, y),
  in_tuple3[x, y] = z.

I'm a little less confident with the second one. No conflicts between the two rules jump out at me. If there is a problem here you may get a functional dependency violation, which you'll know by the output or logging of "Error: Function cannot contain conflicting records."

Example 2 Before (assumed complete clause with "." at end)

tuple1(x,y)
<-
  (
    in_tuple1(x,z),
    in_tuple2(y,z)
  )
  ;
  in_tuple2(x,y).

Example 2 After

tuple1(x,y)
<-
  in_tuple1(x,z),
  in_tuple2(y,z).

tuple1(x,y)
<-
  in_tuple2(x,y).