Logicandapplications2023/class_21_05102023/demorgan.cpp

39 lines
698 B
C++
Raw Normal View History

2023-10-12 11:45:24 +05:30
#include <iostream>
#include <sstream>
#include<vector>
#include"z3++.h"
using namespace z3;
/**
De Morgan's Duality Law: {e not(x and y) <-> (not x) or ( not y) }
*/
int main(){
context c;
expr x = c.bool_const("x");
expr y = c.bool_const("y");
expr conjecture = !(x && y) == (!x || !y);
//create a solver
solver s(c);
//assert the negation of conjecture
s.add(!conjecture);
std::cout << s << "\n";
std::cout << s.to_smt2() << "\n";
//check if the result if unsat
switch (s.check()) {
case unsat: std::cout << "demorgan is valid\n"; break;
case sat: std::cout << "demorgan is not valid\n"; break;
case unknown: std::cout <<"unknown\n"; break;
}
} //end of function