Inference rules in AI

Table of Content:

Content Highlight:

In AI, inference is using a trained model to make predictions. It applies learned knowledge to new data to produce an output. Inference rules are logical rules that govern how new knowledge is derived from existing knowledge. Common types include Modus Ponens, Modus Tollens, and others. These rules allow AI systems to draw conclusions and make decisions based on available information.

What is the inference in Artificial Intelligence?

AI inference in AI (Artificial Intelligence) refers to the process of using a trained model to make predictions or decisions based on new input data. Inference is the phase where the model applies what it has learned during training to new, unseen data to produce an output. This output could be a classification, a regression prediction, a sequence generation, or any other task the model was trained to perform.

During inference, the model's parameters (learned during training) are fixed, and it does not learn or update its parameters further. Instead, it applies its learned knowledge to the new data, often using mathematical operations defined by the model architecture. This process allows AI systems to generalize from the training data to make predictions on new, similar data, which is a core capability of AI systems.

How it works:

AI inference works by taking a trained model and using it to process new input data to generate predictions or decisions. Here's a general overview of how it works:

  1. Trained Model: First, a machine learning model is trained on a dataset. During training, the model learns the patterns and relationships in the data.
  2. Input Data: When new data is introduced for inference, it goes through a preprocessing step to prepare it for the model. This step might include normalization, scaling, or other transformations.
  3. Model Inference: The preprocessed data is fed into the trained model, which applies the learned patterns and relationships to generate an output. This output could be a classification label, a regression value, or some other prediction depending on the model's task.
  4. Output: The model's output is then used for the intended purpose, such as making a decision, generating a response, or classifying an image.
  5. No Learning: Importantly, during inference, the model's parameters remain fixed and do not change. This is in contrast to the training phase, where the model adjusts its parameters based on the training data to improve its performance.

Overall, AI inference allows trained models to be applied to new data, enabling the model to generalize and make predictions or decisions in real-world applications.

Inference rules in AI:

Inference rules are fundamental in logic and reasoning, providing templates for constructing valid arguments. In the field of artificial intelligence, they are crucial for deriving proofs, where a proof is a step-by-step sequence of conclusions that lead to a desired goal or outcome.

One of the key aspects of inference rules is the implication, denoted by the symbol →, which represents a logical relationship between two propositions. For example, in the expression P → Q, P implies Q, meaning that if proposition P is true, then proposition Q must also be true. The implication can be thought of as a promise that if the condition (P) is met, then the consequence (Q) follows.

When dealing with implications, several related terms come into play:

  1. Implication: Symbolized as P → Q, it signifies that if P is true, then Q must also be true.
  2. Converse: The converse of an implication reverses the order of the propositions. In other words, if P implies Q (P → Q), then the converse is Q implies P (Q → P). It's like looking at the implication from the opposite direction. However, it's essential to note that while the original implication may hold true, its converse may not necessarily be true.
  3. Contrapositive: The contrapositive of an implication is formed by ¬ating both the antecedent (P) and the consequent (Q) and then reversing their order. For instance, the contrapositive of P → Q is ¬Q → ¬P. The contrapositive maintains the logical equivalence of the original implication. That is, if the implication holds true, then its contrapositive also holds true.
  4. Inverse: The inverse of an implication involves ¬ating both the antecedent (P) and the consequent (Q) without changing their order. For example, the inverse of P → Q is ¬P → ¬Q. Unlike the contrapositive, the inverse does not necessarily preserve the logical equivalence of the original implication. In other words, if an implication is true, its inverse may or may not be true.

Some of the compound statements in the above term are equivalent to each other, which we can verify using the truth table:

P Q P → Q Q → P ¬ Q → ¬ P ¬ P → ¬ Q
T T T T T T
T F F T F T
F T T F T F
F F T T T T

As a result from the above truth table, we can prove that P → Q is equivalent to ¬ Q → ¬ P, and Q→ P is equivalent to ¬ P → ¬ Q.

Types of Inference rules:

1. Modus Ponens:

Modus Ponens is a foundational rule of inference in logic, stating that if a conditional statement is true and its hypothesis is true, then its conclusion must also be true. Formally, it can be expressed as follows:

Modus Ponens in AI.

If P implies Q (written as PQ), and P is true, then Q is true.

For example, consider the following statements:

  1. Statement 1: "If it is raining, then the ground is wet." (PQ)
  2. Statement 2: "It is raining." (P)

From these two statements, we can infer the following conclusion:

Conclusion: "The ground is wet." (Q)

In this example, Modus Ponens allows us to logically deduce that if it is indeed raining (Statement 2 - P is true), then the ground must be wet (Conclusion - Q is true), based on the conditional statement given in Statement 1 (PQ).

Proof by Truth table:

Modus Ponens example in AI

2. Modus Tollens:

Modus Tollens is a fundamental rule of inference in logic, stating that if a conditional statement is true and its consequent is false, then its antecedent must also be false. Formally, it can be expressed as follows:

Modus Tollens in AI

If P implies Q (written as P → Q) is true and not Q (¬Q) is true, then not P (¬P) is true.

For example, consider the following statements:

  1. Statement 1: "If I am sleepy, then I go to bed." (P → Q)
  2. Statement 2: "I do not go to bed." (¬Q)

From these two statements, we can infer the following conclusion:

Conclusion: "I am not sleepy." (¬P)

In this example, Modus Tollens allows us to logically deduce that if I do not go to bed (Statement 2 - ¬Q is true), then I am not sleepy (Conclusion - ¬P is true), based on the conditional statement given in Statement 1 (P → Q).

Proof by Truth table:

Modus Tollens example in AI

3. Hypothetical Syllogism:

Hypothetical Syllogism is a rule of inference in logic that states that if one conditional statement implies a second conditional statement, and the second statement implies a third conditional statement, then the first statement implies the third statement. Formally, it can be expressed as follows:

If (P → Q) is true and (Q → R) is true, then (P → R) is true.

For example, consider the following statements:

  1. Statement 1: "If you have my home key, then you can unlock my home." (P → Q)
  2. Statement 2: "If you can unlock my home, then you can take my money." (Q → R)

From these two statements, we can infer the following conclusion:

Conclusion: "If you have my home key, then you can take my money." (P → R)

In this example, Hypothetical Syllogism allows us to logically deduce that if you have my home key (Statement 1 - (P → Q) is true), then you can take my money (Conclusion - (P → R) is true), based on the conditional statements given in Statement 1 and Statement 2.

Proof by Truth table:

Hypothetical Syllogism example in AI

4. Disjunctive Syllogism:

Disjunctive Syllogism is a rule of inference in logic that states that if a disjunction (logical OR) of two statements is true, and one of the statements is false, then the other statement must be true. Formally, it can be expressed as follows:

Disjunctive Syllogism in Artificial Intelligence (AI)

If (P ∨ Q) is true, and (¬P) is true, then (Q) is true.

For example, consider the following statements:

  1. Statement 1: "Today is Sunday or Monday." (P ∨ Q)
  2. Statement 2: "Today is not Sunday." (¬P)

From these two statements, we can infer the following conclusion:

Conclusion: "Today is Monday." (Q)

In this example, Disjunctive Syllogism allows us to conclude that if today is not Sunday (Statement 2 - (¬ P) is true), then today must be Monday (Conclusion - (Q) is true), based on the disjunction given in Statement 1.

Proof by Truth table:

Disjunctive Syllogism example in Artificial Intelligence (AI)

5. Addition:

Addition is a fundamental rule of inference in logic that states that if a proposition (P) is true, then the disjunction (P lor Q) is also true, for any proposition (Q).

Addition inference in AI

In the context of artificial intelligence, rules of inference are used to derive new knowledge from existing knowledge. The Addition rule allows us to assert a disjunction when we know that one of the disjuncts is true.

For example, consider the following statements:

  1. Statement 1: "I have a vanilla ice-cream." (P)
  2. Statement 2: "I have chocolate ice-cream."

From these statements, we can infer the following conclusion:

Conclusion: "I have vanilla or chocolate ice-cream." (P ∨ Q)

In this example, the Addition rule allows us to conclude that if I have a vanilla ice-cream (Statement 1 - (P) is true), then I must have either vanilla or chocolate ice-cream (Conclusion - (P ∨ Q) is true), based on the Addition rule in logic.

Proof by Truth table:

Addition inference example in AI

6. Simplification:

Simplification is a rule of inference in logic that states that if a conjunction (logical AND) of two statements is true, then each of the individual statements is also true. Formally, it can be expressed as follows:

Rules of Simplification in AI Inference

If (P ∧ Q) is true, then (Q) is true and (P) is true.

For example, consider the following statement:

  1. Statement: "It is raining and the ground is wet." (P ∧ Q)

From this statement, we can infer the following conclusions:

  1. Conclusion 1: "The ground is wet." (Q)
  2. Conclusion 2: "It is raining." (P)

In this example, the Simplification rule allows us to conclude that if it is raining and the ground is wet (Statement - (P ∧ Q) is true), then it must be true that the ground is wet (Conclusion 1 - (Q) is true) and it is raining (Conclusion 2 - (P) is true), based on the conjunction given in the statement.

Proof by Truth table:

Example of Simplification in AI Inference

7. Resolution:

Resolution is a rule of inference in logic that is used to derive new clauses from existing ones. It is particularly useful in propositional logic and is based on the idea of refutation. The rule states that if there are two clauses, one containing a proposition (P) and the other containing the negation of (P) along with another proposition (R), then we can resolve these two clauses to derive a new clause containing the disjunction of the remaining propositions (Q) and (R).

Formally, the Resolution rule can be expressed as follows:

Rules of Resolution in AI Inference

If (P ∨ Q) and (¬ P ∨ R) are true, then (Q ∨ R) is also true.

The Resolution rule is often used in automated theorem proving and artificial intelligence for logical reasoning.

Proof by Truth table:

Example of Resolution in AI Inference