The first woman to have served on the Supreme Court is withdrawing from public life after being diagnosed with dementia.