Joyous Brands

Artificial Intelligence: A Visual Learner's Series

Part 3: Logic and planning

Instead of treating situations as black boxes, describe what they're made of and the rules they follow, then let the computer reason.

Filling in blanks without breaking rules

In one line: Many puzzles and schedules mean assigning values so no rule is broken, and you can rule out bad options early.

Three colors are enough when neighbors must differEach circle is a county (variable); each line joins neighbors (a constraint); fill shows the color chosenNorthSouthWestEastCentralCentral touches all four,so it gets its own color
  • Variables are the circles, domains are the colors allowed, constraints are the lines.

  • Backtracking: assign one at a time and back up when a rule breaks.

  • Forward checking: once Central is colored, cross that color off all four neighbors immediately.

  • Color the most constrained variable first: Central, which touches everything.

Watch out: The order you assign variables in can turn seconds into hours.

Logic: facts and what follows

In one line: Logic is a precise language for true-or-false facts and the rules for what must follow from them.

ClueSymbol form
If the butler did it, there'd be mudB ⇒ M
There's no mud¬M
The butler or the gardener did itB ∨ G
Conclusion: the gardener did itG
  • A model is one possible world (a true/false value for every symbol).

  • The clues entail G: in every world where all clues are true, G is true too.

Watch out: "If A then B" is automatically true whenever A is false, which surprises most people.

Deriving new facts

In one line: Instead of checking every possible world, chain rules step by step, or ask whether any world fits all the rules.

  Rain  ──▶  Game canceled  ──▶  Practice moves indoors
  fact       rule 1                rule 2        (modus ponens, twice)
  • Sound: derives only true conclusions. Complete: can derive all of them.

  • SAT solvers ask "can all these rules be true at once?" and handle millions of variables in chip design and scheduling.

Talking about objects and relationships

In one line: First-order logic lets one rule cover every object, instead of a separate fact for each.

Tell it Parent(Maria, Leo) and it concludes Older(Maria, Leo) on its own.

Key terms: quantifiers (∀ for all, ∃ there exists), unification, forward and backward chaining.

Watch out: "Everyone loves someone" and "someone is loved by everyone" differ only in quantifier order, and mean very different things.

Planning a sequence of actions

In one line: Describe each action by what must be true before it and what it changes, then find a sequence that reaches the goal.

Each step needs its preconditions done firstThe coffee and toast lanes don't depend on each other, so they can run in parallelPlug in grinderFill kettleGrind beansHeat waterBread in toasterBrew coffeeToast breadBreakfast served
  • Each box is an action; each arrow is a precondition. An action's effects make the next action's preconditions true.

  • Backward planning starts from the goal and asks what each step needs.

  • Partial-order planning fixes only the orderings that matter, as with the two parallel lanes.

Watch out: Real actions fail and facts change, so real systems replan as they go.

Self-test

  1. Draw a constraint graph for scheduling four meetings where some share attendees.

  2. Translate a three-clue mystery of your own into symbols and derive the answer.

  3. Draw a precondition diagram for getting ready for work, and mark the steps that can run in parallel.