I want to use a short (5 lines) mathematical proof from someone else's machine learning paper in my master thesis. Should I provide it, to help comprehension and save readers the trouble of looking it up, or should I just refer to it? Is it OK to copy-paste the proof, as long as I make clear where it came from, or is that plagiarism?
Your masters thesis is yours. Make it something that you are happy with. Your supervisor might also want it to look a certain way because their name will be associated with it by virtue of the fact that they supervised you, but supervisors often have dozens of students in their lifetime, and one stylistic choice about whether to write out a proof or just cite it, will very unlikely make them lose sleep.
Based on the way you worded the question, it seems that your preference would be to write out the 5-line proof. If your preference was to just cite the paper, then you wouldn't have to ask us, because you know very well that there would be no question of plagiarism in that scenario.
So since (1) the thesis is yours and (2) you want to show the full proof (not just a reference to it), we must explore whether or not it would be plagiarism.
If you clearly state:
"Note that the following proof has been reproduced exactly from X with the written consent of the author and the journal's publisher, for the purpose of providing clarity to the reader"
and you give a proper citation, you will with almost 100% certainty be safe from any plagiarism conviction. The question is whether or not you wish to take the 0.001% risk, or put in the extra time and effort to get permission (or not do that, an increase the risk to 0.1%), and one page of your thesis look slightly unconventional; or whether you'd just like to take the most common approach which is to cite the original paper and give your own explanation of the proof in your own words. Both of these options are perfectly reasonable if you are happy with the final product. Without details of what type of proof it is, what it involves, etc., (you haven't even told us whether or not its your own proof, which Buffy has assumed even though I assumed the opposite), none of us will be able to make the best decision for you.
By the way: Congratulations on getting this far in your Masters!
A third option is to give your own proof. Instead of copying it word-for-word, rewrite it in your own words and with notation that matches the rest of your paper, and include a citation of the original source.
Don't do this by taking the source text and just changing a few words. Instead, study it until you feel you understand the key idea, then set it aside and write your own proof. Resist the temptation to just recite the original proof from memory.
This solves all your problems and more:
it keeps the paper self-contained
it isn't plagiarism, since the source has been cited (to credit the idea) and the text hasn't been copied
it doesn't require quotation marks or other indication of verbatim quoting
it isn't copyright infringement, since the exact text wasn't used
it doesn't require explicit consent from the original author or publisher
you have gained a fuller understanding of how the proof works
your version of the proof will fit better in the context of your paper and your own writing style
you may be able to improve upon the original proof, or at least to make it better fit the way you think about the ideas involved
the reader now has two different proofs they can look at (yours and the original), which gives them some options in case they find something unclear in one of them.
At least in mathematics, it's most common to either do this, or else to simply refer to the original. It's very rare to actually copy a proof verbatim, and is usually only done when one wants to add critical or historical commentary on the proof itself.