My situation is the following. I'm about to submit an article to a journal with the goal of having it published in that journal. The journal distributes its content under CC BY 4.0. While writing this article I ran into a (math) sub-problem which I couldn't solve myself. So I asked a question on Math SE and it got an answer which solved the problem. The answer contains a description of the required steps (mathematical aspects) as well as a code snippet which verifies the assumptions with the help of a computer program (this code is required to complete the proof). For completeness, I would like to include the content of this answer in my article; the proof it demonstrates is required for my work to be complete (otherwise my conjecture stands without proof). However, Math SE content is licensed under CC BY-SA 4.0 which seems to be more restrictive than CC BY 4.0 since it additionally requires ShareAlike. The creative commons website provides the following description:
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
This page mentions that ShareAlike also allows publication under a compatible license. The page lists Free Art License and GPLv3 as compatible with CC BY-SA 4.0.
Which brings me to my question(s). Am I allowed to include the Math SE answer's content into my article and have the journal redistribute it under CC BY 4.0? Based on the above findings, my feeling is that I am not allowed to do that (or that the journal is not allowed to redistribute that content and thus would have to reject the article). Which brings me to my second question. In the case that I am not allowed to include the Math SE content, what are my options? For my article to be complete I need a proof of the specific sub-problem similar to the one which has been given in the Math SE answer. I didn't manage to come up with another proof myself (that's why I asked the question). Even if I rephrase that Math SE answer, I guess, including it without proper attribution still poses a copyright infringement (and after all, there is the code snippet which I can't really rewrite; at least not its purpose and what it's doing). Have I reached an impasse?
A glimmer of hope? One option that comes to my mind is that in my article I just state "this is the problem (description-goes-here) and it has been proved here [citation]" (i.e. not including the proof). However, the problem description is not simple and in order to make it more accessible for the Math SE users, I have rephrased it by removing any domain knowledge / notation (i.e. on Math SE it stands as as pure, generic math problem, but it originated from a specific physics problem with dedicated notation etc.). So for the readers of my article it will be difficult to connect the cited answer to the original problem. So this would require me to rephrase the problem inside my article so it has the same form as the one on Math SE. That, however, feels awkward because to the reader it will seem like an unnecessary excursion / transformation which further inflates the article; the readers will ask themselves, why didn't the authors stay within the physics domain and just adapted the proof accordingly; that would have been so much easier to understand.