please give me program that solve a Proof in Discrete
write a c program
Let us suppose, we have a boolean expression as given below:
= P v ~(P^Q)
We need to prove that the above expression is a tautology by using a Programming Language C program.
The program to generate a truth table of the above boolean expression is given below:
#include <stdio.h>
#include <stdbool.h>
int main()
{
//boolean variable declaration
bool p,q;
//display table header
printf("P Q P^Q ~(P^Q) (P v ~(P^Q)) \n");
//display the table data
for ( int i = 0 ; i < 4 ; i++ )
{
p = ( i >> 0 ) & 0x01;
q = ( i >> 1 ) & 0x01;
//display p and q
printf("%d ", p);
printf("%d ", q);
printf("%d %d %d\n", (p&&q), (p&&q),
(p||!(p&&q)));
}
return 0;
}
OUTPUT:
A given boolean expression is a tautology if it is always true and doesn't depend upon the input. The above proposition is a tautology if the above proposition is true for all types of input values of P and Q.
Get Answers For Free
Most questions answered within 1 hours.