In: Computer Science
Part 1 Write a C++ program in which you define the following logical functions:
1) contradictory function (¬?)
2) logical and (? ∧ ?)
3) logical inclusive or (? ∨ ?)
4) implication function (? → ?)
5) biconditional (? ↔ ?)
6) logical exclusive or (? ⨁ ?)
You can find the logical definitions for the above functions as given by Bertrand Russell in your text. You need to write a method (function) for each corresponding logical function. The input and output values for each of these functions should be type boolean. Here are the prototypes:
For each of the following propositions, notice the variables are to be assigned some truth values. Using your functions from part 1, evaluate the truth or falsity of the proposition under the specified assignment. Do this in the same source file as for part 1.
Proposition 1: (? → ?) ∧ (¬? → ?) with c and b are F, a is T.
Proposition 2: (? → ?) ∨ (? ↔ ¬(¬? ⨁ ¬?)) with p is T, q and r are F.
#include<iostream>
using namespace logicaloperators;
//function declaration
void contradictory(bool a,bool b);
void logicalAnd(bool a,bool b);
void logicalInclusiveOr(bool a,bool b);
void implication(bool a,bool b);
void biconditional(bool a,bool b);
void logicalExclusiveOr(bool a,bool b);
int main()
{
bool a=true;
bool b=false;
contradictory(a,b);
logicalInclusiveOr(a,b);
logicalAnd(a,b);
implication(a,b);
biconditional(a,b);
logicalExclusiveOr(a,b);
}
void contradictory(bool a,bool b)
{
cout<<"contradictory a is:"<<¬a<<endl;
cout<<"contradictory b is:"<<¬b<<endl;
}
void logicalInclusiveOr(bool a,bool b)
{
cout<<"Logical inclusive OR is:"<<a^b<<endl;
}
void logicalAnd(bool a,bool b)
{
cout<<"Logical AND is:"<<a^b<<endl;
}
void implication(bool a,bool b
{
cout<<"contradictory a is:"<<a→b<<endl;
};
void biconditional(bool a,bool b)
{
cout<<"contradictory a is:"<<a↔b<<endl;
}
void logicalExclusiveOr(bool a,bool b)
{
cout<<"contradictory a is:"<<a⊕b<<endl;
}