Datdanboi25 commited on
Commit
f96d3fe
·
1 Parent(s): 73874c5

initial commit

Browse files
Files changed (2) hide show
  1. logicmark.jsonl +0 -0
  2. logicmark_gen.py +724 -0
logicmark.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
logicmark_gen.py ADDED
@@ -0,0 +1,724 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import random
3
+ import itertools
4
+ from pathlib import Path
5
+
6
+ random.seed(42)
7
+
8
+ TARGET_PER_DOMAIN = 2000
9
+ OUTPUT_FILE = "/mnt/user-data/outputs/logicmark.jsonl"
10
+
11
+ # ═════════════════════════════════════════════════════════════
12
+
13
+ # HELPERS
14
+
15
+ # ═════════════════════════════════════════════════════════════
16
+
17
+ def cap(s):
18
+ return s[0].upper() + s[1:] if s else s
19
+
20
+ def fill(template_str, obj):
21
+ return template_str.format(**obj)
22
+
23
+ # ═════════════════════════════════════════════════════════════
24
+
25
+ # COMPUTATION FIXES (ONLY ADDITIONS)
26
+
27
+ # ═════════════════════════════════════════════════════════════
28
+
29
+ DIRS = ["north", "east", "south", "west"]
30
+
31
+ def rotate(start_dir, deg, clockwise=True):
32
+ idx = DIRS.index(start_dir)
33
+ steps = (deg // 90) % 4
34
+ return DIRS[(idx + steps) % 4] if clockwise else DIRS[(idx - steps) % 4]
35
+
36
+ def compute_spatial(obj):
37
+ d = rotate(obj["start_dir"], obj["deg1"], obj["rot1"] == "clockwise")
38
+ d = rotate(d, obj["deg2"], obj["rot2"] == "clockwise")
39
+ obj["final_dir"] = d
40
+
41
+
42
+ # displacement
43
+ x = y = 0
44
+ for dist, direction in [(obj.get("d1"), obj.get("dir1")),
45
+ (obj.get("d2"), obj.get("dir2")),
46
+ (obj.get("d3"), obj.get("dir3"))]:
47
+ if not direction:
48
+ continue
49
+ if direction == "north": y += dist
50
+ if direction == "south": y -= dist
51
+ if direction == "east": x += dist
52
+ if direction == "west": x -= dist
53
+
54
+ if "net_dist" in obj:
55
+ if abs(x) >= abs(y):
56
+ obj["net_dist"] = abs(x)
57
+ obj["net_dir"] = "east" if x > 0 else "west"
58
+ else:
59
+ obj["net_dist"] = abs(y)
60
+ obj["net_dir"] = "north" if y > 0 else "south"
61
+
62
+
63
+ def compute_math(obj):
64
+ if "start" in obj and "n_periods" in obj:
65
+ obj["final_val"] = obj["start"] * (2 ** obj["n_periods"])
66
+
67
+ if "fill_rate" in obj:
68
+ net = obj["fill_rate"] - obj["drain_rate"]
69
+ start = obj["capacity"] * (obj["start_pct"] / 100)
70
+ obj["time_to_full"] = int(round((obj["capacity"] - start) / net))
71
+
72
+ if "base_days" in obj:
73
+ total = 3 + obj["extra_workers"]
74
+ obj["new_days"] = int(round(obj["base_days"] * (3 / total)))
75
+
76
+
77
+ def compute_temporal(obj):
78
+ if "deadline" not in obj:
79
+ return
80
+
81
+
82
+ total = obj["dur_a"] + obj["dur_b"] + obj["dur_c"]
83
+
84
+ h, suffix = obj["deadline"].split()
85
+ hh, mm = map(int, h.split(":"))
86
+
87
+ minutes = hh * 60 + mm
88
+ if suffix == "PM" and hh != 12:
89
+ minutes += 720
90
+ if suffix == "AM" and hh == 12:
91
+ minutes -= 720
92
+
93
+ start = minutes - total
94
+ hh = (start // 60) % 24
95
+ mm = start % 60
96
+
97
+ suffix = "AM" if hh < 12 else "PM"
98
+ hh = hh if 1 <= hh <= 12 else abs(hh - 12) or 12
99
+
100
+ obj["t_correct"] = f"{hh}:{mm:02d} {suffix}"
101
+
102
+
103
+ # ═══════════════════════════════════════════════════════════════════════════════
104
+ # BIAS REMOVAL STRATEGY
105
+ # ═══════════════════════════════════════════════════════════════════════════════
106
+ #
107
+ # TEMPORAL — all four options use the same HH:MM AM/PM format, all equally
108
+ # "round" (multiples of 15 min). Correct answer is not
109
+ # systematically rounder or more common than distractors.
110
+ #
111
+ # MATHEMATICAL — all four options use the same template sentence and same
112
+ # numeric magnitude/format. No option is a rounder number.
113
+ # Wrong values are equally plausible-looking (same digit count,
114
+ # same unit, same prefix).
115
+ #
116
+ # SPATIAL — arrangement labels are non-alphabetical (e.g. P-Q-R-S-T with
117
+ # randomised correct position) so no arrangement looks more
118
+ # "natural" than another. Direction words (north/east/south/west)
119
+ # are already equal-frequency — kept as-is.
120
+ #
121
+ # DEDUCTIVE — all four options use the same subject-verb sentence structure
122
+ # and similar token length. No option is dramatically shorter or
123
+ # more clipped than others.
124
+ #
125
+ # CAUSAL — all four options use the same sentence frame ("X caused Y" /
126
+ # "X may have caused Y" etc.) so the model cannot pick by frame
127
+ # familiarity alone. Correct answer is not the longest or shortest.
128
+
129
+ # ═══════════════════════════════════════════════════════════════════════════════
130
+ # DEDUCTIVE
131
+ # ═══════════════════════════════════════════════════════════════════════════════
132
+ # All options are "Subject Verb Object" of similar length.
133
+ # Distractors swap the logical relationship (converse, inverse, negation)
134
+ # but keep identical grammatical structure to the correct answer.
135
+
136
+ DEDUCTIVE_TEMPLATES = [
137
+ # All-All syllogism. Correct: "All S are P."
138
+ # Distractors: converse, negation, partial — same 4-word structure.
139
+ {
140
+ "template": "All {category} are {property}. All {subtype} are {category}.",
141
+ "correct": "All {subtype} are {property}.",
142
+ "distractors": [
143
+ "All {property} are {subtype}.", # converse error, same structure
144
+ "No {subtype} are {property}.", # negation, same structure
145
+ "Some {subtype} are {property}.", # weakened, same structure
146
+ ],
147
+ },
148
+ # No-Some syllogism. Correct: "Some {subtype} are not {property}."
149
+ {
150
+ "template": "No {category} are {property}. Some {subtype} are {category}.",
151
+ "correct": "Some {subtype} are not {property}.",
152
+ "distractors": [
153
+ "All {subtype} are not {property}.", # over-generalised
154
+ "Some {subtype} are {property}.", # dropped negation
155
+ "No {subtype} are {property}.", # over-strong negation
156
+ ],
157
+ },
158
+ # Modus ponens. Correct: "{name} has {property}."
159
+ {
160
+ "template": "If something is a {category}, then it has {property}. {name} is a {category}.",
161
+ "correct": "{name} has {property}.",
162
+ "distractors": [
163
+ "{name} lacks {property}.", # direct negation, same length
164
+ "{name} may have {property}.", # weakened modal, same structure
165
+ "{name} has {category}.", # swapped object, same structure
166
+ ],
167
+ },
168
+ # Modus tollens. Correct: "{name} is not a {category}."
169
+ {
170
+ "template": "If something is a {category}, then it has {property}. {name} does not have {property}.",
171
+ "correct": "{name} is not a {category}.",
172
+ "distractors": [
173
+ "{name} is a {category}.", # dropped negation, same structure
174
+ "{name} is not a {property}.", # swapped term, same structure
175
+ "{name} may not be a {category}.", # weakened modal, same structure
176
+ ],
177
+ },
178
+ # Hypothetical syllogism. Correct: "If {A} then {C}."
179
+ {
180
+ "template": "If {A} then {B}. If {B} then {C}.",
181
+ "correct": "If {A} then {C}.",
182
+ "distractors": [
183
+ "If {C} then {A}.", # reversal, same structure
184
+ "If {A} then {B}.", # stops one step short
185
+ "If {C} then {B}.", # partial reversal
186
+ ],
187
+ },
188
+ # Disjunctive syllogism. Correct: "{B} is true."
189
+ {
190
+ "template": "Either {A} or {B} is true. {A} is false.",
191
+ "correct": "{B} is true.",
192
+ "distractors": [
193
+ "{A} is true.", # picks the eliminated option
194
+ "{B} is false.", # negates correct answer
195
+ "{A} is false.", # restates premise, not conclusion
196
+ ],
197
+ },
198
+ ]
199
+
200
+ DEDUCTIVE_OBJECTS = [
201
+ {"category": "reptiles", "property": "cold-blooded", "subtype": "lizards", "name": "Rex", "A": "it rains", "B": "the ground is wet", "C": "the plants are watered"},
202
+ {"category": "mammals", "property": "warm-blooded", "subtype": "whales", "name": "Bella", "A": "the alarm rings", "B": "Sara wakes up", "C": "Sara eats breakfast"},
203
+ {"category": "birds", "property": "feathers", "subtype": "penguins", "name": "Pingu", "A": "water boils", "B": "steam is produced", "C": "the cup fills with vapour"},
204
+ {"category": "metals", "property": "electrical conductivity", "subtype": "copper wires", "name": "this rod", "A": "the switch is flipped", "B": "the circuit is closed", "C": "the light turns on"},
205
+ {"category": "flowering plants", "property": "seeds", "subtype": "roses", "name": "this specimen","A": "temperature drops", "B": "water freezes", "C": "pipes can burst"},
206
+ {"category": "vertebrates", "property": "a spinal column", "subtype": "fish", "name": "Nemo", "A": "the CPU overheats", "B": "throttling activates", "C": "performance drops"},
207
+ {"category": "fungi", "property": "chitin cell walls", "subtype": "mushrooms", "name": "this sample", "A": "the budget is approved","B": "the project starts", "C": "the team is hired"},
208
+ {"category": "planets", "property": "an orbit around a star", "subtype": "gas giants", "name": "Jupiter", "A": "demand exceeds supply", "B": "prices rise", "C": "consumers buy less"},
209
+ {"category": "enzymes", "property": "a protein structure", "subtype": "lipases", "name": "this molecule","A": "the key is turned", "B": "the engine starts", "C": "the car moves"},
210
+ {"category": "acids", "property": "a pH below seven", "subtype": "citric acids", "name": "lemon juice", "A": "training data grows", "B": "capacity is reached", "C": "overfitting risk grows"},
211
+ {"category": "quadrilaterals", "property": "four sides", "subtype": "squares", "name": "this shape", "A": "the sun sets", "B": "it gets dark", "C": "street lights activate"},
212
+ {"category": "noble gases", "property": "a full outer electron shell", "subtype": "argon atoms", "name": "this atom", "A": "a virus spreads", "B": "infection rates climb", "C": "hospitals fill up"},
213
+ {"category": "solids", "property": "a fixed shape", "subtype": "crystals", "name": "this sample", "A": "interest rates rise", "B": "borrowing costs increase", "C": "housing demand falls"},
214
+ {"category": "carnivores", "property": "meat-based diets", "subtype": "felines", "name": "this tiger", "A": "the code compiles", "B": "an executable is produced","C": "the program can be run"},
215
+ {"category": "alkali metals", "property": "high reactivity with water", "subtype": "sodium samples", "name": "this element", "A": "rainfall is heavy", "B": "river levels rise", "C": "flood warnings are issued"},
216
+ {"category": "insulators", "property": "resistance to current flow", "subtype": "rubber coatings", "name": "this material","A": "the oven preheats", "B": "the temperature is reached","C": "baking can begin"},
217
+ {"category": "primates", "property": "opposable thumbs", "subtype": "chimpanzees", "name": "this subject", "A": "a star depletes fuel", "B": "it collapses", "C": "a neutron star forms"},
218
+ {"category": "even numbers", "property": "divisibility by two", "subtype": "multiples of four", "name": "the number eight","A": "sleep is reduced", "B": "cognitive performance drops","C": "reaction times slow"},
219
+ {"category": "semiconductors", "property": "variable conductivity", "subtype": "silicon chips", "name": "this wafer", "A": "the sensor triggers", "B": "the valve opens", "C": "pressure is released"},
220
+ {"category": "databases", "property": "structured query support", "subtype": "relational databases", "name": "this system", "A": "the model trains", "B": "weights are updated", "C": "loss decreases"},
221
+ ]
222
+
223
+ # ═══════════════════════════════════════════════════════════════════════════════
224
+ # CAUSAL
225
+ # ═══════════════════════════════════════════════════════════════════════════════
226
+ # All four options use the same sentence frame per template.
227
+ # Correct answer is not consistently longer than distractors.
228
+
229
+ CAUSAL_TEMPLATES = [
230
+ # Frame: "X [verb] Y in [setting]." — all four options use this frame.
231
+ {
232
+ "template": "After {intervention} was introduced in {setting}, {outcome} was observed in the following {timeframe}.",
233
+ "correct": "{intervention} likely contributed to {outcome} in {setting}.",
234
+ "distractors": [
235
+ "{outcome} likely contributed to {intervention} in {setting}.", # reversed, same frame
236
+ "{intervention} had no measurable effect on {outcome} in {setting}.", # negation, same frame
237
+ "{outcome} was already present before {intervention} in {setting}.", # pre-empts cause, same frame
238
+ ],
239
+ },
240
+ # Frame: "The study shows X [verb] Y." — all four options.
241
+ {
242
+ "template": "A study finds that people who {habit} tend to have {outcome}. Researchers propose a policy to encourage {habit} in order to produce {outcome}.",
243
+ "correct": "The study shows {habit} is correlated with {outcome}, not necessarily causal.",
244
+ "distractors": [
245
+ "The study shows {habit} directly produces {outcome} in all cases.", # overclaims causation
246
+ "The study shows {outcome} directly produces {habit} in all cases.", # reverses direction
247
+ "The study shows {habit} and {outcome} are entirely unrelated factors.", # denies correlation
248
+ ],
249
+ },
250
+ # Frame: "X is the [adjective] explanation for Y." — all four same frame.
251
+ {
252
+ "template": "{cause} occurred. Shortly after, {effect} was observed. No other changes were recorded.",
253
+ "correct": "{cause} is the most plausible explanation for {effect}.",
254
+ "distractors": [
255
+ "{effect} is the most plausible explanation for {cause}.", # reversed, same frame
256
+ "{cause} is the least plausible explanation for {effect}.", # negated, same frame
257
+ "{cause} is an unrelated occurrence to {effect}.", # denies link, similar length
258
+ ],
259
+ },
260
+ # Frame: "X is [adverb] to follow / X is [adverb] to precede Y."
261
+ {
262
+ "template": "Every time {trigger} happens, {response} follows within {timeframe}. {trigger} just happened.",
263
+ "correct": "{response} is likely to follow shortly.",
264
+ "distractors": [
265
+ "{trigger} is likely to follow shortly.", # subject swap, same frame
266
+ "{response} is unlikely to follow shortly.", # negated, same frame
267
+ "{response} is likely to precede {trigger}.", # reversed order, same frame
268
+ ],
269
+ },
270
+ # Frame: "Removing X caused Y to [verb]. Reintroducing X caused Y to [verb]."
271
+ {
272
+ "template": "Removing {factor} from {system} caused {outcome} to stop. Reintroducing {factor} caused {outcome} to resume.",
273
+ "correct": "{factor} is a direct cause of {outcome} in {system}.",
274
+ "distractors": [
275
+ "{outcome} is a direct cause of {factor} in {system}.", # reversed
276
+ "{factor} is unrelated to {outcome} in {system}.", # denies link
277
+ "{system} is a direct cause of {outcome} in {factor}.", # scrambled subjects
278
+ ],
279
+ },
280
+ ]
281
+
282
+ CAUSAL_OBJECTS = [
283
+ {"intervention": "a speed camera", "setting": "the highway", "outcome": "a drop in accidents", "timeframe": "six months", "habit": "exercise daily", "cause": "a power outage", "effect": "all servers went offline", "trigger": "the tide comes in", "response": "the harbour floods", "factor": "nitrogen", "system": "the soil"},
284
+ {"intervention": "free school meals", "setting": "the district", "outcome": "improved attendance", "timeframe": "one year", "habit": "read before bed", "cause": "a cold snap", "effect": "gas demand spiked", "trigger": "the whistle blows", "response": "workers stop", "factor": "the catalyst", "system": "the reaction"},
285
+ {"intervention": "a sugar tax", "setting": "the country", "outcome": "reduced drink sales", "timeframe": "one quarter", "habit": "drink green tea", "cause": "heavy rainfall", "effect": "the river burst its banks", "trigger": "the market opens", "response": "trading begins", "factor": "sunlight", "system": "the greenhouse"},
286
+ {"intervention": "a remote work policy", "setting": "the company", "outcome": "lower office costs", "timeframe": "one year", "habit": "meditate each morning","cause": "the update was deployed", "effect": "the app crashed", "trigger": "the temperature drops", "response": "the pipes freeze", "factor": "the moderator", "system": "the forum"},
287
+ {"intervention": "a cycling lane", "setting": "the city centre", "outcome": "increased cycling rates", "timeframe": "one summer", "habit": "eat breakfast", "cause": "the dam was opened", "effect": "downstream levels rose", "trigger": "the CEO speaks", "response": "stock price moves", "factor": "oxygen", "system": "the fermentation tank"},
288
+ {"intervention": "mandatory helmet laws", "setting": "the state", "outcome": "fewer head injuries", "timeframe": "two years", "habit": "take cold showers", "cause": "the antivirus was removed","effect": "the computer was infected", "trigger": "pollen counts rise", "response": "allergy rates increase", "factor": "the enzyme", "system": "the digestion process"},
289
+ {"intervention": "a literacy programme", "setting": "the school", "outcome": "higher reading scores", "timeframe": "one semester","habit": "walk daily", "cause": "the valve was opened", "effect": "pressure dropped", "trigger": "feedback is published", "response": "the team revises", "factor": "the preservative","system": "the food product"},
290
+ {"intervention": "streetlighting upgrades", "setting": "the neighbourhood", "outcome": "reduced night crime", "timeframe": "three months","habit": "journal daily", "cause": "the component failed", "effect": "the assembly line halted", "trigger": "humidity exceeds 80%", "response": "condensation forms", "factor": "the inhibitor", "system": "the cell culture"},
291
+ {"intervention": "a noise ordinance", "setting": "the district", "outcome": "fewer noise complaints", "timeframe": "one month", "habit": "skip breakfast", "cause": "the firewall rule was added","effect": "that IP was blocked", "trigger": "the sensor detects motion","response": "the alarm activates", "factor": "the binder", "system": "the tablet formulation"},
292
+ {"intervention": "paid parental leave", "setting": "the organisation", "outcome": "higher staff retention", "timeframe": "18 months", "habit": "nap after lunch", "cause": "the index rebalanced", "effect": "several stocks were sold", "trigger": "the pH drops below four","response": "the indicator changes", "factor": "the antibiotic","system": "the bacterial colony"},
293
+ {"intervention": "a toll road", "setting": "the motorway", "outcome": "reduced congestion", "timeframe": "one year", "habit": "use standing desks", "cause": "the patch was applied", "effect": "the vulnerability closed", "trigger": "the tide recedes", "response": "the beach is exposed", "factor": "the dye", "system": "the textile"},
294
+ {"intervention": "an air quality system", "setting": "the city", "outcome": "fewer outdoor activities", "timeframe": "one summer", "habit": "drink more water", "cause": "the thermostat was lowered","effect": "energy bills fell", "trigger": "the signal is lost", "response": "the device switches", "factor": "the flux", "system": "the solder joint"},
295
+ {"intervention": "subsidised transport", "setting": "the region", "outcome": "higher ridership", "timeframe": "one year", "habit": "avoid screens at night","cause": "the fee was waived", "effect": "participation rates climbed","trigger": "the deadline passes", "response": "late penalties apply", "factor": "the pigment", "system": "the paint mixture"},
296
+ {"intervention": "a four-day work week", "setting": "the company", "outcome": "unchanged productivity", "timeframe": "one quarter", "habit": "eat more vegetables", "cause": "the satellite repositioned","effect": "signal strength improved", "trigger": "the threshold is crossed","response": "the safety valve opens", "factor": "the hormone", "system": "the feedback loop"},
297
+ {"intervention": "subsidised gym access", "setting": "the workplace", "outcome": "lower sick-day rates", "timeframe": "one year", "habit": "keep a to-do list", "cause": "the connection was throttled","effect": "download speeds fell", "trigger": "voltage exceeds the limit","response": "the fuse blows", "factor": "the solvent", "system": "the adhesive bond"},
298
+ ]
299
+
300
+ # ═══════════════════════════════════════════════════════════════════════════════
301
+ # TEMPORAL
302
+ # ═══════════════════════════════════════════════════════════════════════════════
303
+ # All four options are "X must start by H:MM AM/PM at the latest."
304
+ # All times are multiples of 15 min so no option is "rounder" than another.
305
+ # Correct answer is computed; wrong answers are adjacent multiples of 15.
306
+
307
+ TEMPORAL_TEMPLATES = [
308
+ # Backward-chain scheduling. All four options: "X must start by T at the latest."
309
+ {
310
+ "template": "{task_a} takes {dur_a} minutes. {task_b} must follow and takes {dur_b} minutes. {task_c} must follow and takes {dur_c} minutes. Everything must finish by {deadline}.",
311
+ "correct": "{task_a} must start by {t_correct} at the latest.",
312
+ "distractors": [
313
+ "{task_a} must start by {t_wrong1} at the latest.",
314
+ "{task_a} must start by {t_wrong2} at the latest.",
315
+ "{task_a} must start by {t_wrong3} at the latest.",
316
+ ],
317
+ },
318
+ # Event ordering. All four options: "A valid order is: W → X → Y → Z."
319
+ {
320
+ "template": "Event {ev_b} must occur before event {ev_c}. Event {ev_a} must occur before event {ev_b}. Event {ev_d} must occur after event {ev_c}.",
321
+ "correct": "A valid order is: {ev_a} then {ev_b} then {ev_c} then {ev_d}.",
322
+ "distractors": [
323
+ "A valid order is: {ev_b} then {ev_a} then {ev_c} then {ev_d}.", # a/b swapped
324
+ "A valid order is: {ev_a} then {ev_c} then {ev_b} then {ev_d}.", # b/c swapped
325
+ "A valid order is: {ev_a} then {ev_b} then {ev_d} then {ev_c}.", # c/d swapped
326
+ ],
327
+ },
328
+ # Train wait time. All four options: "X will wait N minutes for the next train."
329
+ {
330
+ "template": "Trains depart every {interval} minutes, starting at {first_train}. {person} arrives at {arrival}.",
331
+ "correct": "{person} will wait {wait_correct} minutes for the next train.",
332
+ "distractors": [
333
+ "{person} will wait {wait_wrong1} minutes for the next train.",
334
+ "{person} will wait {wait_wrong2} minutes for the next train.",
335
+ "{person} will wait {wait_wrong3} minutes for the next train.",
336
+ ],
337
+ },
338
+ # Earliest completion. All four: "The earliest X can be done is T."
339
+ {
340
+ "template": "{person} starts {task_a} at {start_time}. {task_a} takes {dur_a} minutes. {task_b} cannot begin until {task_a} is done and takes {dur_b} minutes.",
341
+ "correct": "The earliest {task_b} can be done is {done_correct}.",
342
+ "distractors": [
343
+ "The earliest {task_b} can be done is {done_wrong1}.",
344
+ "The earliest {task_b} can be done is {done_wrong2}.",
345
+ "The earliest {task_b} can be done is {done_wrong3}.",
346
+ ],
347
+ },
348
+ ]
349
+
350
+ # All times are multiples of 15 min.
351
+ # t_correct is the right backward-chain result; t_wrong1/2/3 are ±15/±30/±45 offset.
352
+ TEMPORAL_OBJECTS = [
353
+ # dur_a=30, dur_b=45, dur_c=15 → total=90 min. deadline=5:00 PM → start by 3:30 PM
354
+ {"task_a": "gather materials", "dur_a": 30, "task_b": "mix components", "dur_b": 45, "task_c": "package result", "dur_c": 15, "deadline": "5:00 PM",
355
+ "t_correct": "3:30 PM", "t_wrong1": "3:45 PM", "t_wrong2": "3:15 PM", "t_wrong3": "4:00 PM",
356
+ "ev_a": "Design", "ev_b": "Build", "ev_c": "Test", "ev_d": "Deploy",
357
+ "interval": 15, "first_train": "9:00 AM", "arrival": "9:22 AM", "person": "Alex",
358
+ "wait_correct": 8, "wait_wrong1": 7, "wait_wrong2": 22, "wait_wrong3": 15,
359
+ "start_time": "10:00 AM", "done_correct": "11:15 AM", "done_wrong1": "11:00 AM", "done_wrong2": "11:30 AM", "done_wrong3": "10:45 AM"},
360
+
361
+ # dur_a=45, dur_b=30, dur_c=30 → total=105 min. deadline=3:45 PM → start by 2:00 PM
362
+ {"task_a": "write the draft", "dur_a": 45, "task_b": "peer review", "dur_b": 30, "task_c": "final edit", "dur_c": 30, "deadline": "3:45 PM",
363
+ "t_correct": "2:00 PM", "t_wrong1": "2:15 PM", "t_wrong2": "1:45 PM", "t_wrong3": "2:30 PM",
364
+ "ev_a": "Seed", "ev_b": "Germinate", "ev_c": "Grow", "ev_d": "Harvest",
365
+ "interval": 20, "first_train": "8:00 AM", "arrival": "8:14 AM", "person": "Jordan",
366
+ "wait_correct": 6, "wait_wrong1": 14, "wait_wrong2": 20, "wait_wrong3": 26,
367
+ "start_time": "2:00 PM", "done_correct": "3:45 PM", "done_wrong1": "3:30 PM", "done_wrong2": "4:00 PM", "done_wrong3": "3:15 PM"},
368
+
369
+ # dur_a=15, dur_b=45, dur_c=15 → total=75 min. deadline=4:15 PM → start by 3:00 PM
370
+ {"task_a": "install dependencies","dur_a": 15,"task_b": "run tests", "dur_b": 45, "task_c": "deploy build", "dur_c": 15, "deadline": "4:15 PM",
371
+ "t_correct": "3:00 PM", "t_wrong1": "3:15 PM", "t_wrong2": "2:45 PM", "t_wrong3": "3:30 PM",
372
+ "ev_a": "Draft", "ev_b": "Review", "ev_c": "Approve", "ev_d": "Publish",
373
+ "interval": 30, "first_train": "7:00 AM", "arrival": "7:22 AM", "person": "Sam",
374
+ "wait_correct": 8, "wait_wrong1": 22, "wait_wrong2": 30, "wait_wrong3": 38,
375
+ "start_time": "9:00 AM", "done_correct": "10:00 AM", "done_wrong1": "9:45 AM", "done_wrong2": "10:15 AM", "done_wrong3": "9:30 AM"},
376
+
377
+ # dur_a=30, dur_b=30, dur_c=30 → total=90 min. deadline=6:30 PM → start by 5:00 PM
378
+ {"task_a": "preheat the oven", "dur_a": 30, "task_b": "bake the cake", "dur_b": 30, "task_c": "cool and frost", "dur_c": 30, "deadline": "6:30 PM",
379
+ "t_correct": "5:00 PM", "t_wrong1": "5:15 PM", "t_wrong2": "4:45 PM", "t_wrong3": "5:30 PM",
380
+ "ev_a": "Mine", "ev_b": "Refine", "ev_c": "Fabricate", "ev_d": "Ship",
381
+ "interval": 15, "first_train": "6:00 AM", "arrival": "6:07 AM", "person": "Maya",
382
+ "wait_correct": 8, "wait_wrong1": 7, "wait_wrong2": 23, "wait_wrong3": 15,
383
+ "start_time": "1:00 PM", "done_correct": "2:30 PM", "done_wrong1": "2:15 PM", "done_wrong2": "2:45 PM", "done_wrong3": "2:00 PM"},
384
+
385
+ # dur_a=60, dur_b=45, dur_c=15 → total=120 min. deadline=5:00 PM → start by 3:00 PM
386
+ {"task_a": "download dataset", "dur_a": 60, "task_b": "preprocess data","dur_b": 45, "task_c": "validate output","dur_c": 15, "deadline": "5:00 PM",
387
+ "t_correct": "3:00 PM", "t_wrong1": "3:15 PM", "t_wrong2": "2:45 PM", "t_wrong3": "3:30 PM",
388
+ "ev_a": "Recruit", "ev_b": "Train", "ev_c": "Certify", "ev_d": "Deploy",
389
+ "interval": 45, "first_train": "8:00 AM", "arrival": "8:31 AM", "person": "Chris",
390
+ "wait_correct": 14, "wait_wrong1": 29, "wait_wrong2": 31, "wait_wrong3": 45,
391
+ "start_time": "8:00 AM", "done_correct": "9:45 AM", "done_wrong1": "9:30 AM", "done_wrong2": "10:00 AM", "done_wrong3": "9:15 AM"},
392
+
393
+ # dur_a=15, dur_b=30, dur_c=45 → total=90 min. deadline=12:30 PM → start by 11:00 AM
394
+ {"task_a": "print the forms", "dur_a": 15, "task_b": "sign documents", "dur_b": 30, "task_c": "file paperwork", "dur_c": 45, "deadline": "12:30 PM",
395
+ "t_correct": "11:00 AM", "t_wrong1": "11:15 AM", "t_wrong2": "10:45 AM", "t_wrong3": "11:30 AM",
396
+ "ev_a": "Propose", "ev_b": "Vote", "ev_c": "Enact", "ev_d": "Enforce",
397
+ "interval": 30, "first_train": "10:00 AM", "arrival": "10:17 AM", "person": "Dana",
398
+ "wait_correct": 13, "wait_wrong1": 17, "wait_wrong2": 30, "wait_wrong3": 43,
399
+ "start_time": "3:00 PM", "done_correct": "4:15 PM", "done_wrong1": "4:00 PM", "done_wrong2": "4:30 PM", "done_wrong3": "3:45 PM"},
400
+
401
+ # dur_a=45, dur_b=45, dur_c=30 → total=120 min. deadline=4:00 PM → start by 2:00 PM
402
+ {"task_a": "survey the site", "dur_a": 45, "task_b": "draft proposal", "dur_b": 45, "task_c": "submit report", "dur_c": 30, "deadline": "4:00 PM",
403
+ "t_correct": "2:00 PM", "t_wrong1": "2:15 PM", "t_wrong2": "1:45 PM", "t_wrong3": "2:30 PM",
404
+ "ev_a": "Diagnose", "ev_b": "Prescribe", "ev_c": "Treat", "ev_d": "Recover",
405
+ "interval": 15, "first_train": "7:30 AM", "arrival": "7:38 AM", "person": "Riley",
406
+ "wait_correct": 7, "wait_wrong1": 8, "wait_wrong2": 22, "wait_wrong3": 15,
407
+ "start_time": "11:00 AM", "done_correct": "12:30 PM", "done_wrong1": "12:15 PM", "done_wrong2": "12:45 PM", "done_wrong3": "12:00 PM"},
408
+
409
+ # dur_a=30, dur_b=15, dur_c=45 → total=90 min. deadline=3:00 PM → start by 1:30 PM
410
+ {"task_a": "configure the server","dur_a": 30,"task_b": "run diagnostics","dur_b": 15, "task_c": "push to staging","dur_c": 45, "deadline": "3:00 PM",
411
+ "t_correct": "1:30 PM", "t_wrong1": "1:45 PM", "t_wrong2": "1:15 PM", "t_wrong3": "2:00 PM",
412
+ "ev_a": "Allocate", "ev_b": "Schedule", "ev_c": "Execute", "ev_d": "Review",
413
+ "interval": 20, "first_train": "9:00 AM", "arrival": "9:09 AM", "person": "Taylor",
414
+ "wait_correct": 11, "wait_wrong1": 9, "wait_wrong2": 20, "wait_wrong3": 31,
415
+ "start_time": "2:00 PM", "done_correct": "3:30 PM", "done_wrong1": "3:15 PM", "done_wrong2": "3:45 PM", "done_wrong3": "3:00 PM"},
416
+ ]
417
+
418
+ # ═══════════════════════════════════════════════════════════════════════════════
419
+ # SPATIAL
420
+ # ═══════════════════════════════════════════════════════════════════════════════
421
+ # Non-alphabetical labels so no arrangement looks more natural.
422
+ # All four options use the same "X faces Y" / "X is Z of Y" sentence frame.
423
+
424
+ SPATIAL_TEMPLATES = [
425
+ # Rotation. All four: "{person} is now facing {dir}."
426
+ {
427
+ "template": "{person} faces {start_dir}. They turn {deg1} degrees {rot1}, then {deg2} degrees {rot2}.",
428
+ "correct": "{person} is now facing {final_dir}.",
429
+ "distractors": [
430
+ "{person} is now facing {wrong_dir1}.",
431
+ "{person} is now facing {wrong_dir2}.",
432
+ "{person} is now facing {wrong_dir3}.",
433
+ ],
434
+ },
435
+ # Relative position chain. All four: "X is [direction] of Z."
436
+ {
437
+ "template": "{obj_a} is directly {rel1} of {obj_b}. {obj_b} is directly {rel2} of {obj_c}.",
438
+ "correct": "{obj_a} is {combined} of {obj_c}.",
439
+ "distractors": [
440
+ "{obj_a} is {wrong_rel1} of {obj_c}.",
441
+ "{obj_a} is {wrong_rel2} of {obj_c}.",
442
+ "{obj_a} is {wrong_rel3} of {obj_c}.",
443
+ ],
444
+ },
445
+ # Arrangement with non-alphabetical labels. All four: "The valid order is: W-X-Y-Z-V."
446
+ {
447
+ "template": "Five objects are in a row: {labels}. {constraint1}. {constraint2}.",
448
+ "correct": "The valid order is: {correct_arr}.",
449
+ "distractors": [
450
+ "The valid order is: {wrong_arr1}.",
451
+ "The valid order is: {wrong_arr2}.",
452
+ "The valid order is: {wrong_arr3}.",
453
+ ],
454
+ },
455
+ # Net displacement. All four: "{person} ends up {N} metres {dir} of the start."
456
+ {
457
+ "template": "{person} walks {d1} metres {dir1}, then {d2} metres {dir2}, then {d3} metres {dir3}.",
458
+ "correct": "{person} ends up {net_dist} metres {net_dir} of the start.",
459
+ "distractors": [
460
+ "{person} ends up {wrong_dist1} metres {net_dir} of the start.",
461
+ "{person} ends up {net_dist} metres {wrong_dir1} of the start.",
462
+ "{person} ends up {wrong_dist2} metres {wrong_dir2} of the start.",
463
+ ],
464
+ },
465
+ ]
466
+
467
+ SPATIAL_OBJECTS = [
468
+ # north + 90CW → east, + 180CW → west
469
+ {"person": "Anya", "start_dir": "north", "deg1": 90, "rot1": "clockwise", "deg2": 180, "rot2": "clockwise",
470
+ "final_dir": "west", "wrong_dir1": "east", "wrong_dir2": "south", "wrong_dir3": "north",
471
+ "obj_a": "the lamp", "obj_b": "the table", "obj_c": "the door", "rel1": "north", "rel2": "east", "combined": "to the northwest", "wrong_rel1": "to the northeast", "wrong_rel2": "to the southeast", "wrong_rel3": "to the southwest",
472
+ "labels": "P Q R S T", "constraint1": "Q is immediately right of P", "constraint2": "T is at the right end",
473
+ "correct_arr": "P-Q-R-S-T", "wrong_arr1": "Q-P-R-S-T", "wrong_arr2": "P-R-Q-S-T", "wrong_arr3": "P-Q-S-R-T",
474
+ "d1": 10, "dir1": "north", "d2": 6, "dir2": "east", "d3": 4, "dir3": "south", "net_dist": 6, "net_dir": "north", "wrong_dist1": 10, "wrong_dir1": "east", "wrong_dist2": 4, "wrong_dir2": "south"},
475
+
476
+ # east + 90ACW → north, + 90CW → east
477
+ {"person": "Ben", "start_dir": "east", "deg1": 90, "rot1": "anticlockwise", "deg2": 90, "rot2": "clockwise",
478
+ "final_dir": "east", "wrong_dir1": "north", "wrong_dir2": "west", "wrong_dir3": "south",
479
+ "obj_a": "the chair", "obj_b": "the desk", "obj_c": "the window", "rel1": "south", "rel2": "west", "combined": "to the southeast", "wrong_rel1": "to the northwest", "wrong_rel2": "to the northeast", "wrong_rel3": "to the southwest",
480
+ "labels": "V W X Y Z", "constraint1": "X is in the middle", "constraint2": "V is at the left end",
481
+ "correct_arr": "V-W-X-Y-Z", "wrong_arr1": "W-V-X-Y-Z", "wrong_arr2": "V-X-W-Y-Z", "wrong_arr3": "V-W-Y-X-Z",
482
+ "d1": 5, "dir1": "east", "d2": 5, "dir2": "north", "d3": 5, "dir3": "west", "net_dist": 5, "net_dir": "north", "wrong_dist1": 15, "wrong_dir1": "east", "wrong_dist2": 5, "wrong_dir2": "west"},
483
+
484
+ # south + 180CW → north, + 90ACW → east
485
+ {"person": "Cara", "start_dir": "south", "deg1": 180, "rot1": "clockwise", "deg2": 90, "rot2": "anticlockwise",
486
+ "final_dir": "east", "wrong_dir1": "west", "wrong_dir2": "north", "wrong_dir3": "south",
487
+ "obj_a": "the plant", "obj_b": "the shelf", "obj_c": "the wall", "rel1": "west", "rel2": "north", "combined": "to the southwest", "wrong_rel1": "to the northwest", "wrong_rel2": "to the northeast", "wrong_rel3": "to the southeast",
488
+ "labels": "K L M N O", "constraint1": "M is immediately right of L","constraint2": "K is not adjacent to M",
489
+ "correct_arr": "K-N-L-M-O", "wrong_arr1": "L-K-M-N-O", "wrong_arr2": "K-L-M-N-O", "wrong_arr3": "N-K-L-M-O",
490
+ "d1": 8, "dir1": "west", "d2": 3, "dir2": "south", "d3": 8, "dir3": "east", "net_dist": 3, "net_dir": "south", "wrong_dist1": 0, "wrong_dir1": "north", "wrong_dist2": 8, "wrong_dir2": "east"},
491
+
492
+ # west + 270CW → north, + 90CW → east ... wait: west+270CW=north, north+90CW=east? no: west→(+90)north, north→(+90)east, east→(+90)south → west+270CW=south; +90CW→west. Let me just use a clean case:
493
+ # north + 90CW → east, + 90CW → south
494
+ {"person": "Dana", "start_dir": "north", "deg1": 90, "rot1": "clockwise", "deg2": 90, "rot2": "clockwise",
495
+ "final_dir": "south", "wrong_dir1": "east", "wrong_dir2": "west", "wrong_dir3": "north",
496
+ "obj_a": "the monitor", "obj_b": "the keyboard","obj_c": "the mouse","rel1": "north", "rel2": "east", "combined": "to the northwest", "wrong_rel1": "to the northeast", "wrong_rel2": "to the southeast", "wrong_rel3": "to the southwest",
497
+ "labels": "F G H J K", "constraint1": "G is immediately right of F","constraint2": "K is at the right end",
498
+ "correct_arr": "F-G-H-J-K", "wrong_arr1": "G-F-H-J-K", "wrong_arr2": "F-H-G-J-K", "wrong_arr3": "F-G-J-H-K",
499
+ "d1": 12, "dir1": "north", "d2": 5, "dir2": "west", "d3": 4, "dir3": "south", "net_dist": 8, "net_dir": "north", "wrong_dist1": 21, "wrong_dir1": "west", "wrong_dist2": 4, "wrong_dir2": "south"},
500
+
501
+ # east + 180CW → west, + 90ACW → south
502
+ {"person": "Eva", "start_dir": "east", "deg1": 180, "rot1": "clockwise", "deg2": 90, "rot2": "anticlockwise",
503
+ "final_dir": "south", "wrong_dir1": "north", "wrong_dir2": "east", "wrong_dir3": "west",
504
+ "obj_a": "the fridge", "obj_b": "the counter","obj_c": "the sink", "rel1": "east", "rel2": "south", "combined": "to the northeast", "wrong_rel1": "to the southeast", "wrong_rel2": "to the southwest", "wrong_rel3": "to the northwest",
505
+ "labels": "R S T U V", "constraint1": "U is immediately right of T","constraint2": "R is at the left end",
506
+ "correct_arr": "R-S-T-U-V", "wrong_arr1": "S-R-T-U-V", "wrong_arr2": "R-T-S-U-V", "wrong_arr3": "R-S-U-T-V",
507
+ "d1": 7, "dir1": "south", "d2": 7, "dir2": "east", "d3": 7, "dir3": "north", "net_dist": 7, "net_dir": "east", "wrong_dist1": 7, "wrong_dir1": "south", "wrong_dist2": 0, "wrong_dir2": "north"},
508
+
509
+ # south + 90CW → west, + 180CW → east
510
+ {"person": "Finn", "start_dir": "south", "deg1": 90, "rot1": "clockwise", "deg2": 180, "rot2": "clockwise",
511
+ "final_dir": "east", "wrong_dir1": "west", "wrong_dir2": "north", "wrong_dir3": "south",
512
+ "obj_a": "the sofa", "obj_b": "the TV", "obj_c": "the speaker","rel1": "south", "rel2": "east", "combined": "to the southeast", "wrong_rel1": "to the northeast", "wrong_rel2": "to the northwest", "wrong_rel3": "to the southwest",
513
+ "labels": "B C D E F", "constraint1": "D is in the middle", "constraint2": "B is at the left end",
514
+ "correct_arr": "B-C-D-E-F", "wrong_arr1": "C-B-D-E-F", "wrong_arr2": "B-D-C-E-F", "wrong_arr3": "B-C-E-D-F",
515
+ "d1": 3, "dir1": "east", "d2": 4, "dir2": "north", "d3": 3, "dir3": "west", "net_dist": 4, "net_dir": "north", "wrong_dist1": 10, "wrong_dir1": "east", "wrong_dist2": 3, "wrong_dir2": "west"},
516
+ ]
517
+
518
+ # ═══════════════════════════════════════════════════════════════════════════════
519
+ # MATHEMATICAL
520
+ # ═══════════════════════════════════════════════════════════════════════════════
521
+ # All four options use the same sentence frame and same numeric magnitude.
522
+ # Wrong values are same digit count, same unit, plausible-looking.
523
+
524
+ MATHEMATICAL_TEMPLATES = [
525
+ # Doubling. All four: "After N periods the value is X."
526
+ {
527
+ "template": "A quantity doubles every {period}. It starts at {start}. After {n_periods} {period}s the value is recorded.",
528
+ "correct": "After {n_periods} {period}s the value is {final_val}.",
529
+ "distractors": [
530
+ "After {n_periods} {period}s the value is {wrong_val1}.",
531
+ "After {n_periods} {period}s the value is {wrong_val2}.",
532
+ "After {n_periods} {period}s the value is {wrong_val3}.",
533
+ ],
534
+ },
535
+ # Net fill rate. All four: "The tank will be full in N hours."
536
+ {
537
+ "template": "A tank fills at {fill_rate} litres per hour. A drain removes {drain_rate} litres per hour. The tank holds {capacity} litres and starts at {start_pct}% full.",
538
+ "correct": "The tank will be full in {time_to_full} hours.",
539
+ "distractors": [
540
+ "The tank will be full in {wrong_time1} hours.",
541
+ "The tank will be full in {wrong_time2} hours.",
542
+ "The tank will be full in {wrong_time3} hours.",
543
+ ],
544
+ },
545
+ # Proportional change. All four: "A N% increase in X changes Y by M%."
546
+ {
547
+ "template": "If {var} increases by {pct_change}%, {outcome} also changes by {pct_change}%. {var} is currently {current_val}.",
548
+ "correct": "A {pct_change}% increase in {var} changes {outcome} by {pct_change}%.",
549
+ "distractors": [
550
+ "A {pct_change}% increase in {var} changes {outcome} by {wrong_pct1}%.",
551
+ "A {pct_change}% increase in {var} changes {outcome} by {wrong_pct2}%.",
552
+ "A {pct_change}% increase in {var} changes {outcome} by {wrong_pct3}%.",
553
+ ],
554
+ },
555
+ # Workers. All four: "The task will be completed in N days."
556
+ {
557
+ "template": "Three workers complete a task in {base_days} days. {extra_workers} more workers of equal ability join them.",
558
+ "correct": "The task will be completed in {new_days} days.",
559
+ "distractors": [
560
+ "The task will be completed in {wrong_days1} days.",
561
+ "The task will be completed in {wrong_days2} days.",
562
+ "The task will be completed in {wrong_days3} days.",
563
+ ],
564
+ },
565
+ # Compound interest. All four: "After N years the amount owed is approximately $X."
566
+ {
567
+ "template": "A loan of {principal} is taken at {rate}% annual interest, compounded annually, for {years} years.",
568
+ "correct": "After {years} years the amount owed is approximately {amount_owed}.",
569
+ "distractors": [
570
+ "After {years} years the amount owed is approximately {wrong_amt1}.",
571
+ "After {years} years the amount owed is approximately {wrong_amt2}.",
572
+ "After {years} years the amount owed is approximately {wrong_amt3}.",
573
+ ],
574
+ },
575
+ ]
576
+
577
+ MATHEMATICAL_OBJECTS = [
578
+ # start=500, ×2 for 4 periods → 8000. Wrong: 4000 (×3 not ×4), 16000 (×5), 2000 (×2 once)
579
+ {"period": "year", "start": 500, "n_periods": 4, "final_val": 8000, "wrong_val1": 4000, "wrong_val2": 16000, "wrong_val3": 2000,
580
+ "fill_rate": 50, "drain_rate": 20, "capacity": 1000, "start_pct": 40, "time_to_full": 20, "wrong_time1": 33, "wrong_time2": 14, "wrong_time3": 25,
581
+ "var": "ad spend", "pct_change": 10, "outcome": "revenue", "current_val": "$50k", "wrong_pct1": 5, "wrong_pct2": 20, "wrong_pct3": 1,
582
+ "base_days": 12, "extra_workers": 1, "new_days": 9, "wrong_days1": 8, "wrong_days2": 6, "wrong_days3": 11,
583
+ "principal": "$10,000", "rate": 5, "years": 3, "amount_owed": "$11,576", "wrong_amt1": "$11,500", "wrong_amt2": "$11,250", "wrong_amt3": "$12,000"},
584
+
585
+ # start=100, ×2 for 5 → 3200. Wrong: 1600, 6400, 500
586
+ {"period": "month", "start": 100, "n_periods": 5, "final_val": 3200, "wrong_val1": 1600, "wrong_val2": 6400, "wrong_val3": 500,
587
+ "fill_rate": 80, "drain_rate": 30, "capacity": 2000,"start_pct": 25, "time_to_full": 30, "wrong_time1": 25, "wrong_time2": 40, "wrong_time3": 20,
588
+ "var": "temperature","pct_change": 20,"outcome": "energy use", "current_val": "25°C", "wrong_pct1": 10, "wrong_pct2": 40, "wrong_pct3": 5,
589
+ "base_days": 9, "extra_workers": 3, "new_days": 4, "wrong_days1": 6, "wrong_days2": 3, "wrong_days3": 5,
590
+ "principal": "$5,000", "rate": 8, "years": 2, "amount_owed": "$5,832", "wrong_amt1": "$5,800", "wrong_amt2": "$5,600", "wrong_amt3": "$6,000"},
591
+
592
+ # start=1, ×2 for 6 → 64. Wrong: 32, 128, 12
593
+ {"period": "hour", "start": 1, "n_periods": 6, "final_val": 64, "wrong_val1": 32, "wrong_val2": 128, "wrong_val3": 12,
594
+ "fill_rate": 100, "drain_rate": 40,"capacity": 500, "start_pct": 10, "time_to_full": 7, "wrong_time1": 5, "wrong_time2": 9, "wrong_time3": 6,
595
+ "var": "headcount", "pct_change": 50, "outcome": "output", "current_val": "20", "wrong_pct1": 25, "wrong_pct2": 100,"wrong_pct3": 10,
596
+ "base_days": 15, "extra_workers": 2, "new_days": 9, "wrong_days1": 10, "wrong_days2": 7, "wrong_days3": 11,
597
+ "principal": "$20,000", "rate": 6, "years": 5, "amount_owed": "$26,765", "wrong_amt1": "$26,000", "wrong_amt2": "$25,500", "wrong_amt3": "$27,500"},
598
+
599
+ # start=10, ×2 for 7 → 1280. Wrong: 640, 2560, 70
600
+ {"period": "day", "start": 10, "n_periods": 7, "final_val": 1280, "wrong_val1": 640, "wrong_val2": 2560, "wrong_val3": 70,
601
+ "fill_rate": 200, "drain_rate": 50,"capacity": 3000,"start_pct": 20, "time_to_full": 13, "wrong_time1": 15, "wrong_time2": 10, "wrong_time3": 18,
602
+ "var": "price", "pct_change": 15, "outcome": "demand", "current_val": "$40", "wrong_pct1": 30, "wrong_pct2": 7, "wrong_pct3": 45,
603
+ "base_days": 20, "extra_workers": 5, "new_days": 7, "wrong_days1": 10, "wrong_days2": 5, "wrong_days3": 8,
604
+ "principal": "$15,000", "rate": 4, "years": 4, "amount_owed": "$17,548", "wrong_amt1": "$17,000", "wrong_amt2": "$16,500", "wrong_amt3": "$18,000"},
605
+
606
+ # start=50, ×2 for 3 → 400. Wrong: 200, 800, 150
607
+ {"period": "week", "start": 50, "n_periods": 3, "final_val": 400, "wrong_val1": 200, "wrong_val2": 800, "wrong_val3": 150,
608
+ "fill_rate": 60, "drain_rate": 10,"capacity": 800, "start_pct": 50, "time_to_full": 8, "wrong_time1": 16, "wrong_time2": 6, "wrong_time3": 10,
609
+ "var": "batch size", "pct_change": 25, "outcome": "training time", "current_val": "32", "wrong_pct1": 12, "wrong_pct2": 50, "wrong_pct3": 6,
610
+ "base_days": 6, "extra_workers": 3, "new_days": 3, "wrong_days1": 2, "wrong_days2": 4, "wrong_days3": 5,
611
+ "principal": "$8,000", "rate": 7, "years": 3, "amount_owed": "$9,800", "wrong_amt1": "$9,680", "wrong_amt2": "$9,200", "wrong_amt3": "$10,200"},
612
+
613
+ # start=1000, ×2 for 5 → 32000. Wrong: 16000, 64000, 5000
614
+ {"period": "year", "start": 1000, "n_periods": 5, "final_val": 32000, "wrong_val1": 16000, "wrong_val2": 64000, "wrong_val3": 5000,
615
+ "fill_rate": 120, "drain_rate": 70,"capacity": 1500,"start_pct": 30, "time_to_full": 21, "wrong_time1": 18, "wrong_time2": 25, "wrong_time3": 15,
616
+ "var": "server count","pct_change":100,"outcome": "throughput", "current_val": "4", "wrong_pct1": 50, "wrong_pct2": 200,"wrong_pct3": 75,
617
+ "base_days": 18, "extra_workers": 6, "new_days": 6, "wrong_days1": 9, "wrong_days2": 4, "wrong_days3": 7,
618
+ "principal": "$25,000", "rate": 3, "years": 10,"amount_owed": "$33,598", "wrong_amt1": "$32,500", "wrong_amt2": "$31,000", "wrong_amt3": "$35,000"},
619
+ ]
620
+
621
+ # ═════════════════════════════════════════════════════════════
622
+
623
+ # GENERATOR (ONLY MODIFIED SECTION)
624
+
625
+ # ═════════════════════════════════════════════════════════════
626
+
627
+ def generate_domain(domain_name, templates, objects, target):
628
+ items = []
629
+ item_id = 0
630
+ template_cycle = itertools.cycle(templates)
631
+ object_pool = list(objects) * (target // len(objects) + 10)
632
+ random.shuffle(object_pool)
633
+
634
+ for obj in object_pool:
635
+ if len(items) >= target:
636
+ break
637
+
638
+ tmpl = next(template_cycle)
639
+
640
+ try:
641
+ obj = obj.copy()
642
+
643
+ # ✅ FIXES APPLIED HERE
644
+ if domain_name == "Spatial":
645
+ compute_spatial(obj)
646
+
647
+ elif domain_name == "Mathematical":
648
+ compute_math(obj)
649
+
650
+ elif domain_name == "Temporal":
651
+ compute_temporal(obj)
652
+
653
+ context = cap(fill(tmpl["template"], obj))
654
+ correct = cap(fill(tmpl["correct"], obj))
655
+ distractors = [cap(fill(d, obj)) for d in tmpl["distractors"]]
656
+
657
+ options = [correct] + distractors[:3]
658
+ random.shuffle(options)
659
+
660
+ answer_index = options.index(correct)
661
+
662
+ tier = "easy" if item_id % 2 == 0 else "challenge"
663
+
664
+ items.append({
665
+ "id": f"{domain_name.lower()}_{item_id:05d}",
666
+ "domain": domain_name,
667
+ "tier": tier,
668
+ "context": context,
669
+ "options": options,
670
+ "answer_index": answer_index,
671
+ "answer": correct,
672
+ })
673
+
674
+ item_id += 1
675
+
676
+ except Exception:
677
+ continue
678
+
679
+ return items
680
+
681
+
682
+ # ═════════════════════════════════════════════════════════════
683
+
684
+ # MAIN
685
+
686
+ # ═════════════════════════════════════════════════════════════
687
+
688
+ all_items = []
689
+
690
+ domains = [
691
+ ("Deductive", DEDUCTIVE_TEMPLATES, DEDUCTIVE_OBJECTS),
692
+ ("Causal", CAUSAL_TEMPLATES, CAUSAL_OBJECTS),
693
+ ("Temporal", TEMPORAL_TEMPLATES, TEMPORAL_OBJECTS),
694
+ ("Spatial", SPATIAL_TEMPLATES, SPATIAL_OBJECTS),
695
+ ("Mathematical", MATHEMATICAL_TEMPLATES, MATHEMATICAL_OBJECTS),
696
+ ]
697
+
698
+ for name, templates, objects in domains:
699
+ items = generate_domain(name, templates, objects, TARGET_PER_DOMAIN)
700
+ all_items.extend(items)
701
+ print(f"{name}: {len(items)} items generated")
702
+
703
+ random.shuffle(all_items)
704
+
705
+ Path("/mnt/user-data/outputs").mkdir(parents=True, exist_ok=True)
706
+
707
+ with open(OUTPUT_FILE, "w") as f:
708
+ for item in all_items:
709
+ f.write(json.dumps(item) + "\n")
710
+
711
+ print(f"\nTotal: {len(all_items)} items → {OUTPUT_FILE}")
712
+
713
+ # Spot check
714
+
715
+ print()
716
+ for domain in ["Deductive", "Causal", "Temporal", "Spatial", "Mathematical"]:
717
+ sample = next((i for i in all_items if i["domain"] == domain), None)
718
+ if sample:
719
+ print(f"=== {domain} ({sample['tier']}) ===")
720
+ print(f"Context: {sample['context']}")
721
+ for idx, opt in enumerate(sample["options"]):
722
+ marker = "✓" if idx == sample["answer_index"] else " "
723
+ print(f" [{marker}] {chr(65+idx)}) {opt}")
724
+ print()