math: introduce handle_logical_rl()