Generalized groups as global or local symmetries