Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**Hannibal lecter****Member**- Registered: 2016-02-11
- Posts: 225
- Website

write a regular expression with just two a's each word?

is following answer true?

ans : (aa + b*)

I teacher answer was " b*ab*ab*

is the first answer true too?

Wisdom is a tree which grows in the heart and fruits on the tongue

Offline

**bob bundy****Administrator**- Registered: 2010-06-20
- Posts: 8,386

hi Hannibal lecter

I think it is true. But say more about what led up to the question.

What is the mathematical topic ?

Do you have a definition for an 'expression' ?

Does aa mean 'a AND a' ?

Does a + b mean 'a OR b ?

Does a* mean 'NOT a' ?

Bob

Children are not defined by school ...........The Fonz

You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei

Offline

**Hannibal lecter****Member**- Registered: 2016-02-11
- Posts: 225
- Website

yes it's mean a or b

aa + b* and it's wrong for { babab, bbabbabb,bbbabbbbabbbb,....}

because the expretion of aa + b* is = { aa , b , aab,baa,...}

Wisdom is a tree which grows in the heart and fruits on the tongue

Offline

**bob bundy****Administrator**- Registered: 2010-06-20
- Posts: 8,386

hi Hannibal lecter

Sorry; I don't think I've understood this question at all.

aa + b* is = { aa , b , aab,baa,...}

I'm interpreting aa + b* as meaning "a AND a OR NOT b

aa "a AND a"

b

aab "a AND a AND b"

etc.

and {...} as meaning "the set containing ...

How are these equal?

Bob

Children are not defined by school ...........The Fonz

You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei

Offline

Hi bob,

Hannibal Lecter is referring to regular expressions in formal language theory.

"a" denotes the set containing the character a, i.e. a = {a}.

"ε" denotes the set containing the empty string (which has zero length).

"∅" as usual denotes the empty set.

All characters belong to some alphabet A, from which one can derive sentences. For instance, a string of parentheses like '))(((' is a sentence formed from the alphabet {(, )}. Some sentences will be true with respect to one language, but false with respect to others. For example, you might like to write some sentence which claims that every element of a set is either even or odd. That sentence would be true in , but not in , for instance (because we can't establish an order on without introducing a norm, e.g. absolute value). This might seem trivial, but it allows us to distinguish between different structures (in this case, that and are different groups). These two groups are clearly not isomorphic, but we can apply the same principle to prove that two groups might not be. The nice thing about this is that this can work with lots of types of structures, even graphs.The * notation refers to the Kleene star, which can either operate on sets of strings, or sets of characters. If S is some set of strings derived from some alphabet A, then S* is the smallest superset containing ε which is also closed under concatenation. In other words, S* has to contain all possible concatenations of whichever strings it contains, e.g. {ab, c}* = {ε, ab, c, abab, abc, ...}. I'm sure there's some kind of rule dictating which elements are listed first. Unless the set of characters is trivial (i.e. empty set or ε) then the Kleene star applied to S will give us an infinite set (which is always countable). So in this case, b* = {ε, b, bb, bbb, bbbb, ...}.

Another example: ab* = {a, ab, abb, abbb, abbbb, ...}

+ means 'choose either/or'. For example, "a + b" means "choose either a or b". So (a+b)* means "choose either a or b, then take all possible concatenations". In other words, (a+b)* is the set of all possible words you can make from {a,b}.

So aa + b* = {aa, b, aab, baa, bb, aabb, bbaa, bbb, ...}

Hannibal Lecter is asking for the sentence which generates all words containing exactly two instances of the character 'a', which is "b*ab*ab*".

aa + b* does not generate a set containing only characters with exactly two instances of the letter 'a', because it contains the elements b, bb, bbb, bbbb, ... all of which don't have any 'a' in them.

In general, the regular expression b*ab*ab*a...b*ab* (where 'a' appears *n* times) generates all words which contain the letter 'a' exactly *n* times.

Infinite strings are a different story.

**LearnMathsFree: Videos on various topics.New: Integration Problem | Adding FractionsPopular: Continued Fractions | Metric Spaces | Duality**

Offline

**bob bundy****Administrator**- Registered: 2010-06-20
- Posts: 8,386

hi zetafunc,

Thanks for the explanation. Now the question and answer are both clear to me.

Bob

Children are not defined by school ...........The Fonz

You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei

Offline