Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorporate example Monoid implementation? #45

Open
kalmarek opened this issue Apr 15, 2021 · 0 comments
Open

incorporate example Monoid implementation? #45

kalmarek opened this issue Apr 15, 2021 · 0 comments

Comments

@kalmarek
Copy link
Owner

kalmarek commented Apr 15, 2021

See:
https://gist.github.com/kalmarek/9475f36e768046cd7ef7fc08891bf553

julia> include("Monoids.jl")

julia> using .Monoids

julia> function example_monoid(n::Integer)
           A = Alphabet([[Symbol('a', i) for i in 1:n]; [Symbol('b', i) for i in 1:n]])
           F = FreeMonoid(A)
           rels = let S = gens(F)
               squares = [g^2=>one(g) for g in S]
               @views a, b = S[1:n], S[n+1:end]
               aibj = [a[i]*b[j] => b[j]*a[i] for i in 1:n for j in 1:n]
               [squares; aibj]
           end

           return F/rels
       end
example_monoid (generic function with 1 method)

julia> M = example_monoid(2)
monoid with 8 relations over Alphabet{Symbol}[:a1, :a2, :b1, :b2]

julia> a, b = M(rand(1:4, 20)), M(rand(1:4, 20))
(a1*a2*a1*a2*b1*b2*b1*b2*b1*b2, a2*a1*a2*a1*a2*b2*b1*b2)

julia> a*b
a2*b1*b2*b1

julia> b*a
a2*a1*a2*a1*a2*a1*a2*a1*a2*b2*b1*b2*b1*b2*b1*b2*b1*b2

julia> x = M(rand(1:4, 20)); isreduced(x)
false

julia> y = deepcopy(x); normalform!(y); isreduced(y)
true

julia> x === y
false

julia> x == y
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant