Formal Language A formal language is defined by two components: - Alphabet - Rules of syntax Formal Language
Formal Language ‘Alphabet’ (Similar to words in natural language) • The alphabet is a precisely defined as a finite set. • Elements of the set are called, ‘symbols’. Formal Language
Formal Language ‘Rules of syntax’ (Equivalent of sentences in a natural language) • This defines how to construct ‘strings’ of the language out of ‘symbols’ Formal Language
Formal Language Example: pencil notation (Equivalent of sentences in a natural language) It is not usual to be able to list all the strings in a language. Therefore, there needs to be someway of describing the ‘rules’ that are linked to the language. • Alphabet {H, B, 1, 2, 3, 4} • Strings {“ 4 B”, “ 3 B”, “ 2 B”, “HB”, “ 4 H”, “ 3 H”, “ 2 H”, “H”} (Note, the above are strings not symbols, strings are in double quotes) Formal Language
Formal Language Example: pencil notation (Equivalent of sentences in a natural language) It is not usual to be able to list all the strings in a language. Therefore, there needs to be someway of describing the ‘rules’ that are linked to the language. • Alphabet {H, B, 1, 2, 3, 4} • Strings {“ 4 B”, “ 3 B”, “ 2 B”, “HB”, “ 4 H”, “ 3 H”, “ 2 H”, “H”} (Note, the above are strings not symbols, strings are in double quotes) Formal Language