diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-06-09 13:01:08 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-06-09 13:01:08 +0100 |
| commit | 12245a5550817cf20b1d67690078a1808844b1f1 (patch) | |
| tree | 8c9ecfac3a8df7123cd702851617f6e38ed9aea6 | |
| parent | 76e2dbd7a0d3a01d8ae71a015fa995c9c5032e37 (diff) | |
| download | RSAComb-12245a5550817cf20b1d67690078a1808844b1f1.tar.gz RSAComb-12245a5550817cf20b1d67690078a1808844b1f1.zip | |
improve: avoid generating duplicate rules in filtering program
| -rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/filtering/RevisedFilteringProgram2.scala | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/filtering/RevisedFilteringProgram2.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/filtering/RevisedFilteringProgram2.scala index 3d70b03..a3e4ab6 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/filtering/RevisedFilteringProgram2.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/filtering/RevisedFilteringProgram2.scala | |||
| @@ -177,10 +177,10 @@ class RevisedFilteringProgram2( | |||
| 177 | * @note corresponds to rules 4x in Table 3. | 177 | * @note corresponds to rules 4x in Table 3. |
| 178 | */ | 178 | */ |
| 179 | val r4a = for { | 179 | val r4a = for { |
| 180 | role1 <- queryBody filter (_.isRoleAssertion) | 180 | (role1,i) <- queryBody.zipWithIndex filter (_._1.isRoleAssertion) |
| 181 | index1 = query.bounded indexOf (role1.getArguments get 2) | 181 | index1 = query.bounded indexOf (role1.getArguments get 2) |
| 182 | if index1 >= 0 | 182 | if index1 >= 0 |
| 183 | role2 <- queryBody filter (_.isRoleAssertion) | 183 | (role2,_) <- queryBody.zipWithIndex filter { case (r,j) => j > i && r.isRoleAssertion } |
| 184 | index2 = query.bounded indexOf (role2.getArguments get 2) | 184 | index2 = query.bounded indexOf (role2.getArguments get 2) |
| 185 | if index2 >= 0 | 185 | if index2 >= 0 |
| 186 | } yield Rule.create( | 186 | } yield Rule.create( |
| @@ -201,6 +201,7 @@ class RevisedFilteringProgram2( | |||
| 201 | role2 <- queryBody filter (_.isRoleAssertion) | 201 | role2 <- queryBody filter (_.isRoleAssertion) |
| 202 | index2 = query.bounded indexOf (role2.getArguments get 0) | 202 | index2 = query.bounded indexOf (role2.getArguments get 0) |
| 203 | if index2 >= 0 | 203 | if index2 >= 0 |
| 204 | if role1.getArguments.get(0) != role2.getArguments.get(2) | ||
| 204 | } yield Rule.create( | 205 | } yield Rule.create( |
| 205 | FK(v"K"), | 206 | FK(v"K"), |
| 206 | RSA.Skolem(v"S", List(RSA(index1), RSA(index2))), | 207 | RSA.Skolem(v"S", List(RSA(index1), RSA(index2))), |
| @@ -213,10 +214,10 @@ class RevisedFilteringProgram2( | |||
| 213 | ) | 214 | ) |
| 214 | ) | 215 | ) |
| 215 | val r4c = for { | 216 | val r4c = for { |
| 216 | role1 <- queryBody filter (_.isRoleAssertion) | 217 | (role1,i) <- queryBody.zipWithIndex filter (_._1.isRoleAssertion) |
| 217 | index1 = query.bounded indexOf (role1.getArguments get 0) | 218 | index1 = query.bounded indexOf (role1.getArguments get 0) |
| 218 | if index1 >= 0 | 219 | if index1 >= 0 |
| 219 | role2 <- queryBody filter (_.isRoleAssertion) | 220 | (role2,_) <- queryBody.zipWithIndex filter { case (r,j) => j > i && r.isRoleAssertion } |
| 220 | index2 = query.bounded indexOf (role2.getArguments get 0) | 221 | index2 = query.bounded indexOf (role2.getArguments get 0) |
| 221 | if index2 >= 0 | 222 | if index2 >= 0 |
| 222 | } yield Rule.create( | 223 | } yield Rule.create( |
| @@ -236,12 +237,12 @@ class RevisedFilteringProgram2( | |||
| 236 | * @note corresponds to rules 5x in Table 3. | 237 | * @note corresponds to rules 5x in Table 3. |
| 237 | */ | 238 | */ |
| 238 | val r5a = for { | 239 | val r5a = for { |
| 239 | role1 <- queryBody filter (_.isRoleAssertion) | 240 | (role1,i) <- queryBody.zipWithIndex filter (_._1.isRoleAssertion) |
| 240 | r1arg0 = role1.getArguments get 0 | 241 | r1arg0 = role1.getArguments get 0 |
| 241 | if query.bounded contains r1arg0 | 242 | if query.bounded contains r1arg0 |
| 242 | r1arg2 = role1.getArguments get 2 | 243 | r1arg2 = role1.getArguments get 2 |
| 243 | if query.bounded contains r1arg2 | 244 | if query.bounded contains r1arg2 |
| 244 | role2 <- queryBody filter (_.isRoleAssertion) | 245 | (role2,_) <- queryBody.zipWithIndex filter { case (r,j) => j > i && r.isRoleAssertion } |
| 245 | r2arg0 = role2.getArguments get 0 | 246 | r2arg0 = role2.getArguments get 0 |
| 246 | if query.bounded contains r2arg0 | 247 | if query.bounded contains r2arg0 |
| 247 | r2arg2 = role2.getArguments get 2 | 248 | r2arg2 = role2.getArguments get 2 |
| @@ -292,12 +293,12 @@ class RevisedFilteringProgram2( | |||
| 292 | ) | 293 | ) |
| 293 | ) | 294 | ) |
| 294 | val r5c = for { | 295 | val r5c = for { |
| 295 | role1 <- queryBody filter (_.isRoleAssertion) | 296 | (role1,i) <- queryBody.zipWithIndex filter (_._1.isRoleAssertion) |
| 296 | r1arg0 = role1.getArguments get 0 | 297 | r1arg0 = role1.getArguments get 0 |
| 297 | if query.bounded contains r1arg0 | 298 | if query.bounded contains r1arg0 |
| 298 | r1arg2 = role1.getArguments get 2 | 299 | r1arg2 = role1.getArguments get 2 |
| 299 | if query.bounded contains r1arg2 | 300 | if query.bounded contains r1arg2 |
| 300 | role2 <- queryBody filter (_.isRoleAssertion) | 301 | (role2,_) <- queryBody.zipWithIndex filter { case (r,j) => j > i && r.isRoleAssertion } |
| 301 | r2arg0 = role2.getArguments get 0 | 302 | r2arg0 = role2.getArguments get 0 |
| 302 | if query.bounded contains r2arg0 | 303 | if query.bounded contains r2arg0 |
| 303 | r2arg2 = role2.getArguments get 2 | 304 | r2arg2 = role2.getArguments get 2 |
