/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iomanip>
using bst = std::bitset < 4 >;
using namespace std;
struct myint {
int _m;
myint(){};
myint(int p):_m(p){}
int getint (){return _m;}
};
myint implikacja(myint lft,myint rht);
void bitcout (myint wyrarzenie) {
std::cout<<bst(wyrarzenie.getint())<<std::endl;
return;
}
myint operator | (const myint &p, const myint &q) {return (p._m | q._m);}
myint operator & (const myint &p, const myint &q) {return (p._m & q._m);}
myint operator ~ (const myint &p) {return (~p._m);}
myint operator >>= (const myint &p, const myint &q) {return implikacja(p,q);}
std::ostream & operator << (std::ostream & out, const myint &p){return out<<p._m; }
int main()
{
myint p = 0b1100;
myint q = 0b1010;
//((~(p|q))|(~(p&q)))>>=(~(p>>=q))
myint wyrarzenie =(((~(p|q))|(~(p&q)))>>=(~(p>>=q)));
cout<<"lewa strona ="; bitcout((~(p|q))|(~(p&q)));
cout<<"prawa strona ="; bitcout(~(p>>=q));
cout<<"Cale wyrarzenie ="<<bst(wyrarzenie.getint())<<endl;
cout<<"Czy tautologia ="<<boolalpha<<bst( wyrarzenie.getint()).all()<<endl;
return 0;
}
myint implikacja(myint lft, myint rht) {
bst blft(lft.getint()),
brht(rht.getint()),
bitm;
size_t size = bst().size();
for (size_t i = 0; i < size; i++) bitm[i]=(blft[i] <= brht[i])?1:0;
myint ret(bitm.to_ulong());
return ret;
}