using AbstractAlgebra function groupe(liste) sans_doublon=[] for g in liste if !(g in sans_doublon) push!(sans_doublon,g) end end ajoute=[] for g in sans_doublon inverse=inv(g) if !(inverse in sans_doublon) push!(ajoute,inverse) end end nouveau=[sans_doublon; ajoute] taille=length(nouveau) fin=false while !fin ta=copy(nouveau) taille_a=taille trouve=false while (taille_a>0) && (!trouve) a=pop!(ta) taille_a-=1 tb=copy(nouveau) taille_b=taille while (taille_b>0) && (!trouve) b=pop!(tb) taille_b-=1 produit=a*b if !(produit in nouveau) trouve=true taille+=1 push!(nouveau,produit) inverse=inv(produit) if produit!=inverse push!(nouveau,inverse) taille+=1 end end #if end #while b end # while a fin=!trouve end # while !fin return(nouveau) end # function function diedral(N) r=perm([N; collect(1:N-1)]) s=perm(-collect(1:N).+(1+N)) return(groupe([r,s])) end function anneau(N,T,prefixe="x_") vari=prefixe.*string.(collect(1:N)) A,=PolynomialRing(T,vari) return(A) end function Z_pas_normalise(gr,T,prefixe="x_") N=parent(gr[1]).n A=anneau(N,T,prefixe) s=A() # le zéro de l'anneau for g in gr monome=MPolyBuildCtx(A) ptype=permtype(g) classe=[sum(ptype.==i) for i=1:N] push_term!(monome,T(1),classe) s+=finish(monome) end return(s) end function Z(gr,T,prefixe="x_") return(Z_pas_normalise(gr,T,prefixe)* (1//length(gr))) end function W(g,args...) Pn=Z_pas_normalise(g,ZZ) T=[sum([b for b in args])] for i=2:parent(g[1]).n s=sum([b^i for b in args]) T=[T;s] end return(Pn(T...)//length(g)) end function decompbinom(tableau,symbol="n") t=copy(tableau) i=0 str="" while !isempty(t) coeff=t[1] t=diff(t) if !iszero(coeff) sg=ifelse(coeff>0,"+","") str=(sg*string(coeff)*"binomial("* symbol*","*string(i)*")")*str end i+=1 end return(str) end function Analyse(G) N=parent(G[1]).n println("Analyse du sous-groupe de S_",N) println(G) println("avec ",length(G)," éléments") P=Z(G,QQ) println("Polynome indicateur de cycle:") println(P) B,(x,y)=PolynomialRing(ZZ,["x","y"]) modele=W(G,x,y) println("Modèle pour le coloriage à deux couleurs:") println(modele) C, n=PolynomialRing(QQ,"n") Ncol=P(fill(n,N)...) println("Nombre de coloriages avec une palette de n couleurs:") println(Ncol) tableau=[Integer(Ncol(i)) for i=0:N] println("ou encore ") println(decompbinom(tableau)) end cube=groupe([perm"(1,2,6,5)", perm"(1,3,6,4)"]) Analyse(cube) ffjm=groupe([perm"(1,6,8,3)(2,4,7,5)", perm"(1,6)(2,7)(3,8)"]) Analyse(ffjm)