Finite automata and consolidate bash/POSIX.

main
Joshua Potter 2024-12-23 20:32:13 -07:00
parent e82c40f662
commit 737ed9e300
25 changed files with 1260 additions and 255 deletions

View File

@ -237,7 +237,10 @@
"abs-down.png", "abs-down.png",
"abs-right-down.png", "abs-right-down.png",
"abs-left-down.png", "abs-left-down.png",
"triple-table-repr.png" "triple-table-repr.png",
"state-diagram.png",
"state-diagram-ends1.png",
"state-diagram-ends0.png"
], ],
"File Hashes": { "File Hashes": {
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
@ -578,7 +581,7 @@
"_journal/2024-05/2024-05-25.md": "3e8a0061fa58a6e5c48d12800d1ab869", "_journal/2024-05/2024-05-25.md": "3e8a0061fa58a6e5c48d12800d1ab869",
"_journal/2024-05-27.md": "b36636d10eab34380f17f288868df3ae", "_journal/2024-05-27.md": "b36636d10eab34380f17f288868df3ae",
"_journal/2024-05/2024-05-26.md": "abe84b5beae74baa25501c818e64fc95", "_journal/2024-05/2024-05-26.md": "abe84b5beae74baa25501c818e64fc95",
"algebra/set.md": "6cf503bd1118d22a45f1571057bea96d", "algebra/set.md": "ae08c25c07ecedb2a05c02b258b4542a",
"algebra/boolean.md": "c9bd5abb601be6d2bedd24d5f54848b0", "algebra/boolean.md": "c9bd5abb601be6d2bedd24d5f54848b0",
"git/merge-conflicts.md": "761ad6137ec51d3877f7d5b3615ca5cb", "git/merge-conflicts.md": "761ad6137ec51d3877f7d5b3615ca5cb",
"_journal/2024-05-28.md": "0f6aeb5ec126560acdc2d8c5c6570337", "_journal/2024-05-28.md": "0f6aeb5ec126560acdc2d8c5c6570337",
@ -976,7 +979,7 @@
"_journal/2024-11/2024-11-24.md": "894b021e6335d4e6947448c8d362c083", "_journal/2024-11/2024-11-24.md": "894b021e6335d4e6947448c8d362c083",
"_journal/2024-11-26.md": "29bc0b54d23034b9108e567a1d5fa8ac", "_journal/2024-11-26.md": "29bc0b54d23034b9108e567a1d5fa8ac",
"_journal/2024-11/2024-11-25.md": "1ec17a8473fa9c4779090ecbd22d70ef", "_journal/2024-11/2024-11-25.md": "1ec17a8473fa9c4779090ecbd22d70ef",
"calculus/intervals.md": "6a317fb5053b172611e9e7ae6f66f609", "calculus/intervals.md": "7da1830e226834566eab2c5bd2cae466",
"c17/storage.md": "07f0aa969d502df97f757318bde3c166", "c17/storage.md": "07f0aa969d502df97f757318bde3c166",
"c17/functions.md": "76b12732875998c44b22ba3531cf88a0", "c17/functions.md": "76b12732875998c44b22ba3531cf88a0",
"_journal/2024-11-27.md": "5a58e3a0bd08c689d30600021937495d", "_journal/2024-11-27.md": "5a58e3a0bd08c689d30600021937495d",
@ -999,7 +1002,7 @@
"_journal/2024-12/2024-12-04.md": "965f6619edf1002d960203e3e12a413b", "_journal/2024-12/2024-12-04.md": "965f6619edf1002d960203e3e12a413b",
"_journal/2024-12-06.md": "d75323d0fec57f4fc1f13cb4370df18d", "_journal/2024-12-06.md": "d75323d0fec57f4fc1f13cb4370df18d",
"_journal/2024-12/2024-12-05.md": "4f3b1e7a43e01cc97b0eed6fbc6c1f96", "_journal/2024-12/2024-12-05.md": "4f3b1e7a43e01cc97b0eed6fbc6c1f96",
"calculus/integrals.md": "e8d36a8fae9cd785374f419996ef5269", "calculus/integrals.md": "edc4e00d8e2b9a7cd14836bb543bb8b6",
"_journal/2024-12-07.md": "bfb6c4db0acbacba19f03a04ec29fa5c", "_journal/2024-12-07.md": "bfb6c4db0acbacba19f03a04ec29fa5c",
"_journal/2024-12/2024-12-06.md": "d73b611d2d15827186a0252d9b9a6580", "_journal/2024-12/2024-12-06.md": "d73b611d2d15827186a0252d9b9a6580",
"_journal/2024-12-08.md": "5662897539b222db1af45dcd217f0796", "_journal/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
@ -1015,7 +1018,7 @@
"_journal/2024-12-11.md": "e7393c01b44c5b804f86f45b8b899b59", "_journal/2024-12-11.md": "e7393c01b44c5b804f86f45b8b899b59",
"_journal/2024-12/2024-12-10.md": "d4f43b32220dbe174be514397b1bb035", "_journal/2024-12/2024-12-10.md": "d4f43b32220dbe174be514397b1bb035",
"_journal/2024-12/2024-12-11.md": "e7393c01b44c5b804f86f45b8b899b59", "_journal/2024-12/2024-12-11.md": "e7393c01b44c5b804f86f45b8b899b59",
"encoding/uri.md": "394abe477b882e1414dd2fb151fea823", "encoding/uri.md": "09552882689f55414786d709c43f6697",
"encoding/xml.md": "01a66b1a102cccc682f8f1cab0f50bc6", "encoding/xml.md": "01a66b1a102cccc682f8f1cab0f50bc6",
"encoding/rdf.md": "87a47be25bc5754a11166a4b7663cada", "encoding/rdf.md": "87a47be25bc5754a11166a4b7663cada",
"_journal/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a", "_journal/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a",
@ -1042,7 +1045,19 @@
"encoding/xml/rdf.md": "f4491dd28b937da3182d701a863e40fe", "encoding/xml/rdf.md": "f4491dd28b937da3182d701a863e40fe",
"encoding/xml/index.md": "01a66b1a102cccc682f8f1cab0f50bc6", "encoding/xml/index.md": "01a66b1a102cccc682f8f1cab0f50bc6",
"ontology/reification.md": "ef8275957dcc1a7e5501722d4652e41c", "ontology/reification.md": "ef8275957dcc1a7e5501722d4652e41c",
"ontology/rdf.md": "fd273c30bec6f46b68547f0d392620b1" "ontology/rdf.md": "fd273c30bec6f46b68547f0d392620b1",
"data-models/rdf.md": "a07c290d11087346757185b8047c94c7",
"serialization/xml.md": "84b632282ebcc2b6216923a02abdd4c2",
"serialization/index.md": "5ed7e99e4efc4844839ea357d351f5d8",
"data-models/index.md": "9e60f40798490f0743f291e55f492033",
"_journal/2024-12-22.md": "015dbf675853a81db07d641e8dab7fd4",
"_journal/2024-12/2024-12-21.md": "1c1a5791f7519c92e882957cf417b51f",
"formal-system/language.md": "7797d33a0b0eb187d43dda46a138fb25",
"computability/automaton.md": "e01a115d4df90f565c51435e3f558d1e",
"computability/index.md": "92042eac186e5772144f86141fbac155",
"_journal/2024-12-23.md": "0a7cf306d477020e020ed23ce3c2d68d",
"_journal/2024-12/2024-12-22.md": "75375a867efc5b3aff406c73394d4814",
"computability/language.md": "9ee8bd16c231e71855ab1d8dae3188cb"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -1,9 +0,0 @@
---
title: "2024-12-21"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,11 @@
---
title: "2024-12-23"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Added [[automaton|finite automata]] definition and related introductory notes.

View File

@ -0,0 +1,12 @@
---
title: "2024-12-21"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Notes on properties of [[integrals#Step Functions|step function integrals]].
* Additional notes on [[cardinality|cardinal numbers]].

View File

@ -0,0 +1,11 @@
---
title: "2024-12-22"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Notes on [[language]] (e.g. strings, alphabets, etc.).

View File

@ -366,7 +366,7 @@ For any sets $A$, $B$, and $C$, $$\begin{align*} A \cap (B \cup C) & = (A \cap B
%%ANKI %%ANKI
Basic Basic
The distributive laws of the algebra of sets apply to what operators? The distributive laws of the algebra of sets apply to what operators?
Back: $\cup$ and $\cap$ Back: $\cup$ and $\cap$.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1716803270441--> <!--ID: 1716803270441-->
END%% END%%

View File

@ -1,43 +0,0 @@
---
title: Bash
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
---
%%ANKI
Basic
How do you escape a `'` within a single-quote string?
Back: This is impossible.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752230-->
END%%
%%ANKI
Basic
What does the null string refer to?
Back: The empty string, i.e. `""`.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752237-->
END%%
%%ANKI
Basic
When does Bash remove null strings from a command?
Back: When they occur as part of a non-null command-line argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752241-->
END%%
%%ANKI
Basic
Why does the following not work correctly?
```bash
$ # -F specifies the field separator
$ awk -F"" 'program' files
```
Back: Bash removes the null string before executing the command.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816764555-->
END%%

View File

@ -1,61 +0,0 @@
---
title: Prompts
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
---
## Overview
According to Robbins a POSIX-compliant shell (like Bash) generally has the primary and secondary prompts denoted with `$` and `>` respectively. Adjust these values using environment variables `$PS1` and `PS2` respectively.
%%ANKI
Basic
What symbol is usually used to denote the primary prompt?
Back: `$$`
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706882670149-->
END%%
%%ANKI
Basic
What environment variable controls Bash's primary prompt?
Back: `$$PS1`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706973587222-->
END%%
%%ANKI
Basic
What symbol is usually used to denote the secondary prompt?
Back: `>`
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706882670158-->
END%%
%%ANKI
Basic
What environment variable controls Bash's secondary prompt?
Back: `$$PS2`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706973587232-->
END%%
Paths supplied to commands are typically "sanitized" by prefixing the path name with `./`. This is mentioned in a few different places:
* `find -execdir` performs this prefixing automatically on all found files.
* `awk` ambiguously interprets a file named e.g. `count=1` as variable assignment. Should write `$ awk -f program.awk ./count=1`.
%%ANKI
Basic
What methodology is commonly used to "sanitize" paths supplied as command-line arguments?
Back: Prefixing the paths with `./`.
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706885111460-->
END%%
## Bibliography
* Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

View File

@ -1,69 +0,0 @@
---
title: Measuring Command Robustness
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
- shell
---
## Overview
An interesting point Robbins discusses in his introduction to [[posix/awk/index|gawk]] is this idea of command robustness. He states that:
> A self-contained shell script is more reliable because there are no other files to misplace.
%%ANKI
Basic
What is a self-contained shell script?
Back: A shell script that does not rely on the presence of other files.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911473-->
END%%
%%ANKI
Basic
What makes a self-contained shell script more reliable?
Back: There are no other files to misplace.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911475-->
END%%
He argues that the first command below is more robust than the second since the command is more loosely coupled to its environment:
```bash
$ awk 'program' input-file1 input-file2 ...
$ awk -f program-file input-file1 input-file2 ...
```
It's interesting to think what else can be used as a measure of a command's robustness:
* Required environment variables or environment variables formatted in a certain way
* `$PATH` needs to point to a specific location
* Whether the invoked program is present by default in a distribution or must be installed
* The ability to run with or without an associated TTY
* The ability to run with or without associated standard streams
* `stdout`, `stderr`, `stdin`
* How backwards compatible the invoked program is
* Version mismatch may silently cause the same invocation to fail
* Expected permissions
* EUID, read permissions on an input file, etc.
* Determinism of the program itself
* Does output rely entirely on input or can it make nondeterministic choices
* The amount of resources dedicated to the program
* Failure may occur if not enough memory is provided to the command
* Whether a program acts idempotently
* What happens if I run the command twice in a row?
* Whether a program acts atomically
* Is it possible intermediate files are left that affect subsequent runs?
* The presence of timeouts
* Perhaps a program waits a specified amount of time before input is available. The command's success is now externally determined.
* Locale-aware functionality
* Consider for instance [[posix/awk/index|gawk]]'s `\u` [[escape-sequences|sequence]] which targets characters in the current locale's character set as opposed to specifically Unicode.
* POSIX standard [[posix/regexp#Character Classes|character classes]] serve as another example.
The above scenarios are what makes something like [[nix/index|nix]] so compelling.
## Bibliography
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

View File

@ -1,58 +0,0 @@
---
title: Shebang
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
---
## Overview
The shebang (also writting shabang or sha-bang) is a magic character at the start of a script indicating what command should be run when invoking the script directly. It always begins with ASCII characters `#!`.
%%ANKI
Basic
What ASCII characters do shebangs start with?
Back: `#!`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706726911458-->
END%%
%%ANKI
Basic
What class of programs can be specified in a shebang?
Back: Interpreters
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911461-->
END%%
%%ANKI
Basic
The OS will parse a shebang into what three parts?
Back: `#!`, the interpreter, and the rest of the line as a single argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911464-->
END%%
%%ANKI
Basic
What gotcha does Robbins highlight with shebang parsing?
Back: The remainder of the line following the interpreter is passed as a *single* argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911467-->
END%%
Some systems limit the length of interpreters to just 32 characters. A simple workaround when encountering this limitation is to introduce a symbolic link.
%%ANKI
Basic
What workaround is used when shebang interpreter names are too long?
Back: Introduce a symbolic link.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911470-->
END%%
## Bibliography
* Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

View File

@ -1,18 +1,26 @@
--- ---
title: Integrals title: Integrals
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: calculus::integrals FILE TAGS: calculus::integral
tags: tags:
- calculus - calculus
- integral - integral
--- ---
## Overview
The integral is usually defined first in terms of step functions and then general ordinate sets. It is closely tied to [[area]]. In particular, the integral of some nonnegative function on a closed interval is defined so that its area is equal to the area of the ordinate set in question.
## Step Functions ## Step Functions
Let $s$ be a step function defined on [[intervals|interval]] $[a, b]$, and let $P = \{x_0, x_1, \ldots, x_n\}$ be a [[intervals#Partitions|partition]] of $[a, b]$ such that $s$ is constant on the open subintervals of $P$. Denote by $s_k$ the constant value that $s$ takes in the $k$th open subinterval, so that $$s(x) = s_k \quad\text{if}\quad x_{k-1} < x < x_k, \quad k = 1, 2, \ldots, n.$$ Let $s$ be a step function defined on [[intervals|interval]] $[a, b]$, and let $P = \{x_0, x_1, \ldots, x_n\}$ be a [[intervals#Partitions|partition]] of $[a, b]$ such that $s$ is constant on the open subintervals of $P$. Denote by $s_k$ the constant value that $s$ takes in the $k$th open subinterval, so that $$s(x) = s_k \quad\text{if}\quad x_{k-1} < x < x_k, \quad k = 1, 2, \ldots, n.$$
The **integral of $s$ from $a$ to $b$**, denoted by the symbol $\int_a^b s(x)\,dx$, is defined by the following formula: $$\int_a^b s(x) \,dx = \sum_{k=1}^n s_k \cdot (x_k - x_{k - 1})$$ The **integral of $s$ from $a$ to $b$**, denoted by the symbol $\int_a^b s(x)\,dx$, is defined by the following formula: $$\int_a^b s(x) \,dx = \sum_{k=1}^n s_k \cdot (x_k - x_{k - 1})$$
Furthermore, $$\int_a^b s(x) \,dx = -\int_b^a s(x) \,dx$$
and $$\int_a^a s(x)\,dx = 0.$$
%%ANKI %%ANKI
Basic Basic
Apostol first introduces the integral for the ordinate sets of what kind of function? Apostol first introduces the integral for the ordinate sets of what kind of function?
@ -132,6 +140,183 @@ Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Int
<!--ID: 1733520215132--> <!--ID: 1733520215132-->
END%% END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. How is $\int_b^a s(x) \,dx$ defined?
Back: As $-\int_a^b s(x) \,dx$.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555507-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. How is $\int_a^b s(x) \,dx$ defined?
Back: Given partition $P = \{x_0, x_1, \ldots, x_n\}$ with constant value $s_k$ on the $k$th open subinterval, $$\int_a^b s(x) \,dx = \sum_{k=1}^n s_k \cdot (x_k - x_{k - 1})$$
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555512-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What does $\int_a^b s(x) \,dx$ evaluate to after swapping limits of integration?
Back: As $-\int_b^a s(x) \,dx$.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555515-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What does $\int_a^a s(x) \,dx$ evaluate to?
Back: $0$.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555518-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What name is given to $a$ in $\int_a^b s(x) \,dx$?
Back: The lower limit of integration.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555521-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What name is given to $b$ in $\int_a^b s(x) \,dx$?
Back: The upper limit of integration.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555523-->
END%%
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What name is given to $a$ and $b$ in $\int_a^b s(x) \,dx$?
Back: The limits of integration.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734816555526-->
END%%
### Additivity
Let $s$ and $t$ be step functions defined on $[a, b]$. Then $$\int_a^b s(x) + t(x) \,dx = \int_a^b s(x) \,dx + \int_a^b t(x) \,dx$$
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$. What does the additive property state?
Back: $\int_a^b s(x) + t(x) \,dx = \int_a^b s(x) \,dx + \int_a^b t(x) \,dx$
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463659-->
END%%
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$. What is the following identity called? $$\int_a^b s(x) + t(x) \,dx = \int_a^b s(x) \,dx + \int_a^b t(x) \,dx$$
Back: The additive property.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463668-->
END%%
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$. How is the following more compactly written? $$\int_a^b s(x) \,dx + \int_a^b t(x) \,dx$$
Back: $\int_a^b s(x) + t(x) \,dx$
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463673-->
END%%
### Homogeneousness
Let $s$ be a step function defined on $[a, b]$. Let $c \in \mathbb{R}$. Then $$\int_a^b c \cdot s(x) \,dx = c\int_a^b s(x) \,dx$$
%%ANKI
Basic
Let $s$ be a step function over $[a, b]$. What does the homogeneous property state?
Back: For all $c \in \mathbb{R}$, $\int_a^b c \cdot s(x) \,dx = c \int_a^b s(x) \,dx$.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463679-->
END%%
%%ANKI
Basic
Let $s$ be a step function defined over $[a, b]$ and $c \in \mathbb{R}$. What is the following identity called? $$\int_a^b c \cdot s(x) \,dx = c\int_a^b s(x) \,dx$$
Back: The homogeneous property.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463685-->
END%%
### Linearity
Let $s$ and $t$ be step functions defined on $[a, b]$. Let $c_1, c_2 \in \mathbb{R}$. Then $$\int_a^b [c_1s(x) + c_2t(x)] \,dx = c_1 \int_a^b s(x) \,dx + c_2 \int_a^b t(x) \,dx$$
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$ and $c_1, c_2 \in \mathbb{R}$. What does the linearity property state?
Back: $\int_a^b [c_1 s(x) + c_2 t(x)] \,dx = c_1 \int_a^b s(x) \,dx + c_2 \int_a^b t(x) \,dx$
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463699-->
END%%
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$ and $c_1, c_2 \in \mathbb{R}$. What is the following identity called? $$\int_a^b [c_1s(x) + c_2t(x)] \,dx = c_1 \int_a^b s(x) \,dx + c_2 \int_a^b t(x) \,dx$$
Back: The linearity property.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463704-->
END%%
%%ANKI
Basic
The linearity property is immediately derived from what other two properties?
Back: The additive and homogeneous properties.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463710-->
END%%
%%ANKI
Cloze
The {linearity} property is a combination of the {additive} and {homogenous} properties.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734814463693-->
END%%
### Comparison Theorem
Let $s$ and $t$ be step functions defined on $[a, b]$. Suppose $s(x) < t(x)$ for all $x \in [a, b]$. Then $$\int_a^b s(x) \,dx < \int_a^b t(x) \,dx$$
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$. What does the comparison theorem state?
Back: If $s(x) < t(x)$ for all $x \in [a, b]$, $\int_a^b s(x) \,dx < \int_a^b t(x) \,dx$.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734815755275-->
END%%
%%ANKI
Basic
Let $s$ and $t$ be step functions over $[a, b]$ such that $s(x) < t(x)$ for all $x \in [a, b]$. What is the following called? $$\int_a^b s(x) \,dx < \int_a^b t(x) \,dx$$
Back: The comparison theorem.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734815755282-->
END%%
%%ANKI
Basic
The comparison theorem of step function integrals corresponds to what property of area?
Back: The monotone property of area.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734815755285-->
END%%
%%ANKI
Basic
The monotone property of area corresponds to what theorem of step function integrals?
Back: The comparison theorem.
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
<!--ID: 1734815755288-->
END%%
## Bibliography ## Bibliography
* Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980). * Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).

View File

@ -1,7 +1,7 @@
--- ---
title: Intervals title: Intervals
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: calculus::intervals FILE TAGS: calculus::interval
tags: tags:
- calculus - calculus
--- ---

View File

@ -0,0 +1,501 @@
---
title: Automaton
TARGET DECK: Obsidian::STEM
FILE TAGS: computability::automaton
tags:
- automaton
- computability
---
## Finite Automata
A **finite automaton** is a $5$-tuple $\langle Q, \Sigma, \delta, q_0, F \rangle$, where
1. $Q$ is a finite set called the **states**;
2. $\Sigma$ is a finite set called the alphabet;
3. $\delta \colon Q \times \Sigma \rightarrow Q$ is the **transition function**;
4. $q_0 \in Q$ is the **start state**; and
5. $F \subseteq Q$ is the set of **final states**.
These automaton are typically denoted using a **state diagram** like below. The start state is indicated by an arrow pointing at it from nowhere. An accept state is denoted with a double circle.
![[state-diagram.png]]
A [[language]] is called a **regular language** if a finite automaton recognizes it.
%%ANKI
Basic
A finite automaton comprises of how many components?
Back: Five.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643206-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What kind of mathematical entity is $Q$?
Back: A finite set of states.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643211-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What name is given to $Q$?
Back: $M$'s states.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643215-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What is $\Sigma$?
Back: An alphabet.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643218-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What kind of mathematical entity is $\delta$?
Back: A function.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643221-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What name is given to $\delta$?
Back: $M$'s transition function.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643224-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What is $\delta$'s domain?
Back: $Q \times \Sigma$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643227-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What is $\delta$'s codomain?
Back: $Q$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643230-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What kind of mathematical entity is $q_0$?
Back: An urelement.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643233-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What name is given to $q_0$?
Back: $M$'s start state.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643238-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What name is given to $F$?
Back: $M$'s final states.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643242-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What kind of mathematical entity is $F$?
Back: A finite set.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643247-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. How does $F$ relate to $Q$?
Back: $F \subseteq Q$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643252-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. How does $q_0$ relate to $Q$?
Back: $q_0 \subseteq Q$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643257-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. How does $q_0$ relate to $F$?
Back: N/A.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643263-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How many start states does $M$ have?
Back: One.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643267-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How many accept states does $M$ have?
Back: Zero or more.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643272-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How is $M$'s start state denoted in a state diagram?
Back: With an arrow pointing to it from nowhere.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643277-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How is $M$'s final states denoted in a state diagram?
Back: With double circles.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643282-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How is $M$'s transition function denoted in a state diagram?
Back: As edges to and from states.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643286-->
END%%
%%ANKI
Basic
Consider finite automaton $M$. How is $M$'s alphabet denoted in a state diagram?
Back: With symbols labeling each edge.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643291-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $Q$ evaluate to?
![[state-diagram.png]]
Back: $Q = \{q_1, q_2, q_3\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643296-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $\Sigma$ evaluate to?
![[state-diagram.png]]
Back: $\Sigma = \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643301-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $q_0$ evaluate to?
![[state-diagram.png]]
Back: $q_0 = q_1$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643305-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $\mathop{\text{dom}}\delta$ evaluate to?
![[state-diagram.png]]
Back: $\{q_1, q_2, q_3\} \times \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643309-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $\mathop{\text{ran}}\delta$ evaluate to?
![[state-diagram.png]]
Back: $\{q_1, q_2, q_3\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643313-->
END%%
%%ANKI
Basic
Consider diagram of finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$. What does $F$ evaluate to?
![[state-diagram.png]]
Back: $F = \{q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643317-->
END%%
%%ANKI
Basic
What name is given to a finite automaton's standard graphical depiction?
Back: Its state diagram.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643321-->
END%%
%%ANKI
Cloze
{1:Edges} are to {2:diagraphs} whereas {2:transitions} are to {1:state diagrams}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643325-->
END%%
%%ANKI
Cloze
{1:Vertices} are to {2:graphs} whereas {2:states} are to {1:state diagrams}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643328-->
END%%
%%ANKI
Cloze
The {final} states of a finite automaton are also called the {accept} states.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643332-->
END%%
If $s$ is processed by machine $M$ such that $M$ finishes in an accept state, we say $M$ **accepts** $s$. Otherwise $M$ **rejects** $s$. If $A$ is the set of all strings that $M$ accepts, we say that $A$ is the **language of machine $M$**, denoted $L(M) = A$. We say that $M$ **recognizes** $A$.
%%ANKI
Basic
What does it mean for finite automaton $M$ to accept string $s$?
Back: $M$ finishes processing $s$ on an accept state.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643336-->
END%%
%%ANKI
Basic
What does it mean for finite automaton $M$ to reject string $s$?
Back: $M$ finishes processing $s$ on a non-accept state.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643342-->
END%%
%%ANKI
Basic
Let $M$ be a finite automaton. What is the language of $M$?
Back: The set of strings $M$ accepts.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643347-->
END%%
%%ANKI
Cloze
Finite automaton $M$ {1:accepts} {2:strings} and {2:recognizes} {1:languages}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643352-->
END%%
%%ANKI
Basic
How is the language of finite automaton $M$ denoted?
Back: As $L(M)$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643358-->
END%%
%%ANKI
Basic
Let $M$ be a finite automaton. What is $L(M)$ called?
Back: The language of $M$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643364-->
END%%
%%ANKI
Basic
Let $M$ be a finite automaton. What kind of mathematical entity is $L(M)$?
Back: A set (of strings).
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643370-->
END%%
%%ANKI
Basic
How many strings can a finite automaton potentially accept?
Back: Zero or more.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643375-->
END%%
%%ANKI
Basic
How many languages can a finite automaton potentially recognize?
Back: Exactly one.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643380-->
END%%
%%ANKI
Basic
Suppoe finite automaton $M$ does not accept any strings. What language does it recognize?
Back: $\varnothing$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643385-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $Q$ evaluate to?
![[state-diagram-ends1.png]]
Back: $Q = \{q_1, q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643390-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\Sigma$ evaluate to?
![[state-diagram-ends1.png]]
Back: $\Sigma = \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643396-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $F$ evaluate to?
![[state-diagram-ends1.png]]
Back: $F = \{q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643402-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $q_0$ evaluate to?
![[state-diagram-ends1.png]]
Back: $q_0 = q_1$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643408-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\mathop{\text{dom}}\delta$ evaluate to?
![[state-diagram-ends1.png]]
Back: $\{q_1, q_2\} \times \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643415-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\mathop{\text{ran}}\delta$ evaluate to?
![[state-diagram-ends1.png]]
Back: $\{q_1, q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643420-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $L(M)$ evaluate to?
![[state-diagram-ends1.png]]
Back: $\{w \mid w \text{ ends with a } 1 \}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643424-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $Q$ evaluate to?
![[state-diagram-ends0.png]]
Back: $Q = \{q_1, q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643428-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\Sigma$ evaluate to?
![[state-diagram-ends0.png]]
Back: $\Sigma = \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643433-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $F$ evaluate to?
![[state-diagram-ends0.png]]
Back: $F = \{q_1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643440-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $q_0$ evaluate to?
![[state-diagram-ends0.png]]
Back: $q_0 = q_1$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643445-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\mathop{\text{dom}}\delta$ evaluate to?
![[state-diagram-ends0.png]]
Back: $\{q_1, q_2\} \times \{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643450-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $\mathop{\text{ran}}\delta$ evaluate to?
![[state-diagram-ends0.png]]
Back: $\{q_1, q_2\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643455-->
END%%
%%ANKI
Basic
Consider finite automaton $M = \langle Q, \Sigma, \delta, q_0, F \rangle$ below. What does $L(M)$ evaluate to?
![[state-diagram-ends0.png]]
Back: $\{w \mid w = \epsilon \lor w \text{ ends with a } 0 \}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734999643459-->
END%%
%%ANKI
Basic
What is a regular language?
Back: A language recognized by some finite automaton.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1735008834183-->
END%%
%%ANKI
Cloze
A {regular} language is a language {recognized by some finite automaton}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1735008834191-->
END%%
## Bibliography
* Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,3 @@
---
title: Computability
---

View File

@ -0,0 +1,290 @@
---
title: Language
TARGET DECK: Obsidian::STEM
FILE TAGS: language
tags:
- language
---
## Overview
An **alphabet** is any nonempty finite set. The members of an alphabet are called **symbols** of the alphabet. A **string over an alphabet** is a finite sequence of symbols from that alphabet, usually written next to one another without separation.
Then **length** of a string $w$ over an alphabet, denoted $\lvert w \rvert$, is the number of symbols $w$ contains. The **empty string**, denoted $\epsilon$, is the string of length $0$. The **reverse** of $w$ is the string obtained by writing $w$ in the opposite order.
String $z$ is a **substring** of $w$ if $z$ appears consecutively within $w$. The **concatenation** of strings $x$ and $y$, written $xy$, is the string obtained by appending $y$ to the end of $x$. We say string $x$ is a **prefix** of string $y$ if a string $z$ exists where $xz = y$. We say $x$ is a **proper prefix** of $y$ if $x \neq y$.
A **language** is a set of strings. A language is **prefix-free** if no member is a proper prefix of another member.
%%ANKI
Basic
What is an alphabet?
Back: A nonempty finite set.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366600-->
END%%
%%ANKI
Basic
An alphabet is a set satisfying what two properties?
Back: It is nonempty and finite.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366604-->
END%%
%%ANKI
Basic
What is a symbol of an alphabet?
Back: A member of the alphabet.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366608-->
END%%
%%ANKI
Basic
What name is given to members of an alphabet?
Back: Symbols.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366611-->
END%%
%%ANKI
Cloze
A {symbol} is a {member} of an {alphabet}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366614-->
END%%
%%ANKI
Basic
What is a string over an alphabet?
Back: A finite sequence of symbols from that alphabet.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366618-->
END%%
%%ANKI
Basic
What kind of mathematical entity is a string over an alphabet?
Back: A finite sequence.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366621-->
END%%
%%ANKI
Basic
$01001$ is a string over what minimal alphabet?
Back: $\{0, 1\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366624-->
END%%
%%ANKI
Basic
$hello$ is a string over what minimal alphabet?
Back: $\{e, h, l, o\}$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366627-->
END%%
%%ANKI
Basic
How is the length of string $s$ over alphabet $\Sigma$ denoted?
Back: As $\lvert s \rvert$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366630-->
END%%
%%ANKI
Basic
How is the length of a string over an alphabet defined?
Back: As the number of symbols in the string.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366633-->
END%%
%%ANKI
Basic
Let $w$ be a string over some alphabet. How is the length of $w$ denoted?
Back: $\lvert w \rvert$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366636-->
END%%
%%ANKI
Basic
What is the empty string over an alphabet?
Back: The string of length $0$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366639-->
END%%
%%ANKI
Basic
How is the empty string over an alphabet typically denoted?
Back: $\epsilon$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366642-->
END%%
%%ANKI
Basic
What is the reverse of string $w$ over some alphabet?
Back: The string obtained by writing $w$ in opposite order.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366645-->
END%%
%%ANKI
Basic
How is the reverse of string $w$ over some alphabet typically denoted?
Back: $w^R$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366648-->
END%%
%%ANKI
Basic
How does the length of a string relate to the length of its reverse?
Back: They are equal.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366651-->
END%%
%%ANKI
Basic
How does the length of a string relate to the length of a substring?
Back: The latter is less than or equal to the former.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366655-->
END%%
%%ANKI
Basic
What is a substring of string $w$ over some alphabet?
Back: A string that appears consecutively within $w$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366659-->
END%%
%%ANKI
Basic
Let $x$ and $y$ be strings over some alphabet. How is their concatenation denoted?
Back: $xy$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366662-->
END%%
%%ANKI
Basic
Let $x$ and $y$ be strings over some alphabet. What is the length of $\lvert x y \rvert$?
Back: $\lvert x \rvert + \lvert y \rvert$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366666-->
END%%
%%ANKI
Basic
How is the concatenation of strings $x$ and $y$ over some alphabet denoted?
Back: $xy$
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366671-->
END%%
%%ANKI
Basic
Let $x$ be a string over some alphabet. What does $xx$ denote?
Back: The concatenation of $x$ with itself.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366675-->
END%%
%%ANKI
Cloze
Let $x$ be a string over some alphabet. Then {$xx$} $=$ {$x^2$}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366679-->
END%%
%%ANKI
Basic
Let $x$ be a string over some alphabet. What does $x^k$ denote?
Back: The concatenation of $x$ with itself $k$ times.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366683-->
END%%
%%ANKI
Basic
What does it mean for string $x$ to be a prefix of string $y$ over some alphabet?
Back: There exists some string $z$ such that $xz = y$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366687-->
END%%
%%ANKI
Basic
What does it mean for string $x$ to be a proper prefix of string $y$ over some alphabet?
Back: There exists some string $z$ such that $xz = y$ and $x \neq y$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366692-->
END%%
%%ANKI
Basic
What does it mean for string $x$ to be a suffix of string $y$ over some alphabet?
Back: There exists some string $z$ such that $zx = y$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366697-->
END%%
%%ANKI
Basic
What does it mean for string $x$ to be a proper suffix of string $y$ over some alphabet?
Back: There exists some string $z$ such that $zx = y$ and $x \neq y$.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366702-->
END%%
%%ANKI
Basic
What is a language?
Back: A nonempty set of strings.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366705-->
END%%
%%ANKI
Basic
A language is a set satisfying what?
Back: It contains strings over some alphabet.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366709-->
END%%
%%ANKI
Cloze
{1:Symbols} are to {2:alphabets} whereas {2:strings} are to {1:languages}.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366713-->
END%%
%%ANKI
Basic
What does it mean for a language to be prefix-free?
Back: No member is a *proper* prefix of another member.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366717-->
END%%
%%ANKI
Basic
What does it mean for a language to be suffix-free?
Back: No member is a *proper* suffix of another member.
Reference: Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).
<!--ID: 1734903366720-->
END%%
## Bibliography
* Michael Sipser, _Introduction to the Theory of Computation_, Third edition, international edition (Australia Brazil Japan Korea Mexiko Singapore Spain United Kingdom United States: Cengage Learning, 2013).

View File

@ -8,6 +8,10 @@ tags:
## Overview ## Overview
TODO
## Extensions
The following ERE (**E**xtended **R**egular **E**xpression) operators were defined to achieve consistency between programs like `grep`, `sed`, and `awk`. In POSIX, regexps are greedy. The following ERE (**E**xtended **R**egular **E**xpression) operators were defined to achieve consistency between programs like `grep`, `sed`, and `awk`. In POSIX, regexps are greedy.
%%ANKI %%ANKI
@ -253,7 +257,7 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707050923713--> <!--ID: 1707050923713-->
END%% END%%
## Character Classes ### Character Classes
Notation for describing a class of characters specific to a given locale/character set. Notation for describing a class of characters specific to a given locale/character set.

View File

@ -0,0 +1,3 @@
---
title: Data Models
---

View File

@ -1,8 +1,9 @@
--- ---
title: RDF title: RDF
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: ontology::rdf FILE TAGS: data_model::rdf
tags: tags:
- data_model
- rdf - rdf
--- ---
@ -173,7 +174,7 @@ END%%
Cloze Cloze
RDF is a {data model} whereas XML is a {serialization}. RDF is a {data model} whereas XML is a {serialization}.
Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020. Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020.
Tags: xml Tags: serialization::xml
<!--ID: 1734805690321--> <!--ID: 1734805690321-->
END%% END%%
@ -182,7 +183,7 @@ Basic
How might RDF and XML relate to one another? How might RDF and XML relate to one another?
Back: XML can be used to serialize RDF. Back: XML can be used to serialize RDF.
Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020. Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020.
Tags: xml Tags: serialization::xml
<!--ID: 1734805690328--> <!--ID: 1734805690328-->
END%% END%%

View File

@ -1,8 +1,9 @@
--- ---
title: Uniform Resource Identifiers title: Uniform Resource Identifiers
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: uri FILE TAGS: encoding::uri
tags: tags:
- encoding
- uri - uri
--- ---

204
notes/posix/bash.md Normal file
View File

@ -0,0 +1,204 @@
---
title: Bash
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
---
## Overview
Bash, the Bourne-Again Shell, is a shell program and command language.
%%ANKI
Basic
How do you escape a `'` within a single-quote string?
Back: This is impossible.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752230-->
END%%
%%ANKI
Basic
What does the null string refer to?
Back: The empty string, i.e. `""`.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752237-->
END%%
%%ANKI
Basic
When does Bash remove null strings from a command?
Back: When they occur as part of a non-null command-line argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816752241-->
END%%
%%ANKI
Basic
Why does the following not work correctly?
```bash
$ # -F specifies the field separator
$ awk -F"" 'program' files
```
Back: Bash removes the null string before executing the command.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706816764555-->
END%%
## Prompts
According to Robbins a POSIX-compliant shell (like Bash) generally has the primary and secondary prompts denoted with `$` and `>` respectively. Adjust these values using environment variables `$PS1` and `PS2` respectively.
%%ANKI
Basic
What symbol is usually used to denote the primary prompt?
Back: `$$`
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706882670149-->
END%%
%%ANKI
Basic
What environment variable controls Bash's primary prompt?
Back: `$$PS1`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706973587222-->
END%%
%%ANKI
Basic
What symbol is usually used to denote the secondary prompt?
Back: `>`
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706882670158-->
END%%
%%ANKI
Basic
What environment variable controls Bash's secondary prompt?
Back: `$$PS2`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706973587232-->
END%%
Paths supplied to commands are typically "sanitized" by prefixing the path name with `./`. This is mentioned in a few different places:
* `find -execdir` performs this prefixing automatically on all found files.
* `awk` ambiguously interprets a file named e.g. `count=1` as variable assignment. Should write `$ awk -f program.awk ./count=1`.
%%ANKI
Basic
What methodology is commonly used to "sanitize" paths supplied as command-line arguments?
Back: Prefixing the paths with `./`.
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706885111460-->
END%%
## Shebang
The shebang (also writting shabang or sha-bang) is a magic character at the start of a script indicating what command should be run when invoking the script directly. It always begins with ASCII characters `#!`.
%%ANKI
Basic
What ASCII characters do shebangs start with?
Back: `#!`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706726911458-->
END%%
%%ANKI
Basic
What class of programs can be specified in a shebang?
Back: Interpreters
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911461-->
END%%
%%ANKI
Basic
The OS will parse a shebang into what three parts?
Back: `#!`, the interpreter, and the rest of the line as a single argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911464-->
END%%
%%ANKI
Basic
What gotcha does Robbins highlight with shebang parsing?
Back: The remainder of the line following the interpreter is passed as a *single* argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911467-->
END%%
Some systems limit the length of interpreters to just 32 characters. A simple workaround when encountering this limitation is to introduce a symbolic link.
%%ANKI
Basic
What workaround is used when shebang interpreter names are too long?
Back: Introduce a symbolic link.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911470-->
END%%
## Robustness
An interesting point Robbins discusses in his introduction to [[posix/awk/index|gawk]] is this idea of command robustness. He states that:
> A self-contained shell script is more reliable because there are no other files to misplace.
%%ANKI
Basic
What is a self-contained shell script?
Back: A shell script that does not rely on the presence of other files.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911473-->
END%%
%%ANKI
Basic
What makes a self-contained shell script more reliable?
Back: There are no other files to misplace.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911475-->
END%%
He argues that the first command below is more robust than the second since the command is more loosely coupled to its environment:
```bash
$ awk 'program' input-file1 input-file2 ...
$ awk -f program-file input-file1 input-file2 ...
```
It's interesting to think what else can be used as a measure of a command's robustness:
* Required environment variables or environment variables formatted in a certain way
* `$PATH` needs to point to a specific location
* Whether the invoked program is present by default in a distribution or must be installed
* The ability to run with or without an associated TTY
* The ability to run with or without associated standard streams
* `stdout`, `stderr`, `stdin`
* How backwards compatible the invoked program is
* Version mismatch may silently cause the same invocation to fail
* Expected permissions
* EUID, read permissions on an input file, etc.
* Determinism of the program itself
* Does output rely entirely on input or can it make nondeterministic choices
* The amount of resources dedicated to the program
* Failure may occur if not enough memory is provided to the command
* Whether a program acts idempotently
* What happens if I run the command twice in a row?
* Whether a program acts atomically
* Is it possible intermediate files are left that affect subsequent runs?
* The presence of timeouts
* Perhaps a program waits a specified amount of time before input is available. The command's success is now externally determined.
* Locale-aware functionality
* Consider for instance [[posix/awk/index|gawk]]'s `\u` [[escape-sequences|sequence]] which targets characters in the current locale's character set as opposed to specifically Unicode.
* POSIX standard [[regexp#Character Classes|character classes]] serve as another example.
The above scenarios are what makes something like nix so compelling.
## Bibliography
* Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

View File

@ -0,0 +1,3 @@
---
title: Serialization
---

View File

@ -1,8 +1,9 @@
--- ---
title: XML title: XML
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: xml FILE TAGS: serialization::xml
tags: tags:
- serialization
- xml - xml
--- ---