0% found this document useful (0 votes)
11 views55 pages

Unit - 3 Context Free Grammar: Prof. Dixita B. Kagathara

The document covers the theory of Context Free Grammar (CFG) as part of the Theory of Computation course. It includes topics such as the Chomsky hierarchy, types of grammars, recursive definitions, and examples of CFGs. Additionally, it discusses derivation methods, ambiguity in grammar, and applications of CFG in programming languages.

Uploaded by

22ce146
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views55 pages

Unit - 3 Context Free Grammar: Prof. Dixita B. Kagathara

The document covers the theory of Context Free Grammar (CFG) as part of the Theory of Computation course. It includes topics such as the Chomsky hierarchy, types of grammars, recursive definitions, and examples of CFGs. Additionally, it discusses derivation methods, ambiguity in grammar, and applications of CFG in programming languages.

Uploaded by

22ce146
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Theory of Computation (TOC)

GTU # 3160704

Unit – 3
Context Free
Grammar

Prof. Dixita B. Kagathara


Computer Engineering
Department
Darshan Institute of Engineering & Technology, Rajkot
[email protected]
+91 - 97277 47317 (CE
Department)
Topics to be covered
 Looping
• Chomsky hierarchy
• Context free grammar
• Recursive definition
• FA to regular grammar
• Derivation
• Ambiguity & unambiguous grammar
• Simplified forms & normal forms
• CFG to CNF
• Union, Concatenation & Kleene’s of CFG
Chomsky Hierarchy
Chomsky hierarchy (Classification of grammar)

Grammar

Unrestricted Restricted
grammar (type 0) grammar

Context Context Regular


sensitive free grammar
grammar grammar (type 3)
(type 1) (type 2)

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 4
Type 0 grammar (Phrase Structure Grammar)
 Their productions are of the form:

 where both and can be strings of terminal and nonterminal symbols.


 Example: S → ACaB
Bc → acB
CB → DB
aD → Db

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 5
Type 1 grammar (Context Sensitive Grammar)
 Their productions are of the form:

 where A is non terminal and , , are strings of terminals and non


terminals.
 The strings and may be empty, but must be non-empty.
 Here, a string can be replaced by (or vice versa) only when it is enclosed
by the strings and in a sentential form.
 Example: AB → AbBc
A → bcA
B→b

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 6
Type 2 grammar (Context Free Grammar)
 Their productions are of the form:

 Where is non terminal and is string of terminals and non terminals.


 Example: S → Xa
X→a
X → aX
X → abc

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 7
Type 3 grammar (Linear or Regular grammar)
 Their productions are of the form:
or
 Where are non terminals and is terminal.
 Example: X → a | aY
Y→b

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 8
Hierarchy of grammar

Type 3
(Regular)

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 9
Context Free Grammar
Context Free Grammar
 A context free grammar (CFG) is a 4-tuple where,
is finite set of non terminals,
is disjoint finite set of terminals,
is an element of and it’s a start symbol,
is a finite set of productions of the form where and .
 Application of CFG:
1. CFG are extensively used to specify the syntax of programming
language.
2. CFG is used to develop a parser.

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 11
Context Free Language
 Let be a CFG. The language generated by is

 A language is a context free Language (CFL) if there is a CFG so that .

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 12
CFG Examples
 Write CFG for either a or b
Sa | b
 Write CFG for a+
S aS | a
 Write CFG for a*
S aS | ^
 Write CFG for (ab)*
SabS | ^
 Write CFG for any string of a and b
S aS | bS | a | b

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 13
CFG Examples
 Write CFG for ab*
SaX
X˄| bX
 Write CFG for a*b*
SXY
XaX|˄
YbY|˄
 Write CFG for (a+b)*
SaS | bS | ^
 Write CFG for a(a+b)*
SaX
XaX | bX | ^
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 14
CFG Examples
 Write CFG for a* | b*
SA | B
A˄| aA
B^ |bB
 Write CFG for (011+1)*(01)*
SAB
A011A | 1A | ^
B01B | ^
 Write CFG for balanced parenthesis
S [] | {} | [s] | {s} | ^

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 15
CFG Examples
 Write CFG which contains at least three times 1.
SA1A1A1A
A0A | 1A | ^
 Write CFG that must start and end with same symbol.
S0A0 | 1A1
A0A | 1A | ^
 The language of even & odd length palindrome string over {a,b}
SaSa|bSb|a|b|˄
 No. of a and no. of b are same
SaSb|bSa|˄
 The language of {a, b} ends in a
SaS | bS |a
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 16
CFG Examples
 Write CFG for regular expression (a+b)*a(a+b)*a(a+b)*
SXaXaX
XaX|bX|˄
 Write CFG for number of 0’s and 1’s are same (n0(x)=n1(x))
S0S1 | 1S0 | ^
 Write CFG for L={aibjck | i=j or j=k}
For i=j for j=k
SAB SCD
AaAb | ab CaC | a
BcB | c DbDc | bc

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 17
CFG Examples
 Write CFG for L={ aibjck | j>i+k}
SABC
AaAb |˄
BbB | b
CbCc |˄
 Write CFG for L={ 0i1j0k | j>i+k}
SABC
A0A1 |˄
B1B | 1
C1C0 |˄

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 18
Recursive Definitions
Recursive Definitions
1.Recursive Definition of {a,b}*
CFG: S aS | bS | ^
˄∈L
For any S∈L, aS∈L
For any S∈L, bS∈L
No other strings are in L
2.Recursive Definition of Palindrome
CFG: S aSa | bSb | a | b | ˄
˄, a, b ∈ L
For any S ∈ L , aSa ∈ L and bSb ∈ L
No other string are in L
3.Recursive Definition of the language {anbS
CFG: n
| aSb
n≥0}|˄
˄∈ L
For every S ∈ L, aSb ∈L
No other strings are in L
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 20
FA to Regular Grammar
FA to Regular Grammar

0 1
𝐴→ 0 𝐴
0 𝐴→ 1 𝐵
𝐵→0𝐶
𝐴 1
𝐵 𝐶 𝐵 →1 𝐵
1

0
𝐶 →0 𝐴
𝐶 →1 𝐵
𝐵→0
At last, all the incoming
transitions to the accepting
states are designated by the

Source State → input symbol


production

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 22
Exercise: FA to Regular Grammar

a B a
b
b
A C

b b
a a

a
E D

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 23
Derivation
Derivation
 Derivation is used to find whether the string belongs to a given grammar
or not.
 Types of derivations are:
1. Leftmost derivation
2. Rightmost derivation

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 25
Leftmost derivation
 A derivation of a string in a grammar is a left most derivation if at every
step the left most non terminal is replaced.
 Grammar: SS+S | S-S | S*S | S/S | a Output string: a*a-a

S S
Parse tree
S-S represents the
structure of S - S
S*S-S derivation
a*S-S S S
* a
a*a-S
a*a-a a a
Leftmost
Parse tree
Derivation
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 26
Rightmost derivation
 A derivation of a string in a grammar is a right most derivation if at every
step the right most non terminal is replaced.
 It is all called canonical derivation.
 Grammar: SS+S | S-S | S*S | S/S | a Output string: a*a-a

S
S
S*S
S * S
S*S-S
S*S-a a S S
-
S*a-a
a*a-a a a
Rightmost Parse Tree
Derivation
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 27
Exercise: Derivation
1. Perform leftmost derivation and draw parse tree.
SA1B
A0A | 𝜖
B0B | 1B | 𝜖
Output string: 1001
2. Perform leftmost derivation and draw parse tree.
S0S1 | 01 Output string: 000111
3. Perform rightmost derivation and draw parse tree.
EE+E | E*E | id | (E) | -E
Output string: id + id * id

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 28
Ambiguous grammar
Ambiguity
 Ambiguity, is a word, phrase, or statement which contains more than one
meaning.

A long thin piece of potato

Chip

A small piece of silicon

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 30
Ambiguity
 In formal language grammar, ambiguity would arise if identical string can
occur on the RHS of two or more productions.
 Grammar:
𝑵𝟏 𝑵𝟐 Replaced
by
or ?

 can be derived from either N1 or N2 𝜶

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 31
Ambiguous grammar
 Ambiguous grammar is one that produces more than one leftmost or more
then one rightmost derivation for the same sentence.
 Grammar: SS+S | S*S | (S) | a Output string: a+a*a

S S S S
S*S S+S
S * S S + S
S+S*S a+S
a+S*S S + S a a+S*S a S * S
a+a*S a+a*S
a+a*a a a a+a*a a a
 Here, Two leftmost derivation for string a+a*a is possible hence, above
grammar is ambiguous.

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 32
Exercise: Ambiguous Grammar
Check Ambiguity in following grammars:
1. S aS | Sa | 𝜖 (output string: aaaa)
2. S aSbS | bSaS | 𝜖 (output string: abab)
3. S SS+ | SS* | a (output string: aa+a*)
4. <exp> → <exp> + <term> | <term>
<term> → <term> * <letter> | <letter>
<letter> → a|b|c|…|z (output string: a+b*c)
5. Prove that the CFG with productions: S  a | Sa | bSS | SSb | SbS is
ambiguous (Hint: consider output string yourself)

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 33
Simplified forms &
Normal forms
Nullable Variable
 A Nullable variable in a CFG, is defined as follows:
1. Any variable A for which P contains is nullable.
2. If P contains the production are nullable variable, then A is nullable.
3. No other variables in V are nullable.

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 35
Eliminate ˄ production

Sa X | SaX | Yb |
SaX|Yb|a
Yb a^
XS
X ˄ | S X^ | S
YbY|b
YbY|b YbY|b
Replacing X by ^ in
Nullable all productions Removing ^
variable={X} productions
containing X on
RHS and rewriting
the production
again

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 36
Exercise: Eliminate ^ production
SAC SXaX|bX|Y
AaAb|˄ XXaX|XbX|˄
CaC|a Yab
After elimination of ^ After elimination of ^ production:
production:
S XaX | bX | Y | aX | Xa | a | b
SAC | C
X XaX |XbX | aX | Xa | a | Xb | bX
AaAb| ab
|b
CaC|a
Yab

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 37
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 38
A-derivable
 A variable is called A-derivable ,
1. If is a production, B is A-derivable.
2. If C is A-derivable, is a production, and , then B is A-derivable.
3. No other variables are A-derivable.
 Examples:
SA SA
SB AB
S- S-
derivable={A, derivable={A,
B} B}

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 39
Unit Production
 A production of the form AB is termed as unit production. Where A & B
are nonterminals.

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 41
Elimination of Unit production
SABA|BA|AA|AB|A| Unit
B Productions
A aA|a are SA and
B bB|b SB

SABA|BA|AA|
|aA|a|bB|b Removing unit
AaA|aAB
BbB|b productions

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 42
CFG to CNF
Chomsky Normal Form (CNF)
 A context free grammar is in Chomsky normal form (CNF) if every
production is one of these two forms:

Where and are nonterminal and is terminal.

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 44
Converting CFG to CNF
 Steps to convert CFG to CNF
1. Eliminate ˄-Productions.
2. Eliminate Unit Productions.
3. Restricting the right side of productions to single terminal or string of
two or more nonterminals.
4. Final step of CNF. (shorten the string of NT to length 2)

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 45
Example: CFG to CNF
SAAC Step 3: Replace all mixed string
SAAC|AC|aC
with solid NT PC|a
AaAb|˄
A PAQ|PQ
aAb|ab
CaC|a C PC|a
aC|a
Step 1: Elimination of ^ Pa
production Qb
Eliminate A^
SAAC| AC |C Step-4: Shorten the string of NT to
AaAb|ab length 2
CaC|a
SAX1 X1AC
SAC|PC|a
Step-2: Eliminate Unit
Production
Unit Production is SC APY1 Y1AQ
SAAC|AC|C aC|a APQ
AaAb|ab
CPC|a Chomsky Normal
CaC|a Form
Pa
Prof. Dixita
Jay R Dhamsaniya
B Kagathara Qb
#3160704 (TOC)  Unit 3 – Context Free
#3130006 (PS)  Unit 1 – Basic Probability 46
Example: CFG to CNF
SaAbB
AAb|b
BBa|a
Step 1 and 2 are not required as there is no ^ and unit productions
Step-3: Replace all mixed string with solid NT
Step-4 : final step of CNF
SPAQB
SPT1
AAQ|b T1AT2
BBP|a T2QB
Pa AAQ|b
Qb BBP|a
Pa
Qb

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 47
Example: CFG to CNF
SAA
AB|BB
BabB|b|bb
Step 1 is not required as there is no ^ productions
Step-2: Eliminate Unit Production:
SAA
A abB|b|bb|BB
BabB|b|bb
Step-4 : Shorten the string of NT
Step-3:Replace all mixed string with solid NT:
to length 2
SAA SAA
A PQB|b|QQ|BB A PT1|b|QQ|BB T1QB
B PV1|b|QQ V1QB
B PQB|b|QQ
Pa
Pa Qb
Qb
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 48
Example: CFG to CNF
Step-3:Replace all mixed string with
SASB|^ solid NT:
AaAS|a SASB|AB
BSbS|A|bb APAS|a|PA
Step-1: Eliminate ˄-Production: BSQS|PAS|a|PA|QQ|QS|SQ|b
SASB|AB Pa
AaAS|a|aA Qb
Step-4 : Shorten the string of NT to
BSbS|A|bb|bS|Sb|b length 2
Step-2: Eliminate Unit Production: SAB|AT1 T1SB
SASB|AB Aa|PA|PU1 U1AS
AaAS|a|aA B SV1|PV2|a|PA|QQ|QS|SQ|b
BSbS|aAS|a|aA|bb|bS|Sb|b V1QS V2AS
Pa
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 49
Backus-Naur Form (BNF)
 BNF is one of the notation Example:
techniques for context
free grammar. <exp>=<exp> + <term> | <term>
 It is often used to describe <term>=<term> * <factor> |
syntax of the language <factor>
used in computing.
<factor>=<factor> ^ <primary> |
 Variables written between <primary>
<..> are non terminals.
<primary>=<id> | <const>
 Vertical bar ‘|’ indicating a
alternate choice. <id>=<letter>
 […], which is used to <const>=[+/-]<digit>
enclosed an optional <letter>=a | b | c |……| z
specification.
<digit>=0 | 1 |………….| 9

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 50
Union, Concatenation &
Kleene’s of CFG
Union, Concatenation & Kleene’s of CFG
Theorem:- If L1 and L2 are context - free languages, then the
languages L1 U L2, L1L2 , and L1* are also CFLs.
 The proof is constructive: Starting with CFGs
G1 = (V1, Ʃ, S1,P1) and G2 = (V2, Ʃ, S2,P2) ,
 Generating L1 and L2, respectively, we show how to construct a new CFG
for each of the three cases.
1. Gu = (Vu, Ʃ, Su, Pu) generating L1 U L2
2. Gc= (Vc, Ʃ, Sc, Pc) generating L1L2
3. G* = (V, Ʃ, S, P) generating L1 *

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 52
Union Gu = (Vu, Ʃ, Su, Pu)
 A grammar Gu = (Vu, Ʃ, Su, Pu) generating L1 U L2.
 First we rename the element of V2 if necessary so that V1 ∩ V2= Ø
Vu= V1 U V2 U {Su}
Where Su is a new symbol not in V1 or V2. Then we let
Pu = P 1 U P 2 U { S u  S 1 | S2 }
 On the other hand, if x is derivable from Su in Gu, the first step in any
derivation must be
SuS1 or SuS2
 In the first case, all subsequent productions used must be productions in
G1, because no variables in V2 are involved, and thus x∈ L1; in the second
case, x ∈ L2. Therefore,
L(Gu) ⊆ L1 U L2
#3160704 (TOC)  Unit 3 – Context Free
Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 53
Concatenation Gc= (Vc, Ʃ, Sc, Pc)
 A grammar Gc= (Vc, Ʃ, Sc, Pc) generating L1L2 . Again we relabeled
variables if necessary so that V1 ∩ V2 = Ø and define
Vc = V1 U V2 U {Sc}
 This time we let
Pc= P1 U P2 U { ScS1S2 }
 If x ∈L1L2 then x = x1x2 , where xi ∈Li for each i. we may then derive x in Gc
as follows:
Sc S1 S2  *x1 S2  * x1x2 = x
 First step in the derivation must be ScS1 S2 Where the second step is the
derivation of x1 in G1 and the third step is the derivation of x2 in G2. So x ∈
L1L2

#3160704 (TOC)  Unit 3 – Context Free


Prof. Dixita
Jay R Dhamsaniya
B Kagathara #3130006 (PS)  Unit 1 – Basic Probability 54
Kleene (*)
 A grammar G* = (V, Ʃ, S, P) generating L1 * Let V = V1 U {S}
 Where S ∉ V1.The language L1*contains strings of the form x = x1x2 …xk,
where each xi ∈ L1.
 Since each xi can be derived from S1, then to derive x from S it is enough
to be able to derive a string of k S1‘S. We can accomplish this by including
the productions
SS1S | ^
 In P. Therefore, let
P = P1U { SS1S | ^ }
 The proof that L1 * ⊆ L(G*) is straightforward. If x ∈ L(G*) , on the other
hand, then either x = or x can be derived from some string of the form S1k
in G* . In the second case, since the only production in G* beginning with
S1 are those in G1, we may conclude that
 x∈
Prof. Dixita
Jay B L(G
R Dhamsaniya)k ⊆ L(G )* .#3130006
Kagathara
#3160704 (TOC)  Unit 3 – Context Free
(PS)  Unit 1 – Basic Probability 55
Thank You

You might also like