# group_perm.tcl -- # Small experiment with group theory and permutations # # group -- # Generate the group from the given generators # Arguments: # args List of permutations, each one a generator # Result: # List of elements of the group # proc group {args} { if { [llength $args] > 1 } { set generator [lindex $args 0] set result [eval group [lrange $args 1 end]] set new 1 while { $new } { set new 0 set expanded $result foreach e $result { set eleft [combine $e $generator] set eright [combine $generator $e] if { [lsearch $expanded $eleft] < 0 } { lappend expanded $eleft set new 1 } if { [lsearch $expanded $eright] < 0 } { lappend expanded $eright set new 1 } } set result $expanded } } else { set generator [lindex $args 0] set result [list $generator] set enext $generator set new 1 while { $new } { set new 0 set enext [combine $generator $enext] if { [lsearch $result $enext] < 0 } { lappend result $enext set new 1 } } } return $result } # combine -- # Combine two permutations # Arguments: # p First permutation # q Second permutation (applied first) # Result: # Permutation p.q # proc combine {p q} { set result {} foreach e $q { lappend result [lindex $p $e] } return $result } # main -- # A few simple tests # puts "Simple exchange - applied twice gives identity:" set p {0 2 1} puts [combine $p $p] puts "Cycle of 3 - applied three times gives identity:" set p {1 2 0} puts [combine $p $p] puts [combine [combine $p $p] $p] puts "Cycle of 3 - with inverse gives identity:" set q {2 0 1} puts [combine $p $q] # # Now the heavier stuff: create a (sub)group # puts "Simple subgroup of S3:" puts [group {0 2 1}] puts "S3 complete:" puts [group {1 2 0} {0 2 1}] puts "Subgroup of S4:" puts [group {1 0 2 3} {0 2 1 3}] puts "S4 complete:" puts [group {1 0 2 3} {1 2 3 0}]
Magnus

GAP



