AI Notes
Learn frames for AI. Slots, defaults, inheritance. AI 2024.
What Are Frames?
Frames are a knowledge representation scheme introduced by Marvin Minsky in 1975 that organizes information about stereotypical situations or objects into structured data packets. A frame represents a concept through a collection of slots (attributes) and their values, along with default values, constraints, and procedures that execute when slots are accessed or modified.
Think of a frame as a structured template for knowledge—similar to a class in object-oriented programming but designed for AI reasoning. When you hear "restaurant," your mind activates a mental frame with slots for tables, menu, waiter, food, bill. Frames formalize this cognitive structure computationally.
Frame Structure
Anatomy of a Frame
| Frame | <concept_name> |
| Slot | <attribute_name> |
| Value | <current_value> |
| Default | <assumed_value_if_unknown> |
| Type | <data_type_constraint> |
| Range | <allowed_values> |
| If-needed | <procedure_to_compute_value> |
| If-added | <procedure_when_value_set> |
| If-removed | <procedure_when_value_deleted> |
Example: University Frame System
| Frame | UNIVERSITY |
| is-a | Educational_Institution |
| name | [Value: nil, Type: string] |
| location | [Value: nil, Type: City] |
| founded | [Value: nil, Type: year, Range: 1000-2024] |
| students | [Value: nil, Type: integer, If-needed: query_database()] |
| departments | [Value: nil, Type: list_of(Department)] |
| ranking | [Value: nil, Default: "unranked"] |
| Frame | MIT |
| instance-of | UNIVERSITY |
| name | [Value: "Massachusetts Institute of Technology"] |
| location | [Value: Cambridge_MA] |
| founded | [Value: 1861] |
| students | [Value: 11,934] |
| departments | [Value: [EECS, MechE, Physics, ...]] |
| ranking | [Value: 1] |
Inheritance in Frame Systems
Frames support inheritance hierarchies where child frames inherit slots from parents:
| Frame | VEHICLE |
| has-wheels | [Default: 4] |
| has-engine | [Default: yes] |
| can-move | [Value: yes] |
| Frame | CAR |
| is-a | VEHICLE |
| doors | [Default: 4] |
| passengers | [Range: 1-7] |
| Frame | SPORTS_CAR |
| is-a | CAR |
| doors | [Default: 2] ← overrides CAR's default |
| top-speed | [Range: 150-250] |
| passengers | [Default: 2] |
| Frame | my_ferrari |
| instance-of | SPORTS_CAR |
| color | [Value: red] |
| top-speed | [Value: 211] |
| Inherited | has-wheels=4, has-engine=yes, doors=2 |
Inheritance with Exceptions
| Frame | BIRD |
| can-fly | [Default: yes] |
| has-wings | [Value: yes] |
| has-feathers | [Value: yes] |
| Frame | PENGUIN |
| is-a | BIRD |
| can-fly | [Value: no] ← exception to default |
| can-swim | [Value: yes] |
| habitat | [Default: "antarctica"] |
| Query | Can a penguin fly? |
| 1. Check PENGUIN frame | can-fly = no (explicit value) |
Procedural Attachments (Demons)
Frames can have procedures that trigger automatically:
| Frame | BANK_ACCOUNT |
| balance | [Value: 1000, |
| If-added | log_transaction(), |
| If-needed | fetch_from_database()] |
| overdraft-limit | [Value: -500] |
| status | [If-needed: compute_status()] |
| Demon | compute_status() |
| IF balance > 0 | return "active" |
| IF balance > overdraft-limit | return "overdrawn" |
| ELSE | return "frozen" |
Frame-Based Reasoning Example
Scenario: Restaurant Frame Activation
| Frame | RESTAURANT_VISIT |
| actors | [customer, waiter, chef] |
| entry-action | [Default: "seated by host"] |
| ordering | [Default: "choose from menu"] |
| eating | [follows: ordering] |
| paying | [follows: eating, method: Default="card"] |
| tip | [Default: 15-20%, If-needed: calculate_from_service()] |
| Situation | "John went to McDonald's" |
| Activate | FAST_FOOD_RESTAURANT (is-a: RESTAURANT_VISIT) |
| Override | entry-action = "order at counter" |
| Override | waiter = none |
| Override | paying = "pay before eating" |
| Override | tip = 0 |
Frames vs. Other Representations
| Feature | Frames | Semantic Nets | Logic | OOP |
|---|---|---|---|---|
| Structure | Slots+facets | Nodes+edges | Predicates | Attributes |
| Inheritance | Yes | Yes | Derived | Yes |
| Defaults | Yes | No | Complex | No (null) |
| Procedures | Demons | No | No | Methods |
| Reasoning | Slot matching | Traversal | Inference | None built-in |
Applications
Natural Language Understanding
Frames represent script-like scenarios
"John ordered pizza" → activate RESTAURANT frame
Fill slots: customer=John, food=pizza
Computer Vision
Object recognition via frame matching
Detected features fill slots → identify object
Planning
Action frames with preconditions and effects
Chain frames to build plans
Diagnosis
Device frames with normal-state slots
Compare observed values to expected defaults
Interview Questions
Q: How do frames relate to object-oriented programming? A: Frames preceded OOP and inspired many OOP concepts. Both use inheritance, encapsulation (slots), and associated procedures (methods/demons). Key difference: frames include defaults, if-needed procedures, and are designed for AI reasoning (matching, inheritance-based inference), while OOP classes focus on software engineering (encapsulation, polymorphism, modularity).
Q: What is the frame problem in AI? A: Confusingly, this isn't about frames the data structure. The "frame problem" asks: when an action occurs, what does NOT change? If a robot paints a wall, the wall's color changes—but the wall's weight, the room's size, and millions of other facts remain unchanged. Representing what stays constant is computationally expensive.
Q: What are the advantages of default values in frames? A: Defaults enable reasoning with incomplete information. Without defaults, missing values halt reasoning. With defaults, the system makes reasonable assumptions ("birds can fly") that can be overridden when specific information arrives ("this bird is a penguin, so it can't fly"). This models human commonsense reasoning effectively.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Frames - Structured Knowledge Objects.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Artificial Intelligence topic.
Search Terms
artificial-intelligence, artificial intelligence, artificial, intelligence, knowledge, representation, frames, frames - structured knowledge objects
Related Artificial Intelligence Topics