Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active January 14, 2019 10:04
Show Gist options
  • Save iegik/066a4fd8caa968bbf7a2a7272bad5f6e to your computer and use it in GitHub Desktop.
Save iegik/066a4fd8caa968bbf7a2a7272bad5f6e to your computer and use it in GitHub Desktop.

LOGICAL AND - a ∧ b (a && b) - is true if A and B are both true; else it is false.

LOGICAL OR - a ∨ b (a || b) - is true if A or B (or both) are true; if both are false, the statement is false.

LOGICAL XOR - a ⊕ b (a != b) - is true when either A or B, but not both, are true.

EQUIVALENCE - a ↔ b (a == b) - means A is true if B is true and A is false if B is false

LOGICAL NOT - ¬a (!a) - is true if and only if A is false.

IMPLICATION - a → b (!a || b) - means if A is true then B is also true; if A is false then nothing is said about B.

TERNARY - a ∧ b ∨ c (a ? b : c) -

a b a ∧ b a ∨ b a ⊕ b a ↔ b ¬a a → b
0 0 0 0 0 1 1 1
0 1 0 1 1 0 1 1
1 0 0 1 1 0 0 0
1 1 1 1 0 1 0 1

Association

Disjunctions and conjunctions are binary operations, meaning they only operate on two inputs

(a ∧ b) ∧ c = a ∧ (b ∧ c)
(a ∨ b) ∨ c = a ∨ (b ∨ c)
(a ⊕ b) ⊕ c = a ⊕ (b ⊕ c)

Distribution

a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c)
a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c)
a ∧ (b ⊕ c) = (a ∧ b) ⊕ (a ∧ c)

Ternary (If-Then-Else)

a ∧ b ∨ c = (a → b) ∧ (¬a → c)

Commutation

Any disjunction (||), conjunction (&&), or bicondition (===) can swap the order of its parts*.

a ∧ b = b ∧ a
a ∨ b = b ∨ a
a ⊕ b = b ⊕ a
a ↔ b = b ↔ a

DeMorgan’s Laws

¬(a ∨ b) = ¬a ∧ ¬b
¬(a ∧ b) = ¬a ∨ ¬b
¬¬a = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment