Operators

Operators accept Bools, truth values, and propositions. However, boolean values cannot interoperate with truth values and propositions. Operations on boolean values is always eagerly evaluated, whereas operations on truth values and propositions is evaluated according to the operator's Evaluation trait.

Info

Operations on propositions that have each been normalized eagerly evaluate to another normalized proposition. This behavior is likely to be removed in v0.4.

Typing symbols with tab completion is performed by typing \, followed by the given characters, and then the [TAB] key. For example, is typed with \top[TAB]. See also Tab Completion and Unicode Input.

Operator associativity determines how operators with the same precedence group their operands. For example, is left associative. Therefore, p ∧ q ∧ r is equivalent to (p ∧ q) ∧ r. Operator precedence determines how expressions with distinct operators are grouped together. Higher precedence operators will group their operands before lower precedence operators. For example, has a higher precedence than . Therefore, p ∨ q ∧ r is equivalent to p ∨ (q ∧ r), even though both operators are left associative. See also Julia's documentation on Operator Precedence and Associativity.

Info

This associativity is determined by Julia's parser and is distinct from the Associativity trait used to specify the direction an operator folds.

Info

== has a precedence of 7, which is higher than that of several binary operators. For those cases, you may need to use parentheses. For example, p → q == r parses as p → (q == r) rather than (p → q) == r.

NameSymbolTab CompletionAssociativityPrecedence
tautology\topnone0
contradiction\botnone0
identical𝒾\scrinone0
not¬\negright0
and\wedgeleft12
or\veeleft11
imply\rightarrowright4
exclusive_or\nleftrightarrowright4
converse_imply\leftarrowright4
not_and\uparrowright15
not_or\downarrowright15
not_imply\nrightarrowright4
not_exclusive_or\leftrightarrowright4
not_converse_imply\nleftarrowright4
conjunction\bigwedgenone0
disjunction\bigveenone0

Nullary Operators

PAndQ.tautologyConstant
tautology()
⊤()

Logical true operator.

can be typed by \top[TAB].

Examples

julia> print_table(⊤)
┌───┐
│ ⊤ │
├───┤
│ ⊤ │
└───┘
source
PAndQ.contradictionConstant
contradiction()
⊥()

Logical false operator.

can be typed by \bot[TAB].

Examples

julia> print_table(⊥)
┌───┐
│ ⊥ │
├───┤
│ ⊥ │
└───┘
source

Unary Operators

PAndQ.identicalConstant
identical(p)
𝒾(p)

Logical identity operator.

Examples

julia> @atomize print_table(𝒾(p))
┌───┐
│ p │
├───┤
│ ⊤ │
│ ⊥ │
└───┘
source
PAndQ.notConstant
not(p)
¬p

Logical negation operator.

¬ can be typed by \neg[TAB].

Examples

julia> @atomize print_table(¬p)
┌───┬────┐
│ p │ ¬p │
├───┼────┤
│ ⊤ │ ⊥  │
│ ⊥ │ ⊤  │
└───┴────┘
source

Binary Operators

PAndQ.andConstant
and(p, q)
p ∧ q

Logical conjunction operator.

can be typed by \wedge[TAB].

Examples

julia> @atomize print_table(p ∧ q)
┌───┬───┬───────┐
│ p │ q │ p ∧ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊤     │
│ ⊥ │ ⊤ │ ⊥     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊥     │
│ ⊥ │ ⊥ │ ⊥     │
└───┴───┴───────┘
source
PAndQ.orConstant
or(p, q)
p ∨ q

Logical disjunction operator.

can be typed by \vee[TAB].

Examples

julia> @atomize print_table(p ∨ q)
┌───┬───┬───────┐
│ p │ q │ p ∨ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊤     │
│ ⊥ │ ⊤ │ ⊤     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊤     │
│ ⊥ │ ⊥ │ ⊥     │
└───┴───┴───────┘
source
PAndQ.implyConstant
imply(p, q)
p → q

Logical implication operator.

can be typed by \rightarrow[TAB].

Examples

julia> @atomize print_table(p → q)
┌───┬───┬───────┐
│ p │ q │ p → q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊤     │
│ ⊥ │ ⊤ │ ⊤     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊥     │
│ ⊥ │ ⊥ │ ⊤     │
└───┴───┴───────┘
source
PAndQ.exclusive_orConstant
exclusive_or(p, q)
p ↮ q

Logical exclusive disjunction operator.

can be typed by \nleftrightarrow[TAB].

Examples

julia> @atomize print_table(p ↮ q)
┌───┬───┬───────┐
│ p │ q │ p ↮ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊥     │
│ ⊥ │ ⊤ │ ⊤     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊤     │
│ ⊥ │ ⊥ │ ⊥     │
└───┴───┴───────┘
source
PAndQ.converse_implyConstant
converse_imply(p, q)
p ← q

Logical converse implication operator.

can be typed by \leftarrow[TAB].

Examples

julia> @atomize print_table(p ← q)
┌───┬───┬───────┐
│ p │ q │ p ← q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊤     │
│ ⊥ │ ⊤ │ ⊥     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊤     │
│ ⊥ │ ⊥ │ ⊤     │
└───┴───┴───────┘
source
PAndQ.not_andConstant
not_and(p, q)
p ↑ q

Logical non-conjunction operator.

can be typed by \uparrow[TAB].

Examples

julia> @atomize print_table(p ↑ q)
┌───┬───┬───────┐
│ p │ q │ p ↑ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊥     │
│ ⊥ │ ⊤ │ ⊤     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊤     │
│ ⊥ │ ⊥ │ ⊤     │
└───┴───┴───────┘
source
PAndQ.not_orConstant
not_or(p, q)
p ↓ q

Logical non-disjunction operator.

can be typed by \downarrow[TAB].

Examples

julia> @atomize print_table(p ↓ q)
┌───┬───┬───────┐
│ p │ q │ p ↓ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊥     │
│ ⊥ │ ⊤ │ ⊥     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊥     │
│ ⊥ │ ⊥ │ ⊤     │
└───┴───┴───────┘
source
PAndQ.not_implyConstant
not_imply(p, q)
p ↛ q

Logical non-implication operator.

can be typed by \nrightarrow[TAB].

Examples

julia> @atomize print_table(p ↛ q)
┌───┬───┬───────┐
│ p │ q │ p ↛ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊥     │
│ ⊥ │ ⊤ │ ⊥     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊤     │
│ ⊥ │ ⊥ │ ⊥     │
└───┴───┴───────┘
source
PAndQ.not_exclusive_orConstant
not_exclusive_or(p, q)
p ↔ q

Logical exclusive non-disjunction operator.

can be typed by \leftrightarrow[TAB].

Examples

julia> @atomize print_table(p ↔ q)
┌───┬───┬───────┐
│ p │ q │ p ↔ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊤     │
│ ⊥ │ ⊤ │ ⊥     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊥     │
│ ⊥ │ ⊥ │ ⊤     │
└───┴───┴───────┘
source
PAndQ.not_converse_implyConstant
not_converse_imply(p, q)
p ↚ q

Logical converse non-implication operator.

can be typed by \nleftarrow[TAB].

Examples

julia> @atomize print_table(p ↚ q)
┌───┬───┬───────┐
│ p │ q │ p ↚ q │
├───┼───┼───────┤
│ ⊤ │ ⊤ │ ⊥     │
│ ⊥ │ ⊤ │ ⊤     │
├───┼───┼───────┤
│ ⊤ │ ⊥ │ ⊥     │
│ ⊥ │ ⊥ │ ⊥     │
└───┴───┴───────┘
source

Nary Operators

PAndQ.conjunctionConstant
conjunction(ps)
⋀(ps)

Equivalent to fold(𝒾, (∧) => ps).

can be typed by \bigwedge[TAB].

See also identical, and, and fold.

Examples

julia> ⋀(())
⊤

julia> @atomize ⋀((p, q, r, s))
((p ∧ q) ∧ r) ∧ s
source
PAndQ.disjunctionConstant
disjunction(ps)
⋁(ps)

Equivalent to fold(𝒾, (∨) => ps).

can be typed by \bigvee[TAB].

See also identical, or, and fold.

Examples

julia> ⋁(())
⊥

julia> @atomize ⋁((p, q, r, s))
((p ∨ q) ∨ r) ∨ s
source

Utilities

PAndQ.foldFunction
fold(f, pairs...)

A generalization of mapreduce with an arbitrary number of nested folds and traits to determine each operator's Associativity and initial_value.

The function f must accept as many parameters as there are pairs. Each pair must be a two element iterable where the first element is a binary operator and the second element is an iterable to be folded over.

Given a single pair, this function is similar to mapreduce and other similar functions. Giving additional pairs will generalize the following pattern:

mapreduce(a, xs) do x
    mapreduce(b, ys) do y
        ...
    end
end

This can be rewritten as:

fold(a => xs, b => ys, ...) do x, y, ...
    ...
end

Examples

julia> fold(⊤)
⊤

julia> @atomize fold(¬, (∧) => (p, q))
¬p ∧ ¬q

julia> @atomize fold(↔, (∧) => (p, q), (∨) => (r, s))
((p ↔ r) ∨ (p ↔ s)) ∧ ((q ↔ r) ∨ (q ↔ s))
source