This subject is covered in Mishna and Gemara (an interesting detail, the 3rd Chapter in Gemara is the 4st in the edition of Mishnayot: Chapter Hakore et hamegila omed).
The list of the rules explicitly noted in mishna and gemara, explanation for numbers
- Monday, Thusday, Shabbat (and Yom Kipur) afternoon, (3 = Tora, Neviim, Ketuvim; 3 = Cohen, Levy, Israel, first verse of Bircat Kohanim contains 3 words; 3 Guard gates) --> exactly 3
- Taanit tsibur & 9 beav --> exactly 3
All the cases above not more than 3 to not prevent from working.
- Rosh Chodesh and Chol Hamoed (i. e when they pray Mussaf and there isn't Yom Tov) --> exactly 4
- Yom Tov (due to prohibition to make Melacha --> + 1; second verse of Birkat Kohanim contains 5 words; 5 important ministers) --> at least 5
- Yom Kipur (due to Chiuv Karet --> + 1; 6 mans to the left and right of Ezra) --> at least 6
- Shabbat (due to stoning --> + 1; third verse of Birkat Kohanim contains 7 words; 7 ministers) --> at least 7
The term at least refers to the permission to add aliot: See Gemara Megila 23A:
אמר רבא תנא דבי רבי ישמעאל היא דתנא דבי ר' ישמעאל ביום טוב חמשה ביוה''כ ששה בשבת שבעה אין פוחתין מהן אבל מוסיפין עליהן דברי ר' ישמעאל
and in Soncino's translation:
Raba said: The view is that of a Tanna of the school of R' Ishmael, since in the school of R' Ishmael it was stated: 'On festivals five, on the Day of Atonement six, on Sabbath seven; this number may not be diminished but it may be increased.
See also SA OC 282, 1