mufti: a jurist who interprets Muslim religious law
jurist: a legal scholar versed in civil law or the law of nations
idiot savant: person who is mentally retarded in general but who displays remarkable aptitude in some limited field (usually involving memory)