Logic for Computer Scientists
(summer semester 2017-2018, moodle)
(summer semester 2017-2018, moodle)
Consistency is the playground of dull minds.
("Sapiens", Yuval Noah Harari)
c comment lines start with character 'c'c the next line says that this SAT instance has 3 variables and 2 clausesp cnf 3 2c the first clause contains "x_1" and "not x_3"c "0" is a terminator that allows clauses to span multiple lines1 -3 0c the second clause contains "x_2", "x_3", and "not x_1"2 3 -1 0This can be fed to z3 as
cat example.cnf | z3 -in -dimacsz3 -dimacs example.cnfcnfgen php 10 9 | z3 -dimacs -in (unsat; ends in reasonable time)cnfgen php 11 10 | z3 -dimacs -in (unsat; does not)cnfgen php 100 100 | z3 -dimacs -in (sat; takes way longer to generate the input than solving it)cnfgen op 24 | z3 -in -dimacs (unsat; terminates but slow)python2 -m virtualenv env0source ./env0/bin/activatepip install z3-solver# simple example of using Z3 from Pythonfrom z3 import *p = Bool('p')q = Bool('q')r = Bool('r')solve(Or(p, q, r, q), Or(Not(p), q), Or(p, Not(q), r))cnfgen randkcnf 3 100 200 | z3 -in -dimacsvirtualenv-2 .venvsource .venv/bin/activatepip install z3-solver jupyter numpy matplotlibjupyter notebooksource .venv/bin/activatejupyter notebookcoqide file.v.Maps.v (and generate Maps.vo) type: coqc Maps.v.)Add LoadPath "/path/").