OrderPayShip (the “workhorse“) showed one way to use commitments. In today’s example, I’m going to show a different commitment pattern, which more directly models a legal contract.
Let’s assume Bob sells cars and Alice wants to buy one. Expensive items like this (much more expensive than a pizza) often involve an explicit legal contract. In this case, Alice and Bob want binding signatures on a legal contract. We still need two commitments: one from Alice to Bob and one from Bob to Alice. The trick is to make both commitments become active exactly when BOTH Alice and Bob have signed the contract. We can model this legal contract as
C(Alice, Bob, AliceSigns and BobSigns, AlicePays)
C(Bob, Alice, AliceSigns and BobSigns, BobGivesKey)
Both commitments SIMULTANEOUSLY become unconditional only after both Alice and Bob sign the contract. Then both parties have to satisfy their individual commitments.
The Workhorse pattern involved only two agent actions: pay and ship. What happens when each agent must perform lots of actions? The legal contract pattern enables you to collect all of a single agent’s commitments to others into a single commitment. So a more complex example, where Bob provides continuing service to keep Alice’s car running, might look like this
C(Alice, Bob, AliceSigns and BobSigns, AlicePays and AliceBuysGas and AliceMaintains)
C(Bob, Alice, AliceSigns and BobSigns, BobGivesKey and BobServices and BobRepairs)
The difference between Workhorse and Legal Contract is more style than substance. This means you can approach problems from multiple directions.