How do we know Mary was a perpetual virgin?

Did Mary stay a virgin her whole life? This seems to say she and Joseph had relations after the birth of Jesus.

Matthew 1:22-25Now all this took place that what was spoken by the Lord through the prophet might be fulfilled, saying, 23 Behold, the virgin shall be with child, and shall bear a Son, and they shall call His name Immanuel," which translated means, "God with us. 24 And Joseph arose from his sleep, and did as the angel of the Lord commanded him, and took her as his wife, 25 and kept her a virgin until she gave birth to a Son; and he called His name Jesus.

Also, it talks about Jesus having brothers.

Matther 12:46 While he was still speaking to the people, behold, his mother and his brothers stood outside, asking to speak to him.

Matthew 13:53-56 Where did this man get this wisdom? Where did he get this power to do miracles?" they asked. "Isn’t this the carpenter’s son? Isn’t his mother’s name Mary? Aren’t his brothers James, Joseph, Simon and Judas? Aren’t all his sisters with us?

You should find the following links helpful:

Catholic Scripture Responses to Protestant Objections to Mary’s Perpetual Virginity

and

Church Tradition of Mary’s Perpetual Virginity

DISCLAIMER: The views and opinions expressed in these forums do not necessarily reflect those of Catholic Answers. For official apologetics resources please visit www.catholic.com.