Program-Based Analysis For Quantitative Properties