First and foremost there are laws in Massachusetts that govern leasing (and subleasing - this is only a sub-category of leasing after all) of real property. I do not know what they say and I am not going to bother finding out; you should. Start here.
Typically, real property transactions are one of the most highly regulated areas in any jurisdiction. In general, they will read terms into any contract, prohibit other terms and may specify the form of the contract - it may be that the contract must contain certain clauses or it is unenforceable.
Notwithstanding, if the contract is enforceable and if the only terms are the ones you have given (both questionable predicates):
- Bob can physically leave anytime he wants to - a subtenant is not an inmate of a prison. Bob will have access to the property until 15 August and must pay the rent up until that date. Alice must allow Bob "quiet enjoyment" of the property until that time.
- Bob can ask Alice to vary the terms of the contract in any way he likes; including reducing (or extending) the term with or without notice periods. If Alice agrees then the contract is varied and the new terms replace the old.
Having said that, civil law only matters when there is a dispute; if Bob and Alice (and Ted and Carol) are (reasonably) happy with their arrangement it does not matter that it may be legally unenforceable. Courts and judges do not wander around town sticking their nose into every arrangement to make sure it is in full compliance with the law (largely because of the risk of bodily harm that would result :)); they only interfere when one of the parties asks them to.