District discount mechanics
Districts apart from the Aqueduct, Canal, Dam, Spaceport, and Neighborhood can be discounted 40%, with the exception of the Government Plaza and the Diplomatic Quarter, which have a discount of 25%.
Succinctly, this mechanic can be described by:
If the number of specialty districts completed is greater than or equal to the number researched,
Then if the number of existing copies of a district is less than the ratio of specialty districts placed to specialty districts researched,
Then the 40% discount applies.
In more detail, for a cost discount to apply you have to satisfy two conditions:
1. Necessary condition: You have to complete as many specialty districts as you have researched.
Let's call the number of specialty districts you have researched (or unlocked) A, and the number of specialty districts you have finished B1 , then B1 has to be greater than or equal to A.
For example: You have unlocked the ability to build the Government Plaza, the Holy Site and the Campus (A = 3), and you have built 2 Campuses (B1 = 2). In this case, you have not satisfied the necessary condition for the discount, and thus it will not apply for any specialty district you are about to build until you finish the third specialty district. Remember, B1 only counts finished specialty districts, so just putting down a base without completing it will not count.
This is the necessary condition, meaning it has to be in place for the other (second) condition to be considered, but it will not guarantee an occurrence.
2. Sufficient condition: You will only get the discount on a certain type of district if the number of copies of that district in your empire is lower than the number of constructed districts versus unlocked districts ratio.
Don't worry if that sounds complicated at first. Let's still call the number of districts you have researched (or unlocked) A, the number of districts you have constructed (not completed, but constructed, meaning just putting down a district without finishing does count in this case) B2 , and the number of copies any particular district in question C. In order to know if a particular type of districts receives the discount or not, just compare the number of copies of that district, C, to the B2/A ratio, if the number of copies is lower than the ratio, then the answer is yes, the discount will apply.
For example: You have unlocked the Campus, Government Plaza, Holy Site and Commercial Hub (A = 4). You have constructed 2 Holy Sites, 2 Campuses and the Government Plaza (B2 = 5). (Just a quick reminder of our previous condition: if among these 5 constructed districts, fewer than 4 are completed, the necessary condition is not satisfied, and thus the sufficient condition will not be considered.) The B2/A ratio is 1.25. The current number of Commercial Hubs you have is C = 0, which is smaller than 1.25; therefore, when you build a Commercial Hub in any city, you will receive a 40% discount. After putting down the first Commercial Hub ("constructing"), the value of Commercial Hub will rise to 1, which is still smaller than 1.5 (now A = 4, but B2 = 6) meaning you can concurrently put down another Commercial Hub in another city (without having to wait for the first one to finish), and still get the discount. You will not get the discount when putting down the third Commercial Hub, however, as 2 is larger than 1.75 (A = 4, B2 = 7).
This is the sufficient condition, meaning it has to be satisfied in order to guarantee the desired occurrence.
Combining these two conditions using these terms, where:
A = Number of specialty districts researched (unlocked)
B1 = Number of specialty districts completed
B2 = Number of specialty districts placed (at least started)
C = Copies of a particular district
If B1 ≥ A, Then if C < B2/A , the discount applies.
Please note that in both conditions, the mathematical values of A, B1 , and B2 will only be updated when a technology or a civic is completed. Also, once you place a district, the cost of that district is locked in whether or not you complete that district right away, meaning the cost will not scale up with the technology and civic progression, and will not change in your favor or against you if you later satisfy or no longer uphold the discount conditions.