# Thm 61.1 : trois involutions a composantes disjointes sur la donnee d'orientation.
# Donnee : (ordre_de_lecture, bout_ket, fleche, creneau, exposant, signe, marqueur_de_lecture).
# Les deux bouts d'un lien sont DISTINCTS (u, v) ; S les echange, C renverse la fleche,
# R renverse creneau, exposant, signe et marqueur.
def apply_S(dat):
ordre, ket, arr, slot, expo, sgn, rmark = dat
u, v = ordre
return ((v, u), v if ket == u else u, arr, slot, expo, sgn, rmark)
def apply_C(dat):
ordre, ket, arr, slot, expo, sgn, rmark = dat
return (ordre, ket, 1 if arr == -1 else -1, slot, expo, sgn, rmark)
def apply_R(dat):
ordre, ket, arr, slot, expo, sgn, rmark = dat
inv = lambda x: -x
return (ordre, ket, arr, inv(slot), inv(expo), inv(sgn), inv(rmark))
def compte(dat):
# Une fonction de la structure NON ORIENTEE : invariante sous chaque carte.
ordre, ket, arr, slot, expo, sgn, rmark = dat
u, v = ordre
return (frozenset((u, v)), frozenset((arr, -arr)), frozenset((slot, -slot)),
frozenset((expo, -expo)), frozenset((sgn, -sgn)), frozenset((rmark, -rmark)))
ENDS = ((1, 2), (2, 1))
combos = [((o, k, a, s, e, g, m))
for o in ENDS for k in (1, 2)
for a in (1, -1) for s in (1, -1) for e in (1, -1)
for g in (1, -1) for m in (1, -1)]
def produit_SCR(dat):
return apply_R(apply_C(apply_S(dat)))
ORDRES = [produit_SCR,
lambda d: apply_S(apply_C(apply_R(d))),
lambda d: apply_C(apply_S(apply_R(d))),
lambda d: apply_R(apply_S(apply_C(d))),
lambda d: apply_S(apply_R(apply_C(d))),
lambda d: apply_C(apply_R(apply_S(d)))]
okS = okC = okR = okP2 = okOrdres = okComptes = moved_all = 0
for dat in combos:
okS += apply_S(apply_S(dat)) == dat
okC += apply_C(apply_C(dat)) == dat
okR += apply_R(apply_R(dat)) == dat
P = produit_SCR(dat)
okP2 += produit_SCR(P) == dat # le carre du produit : identite
okOrdres += all(o(dat) == P for o in ORDRES) # composantes disjointes -> les six ordres coïncident
okComptes += all(compte(dat) == compte(f(dat))
for f in (apply_S, apply_C, apply_R, produit_SCR))
P2 = produit_SCR(dat)
moved_all += (P2[0] != dat[0] and P2[1] != dat[1] and P2[2] == -dat[2]
and P2[3] == -dat[3] and P2[4] == -dat[4] and P2[5] == -dat[5]
and P2[6] == -dat[6])
n = len(combos)
print("S^2 = C^2 = R^2 = identite :", okS, "/", n, "=", okC, "/", n, "=", okR, "/", n)
print("produit : P^2 = identite", okP2, "/", n, " ; les six ordres coïncident", okOrdres, "/", n)
print("comptes (structure non orientee) inchanges par S, C, R et le produit :", okComptes, "/", n)
print("le produit meut chaque composante de la donnee :", moved_all, "/", n)
t611_ok = (okS == okC == okR == okP2 == okOrdres == okComptes == moved_all == n)
print("attendu (imprime) : chaque involution rend la donnee, P meut tout, P^2 = I, comptes immobiles ->", t611_ok)