What is Logical Representation in AI?

Logical representation provides machines with the capacity for representing their world and for logical reasoning

True or false
Understand categories and variables
∀x

You don’t always get what you want

Intelligent AI agents can perceive their environment and take actions autonomously to achieve their goals, but they require world knowledge to make good decisions.

A **‘knowledge base’** is a set of sentences expressed in a ‘knowledge representation language’ that tells the AI about its world. Knowledge-based agents use a process of drawing inferences (reasoning) over their internal representation of knowledge to decide which actions to take.

Take shopping as an example. An online retailer typically tracks what you put in your basket, even if you later take it out, along with your address, the time of day, and your payment method. The agent uses this highly personal data to constantly refine its performance, offering you new items to see what you will do.

You may have started out looking for a kettle but left with a nasal hair trimmer.

Knowledge representation languages

**Knowledge representation languages** capture assertions about the world in a form that allows AIs to reason in order to complete complex tasks and solve problems. They are defined by their syntax, specifying the structure of the sentences, and their semantics, expressing the sentence truth in the world. These languages also allow for ‘entailment’ – the idea that one sentence logically follows from another.

**For an AI agent to learn, it must be able to add to the language and derive new sentences from old ones.**

When an agent begins an action, it updates the knowledge base with what it perceives, asks what action it should perform, and is told what to do in response to reasoning about the current state of its world.

‘Declarative methods’ involve telling the knowledge-based programs what they need to know to operate in their environment, while ‘procedural methods’ provide detailed coding to teach desired behaviors.

Successful AI agents typically combine both declarative and procedural approaches within their design and include mechanisms for them to learn unsupervised.

Propositional logic

**‘Propositional logic’** is a branch of mathematical logic that uses a set of propositions, or statements, to represent objects in an imagined or real world and the relationships between them. Each statement can be true or false. It combines rules for sentence structure, or syntax, with those for defining their logical truth, or semantics.

Put simply, propositional logic is a language for asserting things as **true or false**. It is also sometimes known as Boolean logic.

Such logic combines propositional symbols and logical connectives, such as ‘and’ and ‘or,’ and is used to analyze declarative statements, known as propositions, that make a statement about the world.

Individually or taken together, statements are assigned a truth value that cannot, under any circumstances, be ambiguous.

How to think about propositional logic

Here are some example statements of propositional logic:

*The sun sets in the west*

*The sun sets in the east*

*a2 + b2 = c2*

*a > b*

*b < a*

Each of these statements can either be true or false (or indeed unknown).

Propositional logic is **limited in what it can say**. It does not have the expressive power to concisely deal with time and space or represent universal patterns or relationships among objects.

As a result, it does not scale well; while it may be useful for specific, well-defined problem-solving, known as ‘bounded tasks’, it is less useful for open-ended and complex work, known as ‘unbounded tasks’.

Drawing inferences in propositional logic

Propositional logic allows for complex sentences to be constructed from simple ones, making use of a set of clearly defined operators known as ‘logical connectives.’

These logical connectives are essential for writing propositional statements. They are listed here with their logic symbols, and they include:

**not(¬)** – a way to ‘negate’ the statement

**and (∧)** – a ‘conjunction’ combines 2 sentences

**or (V)** – a ‘disjunction’ indicates the relationship between 2 distinct alternatives

**implies (=>)** – an ‘implication’ involves both a premise and a conclusion, similar to an if-then statement- ‘If I eat too much then I will be sick.’ This would be written as ‘Eating too much implies me being sick.’

**If and only if (<=>)** – returns a true value only if both sides satisfy one another.

Inferences explained

The basic inference rule in propositional logic is known as **‘Modus Ponens.’** This is a kind of logic that works to infer a truth from two other propositions.

‘Modus Ponens’ can be expressed as follows, where P and Q both represent separate sentences:

*If P, then Q*

*P*

*Therefore Q*

To think about that more clearly, let’s imagine P is the sentence ‘It is a car’, and Q is the sentence ‘It has wheels’:

*If it is a car, then it has wheels*

*It is a car*

*Therefore, it has wheels*

This inference is logically sound in any world in which the premise of part one is true – so unless you’re in *Back to the Future*, you can rest assured that the inference made in this example is sound.

Agents using propositional logic

Propositional logic allows computer code, or AI agents, to efficiently keep track of what they have learned about their world. They can store propositional statements such as ‘If it is a car, it has wheels’. It can then apply logical inferences from these and similar known truths to enlarge its bank of knowledge – in this case, it now knows that any car it comes across will have wheels.

We begin by writing down the set of logical sentences, or **‘transition model,’** that define the AI agent’s world. These are written into the knowledge base. This is best imagined through examples from game design.

We might have an AI agent that is an orc character in a game. The agent has the statement ‘If it is an orc, then it can move one square per turn’ stored. This means that any movement that the orc makes will have this rule applied to it.

Effect axioms and frame problems

Once the agent has executed this logic, we can capture **‘effect axioms’** – they specify the outcome of the agent’s actions.

These effect axioms can also be expressed as propositional statements. For example, ‘my orc character is moving from square (5,6) to (6,6).’ This can be stored as a true or false value for the agent to use in later inferences.

However, an agent working only on propositional logic will come across what’s known as ‘frame problems.’ **Frame problems** are where effect axioms don’t specify in full what has changed – we know that the orc has moved its position, but what about the items it was carrying?

This is the limit of propositional logic – it can only create quite simple statements and inferences. So unless we specifically tell an agent that an orc’s items move along with them, it cannot infer this.

What is predicate logic?

First-order or predicate logic is another means of knowledge representation in artificial intelligence. While it is considered more powerful than propositional logic, it is an extension rather than a replacement.

**The key difference with predicate logic is that it can deal with properties, rather than just propositions**. In other words, in addition to propositions, predicate logic can identify specific details about the subjects of those propositions.

It does this by understanding variables. In this context, variables mean things whose definitions can be changed by new declarations.

An example of predicate logic

”If

Let’s consider the following set of inferences using propositional logic:

If Frodo puts on the ring, he’ll turn invisible (*If* P, *then* Q)

Frodo puts on the ring (P)

Therefore, he’ll turn invisible (*Therefore*, Q)

The conclusion that Frodo will turn invisible is inferable with propositional logic. However, these propositions make no distinction between the properties of their subjects. Propositional logic is only able to make basic deductions – **it knows that P leads to Q, but nothing more**. That means that things that are obvious to a human reader will be impossible to infer under propositional logic.

For example, consider these two propositions:

If Frodo puts on the ring, he’ll turn invisible (*If* P, *then* Q)

Sauron can see invisible people (R)

Obviously, we can infer from this that ‘If Frodo puts on the ring, Sauron can see him’. However, it would be **impossible to compute this with propositional logic.**

Predicates and variables

The reason it would be impossible to infer that ‘Sauron can see Frodo when he puts on the ring’ from the two propositions in the example is that propositional logic does not understand that ‘invisible people’ is a category – one that can contain objects such as ‘Frodo’.

Predicate logic, on the other hand, is able to parse statements and store variables and the conditions governing them. It will place Frodo within the category ‘invisible’, and therefore infer that Frodo is visible to Sauron. Parsing these statements with predicate logic would look like this – where ‘F’ represents Frodo, ‘S’, Sauron, and ‘IP(x)’ represents the categorical variable ‘invisible people’:

If Frodo puts on the ring, he’ll turn invisible (*If* F *performs* P, IP(x) *will contain* F)

Sauron can see invisible people (S *can see whatever is in* IP(x))

If Frodo puts on the ring, Sauron can see him (*If* F *performs* P, S *can see* F)

By understanding this, **predicate logic can be used for far smarter inferences than propositional logic, and express more complex things in a more efficient way.**

”Frodo

Different items in predicate logic

The most basic form of predicate logic is atomic sentences. These are statements about a category, using the verb ‘to be’ as the modifier. The easiest way to express how this works is through putting the objects contained in the categorical variable in brackets. For example:

*Bill and Bob are brothers => Brothers (Bill, Bob)*

*Ginger is a cat => Cat(Ginger)*

There are also more complex ways that predicate logic can work.

Like natural language, predicate logic assumes that the world contains facts, objects (people, numbers, theories, etc.), relations (unitary ones such as green or square), and n-any relations (such as taller than or sits between), and functions (father of, daughter of, end of, etc.)

Predicate logic quantifiers

Another reason that predicate logic is valuable to AI is that it is able to use quantifiers. **This means it can understand the concepts of ‘all’, or ‘some’.** The quantifier ‘all’ is known as a universal quantifier. When universal quantifiers are used, the agent will know that the statement will apply to every object in that category.

There are also existential quantifiers – words like ‘some’. Predicate logic is able to understand the concept that in a group of objects, only some of them may share a given quality.

Using predicate logic to create a knowledge base

Predicate logic provides AI researchers with an expressive logical language that allows them to represent knowledge in a particular domain. Predicate logic works by holding a ‘knowledge base’ – a record of which variables contain what object.

For example, we can represent ‘Richard is a king, Jack is a person, and all kings are persons,’ using the following predicate logic:

Richard is a king = *TELL (KB, King(Richard))*

Jack is a person = *TELL (KB, Person(Jack))*

All kings are people = *TELL (KB, ∀x King(X) => Person(x))*

*KB* stands for ‘Knowledge Base’. *∀x* is the symbol we use to express ‘all’, the universal quantifier. *TELL* here is the instruction we would use to declare that the variable contains the object we want it to.

Querying a knowledge base with predicate logic

Once something is stored in a knowledge base, we can query it using ASK. For example:

Q: ‘Is Richard a king?’ = *ASK (KB, King(Richard))*

‘True’ is returned. And yet, more often we wish to know what value(s) of x make a sentence true. For example:

Q: Are kings people? = *ASKVARS (KB, Person(x))*

This logic will tell us that Richard and Jack are both people.

These statements are difficult to read for those unfamiliar with the syntax, but once you’ve gotten used to it, predicate logic is **an extremely powerful tool for concisely representing complex natural language descriptions.**

Using predicate logic for knowledge engineering

‘Knowledge engineering’ involves constructing knowledge bases for particular domains. While typically these knowledge bases are limited and their range of queries known in advance, general purpose knowledge bases exist for other purposes, such as natural language processing.

This means that **most AI agents have large knowledge bases built-in**. If their job is natural language processing, this means the whole dictionary, plus many rules for syntax and grammar. This means they don’t have to be taught, for example, that ‘people’ is a variable category, or that ‘to be’ is how variables are declared.

‘Knowledge engineering’ is the field of optimizing knowledge bases for specific programs and agents. If an AI agent is being built for analyzing designs for bridges, it needs to have a knowledge base that covers bridge designs and common issues with them. If the AI is for quality checking new cars, it needs a similarly specialized knowledge base.

Acting with uncertainty

While knowledge engineering is highly important, in the real world, AI agents must handle uncertainty. After all, they may not have sufficient information regarding their present state or what things will be like after a sequence of actions take place – whether successful or not.

Rational decisions might depend on the relative importance of various goals and the degree to which they can be achieved. Our primary tool for dealing with degrees of belief is **’probability theory.’** It provides a helpful foundation for uncertain reasoning.

*Bayes’ rule* describes the probability of an event based on prior knowledge of the conditions. It is often used in probability theory to describe the likelihood of an event happening and underlies most modern AI systems for probabilistic inference. Probability helps by expressing the agent’s inability to reach a decision regarding the truth of a sentence. On the other hand, ‘decision theory’ combines the agent’s beliefs and desires – the best action being the one that maximizes expected utility.

You will forget 90% of this article in 7 days.

Download Kinnu to have fun learning, broaden your horizons, and remember what you read. Forever.

You might also like

What is Computer Vision, and What are its Real-World Applications and Potential for Misuse?;

For AI to successfully interact with, and learn from its environment, it must be able to ‘see’ what’s going on

Introduction to AI;

Start here for an overview of this exciting pathway

What is AI, and What are Its Potential Rewards?;

The rapidly advancing field of AI is challenging our understanding of what it means for a machine to display human-like intelligence

What is the history of Artificial Intelligence (AI)?;

The potential of AI to transform what we mean by intelligence was recognized during the earliest days of computing

Machine Learning;

Machine learning has made AI more flexible and adaptive, able to modify its behavior in response to its learning and the environment

What is Knowledge Representation in AI?;

Without an accurate and helpful representation of its environment, the AI simply has a collection of abstract data

Leave a Reply

Your email address will not be published. Required fields are marked *