Propositional Implication Deduction Engine

Hard · Software Engineering Fundamentals · Software Engineer · Online Assessment

Problem Statement

Build a propositional deduction engine that classifies query variables under partial information.

Each proposition is named by an alphanumeric identifier without spaces (such as "BuildGreen" or "VaultSealed"). A literal is either a proposition name "X" (asserting X is true) or "!X" (asserting X is false).

Implement the following function:

def evaluate_propositions(
    facts: List[str],
    rules: List[str],
    queries: List[str],
) -> List[str]:

You receive three inputs:

  • facts: literals ("X" or "!X") known to hold unconditionally.
  • rules: directed implications formatted as "P -> Q", where P and Q are each literals (either positive or negated, such as "!A -> B" or "C -> !D"). Every rule requires that whenever P holds, Q also holds—which automatically enforces the contrapositive "!Q -> !P".
  • queries: unnegated proposition names to classify.

The supplied facts and rules are guaranteed to be mutually consistent (at least one boolean assignment across all variables satisfies every fact and every rule). Across the set of all satisfying boolean assignments, classify each query proposition X in queries (preserving query order) as:

  • "TRUE" if X is true in every satisfying assignment,
  • "FALSE" if X is false in every satisfying assignment, or
  • "CANNOT_DETERMINE" if at least one satisfying assignment makes X true and at least one makes X false.

Examples

Example 1

facts = ["BuildGreen", "!CanaryLive"]
rules = [
    "BuildGreen -> ArtifactSigned",
    "ArtifactSigned -> ReadyToStage",
    "CanaryLive -> TrafficSplit",
]
queries = ["ReadyToStage", "TrafficSplit", "CanaryLive"]
# Expected output: ["TRUE", "CANNOT_DETERMINE", "FALSE"]

Walk-through: BuildGreen forces ArtifactSigned, which in turn forces ReadyToStage ("TRUE"). !CanaryLive pins CanaryLive to false ("FALSE"). Because CanaryLive is false, "CanaryLive -> TrafficSplit" places no constraint on TrafficSplit, leaving both true and false valid ("CANNOT_DETERMINE").

Example 2

facts = ["!VaultSealed"]
rules = [
    "KeyRotated -> VaultSealed",
    "AuditMode -> KeyRotated",
]
queries = ["KeyRotated", "AuditMode"]
# Expected output: ["FALSE", "FALSE"]

Walk-through: Because VaultSealed is false, the contrapositive "!VaultSealed -> !KeyRotated" forces KeyRotated false, and "!KeyRotated -> !AuditMode" then forces AuditMode false.

Example 3

facts = ["RegionEast"]
rules = [
    "CacheHit -> FastReply",
    "!CacheHit -> FastReply",
]
queries = ["FastReply", "CacheHit"]
# Expected output: ["TRUE", "CANNOT_DETERMINE"]

Walk-through: In every valid assignment, CacheHit is either true or false, and both branches force FastReply to hold ("TRUE"), even though CacheHit itself remains unconstrained ("CANNOT_DETERMINE").

Constraints

  • 1 <= len(facts) <= 200
  • 0 <= len(rules) <= 500
  • 1 <= len(queries) <= 200
  • Every proposition identifier consists of 1 to 20 ASCII alphanumeric characters (A-Z, a-z, 0-9).
  • All facts and rules together admit at least one satisfying truth assignment.

Step-by-step walkthrough

  1. Understand the goal: true in EVERY valid world

    Each proposition name (such as "BuildGreen" or "KeyRotated") is a boolean variable that is either true or false. A literal is a variable ("A") or its negation ("!A").

    • Every entry in facts pins down a literal that is unconditionally true ("!CanaryLive" means CanaryLive is false).
    • Every rule "P -> Q" says: whenever P holds, Q must also hold. Notice what a rule forbids and what it allows:
      • If P is true, Q must be true.
      • If Q is false (!Q holds), P cannot be true, so !P must hold. This reversed form, "!Q -> !P", is called the contrapositive and is 100% logically equivalent to "P -> Q".
      • If P is false, the rule places zero restriction on Q (Q could be true or false).

    A truth assignment to all variables that satisfies every fact and every rule is called a valid interpretation (or model). For each query variable X, we classify what happens across all valid models:

    X is true in every valid model                      -> "TRUE"
    X is false in every valid model                     -> "FALSE"
    X is true in >= 1 valid model and false in >= 1     -> "CANNOT_DETERMINE"
    

    With up to 200 facts, 500 rules, and 200 queries, there can be up to ~1,400 distinct variables (~2,800 literals). Listing a brute-force truth table (2^1400 rows) is completely impossible, so we need a graph algorithm over the literals.

  2. Represent literals cleanly so double negations vanish

    If we kept literals as raw strings and negated them by prepending "!", negating "!A" would produce "!!A", which would not match "A". Double negations happen constantly when forming contrapositives—for example, the contrapositive of "!G -> F" is "!F -> !!G", which means "!F -> G".

    Instead, represent every literal as a 2-tuple (name, is_positive):

    "A"   -> ("A", True)
    "!A"  -> ("A", False)
    "!!A" -> ("A", True)
    

    Flipping a literal's truth value is now just not is_positive, with zero string gymnastics:

    def parse_literal(text: str):
        """Parse 'A' -> ('A', True) and '!A' -> ('A', False), canceling double '!'."""
        cleaned = text.strip()
        is_positive = True
        # Each leading '!' flips the truth sign, so '!!A' cleanly becomes ('A', True)
        while cleaned.startswith("!"):
            is_positive = not is_positive
            cleaned = cleaned[1:].strip()
        return (cleaned, is_positive)
    
    
    def negate(literal):
        """Flip ('A', True) <-> ('A', False)."""
        name, is_positive = literal
        return (name, not is_positive)
    
  3. Build the implication graph with contrapositives

    Now turn rules into a directed implication graph where every node is a literal (name, is_positive) and a directed arrow U -> V means "if literal U holds, literal V must also hold."

    Every rule "P -> Q" contributes two arrows: the forward rule P -> Q and its contrapositive !Q -> !P. Without that second arrow, Example 2 (facts = ["!VaultSealed"], rules = ["KeyRotated -> VaultSealed", "AuditMode -> KeyRotated"]) would have no outgoing arrow from !VaultSealed and would miss !KeyRotated and !AuditMode:

    Rule "KeyRotated -> VaultSealed" creates two directed edges:
      ("KeyRotated", True)    --->  ("VaultSealed", True)    [forward]
      ("VaultSealed", False)  --->  ("KeyRotated", False)    [contrapositive]
    
    Rule "!G -> F" creates two directed edges:
      ("G", False)           --->  ("F", True)              [forward]
      ("F", False)           --->  ("G", True)              [contrapositive: negate(("G", False)) = ("G", True)]
    
    def add_edge(graph: dict, source, target) -> None:
        """Append directed implication edge source -> target to adjacency list."""
        if source not in graph:
            graph[source] = []
        graph[source].append(target)
    
    
    def build_graph(rules: List[str]) -> dict:
        """Build implication graph: each 'P -> Q' adds edges P -> Q and !Q -> !P."""
        # graph: dict mapping literal (name, is_positive) -> list of implied literals
        graph = {}
        for rule in rules:
            left_text, right_text = rule.split("->")
            premise = parse_literal(left_text)
            conclusion = parse_literal(right_text)
    
            # Forward implication: if premise holds, conclusion must hold
            add_edge(graph, premise, conclusion)
            # Contrapositive: if conclusion is false, premise must also be false
            add_edge(graph, negate(conclusion), negate(premise))
        return graph
    
  4. Collect consequences with Breadth-First Search (and why not recursion)

    Starting from any set of literals we know (or assume) to be true, every literal reachable along directed arrows in graph is also forced to be true. We find all reachable literals with Breadth-First Search (BFS) using a deque queue and a seen set so cycles in the rules never cause infinite loops.

    Why use an explicit deque instead of recursive DFS? Because 500 rules can create nearly 1,000 edges in a single chain: 499 rules V0 -> V1 -> ... -> V499 plus one rule V499 -> !V499 produce the 999-edge path V0 -> ... -> V499 -> !V499 -> !V498 -> ... -> !V0, which hits CPython's ~1,000-frame recursion limit and raises RecursionError. An iterative queue handles any depth effortlessly:

    from collections import deque
    
    
    def derive(graph: dict, start_literals) -> set:
        """Return all literals reachable from start_literals via iterative BFS."""
        # seen: set of (name, is_positive) literals proven true from start_literals
        seen = set(start_literals)
        # Use a FIFO queue instead of recursion because 500 rules can form a 999-edge path
        queue = deque(start_literals)
    
        while queue:
            current = queue.popleft()
            for implied in graph.get(current, []):
                if implied not in seen:
                    seen.add(implied)
                    queue.append(implied)
        return seen
    
  5. Why forward chaining from facts alone misses valid deductions

    It is tempting to run derive(graph, fact_literals) once and answer "TRUE" if X was reached, "FALSE" if !X was reached, and "CANNOT_DETERMINE" otherwise. That handles direct chains (Examples 1 and 2), yet fails on valid deductions that require reasoning by cases (such as Example 3)!

    Look at two tiny examples where facts = ["RegionEast"]:

    Puzzle 1 (Example 3 case split):  rules = ["CacheHit -> FastReply", "!CacheHit -> FastReply"],  query = "FastReply"
      In every valid world, CacheHit is either True or False:
        - If CacheHit is True,  "CacheHit -> FastReply"  forces FastReply = True.
        - If CacheHit is False, "!CacheHit -> FastReply" forces FastReply = True.
      So FastReply is TRUE in 100% of valid models!
      Yet starting BFS at fact "RegionEast" goes nowhere because no arrow leaves "RegionEast".
    
    Puzzle 2 (self-contradicting premise):  rules = ["X -> Y", "X -> !Y"],  query = "X"
      If X were True, both Y and !Y would have to be True at once (impossible!).
      So X must be FALSE in 100% of valid models—again with zero arrows leaving "RegionEast".
    

    Forward chaining from facts only discovers consequences triggered directly by a known fact; it misses truths forced by the structure of the rules themselves.

  6. Key insight: proof by contradiction makes two-literal deduction exact

    Go right back to the definition: X is "TRUE" in every valid model if and only if no valid model has X false (i.e., !X true).

    So we test !X by proof by contradiction:

    1. Precompute base = derive(graph, fact_literals) once—everything forced by facts.
    2. Temporarily assume assumption (say !X) holds, and compute reached = derive(graph, [assumption]).
    3. Check whether base together with reached forces both some literal Y and its negation !Y. If it does, assumption is impossible!

    Why is "no clash between Y and !Y" a guarantee that a valid model with assumption really exists? Because all our rules have just one literal on each side: take any valid model M of the consistent premises, overwrite every literal in S = base ∪ reached to be true (which is conflict-free since no Y and !Y are both in S), and keep M's truth values for all remaining variables. For any rule P -> Q: - If P is in S, our BFS followed P -> Q, so Q is also in S (and true). - If !Q is in S, our BFS followed !Q -> !P, so !P is also in S (making P false). - Otherwise neither P nor !Q was forced by S, so P and Q could only break the rule if M already broke it—which M does not!

    Because base alone has no internal conflict, any conflict in base ∪ reached must involve at least one literal inside reached:

    def leads_to_conflict(graph: dict, base: set, assumption) -> bool:
        """Return True if adding `assumption` to known `base` derives both Y and !Y."""
        # Derive every consequence forced by temporarily assuming `assumption` holds
        reached = derive(graph, [assumption])
    
        # Because `base` itself is conflict-free, any contradiction must touch `reached`
        for literal in reached:
            opposite = negate(literal)
            if opposite in base or opposite in reached:
                return True
        return False
    
  7. Trace two tricky examples step by step

    Trace 1 — Example 2 (facts = ["!VaultSealed"], rules = ["KeyRotated -> VaultSealed", "AuditMode -> KeyRotated"], queries = ["KeyRotated", "AuditMode"]):

    Graph edges:
      KeyRotated -> VaultSealed,   !VaultSealed -> !KeyRotated
      AuditMode -> KeyRotated,     !KeyRotated -> !AuditMode
    
    Precompute base from facts ["!VaultSealed"]:
      base = { !VaultSealed, !KeyRotated, !AuditMode }
    
    Evaluate query "AuditMode":
      1) Test assumption !AuditMode:
           reached = { !AuditMode }
           opposite AuditMode is neither in base nor in reached -> NO conflict
      2) Test assumption AuditMode:
           reached = { AuditMode, KeyRotated, VaultSealed }
           opposites !AuditMode, !KeyRotated, !VaultSealed ARE in base -> CONFLICT!
      Result -> "FALSE" (and likewise "FALSE" for "KeyRotated")
    

    Trace 2 — Example 3 (facts = ["RegionEast"], rules = ["CacheHit -> FastReply", "!CacheHit -> FastReply"], queries = ["FastReply", "CacheHit"]):

    Graph edges:
      CacheHit -> FastReply,    !FastReply -> !CacheHit
      !CacheHit -> FastReply,   !FastReply -> CacheHit
    base = { RegionEast }
    
    Evaluate query "FastReply":
      1) Test assumption !FastReply:
           !FastReply -> !CacheHit -> FastReply, and !FastReply -> CacheHit -> FastReply
           reached = { !FastReply, !CacheHit, CacheHit, FastReply }
           contains both CacheHit and !CacheHit -> CONFLICT!
      Assuming FastReply is false is impossible -> Result: "TRUE"
    
    Evaluate query "CacheHit":
      1) Test assumption !CacheHit -> reached = { !CacheHit, FastReply } -> no conflict with base { RegionEast }
      2) Test assumption  CacheHit -> reached = {  CacheHit, FastReply } -> no conflict with base { RegionEast }
      Both worlds are valid -> Result: "CANNOT_DETERMINE"
    
  8. Complete solution

    Put all the pieces together inside evaluate_propositions: build graph once, compute base once, and run at most two small BFS checks per query.

    from typing import List
    from collections import deque
    
    
    def parse_literal(text: str):
        """Parse 'A' -> ('A', True) and '!A' -> ('A', False), canceling double '!'."""
        cleaned = text.strip()
        is_positive = True
        # Each leading '!' flips the truth sign, so '!!A' cleanly becomes ('A', True)
        while cleaned.startswith("!"):
            is_positive = not is_positive
            cleaned = cleaned[1:].strip()
        return (cleaned, is_positive)
    
    
    def negate(literal):
        """Flip ('A', True) <-> ('A', False)."""
        name, is_positive = literal
        return (name, not is_positive)
    
    
    def add_edge(graph: dict, source, target) -> None:
        """Append directed implication edge source -> target to adjacency list."""
        if source not in graph:
            graph[source] = []
        graph[source].append(target)
    
    
    def build_graph(rules: List[str]) -> dict:
        """Build implication graph: each 'P -> Q' adds edges P -> Q and !Q -> !P."""
        # graph: dict mapping literal (name, is_positive) -> list of implied literals
        graph = {}
        for rule in rules:
            left_text, right_text = rule.split("->")
            premise = parse_literal(left_text)
            conclusion = parse_literal(right_text)
    
            # Forward implication: if premise holds, conclusion must hold
            add_edge(graph, premise, conclusion)
            # Contrapositive: if conclusion is false, premise must also be false
            add_edge(graph, negate(conclusion), negate(premise))
        return graph
    
    
    def derive(graph: dict, start_literals) -> set:
        """Return all literals reachable from start_literals via iterative BFS."""
        # seen: set of (name, is_positive) literals proven true from start_literals
        seen = set(start_literals)
        # Use a FIFO queue instead of recursion because 500 rules can form a 999-edge path
        queue = deque(start_literals)
    
        while queue:
            current = queue.popleft()
            for implied in graph.get(current, []):
                if implied not in seen:
                    seen.add(implied)
                    queue.append(implied)
        return seen
    
    
    def leads_to_conflict(graph: dict, base: set, assumption) -> bool:
        """Return True if adding `assumption` to known `base` derives both Y and !Y."""
        # Derive every consequence forced by temporarily assuming `assumption` holds
        reached = derive(graph, [assumption])
    
        # Because `base` itself is conflict-free, any contradiction must touch `reached`
        for literal in reached:
            opposite = negate(literal)
            if opposite in base or opposite in reached:
                return True
        return False
    
    
    def evaluate_propositions(facts: List[str], rules: List[str], queries: List[str]) -> List[str]:
        # Phase 1: build the implication graph once and close the unconditionally true facts
        graph = build_graph(rules)
        fact_literals = [parse_literal(fact) for fact in facts]
        # base: set of all literals forced true in every valid model by the facts alone
        base = derive(graph, fact_literals)
    
        # Phase 2: test each query by checking whether false or true causes a contradiction
        answers = []
        for query in queries:
            query_literal = parse_literal(query)
    
            # If assuming !query_literal causes a contradiction, query_literal must be TRUE
            if leads_to_conflict(graph, base, negate(query_literal)):
                answers.append("TRUE")
            # If assuming query_literal causes a contradiction, query_literal must be FALSE
            elif leads_to_conflict(graph, base, query_literal):
                answers.append("FALSE")
            # Otherwise at least one valid model has it true and another has it false
            else:
                answers.append("CANNOT_DETERMINE")
    
        return answers
    

    ✅ Submit now — all tests should pass.

Intuition & how it works

Picture every proposition A as a pair of dominoes on a table: one labeled A ("A is true") and one labeled !A ("A is false"). Each rule "P -> Q" connects domino P to domino Q with a one-way ramp—and because "if P holds then Q holds" is logically identical to "if Q is false then P must be false" (called the contrapositive, the reversed negated form of an implication), that same rule also lays a second ramp from !Q to !P. First, we tip over all known facts dominoes to record every domino base that must fall. Then, to judge a query X, we test by proof by contradiction (assuming the opposite of a statement to see whether an impossible clash follows): we test tipping !X—if doing so knocks over both Y and !Y for any variable Y, then X can never be false, so X is "TRUE"; if tipping X causes such a clash, X is "FALSE"; if neither clashes, both worlds are valid ("CANNOT_DETERMINE").

Why do simpler approaches fall short? Enumerating a truth table (checking all 2^N combinations of True and False across N variables) explodes astronomically as soon as dozens or hundreds of variables appear. Conversely, merely following arrows forward from facts is fast, cleanly solving simple chains, yet misses truths forced by case splits—for example, if "Rain -> Wet" and "!Rain -> Wet", then "Wet" must be true in every valid truth assignment even when no fact mentions "Rain".

Walk through a combined contrapositive and case-split example with facts = ["!VaultSealed"], rules = ["KeyRotated -> VaultSealed", "CacheHit -> FastReply", "!CacheHit -> FastReply"]: 1. Build ramps: "KeyRotated -> VaultSealed" adds KeyRotated -> VaultSealed and !VaultSealed -> !KeyRotated; "CacheHit -> FastReply" adds CacheHit -> FastReply and !FastReply -> !CacheHit; "!CacheHit -> FastReply" adds !CacheHit -> FastReply and !FastReply -> CacheHit. 2. Close facts: Starting from !VaultSealed, Breadth-First Search (BFS) (exploring a graph layer by layer with a queue) reaches base = {!VaultSealed, !KeyRotated}. 3. Query "KeyRotated": Assuming KeyRotated reaches {KeyRotated, VaultSealed}, colliding with !KeyRotated in base -> "FALSE". 4. Query "FastReply": Assuming !FastReply follows !FastReply -> !CacheHit and !FastReply -> CacheHit, colliding on CacheHit and !CacheHit -> !FastReply is impossible, so "FastReply" -> "TRUE".

Complexity

Let F be the number of facts, R the number of rules, Q the number of queries, and L the number of distinct literals (L <= 2 * (F + 2R + Q), at most ~2,800 under the constraints).

  • Time: O(F + R + Q * (L + R)). Parsing R rules and adding two directed edges per rule takes O(R) time, and computing base from F facts runs one BFS visiting each literal and rule edge at most once in O(F + L + R) time. Each of the Q queries runs at most two BFS searches (derive) plus a hash-set scan over reached, costing O(L + R) per query—at most ~1.5 million tiny operations at the maximum limits (F = 200, R = 500, Q = 200).
  • Space: O(L + R). The adjacency list graph stores 2R directed edges across at most L literal keys, and the sets base, seen, and reached plus the BFS deque each hold at most L literals at any moment.

Edge cases

  • Query variable never appears in facts or rules: Assuming !X reaches only {!X} and assuming X reaches only {X}, neither of which conflicts with base, returning "CANNOT_DETERMINE".
  • Query is directly in facts (or negated in facts): If "A" is in facts, "A" is in base; assuming "!A" immediately collides with "A" in base and returns "TRUE".
  • Negated literals inside rules ("!A -> B", "!G -> F"): Representing literals as (name, is_positive) makes negating ("G", False) produce ("G", True) automatically, avoiding "!!G" bugs.
  • Case splits ("A -> B" and "!A -> B"): Assuming "!B" reaches both "!A" and "A" via contrapositives, proving "B" is "TRUE" without knowing "A".
  • Self-contradicting antecedents ("X -> Y" and "X -> !Y"): Assuming "X" derives both "Y" and "!Y", proving "X" must be "FALSE".
  • Deep 999-edge chains through contrapositives: 499 rules V0 -> ... -> V499 plus V499 -> !V499 create a 999-edge path down to !V0; iterative deque BFS avoids RecursionError.
  • Empty rules list or duplicate queries: Works cleanly with graph = {} and preserves exact query order.

Common mistakes

  • Omitting contrapositive edges: Adding P -> Q without !Q -> !P fails whenever a false conclusion forces a premise false (such as !VaultSealed forcing !KeyRotated).
  • Confusing an implication with an if-and-only-if equivalence: "CanaryLive -> TrafficSplit" with "!CanaryLive" does not imply "!TrafficSplit"—adding !P -> !Q wrongly answers "FALSE" instead of "CANNOT_DETERMINE".
  • Only running forward BFS from facts: Misses variables proven true or false via case splits ("A -> B" plus "!A -> B"), violating the "true in all valid interpretations" contract.
  • Keeping literals as unparsed strings: Negating "!A" as "!!A" or failing to strip whitespace around "->" breaks dictionary lookups in the graph.
  • Using recursive DFS: Because each rule generates two edges, a valid 500-rule input can form a 999-step path that overflows Python's default 1,000-frame call stack.

Alternative approaches

  • Single-path 2-SAT check: Because binary implications are an instance of 2-SAT (boolean satisfiability where every constraint is a clause of at most two literals), adding a graph edge !f -> f for each fact f means X is "TRUE" if and only if there is a directed path from !X to X (and "FALSE" if and only if there is a path from X to !X). Our leads_to_conflict check is equivalent because contrapositive symmetry funnels any clash Y and !Y back to X.
  • Strongly Connected Components (SCCs) + DAG reachability: Grouping mutually reachable literals into strongly connected components (maximal groups of nodes where every node can reach every other node) via Tarjan's algorithm in O(L + R) time lets you precompute reachability across the graph when query count Q is huge relative to L.
  • Exhaustive truth table: Testing all 2^N assignments takes exponential time, unusable in production beyond ~20 variables, though great as a tiny randomized test oracle (N = 5).

Follow-up questions

  • If the caller could supply mutually inconsistent facts and rules, how would you check whether at least one valid truth assignment exists? Add a directed edge !f -> f to the implication graph for every fact f (encoding that f cannot be false), then run Tarjan's or Kosaraju's O(L + R) algorithm to find all strongly connected components (clusters of literals that all imply one another in a cycle). By the standard 2-SAT theorem, the premises contain a contradiction—even one hidden entirely inside rules like "A -> B", "A -> !B", "!A -> B", "!A -> !B" with no matching fact—if and only if some variable has both Y and !Y in the same strongly connected component (Y ->* !Y and !Y ->* Y). Extracting the cycle Y -> ... -> !Y -> ... -> Y also gives a human-readable proof of the contradiction.
  • How does the algorithm change if rule premises can combine multiple literals with AND, such as 'P AND Q -> R'? A rule "P AND Q -> R" is equivalent to the 3-literal clause (!P OR !Q OR R), whose contrapositive !R -> (!P OR !Q) splits into an OR rather than a single graph arrow. If rules only have positive preconditions leading to a single literal (P AND Q -> R or P AND Q -> !R), every constraint is a Horn clause (a disjunction with at most one positive literal), where unit propagation—maintaining an unsatisfied-premise counter on each clause and firing whenever all but one literal in the clause are falsified (so known P and !R also force !Q)—still decides "TRUE" / "FALSE" / "CANNOT_DETERMINE" exactly in O(Q * total_rule_size) time! If rules also allow arbitrary negations on the left like "!P AND !Q -> R" (P OR Q OR R), the problem becomes general 3-SAT (which is coNP-complete to check across all models), requiring two calls to a CDCL SAT solver per query (Premises + !X and Premises + X).
  • Suppose each implication rule holds only with a given probability; how could you estimate lower and upper probability bounds for a query? Under independent rule probabilities (Dempster-Shafer style), treat each rule r_i as active in a sampled world with probability p_i, drop worlds whose active rules contradict the facts or each other, and normalize over consistent worlds: belief (the lower bound) is P(world proves X | consistent) and plausibility (the upper bound) is 1 - P(world proves !X | consistent). For example, with facts A, D and independent rules A -> B (0.9), B -> C (0.8, so chain 0.72), and D -> !C (0.5), conflicting worlds have probability 0.72 * 0.5 = 0.36 (leaving 0.64 consistent mass), C-proving worlds have 0.72 * 0.5 = 0.36 (Bel(C) = 0.36 / 0.64 = 0.5625), and !C-proving worlds have 0.28 * 0.5 = 0.14 (Pl(C) = 1 - 0.14 / 0.64 = 0.78125). Because exact summation over 2^R worlds is #P-hard, estimate both bounds via Monte Carlo sampling (K = 10,000 kept worlds gives standard error <= 0.5 / sqrt(10,000) = 0.005), or use linear programming (Nilsson probabilistic logic) if rule probabilities are not assumed independent.

Follow-up questions

Similar questions

More Epic Systems interview questions

All 3 Epic Systems questions →