From Lekshe Jonwang.

གི་ཀྱི་གྱི་འི་ཡི་ལྔ་པོ། །རྣམ་དབྱེ་དྲུག་པ་འབྲེལ་སྒྲ་དང༌། །

The five particles གི་ ཀྱི་ གྱི་ འི་ ཡི་ are the sixth case (རྣམ་དབྱེ་དྲུག་པ་), the connective particle (འབྲེལ་སྒྲ་), i.e. the genitive of. All five mean the same; which one is written depends only on the suffix (རྗེས་འཇུག་, see Tibetan Syllable Parts) of the syllable before.

སྦྱོར་ཚུལ་ན་མ་ར་ལ་གྱི། །ད་བ་ས་ཀྱི་ག་ང་གི །འ་དང་མཐའ་མེད་འི་དང་ཡི། །

“The way of joining: after ན་ མ་ ར་ ལ་, གྱི་; after ད་ བ་ ས་, ཀྱི་; after ག་ ང་, གི་; after འ་ and no suffix (མཐའ་མེད་), འི་ and ཡི་.”

Previous suffixParticleExample
ན་ མ་ ར་ ལ་གྱི་དོན་གྱི་, ཡུམ་གྱི་, གསེར་གྱི་, ཡུལ་གྱི་
ད་ བ་ ས་ཀྱི་བོད་ཀྱི་, ཡབ་ཀྱི་, ཆོས་ཀྱི་
ག་ ང་གི་ཚིག་གི་, མིང་གི་
འ་ or none (མཐའ་མེད་)འི་ or ཡི་ནམ་མཁའི་, བླ་མའི་, ང་ཡི་

The verse itself is full of examples:

  • ཐོན་མིའི་ལེགས་བཤད་སུམ་ཅུ་པའི་ (no suffix)
  • དབྱངས་ཀྱི་བྱ་བ་ (ས་)
  • མིང་གི་ཐོག་མར་ (ང་)
  • ཚིག་གི་ལོ་མས་ (ག་)
  • དོན་གྱི་འབྲས་བུ་ (ན་)

Logic Behind It

In speech the three sound nearly alike, so the spelling has to come from the rule. A way to remember it:

  • ག་ ང་ are made in the same place as ག, so the particle stays plain: གི་.
  • ན་ མ་ ར་ ལ་ are soft (nasals and liquids), so the particle is soft too: གྱི་.
  • ད་ བ་ ས་ are hard stops, so the particle hardens: ཀྱི་.
  • Open syllables just glue the particle on: འི་.

འི་ vs ཡི་

  • འི་ merges into the previous syllable and doesn’t add one: ང་ → ངའི་. If the syllable ends in འ་, that འ carries the vowel: ནམ་མཁའ་ → ནམ་མཁའི་.
  • ཡི་ is written as a syllable of its own: ང་ཡི་.

The meaning is the same. The difference is metrical, as a later verse says:

ར་རུ་འི་ཡི་འང་ཡང་རྣམས། །རྐང་པ་མི་སྐོང་སྐོང་བའི་ཁྱད། །

“ར་/རུ་, འི་/ཡི་, འང་/ཡང་ differ in that [the first] does not fill a syllable of the line, [the second] does.” So in verse ཡི་ is chosen when the line needs one more syllable. In prose འི་ is the norm, though ང་ཡི་ is also heard in colloquial (see Tibetan Postpositions).

Same Rule for the Agentive Particle

དེ་རྣམས་ས་མཐའ་ཅན་ལྔ་ནི། །རྣམ་དབྱེ་གསུམ་པ་བྱེད་སྒྲ་སྟེ། །

“Those five with a ས་ ending are the third case, the agentive particle (བྱེད་སྒྲ་).” So the agentive follows exactly the same distribution, see Tibetan Using Agentive Particle བྱེད་སྒྲ་:

Previous suffixGenitiveAgentiveExample
ན་ མ་ ར་ ལ་གྱི་གྱིས་སློབ་དཔོན་གྱིས་
ད་ བ་ ས་ཀྱི་ཀྱིས་སངས་རྒྱས་ཀྱིས་
ག་ ང་གི་གིས་ཁོང་གིས་
འ་ or none (མཐའ་མེད་)འི་ or ཡི་ས་ or ཡིས་ངས་, བླ་མས་

Colloquial Auxiliary གི་ཡོད་ / གི་འདུག / གི་རེད

The connector of the colloquial imperfective auxiliary is spelled with the same rule, except that after an open syllable it is always གི་ (never འི་):

  • ཟ་གི་ཡོད། (no suffix)
  • ཐུག་གི་འདུག (ག་)
  • བྱེད་ཀྱི་ཡོད། (ད་)
  • ཉན་གྱི་ཡོད། (ན་)

Similar Idea for པ་ / བ་

The nominalizer/possessor particles (བདག་སྒྲ་) པ་ བ་ པོ་ བོ་ also depend on the previous suffix. They are not genitive particles, and the groups are different: hard suffixes take པ་, soft and open ones take བ་. See Tibetan པ་ བ་ at Nouns.

Previous suffixParticleExample
ག་ ད་ ན་ བ་ མ་ ས་ (and da-drag)པ་ / པོ་བྱེད་པ་, བསྟན་པ་, བསམ་པ་
ང་ འ་ ར་ ལ་ or none (མཐའ་མེད་)བ་ / བོ་མཐོང་བ་, གསོལ་བ་, ཟ་བ་

Watch ན་ མ་: with the genitive they go with ར་ ལ་ (གྱི་), but here they go with the hard suffixes (པ་).