(A) (i) An applicant is the wife, husband, widow, or widower of a fully or currently insured individual for purposes of this subchapter if the courts of the State in which such insured individual is domiciled at the time such applicant files and application, or, if such insured individual is dead, the courts of the State in which he was domiciled at the time of death, or, if such insured individual is or was not so domiciled in any State, the courts of the District of Columbia, would find that such applicant and such insured individual were validly married at the time such applicant files such application or, if such insured individual is dead, at the time he died. (ii) If such courts would not find that such applicant and such insured individual were validly married at such time, such applicant shall, nevertheless be deemed to be the wife, husband, widow, or widower, as the case may be, of such insured individual if such applicant would, under the laws applied by such courts in determining the devolution of intestate personal property, have the same status with respect to the taking of such property as a wife, husband, widow, or widower of such insured individual.
(B) (i) In any case where under subparagraph (A) an applicant is not (and is not deemed to be) the wife, widow, husband, or widower of a fully or currently insured individual, or where under subsection (b), (c), (d), (f), or (g) such applicant is not the wife, divorced wife, widow, surviving divorced wife, husband, divorced husband, widower, or surviving divorced husband of such individual, but it is established to the satisfaction of the Commissioner of Social Security that such applicant in good faith went through a marriage ceremony with such individual resulting in a purported marriage between them which, but for a legal impediment not known to the applicant at the time of such ceremony, would have been a valid marriage, then, for purposes of subparagraph (A) and subsections (b), (c), (d), (f), and (g), such purported marriage shall be deemed to be a valid marriage. Notwithstanding the preceding sentence, in the case of any person who would be deemed under the preceding sentence a wife, widow, husband, or widower of the insured individual, such marriage shall not be deemed to be a valid marriage unless the applicant and the insured individual were living in the same household at the time of the death of the insured individual or (if the insured individual is living) at the time the applicant files the application. A marriage that is deemed to be a valid marriage by reason of the preceding sentence shall continue to be deemed a valid marriage if the insured individual and the person entitled to benefits as the wife or husband of the insured individual are no longer living in the same household at the time of the death of such insured individual. (ii) The provisions of clause (i) shall not apply if the Commissioner of Social Security determines, on the basis of information brought to the Commissioner’s attention, that such applicant entered into such purported marriage with such insured individual with knowledge that it would not be a valid marriage. (iii) The entitlement to a monthly benefit under subsection (b) or (c) of section 402 of this title , based on the wages and self-employment income of such insured individual, of a person who would not be deemed to be a wife or husband of such insured individual but for this subparagraph, shall end with the month before the month in which such person enters into a marriage, valid without regard to this subparagraph, with a person other than such insured individual. (iv) For purposes of this subparagraph, a legal impediment to the validity of a purported marriage includes only an impediment (I) resulting from the lack of dissolution of a previous marriage or otherwise arising out of such previous marriage or its dissolution, or (II) resulting from a defect in the procedure followed in connection with such purported marriage.