# Individualistic Economics Formalism
[](https://hackmd.io/yDlYsfMeRy-z7TfqqveC1Q)
> "The only real power comes out of a long rifle." -- Joseph Stalin
Let's take some notes.
1. Initial conditions: Population, resources.
2. Evolutionary traits: Population, resources, trade, demand and supply, currency.
---
### **Local**
Data structures:
```julia=
abstract type AbstractGovernment end
struct Resource <: AbstractGovernment
name :: String
end
abstract type Entity <: AbstractGovernment end
struct Person <: Entity
resources :: Dict{Resource, Real} # resource => amount?
bundles :: Real # Money?
end
struct Contract <: Entity
parties :: Array{Person}
resources :: Dict{Resource, Real}
# This addresses shared ownership (resource => ownership?)
bundles :: Real
end
```
How to query ownership?
```julia=
function ownership(bank :: Contract, money :: Resource, johnny :: Person)
if johnny in bank.parties
if money in bank.resources
bank.resources(money) # bundles saved, but how?
else
println("$(johnny) doesn't own this resource.")
else
println("$(johnny) isn't in this contract.")
end
end
# Constraint on ownership
# sum(ownership.(drugs, characters)) == 1
```
---
## Demand-Supply Economics
In the following, the first person is the client, and the second person is the vendor.
$$Demand :: Resource \times Person \times Person \to \mathbb R$$
```julia=
function demand(dress :: Resource, lisa :: Person, johnny :: Person)
???
Profit.
end
```
$$Supply :: Resource \times Person \times Person \to \mathbb R$$
```julia=
function supply(drugs :: Resource, chris_r :: Person, denny :: Person)
???
Jail.
end
```
$$Price :: Resource \times Person \times Person \to \mathbb R$$
```julia=
function price(drugs :: Resource, chris_r :: Person, denny :: Person)
dem = demand(drugs, chris_r, denny)
sup = supply(drugs, chris_r, denny)
func(dem, sup)
end
func(demand, supply) = ...
```
Data analytics:
```julia=
Datum = (Demand, Supply, Price)
data :: [Datum]
```
Cases: $(+/-, +/-, +/-)$
_e.g._
Trash ≈ (-, -, +)\
Vendor-Vendor
Consider `r :: Resource, p1 :: Person, p2 :: Person`, where `p1` is a client and `p2` is a vendor.
```haskell=
datum res p1 p2 = ( demand res p1 p2,
supply res p1 p2,
price res p1 p2 )
```
```julia=
datum(r, p1, p2) == (+dem, +sup, +prc)
# ⇒ p1 wants to buy r and pay for what p2 is selling.
datum(r, p1, p2) == (-dem, -sup, -prc)
# ⇒ p2 wants to buy r and pay for what p1 is selling.
```
```julia=
datum(r, p1, p2) == (-dem, +sup, 0) | (+dem, -sup, 0)
# ⇒ either both want to sell or both want to buy
```
```julia=
datum(r, p1, p2) == (-dem, -sup, +prc)
# ⇒ p1 wants to get rid of r and p2 is willing to take it,
# for a positive price (to be paid by p1)
datum(r, p1, p2) == (+dem, +sup, -prc)
# ⇒ p1 wants to buy r, which p2 is supplying, but expects p2 to pay.
```
```julia=
# Skew-symmetry
datum(r, p1, p2) == ( dem, sup, prc) ⇔
datum(r, p2, p1) == (-dem, -sup, -prc)
```
Seems like $\mathbb Z_2^3 / \mathbb Z$.
---
### **Global**
$$Demand :: Resource \to \mathbb R$$
```julia=
function macro_demand(dress :: Resource)
¿ sum(demand(dress, lisa, johnny)
for lisa in population, johnny in population) ?
end
```
$$Supply :: Resource \to \mathbb R$$
```julia=
function macro_supply(drugs :: Resource)
¿ sum(supply(drugs, chris_r, denny)
for chris_r in population, denny in population) ?
end
```
$$Price :: Resource \to \mathbb R?$$
Consider $Price :: Resource \times [Person] \to \mathbb R$?
```julia=
persons :: [Person]
persons = ???
function macro_price(football)
couples = product(persons, persons)
end
```
```haskell=
price r persons = sum [p * min d s | (d, s, p) <- date] /
sum [min d s | (d, s, _) <- date]
where
allpairs = distinctPairs persons
date = filter (\(_, _, p) -> p > 0) $ [ datum r p1 p2 | (p1, p2) <- allpairs ]
```