Skip to content

Commit

Permalink
vault backup: 2024-01-24 13:14:12
Browse files Browse the repository at this point in the history
  • Loading branch information
benjitusk committed Jan 24, 2024
1 parent 1d14c7e commit 017d579
Show file tree
Hide file tree
Showing 11 changed files with 3,489 additions and 24 deletions.
Binary file added docs/Torah and Tech Week Four.pdf
Binary file not shown.
Binary file added docs/Torah and Tech Week Three.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,111 @@ Since AVL-Search is $O(\log n)$, the worst case is $O(\log n)$.
The worst case is where $|\text{tree}_{h(k)}|=n$.
We need to delete from the AVL tree of size $n$ (height $\Theta(\log n)$).
Since AVL-Delete is $O(\log n)$, the worst case is $O(\log n)$.


### Question 4
#### Part A
```python
def search(HT,k):
index=hash(k)
curr=HT[i]
while(concat(curr.l.bits, i.bits, curr.r.bits) != k*k):
curr = cur.next
return curr.val
```

The solution is to calculate the square of the key, instead of taking the square root of the concatenated bits. While the concatenated bits do not equal the square of the key, we have not yet found the value.

#### Part B
The size of the index is $p$ bits, because the hash table has $2^p$ entries.
$b$ is the size of the key, therefore, $k^2$is $2b$ bits long.
The following calculations are referring to the size (in bits), not the literal value.
$2b=l+p+r$
$l+r=2b-p$
$2r=2b-p$ (because $l=r$)
We save space when $2r<b$
$2b-p<b$
${b<p}$
$\therefore$ We save memory space when $b<p$.

### Question 5

#### Linear Probing
| Index | Content | Probes |
| ---- | ---- | ---- |
| 0 | 15 | 2 |
| 1 | 1 | 1 |
| 2 | 18 | 1 |
| 3 | 34 | 2 |
| 4 | 68 | 1 |
| 5 | 51 | 3 |
| 6 | | |
| 7 | 39 | 1 |
| 8 | 72 | 1 |
| 9 | | |
| 10 | 122 | 1 |
| 11 | 43 | 1 |
| 12 | 26 | 3 |
| 13 | 13 | 1 |
| 14 | 14 | 1 |
| 15 | 31 | 1 |

Average number of probes is $\frac{20}{14}=1.428$

The expected runtime = $\Theta(1+\frac\alpha 2)$
In our case, this is $1+\frac{14}{16\cdot2}=\frac{23}{16}=1.4375$
The ratio is $\frac{20}{14}\div\frac{23}{16}=\frac{160}{161}=0.994$

#### Quadratic Probing
| Index | Content | Probes |
| ---- | ---- | ---- |
| 0 | 15 | 2 |
| 1 | 1 | 1 |
| 2 | 18 | 1 |
| 3 | 34 | 2 |
| 4 | 68 | 1 |
| 5 | | |
| 6 | 51 | 3 |
| 7 | 39 | 1 |
| 8 | 72 | 1 |
| 9 | 26 | 6 |
| 10 | 122 | 1 |
| 11 | 43 | 1 |
| 12 | | |
| 13 | 13 | 1 |
| 14 | 14 | 1 |
| 15 | 31 | 1 |

Average number of probes is $\frac{23}{14}=1.643$

The expected runtime = $\Theta(1+\frac\alpha 2)$
In our case, this is $1+\frac{14}{16\cdot2}=\frac{23}{16}=1.4375$
The ratio is $\frac{23}{14}\div\frac{23}{16}=\frac{16}{14}=1.143$

#### Double Hashing
| Index | Content | Probes |
| ---- | ---- | ---- |
| 0 | 15 | 2 |
| 1 | 1 | 1 |
| 2 | 18 | 1 |
| 3 | 51 | 1 |
| 4 | 68 | 1 |
| 5 | | |
| 6 | 26 | 1 |
| 7 | 34 | 2 |
| 8 | 72 | 1 |
| 9 | 43 | 2 |
| 10 | 122 | 1 |
| 11 | 39 | 3 |
| 12 | | |
| 13 | 13 | 1 |
| 14 | 14 | 1 |
| 15 | 31 | 1 |

Average number of probes is $\frac{19}{14}=1.357$

The expected runtime = $\Theta(1+\frac\alpha 2)$
In our case, this is $1+\frac{14}{16\cdot2}=\frac{23}{16}=1.4375$
The ratio is $\frac{19}{14}\div\frac{23}{16}=\frac{152}{161}=0.944$


10 changes: 5 additions & 5 deletions docs/Year II/Semester I/Discrete Mathematics/01. Sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- The **empty set** is the set containing no elements.
- Denoted as $\set{}$ or $\phi$ (Greek letter phi)
- It is a subset of *every* set, other than itself

#Discrete-vocab

> [!example] Set syntax and examples
>
Expand Down Expand Up @@ -95,7 +95,7 @@ We must show that both of the following are true:
*Dec. 31*

### Power Set
**Definition:** The **power set** of a set $S$ (denoted $\pset S$) is the set of all subsets of $S$.
**Definition:** The **power set** of a set $S$ (denoted $\pset S$) is the set of all subsets of $S$. #Discrete-vocab

> [!example] Power Set Examples
>
Expand All @@ -113,7 +113,7 @@ For any set $S$, $\phi\in\pset S$ and $S\in\pset S$.
> $\set{1}\in\pset{\set{1,2}}$, but $1\notin\pset{\set{1,2}}$
#### Power Set Theorem
For any finite set $S$, $|\pset S|=2^{|S|}$, where $|S|$ is the number of elements in $S$.
For any finite set $S$, $|\pset S|=2^{|S|}$, where $|S|$ is the number of elements in $S$. #Discrete-theorems

This means that the number of elements in the power set of a set is equal to $2$ raised to the number of elements in the set.

Expand All @@ -134,7 +134,7 @@ This means that the number of elements in the power set of a set is equal to $2$
- Explanation: The intersection of all intervals $[\frac1i,\frac1{i+1})$ for $i=1,2,3,\dots$ is the set $\set{0}$ because the only number that is in every interval is $0$.

### Cartesian Products
**Definition:** An **ordered pair** is a pair of elements $(a,b)$ in which the order of the elements matters. $(a,b)\not=(b,a)$.
**Definition:** An **ordered pair** is a pair of elements $(a,b)$ in which the order of the elements matters. $(a,b)\not=(b,a)$. #Discrete-vocab

**Definition:** An **ordered n-tuple** is an ordered list of $n$ elements $(a_1,a_2,\dots,a_n)$ in which the order of the elements matters. $(a_1,a_2,\dots,a_n)\not=(a_2,a_1,\dots,a_n)$.

Expand All @@ -143,7 +143,7 @@ Familiar examples of ordered pairs and ordered n-tuples:
- Point in space: $(x,y,z)$

**Definition:**
Let $A, B$ be sets. The **Cartesian product** of $A$ and $B$ (denoted $A\times B$) is the set of all ordered pairs $(a,b)$ where $a\in A$ and $b\in B$.
Let $A, B$ be sets. The **Cartesian product** of $A$ and $B$ (denoted $A\times B$) is the set of all ordered pairs $(a,b)$ where $a\in A$ and $b\in B$. #Discrete-vocab

Formally, $A\times B=\set{(a,b)\mid a\in A,\ b\in B}$

Expand Down
139 changes: 120 additions & 19 deletions docs/Year II/Semester I/Discrete Mathematics/02. Relations.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
*Dec. 31*
*Jan 7*
## Relations

Intuitively, a relation is a way of "comparing" two elements
1. $<$, $>$, $=$, $\leq$, $\geq$, among numbers
2. $A=$ set of people, $B=$ set of cities
- We can define a relation to hold between person $a\in A$ and city $b\in B$ if $a$ lives in $b$.
3. $A=$ set of people
- We can define a relation to hold between person $a_1\in A$ and person $a_2\in A$ if they share a family connection.

Formal **Definition:** Let $A,B$ be sets. A **relation** $R$ from $A$ to $B$ is a subset of $A\times B$.
**Formal Definition:**
Let $A,B$ be sets. A **relation** $R$ from $A$ to $B$ is a subset of $A\times B$.

_Yeah, that's it. The relation doesn't have to be anything meaningful. It's just a subset of the Cartesian product of the two sets._

Expand All @@ -20,7 +20,7 @@ _Yeah, that's it. The relation doesn't have to be anything meaningful. It's just
> 2. "greater than" relation: $R=\set{(2,1), (3,1), (3,2)}$
> 3. "arbitrary" relation: $R=\set{(1,1), (1,3), (2,1)}$
A relation $R$ from $A$ to itself (i.e. $R\sseq A\times A$) is called a **relation on $A$**.
A relation $R$ from $A$ to itself (i.e. $R\sseq A\times A$) is called a **relation on $A$**. #Discrete-vocab

For example, see the third example in the intuitive definition above.

Expand All @@ -34,10 +34,11 @@ For example, see the third example in the intuitive definition above.
- E.g, $A=\set{1,2,3}$, $B=\set{4,5,6}$, $R=$ "less than"
- $R=A\times B$ because every element of $A$ is less than every element of $B$

The ususal set operations can be applied to relations, e.g. union, intersection, complement, etc. since relations are just sets.
The usual set operations can be applied to relations, e.g. union, intersection, complement, etc. since relations are just sets.

### Inverse Relations
**Definition:** Let $R$ be a relation from $A$ to $B$. The **inverse relation** of $R$ (denoted $R^{-1}$) is the relation from $B$ to $A$ defined by $R^{-1}=\set{(b,a)\mid(a,b)\in R}$.
**Definition:**
Let $R$ be a relation from $A$ to $B$. The **inverse relation** of $R$ (denoted $R^{-1}$) is the relation from $B$ to $A$ defined by $R^{-1}=\set{(b,a)\mid(a,b)\in R}$. #Discrete-vocab

> [!example] Examples of Inverse Relations
>
Expand All @@ -50,11 +51,12 @@ The ususal set operations can be applied to relations, e.g. union, intersection,
### Composition of Relations
Suppose $R_1 \sseq A\times B$ and $R_2 \sseq B\times C$ are relations.

**Definition:** The **composition** of $R_1$ and $R_2$ (denoted $R_1\circ R_2$) is the relation from $A$ to $C$ defined by $R_1\circ R_2=\set{(a,c)\mid\exists b\in B\text{ s.t. }(a,b)\in R_1\text{ and }(b,c)\in R_2}$.
**Definition:**
The **composition** of $R_1$ and $R_2$ (denoted $R_1\circ R_2$) is the relation from $A$ to $C$ defined by $R_1\circ R_2=\set{(a,c)\mid\exists b\in B\text{ s.t. }(a,b)\in R_1\text{ and }(b,c)\in R_2}$.

> [!tldr] Compositions explained in English
>
> A composition of relations $R_1$ and $R_2$ is a new relation $R_1\circ R_2$ that contains all pairs $(a,c)$ where there exists some $b$ such that $(a,\boldsymbol{b})\in R_1$ and $(\boldsymbol{b},c)\in R_2$.
> A composition of relations $R_1$ and $R_2$ is a new relation $R_1\circ R_2$ that contains all pairs $(a,c)$ where there exists some $b$ such that $(a,\boldsymbol{b})\in R_1$ and $(\boldsymbol{b},c)\in R_2$. #Discrete-vocab
> [!example] Examples of common composed relations
>
Expand All @@ -70,15 +72,107 @@ Suppose $R_1 \sseq A\times B$ and $R_2 \sseq B\times C$ are relations.
- **Associative:** $(R_1\circ R_2)\circ R_3=R_1\circ(R_2\circ R_3)$

### Equivalence Relations
> [!error] Missing section
#### Partitions
**Definition:**
Let $A$ be any set. A **partition** $P$ of $A$ is a set of subsets of $A$:

$$P=\set{A_1,A_2,\dots,A_i,\dots,A_n}$$
such that two conditions are met: #Discrete-vocab
1. For all $i\not=j:A_i\cap A_j=\phi$
- Subsets in $P$ are disjoint
2. $\cup_i^nA_i=A$
- Every element of $A$ is in some subset of the partition

>[!example] Example of a partition
>
> Let $A=\set{1,2,3,4,5,6,7}$
> Let $A_1=\set{2,5}$
> Let $A_2=\set{1,3,6}$
> Let $A_3=\set{7}$
> Let $A_4=\set{4}$
>
> Then the partition $P$ of $A$ looks like this:
>
> ![[Excalidraw/02. Relations 2024-01-23 17.38.17.excalidraw]]
#### Equivalence Relations
**Definition** Given a partition $P$ of $A$, define a relation $R$ as follows:
$(a,b)\in R$ whenever $a,b$ belong to the same subset in the partition $P$.
#Discrete-vocab

In our *above* example, $(1,6)\in R$, $(1,2)\in R$, $(7,7)\in R$, $(7,6)\not\in R$.

> [!example] Example of an Equivalence Relation
>
> Let $A=\set{1,2,3,4}$
> Let the partition be defined as specified in this diagram:
> ![[Excalidraw/02. Relations 2024-01-23 17.46.05.excalidraw]]
>
> Then, $R=\set{(1,3),(3,1),(2,2),(4,4),(1,1),(3,3)}$
$R$ is called an *equivalence relation*, and we say that $R$ is *induced* by the partition $P$. #Discrete-vocab

Any relation $R$ on $A$ is:
- Reflexive
- Every $a\in A$ belongs to the same “cell” as itself
- Symmetric
- If $a$ is in $b$’s cell, then $b$ is in $a$’s cell
- Transitive
- If $a$ is in $b$’s cell, and $b$ is in $c$’s cell, then $a$ is in $c$’s cell
#### Equivalence Relation Theorem
Any relation $R$ on $A$ which is reflexive, symmetric, and transitive is an equivalence relation (induced by some partition of $A$).

I.e., we can “work backwards” from a relation satisfying these three properties to find the partition which induced it.
#Discrete-theorems

> [!example] Example of the Equivalence Relation Theorem
>
> $A=\Z$
> $R\subseteq \Z\times\Z$
> $R=\set{(a,b)\mid a-b \mod 5=0}$
> $(3,-2)\in R, (5,0)\in R, (-7,3)\in R, (3,13)\in R$
> $(1,2)\not\in R, (4,0)\not\in R, (2,-7)\not\in R, (8,8)\in R$
>
> **Claim:** $R$ is reflexive, symmetric, and transitive.
>
> **Proof:**
> 1. $\forall n\in\Z,n-n=0=0\cdot5$; hence $(n,n)\in R$
> 2. If $a-b=5k$ then $b-a=-5k=5\cdot(-k)$
> - If $(a,b)\in R$ then $(b,a)\in R$
> 3. If $a-b=5k$ and $b-c=5l$, then $a-c=(a-b)+(b-c)=5k+5l=5(k+l)\Rightarrow(a,c)\in R$
>
> Therefore, $R$ is an equivalence relation.
#### Equivalence Classes
**Definition:**
The cells of a partition (which induces $R$) are called the **equivalence classes** of $R$.

For each $a\in A$, $[a]$ means the equivalence class of $a$.
E.g., in the last example, $[3]=[-12]$ (because they are both two less than multiples of 5)

The set of all equivalence classes of $A$ in the relation $R$ is denoted $A/R$ (“$A$ modulo $R$”) and is called the *quotient set* of $R$. #Discrete-vocab

In the last example, $A/R=\set{[0],[1],[2],[3],[4],[5]}$

> [!example] Example of Quotient Sets
> $A=$ set of people
> $R$ is a relation on $A$: $(a,b)\in R$ when $a,b$ share last names.
>
> It’s easy to see that $R$ is reflexive, symmetric, and transitive, and hence is an equivalence relation.
>
>It’s also easy to see that each equivalence class corresponds to a family name.
>
>The quotient set $A/R$ is the set of all last names.

*Jan 14*
### Order Relations
**Definition:**
An order relation generalizes the familiar “orders” like ≤ or ≥ on sets of numbers. #Discrete-vocab Formally, a relation $R$ on a set $A$ is an **order relation** if it has three properties:
#### Properties of Order Relations
An order relation generalizes the familiar “orders” like ≤ or ≥ on sets of numbers.
Formally, a relation $R$ on a set $A$ is an **order relation** if it has three properties:

1. $R$ is reflexive
2. $R$ is transitive
3. $R$ is antisymmetric
3. $R$ is antisymmetric #Discrete-vocab
- i.e., if $(a,b)\in R$ and $(b,a)\in R$, then $a=b$
- $R$ cannot hold between different elements in both directions
- Note that this is **not** the same as being asymmetric
Expand All @@ -87,6 +181,7 @@ Formally, a relation $R$ on a set $A$ is an **order relation** if it has three p
If $R$ is an order relation, then we use the notation

$$a\leqslant_Rb$$
in place of using $aRb$ or $(a,b)\in R$.

> [!example] Examples of order relations
>
Expand All @@ -98,21 +193,27 @@ $$a\leqslant_Rb$$
> 4. Let $A=\N$.
> Define $R$ on $A$ as: $(a,b)\in R$ if $a|b$ ($a$ divides $b$).
Note that examples 1 and 2 are “stronger” orderings. They are called **total orders** because $\forall a \in A$, $\exists b$ s.t. either $(a,b)\in R$ or $(b,a)\in R$.
Another way to say this is $\forall a \in A,\exists b$ s.t. $(a,b)\in R\cup R^{-1}$
Examples 3 and 4 are **partial orders** because there exist at least two elements in $A$ that cannot be compared with each other.
**Definition:**
An order relation $R$ on a set $A$ is a **total order** if, for *every* $a_1,a_2\in A$, either $a_1\leq_Ra_2$ or $a_2\leq_Ra_1$ (or both, if $a=b$).
Otherwise, $R$ is called a **partial order**. #Discrete-vocab

Examples 1 and 2 above are examples of total orders, and examples 3 and 4 above are partial orders.

##### Hasse Diagrams
A partial order $R$ on a set $A$ can be illustrated using a **Hasse diagram**:
A partial order $R$ on a set $A$ can be illustrated using a **Hasse diagram**.

For example, $A={n|1≤n≤20}$, and $R$ is the divisibility relation (example 3 from above)

###### Property of HD
![[Excalidraw/02. Relations 2024-01-23 20.31.11.excalidraw]]

###### Property of Hasse Diagrams
We can get from $a_1$ to $a_2$ by moving up edges iff then $a_1\leq_Ra_2$
###### Rules of HD
1. All **minimal elements** go on the bottom.
- ($a_1 \in A$ is minimal if there does $\not\exists b\in A$ s.t. $b\leq_Ra$)
- If there is a single minimum element $a$, then $a$ is called a minimum in $R$.
- If there is a single minimum element $a$, then $a$ is called a minimum in $R$. #Discrete-vocab
- In the above example, $1$ is a minimum.
- If we delete $1$ from $A$, then $2,3,5,7,11,13,17,19$ are all minimal elements, but there is no *minimum*.
2. An edge exists from $a_1$ “goes up” to $a_2$ if:
1. $a_1 \not= a_2$
2. $a_1\leq_Ra_2$
Expand Down
28 changes: 28 additions & 0 deletions docs/Year II/Semester I/Torah and Tech/Torah and Tech Week Four.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*By Benji Tusk*

**Prohibited Sources (i) – The Status of the Stem Cells**

1. **Mere Water (מיא בעלמא):**
- Rabbi Zvi Ryzman, in his essay, argues that stem cells used in cultured meat should be considered as "mere water" and not actual meat.
- He bases this argument on the Talmudic concept that within the first forty days of gestation, a fetus is not considered a viable human life, akin to "mere water."
- The rationale is that until forty days, the fetus lacks sufficient development to be considered meat, and therefore, stem cells before this period might be viewed similarly.

2. **Objections to the 'Mere Water' Concept:**
- Rabbi Yaakov Ariel objects to this perspective. He argues that the growth of microscopic entities doesn't exempt them from being considered meat. While they may not be fit for consumption due to their size, their essence remains meat-like.
- Another objection suggests that the 'mere water' concept is only applicable when the forbidden substance is not present within the growing entity. Stem cells, on the other hand, maintain the imprint of their origin, potentially containing DNA from a non-kosher source.

3. **Comparison to Agricultural Produce:**
- Some suggest a comparison to "outgrowths of teruma," where the halachic status of a seed does not necessarily transfer to its produce. This principle is found in Mishna Terumot.
- The Mishna distinguishes between seeds that rot and disintegrate, nullifying the prohibition, and corms where the core remains for the next season, making their outgrowths prohibited.

4. **Rambam's Perspective on Growth:**
- Rambam's view is introduced, suggesting that the growth process changes the halachic status of the plant, even if the root does not disintegrate. This is relevant to the laws of teruma and untithed produce.
- Rabbi Ariel, however, contends that stem cells maintain the forbidden substance within their structure, potentially through the DNA code.

5. **The 'Mere Water' Concept and Abortion:**
- The concept of "mere water" is brought into the discussion of abortion. Some poskim debate whether a human fetus is considered 'mere water' up to forty days from conception, potentially allowing abortion up to that point or under special circumstances.
- Various poskim, such as Rabbi Yair Chayim Bacharach and Rabbi Moshe Feinstein, present differing views on the permissibility of abortion based on this concept.

**Conclusion:**
- The application of the 'mere water' concept to stem cells in the context of cultured meat is met with various objections. The presence of the forbidden substance and the potential impact of growth on the halachic status of the cells are central issues in this debate.
- The comparison to agricultural produce, Rambam's perspective on growth, and the application of 'mere water' to abortion further complicate the discussion, highlighting the intricate nature of applying Halacha to emerging technologies and ethical dilemmas.
Loading

0 comments on commit 017d579

Please sign in to comment.