The gemara elaborates about the melacha of writing on shabbos. Although the Shulchan Aruch 340:4 is very concise in this melacha, the Mishna Berura elaborates and provides many details based on what is found in our gemara.
The gemara says that if one erases the middle of the ches turning it into two zayin, or erases the back of the dales turning it into a reish (and completes a sefer by doing this so that it is like writing two letters), they are chayev. The Ran struggles with a fundamental question. Why is this not a problem of chok tochos? In the context of STAM and gittin we require the writing to be performed by writing, not by erasing, because when a letter is formed through erasing it is called חק תוכות which doesn't qualif as כתיבה? The Ran cites the Rashba who says that erasing the roof of the ches or the back of the dales would not be considered חק תוכות because it is similar to merely separating between two attached letters which would not be a problem of חק תוכות, here too it is like erasing ink that fell on the back of the letter. Perhaps the Rashba understands that we are speaking about a case where his intention was to write a reish, just that some extra ink came out forming a dales, therefore he equates this with ink falling on a letter. However, the Ran takes a radically different approach. The Ran says that to be in violation for writing on shabbos we don't make a distinction between actual writing and חק תוכות. One can even be chayev for writing חק תוכות. His rationale is:
דכל היכא דהוי מלאכת מחשבת מיחייב שהרי אפילו מוחק ע"מ לכתוב חייב
The approach of the Ran seems to be that on shabbos our focus is not on the technical act of writing, rather on מלאכת מחשבת. That means that our focus is on the result of the melacha, not the act of doing the melacha. Therefore, so long as a person accomplishes a כתיבה, even if he does so by erasing which wouldn't qualify as writing in other areas of Torah, it is considered writing on shabbos so he is chayev.