class 20,21,22,23,24 summary

This commit is contained in:
Ramchandra Phawade Phawade 2023-10-12 11:45:24 +05:30
parent 519e848e4f
commit a3968c50a3
9 changed files with 1601 additions and 0 deletions

View File

@ -0,0 +1,16 @@
Resolution
Examples
Soundness of resolution rule.
Res*(F)
Proposition 1:
If \emptyset \in Res*(F) then F is unsatisfiable.
Proof : (by contradiction and using soundness of resolution rule)
Proposition 2:
If F is unsatisfiable then \emptyset \in Res*(F)
Proof : (by induction on #prop_variables appearing in F
Base case : when F has only one variable.

Binary file not shown.

View File

@ -0,0 +1,38 @@
#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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
/*++
Copyright (c) 2015 Microsoft Corporation
--*/
#include <iostream>
#include <sstream>
#include<vector>
#include"z3++.h"
using namespace z3;
void expr_vector_example() {
std::cout << "expr_vector example\n";
context c;
const unsigned N = 10;
expr_vector x(c);
for (unsigned i = 0; i < N; i++) {
std::stringstream x_name;
x_name << "x_" << i;
x.push_back(c.int_const(x_name.str().c_str()));
}
solver s(c);
for (unsigned i = 0; i < N; i++) {
s.add(x[i] >= 1);
}
std::cout << s << "\n" << "solving...\n" << s.check() << "\n";
model m = s.get_model();
std::cout << "solution\n" << m;
}
int main() {
try {
expr_vector_example(); std::cout << "\n";
std::cout << "done\n";
}
catch (exception & ex) {
std::cout << "unexpected error: " << ex << "\n";
}
return 0;
}

View File

@ -0,0 +1,45 @@
#include <iostream>
#include <sstream>
#include<vector>
#include"z3++.h"
using namespace z3;
/**
find values of expressions that satisfy the following ineaualities
x >= 1
y < x +3
*/
int main(){
context c;
expr x = c.int_const("x");
expr y = c.int_const("y");
//create a solver
solver s(c);
//adding the constraints
s.add(x >=1);
s.add(y < x+3);
std::cout << s.check() << "\n\n";
model m = s.get_model();
std::cout << m << "\n";
//traversing the model
std::cout << "traversing the model" << "\n";
for (unsigned i =0; i < m.size(); i++){
func_decl v = m[i];
assert(v.arity() ==0);
std::cout << v.name()<<"="<<m.get_const_interp(v) << "\n";
}
// evaluating the expressions in the model.
std::cout << "evaluating the expressions in the model" << "\n";
std::cout << "x+y+1= "<< m.eval(x+y+1)<<"\n";
return 0;
} //end of function

View File

@ -0,0 +1,14 @@
Introduction to FOL
-- socrates example.
Why do we need FOL to deduct that Socrates is mortal.
-- Predicates are relating the objects and properties.
-- Signature of FOL (constants, functions, relations).
-- we need variables, logical symbols and non-logical symbols,
also to define wffs.
-- Example of Number Theory and some formulas
-- Example of set theory and some examples
-- Example of min FOL (with only =).

View File

@ -0,0 +1,10 @@
-- Syntax of FOL
-- step (1) terms : constant, variabls, or succussive applications to functions.
-- examples of terms in number theory, set theory, min FOL
-- step (2) atomic formulas : Relations over terms, = exists unless
specified.
-- examples of atomic formulas in number theory, set theory, min FOL
-- step (3) wffs : atomic formulas, or formulas constructed from
smaller formulas using negation, implication, \forall, \exists.

View File

@ -0,0 +1,10 @@
Revision of syntax of FOL.
Semantics of FOL
Structure.
Example of structure of natural numbers
EXamples of formulas from number theory
Assignment functions S: Variables --> \universe
Extenstion of S to give meaning to terms, atomic formulas and wffs.