Detect whether conditions in conditional if-rules may generate contradictions. Strictly speaking these rules do not make the rule set infeasible but rather make the if-condition unsatisfiable. Semantically speaking these rules are contradicting, because the writer of the rule set did not have the intention to make the condition forbidden.

detect_contradicting_if_rules(x, ..., verbose = interactive())

Arguments

x

A validator object.

...

Additional arguments passed to detect_if_clauses.

verbose

Logical. If TRUE, print the results.

Value

A list of contradictions found in the if clauses, or NULL if none are found.

Details

In general it detects (variations on) cases where:

  • if (A) B and if (A) !B, which probably is not intended, but logically equals !A.

  • if (A) B and if (B) !A, which probably is not intended but logically equals !A.

See examples for more details.

Examples

rules <- validator(
  if (nace == "a") export == "y",
  if (nace == "a")  export == "n"
)

conflicts <- detect_contradicting_if_rules(rules, verbose=TRUE)
#> 1 contradiction(s) with if clauses found:
#> When nace == "a":
#>   V1: if (nace == "a") export == "y"
#>   V2: if (nace == "a") export == "n"

print(conflicts)
#> $`nace == "a"`
#> [1] "V1" "V2"
#> 


# this creates a implicit contradiction when income > 0
rules <- validator(
  rule1 = if (income > 0) job == "yes",
  rule2 = if (job == "yes") income == 0
)

conflicts <- detect_contradicting_if_rules(rules, verbose=TRUE)
#> 1 contradiction(s) with if clauses found:
#> When income > 0:
#>   rule2: if (job == "yes") income == 0
#>   rule1: if (income > 0) job == "yes"