Professional Documents
Culture Documents
AI Final Labtask
AI Final Labtask
AI Final Labtask
Answer:
a) good_player(afridi, t20).
b) powerful_president(trump).
last_decade(2020, 2029).
c) born(hashim, 1995).
Q.2 Consider the following statements. Convert into FOPL resolution and re-write to CNF form.
And convert it into Resolution Graph.
Gita likes all kinds of food
Mango and chapatti are food.
Gita eats almond and is still alive.
Anything eaten by anyone and is still alive is food
Answer:
1. ¬food(x) ∨ likes(gita, x)
2. food(mango)
3. food(chapatti)
4. eats(gita, almond)
5. alive(gita)
6. ¬eats(y, x) ∨ ¬alive(y) ∨ food(x)
Resolution Graph:
(2) food(mango)
/
(6) (3) food(chapatti)
/ \
(1) - food(x) (6) - eats(y, x)
\ /
(6) (5) alive(gita)
\
(4) eats(gita, almond)
Q.3 Convert the following English sentences to FOL (First Order Logic).
Every student loves some other students.
All students are smart.
There exists a smart student
Some students are obedient.
Hashim and Ayesha took the bus.
Some peoples are aggressive in nature
Some students are obedient.
Hashim and Ayesha took the bus.
Answer:
To convert the given English sentences into First-Order Logic (FOL), we need to assign predicates, variables, and
quantifiers to represent the different elements in the sentences. Here's the conversion:
Q.4 Consider the following statements. Use Propositional Logic & apply Resolution Method to
prove that the goal is derivable from the given knowledge base. Also draw a Graph.
The humidity is high or the sky is cloudy.
If the sky is cloudy, then it will rain.
If the humidity is high, then it is hot.
It is not hot.
Answer:
To apply the Resolution Method to prove that the goal is derivable from the given knowledge base, we need to
represent the statements in Propositional Logic and perform resolution steps. Here's the representation:
1. The humidity is high or the sky is cloudy.
P: humidity_high ∨ sky_cloudy
P: sky_cloudy → rain
P: humidity_high → hot
4. It is not hot.
P: ¬hot
Goal: rain
To prove that the goal "rain" is derivable from the given knowledge base, we can use the Resolution Method.
We start by converting the statements into CNF (Conjunctive Normal Form) and perform resolution steps:
CNF Conversion:
1. humidity_high ∨ sky_cloudy
2. ¬sky_cloudy ∨ rain
3. ¬humidity_high ∨ hot
4. ¬hot
Resolution Steps:
Step 1: Resolve clauses 1 and 2 on "sky_cloudy":
-------------------------------------
humidity_high ∨ rain
-------------------------------------
¬humidity_high
-------------------------------------
rain
Since "rain" is derived, the goal is proven to be derivable from the given knowledge base.
Resolution Graph:
/ \
\ /
(8) rain
Q.5 Write a Python Program to generate the following Series by using Functions up to ‘N’
numbers. Number is entered by User.
Fibonacci
Factorial of Number
Table of N Number
Answer:
def fibonacci_series(n):
series = []
if n <= 0:
return series
elif n == 1:
series.append(0)
return series
else:
series = [0, 1]
series.append(series[-1] + series[-2])
return series
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
def table_of_n(n):
fibonacci = fibonacci_series(number)
print("Fibonacci series:")
print(fibonacci)
factorial_result = factorial(number)
print(factorial_result)
print(f"Table of {number}:")
table_of_n(number)
```