bha_1999
bha_1999

Reputation: 39

Computer languages are considered as finite sets, and mathematically set operations can be performed on them

I am reading about Compiler Design - Lexical Analysis and I came across this sentence. I didn't get it. What set operations can be performed on Computer Languages and how exactly? How does union, intersection etc look like in a computer language, someone please explain

Here's the link from where I am reading:

https://www.tutorialspoint.com/compiler_design/compiler_design_lexical_analysis.htm

Upvotes: 0

Views: 165

Answers (1)

rici
rici

Reputation: 241691

The only sense in which computer languages are finite sets is the practical limitation that we live in a finite universe. In this finite universe, everything has a limit. That's probably a useful perspective for many practical problems but it doesn't help understand mathematical models. (I'm not sure how useful your source is, either. Personally, I'd suggest one of the traditional textbooks.)

The framework of formal language theory defines a language as an infinite set of finite strings. That set is simply the set of valid strings -- in this case computer programs.

The intersection of two languages (considered as sets of valid sentences) is just like any other set intersection: it consists of all things which are in both sets. Similarly, the union of two languages is theset of strings which are in at least one of the languages.

As examples, we could (in theory) construct the set of programs which are both valid C and which contain the identifier future. Or the set of strings which are either JSON or XML. And so on.

Upvotes: 1

Related Questions