Imagine building an assistant for a university library. The assistant needs to know that some books are on loan, that students may borrow a limited number of books, and that overdue items cannot be renewed without a policy exception. Storing these rules as scattered sentences is possible, but checking them reliably becomes difficult. Knowledge representation gives us structured ways to encode facts and relationships so a computer can reason about them.
What is knowledge representation?
Knowledge representation (KR) is the study and practice of encoding information about a domain in forms a computing system can manipulate. Automated reasoning is the process of deriving conclusions from represented knowledge using defined inference methods.
A representation is useful only if it captures the distinctions needed by the task. A map of subway stations, for example, should record connections; it need not record the color of every nearby building.
Facts, relationships, and rules
Consider these statements:
- Amina is a student.
- Every student with an active membership may borrow a reference-free book.
- Amina has an active membership.
- Book B is reference-free.
A reasoning system could use these premises to derive that Amina may borrow Book B. But this conclusion holds only if the rule and premises have been represented correctly and no other restrictions apply.
Predicates and logical statements
A predicate expresses a property or relationship, such as Student(Amina) or Borrowable(BookB). In first-order logic, variables let us state more general rules. Informally:
Read this as: for every x, if x is a student and has active membership, then x is eligible. The notation does not itself specify which book may be borrowed; that requires more rules.
Main representation approaches
| Approach | Basic idea | Typical use |
|---|---|---|
| Propositional logic | Statements that are true or false | Simple rule checking |
| First-order logic | Objects, relations, variables, and quantifiers | Expressive domain rules |
| Production rules | IF condition THEN consequence | Expert systems and policy engines |
| Ontologies | Defined types, properties, and relationships | Shared domain vocabulary |
| Knowledge graphs | Entities and typed links | Connected facts and retrieval |
| Probabilistic models | Represent uncertainty over possible states | Reasoning under uncertainty |
Not all knowledge is naturally Boolean. Real systems may need probabilities, exceptions, time, provenance, and incomplete information.
A small rule-based inference example
The following Python program computes simple conclusions from explicit rules. It is intentionally small and illustrates forward chaining, not a full logical theorem prover.
facts = {"student:amina", "active:amina"}
rules = [
({"student:amina", "active:amina"}, "eligible:amina"),
({"eligible:amina"}, "can_request_loan:amina"),
]
changed = True
while changed:
changed = False
for premises, conclusion in rules:
if premises.issubset(facts) and conclusion not in facts:
facts.add(conclusion)
changed = True
print(sorted(facts))
The program repeatedly looks for rules whose premises are known. Whenever it adds a new fact, another rule may become applicable. This process stops when no new fact can be derived. For many real domains, we would represent variables and types rather than hard-code a person’s name.
Forward chaining and backward chaining
Forward chaining starts with facts, applies rules, and derives further facts. It is useful when many consequences may follow from changing data. Backward chaining starts with a question, such as “Is Amina eligible?”, and searches for the premises needed to establish it. The two methods may reach the same conclusion in a well-defined rule system but differ in their search strategy.
Knowledge graphs and ontologies
A knowledge graph stores entities and relationships. For example, (Amina, enrolled_in, CS101) and (CS101, taught_by, ProfessorK) can support traversals such as “Which instructors teach Amina’s courses?”
An ontology gives a shared meaning to kinds of entities and relations. It might specify that Course is a type of academic offering and that taught_by relates a course to an instructor. Ontologies make it easier to combine information from different systems, provided they agree on definitions.
A graph alone does not guarantee logical correctness. Its relationships still need reliable sources and appropriate rules.
Open-world and closed-world assumptions
Under a closed-world assumption, a missing fact may be treated as false for the purpose of a query. Under an open-world assumption, missing information does not imply falsehood. A library inventory service might reasonably use closed-world behavior for the items currently listed in its database; a public knowledge graph generally cannot conclude that a historical event never happened merely because it has no record.
This distinction is vital for software design because unknown and false are not the same state.
Connection to machine learning
Symbolic systems manipulate explicitly represented relationships; learned systems infer patterns from data. A neuro-symbolic system can combine them. For instance, a document model extracts candidate facts, and a rule engine verifies policy constraints before an automated decision. The learned extraction can still be wrong, so provenance and validation remain important.
Limitations
Writing complete rules is expensive, rules can conflict, and real-world knowledge changes. Logical conclusions depend on the quality and completeness of premises. Some reasoning tasks are computationally difficult even when their statements are short. For these reasons, symbolic reasoning is often combined with databases, search algorithms, and learning-based components.
Related PlainCS articles
- Symbolic AI and Learning-Based AI
- Search, Planning, and Decision-Making
- AI Agents and Tool-Using Workflows
- Information Retrieval and Search
Further reading
Related articles in
- AI Agents and Tool-Using Workflows — Learn agent goals, tool invocation, planning, state, permissions, and how to evaluate multi-step AI workflows.
- AI Development Tools: Git, Jupyter, and APIs — Learn how Git, Jupyter notebooks, Python environments, and APIs fit together in reproducible, secure artificial intelligence workflows.
- How AI Is Changing Theoretical Computer Science — AI is beginning to help researchers explore algorithms, mathematical structures, and formal proofs. Here is what it can do, what still needs human judgment, and why verification matters.