This question is based on William Shakespeare’s Hamlet. The principal function of the play-within-the-play in…