It is difficult to ascertain with certainty the age of a statement the Babylonian Talmud:
- It could go back all the way to the attributed speaker
- It could be a statement based on what the attributed speaker said,
but has been developed/expanded upon since that time
- It could be an incorrect attribution
Much of the material was in oral circulation (and/or through now lost written sources) for many years, making its origin difficult to trace.
The statement was in circulation
For purposes of this answer I will acknowledge that there is no reason why Rabbi Hillel couldn't have said this. Furthermore, the idea (of the negative Golden Rule) is found in earlier sources as well, such as Isocrates of ancient Greece (4th century B.C.):
Do not do to others that which angers you when they do it to you (see
Tobit (or its sources) may be older than Isocrates; the exact date is unknown.
Jesus frequently dialogued with the religious leaders of His day, and so it is reasonable to accept that He would have been familiar with this idea.
Negative vs. Positive Golden Rule
Both the negative and positive form of the Golden Rule have their roots in the Old Testament:
Thou shalt not avenge, nor bear any grudge against the children of thy
people, but thou shalt love thy neighbour as thyself: I am the Lord.
The positive form of the Golden Rule "All things therefore whatsoever you would that men should do to you, do you also to them" may indeed be original to Jesus--there is no definite usage (to my knowledge) of the positive form from an earlier date.
The positive form is an insightful development upon the negative form (negative form was found in Greece, Hillel, Tobit, etc) in that it isn't enough not to do ill; we are called upon to do good.
Whether Jesus learned the negative form of the Golden Rule through the disciples of Hillel or other means, it was an idea circulating in the eastern Mediterranean at His time. (For this reason, I doubt the Talmud derived the negative form of the Golden Rule from Jesus, though I can't rule it out completely)
I suggest that Jesus is expanding the maxim to show the type of life His followers should live, much as He did with other commands in the Sermon on the Mount.
What is the relationship between Sabbath 31a and Matthew 7:12?
The answer is uncertain, but an educated guess would be this:
- There is no direct literary relationship
- The basic ideas of each have common, older sources
- Jesus took the idea a step further