Skip to content

Commit

Permalink
Cheatsheets for CM1020 Discrete Mathemathics (world-class#22)
Browse files Browse the repository at this point in the history
* init dm personal dir
* add set theory file
* add set builder notation
* add section on powersets
* add section on set operations
* generate PDF for set theory
* add chapter on universal set, compelement and laws
* add laws and identities of sets
* add section on partition set
* generate pdf for universal set, complement and laws doc
* fix typo
* rename src file
* fix typo, generate PDFs
* update README, reference PDFs
* add functions doc
* add function info pic to functions doc
* expand injective, surjective and bijective functions
* add section on composition
* section on inverses
* add section on injective/bijective/surjective proofs
* add section on exponential and logarithmic functions
* expand section on floor or ceiling, convert phi to emptyset
* restruct floor and ceiling section
* update PDFs
* fix typo, update PDF
* reference Propositional Logic in README
* rename title
* adjust sentence
* track postulates of boolean algebra chapter
* add basic theorems to boolean algebra
* update README
* add section on boolean functions
* generate pdf for boolean algebra
* start logic gates chapter
* add circuits to logic gates
* update README, generate pdf for logic gates
* update pdf for boolean algebra
* update logic gates pdf
* add simplification of circuits to logic gates
* adjust widh of pictures
* fix typo
* formatting
* update boolean algebra pdf
* change Proof ref
* add graph chapter, track assets
* expand walks, paths and other concepts
* expand concepts
* update transitive closure graph
* update section levels
* expand degree sequence of graphs section
* track new assets
* adjust width of pictures in graph chapter
* expand graph chapter, create PDF
* update README
* create graph subdir for assets
* start chapter on graph isomorphism
* todo on dijkstra's algorithm
* create PDF for graph isomorphism
* update README
* add chapter on trees
* add section on spanning trees
* add section on rooted trees
* update README
* add section on binary search trees
* generate PDF for Trees
* add chapter on Relations
* update README
* expand Matrix and Graph sections on Relations chapter
* add second graph example
* add section on properties
* add section on transitivity
* generate PDF for relations
* add chapter on equivalence relations & classes
* add section on partial and total order
* expand Relation cheatsheet with more notes
* update README, generate PDFs for Relations and Equivalences
* update README
* init Basics of Counting
* add chapter on binomial coefficients
* update README
* generate PDF for binomial coefficients
* update README, remove TODOs
* regenerate all PDFs
* fix typo in README
  • Loading branch information
lamafab authored Mar 6, 2023
1 parent 9548df9 commit cd1ac5d
Show file tree
Hide file tree
Showing 82 changed files with 2,119 additions and 0 deletions.
78 changes: 78 additions & 0 deletions level-4/discrete-mathematics/student-notes/fabio-lama/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# About

Listed here is a collection of cheatsheet by topic. Those cheatsheets do not
explain the topics in depth, but rather serve as quick lookup documents.
Therefore, the course material provided by the lecturer should still be studied
and understood. Not everything that is tested at the mid-terms or final exams is
covered and the Author does not guarantee that the cheatsheets are free of
errors.

* [Set Theory](./cheatsheet_set_theory.pdf)
* [Universal Set, Complement and Laws](./cheatsheet_universal_set_complement_laws.pdf)
* [Functions](./cheatsheet_functions.pdf)
* [Propositional & First-order Logic](/level-4/fundamentals-of-computer-science/student-notes/fabio-lama/cheatsheet_propositional_logic.pdf)
* (covered in the Authors _Fundamentals of Computer Science_ module notes)
* [Postulates of Boolean Algebra](./cheatsheet_postulates_boolean_algebra.pdf)
* [Logic Gates](./cheatsheet_logic_gates.pdf)
* [Proofs](/level-4/fundamentals-of-computer-science/student-notes/fabio-lama/cheatsheet_proofs.pdf)
* (covered in the Authors _Fundamentals of Computer Science_ module notes)
* [Graph Theory](./cheatsheet_graphs.pdf)
* [Graph Theory: Isomorphism](./cheatsheet_graphs_isomorphism.pdf)
* [Trees](./cheatsheet_trees.pdf)
* [Relations](./cheatsheet_relations.pdf)
* [Equivalence Relations & Classes](./cheatsheet_equivalence.pdf)
* [Combinatorics](/level-4/computational-mathematics/student-notes/fabio-lama/cheatsheet_probability_combinatorics.pdf)
* (covered in the Authors _Computational Mathematics_ module notes)
* [Binomial Coefficients & Identities](./cheatsheet_binomial_coefficients.pdf)

# Building

_NOTE_: This step is only necessary if you chose to modify the base documents.

The base documents are written in [AsciiDoc](https://asciidoc.org/) and can be
found in the `src/` directory.

The following dependencies must be installed (Ubuntu):

```console
$ apt install -y ruby-dev wkhtmltopdf
$ gem install asciidoctor
$ chmod +x build.sh
```

To build the documents (PDF version):

```console
$ ./build.sh pdf
```

Optionally, for the HTML version:

```console
$ ./build.sh html
```

and for the PNG version:

```console
$ ./build.sh png
```

The generated output can be deleted with `./build.sh clean`.

# Disclaimer

The Presented Documents ("cheatsheets") by the Author ("Fabio Lama") are
summaries of specific topics. The term "cheatsheet" implies that the Presented
Documents are intended to be used as learning aids or as references for
practicing and does not imply that the Presented Documents should be used for
inappropriate practices during exams such as cheating or other offenses.

The Presented Documents are heavily based on the learning material provided by
the University of London, respectively the VLeBooks Collection database in the
Online Library and the material provided on the Coursera platform.

The Presented Documents may incorporate direct or indirect definitions,
examples, descriptions, graphs, sentences and/or other content used in those
provided materials. **At no point does the Author present the work or ideas
incorporated in the Presented Documents as their own.**
77 changes: 77 additions & 0 deletions level-4/discrete-mathematics/student-notes/fabio-lama/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# Because `make` sucks.

gen_html() {
# Remove suffix and prefix
FILE=$1
OUT=${FILE%.adoc}
HTML_OUT="cheatsheet_${OUT}.html"

asciidoctor $FILE -o ${HTML_OUT}
}

# Change directory to src/ in order to have images included correctly.
cd "$(dirname "$0")/src/"

case $1 in
html)
for FILE in *.adoc
do
# Generate HTML file.
gen_html ${FILE}
done

# Move up from src/
mv *.html ../
;;
pdf)
for FILE in *.adoc
do
# Generate HTML file.
gen_html ${FILE}

# Convert HTML to PDF.
PDF_OUT="cheatsheet_${OUT}.pdf"
wkhtmltopdf \
--enable-local-file-access \
--javascript-delay 2000\
$HTML_OUT $PDF_OUT
done

# Move up from src/
mv *.pdf ../

# Cleanup temporarily generated HTML files.
rm *.html > /dev/null 2>&1
;;
png | img)
for FILE in *.adoc
do
# Generate HTML file.
gen_html ${FILE}

# Convert HTML to PNG.
IMG_OUT="cheatsheet_${OUT}.png"
wkhtmltopdf \
--enable-local-file-access \
--javascript-delay 2000\
$HTML_OUT $IMG_OUT
done

# Move up from src/
mv *.png ../

# Cleanup temporarily generated HTML files.
rm *.html > /dev/null 2>&1
;;
clean)
rm *.html > /dev/null 2>&1
rm *.png > /dev/null 2>&1
rm ../*.html > /dev/null 2>&1
rm ../*.png > /dev/null 2>&1
;;
*)
echo "Unrecognized command"
;;
esac
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
= Cheatsheet - Binomial Coefficients & Identities
Fabio Lama <fabio[email protected]>
:description: Module: CM1020- Discrete Mathematics, started 25. October 2022
:doctype: article
:sectnums: 4
:stem:

== Binomial Theorem

An expression consisting of two terms, connected by a stem:[+] or stem:[-] sign,
is called a **binomial expression**. As we increase the power of binomials,
expanding them becomes more and more complicated:

[stem]
++++
(x+y)^1 = x + y\
(x+y)^2 = x^2 + 2xy + y^2\
(x+y)^3 = x^3 + 3x^2y + 3xy^2 + y^3\
...
++++

The **binomial theorem** helps us to simplify this expansion. Let stem:[x] and
stem:[y] be variables, and stem:[n] a non-negative integer. The expansion of
stem:[(x+y)^n] can be formalized as:

[stem]
++++
(x+y)^n = sum_(k=0)^n ((n),(k)) x^k y^(n-k)
++++

The **binomial coefficients** are the coefficients in the binomial theorem and
denoted as:

[stem]
++++
((n),(k)) = (n!)/(k!(n-k)!)
++++

Here we say **"n choose k"**.

For example:

> What is the coefficient of stem:[x^8 y^7] in the expansion of stem:[(3x
-y)^15].

We can view the expression as stem:[(3x+ (-y))^15]. By the binomial theorem:

[stem]
++++
(3x+ (-y))^15 = sum_(k=0)^15 ((15),(k)) (3x)^k (-y)^(15-k)
++++

The coefficient of stem:[x^8 y^7] in the expansion is obtained when stem:[k=8]:

[stem]
++++
((15),(8)) (3)^8 (-1)^7 = -3^8 (15!)/(8!7!)
++++

=== Pascal's Identity

If stem:[n] and stem:[k] are integers with stem:[n >= k >= 1], then:

[stem]
++++
((n),(k)) + ((n),(k-1)) = ((n+1),(k))
++++

=== Pascal's Triangle

**Pascals' triangle** is a number triangle with numbers arranged in staggered rows
such that **stem:[a_(n,r)] is the binomial coefficient stem:[((n),(r))]**.

image::./assets/pascals_triangle.png[align=center, width=600]
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
= Cheatsheet - Equivalence Relations & Classes
Fabio Lama <fabio[email protected]>
:description: Module: CM1020- Discrete Mathematics, started 25. October 2022
:doctype: article
:sectnums: 4
:stem:

NOTE: You should read the cheatsheet on _Relations_, too.

== Definitions

=== Equivalence Relation

Let stem:[R] be a relation of elements on set stem:[S]. stem:[R] is an
**equivalence relation** if and only if stem:[R] is **reflexive**, **symmetric**
and **transitive**.

=== Equivalence Classes

Let stem:[R] be an **equivalence relation** on a set stem:[S]. Then, the
**equivalence class** of stem:[a in S] is the **subset** of stem:[S] containing
all the **elements related** to stem:[a] through stem:[R]:

[stem]
++++
[a] = {x: x in S " and " xRa}
++++

For example:

[stem]
++++
S = {1, 2, 3, 4, 5}\
R = {(a, b) in S^2 | a - b " is an even number" }
++++

The set stem:[R] has two equivalence classes:

[stem]
++++
[1] = [3] = [5] = {1, 3, 5}\
[2] = [4] = {2, 4}
++++

== Partial & Total Order

Let stem:[R] be a relation on elements in a set stem:[S]. stem:[R] is a
**partial order** if and only if stem:[R] is **reflexive**, **anti-symmetric**
and **transitive**.

Additionally, stem:[R] is a **total** order if and only if:

* stem:[R] is a **partial order**.
* stem:[AA (a, b) in S] we have **either** stem:[aRb] **or** stem:[bRa].

For example, the following relation is a total order:

[stem]
++++
R = {(a, b) in ZZ^2 | a <= b}
++++
Loading

0 comments on commit cd1ac5d

Please sign in to comment.