Sub topic 4
Mapping Entities and Relations Between Domains
This chapter assumes you can already tell a source domain from a target problem, and that you know surface similarity from structural similarity. Those ideas come from the earlier chapters. You also need basic Python reading ability for the code examples. Here you will learn how to build an explicit mapping between two domains. You will also learn how to check that the mapping is sound before you trust it.
What a mapping is
A mapping is a set of pairings. Each pairing links one thing in the source domain to one thing in the target problem. Pairing things is only half the job, because the pairings must also preserve how the things relate to each other.
Take the classic comparison of the solar system and the atom. Pairing "sun" with "nucleus" is a claim about roles. The sun is the heavy center that other bodies circle, and the nucleus plays that part in the atom. The mapping is useful only because the sun and the planet are connected by relations, and those relations carry over to the nucleus and the electron.
Structure mapping is the name for this view of analogy. The analogy is not "the sun is like the nucleus." It is "the pattern of relations among the sun and planets matches the pattern among the nucleus and electrons."
The parts of a mapping
Every domain description contains three kinds of content. Keep them apart, because they behave differently under a mapping.
| Kind | What it is | Example (solar system) | Usually maps? |
|---|---|---|---|
| Entity | A thing or role in the domain | sun, planet | Yes, these are the pairings |
| Attribute | A property of one entity | the sun is yellow, hot, and 4.6 billion years old | Rarely |
| Relation | A link between two or more entities | the sun attracts the planet; the planet orbits the sun | Yes, this is what carries the value |
A good rule is that attributes describe a single entity and relations connect entities. Surface similarity is mostly attribute matching: both things are round, both are small, both are red. Structural similarity is relation matching. If you notice that you are justifying a mapping with attributes, stop and look for relations.
Three rules for a sound mapping
Researchers who study analogy describe a few constraints that separate a strong mapping from a loose one.
- One-to-one. Each source entity pairs with at most one target entity, and the reverse is also true. If "planet" maps to both "electron" and "proton," you cannot tell which one inherits the planet's relations.
- Parallel connectivity. If a relation is mapped, its arguments must be mapped too. When "attracts(sun, planet)" becomes "attracts(nucleus, electron)", the mapping must already contain sun→nucleus and planet→electron. A relation whose arguments are paired inconsistently is broken.
- Systematicity. Prefer mappings that preserve a connected system of relations over mappings that preserve many isolated facts. "The sun attracts the planet, and that attraction is why the planet orbits" is one linked system. It is worth more than five unrelated matching facts.
The third rule explains why a mapping built around one deep causal chain beats a mapping that matches a long list of coincidences.
A mapping in code
The code below represents relations as tuples, the mapping as a dictionary, and the transfer step as a rewrite. This version adds the two checks that the rules above require: a one-to-one test and a test that every entity used by a relation has a pairing.
# Source domain: planets orbiting a sun (relations among entities)
source_relations = [
("attracts", "sun", "planet"),
("more_massive_than", "sun", "planet"),
("orbits", "planet", "sun"),
]
# Mapping between entities of the source and the target (the atom)
mapping = {"sun": "nucleus", "planet": "electron"}
def is_one_to_one(entity_map):
"""True if no two source entities share a target entity."""
targets = list(entity_map.values())
return len(targets) == len(set(targets))
def unmapped_entities(relations, entity_map):
"""Entities used by relations that have no pairing yet."""
used = {entity for _, a, b in relations for entity in (a, b)}
return used - entity_map.keys()
def transfer(relations, entity_map):
"""Rewrite each source relation in terms of target entities."""
if not is_one_to_one(entity_map):
raise ValueError("mapping is not one-to-one")
missing = unmapped_entities(relations, entity_map)
if missing:
raise ValueError(f"no pairing for: {sorted(missing)}")
return [(rel, entity_map[a], entity_map[b]) for rel, a, b in relations]
for rel in transfer(source_relations, mapping):
print(rel)
# ('attracts', 'nucleus', 'electron')
# ('more_massive_than', 'nucleus', 'electron')
# ('orbits', 'electron', 'nucleus')The output is a list of candidate claims about the atom. They are not facts. The program has no way to know whether electrons really orbit a nucleus in a path like a planet's. It only rewrites the vocabulary. Checking the claims is a separate job, covered in the chapter on testing where an analogy holds and breaks.
The error checks matter in practice. If you add a third entity such as ("heated_by", "planet", "sun") and forget to pair a new entity, transfer stops with a clear message instead of silently producing a wrong claim.
Seeing the mapping
The diagram shows the same mapping as two columns joined by dashed pairing links. The relations are drawn inside each domain, so you can see that the shape on the left reappears on the right.
Building a mapping step by step
Use this procedure whenever you have a candidate source domain and a target problem.
- List the source relations. Write each as a short phrase with named participants: "the thermostat compares temperature to a setpoint." Aim for relations, not descriptions.
- List the target facts the same way. Use the same style, so the two lists can be compared line by line.
- Pair entities by role. Ask what job each entity does in its domain. Pair the ones with matching jobs, not matching appearance.
- Check each pairing against the rules. Is it one-to-one? Do relations keep their arguments?
- Mark what is left over. Source relations with no target counterpart are either candidate ideas to transfer or places where the analogy fails. Target facts with no source counterpart are things the analogy cannot explain.
- Keep the mapping small and connected. Drop pairings that rest only on attributes.
Step 5 is where most of the value appears. A source relation with no target counterpart is a question: does the target have this, and have we missed it?
An example with a failed pairing
Suppose you manage a busy support queue and want to borrow from a highway system. You pair "cars" with "tickets," "lanes" with "agents," and "congestion" with "backlog." Most pairings work. Then you notice that cars travel through lanes without changing, while a ticket is worked on and transformed, and may be split into new tickets.
That difference breaks one relation. The highway relation "a car occupies a lane for the same length of time as any other car" does not hold for tickets, because tickets differ in effort. The mapping is still useful for queue length and throughput, but it must not be extended to predict how long each ticket takes. The mapping tells you which of the highway's relations to trust and which to discard.
Common errors when mapping
- Pairing by attribute. Matching the sun and the nucleus because both are "central and bright" is weak. Matching them because both hold the other entity in orbit by attraction is strong.
- Many-to-one pairings. Two source entities collapsed into one target entity make the relations ambiguous. Split the target entity or drop one pairing.
- Mapping only entities. A list of paired nouns without relations is a vocabulary table, not an analogy.
- Treating the mapping as evidence. A clean mapping shows that the two domains can be aligned. It does not show that the carried-over claims are true.
- Keeping every source relation. Some relations belong to the source's physics or history and have no meaning in the target. Drop them on purpose.
Exercise
A team compares a software release process to a relay race. They pair "runner" with "developer," "baton" with "code change," and "next runner" with "reviewer." They also pair "stadium crowd" with "customers" because both "watch the result." Which pairings rest on relations, which rest on attributes or weak grounds, and what source relation might the team try to carry over?
Show answer
The runner, baton, and next-runner pairings rest on relations: the runner hands the baton to the next runner, and the developer hands the change to the reviewer. The role of "passes responsibility forward" is preserved. The crowd-to-customers pairing rests on the shared attribute of "watching," not on a matching relation, since customers use the product and affect later work while a crowd does not influence the race. The team should treat that pairing as weak and probably drop it. A relation worth carrying over is "a dropped baton loses the race at the handoff." It suggests that the handoff between developer and reviewer is where failures concentrate, so it is a good place to add checks. The team should still test whether handoffs are the real failure point in their own data.