package logtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Logtk.CnfSource

Reduction to CNF and Simplifications

CNF allows to transition from a free-form AST (with statements containing formulas as TypedSTerm.t) into an AST using clauses and without some constructs such as "if/then/else" or "match" or "let". The output is more suitable for a Superposition-like prover.

There also are conversion functions to go from clauses that use TypedSTerm.t, into clauses that use the Term.t (hashconsed, and usable in unification, indexing, etc.).

We follow chapter 6 "Computing small clause normal forms" of the "handbook of automated reasoning" for the theoretical part.

A few notes:

In worst case, normal CNF transformation can lead to an exponential number of clauses, which is prohibitive. To avoid that, we use the Tseitin trick to name some intermediate formulas by introducing fresh symbols (herein named "proxies") and defining them to be equivalent to the formula they define.

This is done only if we estimate that adding the proxy will reduce the final number of clauses (See Estimation module).

Before doing CNF we remove all the high-level constructs such as pattern-matching and "let" by introducing new symbols and defining the subterm to eliminate using this new symbol (See Flatten module). It is important to capture variables properly in this phase (as in closure conversion).

Sourcetype term = TypedSTerm.t
Sourcetype form = TypedSTerm.t
Sourcetype type_ = TypedSTerm.t

See "computing small normal forms", in the handbook of automated reasoning. All transformations are made on curried terms and formulas.

Sourceexception Error of string
Sourceexception NotCNF of form
Sourceval miniscope : ?distribute_exists:bool -> form -> form

Apply miniscoping transformation to the term.

  • parameter distribute_exists

    see whether ?X:(p(X)|q(X)) should be transformed into (?X: p(X) | ?X: q(X)). Default: false

Sourcetype options =
  1. | DistributeExists
    (*

    if enabled, will distribute existential quantifiers over disjunctions. This can make skolem symbols smaller (smaller arity) but introduce more of them.

    *)
  2. | DisableRenaming
    (*

    disables formula renaming. Can re-introduce the worst-case exponential behavior of CNF.

    *)
  3. | InitialProcessing of form -> form
    (*

    any processing, at the beginning, before CNF starts

    *)
  4. | PostNNF of form -> form
    (*

    any processing that keeps negation at leaves, just after reduction to NNF. Its output must not break the NNF form (negation at root only).

    *)
  5. | PostSkolem of form -> form
    (*

    transformation applied just after skolemization. It must not break skolemization nor NNF (no quantifier, no non-leaf negation).

    *)

Options are used to tune the behavior of the CNF conversion.

Sourcetype clause = lit list

Basic clause representation, as list of literals

Sourceval clause_to_fo : ?ctx:Term.Conv.ctx -> clause -> Term.t SLiteral.t list
Sourcetype f_statement = (term, term, type_) Statement.t

A statement before CNF

Sourcetype c_statement = (clause, term, type_) Statement.t

A statement after CNF

Sourceval pp_f_statement : f_statement CCFormat.printer
Sourceval pp_c_statement : c_statement CCFormat.printer
Sourceval is_clause : form -> bool
Sourceval is_cnf : form -> bool

Main Interface

Sourceval cnf_of : ?opts:options list -> ?ctx:Skolem.ctx -> f_statement -> c_statement CCVector.ro_vector

Transform the statement into proper CNF; returns a list of statements, including type declarations for new Skolem symbols or formulas proxies. Options are used to tune the behavior.

Sourceval cnf_of_seq : ?opts:options list -> ?ctx:Skolem.ctx -> f_statement Iter.t -> c_statement CCVector.ro_vector
Sourceval type_declarations : c_statement Iter.t -> type_ ID.Map.t

Compute the types declared in the statement sequence

Conversions

Converts statements based on TypedSTerm into statements based on Term and Type

OCaml

Innovation. Community. Security.