.. index:: single: sat_program
.. _sat_program/0:

.. rst-class:: right

**object**

``sat_program``
===============

Canonical CNF statement validation, DIMACS source generation, and variable table computation.

| **Availability:** 
|    ``logtalk_load(sat(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-11-10

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Uses:**
|    :ref:`list <list/0>`
|    :ref:`type <type/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: serialize/2
.. _sat_program/0::serialize/2:

``serialize/2``
^^^^^^^^^^^^^^^

Serializes ground canonical CNF statements to DIMACS character codes, assigning sequential variable numbers by first occurrence.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``serialize(Statements,Codes)``
| **Mode and number of proofs:**
|    ``serialize(+list,-list(code))`` - ``one_or_error``

| **Exceptions:**
|    ``Statements`` is a partial list or a list with an element ``Statement`` which is a variable:
|        ``instantiation_error``
|    ``Statements`` is neither a partial list nor a list:
|        ``type_error(list,Statements)``
|    An element ``Statement`` of the list ``Statements`` is not a valid statement:
|        ``domain_error(sat_statement,Statement)``


------------

.. index:: serialize/4
.. _sat_program/0::serialize/4:

``serialize/4``
^^^^^^^^^^^^^^^

Serializes statements with origins and returns ``line(Start, End, Origin)`` source-map entries; the generated header occupies line 1.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``serialize(Statements,Origins,Codes,SourceMap)``
| **Mode and number of proofs:**
|    ``serialize(+list,+list,-list(code),-list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Statements`` is a partial list or a list with an element ``Statement`` which is a variable:
|        ``instantiation_error``
|    ``Statements`` is neither a partial list nor a list:
|        ``type_error(list,Statements)``
|    An element ``Statement`` of the list ``Statements`` is not a valid statement:
|        ``domain_error(sat_statement,Statement)``
|    ``Origins`` is a partial list or a list with an element ``Origin`` which is a variable:
|        ``instantiation_error``
|    ``Origins`` is neither a variable nor a list:
|        ``type_error(list,Origins)``
|    ``Origins`` has an element that is neither ``unknown`` nor a valid ``source(File, Start, End)`` term, or its length differs from ``Statements``:
|        ``domain_error(sat_origins,Origins)``


------------

.. index:: variables/2
.. _sat_program/0::variables/2:

``variables/2``
^^^^^^^^^^^^^^^

Returns the ordered ``Term-Number`` variable table that ``serialize/2`` and ``serialize/4`` assign by first occurrence across clause statements.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``variables(Statements,Variables)``
| **Mode and number of proofs:**
|    ``variables(+list,-list(pair))`` - ``one_or_error``

| **Exceptions:**
|    ``Statements`` is a partial list or a list with an element ``Statement`` which is a variable:
|        ``instantiation_error``
|    ``Statements`` is neither a partial list nor a list:
|        ``type_error(list,Statements)``
|    An element ``Statement`` of the list ``Statements`` is not a valid statement:
|        ``domain_error(sat_statement,Statement)``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

