Catalysis of the reaction: FMNH2 + O2 <=> 5,6-dimethylbenzimidazole + D-erythrose 4-phosphate + dialuric acid