Work / World
Smart cities
A city index with a specification, a reference implementation and a stated proof boundary.
The smart cities program is the applied layer of Guiju. It turns the corpus into a city standard: a livability index with fixed weights, integer arithmetic, a Lean specification and a Rust reference. It is not a national policy.
The standard exists because the reporting layer had silently mixed percentile ranks, floating point and changing weights.
The standard
The index has four dimensions over integer basis points:
| Dimension | Weight | Direction |
|---|---|---|
| Air quality | 4,500 | lower raw value is better |
| Human development | 2,500 | higher is better |
| Greenness | 1,500 | higher is better |
| Economic capacity | 1,500 | higher is better |
| Total | 10,000 |
For a finite sample, the percentile score is the count of values at most the raw value, times 10,000, divided by the sample size. Ties use the upper rank. An empty sample returns zero. A lower-is-better dimension uses 10,000 minus the percentile; the composite is the weighted sum divided by 10,000.
With 100 sample values, a raw value at or above 40 of them scores 4,000; the lowest distinct value has a count of one and scores 100, the highest a count of 100 and 10,000. On a lower-is-better dimension the directions reverse: the cleanest air scores 9,900, the dirtiest 0. Weights must sum to 10,000 and every score must be in [0, 10,000]; outside that domain the Rust function returns None and the Lean theorem carries the corresponding hypothesis. Missing dimensions are not part of the formal core; the reporting layer uses complete cases, and renormalisation is a separate extension, not claimed.
What is proved
The Lean file is Livability.lean; the axiom audit is Audit.lean. The theorems use only propext and Quot.sound. standardWeights_valid uses no axioms. No sorry is present.
| Theorem | Statement |
|---|---|
standardWeights_valid | the published weights sum to 10,000 |
percentile_le_max | every percentile score is at most 10,000 |
percentile_mono | a higher raw value cannot lower the percentile |
percentileLower_le_max | a lower-is-better score is at most 10,000 |
percentileLower_mono | lower-is-better reverses the raw-value order |
composite_le_max | valid weights and bounded scores give a bounded composite |
composite_mono | raising any dimension score cannot lower the composite |
The Rust reference implements percentile, percentile_lower and composite. Its contract test has 11 cases covering the standard weights, exact upper-rank ties, bounds, monotonicity, empty samples, floor division, invalid weights and out-of-range scores. ./check.sh runs formatting, the Rust tests, the extraction-package check, the Lean compile and the axiom audit.
The extraction root is prepared but not run: the pinned Aeneas/Charon tools are not installed in the checkout, so the Rust implementation is tested, not proved to refine the Lean specification.
What it does not cover
- The Python data pipeline, the joins and the choice of raw indicators.
- Floating-point arithmetic in any reporting script.
- Missing-dimension renormalisation.
- The amenity-weighted variant, which adds an amenity component outside the formal standard.
- Causal interpretation. This is an index specification, not a model of welfare.
The China proxy
The application scores 207 prefecture cities: air quality the 2020-2024 mean PM2.5 and the share of days with AQI above 100, HDI the GHSL subnational value for 2020, greenness GHSL NDVI for 2025 and economic capacity the latest province GDP per capita. The balanced weights put Meizhou, Maoming, Zhuhai, Putian and Zhoushan at the top. The major-city table for cities above 3 million uses air 35, HDI 30, green 15 and GDP 20; Nanjing, Shantou, Shenzhen, Zhongshan and Chaozhou lead. A 30-city amenity table combines 60 per cent of the major-city score with 40 per cent of an amenity score from museums, hospitals, universities, theatres, parks and metro stations within 10 km. Shanghai, Beijing, Guangzhou, Nanjing and Hangzhou lead.
The proxy is not the Economist Intelligence Unit (EIU) liveability index. It has no safety, housing, healthcare quality, culture or transit data. Air quality is the only city-specific social variable; HDI and greenness come from the assigned GHSL urban centre. 49 GHSL centres are shared by more than one prefecture. Province GDP per capita is not city GDP. Proximity is not access or quality, OpenStreetMap (OSM) is a volunteer map, and a low amenity count can mean missing mapping rather than absence.
Where it sits in the network
The program does not run on Song.
The proxy figures come from the Guiju working tree. Sources: GHSL Urban Centre Database R2024A V1.2 (CC BY 4.0), WHO ambient air-quality data, and OpenStreetMap (ODbL).