Legal obligations are worth the paper they're written on, when it comes to war between two major world powers. Any decision to retaliate would end up being based on what's best geopolitically for the USA.
Giving up Taiwan, of course, would announce to the world that allies of the US should look for other world power sponsors, because our support is paper thin.
That kind of choice is very costly, and it would take a very unique type of President willing to piss away a century of alliance building.