In this case Bob would pay IRS 20% tax for the price appreciation happened when he lived in CA. The 4% tax applies only to the price gain during his stay in Puerto rico.
This is inaccurate. The 4% number is a figure that applies to businesses that are export related and that apply and receive approval for Act 20. It's a 4% tax on the inc's business income and is unrelated to capital gains.