|
1 | 1 | <?xml version="1.0"?> |
2 | 2 | <section xml:id="general-intro_formal-and-natural-languages"> |
3 | 3 | <title>Formal and Natural Languages</title> |
4 | | - <p><term>Natural languages</term> are the languages that people speak, such as English, |
| 4 | + <p> |
| 5 | + <term>Natural languages</term> are the languages that people speak, such as English, |
5 | 6 | Spanish, and French. They were not designed by people (although people try to |
6 | 7 | impose some order on them); they evolved naturally.</p> |
7 | | - <p><term>Formal languages</term> are languages that are designed by people for specific |
| 8 | + <p> |
| 9 | + <term>Formal languages</term> are languages that are designed by people for specific |
8 | 10 | applications. For example, the notation that mathematicians use is a formal |
9 | 11 | language that is particularly good at denoting relationships among numbers and |
10 | 12 | symbols. Chemists use a formal language to represent the chemical structure of |
|
19 | 21 | Tokens are the basic elements of the language, such as words, numbers, and |
20 | 22 | chemical elements. One of the problems with <c>3=+6$</c> is that <c>$</c> is not a |
21 | 23 | legal token in mathematics (at least as far as we know). Similarly, |
22 | | - <subscript>2</subscript>Zz is not legal because there is no element with the abbreviation |
23 | | - <c>Zz</c>.</p> |
| 24 | + <subscript>2</subscript>Zz is not legal because there is no element with the abbreviation |
| 25 | + <c>Zz</c>. |
| 26 | + </p> |
24 | 27 | <p>The second type of syntax rule pertains to the <term>structure</term> of a statement— |
25 | 28 | that is, the way the tokens are arranged. The statement <c>3=+6$</c> is |
26 | 29 | structurally illegal because you can't place a plus sign immediately after an |
27 | 30 | equal sign. Similarly, molecular formulas have to have subscripts after the |
28 | 31 | element name, not before.</p> |
29 | 32 | <p>When you read a sentence in English or a statement in a formal language, you |
30 | 33 | have to figure out what the structure of the sentence is (although in a natural |
31 | | - language you do this subconsciously). This process is called <term>parsing</term>.</p> |
| 34 | + language you do this subconsciously). This process is called <term>parsing</term>. |
| 35 | + </p> |
32 | 36 | <p>For example, when you hear the sentence, <q>The other shoe fell</q>, you understand |
33 | 37 | that the other shoe is the subject and fell is the verb. Once you have parsed |
34 | 38 | a sentence, you can figure out what it means, or the <term>semantics</term> of the sentence. |
|
107 | 111 | </statement> |
108 | 112 | <feedback> |
109 | 113 | Actually both languages can be parsed (determining the structure of the sentence), but formal languages can be parsed more easily in software. |
110 | | - </feedback> |
| 114 | + </feedback> |
111 | 115 | </choice> |
112 | 116 | <choice correct="yes"> |
113 | 117 | <statement> |
114 | 118 | <p>ambiguity, redundancy, and literalness.</p> |
115 | 119 | </statement> |
116 | 120 | <feedback> |
117 | 121 | All of these can be present in natural languages, but cannot exist in formal languages. |
118 | | - </feedback> |
| 122 | + </feedback> |
119 | 123 | </choice> |
120 | 124 | <choice> |
121 | 125 | <statement> |
122 | 126 | <p>there are no differences between natural and formal languages.</p> |
123 | 127 | </statement> |
124 | 128 | <feedback> |
125 | 129 | There are several differences between the two but they are also similar. |
126 | | - </feedback> |
| 130 | + </feedback> |
127 | 131 | </choice> |
128 | 132 | <choice> |
129 | 133 | <statement> |
130 | 134 | <p>tokens, structure, syntax, and semantics.</p> |
131 | 135 | </statement> |
132 | 136 | <feedback> |
133 | 137 | These are the similarities between the two. |
134 | | - </feedback> |
| 138 | + </feedback> |
135 | 139 | </choice> |
136 | 140 | </choices> |
137 | 141 | </exercise> |
|
146 | 150 | </statement> |
147 | 151 | <feedback> |
148 | 152 | It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding. |
149 | | - </feedback> |
| 153 | + </feedback> |
150 | 154 | </choice> |
151 | 155 | <choice correct="yes"> |
152 | 156 | <statement> |
153 | 157 | <p>False</p> |
154 | 158 | </statement> |
155 | 159 | <feedback> |
156 | 160 | It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding. |
157 | | - </feedback> |
| 161 | + </feedback> |
158 | 162 | </choice> |
159 | 163 | </choices> |
160 | 164 | </exercise> |
|
0 commit comments