VOWS TO FAST [Nedarim: fasting]
Gemara
102b (Mishnah): If one said 'Alai to bring (a Minchah of) two Esronim in one Kli' and he brought them in two Kelim, or vice-versa, it is Kosher, but he was not Yotzei.
(Beraisa - R. Shimon): He was not Yotzei;
107b (Mishnah): If one vowed to offer a bull worth 100 Zuz and he brought two bulls worth 100 together, he was not Yotzei;
Even if each is worth almost 100, he was not Yotzei.
Ta'anis 12b (Rav): One may borrow a fast and repay it.
Version #1 - Shmuel: He did not accept a vow, that he must pay it in any case! He merely accepted to pain himself, if he can. If he cannot, he cannot!
Version #2 - Shmuel: This is obvious! It is no more than a vow. If one cannot pay a vow now, he pays it later, when he can!
Rav Yehoshua brei d'Rav Idi visited Rav Asi's house. They prepared a third-born (choice) calf for him, and offered him to eat. When he said that he is fasting, they suggested that he borrow and repay, like Rav taught.
Rav Yehoshua: I am in a Ta'anis Chalom;
(Rabah bar Machsiya): A fast is good for (terminating a decree that caused) a (bad) dream like fire is for stubble.
(Rav Chisda): The fast must be that day.
Rishonim
Rambam (Hilchos Ta'anis 1:14): If one forgot that he is fasting and he ate, he completes his fast.
Ra'avad: The Yerushalmi says that this is when he vowed 'this day.' If he vowed Stam 'a day' he lost his fast.
Rambam (Hilchos Nedarim 4:16): If one vowed to fast 10 days, whichever days he wants, and he was fasting one day and he needed (to eat) for a Mitzvah, or to honor a great person, he eats and pays (fasts) another day, since he did not fix the days when he vowed. If he vowed to fast today, and he forgot and ate, he completes his fast. If he vowed to fast a day or two, and after beginning to fast he forgot and ate, he lost his fast and he must fast another day.
Rosh (Ta'anis 1:16, citing R. Chananel): The Heter to borrow a fast and repay is when there is pain of Ones. We learn from Shmuel, who says that he accepted pain, if he can pain himself. My Rebbeyim would get three men to permit a vow to fast. Since he said 'I am in a fast', this is like a vow. It seems that since he must pay, the vow was not Batel. Rather, we estimate that he intended to fast one day, but not to fix this day for an obligation. The Yerushalmi proves this. It derives that one may fast for hours, for Rav taught that one may borrow a fast and pay it. The Bavli says that a fast that is not until night is not a fast. We must say that it is called a fast in this respect, that he need not permit his vow; fasting part of the day is called a fast. The Yerushalmi connotes that this is if he said Stam '(I will fast a) day', but not if he said '(I will fast) this day.' It seems that one who forgot and ate lost his fast, i.e. if he said Stam, but if he said 'this day', he completes the fast. When he said Stam, he lost his fast because he can borrow and pay another day. One cannot borrow and pay if he said 'this day', therefore, he completes the fast even if he ate a k'Zayis. The Bavli disagree, for Shmuel said that it is not a vow that he must finish the fast. He merely accepted to pain himself. We understand this if he said 'this day.' Therefore, he need not repay it. If he said 'a day', if he cannot fast now, why shouldn't he repay it when he is healthy and he can fast?!
Rosh (ibid.): The Ra'avad said that acceptance to fast is only like a vow, i.e. of Tzedakah. Before Tzedakah comes to the Gabai, the donor may borrow and repay (Erchin 6a). Accepting a fast is like Tzedakah, as if he offered his fat and blood to Hash-m, and in place of them he gives to the poor. We estimate that he accepted on condition that he may borrow and repay. What is the Ra'avad's intent 'in place of them he gives to the poor'? He must repay the fast! Perhaps he means that it depends on him, and he may opt to give to the poor and not fast, or repay the fast. I disagree. We say that fasting is greater than Tzedakah, for it is with his body, and Tzedakah is with his money! Therefore, paying with Tzedakah is not proper payment.
Hagahos Ashri: Or Zaru'a says that one may borrow and repay not only if the fast is difficult or he was invited to a Seudas Mitzvah. It is even if he was invited to eat with friends, for Darchei Shalom.
Ran (Ta'anis 4a DH Loveh): Accepting a fast is not a full vow. If it were, surely one could not borrow and repay! If one forbade to himself meat on a certain day, surely he may not change the day! This is why in Version #1, Shmuel held that his acceptance is only if he is able to pain himself. If not, he need not repay. In Version #2, he says that it is no more than a vow. This does not refer to Konam (forbidding something to himself like Hekdesh), for surely one may not borrow and repay Konam! Rather, it refers to a vow of Tzedakah. Before the Gabai receives it, one may change it, i.e. borrow and repay.
Ran (DH v'Yesh): Some say that we say that one may borrow and repay when one accepted a number of fasts without specifying which days, and afterwards he decided to fast on a particular day to fulfill one of them. His initial vow did not obligate him to fast that day, so when he borrows, his initial vow will still be fulfilled. However, if he initially accepted to fast on a certain day, he may not borrow and repay. They support this from the Yerushalmi. When he said Stam, he lost his fast because he can borrow and pay another day. If so, we must say that those who suggested to Rav Yehoshua brei d'Rav Idi that he borrow and repay were not concerned that he had vowed 'this day.' They were striving to get him to eat. It is as if they suggested 'perhaps you did not vow this day.' Others say that one may borrow and repay even a fast of this day; it is like a vow of Tzedakah. The Ra'avad and Rashba hold like this. The Yerushalmi is inconclusive.
Terumas ha'Deshen (Pesakim 61): Two consecutive days and nights are like 40 days (of fasting).
Poskim
Shulchan Aruch (OC 568:1): If one vowed to fast today, and he forgot and ate, he completes his fast. The same applies to a Ta'anis Chalom or a Ta'anis Tzibur.
Gra (DH Nadar): One may not borrow and repay a Ta'anis Chalom, for it is only on that day. The same applies to a Ta'anis Tzibur. This is why the Gemara said that one may borrow his fast.
Mishnah Berurah (3): It seems that on a Ta'anis Tzibur, even if one ate he may say Tefilas 'Aneinu'. 'Yom Tzom ha'Ta'anis ha'Zeh' applies, for Chachamim enacted to fast. If one ate on his own fast day a Shi'ur (that would nullify the fast had he not said 'this day'), even though he must complete the fast, he may not say Aneinu.
Kaf ha'Chayim (8): A Shali'ach Tzibur may say Aneinu even if he is not fasting, since Chachamim enacted to fast.
Shulchan Aruch (4): Some say that fasting two consecutive days and nights is considered like 40 fasts that are not consecutive.
Kaf ha'Chayim (61,62): Some bring that fasting six straight days equals 65,600 fasts. R. Shlomo Luria says that one may not rely on Sifrei ha'Mekubalim except for the Ari Zal and his Talmid R. Chaim Vital. Tosefes Ma'aseh Rav (39, in Sidur ha'Gra p.520) says that once the Gra's wife accepted on herself to fast from Motzei Shabbos until Shabbos. When the Gra found out, he told her that all such fasts cannot rectify missing one Melavah Malkah. She ate immediately. However, if one cannot eat anything on Motzei Shabbos, even cake, due to eating on Shabbos, he may accept a fast on Shabbos and stop eating before sundown.
Rema: Some say that this is for a weak person, but a healthy person must fast three consecutive days to count like 40 fasts.
Kaf ha'Chayim (64): Hilchos Ketanos (2:252) says that one should be concerned for danger (if he fasts too many days consecutively). Perhaps an organ will deteriorate from lack of nutrients. Even if the person does not die within the year, perhaps the organ already started to deteriorate. A weak person should fast only separate fasts according to his ability, and redeem the rest through money.
Rema (ibid.): It seems that this refers to one who must fast 40 days that are not consecutive, due to Teshuvah, to pain himself. Then, we equate one pain against another. However, if one vowed to fast 40 days, he must fulfill his vow. This is not less than one who vowed to fast this day; he may not borrow and repay.
Magen Avraham (15): It is better to fast separate fasts in order that at all times his heart will be humbled and his sin will be in front of him.
Rema: (ibid.): Even according to the opinion that he may borrow and repay, here he agrees that he must fulfill his vow. All the more so, those who fast 40 days before Yom Kipur to commemorate Moshe going up on Har Sinai cannot fulfill this through two or three consecutive days.
Gra (DH Hacha): This is like we say in Menachos 107, that if one vowed to bring a bull for a Maneh and he brought two bulls for a Maneh, he was not Yotzei, even if each is worth almost a Maneh.
Dameshek Eliezer: This is because one must fulfill his vow exactly the way he said it.
Eshel Avraham (14, cited in Mishnah Berurah 32): If one vowed to fast two consecutive days and nights, can he change this to fast 40 non-consecutive days? Perhaps this depends on whether one who vowed to bring a large Minchah may bring two small Menachos.
Note: It seems that the Mishnah of two bulls proves that smaller fasts, even if in all they are for a longer time, do not fulfill a vow for a long fast.
Magen Avraham (16): The opinion that permits to borrow and repay holds that he did not accept in order that he will be pained. Here, in any case he will need to fulfill what he accepted.
Kaf ha'Chayim (68): Mateh Efrayim (581:2) says that it depends on the intent of the one who vowed.