You are on page 1of 7

NAME: YARRAIAHGARI PRANAVI TEJA

REG NO. : BL.EN.U4AIE23152

DM RULES OF INFERENCE

1.Rule of conjunction

n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==1) b(i,1)=1;
else
b(i,1)=0;
end
end
x=[a,b];
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==1) b(i,2)=1;
else
b(i,2)=0;
end
end
y=[a,b];
for i=1:1:2^n
if(b(i,1)==1&b(i,2)==0) b(i,3)=0;
else
b(i,3)=1;
end
end
z=[a,b]

z = 4×5
1 1 1 1 1
1 0 0 0 1
0 1 0 0 1
0 0 0 0 1

disp("tauotology")

tauotology

disp("rule of conjuction")

rule of conjuction

2.Rule of addition

clc;
clf;
n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n

1
if(a(i,1)==0&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];
for i=1:1:2^n
if(a(i,1)==1&b(i,1)==0) b(i,2)=0;
else
b(i,2)=1;
end
end
y=[a,b]

y = 4×5
1 1 1 1 1
1 0 1 1 1
0 1 1 1 1
0 0 0 1 1

disp("tauotology")

tauotology

disp("Rule of Addition")

Rule of Addition

3.Rule of simplification

n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==1) b(i,1)=1;
else
b(i,1)=0;
end
end
x=[a,b];
for i=1:1:2^n
if(b(i,1)==1&a(i,1)==0) b(i,2)=0;
else
b(i,2)=1;
end
end
y=[a,b]

y = 4×5
1 1 1 1 1
1 0 0 1 1
0 1 0 1 1
0 0 0 1 1

2
disp("tauotology")

tauotology

disp("Rule of Simplification")

Rule of Simplification

4.rule of modus ponens

n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];
for i=1:1:2^n
if(a(i,1)==1&b(i,1)==1) b(i,2)=1;
else
b(i,2)=0;
end
end
y=[a,b];
for i=1:1:2^n
if(b(i,2)==1&a(i,2)==0) b(i,3)=0;
else
b(i,3)=1;
end
end
z=[a,b]

z = 4×5
1 1 1 1 1
1 0 0 0 1
0 1 1 0 1
0 0 1 0 1

disp("tautology")

tautology

disp("Rule of modus ponens")

Rule of modus ponens

5.rule of hypothetical syllogism

n=3;
a=dec2bin(2^n-1:-1:0)-'0';

3
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];
for i=1:1:2^n
if(a(i,2)==1&a(i,3)==0) b(i,2)=0;
else
b(i,2)=1;
end
end
y=[a,b];
for i=1:1:2^n
if(b(i,1)==1&b(i,2)==1) b(i,3)=1;
else
b(i,3)=0;
end
end
z=[a,b];
for i=1:1:2^n
if(a(i,1)==1&a(i,3)==0) b(i,4)=0;
else
b(i,4)=1;
end
end
s=[a,b];
for i=1:1:2^n
if(b(i,3)==1&b(i,4)==0) b(i,5)=0;
else
b(i,5)=1;
end
end
p=[a,b]

p = 8×8
1 1 1 1 1 1 1 1
1 1 0 1 0 0 0 1
1 0 1 0 1 0 1 1
1 0 0 0 1 0 0 1
0 1 1 1 1 1 1 1
0 1 0 1 0 0 1 1
0 0 1 1 1 1 1 1
0 0 0 1 1 1 1 1

disp("tautology")

tautology

disp("rule of hypothetical syllogism")

rule of hypothetical syllogism

4
6.rule of modus tollens

n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==1&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];

Error using horzcat


Dimensions of arrays being concatenated are not consistent.

for i=1:1:2^n
if(~a(i,2)==1&b(i,1)==1) b(i,2)=1;
else
b(i,2)=0;
end
end
y=[a,b];
for i=1:1:2^n
if(b(i,2)==1&~a(i,1)==0) b(i,3)=0;
else
b(i,3)=1;
end
end
s=[a,b]
disp("tautology")
disp("rule of modus tollens")

7.rule of disjunctive syllogism

n=2;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==0&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];
for i=1:1:2^n
if(b(i,1)==1&~a(i,1)==1) b(i,2)=1;
else
b(i,2)=0;
end
end

5
y=[a,b];
for i=1:1:2^n
if(b(i,2)==1&a(i,2)==0) b(i,3)=0;
else
b(i,3)=1;
end
end
z=[a,b]
disp("tautology")
disp("rule of disjunctive syllogism")

8. rule of resolution

n=3;
a=dec2bin(2^n-1:-1:0)-'0';
for i=1:1:2^n
if(a(i,1)==0&a(i,2)==0) b(i,1)=0;
else
b(i,1)=1;
end
end
x=[a,b];
for i=1:1:2^n
if(~a(i,1)==0&a(i,3)==0) b(i,2)=0;
else
b(i,2)=1;
end
end
y=[a,b];
for i=1:1:2^n
if(b(i,1)==1&b(i,2)==1) b(i,3)=1;
else
b(i,3)=0;
end
end
z=[a,b];
for i=1:1:2^n
if(a(i,2)==0&a(i,3)==0) b(i,4)=0;
else
b(i,4)=1;
end
end
s=[a,b];
for i=1:1:2^n
if(b(i,3)==1&b(i,4)==0) b(i,5)=0;
else
b(i,5)=1;
end
end
p=[a,b]

6
disp("tautology")
disp("rule of resolution")

You might also like