Propositional Logic and Logical Operators
What Is Propositional Logic?
Propositional logic represents statements that can be classified as either true or false.
A proposition is a statement with a truth value.
Examples:
- P: The server is running.
- Q: The database is connected.
- R: The application is available.
If P is true and Q is true, we may use a logical rule to conclude that the application has the two required conditions for availability.
The actual availability of a production application may depend on additional factors, but this simplified example demonstrates how logical statements can be combined.
Common Logical Operators
1. AND ((\land))
The result is true only when both statements are true.
[
P \land Q
]
Example: The user is authenticated AND has permission.
2. OR ((\lor))
The result is true when at least one statement is true.
[
P \lor Q
]
Example: The user can sign in using a password OR an approved alternative authentication method.
3. NOT ((\neg))
Reverses a truth value.
[
\neg P
]
If P means "the server is running," then NOT P means "the server is not running."
4. Implication ((\rightarrow))
Represents a conditional relationship.
[
P \rightarrow Q
]
This means "if P, then Q." In classical propositional logic, the implication is false only when P is true and Q is false.
5. Biconditional ((\leftrightarrow))
Indicates that two statements have the same truth value.
[
P \leftrightarrow Q
]
It is often read as "P if and only if Q."
Truth Table for AND and OR
P | Q | P AND Q | P OR Q |
| True | True | True | True |
| True | False | False | True |
| False | True | False | True |
| False | False | False | False |
Applying Logic in Python
Python supports logical operations using and, or, and not.
is_authenticated = True
has_permission = False
can_access = is_authenticated and has_permission
print(can_access)
Output:
False
Although the user is authenticated, access is denied because the user does not have the required permission.
Combining Multiple Conditions
is_verified = True
has_valid_subscription = True
account_suspended = False
can_use_service = (
is_verified
and has_valid_subscription
and not account_suspended
)
print(can_use_service)Output:
True
This example shows how logical conditions can express application policies.
Why Propositional Logic Matters in AI
Propositional logic is useful for:
- Representing simple facts.
- Expressing conditions and constraints.
- Checking whether a set of statements is consistent.
- Building rule-based decision systems.
- Supporting automated reasoning.
Its limitation is that it does not directly express variables, objects, or relationships with the flexibility of first-order logic.
Artificial Intelligence Tutorial
Vishalini A








