Skip to content

Commit

Permalink
kb autocommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jemoka committed Jan 30, 2025
1 parent 49439aa commit e0aea77
Show file tree
Hide file tree
Showing 22 changed files with 646 additions and 5 deletions.
58 changes: 58 additions & 0 deletions content/posts/KBha_library_of_languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
+++
title = "A Library of Languages"
author = ["Houjun Liu"]
draft = false
+++

## PERFECT-MATCHING {#perfect-matching}

Given a bipartite graph \\(G = \qty(U,V,E)\\), is there a perfect matching (a one to one correspondence between \\(U\\) and \\(V\\) nodes)?

This is in both [NP]({{< relref "KBhnon_polynomial_time.md" >}}) and [coNP]({{< relref "KBhconp.md" >}})

But, [PERFECT-MATCHING](#perfect-matching) is in \\(P\\)


### NP trivial {#np-trivial}

I hand you the matching


### Not Hall's Theorem {#not-hall-s-theorem}

**Sufficient**: Suppose \\(S \subseteq U\\), consider \\(N\qty(S) \subseteq V\\), the [neighborhood]({{< relref "KBhstructure_learning.md#local-graph-search" >}}) of \\(S\\) is \\(|N(s)|< |S|\\), then there is no perfect matching.

Sketch: suppose for contradiction there _is_ a matching, but there would be not enough space to assign everyone in \\(S\\) a deduplicated match.


### Hall's Theorem {#hall-s-theorem}

**Necessary**: if \\(G = \qty(U, V, E)\\) has no perfect matching, then such an \\(S\\) from [Not Hall's Theorem](#not-hall-s-theorem) must exist.


## PRIMES {#primes}

"very prime has a succinct certificate"

\begin{equation}
\text{PRIMES} : \qty {A \mid A\text{ is prime}}
\end{equation}

The certificate?

\begin{equation}
A \text{ prime} \Leftrightarrow \exists 1 < b < A : B, B^{2}, \dots, B^{A\*2} \not \cong \ \text{mod}\ A
\end{equation}

So \\(\text{PRIMES} \in \text{NP}\\)


## FACTORING {#factoring}

\begin{equation}
\text{FACTORING} = \qty {X, A, B \mid \text{X has a prime factor $\in [A,B]$}}
\end{equation}

\\(\text{FACTORING} \in NP\\) certificate: just give the prime factor

\\(\text{FACTORING} \in \text{coNP}\\) certificate: give the prime factorization of \\(X\\); verifier check that these numbers do multiply to \\(x\\), check that none of these numbers are in \\([A,B]\\)
2 changes: 2 additions & 0 deletions content/posts/KBhcomplexity_theory_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ draft = false
- [SU-CS254 JAN132025]({{< relref "KBhsu_cs254_jan1032025.md" >}})
- [SU-CS254 JAN152025]({{< relref "KBhsu_cs254_jan152025.md" >}})
- [SU-CS254 JAN222025]({{< relref "KBhsu_cs254_jan222025.md" >}})
- [SU-CS254 JAN272025]({{< relref "KBhsu_cs254_jan272025.md" >}})
- [SU-CS254 JAN292025]({{< relref "KBhsu_cs254_jan292025.md" >}})


## Logistics {#logistics}
Expand Down
21 changes: 19 additions & 2 deletions content/posts/KBhconp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ draft = false
[coNP]({{< relref "KBhconp.md" >}}) is the set:

\begin{equation}
\text{coNP}= \qty {L \mid \neg L \in NP}
\text{coNP}= \qty {\neg L \mid L \in NP}
\end{equation}

meaning, a language in coNP is of the shape "for every y of |x|^k length, we have" (because NP is "for some y of |x|^k length, we have", and negative of NP means "for every y of |x|^k length, we don't have" which is coNP)
"\\(L\\) is in [coNP]({{< relref "KBhconp.md" >}}) if there exists a poly-time verifier for the "no" instances of this language". Formally:

\begin{equation}
L \in \text{coNP} \Leftrightarrow \exists \text{polytime} V s.t. x \in L: \exists w \in \qty {0,1}^{\text{poly}\qty(x)}, V\qty(x,w) = 1
\end{equation}

Some [coNP]({{< relref "KBhconp.md" >}}) stuff: [UNSAT]({{< relref "KBhunsat.md" >}}), NOT-3COL, etc.


## \\(P \subseteq coNP\\) {#p-subseteq-conp}
Expand All @@ -19,6 +25,17 @@ Because we just invert the judgments after running \\(P\\) to get the whole set.

Meaning: recall that \\(L \in P \implies \neg L \in P \implies \neg L \in NP \implies L \in coNP\\).

"Take \\(\text{P} \subseteq \text{NP}\\), 'co' both sides


## if \\(\text{P}= \text{NP}\\), then \\(\text{NP} = \text{coNP}\\) {#if-text-p-text-np-then-text-np-text-conp}

\begin{equation}
L \in \text{NP} \underbrace{\implies}\_{\text{(given)}}\ L \in \text{P} \implies L \in \text{coNP}
\end{equation}

More importantly, this means that \\(\text{NP} \neq \text{coNP}\\) we see that the contrapositive of this statement implies \\(\text{P} \neq \text{NP}\\).


## coNP complete {#conp-complete}

Expand Down
19 changes: 19 additions & 0 deletions content/posts/KBhfalsification.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,22 @@ Let's use [monte-carlo tree search]({{< relref "KBhmonte_carlo_tree_search.md" >
- no! select a new node which _minimizes_ \\(Q\_{\text{child}} - c \sqrt{ \frac{\log N}{N\_{\text{child}}}}\\), which is the [Lower Confidence Bound Exploration]({{< relref "KBhsu_cs361_may072024.md#lower-confidence-bound-exploration" >}}); the reason why we are picking **lowest** is because we want to minimize \\(Q\\), instead of [UCB 1]({{< relref "KBhdirected_exploration.md#ucb-1" >}}) which is trying to maximize \\(Q\\)

How do we estimate \\(Q\\)? We can do whatever we want; for instance, we can perform a bunch of roll-outs and estimate the robustness.


#### reinforcement learning falsification {#reinforcement-learning-falsification}

Technically, falsification is just RL:

- system =&gt; reward to adversary
- adversary =&gt; action to system

Most RL algorithms are designed to be very sample efficient, which means we can find failures rather quickly.

Using [MCTS]({{< relref "KBhmonte_carlo_tree_search.md" >}}) or [reinforcement learning]({{< relref "KBhreinforcement_learning.md" >}}) to search for the most likely failure is called **adaptive stress testing**.


## how to pick a falsification method? {#how-to-pick-a-falsification-method}

- if failure is easy to come by, just do [direct falsification](#direct-falsification)
- if you could compute the gradient, then do that
- otherwise, do black box approaches / population approaches / etc.
106 changes: 106 additions & 0 deletions content/posts/KBhinterpolation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
+++
title = "interpolation"
author = ["Houjun Liu"]
draft = false
+++

[nyquist limit]({{< relref "KBhsu_engr76_apr302024.md#lossless-sampling" >}}) is great and all, but I really don't want to wait for all \\(T\\) to be able to sample all the necessary terms to solve for every \\(a\_{j},b\_{j}\\) before we can reconstruct our signal.

So, even if we got our sequence of \\(\frac{1}{2B}\\) length of points, we need an alternative way to reconstruct the signal as we go.

One way to reconstruction via interpolation is just to connect the dots; however, this is bad because it creates sharp corners.


## In General {#in-general}

Suppose you have a sampling period length \\(T\_{s}\\):

\begin{equation}
\hat{x}(t) = \sum\_{m=0}^{\infty} X\qty(mT\_{s}) F\qty( \frac{t-mT\_{s}}{T\_{s}}) = x(0) F \qty(\frac{t}{T\_{s}}) + x(T\_{s}) f\qty(\frac{t-T\_{s}}{T\_{s}}) + \dots
\end{equation}

where \\(F(t)\\) is some interpolation function such that:

\begin{equation}
\begin{cases}
F(0) = 1 \\\\
F(k) = 0, k \in \mathbb{Z} \backslash \\{0\\}
\end{cases}
\end{equation}

Notice the above is a [convolution]({{< relref "KBhconvolution.md" >}}) between \\(X\\) and \\(F\\), where \\(y\\) is fixed as a multiple \\(m\\) around \\(mT\_{s}\\) and the convolution is centered at \\(\frac{t}{T\_{s}}\\).

However, because we are finite valued, we just slide a window around and skip around.


### Consider now \\(\hat{x}\\) at \\(kT\_{s}\\) {#consider-now-hat-x-at-kt-s}

\begin{align}
\hat{x}(kT\_{s}) &= \sum\_{m=0}^{\infty} X(mT\_{s}) F \qty(\frac{kT\_{s}- mT\_{s}}{T\_{s}}) \\\\
&= \sum\_{m=0}^{\infty} X(mT\_{s}) F \qty(k-m)
\end{align}

now, recall that \\(F\\) is \\(0\\) for all non-zero integers, so each term will only be preserved once, precisely at \\(m = k\\). Meaning:

\begin{align}
\hat{x}(kT\_{s}) &= \sum\_{m=0}^{\infty} X(mT\_{s}) F \qty(k-m) \\\\
&= X(kT\_{s}) 1 \\\\
&= X(kT\_{s})
\end{align}

so this is why we need \\(F(k) = 0, k \in \mathbb{Z} \backslash \\{0\\}\\)


## Zero-Hold Interpolation {#zero-hold-interpolation}

Choose \\(F\\) such that:

\begin{equation}
F = \begin{cases}
1, \text{if}\ |x| < \frac{1}{2} \\\\
0
\end{cases}
\end{equation}


## Infinite-Degree Polynomial Interpolation {#infinite-degree-polynomial-interpolation}

\begin{equation}
F(t) = (1-t) (1+t) \qty(1- \frac{t}{2}) \qty(1+ \frac{t}{2}) \dots = \text{sinc}(t) = \frac{\sin(\pi t)}{\pi t}
\end{equation}

This is the BEST interpolation; this is because it will be stretched such that every zero crossing matches eat \\(mT\_{s}\\), meaning we will recover a sum of sinusoids.

This gives a **smooth signal**; and if sampling was done correctly with the [nyquist limit]({{< relref "KBhsu_engr76_apr302024.md#lossless-sampling" >}}), interpolating with [sinc interpolation](#infinite-degree-polynomial-interpolation) will give you your original signal.


### Shannon's Nyquist Theorem {#shannon-s-nyquist-theorem}

Let \\(X\\) be a [Finite-Bandwidth Signal]({{< relref "KBhsu_engr76_apr252024.md#finite-bandwidth-signal" >}}) where \\([0, B]\\) Hz.

if:

\begin{equation}
\hat{X}(t) = \sum\_{m=0}^{\infty} X(mTs) \text{sinc} \qty( \frac{t-mTs}{Ts})
\end{equation}

where:

\begin{equation}
\text{sinc}(t) = \frac{\sin \qty(\pi t)}{\pi t}
\end{equation}

- if \\(Ts < \frac{1}{2B}\\), that is, \\(fs > 2B\\), then \\(\hat{X}(t) = X(t)\\) (this is a STRICT inequality!)
- otherwise, if \\(Ts > \frac{1}{2B}\\), then \\(\hat{X}(t) \neq X(t)\\), yet \\(\hat{X}(mTs) = X(mTs)\\), and \\(\hat{X}\\) will be bandwidth limited to \\([0, \frac{fs}{2}]\\).

This second case is callled "aliasing", or "strocoscopic effect".

---

Alternate way of presenting the same info:

\begin{equation}
\hat{X}(t) = \sum\_{m=0}^{\infty} X(mTs) \text{sinc} \qty( \frac{t-mT\_{s}}{T\_{s}})
\end{equation}

Let \\(X(t)\\), as before, be a continuous-time, bandwidth limited, signal with [Bandwidth]({{< relref "KBhsu_engr76_apr252024.md#bandwidth" >}}) \\(B\\); let \\(\hat{X}(t)\\) be the reconstruction of this signal with samples taken apart by \\(T\_{s} < \frac{1}{2B}\\); then \\(\hat{X}(t) = X(t)\\). Otherwise, if \\(T\_{s} > \frac{1}{2B}\\), then the reconstruction \\(\hat{X}(t) \neq X(t)\\), but the samples at \\(mT\_{s}\\) will still match (that is, \\(X(m T\_{s}) = \hat{X}(m T\_{s})\\)) and \\(\hat{X}(t)\\) will be a [Baseband Signal]({{< relref "KBhsu_engr76_may022024.md#passband-signal" >}}) whose spectrum is limited by \\([0, \frac{\frac{1}{T\_{s}}}{2}] = [0, \frac{F\_{s}}{2}]\\). This second case is callled "aliasing", or "strocoscopic effect".
13 changes: 13 additions & 0 deletions content/posts/KBhknowledgebase_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ title = "knowledgebase testing page"
author = ["Houjun Liu"]
draft = false
+++

## On Paradox {#on-paradox}

**Generally: everything has multiple sides and try to recognize it**

- chapter on paradox
- dispelling the common notion of standards
- _humbleness_: to recognize something, you have to know what the absence of it is
- equilibrium---
- nothing is one-sided, so stuff has multiple sides
- possible notions of extremism: "the recognition of beauty is an ugly act"
- highlighting this as a truth of the world---not trying to make a plan of action, but instead trying to just outline a particular view of the world
- **even for the way**: there is a similar side
15 changes: 15 additions & 0 deletions content/posts/KBhnp_intersect_conp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
+++
title = "NP intersect coNP"
author = ["Houjun Liu"]
draft = false
+++

\\(\text{NP} \cap \text{coNP}: \forall x \in \qty {0,1}^{\*}, \exists\\) short, efficiently checkable proof of BOTH \\(x\\) presence/absence in \\(L\\)


## some examples {#some-examples}

- in P: [PERFECT-MATCHING]({{< relref "KBha_library_of_languages.md#perfect-matching" >}})
- in P: [PRIMES]({{< relref "KBha_library_of_languages.md#primes" >}})
- **we don't know if this is in \\(P\\)**: [FACTORING]({{< relref "KBha_library_of_languages.md#factoring" >}})
... if it was, much of cryptography will break
Loading

0 comments on commit e0aea77

Please sign in to comment.