File size: 2,705 Bytes
134a00c
e61901b
134a00c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import re
from .explainer_types import ExplainerResult, ExplainerScaffold


def explain_probability_question(text: str) -> ExplainerResult | None:
    t = text.lower()

    # ✅ STRONG detection
    probability_signals = [
        "probability",
        "chance",
        "odds",
        "random",
        "chosen at random",
        "selected at random",
        "picked at random",
        "drawn",
        "without replacement",
        "with replacement",
    ]

    has_probability = any(p in t for p in probability_signals)

    if not has_probability:
        return None

    givens = []
    relationships = []
    constraints = []
    trap_notes = []

    numbers = re.findall(r"\b\d+\b", t)

    if numbers:
        givens.append(f"Numbers mentioned: {', '.join(numbers[:5])}")
    else:
        givens.append("A situation involving possible outcomes is described")

    if "without replacement" in t:
        relationships.append("The probabilities change after each selection")
        constraints.append("The total number of items decreases after each draw")

    if "with replacement" in t:
        relationships.append("The probabilities stay the same for each selection")

    if "at least" in t:
        relationships.append("This may require using the complement (1 - probability of the opposite event)")

    if "both" in t or "and" in t:
        relationships.append("You may need to combine probabilities of multiple events occurring together")

    if "or" in t:
        relationships.append("You may need to consider multiple possible favorable cases")

    # default structure
    relationships.append("Probability = favorable outcomes ÷ total possible outcomes")

    asks_for = "the probability of a specific event occurring"

    trap_notes.extend([
        "Make sure you correctly identify the total number of possible outcomes",
        "Check whether events are independent or dependent",
        "Watch for 'at least' — often easier to use the complement",
        "Be careful not to double count outcomes",
    ])

    return ExplainerResult(
        understood=True,
        topic="probability",
        asks_for=asks_for,
        givens=givens,
        constraints=constraints,
        relationships=relationships,
        needed_concepts=[
            "favorable vs total outcomes",
            "independent vs dependent events",
            "complement rule",
        ],
        trap_notes=trap_notes,
        strategy_hint="Start by identifying all possible outcomes, then count how many satisfy the condition.",
        plain_english="The question is asking you to work out how likely an event is by comparing favorable outcomes to all possible outcomes.",
    )