> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# DA.Logic

> Reference documentation for Daml module DA.Logic.

Daml module

# DA.Logic

Logic - Propositional calculus.

Daml

Module
DA.Logic

Latest release
3.7.5

## Data Types

### `data Formula t`

A `Formula t` is a formula in propositional calculus with
propositions of type t.

Constructors:

* `Proposition t`

`Proposition p` is the formula p

* `Negation (Formula t)`

For a formula f, `Negation f` is ¬f

* `Conjunction [Formula t]`

For formulas f1, ..., fn, `Conjunction [f1, ..., fn]` is f1 ∧ ... ∧ fn

* `Disjunction [Formula t]`

For formulas f1, ..., fn, `Disjunction [f1, ..., fn]` is f1 ∨ ... ∨ fn

Instances:

* instance [`Action`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) [`Formula`](#type-da-logic-types-formula-34794)
* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) [`Formula`](#type-da-logic-types-formula-34794)
* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) [`Formula`](#type-da-logic-types-formula-34794)
* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `t` => [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) ([`Formula`](#type-da-logic-types-formula-34794) `t`)
* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) `t` => [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) ([`Formula`](#type-da-logic-types-formula-34794) `t`)
* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `t` => [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) ([`Formula`](#type-da-logic-types-formula-34794) `t`)

## Functions

### `&&&`

`&&&` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`&&&` is the ∧ operation of the boolean algebra of formulas, to
be read as "and"

### `|||`

`|||` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`|||` is the ∨ operation of the boolean algebra of formulas, to
be read as "or"

### `true`

`true` : [`Formula`](#type-da-logic-types-formula-34794) `t`

`true` is the 1 element of the boolean algebra of formulas,
represented as an empty conjunction.

### `false`

`false` : [`Formula`](#type-da-logic-types-formula-34794) `t`

`false` is the 0 element of the boolean algebra of formulas,
represented as an empty disjunction.

### `neg`

`neg` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`neg` is the ¬ (negation) operation of the boolean algebra of
formulas.

### `conj`

`conj` : \[[`Formula`](#type-da-logic-types-formula-34794) `t`] -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`conj` is a list version of `&&&`, enabled by the associativity
of ∧.

### `disj`

`disj` : \[[`Formula`](#type-da-logic-types-formula-34794) `t`] -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`disj` is a list version of `|||`, enabled by the associativity
of ∨.

### `fromBool`

`fromBool` : [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265) -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`fromBool` converts `True` to `true` and `False` to `false`.

### `toNNF`

`toNNF` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`toNNF` transforms a formula to negation normal form
(see [https://en.wikipedia.org/wiki/Negation\_normal\_form](https://en.wikipedia.org/wiki/Negation_normal_form)).

### `toDNF`

`toDNF` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`toDNF` turns a formula into disjunctive normal form.
(see [https://en.wikipedia.org/wiki/Disjunctive\_normal\_form](https://en.wikipedia.org/wiki/Disjunctive_normal_form)).

### `traverse`

`traverse` : [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) `f` => (`t` -> `f` `s`) -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> `f` ([`Formula`](#type-da-logic-types-formula-34794) `s`)

An implementation of `traverse` in the usual sense.

### `zipFormulas`

`zipFormulas` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `s` -> [`Formula`](#type-da-logic-types-formula-34794) (`t`, `s`)

`zipFormulas` takes to formulas of same shape, meaning only
propositions are different and zips them up.

### `substitute`

`substitute` : (`t` -> [`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`substitute` takes a truth assignment and substitutes `True` or
`False` into the respective places in a formula.

### `reduce`

`reduce` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Formula`](#type-da-logic-types-formula-34794) `t`

`reduce` reduces a formula as far as possible by:

1. Removing any occurrences of `true` and `false`;
2. Removing directly nested Conjunctions and Disjunctions;
3. Going to negation normal form.

### `isBool`

`isBool` : [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isBool` attempts to convert a formula to a bool. It satisfies
`isBool true == Some True` and `isBool false == Some False`.
Otherwise, it returns `None`.

### `interpret`

`interpret` : (`t` -> [`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> [`Either`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-types-either-56020) ([`Formula`](#type-da-logic-types-formula-34794) `t`) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`interpret` is a version of `toBool` that first substitutes using
a truth function and then reduces as far as possible.

### `substituteA`

`substituteA` : [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) `f` => (`t` -> `f` ([`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265))) -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> `f` ([`Formula`](#type-da-logic-types-formula-34794) `t`)

`substituteA` is a version of `substitute` that allows for truth
values to be obtained from an action.

### `interpretA`

`interpretA` : [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) `f` => (`t` -> `f` ([`Optional`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265))) -> [`Formula`](#type-da-logic-types-formula-34794) `t` -> `f` ([`Either`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-types-either-56020) ([`Formula`](#type-da-logic-types-formula-34794) `t`) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265))

`interpretA` is a version of `interpret` that allows for truth
values to be obtained form an action.

## Orphan Typeclass Instances

* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) `t` => [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) ([`Formula`](#type-da-logic-types-formula-34794) `t`)

* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) `t` => [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) ([`Formula`](#type-da-logic-types-formula-34794) `t`)

* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) `t` => [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) ([`Formula`](#type-da-logic-types-formula-34794) `t`)

* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) [`Formula`](#type-da-logic-types-formula-34794)

* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) [`Formula`](#type-da-logic-types-formula-34794)

* instance [`Action`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) [`Formula`](#type-da-logic-types-formula-34794)
