Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cheatsheets for CM1020 Discrete Mathemathics #22

Merged
merged 84 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6948b76
init dm personal dir
lamafab Oct 25, 2022
5573cf8
add set theory file
lamafab Oct 25, 2022
6476794
add set builder notation
lamafab Oct 25, 2022
6026ead
add section on powersets
lamafab Oct 25, 2022
c9debf1
add section on set operations
lamafab Oct 25, 2022
a55e602
generate PDF for set theory
lamafab Oct 25, 2022
d67dece
add chapter on universal set, compelement and laws
lamafab Oct 25, 2022
c6e394d
add laws and identities of sets
lamafab Oct 25, 2022
c42a0a1
add section on partition set
lamafab Oct 25, 2022
b743c12
generate pdf for universal set, complement and laws doc
lamafab Oct 25, 2022
941177f
fix typo
lamafab Oct 25, 2022
edb05e5
rename src file
lamafab Oct 25, 2022
53301a1
fix typo, generate PDFs
lamafab Oct 29, 2022
fbafe44
update README, reference PDFs
lamafab Oct 29, 2022
b0e05e0
add functions doc
lamafab Nov 1, 2022
7b39176
add function info pic to functions doc
lamafab Nov 1, 2022
aaf3043
expand injective, surjective and bijective functions
lamafab Nov 1, 2022
56efc56
add section on composition
lamafab Nov 2, 2022
1e5436b
section on inverses
lamafab Nov 2, 2022
d15d5ce
add section on injective/bijective/surjective proofs
lamafab Nov 2, 2022
8025902
add section on exponential and logarithmic functions
lamafab Nov 2, 2022
8e1eb66
expand section on floor or ceiling, convert phi to emptyset
lamafab Nov 2, 2022
5e1b4fc
restruct floor and ceiling section
lamafab Nov 2, 2022
cafa513
update PDFs
lamafab Nov 2, 2022
59af10a
fix typo, update PDF
lamafab Nov 2, 2022
96900c2
reference Propositional Logic in README
lamafab Nov 19, 2022
65b41e5
rename title
lamafab Nov 19, 2022
1723fd2
adjust sentence
lamafab Nov 19, 2022
e5bae75
track postulates of boolean algebra chapter
lamafab Dec 10, 2022
03698ae
add basic theorems to boolean algebra
lamafab Dec 10, 2022
8b98800
update README
lamafab Dec 10, 2022
ea6fdda
add section on boolean functions
lamafab Dec 10, 2022
842b5e7
generate pdf for boolean algebra
lamafab Dec 10, 2022
57d4f53
start logic gates chapter
lamafab Dec 10, 2022
07c2c20
add circuits to logic gates
lamafab Dec 10, 2022
d410e84
update README, generate pdf for logic gates
lamafab Dec 10, 2022
494792d
update pdf for boolean algebra
lamafab Dec 10, 2022
5041544
update logic gates pdf
lamafab Dec 10, 2022
487cee0
add simplification of circuits to logic gates
lamafab Dec 10, 2022
3245941
adjust widh of pictures
lamafab Dec 10, 2022
21a7f63
fix typo
lamafab Dec 10, 2022
46bd2bd
formatting
lamafab Dec 30, 2022
04f533d
update boolean algebra pdf
lamafab Dec 30, 2022
f15daf9
change Proof ref
lamafab Jan 10, 2023
92b1ac2
add graph chapter, track assets
lamafab Jan 10, 2023
913af14
expand walks, paths and other concepts
lamafab Jan 10, 2023
104c9f4
expand concepts
lamafab Jan 10, 2023
26d82f1
update transitive closure graph
lamafab Jan 10, 2023
8dcf913
update section levels
lamafab Jan 10, 2023
a3f1f4f
expand degree sequence of graphs section
lamafab Jan 12, 2023
567fbdf
track new assets
lamafab Jan 12, 2023
09b192f
adjust width of pictures in graph chapter
lamafab Jan 12, 2023
f8876b4
expand graph chapter, create PDF
lamafab Jan 12, 2023
99ae6b0
update README
lamafab Jan 12, 2023
83cd75c
create graph subdir for assets
lamafab Jan 12, 2023
6406058
start chapter on graph isomorphism
lamafab Jan 12, 2023
c77ca59
todo on dijkstra's algorithm
lamafab Jan 12, 2023
7503f58
create PDF for graph isomorphism
lamafab Jan 12, 2023
1e78b48
update README
lamafab Jan 12, 2023
3318ca8
add chapter on trees
lamafab Feb 7, 2023
64420a0
add section on spanning trees
lamafab Feb 7, 2023
e5f4c9a
add section on rooted trees
lamafab Feb 7, 2023
2564feb
update README
lamafab Feb 7, 2023
323d49f
add section on binary search trees
lamafab Feb 13, 2023
2b76af9
generate PDF for Trees
lamafab Feb 13, 2023
f8c6ec8
add chapter on Relations
lamafab Feb 13, 2023
b5c407e
update README
lamafab Feb 13, 2023
ad92a14
expand Matrix and Graph sections on Relations chapter
lamafab Feb 13, 2023
990ccf5
add second graph example
lamafab Feb 13, 2023
633862f
add section on properties
lamafab Feb 13, 2023
1b82101
add section on transitivity
lamafab Feb 13, 2023
661942a
generate PDF for relations
lamafab Feb 13, 2023
6557b7f
add chapter on equivalence relations & classes
lamafab Feb 15, 2023
beba527
add section on partial and total order
lamafab Feb 15, 2023
8923d54
expand Relation cheatsheet with more notes
lamafab Feb 17, 2023
a57c479
update README, generate PDFs for Relations and Equivalences
lamafab Feb 17, 2023
9124a57
update README
lamafab Feb 17, 2023
8d8ebdb
init Basics of Counting
lamafab Feb 17, 2023
129ed3e
add chapter on binomial coefficients
lamafab Feb 27, 2023
28e0be9
update README
lamafab Feb 27, 2023
0c98144
generate PDF for binomial coefficients
lamafab Feb 27, 2023
e427699
update README, remove TODOs
lamafab Mar 6, 2023
05cc6bb
regenerate all PDFs
lamafab Mar 6, 2023
bf22654
fix typo in README
lamafab Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.lama@pm.me>
: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.lama@pm.me>
: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