0

We know that a string is finite but on the other hand we know that a language is a set of strings(possibly infinite) over an alphabet. Isn't this relation a contradiction?

SaJa
  • 3
  • 6

2 Answers2

3

Every natural number has a finite number of digits in it. Yet, there's an infinite number of natural numbers.

In other words, as long as there's no bound on the number of digits per number, you can always create longer and longer numbers from the same alphabet.

Oak
  • 26,231
  • 8
  • 93
  • 152
  • I see what you mean but if we talk about a machine that is not possible because there is always a boundary otherwise the machine(computer) might spit an error such as segmentation fault. – SaJa Feb 20 '16 at 15:05
  • 3
    @SaJa If you're talking about language as a set of strings, then you're not talking about actual computers. Turing machine or any other equivalent model (like RAM) are in practice closest to actual computers, even though they require infinite memory. In theory, since computers have limited memory, they're just (really huge) finite state machines. – svick Feb 20 '16 at 17:27
  • @SaJa as svick wrote, if the question is about theoretical computer science, there's no limit. If it's about a concrete machine, then the length of each word is limited and the alphabet is limited, which immediately means that the size of the language is limited. – Oak Feb 20 '16 at 18:49
  • @SaJa, isn't that moving the goalposts? Your question was theoretical, but when it was answered, your comment switches to an unrelated practical objection. – comingstorm Feb 26 '16 at 17:45
  • @comingstorm that was not the case at all, i needed an answer and the answer I received wasn't related to the question. – SaJa Feb 27 '16 at 10:10
  • @SaJa You are absolute correct with respect to real computers. Real computers are not capable of recognizing infinite languages. As such, they recognize only a subset of the regular languages, even in theory. We usually ignore this objection since other models are more useful abstractions when we aren't interested in recognizing really big strings - but your objection is technically correct. – Patrick87 Mar 01 '16 at 14:39
2

In the phrase "a language is a set of strings(possibly infinite) over an alphabet", the parenthetical observation relates to the set, not to the strings. That is, it might equally well have been described as "a set (possibly infinite) of (finite) strings". There is no contradiction in the definition (properly understood), because it is the strings which are said to be finite and the set which is said to be infinite.

Note, by the way, that it is possible to allow infinite strings and to consider the properties of languages defined as sets of finite or infinite strings, but pretty much all work on formal languages restricts sentences to finite length; the restriction makes a lot of questions tractable which are not tractable for the case where infinite strings are allowed.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65