I think you’re looking at this backwards.
The Portuguese word spelled sim did not come to be pronounced [sĩ]
through some sort of assimilation of nasal consonant, the way occurred with Portuguese fim [fĩ]
and um [ũ]
, or even sem < Latin sine.
Rather, the word came to be pronounced that way, and so came to spelled in a way that indicated its nasalization, and ‹im› is simply how one spells [ĩ]
there.
Although not all nasalization in Portuguese is explicitly marked in the orthography (for example, in muito [mũĩ̯tu]
), with sim [sĩ]
, it is. Similarly, Portuguese assim [ɐˈsĩ]
is written with an ‹im›. This developed from Latin ad sic, “with nasalization”.[ref] The history of Portuguese is complex and uneven, and did not settle down until much later than in languages such as neighboring Spanish did back in the 1500s.
Nasalization and palatalizations were variously marked with an tilde, with an n or m, or with a following h — or with some combination of these:[ref]
- cimco > cinco
- grãde > grande
- tẽpo > tempo
- razõ > razom
- camĩho > caminho
In the earliest preserved texts of what would become Portuguese, you see the letter h used innovatively, as in sabha for sabia, or mha for what become modern minha, meu. For example, Dom Denis wrote in one of his Cantigas de Amor:[ref]
Proençaes soen mui ben trobar
e dizen eles que é con amor;
mais os que troban no tempo da frol
e non en outro, sei eu ben que non
an tan gran coita no seu coraçon
qual m'eu por mha senhor vejo levar.
In contrast, Afonso Xº wrote mia for the same word used in the same situation in his Cantigas de Santa Maria:[ref]
Con sennor, assi dizia, | chorando mui feramente:
«Mia Sennor, eu a ti venno | como moller que se sente
de grand' erro que á feito; | mas, Sennor, venna-ch' a mente
se che fiz algun serviço, | e guarda-me mia pessõa
Atant' é Santa Maria | de toda bondade bõa...
Afonso writes other othographically interesting things, like non poss' eu perdon gãar for modern Portuguese ganhar[ref], or non disse ssi nen non[ref]. There we see that Latin sic has for Afonso become ssi without the nasalization marking present in nen, the same word which would become modern Spanish ni, but there unnasalized.
In other places, Afonso uses mi as a prepositional object, which modern Portuguese would spell as mim with final ‹im› to indicate nasalization, despite there never having been an historical dental consonant. Similarly, as words like mha, mia, mi came to be pronounced with nasalization, these were also reanalysed the way medieval ũa would. On page 147 of The Romance Languages [Harris&Vincent; OUP 1990], in the section on historical Portuguese morphology, they write:
Both the articles show abnormal phonetic developments. In the indefinite article, derived from the numeral UNUM, the feminine forms would ordinarily have been denasalised, as ∗[ua], ∗[uas], but retain their nasality, by analogy with the masculine. The modern feminine forms developed in the seventeenth sentury, though glide epenthesesis ũa > ∗uw̃a > uma possibly influenced by the orthographic form of the masculine, (h)um.
On page 143, the authors explain that ‹‑m› and ‹‑n› are modern orthographic indicators of nasality, which in earlier days used a tilde, or which were not indicated in the orthography at all. They warn that “in many cases (e.g. tã = ta(n)?) its interpretation is a matter of dispute between linguists and paleographers.”
So analogous forms of writing nasalized vowels using a following ‹m› in the orthography influenced how nasal vowels would coming to be written as orthography became more regular. There was no historical nasal consonant left in mea > mha, mia > minha, but it got written that way, and this in turn came to influence the pronunciation. Similarly, the spellings of mim, sim, assim represent the comparatively recent orthographic invention/convention for writing a [ĩ]
there, despite there never having been a nasal consonant present to assimilate. In some cases, there was; in some cases there was not; and in some cases, it is a matter of some dispute just what was actually going on there.