Kevletesteur's picture
Upload folder using huggingface_hub
e00f1a7 verified
Raw
History Blame Contribute Delete
6.23 kB
#!/usr/bin/env python3
# T1/T1b — GÉNÉRATEUR de 240 items à réponse ENTIÈRE vérifiable. 6 familles × 40 (20 EN/20 FR),
# vérités calculées (sympy/math), jamais tapées. Auto-testé sur valeurs connues.
import json, math, sympy as sp
items = []
def add(fam, lang, q, val):
assert float(val) == int(val), (fam, q, val)
items.append({"id": len(items), "famille": fam, "langue": lang, "enonce": q, "cible": int(val)})
def bloc(fam, gen_en, gen_fr, params):
for i, p in enumerate(params):
if i % 2 == 0:
q, v = gen_en(p); add(fam, "en", q, v)
else:
q, v = gen_fr(p); add(fam, "fr", q, v)
# F1 — dimensions de groupes de Lie (40)
NS = [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]
def f1e(N):
if N % 3 == 0: return (f"What is the dimension of the Lie group SU({N})?", N * N - 1)
if N % 3 == 1: return (f"What is the dimension of the Lie group SO({N})?", N * (N - 1) // 2)
return (f"What is the dimension of the Lie group Sp({2*N})? (compact symplectic, rank {N})", N * (2 * N + 1))
def f1f(N):
if N % 3 == 0: return (f"Quelle est la dimension du groupe de Lie SU({N}) ?", N * N - 1)
if N % 3 == 1: return (f"Quelle est la dimension du groupe de Lie SO({N}) ?", N * (N - 1) // 2)
return (f"Quelle est la dimension du groupe de Lie Sp({2*N}) ? (symplectique compact, rang {N})", N * (2 * N + 1))
bloc("lie", f1e, f1f, NS)
# F2 — ordres de groupes finis (40)
P2 = [(2, 3), (3, 2), (4, 5), (5, 4), (6, 7), (7, 6), (8, 3), (3, 8), (5, 7), (7, 5),
(4, 9), (9, 4), (6, 5), (5, 6), (8, 7), (7, 8), (9, 2), (2, 9), (6, 11), (11, 6),
(4, 3), (3, 4), (5, 2), (2, 5), (7, 3), (3, 7), (8, 5), (5, 8), (9, 7), (7, 9),
(10, 3), (3, 10), (6, 3), (3, 6), (10, 7), (7, 10), (4, 7), (7, 4), (9, 5), (5, 9)]
def f2e(p):
n, m = p
if m % 2: return (f"What is the order of the symmetric group S_{n}?", math.factorial(n))
return (f"What is the order of the dihedral group of a regular {n}-gon (rotations and reflections)?", 2 * n)
def f2f(p):
n, m = p
if m % 2: return (f"Quel est l'ordre du groupe alterné A_{n} ?", math.factorial(n) // 2)
return (f"Quel est l'ordre du groupe diédral d'un polygone régulier à {n} côtés (rotations et réflexions) ?", 2 * n)
bloc("ordres", f2e, f2f, P2)
# F3 — combinatoire (40)
P3 = [(10, 3), (12, 5), (8, 4), (15, 2), (9, 6), (11, 4), (14, 7), (7, 3), (13, 5), (16, 3),
(6, 2), (18, 4), (10, 5), (12, 3), (20, 2), (9, 4), (8, 5), (15, 6), (11, 2), (17, 3),
(5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (4, 0), (11, 0), (12, 0), (5, 1),
(6, 1), (7, 1), (8, 1), (9, 1), (10, 1), (4, 1), (11, 1), (3, 1), (12, 1), (13, 1)]
def cat(n): return math.comb(2 * n, n) // (n + 1)
def der(n): return round(math.factorial(n) / math.e) if n else 1
def f3e(p):
n, k = p
if k >= 2: return (f"Compute the binomial coefficient C({n},{k}).", math.comb(n, k))
if k == 0: return (f"Compute the {n}-th Catalan number C_{n} = (2n choose n)/(n+1).", cat(n))
return (f"Compute the number of derangements of {n} objects.", sp.subfactorial(n))
def f3f(p):
n, k = p
if k >= 2: return (f"Calcule le coefficient binomial C({n},{k}).", math.comb(n, k))
if k == 0: return (f"Calcule le {n}-ième nombre de Catalan C_{n} = C(2n,n)/(n+1).", cat(n))
return (f"Calcule le nombre de dérangements de {n} objets.", sp.subfactorial(n))
bloc("combi", f3e, f3f, P3)
# F4 — arithmétique (40)
P4 = [36, 48, 60, 72, 84, 90, 96, 100, 120, 144, 168, 180, 210, 240, 256, 300, 360, 420, 480, 504,
540, 600, 630, 660, 720, 840, 900, 960, 1000, 1024, 45, 50, 54, 56, 63, 64, 66, 70, 75, 80]
def f4e(n):
if n % 2: return (f"Compute Euler's totient phi({n}).", sp.totient(n))
return (f"How many positive divisors does {n} have?", sp.divisor_count(n))
def f4f(n):
if n % 2: return (f"Calcule l'indicatrice d'Euler phi({n}).", sp.totient(n))
return (f"Combien {n} possède-t-il de diviseurs positifs ?", sp.divisor_count(n))
bloc("arith", f4e, f4f, P4)
# F5 — chaînes entières 2 étapes (40)
P5 = [(N, k) for N, k in zip(NS, [2, 3, 5, 7, 4, 6, 8, 9, 2, 3, 5, 7, 4, 6, 8, 9, 2, 3, 5, 7,
4, 6, 8, 9, 2, 3, 5, 7, 4, 6, 8, 9, 2, 3, 5, 7, 4, 6, 8, 9])]
def f5e(p):
N, k = p
d = N * N - 1
return (f"Step 1: compute d = dim SU({N}) = N**2 - 1. Step 2: compute d*{k} - {N}. "
f"Give the value of step 2.", d * k - N)
def f5f(p):
N, k = p
d = N * N - 1
return (f"Étape 1 : calcule d = dim SU({N}) = N**2 - 1. Étape 2 : calcule d*{k} - {N}. "
f"Donne la valeur de l'étape 2.", d * k - N)
bloc("chaine", f5e, f5f, P5)
# F6 — physique à réponse entière (40)
P6 = [(3, 0), (3, 3), (3, 6), (6, 3), (6, 6), (9, 0), (6, 0), (9, 3), (12, 3), (9, 6),
(12, 0), (12, 6), (15, 3), (3, 0), (15, 0), (6, 3), (15, 6), (9, 0), (18, 3), (12, 3)] * 2
def f6e(p):
N, nf = p
b0 = (11 * N - 2 * nf) // 3
return (f"With the convention beta(g) = -b0*g**3/(16*pi**2), b0 = 11*N/3 - 2*nf/3: compute b0 "
f"for SU({N}) Yang-Mills with {nf} Dirac fermion flavors in the fundamental.", b0)
def f6f(p):
N, nf = p
g = N * N - 1
return (f"Combien y a-t-il de gluons (bosons de jauge) dans une théorie de jauge SU({N}) ?", g)
bloc("physique", f6e, f6f, P6)
# auto-tests
assert any(i["cible"] == 8 and "SU(3)" in i["enonce"] and i["famille"] == "physique" for i in items)
assert any(i["cible"] == 11 and i["famille"] == "physique" for i in items) # b0 SU(3) nf=0
assert any(i["cible"] == 120 and "S_5" in i["enonce"] for i in items) # |S_5|
assert any(i["cible"] == 42 and "Catalan" in i["enonce"] for i in items) # C_5 = 42
assert any(i["cible"] == int(sp.totient(45)) and "45" in i["enonce"] for i in items)
assert len(items) == 240, len(items)
with open("./t1_items.jsonl", "w") as f:
for it in items:
f.write(json.dumps(it, ensure_ascii=False) + "\n")
fr = sum(1 for i in items if i["langue"] == "fr")
print(f" {len(items)} items ({fr} FR), 6 familles, générateur auto-testé")