Suppose that two people (A and B) decided to combine their money and jointly invest them into something. Suppose that A contributed X dollars and B contributed Y dollars. After some time lapse the value of their X+Y dollars becomes Z. If they realize this investment at that point, what portion of Z would A take and what portion would B take ?

Of course, there is no law stipulating that. All depends on the agreement between the parties. But in most cases the parties agree to split profit proportionally to their contributions. In other words, A normally gets XZ/(X+Y) and B gets YZ/(X+Y).

Surprisingly, there are exceptions to this reasonable rule. When you buy a house which costs P1 dollars, you contribute a downpayment X and bank contributes the rest (P1-X). But when you sell the house for a price P2 you pay to the bank somewhat about R(P1-X), where R is the compound interest over the period of time that you owned the house. The rest is yours. Thus, you get roughly P2 - R(P1-X) and not (P2 x X)/P1, as would be the case with the normal investors A and B.

The difference is huge. For example, if X = 0.05 x P1, P2 = 2 x P1 and R = 5%, then you get 2 x P1 - 1.05 x (P1 - 0.05 x P1) = 1.025 x P1 rather than 0.1 x P1 !

This makes investing into real estate quite different from any other
type of investment in that it violates __the fundamental
principle of economical sanity:
the return on capital must be proportional to the amount of capital invested.__
(Do not confuse this with the Marx's or Malthus' observation that
"the return on capital is, on average, the same for all types of
investments".)
In the case of real estate, the return is simply not proportional !
For example, if you put down $100 on a house that costs $100,000
and its value appreciates to $200,000, then the return on your $100
is almost $100,000. But if you put down $200 instead, the return on
$200 is again almost $100,000 ! (__Not to mention another paradox that
you profit more than the bank which covered most of
the purchase price !__)

I am not sure if the returns are indeed, on average, the same for all kinds of
investment, but I am positive that
__in a balanced economy there should be no astronomical disparity
between various types of investment at any point in time.__
It should not be that
when you invest $100 into stocks and stocks rise 100%,
your $100 become $200, but if you invest $100 into real estate
by putting them
down on a $100,000 property, which then
appreciates 100%, your $100 become almost $100,000 !

__
Is it not a loophole in the law (or absence of a proper law),
which may destabilize economy ? The fact that no destabilization happened in the
past is only because never before real estate appreciated 100%
over 4 years.
__

According to TRIZ, contradiction is a disease of a system. To make it healthy
contradictions have to be resolved !
__Would not it be, therefore,
prudent to enact a law that upon house sale
mortgagee and owner have to have equal
rates of return on capital invested ?__
Then people that put only $100 down on a $100,000 house would not be undeservingly
rewarded with $100,000 profit upon its sale.
They would get just $200, which is fair.
And bank, which contributed $99,900 would get back roughly $199,800
rather than $100,000, which it gets under the current legislation.

Of course, in the case of property depreciation, the borrower still has to return the amount borrowed (with interest) and not to leverage his losses on the shoulders of the bank.

Such a law would be in accord with Marx's ideas about the equality of the rates of return. At the same time it would be very beneficial for banks ! Yet another paradox, is not it ?