"""
This is a WebAssembly power Python shell,
where you can try the examples in the browser:
1. Type code in the input cell and press
   Shift + Enter to execute;
2. Or copy paste the code, and click on
   the "Run" button in the toolbar
3. By the way, TAB-based autocompletion works!
"""
# the standard way to import PySAT:
from pysat.formula import CNF
from pysat.solvers import Solver
# create a satisfiable CNF formula "(-x1 ∨ x2) ∧ (-x1 ∨ -x2)":
cnf = CNF(from_clauses=[[-1, 2], [-1, -2]])
# create a SAT solver for this formula:
with Solver(bootstrap_with=cnf) as solver:
    # 1.1 call the solver for this formula:
    print('formula is', f'{"s" if solver.solve() else "uns"}atisfiable')
    # 1.2 the formula is satisfiable and so has a model:
    print('and the model is:', solver.get_model())
    # 2.1 apply the MiniSat-like assumption interface:
    print('formula is',
        f'{"s" if solver.solve(assumptions=[1, 2]) else "uns"}atisfiable',
        'assuming x1 and x2')
    # 2.2 the formula is unsatisfiable,
    # i.e. an unsatisfiable core can be extracted:
    print('and the unsatisfiable core is:', solver.get_core())