Determine whether an AIG is satisfiable.
(aig-sat aig &key (config 'satlink::*default-config*) (gatesimp '(aignet::default-gatesimp)) (transform-config 'nil)) → (mv status env)
This is a convenient, high level way to ask a SAT solver whether a Hons AIG is satisfiable. When the AIG is satisfiable, you get back a satisfying assignment in terms of the Hons AIG's variables.
This function should only fail if there is some problem with the SAT solver, e.g., it produces output that satlink does not understand.
The underlying mechanism takes advantage of aignet to carry out the
convert export dimacs AIG -------------> AIGNET -----------------> CNF -------> Solver || || || | || || || | interpret satisfying satisfying satisfying | output alist or <------- array or <----------- assign or <----' 'unsat' convert 'unsat' translate 'unsat'
We simply trust the SAT solver if it says
Function:
(defun aig-sat-fn (aig config gatesimp transform-config) (declare (xargs :guard (and (satlink::config-p config) (aignet::gatesimp-p gatesimp)))) (let ((__function__ 'aig-sat)) (declare (ignorable __function__)) (b* (((local-stobjs satlink::env$ aignet::sat-lits aignet) (mv status env satlink::env$ aignet::sat-lits aignet)) ((mv cnf ?lit vars aignet::sat-lits aignet) (aignet::aig->cnf aig aignet::sat-lits aignet :transform-config transform-config :gatesimp gatesimp)) ((mv result satlink::env$) (satlink::sat cnf satlink::env$ :config config)) ((unless (eq result :sat)) (mv result nil satlink::env$ aignet::sat-lits aignet)) (env (aignet::aig-cnf-vals->env satlink::env$ vars aignet::sat-lits aignet))) (mv :sat env satlink::env$ aignet::sat-lits aignet))))
Theorem:
(defthm aig-sat-when-sat (b* (((mv status env) (aig-sat aig :config config :transform-config transform-config :gatesimp gatesimp))) (implies (equal status :sat) (aig-eval aig env))))
Theorem:
(defthm aig-sat-when-unsat (b* (((mv status &) (aig-sat aig :config config :transform-config transform-config :gatesimp gatesimp))) (implies (aig-eval aig env) (not (equal status :unsat)))))