Home »
Machine Learning/Artificial Intelligence
Backus-Naur Form (BNF) in Artificial Intelligence
In this tutorial, we will learn about the Backus-Naur Form is and how is it related to Artificial Intelligence? We will study the BNF in detail and will also study the rules and principles that are used while using this form.
By Monika Sharma Last updated : April 15, 2023
Backus-Naur Form (BNF)
Backus-Naur Form, in short, known as BNF is a technique by which we can notify our Context Free Grammar (CFG). The CFG (or CFL for Context Free Language) is a formal grammar in which all the strings lying in that given language or Grammar can be derived using the standard rules and principles which are known as production rules.
In a computer system, BNF is used to define the layout of the information.
BNF Rule
The syntax of any rule in the BNF is as follows:
<SYMBOL> ::= <Expression1> | <Expression2> | ...
Points to be noted
The following points must be noted:
- The SYMBOL present in the LHS is always a non-terminal symbol.
- The sequence of symbols (or expressions): Expression1, Expression2, ... present on the RHS can either be a terminal symbol or a non-terminal symbol.
- The sequence of symbols in the RHS can also contain only one symbol.
- If there are more than one symbols present, then they are separated by the or sign- |.
- All these rules of the Grammar together are called the Production Rules.
- The symbols on the LHS and RHS are separated by the symbol ::= or :=.
In the sequence of symbols on the RHS, we represent the symbols as follows:
- The optional Symbols are written in within square brackets.
- The repeating symbols which can appear any number of times are followed by *.
- The symbols which repeat for at least one time are followed by +.
- Group of items must always be enclosed within brackets.
In Artificial Intelligence, the BNF is used for knowledge representation in the KB (Knowledge Base) of the agent. The words or strings can be derived from the raw data present in the agent's system by using this method.
Example of knowledge representation using the Backus-Naur Form
In an agent who is designed to fix or automatically call the respective maintenance men when any sort of problem detected in household items, the information is present as follows:
<Problem> := Water Purifier | Television | Telephone | Washing Machine
<Water Purifier> := Manual | Phone Number
<Television> := Manual | Phone Number
<Telephone> := Manual | Phone Number
<Washing Machine> := Manual | Phone Number
<Manual> := Fix
<Phone Number> := Call