- Overview
- Tutorials
- Getting started
- Get started with Canton and the JSON Ledger API
- Get Started with Canton, the JSON Ledger API, and TypeScript
- Get started with Canton Network App Dev Quickstart
- Get started with smart contract development
- Basic contracts
- Test templates using Daml scripts
- Build the Daml Archive (.dar) file
- Data types
- Transform contracts using choices
- Add constraints to a contract
- Parties and authority
- Compose choices
- Handle exceptions
- Work with dependencies
- Functional programming 101
- The Daml standard library
- Test Daml contracts
- Next steps
- Application development
- Getting started
- Development how-tos
- Component how-tos
- Explanations
- References
- Application development
- Smart contract development
- Daml language cheat sheet
- Daml language reference
- Daml standard library
- DA.Action.State.Class
- DA.Action.State
- DA.Action
- DA.Assert
- DA.Bifunctor
- DA.Crypto.Text
- DA.Date
- DA.Either
- DA.Exception
- DA.Fail
- DA.Foldable
- DA.Functor
- DA.Internal.Interface.AnyView.Types
- DA.Internal.Interface.AnyView
- DA.List.BuiltinOrder
- DA.List.Total
- DA.List
- DA.Logic
- DA.Map
- DA.Math
- DA.Monoid
- DA.NonEmpty.Types
- DA.NonEmpty
- DA.Numeric
- DA.Optional
- DA.Record
- DA.Semigroup
- DA.Set
- DA.Stack
- DA.Text
- DA.TextMap
- DA.Time
- DA.Traversable
- DA.Tuple
- DA.Validation
- GHC.Show.Text
- GHC.Tuple.Check
- Prelude
- Smart contract upgrading reference
- Glossary of concepts
DA.Logic¶
Logic - Propositional calculus.
Data Types¶
data Formula t
A
Formula t
is a formula in propositional calculus with propositions of type t.
Proposition p
is the formula pFor a formula f,
Negation f
is ¬fConjunction [Formula t]
For formulas f1, ..., fn,
Conjunction [f1, ..., fn]
is f1 ∧ ... ∧ fnDisjunction [Formula t]
For formulas f1, ..., fn,
Disjunction [f1, ..., fn]
is f1 ∨ ... ∨ fninstance Applicative Formula
instance Eq t => Eq (Formula t)
Functions¶
- (&&&)
: Formula t -> Formula t -> Formula t
&&&
is the ∧ operation of the boolean algebra of formulas, to be read as "and"
- (|||)
: Formula t -> Formula t -> Formula t
|||
is the ∨ operation of the boolean algebra of formulas, to be read as "or"
- true
: Formula t
true
is the 1 element of the boolean algebra of formulas, represented as an empty conjunction.
- false
: Formula t
false
is the 0 element of the boolean algebra of formulas, represented as an empty disjunction.
- toNNF
-
toNNF
transforms a formula to negation normal form (see https://en.wikipedia.org/wiki/Negation_normal_form).
- toDNF
-
toDNF
turns a formula into disjunctive normal form. (see https://en.wikipedia.org/wiki/Disjunctive_normal_form).
- traverse
: Applicative f => (t -> f s) -> Formula t -> f (Formula s)
An implementation of
traverse
in the usual sense.
- zipFormulas
: Formula t -> Formula s -> Formula (t, s)
zipFormulas
takes to formulas of same shape, meaning only propositions are different and zips them up.
- substitute
: (t -> Optional Bool) -> Formula t -> Formula t
substitute
takes a truth assignment and substitutesTrue
orFalse
into the respective places in a formula.
- reduce
-
reduce
reduces a formula as far as possible by:Removing any occurrences of
true
andfalse
;Removing directly nested Conjunctions and Disjunctions;
Going to negation normal form.
- isBool
-
isBool
attempts to convert a formula to a bool. It satisfiesisBool true == Some True
andisBool false == Some False
. Otherwise, it returnsNone
.
- interpret
: (t -> Optional Bool) -> Formula t -> Either (Formula t) Bool
interpret
is a version oftoBool
that first substitutes using a truth function and then reduces as far as possible.
- substituteA
: Applicative f => (t -> f (Optional Bool)) -> Formula t -> f (Formula t)
substituteA
is a version ofsubstitute
that allows for truth values to be obtained from an action.
- interpretA
: Applicative f => (t -> f (Optional Bool)) -> Formula t -> f (Either (Formula t) Bool)
interpretA
is a version ofinterpret
that allows for truth values to be obtained form an action.