James B. Wilson Professor of Mathematics
\[8(7+3)^2?\]
\(=8(10)^2\)
\(=8\times 100\)
\(=800\)
This And That
This
That
And
\(3+(-7)\)
3
\(-7\)
7
+
-
\(3+(-7)\)
3
\(-7\)
7
+
-
-4
3+(-7)=-4
=
root
leaf
Trees can be visualized as plants, roots, file folders..
illegal not a new node
Major Fact: Every leaf has a unique path to the root. Hence, grammar as rooted trees has a unique interpretation.
<Subject> ::= Jack
<Subject> ::= Jill
<Modifier> ::= up
<Modifier> ::= down
<Objects> ::= hill
<Objects> ::= river
<<Sentence>> ::= <Subject> went <Modifier> the <Objects>.
Accepted "well-formed" sentences
Rejected "ill-formed" sentences
<subject> ::= Jack
. is called Backus-Naur Form or "BNF" <Subject> ::= Jack
<Subject> ::= Jill
<Modifier> ::= up
<Modifier> ::= down
<Objects> ::= hill
<Objects> ::= river
<<Sentence>> ::= <Subject> went <Modifier> the <Objects>.
<Subject> ::= Jack | Jill
<Modifier> ::= up
| down
<Objects> ::= hill
<Objects> ::= river
<<Sentence>> ::= <Subject> went <Modifier> the <Objects>.
Use "|" to separate options
Nat
<Digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<Nat> ::= 0 | <Digit> | <Digit><Nat>
<Digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<Nat> ::= 0 | <Digit> | <Digit><Nat>
<Digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<Nat> ::= 0 | <Digit> | <Digit><Number>
<Int> ::= <Nat> | -<Nat>
This now accepts "-541". (-541:Int or \(-541:\mathbb{Z}\))
Warning about artifacts: Accepts "-0" and "0" but doesn't know 0=-0!
int 5
or 5:Int. -- Computation
<Nat> ::= ...# already done
<Decimal> ::= ... # can be done, more work.
<Variable> ::= x | y | z
<Polynomial> ::= <Decimal>
| <Variable>
| (<Polynomial>+<Polynomial>)
| (<Polynomial>*<Polynomial>)
| (<Polynomial>)^<Nat>
Accepts...\[(3.14+x\hat{\hspace{3mm}} 2)*(y+(2*z))\]
Rejects...\[(\pi+x^2)(y+2z)\]
While logical grammars are predictable;
humans like a bit of flexibility.
Debates still rage over whether English is a "context-free grammar" (see James Higginbotham)
Technical Jargon: Logical grammars are "Context Free".
Those make trees.
This And This
This
This
And
We argue with operators,
which combine lists of data.
If we reuse data we just put it in as many times as used.
This And This
This
And
\(3+7\)
3
7
+
\[\begin{array}{cc} & 3\\ + & 7\\ \hline & 10\end{array}\]
> 3 + 7
10
This And This
This
That
And
\[\begin{array}{cc} & \text{this}\\ \wedge & \text{that}\\ \hline & \text{this}\wedge \text{that}\end{array}\]
> this = true
> that = false
> this && that
false
\[\begin{array}{cc} & 3\\ & 7\\ + & 3\\ \hline & 13\end{array}\]
\(3+7+3\)
[3,7,3]
sum
> as = [3,7,3]
> sum(as)
13
Parse this formula
\(\div\)
\(\circ\)
\(+\)
\(+\)
Sentence that parse are called "well-formed" and those are the only ones we bother to user in our logic.