Here's the extract from SO2003
65Sex with an adult relative: consenting to penetration
(1)A person aged 16 or over (A) [F5(subject to subsection (3A))] commits an offence if—
(a)another person (B) penetrates A’s vagina or anus with a part of B’s body or anything else, or penetrates A’s mouth with B’s penis,
(b)A consents to the penetration,
(c)the penetration is sexual,
(d)B is aged 18 or over,
(e)A is related to B in a way mentioned in subsection (2), and
(f)A knows or could reasonably be expected to know that he is related to B in that way.
So in this case Mary (A) would have to defend herself against a charge of incest by using subsection (f) ie that she did not know she was related to Derek (B). I suspect that subsection was drafted more to cover eg siblings separated when young who met and had sex without realising their relationship.
So a court would probably rule that although Mary's defence to incest wasn't envisaged by subsection (f) it would be a reasonable defence that would go into case law to be cited in future in any similar case.