Are safety helmets compulsory?

No they are not. They are only required to be provided and worn when there is a foreseeable risk of injury to the head other than by falling. For example, from falling objects or hitting the head ahead against something. If there is no foreseeable risk of injury to the head other than by falling, then hard hats are not required by law.