CMSI 2820

CMSI 2820: Discrete Mathematics Cheat Sheet

Quick reference guide for course material. Sections unlock when homework is assigned.

Useful Terminal Commands

Git Commands

CommandDescriptionExample
git add [file/directory/path]Add a file/directory to the staging area. Use "." to add all changes currently in the working directory.git add .git add farm.pygit add src/
git commit -m "[commit message]"Commit changes to the repository. The -m flag is used to add a commit message to the commit and avoid the custom terminal interface.git commit -m "Completed HW1! 🎉"git commit -m "Fixed bug in farm.py"
git pushPush changes to the remote repository. This will update GitHub's cloud copy of the repository with the changes you have made locally.git push
git pullPull changes from the remote repository. This will update your local copy of the repository with the changes that have been made to the cloud repository.git pull

Python Commands

CommandDescriptionExample
python -m pytestRun the unit tests for the current project.python -m pytest
python [file.py]Run the file.py file. On MacOS, you may need to use `python3` instead of `python`.python proceedings.pypython3 test_farm.py
python -m pip install [package]Install a package using Python's Package Manager.python -m pip install pytestpython -m pip install numpy

Logic

Logical Operators

OperatorSymbolMeaningExample
Negation¬p or ~pNOT pIf p is true, ¬p is false
Conjunctionp ∧ qp AND qTrue only if both are true
Disjunctionp ∨ qp OR qTrue if at least one is true
Implicationp → qIf p then qFalse only if p is true and q is false
Biconditionalp ↔ qp if and only if qTrue if both have same truth value

Key Logical Equivalences

  • ¬(¬p) ≡ p (Double Negation)
  • p ∧ q ≡ q ∧ p (Commutative)
  • ¬(p ∧ q) ≡ ¬p ∨ ¬q (De Morgan's Laws)
  • p → q ≡ ¬p ∨ q (Implication)