Semantic pedantics

No one is perfect.
\forall x \neg P(x)
\equiv \neg P(x_1) \wedge \neg P(x_2) \wedge \dots \wedge \neg P(x_n)
\equiv \neg \exists x P(x)

Not everyone is perfect.
\neg \forall x P(x)
\equiv \neg (P(x_1) \wedge P(x_2) \wedge \dots \wedge P(x_n))

After DeMorgan’s Law
\neg P(x_1) \vee \neg P(x_2) \vee \dots \vee \neg P(x_n) \equiv \exists x \neg P(x)

And the answer key also has this:

Not everybody is your friend or someone is not perfect.
(\forall x \neg F(x)) \vee (\exists x \neg P(x))

So, “everybody” refers to “one” and “someone” is the same as “everyone.”

Programmatic spittoon

Using AutoIt variables to store SQL strings is like writing HTML with Javascript: an activity that makes me question whether a programming language ought to produce executive text. HTML is markup, but the tags specify certain rendering decisions to a browser engine, even if it’s something as trivially distinctive as a table versus an image. And what about VBA against a template? Loops over Cells().

That makes me think of XML as the “file format” of the Internet. If we relegate presentation to CSS and <div> tags, could we rely on the DOM as our tree of hooks? From each branch a useful node, and to each node collection a structured XML: transmittance of which becomes a Javascriptural understanding of rows and columns.

The concept hovers dangerously close to userland, where requests for column widths, color formatting, and four decimal places instead of two are seen as programmer responsibilities. A good template will let the user make truly cosmetic changes. Excel is smart enough to adjust formulas when a row is added, which is awesome.

Will I have to learn C# to programmatically create PivotTables? It would be nice to run it, one-and-done, and have it prepared for view-sumption, without opening Excel.

Database for fun and re-creation

One common pattern of databases – one which I have never heard in imagined classes in my mind for databases – is to create them from existing data. Workbooks are not inherently relational, and people don’t construct sheets with long arrays of numbers.

  A B C D E F ...
1 7 9 2 4 1 8
2 2 4 1 4 5 9
3 2 4 5 6 2 3
4 1 1 1 4 5 1
5 4 5 9 1 2 4

One of my aggregate tables could look like this in Excel. All of its content, all that duplicate stuff, is squirreled away in other tables. You’d need a clever macro to spot you for dupes on a regular worksheet to trust VLOOKUP() for the rest: that function drives the workbook world. Plus, if you’re thinking relationally in Excel, you’re seriously awesome.

But I mean reconstructing the database, building it from its input, which might have been another database. At first it sounds like a waste of time, like reinventing the wheel. I’ve found that such activities hone the mind to woodwork and mechanics, foundations of fundamentals, while the actual Rolling of Things becomes a philosophical actualization.

The furnished API

I’ve got AutoIt issuing COM-based statements to ADOB objects, forging tables in created Access databases. Wild stuff. I tried to separate the connection, query and record set, but they’re all linked. Each abstraction is its own packaged transaction. I’m okay with this because the access patterns are well-defined, if not repetitive. This interface is meant for a particular database for one application. The functions could be reused in other contexts, but I do not foresee that chance. After all, website visitors do not get to execute arbitrary SQL to interact with the backend; they click buttons and fill forms.

I use “SELECT @@IDENTITY” to get the latest AutoNumbered ID on a new Insert. I run parallel arrays like a furtive drug-runner through the asteroid belt, on my way to a gas giant burglar who calls himself “Bon Belcher.” (Mind your global indices.)

I’ve got a month left before I can get my road bike. The new models come out soon. My trepidation is tempered by abandon: the bike, bought, is a bridge burned. There’s one way out, and that’s the street-path out. Never mind the Abercrombie & Fitch; I’ve got a hundred psi on my mind.

Collecting old computer books

No matter what people have told you, you can’t learn UNIX from the manuals, or even the sources. UNIX is so much more than that. To understand UNIX is to understand its users and its applications, as well as its failures and flaws. This is just some of what this book hopes to cover.

— “Life with UNIX: A Guide for Everyone,” Preface

I thought it would be enough to have the man pages and a Thinkpad, but evidently you also need to put some work in. I never consciously learned Windows, and only by dint of work am I digging into Excel, VBA and Access. I search for COM snippets for accessing the ADO library, little DAO-patterned formlets; AutoIt again proves its prowess.

I’ve romanticized C and systems programming and the old languages, knowing that in practice – at work – it’s easier to Dim a variable and slam a loop through the sheets, with some clever play at the end borrowed from K&R samples (not even past the first chapter):

Dim lRow As Long

lRow = 6 ' template header starts at row 6
While Cells(lRow, 1) <> ""
  Cells(lRow, 13) = "=SUM(RC[-1]:RC[-13])"
  lRow = lRow + 1
Cells(lRow, 13) = "=SUM(R[-1]C:R[-" & lRow - 6 & "]C)" ' cute

The code sums numbers across a row, and then puts the vertical sum at the bottom. When the loop exits, lRow is the blank cell underneath the burgeoning column. Did you know WordPress supports \LaTeX? Now it’s perfect.

Serialized access to a database

One requirement of the application is to serialize writes. What does that mean? The same record cannot be added to the table once it exists. That’s what databases are good for – primary keys warding the dupes. But I did not want to repeat a lengthy string as a key when the AutoNumber, a Long Integer type, would suffice.

I did compromise and make the Text string a primary key in the SerializedItem table, but there are no other repeats outside it: once a record is created in the SerializedItem table, its token is an auto-incremented ID as a foreign key.


When an item is to be entered into the database, SerializedItem is checked for the tokenID. The tokenID identifies the item to all other tables (Lookup and Item). With the tokenID, we check if the item has been assigned a cubby by examining the Lookup table.

If the item hasn’t been assigned a cubby, we ask the user if he wants to assign a cubby to the item. If so, the database takes his cubby and itemSKU input and adds records to StorageTrack, Item and Assign tables.

With this design, items cannot be assigned to different cubbies. Serialization is gained by checking the itemSKU attribute as the primary key. The database should throw an error if anyone else tries to assign a different cubby to an item whose SKU already exists; instead, the user would be asked to move that item to the same cubby.

This is all theoretical; I haven’t tried it. Hopefully it’s good enough for teddy bears and trains for a toy room and IKEA furnishings.

Edit: A better way is to issue an SQL specifying UNIQUE (x,y,z) constraint rather than two tables to track serialized, non-duplicate records.

The fear of insufficiency

I began the next section of discrete math. It covers predicates and quantifiers. These are the loops of the logic world, stretched blankets over exact universes. One quantification, the universal, implies a long conjunction: for every  x1-x2-dot-dot-dot-xn, apply AND to each of them. It takes one counterexample to show a universal quantification false.

I met the propositional function P(x), which encapsulates the subject and predicate of a statement. Specifying the domain lets us assign values to the variable. Since we’re in logic land, each such assignment evaluates to a truth value, True or False.

Multiple variables create instances of tuples. Databases also use the term tuple. Could the row of a database be an instance of a long function P(a, b, c, …, z)? The binding of one or more of those variables specifying uniqueness, and each row mapped to an array with one less dimension: tables as 2D, mappings as collapse to 1-dimensional, linear collections.

But I speak of fear. One example had math: x2-ge-x. Rosen broke it down to x-times-x-minus-1-ge-0. Then he goes to say it’s true if and only if x-le-0 or x-ge-1. How did he get there? I became worried that my math journey would abruptly cease at section three, chapter one.

Wolfram Alpha gave hints, but ultimately I made a table:

Universe: real numbers
x    x*(x-1)  x*(x-1)>=0
-2.0 6        T
-1.5 3.75     T
-1.0 2        T
-0.5 2.25     T
0    0        T
0.5  -0.25    F
1.0  0        T
1.5  0.25     T
2.0  2        T

Somewhere between 0 and 1, the values we assign to the x variable do not result in a true inequality. Another way to say “x <= 0 or x >=1” is 0-lt-x-lt-1. Can we believe that, though? What if there’s some number 0.000029482 that satisfies greater than or equal to zero? We can think through some assumptions:

x*(x-1) >= 0
A. if x = 0, x*(x-1) = 0
B. if x < 0,
x * (x - 1) >= 0
(x - 1) <= 0     | divide by x (-), switches sign
x <= 1           | add 1 to both sides
x >= 1           | multiply by -1 on both sides (x is -)

The inequality is true when x <= 0.

x*(x-1) >= 0
A. if x = 1, x*(x-1) = 0
B. if x > 1,
x * (x - 1) >= 0
(+) * (+) >= 0   | positive times positive is >= 0

The inequality is also true when x >= 1.

x*(x-1) >= 0
if 0 < x < 1,
x * (x - 1) >= 0
(+) * (-) >= 0 ? | x (less than 1) minus 1 is negative (so, False)

When x is between 0 and 1, the inequality is false. Going back to the universal quantifier, for every x, P(x), with the domain of all real numbers, is false.

I generalized the process thus:

  • Gather “data”: make a table. play with numbers. fiddle around. You are the compiler.
  • Discover the “rules”: 0 < x < 1
  • Check yourself: if x <= 0, if x >= 1, if 0 < x < 1
  • Conclude: agree with the author or disagree; move on

Short dip into negative space

A compound proposition is made up of multiple propositions. If we can assign a truth value to each proposition that makes the compound proposition true, then the compound proposition is satisfiable. If every assignment leads to the compound proposition being true, then the compound proposition is a tautology. Tautologies are true “no matter what.”

p | p v ~p
T     T
F     T

The compound proposition is always true regardless of the assignment of truth values to p. The compound proposition p OR NOT p is a tautology.

An algorithm can be written that determines if a compound proposition is satisfiable. Such an algorithm could be used in a loop. For each assignment, continue until an assignment of propositions is unsatisfiable. If so, exit: that compound proposition is not a tautology. You would have to test every assignment.

Rosen hints at an alternative: try the negation of the compound proposition. If a compound proposition is a tautology, it will always be True, True, …, True for any assignment of Ts and Fs. Then its negation would always be False, False, …, False. However, with the negated version of the compound proposition, we only need to test one instance of satisfiability: if the NOT version is satisfiable once, the original compound proposition is not a tautology.

You can show a compound proposition is true every time, or that its negation is true once. If the negated version is True with that assignment, then the original version will evaluate to False. One False means the compound proposition is not always true, and you need “always True” to get a tautology.

When you are proving something, you could assume the opposite – then you only need to show one example. That means the original given can’t always be true. Would you prefer to demonstrate one counterexample or an exhaustive* listing?

* “Define exhaustive.”

Speculative generator

A story being an aggregate of chunked words to bond various explanations, then it could show us the progression of a thought process where each compound proposition is satisfied by one combination of truth values.

We plug into this “world engine” certain facts [1], and it creates random compound propositions that are all true for some combination of True and False for each assignment of p, q, r, s, etc.

Our work consists of kicking out each false in some way, changing our preconceptions in each chapter, assuming a different role, until things begin to resolve toward the One Path in which every compound proposition is True.

p q r s C1 C2 C3 C4 C5 ...
T T T F T  F
T T F T T  T  F
T T F F T  T  T  F
T F T T T  T  T  T  F
T F T F T  T  T  T  T

It’s a harebrained idea, attempting to mechanize what intuition and skill melds in a writer to weave magic. Even if the method is systematic, all the reader cares about is the “user experience.” For books, that’s great writing and consistent verisimilitude. People can tell artificiality without training.

But as a check against our gut in the middle of a complex narrative, it may have some use. If I bang one out before NaNoWriMo, that would be a nice laboratory for its efficacy.

Inspired by exercise 53 of Rosen’s 5e “Discrete Mathematics and Its Applications.” In the picture below, we see several ways that every compound proposition is satisfied. Ideally, there would only be one set of assignments to p, q, r, and s that made every compound proposition True.


The direct solution is p AND NOT q AND NOT r AND NOT s, where p is True and q, r, and s are all False. We call that Author’s Intent.

[1] Cultural perspective or a moral, objective one – the viewpoint of the Main Character?

The not-not is

Given an implication, we have its converse, contrapositive and inverse:

p -> q
q -> p
~q -> ~p (contrapositive)
~p -> ~q (inverse)

The original implication is logically equivalent to its contrapositive. The converse and inverse are logically equivalent to each other.

p -> q
~p v q, because p -> q = ~p v q
q v ~p, because p v q = q v p
~(~q) v ~p, because ~(~p) = p
~q -> ~p, because p -> q = ~p v q

So we see that an implication and its contrapositive are logically equivalent.

Given p -> q,
q -> p
~q v p, because p -> q = ~p v q
p v ~q, because p v q = q v p
~(~p) v ~q, because ~(~p) = p
~p -> ~q, because p -> q = ~p v q

And this shows the converse and inverse of an implication are logically equivalent.

I ordered a raft of books, old books, costing about a cent each, whose value outweighs the ship rate of which I paid the majority of the total. Books from shops into the hands of a collector, a private math where communion competes with pragmatics.