From 16ffe8d4efed2c91e2ee7c825e22f13f19f480fe Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Sun, 19 May 2024 15:07:38 -0600 Subject: [PATCH] Notes on hashing and unary/binary x86 ops. --- .../plugins/obsidian-to-anki-plugin/data.json | 19 +- notes/_journal/2024-05-19.md | 11 + notes/_journal/{ => 2024-05}/2024-05-17.md | 3 +- notes/_journal/2024-05/2024-05-18.md | 12 + notes/hashing/direct-addressing.md | 94 ++++ notes/hashing/index.md | 5 + notes/programming/pred-trans.md | 2 +- notes/set/axioms.md | 292 ------------ notes/set/classes.md | 276 +++++++++++ notes/set/index.md | 444 ++++++++++++++---- notes/set/trees.md | 4 +- notes/x86-64/instructions.md | 308 +++++++++++- 12 files changed, 1054 insertions(+), 416 deletions(-) create mode 100644 notes/_journal/2024-05-19.md rename notes/_journal/{ => 2024-05}/2024-05-17.md (72%) create mode 100644 notes/_journal/2024-05/2024-05-18.md create mode 100644 notes/hashing/direct-addressing.md create mode 100644 notes/hashing/index.md delete mode 100644 notes/set/axioms.md create mode 100644 notes/set/classes.md diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 2b89a60..a59e8a6 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -309,7 +309,7 @@ "_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f", "_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b", "set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53", - "set/index.md": "923225a165d52476bee68d36ac2e4db3", + "set/index.md": "85eef335afe27f8c0308c9ef5aa5d3ca", "set/graphs.md": "4bbcea8f5711b1ae26ed0026a4a69800", "_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb", "_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391", @@ -328,9 +328,9 @@ "_journal/2024-03-22.md": "8da8cda07d3de74f7130981a05dce254", "_journal/2024-03/2024-03-21.md": "cd465f71800b080afa5c6bdc75bf9cd3", "x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2", - "x86-64/instructions.md": "c447f09c6b0ad504726c3232ff5871b4", + "x86-64/instructions.md": "6f18c3e6d01c80dc5ce6ec05c66ff627", "git/refs.md": "e20c2c9b14ba6c2bd235416017c5c474", - "set/trees.md": "27bba3f28c31ad9effe9a99a43991bd4", + "set/trees.md": "c29347ec0ac2e8d5339514c869ecaedf", "_journal/2024-03-24.md": "1974cdb9fc42c3a8bebb8ac76d4b1fd6", "_journal/2024-03/2024-03-23.md": "ad4e92cc2bf37f174a0758a0753bf69b", "_journal/2024-03/2024-03-22.md": "a509066c9cd2df692549e89f241d7bd9", @@ -432,7 +432,7 @@ "_journal/2024-05-13.md": "71eb7924653eed5b6abd84d3a13b532b", "_journal/2024-05/2024-05-12.md": "ca9f3996272152ef89924bb328efd365", "git/remotes.md": "2208e34b3195b6f1ec041024a66fb38b", - "programming/pred-trans.md": "7006b05654a0485472166e81700c98f1", + "programming/pred-trans.md": "9ea72ae99f4de83531b27f4621d21616", "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05/2024-05-13.md": "71eb7924653eed5b6abd84d3a13b532b", @@ -443,8 +443,15 @@ "_journal/2024-05/2024-05-15.md": "4e6a7e6df32e93f0d8a56bc76613d908", "logic/pred-logic.md": "c23c3da8756ac0ef17b9710a67440d84", "logic/prop-logic.md": "f7d3ae42989c1c226c40c8354a546264", - "_journal/2024-05-17.md": "6e8033da97f16d9ce32b4d5762bcd573", - "_journal/2024-05/2024-05-16.md": "9fdfadc3f9ea6a4418fd0e7066d6b10c" + "_journal/2024-05-17.md": "fb880d68077b655ede36d994554f3aba", + "_journal/2024-05/2024-05-16.md": "9fdfadc3f9ea6a4418fd0e7066d6b10c", + "_journal/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c", + "hashing/direct-addressing.md": "05c93ad0fe50092f2abff696888147d0", + "hashing/index.md": "340f8583eb51eaef011e3302bddb7ff8", + "set/classes.md": "a0bb2532284dea67bbfe7c1e3d714fd1", + "_journal/2024-05-19.md": "fddd90fae08fab9bd83b0ef5d362c93a", + "_journal/2024-05/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c", + "_journal/2024-05/2024-05-17.md": "fb880d68077b655ede36d994554f3aba" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-05-19.md b/notes/_journal/2024-05-19.md new file mode 100644 index 0000000..cd191bc --- /dev/null +++ b/notes/_journal/2024-05-19.md @@ -0,0 +1,11 @@ +--- +title: "2024-05-19" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] Sheet Music (10 min.) +- [ ] Go (1 Life & Death Problem) +- [ ] Korean (Read 1 Story) + +* Flashcards on x86-64 [[instructions#Unary Operations|unary operations]] and [[instructions#Binary Operations|binary operations]]. \ No newline at end of file diff --git a/notes/_journal/2024-05-17.md b/notes/_journal/2024-05/2024-05-17.md similarity index 72% rename from notes/_journal/2024-05-17.md rename to notes/_journal/2024-05/2024-05-17.md index e07ded3..1926ba0 100644 --- a/notes/_journal/2024-05-17.md +++ b/notes/_journal/2024-05/2024-05-17.md @@ -10,4 +10,5 @@ title: "2024-05-17" * Exploration of the law of [[pred-trans#Distributivity of Conjunction|Distributivity of Conjunction]]. * Flashcards for left-child, right-sibling tree representations. -* Distinguish [[set/index#Classes|classes]] and sets. Discuss Zermelo-Fraenkel and von Neumann-Bernays alternatives. \ No newline at end of file +* Distinguish [[set/index#Classes|classes]] and sets. Discuss Zermelo-Fraenkel and von Neumann-Bernays alternatives. +* First play test for Hide and Seek. Decided to move forward with building the mobile apps. \ No newline at end of file diff --git a/notes/_journal/2024-05/2024-05-18.md b/notes/_journal/2024-05/2024-05-18.md new file mode 100644 index 0000000..c1c127f --- /dev/null +++ b/notes/_journal/2024-05/2024-05-18.md @@ -0,0 +1,12 @@ +--- +title: "2024-05-18" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] Sheet Music (10 min.) +- [ ] Go (1 Life & Death Problem) +- [ ] Korean (Read 1 Story) + +* Notes on direct-address tables. +* Notes on the subset axioms and Russell's paradox. \ No newline at end of file diff --git a/notes/hashing/direct-addressing.md b/notes/hashing/direct-addressing.md new file mode 100644 index 0000000..3b10bff --- /dev/null +++ b/notes/hashing/direct-addressing.md @@ -0,0 +1,94 @@ +--- +title: Direct Addressing +TARGET DECK: Obsidian::STEM +FILE TAGS: hashing::direct +tags: + - hashing +--- + +## Overview + +Given a universe of keys $U = \{0, 1, \ldots, m - 1\}$, a **direct-address table** has $m$ **slots**. Each slot corresponds to a key in universe $U$. + +%%ANKI +Basic +With respect to hashing, what does the "universe" of keys refer to? +Back: Every potential key that may be inserted into the underlying dictionary. +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Given universe $U$, how many slots must a direct-address table have? +Back: $|U|$ +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +What name is given to each position in a direct-address table? +Back: A slot. +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Given a direct-address table, the element at slot $k$ has what key? +Back: $k$. +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Given a direct-address table, an element with key $k$ is placed in what slot? +Back: The $k$th slot. +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Write pseudocode to test membership of $x$ in direct-address table `T[0:m-1]`. +Back +```c +bool membership(T, x) { + return T[x.key] != NIL; +} +``` +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Write pseudocode to insert $x$ into direct-address table `T[0:m-1]`. +Back +```c +void insert(T, x) { + T[x.key] = x; +} +``` +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +%%ANKI +Basic +Write pseudocode to delete $x$ from direct-address table `T[0:m-1]`. +Back +```c +void delete(T, x) { + T[x.key] = NIL; +} +``` +Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). + +END%% + +## Bibliography + +* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). \ No newline at end of file diff --git a/notes/hashing/index.md b/notes/hashing/index.md new file mode 100644 index 0000000..0740643 --- /dev/null +++ b/notes/hashing/index.md @@ -0,0 +1,5 @@ +--- +title: Hashing +tags: + - hash +--- diff --git a/notes/programming/pred-trans.md b/notes/programming/pred-trans.md index 1569fa3..22373f8 100644 --- a/notes/programming/pred-trans.md +++ b/notes/programming/pred-trans.md @@ -260,7 +260,7 @@ Given any command $S$, $$wp(S, F) = F$$ %%ANKI Basic Given command $S$, what does $wp(S, F)$ evaluate to? -Back: The empty set. +Back: $F$. Reference: Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981. END%% diff --git a/notes/set/axioms.md b/notes/set/axioms.md deleted file mode 100644 index 732a875..0000000 --- a/notes/set/axioms.md +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: Axioms -TARGET DECK: Obsidian::STEM -FILE TAGS: set -tags: - - set ---- - -## Overview - -Enderton describes ten different axioms in total which serve as the foundation of our set theory. - -## Extensionality - -If two sets have exactly the same members, then they are equal: $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ -%%ANKI -Basic -What does the extensionality axiom state? -Back: If two sets have exactly the same members, then they are equal. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the extensionality axiom expressed using first-order logic? -Back: $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -The following encodes which set theory axiom? $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ -Back: The extensionality axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How many sets exist with no members? -Back: Exactly one. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Which set theory axiom proves uniqueness of $\varnothing$? -Back: The extensionality axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -## Empty Set Axiom - -There exists a set having no members: $$\exists B, \forall x, x \not\in B$$ - -%%ANKI -Basic -What does the empty set axiom state? -Back: There exists a set having no members. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the empty set axiom expressed using first-order logic? -Back: $$\exists B, \forall x, x \not\in B$$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -The following encodes which set theory axiom? $$\exists B, \forall x, x \not\in B$$ -Back: The empty set axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Which set theory axiom proves existence of $\varnothing$? -Back: The empty set axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What two properties ensures definition $\varnothing$ is well-defined? -Back: The empty set exists and is unique. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the empty set defined using set-builder notation? -Back: $\{x \mid x \neq x\}$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -## Pairing Axiom - -For any sets $u$ and $v$, there exists a set having as members just $u$ and $v$: $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ - -%%ANKI -Basic -What does the pairing axiom state? -Back: For any sets $u$ and $v$, there exists a set having as members just $u$ and $v$. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the pairing axiom expressed using first-order logic? -Back: $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -The following encodes which set theory axiom? $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ -Back: The pairing axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Which set theory axiom proves existence of set $\{x, y\}$ where $x \neq y$? -Back: The pairing axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Which set theory axiom proves existence of set $\{x\}$? -Back: The pairing axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -For sets $u$ and $v$, what name is given to set $\{u, v\}$? -Back: The pair set of $u$ and $v$. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -In set theory, what does a singleton refer to? -Back: A set with exactly one member. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What set theory axiom is used to prove existence of singletons? -Back: The pairing axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the pair set $\{u, v\}$ defined using set-builder notation? -Back: $\{x \mid x = u \lor x = v\}$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -## Union Axiom - -### Preliminary Form - -For any sets $a$ and $b$, there exists a set whose members are those sets belonging either to $a$ or to $b$ (or both): $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ - -%%ANKI -Basic -What does the union axiom (preliminary form) state? -Back: For any sets $a$ and $b$, there exists a set whose members are all in either $a$ or $b$. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the union axiom (preliminary form) expressed using first-order logic? -Back: $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -The following encodes which set theory axiom? $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ -Back: The union axiom (preliminary form). -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the union of sets $a$ and $b$ denoted? -Back: $a \cup b$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What two set theory axioms prove existence of e.g. $\{x_1, x_2, x_3\}$? -Back: The pairing axiom and union axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the union of set $a$ and $b$ defined using set-builder notation? -Back: $\{x \mid x \in a \lor x \in b\}$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -## Power Set Axiom - -For any set $a$, there is a set whose members are exactly the subsets of $a$: $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ - -%%ANKI -Basic -What does the power set axiom state? -Back: For any set $a$, there exists a set whose members are exactly the subsets of $a$. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the power set axiom expressed using first-order logic? -Back: $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -The following encodes which set theory axiom? $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ -Back: The power set axiom. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is $x \subseteq a$ rewritten using first-order logic and $\in$? -Back: $\forall t, t \in x \Rightarrow t \in a$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the power set of set $a$ denoted? -Back: $\mathscr{P}{a}$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -How is the power set of set $a$ defined using set-builder notation? -Back: $\{x \mid x \subseteq a\}$ -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -## Bibliography - -* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). \ No newline at end of file diff --git a/notes/set/classes.md b/notes/set/classes.md new file mode 100644 index 0000000..aba5d4d --- /dev/null +++ b/notes/set/classes.md @@ -0,0 +1,276 @@ +--- +title: Classes +TARGET DECK: Obsidian::STEM +FILE TAGS: set::class +tags: + - class + - set +--- + +## Overview + +The **Zermelo-Fraenkel alternative** avoids speaking of collections defined using set theoretical notation that are not sets. The **von Neumann-Bernays** alternative calls these **classes**. + +%%ANKI +Basic +In set theory, what is a class? +Back: A collection defined using set theoretical notation that isn't a set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which two alternatives are usually employed when speaking of classes? +Back: The Zermelo-Fraenkel alternative and the von Neumann-Bernays alternative. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What does the Zermelo-Fraenkel alternative say about classes? +Back: It gives it no ontological status at all. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What does the von Neumann-Bernays alternative say about classes? +Back: It refers to objects defined using set theory but that aren't actually sets. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Cloze +The {1:Zermelo}-{2:Fraenkel} alternative is a separate approach from the {2:von Neumann}-{1:Bernays} alternative. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which set theory alternative avoids the term "class"? +Back: The Zermelo-Fraenkel alternative. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which set theory alternative embraces the term "class"? +Back: The von Neumann-Bernays alternative. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What kind of mathematical object is $\{x \mid x \neq x\}$? +Back: A set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What kind of mathematical object is $\{x \mid x = x\}$? +Back: A class. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Are sets or classes more general? +Back: Classes. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is every set a class? +Back: Yes. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is every class a set? +Back: No. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Assuming entrance requirement $\_\_\_$, what kind of mathematical object is $\{x \mid \_\_\_\}$? +Back: A class. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Russell's Paradox + +Let $R = \{x \mid x \not\in x\}$. Then $R \in R \Leftrightarrow R \not\in R$. + +%%ANKI +Basic +What simpler set is $\{x \mid x \neq x\}$ equivalent to? +Back: The empty set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{x \mid x \neq x\}$ a set? +Back: Yes. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What simpler set is $\{x \mid x = x\}$ equivalent to? +Back: N/A. This is a class. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{x \mid x = x\}$ a set? +Back: No. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What simpler set is $\{x \mid x \in x\}$ equivalent to? +Back: The empty set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{x \mid x \in x\}$ a set? +Back: Yes. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What simpler set is $\{x \mid x \not\in x\}$ equivalent to? +Back: N/A. This is a class. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{x \mid x \not\in x\}$ a set? +Back: No. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $R = \{x \mid x \not\in x\}$. What biconditional demonstrates a paradox? +Back: $R \in R \Leftrightarrow R \not\in R$ +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +Given $R = \{x \mid x \not\in x\}$, what contradiction arises when we assume $R \in R$? +Back: The entrance requirement says $R \not\in R$. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +Given $R = \{x \mid x \not\in x\}$, what contradiction arises when we assume $R \not\in R$? +Back: $R$ satisfies the entrance requirement meaning $R \in R$. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +What special name is given to class $\{x \mid x \not\in x\}$? +Back: The Russell set. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +Explain how the Russell set is defined in plain English. +Back: It is the "set" of all sets that do not contain themselves. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +What is the entrance requirement of the Russell set? +Back: $x \not\in x$ +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +The barber paradox is a variant of what other paradox? +Back: Russell's paradox. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +What does the barber paradox assume existence of? +Back: A barber who shaves all those, and those only, who do not shave themselves. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +What question is posed within the barber paradox? +Back: Does the barber shave himself? +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +In the barber paradox, what contradiction arises when we assume the barber shaves himself? +Back: The barber *only* shaves those who do not shave themselves. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +%%ANKI +Basic +In the barber paradox, what contradiction arises when we assume the barber does not shave himself? +Back: The barber shaves *all* men who do not shave themselves. +Reference: “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). + +END%% + +## Bibliography + +* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). +* “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). \ No newline at end of file diff --git a/notes/set/index.md b/notes/set/index.md index 05323f6..38bf1c8 100644 --- a/notes/set/index.md +++ b/notes/set/index.md @@ -134,130 +134,392 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre END%% -## Classes - -The **Zermelo-Fraenkel alternative** avoids speaking of collections defined using set theoretical notation that are not sets. The **von Neumann-Bernays** alternative calls these **classes**. +## Extensionality +If two sets have exactly the same members, then they are equal: $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ %%ANKI Basic -In set theory, what is a class? -Back: A collection defined using set theoretical notation that isn't a set. +What does the extensionality axiom state? +Back: If two sets have exactly the same members, then they are equal. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + END%% %%ANKI Basic -Which two alternatives are usually employed when speaking of classes? -Back: The Zermelo-Fraenkel alternative and the von Neumann-Bernays alternative. +How is the extensionality axiom expressed using first-order logic? +Back: $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + END%% %%ANKI Basic -What does the Zermelo-Fraenkel alternative say about classes? -Back: It gives it no ontological status at all. +The following encodes which set theory axiom? $$\forall A, \forall B, (x \in A \Leftrightarrow x \in B) \Rightarrow A = B$$ +Back: The extensionality axiom. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + END%% %%ANKI Basic -What does the von Neumann-Bernays alternative say about classes? -Back: It refers to objects defined using set theory but that aren't actually sets. +How many sets exist with no members? +Back: Exactly one. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + +END%% + +%%ANKI +Basic +Which set theory axiom proves uniqueness of $\varnothing$? +Back: The extensionality axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Empty Set Axiom + +There exists a set having no members: $$\exists B, \forall x, x \not\in B$$ + +%%ANKI +Basic +What does the empty set axiom state? +Back: There exists a set having no members. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the empty set axiom expressed using first-order logic? +Back: $$\exists B, \forall x, x \not\in B$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +The following encodes which set theory axiom? $$\exists B, \forall x, x \not\in B$$ +Back: The empty set axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which set theory axiom proves existence of $\varnothing$? +Back: The empty set axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What two properties ensures definition $\varnothing$ is well-defined? +Back: The empty set exists and is unique. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the empty set defined using set-builder notation? +Back: $\{x \mid x \neq x\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Pairing Axiom + +For any sets $u$ and $v$, there exists a set having as members just $u$ and $v$: $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ + +%%ANKI +Basic +What does the pairing axiom state? +Back: For any sets $u$ and $v$, there exists a set having as members just $u$ and $v$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the pairing axiom expressed using first-order logic? +Back: $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +The following encodes which set theory axiom? $$\forall u, \forall v, \exists B, \forall x, (x \in B \Leftrightarrow x = u \lor x = v)$$ +Back: The pairing axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which set theory axiom proves existence of set $\{x, y\}$ where $x \neq y$? +Back: The pairing axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which set theory axiom proves existence of set $\{x\}$? +Back: The pairing axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +For sets $u$ and $v$, what name is given to set $\{u, v\}$? +Back: The pair set of $u$ and $v$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +In set theory, what does a singleton refer to? +Back: A set with exactly one member. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What set theory axiom is used to prove existence of singletons? +Back: The pairing axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the pair set $\{u, v\}$ defined using set-builder notation? +Back: $\{x \mid x = u \lor x = v\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Union Axiom + +### Preliminary Form + +For any sets $a$ and $b$, there exists a set whose members are those sets belonging either to $a$ or to $b$ (or both): $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ + +%%ANKI +Basic +What does the union axiom (preliminary form) state? +Back: For any sets $a$ and $b$, there exists a set whose members are all in either $a$ or $b$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the union axiom (preliminary form) expressed using first-order logic? +Back: $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +The following encodes which set theory axiom? $$\forall a, \forall b, \exists B, \forall x, (x \in B \Leftrightarrow x \in a \lor x \in b)$$ +Back: The union axiom (preliminary form). +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the union of sets $a$ and $b$ denoted? +Back: $a \cup b$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What two set theory axioms prove existence of e.g. $\{x_1, x_2, x_3\}$? +Back: The pairing axiom and union axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the union of set $a$ and $b$ defined using set-builder notation? +Back: $\{x \mid x \in a \lor x \in b\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Power Set Axiom + +For any set $a$, there is a set whose members are exactly the subsets of $a$: $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ + +%%ANKI +Basic +What does the power set axiom state? +Back: For any set $a$, there exists a set whose members are exactly the subsets of $a$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the power set axiom expressed using first-order logic? +Back: $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +The following encodes which set theory axiom? $$\forall a, \exists B, \forall x, (x \in B \Leftrightarrow x \subseteq a)$$ +Back: The power set axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is $x \subseteq a$ rewritten using first-order logic and $\in$? +Back: $\forall t, t \in x \Rightarrow t \in a$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the power set of set $a$ denoted? +Back: $\mathscr{P}{a}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the power set of set $a$ defined using set-builder notation? +Back: $\{x \mid x \subseteq a\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Subset Axioms + +For each formula $\_\_\_$ not containing $B$, the following is an axiom: $$\forall t_1, \cdots, \forall t_k, \forall c, \exists B, \forall x, (x \in B \Leftrightarrow x \in c \land \_\_\_)$$ + +%%ANKI +Basic +What do the subset axioms state? +Back: For each formula $\phi$ not containing $B$, the following is an axiom: $$\forall t_1, \cdots, \forall t_k, \forall c, \exists B, \forall x, (x \in B \Leftrightarrow x \in c \land \_\_\_)$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $\_\_\_$ be a wff excluding $B$. How is its subset axiom stated in first-order logic? +Back: $$\forall t_1, \cdots, \forall t_k, \forall c, \exists B, \forall x, (x \in B \Leftrightarrow x \in c \land \_\_\_)$$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +The following encodes which set theory axiom(s)? $$\forall t_1, \cdots, \forall t_k, \forall c, \exists B, \forall x, (x \in B \Leftrightarrow x \in c \land \_\_\_)$$ +Back: The subset axioms. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which axioms prove the existence of the union of two sets? +Back: The union axiom. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which axioms prove the existence of the intersection of two sets? +Back: The subset axioms. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the intersection of sets $A$ and $B$ denoted? +Back: $A \cap B$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the intersection of sets $a$ and $b$ defined using set-builder notation? +Back: $\{x \mid x \in a \land x \in b\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Which axioms prove the existence of the relative complement of two sets? +Back: The subset axioms. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Given sets $A$ and $B$, what does $A - B$ denote? +Back: The relative complement of $B$ in $A$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the relative complement of set $B$ in $A$ denoted? +Back: $A - B$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is the relative complement of set $b$ in $a$ defined using set-builder notation? +Back: $\{x \mid x \in a \land x \not\in b\}$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + END%% %%ANKI Cloze -The {1:Zermelo}-{2:Fraenkel} alternative is a separate approach from the {2:von Neumann}-{1:Bernays} alternative. +Union is to the {union axiom} whereas intersection is to the {subset axioms}. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + END%% %%ANKI Basic -Which set theory alternative avoids the term "class"? -Back: The Zermelo-Fraenkel alternative. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Which set theory alternative embraces the term "class"? -Back: The von Neumann-Bernays alternative. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What kind of mathematical object is $\{x \mid x \neq x\}$? -Back: A set. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What name is given to $\{x \mid x \neq x\}$? -Back: The empty set. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What kind of mathematical object is $\{x \mid x = x\}$? -Back: A class. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -What name is given to $\{x \mid x = x\}$? -Back: The class of all sets. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Are sets or classes more general? +The subset axioms ensure we do not construct what kind of mathematical object? Back: Classes. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Is every set a class? -Back: Yes. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Is every class a set? -Back: No. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - -%%ANKI -Basic -Assuming entrance requirement $\_\_\_$, what kind of mathematical object is $\{x \mid \_\_\_\}$? -Back: A class. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - + END%% ## Bibliography * Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). +* “Russell’s Paradox,” in *Wikipedia*, April 18, 2024, [https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437](https://en.wikipedia.org/w/index.php?title=Russell%27s_paradox&oldid=1219576437). * Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). \ No newline at end of file diff --git a/notes/set/trees.md b/notes/set/trees.md index e8f417d..89b319e 100644 --- a/notes/set/trees.md +++ b/notes/set/trees.md @@ -786,7 +786,7 @@ struct Node { struct Node *children[k]; }; ``` -Back: A $k$-ary child representation. +Back: A $k$-child representation. Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). Tags: c17 @@ -845,7 +845,7 @@ END%% Basic The following is a portion of what kind of tree representation? ![[binary-tree-nodes.png]] -Back: A $k$-ary (binary) child representation. +Back: A $k$-child (binary) representation. Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). END%% diff --git a/notes/x86-64/instructions.md b/notes/x86-64/instructions.md index a245f5f..edd172a 100644 --- a/notes/x86-64/instructions.md +++ b/notes/x86-64/instructions.md @@ -294,25 +294,16 @@ END%% The MOV instruction class has four primary variants: `movb`, `movw`, `movl`, and `movq`. There also exist zero extension and sign extension variations in the forms of MOVS and MOVZ. -| Instruction | Operands | Effect | Description | -| ----------- | -------- | ---------------- | ------------------------------------------- | -| `movb` | S, D | D <- S | Move byte | -| `movw` | S, D | D <- S | Move word | -| `movl` | S, D | D <- S | Move double word | -| `movq` | S, D | D <- S | Move quad word | -| `movabsq` | I, R | R <- I | Move quad word | -| `movzbw` | S, R | R <- ZE(S) | Move zero-extended byte to word | -| `movzbl` | S, R | R <- ZE(S) | Move zero-extended byte to double word | -| `movzwl` | S, R | R <- ZE(S) | Move zero-extended word to double word | -| `movzbq` | S, R | R <- ZE(S) | Move zero-extended byte to quad word | -| `movzwq` | S, R | R <- ZE(S) | Move zero-extended word to quad word | -| `movsbw` | S, R | R <- SE(S) | Move sign-extended byte to word | -| `movsbl` | S, R | R <- SE(S) | Move sign-extended byte to double word | -| `movswl` | S, R | R <- SE(S) | Move sign-extended word to double word | -| `movsbq` | S, R | R <- SE(S) | Move sign-extended byte to quad word | -| `movswq` | S, R | R <- SE(S) | Move sign-extended word to quad word | -| `movslq` | S, R | R <- SE(S) | Move sign-extended double word to quad word | -| `cltq` | | %rax <- SE(%eax) | Sign-extend `%eax` to `%rax` | +| Instruction | Operands | Effect | Description | +| ------------ | -------- | ---------------- | ------------------------------------ | +| `mov[bwlq]` | S, D | D <- S | Move byte/word/double word/quad word | +| `movabsq` | I, R | R <- I | Move quad word | +| `movzb[wlq]` | S, R | R <- ZE(S) | Move zero-extended byte | +| `movzw[lq]` | S, R | R <- ZE(S) | Move zero-extended word | +| `movsb[wlq]` | S, R | R <- SE(S) | Move sign-extended byte | +| `movsw[lq]` | S, R | R <- SE(S) | Move sign-extended word | +| `movslq` | S, R | R <- SE(S) | Move sign-extended double word | +| `cltq` | | %rax <- SE(%eax) | Sign-extend `%eax` to `%rax` | Notice there is no `movzlq` instruction. `movl` covers this functionality since, by convention, instructions moving double words into a 64-bit register automatically zeroes out the upper 32 bits. @@ -757,7 +748,7 @@ END%% %%ANKI Basic -Besides effect memory computations, how else is `leaq` used? +Besides effective memory computations, how else is `leaq` used? Back: For certain arithmetic operations. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. @@ -765,7 +756,7 @@ END%% %%ANKI Basic -Assume `%rbx` holds $p$ and `%rdx` holds $q$. What is the value of `%rax` in the following? +Assume `%rdx` holds $q$. What is the value of `%rax` in the following? ```asm leaq 9(%rdx),%rax ``` @@ -787,7 +778,7 @@ END%% %%ANKI Basic -Assume `%rbx` holds $p$ and `%rdx` holds $q$. What is the value of `%rax` in the following? +Assume `%rbx` holds $p$. What is the value of `%rax` in the following? ```asm leaq 2(%rbx, %rbx, 7),%rax ``` @@ -798,7 +789,7 @@ END%% %%ANKI Basic -Assume `%rbx` holds $p$ and `%rdx` holds $q$. What is the value of `%rax` in the following? +Assume `%rdx` holds $q$. What is the value of `%rax` in the following? ```asm leaq 0xE(, %rdx, 3),%rax ``` @@ -807,6 +798,277 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +### Unary Operations + +| Instruction | Operands | Effect | Description | +| ----------- | -------- | ---------- | ------------ | +| `inc[bwlq]` | D | D <- D + 1 | Increment | +| `dec[bwlq]` | D | D <- D - 1 | Decrement | +| `neg[bwlq]` | D | D <- -D | Negate | +| `not[bwlq]` | D | D <- ~D | Complement | + +%%ANKI +Basic +What four variants do `INC` instructions take on in x86-64? +Back: `incb`, `incw`, `incl`, `incq` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D + 1$? +Back: `INC` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +What combination of source and destination types is prohibited in unary instructions? +Back: A source and destination memory address. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +What do the instructions in the `INC` instruction class do? +Back: Increments the specified destination by $1$. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`INC`} instruction class is to x86-64 whereas the {`++`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +What do the instructions in the `DEC` instruction class do? +Back: Decrements the specified destination by $1$. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D - 1$? +Back: `DEC` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`DEC`} instruction class is to x86-64 whereas the {`--`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +What do the instructions in the `NEG` instruction class do? +Back: Negates the specified destination. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow -D$? +Back: `NEG` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`NEG`} instruction class is to x86-64 whereas the {`-`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +What do the instructions in the `NOT` instruction class do? +Back: Complements the specified destination. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow \textasciitilde D$? +Back: `NOT` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`NOT`} instruction class is to x86-64 whereas the {`~`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +What distinguishes the `NEG` and `NOT` instruction classes? +Back: The former negates, the latter complements. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +### Binary Operations + +| Instruction | Operands | Effect | Description | +| ------------ | -------- | ----------- | -------------- | +| `add[bwlq]` | S, D | D <- D + S | Addition | +| `sub[bwlq]` | S, D | D <- D - S | Subtraction | +| `imul[bwlq]` | S, D | D <- D * S | Multiplication | +| `xor[bwlq]` | S, D | D <- D ^ S | Exclusive-or | +| `or[bwlq]` | S, D | D <- D \| S | Or | +| `and[bwlq]` | S, D | D <- D & S | And | + +%%ANKI +Basic +What four variants do `ADD` instructions take on in x86-64? +Back: `addb`, `addw`, `addl`, `addq` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +What combination of source and destination types is prohibited in `ADD` instructions? +Back: A source and destination memory address. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D + S$? +Back: `ADD` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`ADD`} instruction class is to x86-64 as the {`+=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D - S$? +Back: `SUB` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which `SUB` instruction is equivalent to `decq %rcx`? +Back: +```asm +subq $1, %rcx +``` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How does Bryant et al. recommend reading `SUB` instructions? +Back: As subtracting the first operand *from* the second. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`SUB`} instruction class is to x86-64 as the {`-=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D * S$? +Back: `IMUL` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`IMUL`} instruction class is to x86-64 as the {`*=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D \;^\wedge\; S$? +Back: `XOR` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`XOR`} instruction class is to x86-64 as the {`^=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D \mid S$? +Back: `OR` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`OR`} instruction class is to x86-64 as the {`|=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which instruction class corresponds to effect $D \leftarrow D \;\&\; S$? +Back: `AND` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +The {`AND`} instruction class is to x86-64 as the {`&=`} operator is to C. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + ## Bibliography * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.