13th LSF A Logial and Semanti F ramew o rks, with - - PowerPoint PPT Presentation

13th lsf a logi al and semanti f ramew o rks with appli
SMART_READER_LITE
LIVE PREVIEW

13th LSF A Logial and Semanti F ramew o rks, with - - PowerPoint PPT Presentation

13th LSF A Logial and Semanti F ramew o rks, with Appliations UF C, F o rtaleza, CE Ma rus Ramos Some Appliations Septemb er 26th, 2018 1 / 29 Some Appliations of the F o rmalization of the Pumping Lemma


slide-1
SLIDE 1 13th LSF A Logi al and Semanti F ramew
  • rks,
with Appli ations UF C, F
  • rtaleza,
CE Ma r us Ramos Some Appli ations Septemb er 26th, 2018 1 / 29
slide-2
SLIDE 2 Some Appli ations
  • f
the F
  • rmalization
  • f
the Pumping Lemma fo r Context-F ree Languages Ma r us Vin ius Midena Ramos (UNIV ASF, P etrolina, PE) Jos Ca rlos Ba ela r Almeida (HASLab
  • INESC
TEC, Universidade do Minho, Braga, P
  • rtugal)
Nelma Mo reira (Depa rtamento de Cin ia de Computado res, F a uldade de Cin ias, P
  • rto,
P
  • rtugal)
Ruy J. G. B. de Queiroz (UFPE, Re ife, PE) Septemb er 26th, 2018 Ma r us Ramos Some Appli ations Septemb er 26th, 2018 2 / 29
slide-3
SLIDE 3 S op e F
  • rmalize
  • f
a substantial pa rt
  • f
  • ntext-free
language theo ry in the Co q p ro
  • f
assistant.

F
  • rmalization
is the p ro ess
  • f
writing p ro
  • fs
su h that they have a p re ise meaning
  • ver
a simple and w ell-dened al ulus whose rules an b e automati ally he k ed b y a ma hine;

Context-free language theo ry is fundamental in the rep resentation and study
  • f
a rti ial languages, sp e ially p rogramming languages, and in the
  • nstru tion
  • f
their p ro esso rs ( ompilers and interp reters);

The fo rmalization
  • f
  • ntext-free
language theo ry is a k ey to the erti ation
  • f
  • mpilers
and p rograms, as w ell as to the development
  • f
new languages and to
  • ls
fo r ertied p rogramming. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 3 / 29
slide-4
SLIDE 4 Context-F ree Language Theo ry Overview

P a rt
  • f
F
  • rmal
Language Theo ry (Chomsky Hiera r hy):

Regula r Languages;

Context-F ree Languages ;

Context-Sensitive Languages;

Re ursively Enumerable Languages.

Develop ed from mid 1950s to late 1970s;

Sin e then, mostly text p ro
  • fs
and almost no fo rmalization;

Relevant to the rep resentation, study and implementation
  • f
a rti ial languages; Ma r us Ramos Some Appli ations Septemb er 26th, 2018 4 / 29
slide-5
SLIDE 5 Context-F ree Language Theo ry Steps Main results sin e 2013: 1 Closure p rop erties ( 9th LSF A 2014 ):

Union;

Con atenation;

Kleene sta r. 2 Gramma r simpli ation ( 10th LSF A 2015 ):

Elimination
  • f
empt y rules;

Elimination
  • f
unit;

Elimination
  • f
useless symb
  • ls;

Elimination
  • f
ina essible symb
  • ls.
3 Chomsky No rmal F
  • rm;
4 Pumping Lemma ( JFR, 2016 ) 5 Languages that a re not
  • ntext-free
( 13th LSF A, 2018 ) Ma r us Ramos Some Appli ations Septemb er 26th, 2018 5 / 29
slide-6
SLIDE 6 Basi Denitions Context-F ree Gramma r

G = (V, Σ, P, S)

, where:

◮ V

is the vo abula ry
  • f G
;

◮ Σ

is the set
  • f
terminal symb
  • ls;

◮ N = V \ Σ

is the set
  • f
non-terminal symb
  • ls;

◮ P

is the set
  • f
rules α → β , with α ∈ N and β ∈ V ∗ ;

◮ S ∈ N

is the sta rt symb
  • l.
Re ord fg ( non_terminal terminal : Type ): Type := { start_symbol : non_terminal ; rules : non_terminal → list (non_terminal + terminal ) → Prop ; rules_finite :

n : nat ,

ntl : nlist ,

tl : tlist , rules_finite_def start_symbol rules n ntl tl }. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 6 / 29
slide-7
SLIDE 7 Basi Denitions Context-F ree Gramma r Making sure that fg rep resents a
  • ntext-free
gramma r:

General t yp es might have an innite numb er
  • f
elements;

W e must he k that the rules
  • f
the gramma r a re built from nite sets
  • f
terminal and non-terminal symb
  • ls;

W e must also he k that the set
  • f
rules is nite;

The p redi ate rules_finite_def is used to mak e sure that these
  • nditions
a re satised fo r every gramma r in the fo rmalization, either user-dened
  • r
  • nstru ted;

A list
  • f
non-terminal symb
  • ls
(ntl), a list
  • f
terminal symb
  • ls
(tl) and an upp er b
  • und
  • n
the length
  • f
the right-hand side
  • f
the rules (n) must b e supplied. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 7 / 29
slide-8
SLIDE 8 Basi Denitions Example

G = ({S′, A, B, a, b}, {a, b}, {S′ → aS′, S′ → b}, S′)

generates the language a∗b. Indu tive nt1 : Type := | S ' | A | B. Indu tive t1 : Type := | a | b . Indu tive rs1 : nt1 → list (nt1 + t1 ) → Prop := r1 : rs1 S' [ inr a; inl S '℄ | r2 : rs1 S' [ inr b℄. Definition g1 : fg nt1 t1 := {| start_symbol := S'; rules := rs1 ; rules_finite := rs1_finite |}. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 8 / 29
slide-9
SLIDE 9 Basi Denitions Derivation Substitution p ro ess:

s1

derives s2 b y appli ation
  • f
zero
  • r
mo re rules: s1 ⇒∗ s2 . Indu tive derives ( non_terminal terminal : Type ) ( g : fg non_terminal terminal ) : sf → sf → Prop := | derives_refl :

s : sf , derives g s s | derives_step :

( s1 s2 s3 : sf )

( left : non_terminal )

( right : sf ), derives g s1 (s2 ++ inl left :: s3 ) → rules g left right → derives g s1 (s2 ++ right ++ s3 ) Ma r us Ramos Some Appli ations Septemb er 26th, 2018 9 / 29
slide-10
SLIDE 10 Basi Denitions Derivation

Predi ate generates: a derivation that b egins with the sta rt symb
  • l
  • f
the gramma r;

Predi ate produ es: a derivation that b egins with the sta rt symb
  • l
  • f
the gramma r and ends with a senten e.

S ⇒ α1 ⇒

derives
  • α2 ⇒ ... ⇒ αn−1
  • generates

⇒ αn ⇒ ω

  • produ es
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 10 / 29
slide-11
SLIDE 11 Basi Denitions Example

S ⇒ aS ⇒ aaS ⇒ aab

Lemma produ es_g1_aab : produ es g1 [a; a; b ℄. Proof . unfold produ es . unfold generates . simpl . apply derives_step with (s2 :=[inr a; inr a℄)(left := S')(right :=[inr b℄). apply derives_step with (s2 :=[inr a℄)( left := S')( right :=[ inr a ;inl S '℄). apply derives_start with (left :=S ')( right :=[ inr a ;inl S '℄). apply r11 . apply r11 . apply r12 . Qed . Ma r us Ramos Some Appli ations Septemb er 26th, 2018 11 / 29
slide-12
SLIDE 12 Basi Denitions Gramma r Equivalen e

g1 ≡ g2

if they generate the same language, that is,

∀s, (S1 ⇒∗

g1 s) ↔ (S2 ⇒∗ g2 s)

Definition g_equiv ( non_terminal1 non_terminal2 terminal : Type ) ( g1 : fg non_terminal1 terminal ) ( g2 : fg non_terminal2 terminal ): Prop :=

s : list terminal , produ es g1 s ↔ produ es g2 s. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 12 / 29
slide-13
SLIDE 13 Basi Denitions Context-F ree Language

A language is a set
  • f
strings
  • ver
a given alphab et;

A
  • ntext-free
language is a language that is generated b y some
  • ntext-free
gramma r: L(G) = {w | S ⇒∗

g w}

. Definition lang (terminal : Type ):= list terminal → Prop . Definition lang_of_g (g: fg ): lang := fun w: list terminal ⇒ produ es g w. Definition lang_eq (l k: lang ) :=

w, l w ↔ k w. Definition fl (terminal : Type ) ( l : lang terminal ): Prop :=

non_terminal : Type ,

g: fg non_terminal terminal , lang_eq l (lang_of_g g ). Ma r us Ramos Some Appli ations Septemb er 26th, 2018 13 / 29
slide-14
SLIDE 14 Appli ations Obje tives

Derive fo rmal p ro
  • fs
that some w ell-kno wn, lassi languages, a re not
  • ntext-free.
F
  • r
this, w e use the fo rmalization
  • f
the Pumping Lemma p reviously
  • btained
b y the autho rs in the Co q p ro
  • f
assistant. F
  • r
ea h
  • f
these languages, w e dis uss the fo rmalization
  • f
their non
  • ntext-freeness
and mak e hop efully useful
  • nsiderations
ab
  • ut
the p ro
  • f
  • nstru tion
p ro ess and the
  • mplexit
y
  • f
the
  • rresp
  • nding
fo rmal and text p ro
  • fs;

Develop a fo rmal p ro
  • f
  • f
the fa t that the lass
  • f
the
  • ntext-free
languages is not losed under the interse tion
  • p
eration. F
  • r
that, w e follo w the lassi al p ro
  • f
that uses a
  • unter-example,
whi h in
  • ur
ase is
  • ne
  • f
the languages p roved not to b e
  • ntext-free
in the p revious
  • bje tive.
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 14 / 29
slide-15
SLIDE 15 Appli ations Pumping Lemma Let L b e a
  • ntext-free
language dened
  • ver
alphab et Σ . Then there is a numb er n , dep ending
  • nly
  • n L ,
su h that fo r every senten e α ∈ L , if

|α| ≥ n ,

then all
  • f
the follo wing a re true (|w| denotes the length
  • f
the w
  • rd w
):

◮ ∃ u, v, w, x, y.(α = uvwxy)

;

◮ |vx| ≥ 1

;

◮ |vwx| ≤ n ; ◮ ∀i.(uviwxiy ∈ L)

A t ypi al use
  • f
the Pumping Lemma is to sho w that a given language is not
  • ntext-free
b y using the
  • ntrap
  • sitive
  • f
the statement
  • f
the lemma. The info rmal p ro
  • f
p ro eeds b y
  • ntrap
  • sition:
the language is assumed to b e
  • ntext-free,
and this leads to a
  • ntradi tion
from whi h
  • ne
  • n ludes
that the language in question an not b e
  • ntext-free.
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 15 / 29
slide-16
SLIDE 16 Appli ations Languages Classi al languages
  • nsidered:
1 squa re: {w ∈ {a}∗ | ∃ i, |w| = i2, i ≥ 0} , 2 p rime: {w ∈ {a}∗ | |w| is a p rime numb er} , 3 anbn n: {aibici | i ≥ 0} . F
  • r
ea h:

T ext p ro
  • f;

F
  • rmal
p ro
  • f;

Compa rison. Besides these languages, w e also dis uss: 4 anbnanbn: {anbnanbn | n ≥ 0} 5 ww: {ww | w ∈ {a, b}∗} Ma r us Ramos Some Appli ations Septemb er 26th, 2018 16 / 29
slide-17
SLIDE 17 Appli ations Languages Results: 1 squa re: straightfo rw a rd; (∼ 20x expansion fa to r) 2 p rime: straightfo rw a rd; (∼ 20x expansion fa to r) 3 anbn n: mu h ha rder (why?); (∼ 100x expansion fa to r) 4 anbnanbn: mu h mu h ha rder (in omplete); (∼ 200x expansion fa to r) 5 ww: also in omplete. Let's tak e a lo
  • k
at anbn n. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 17 / 29
slide-18
SLIDE 18 Appli ations Language anbn n T ext p ro
  • f

Supp
  • se
that it is
  • ntext-free
and
  • nsider
the w
  • rd anbncn
, where n is the
  • nstant
  • f
the Pumping Lemma;

◮ anbncn ∈

anbn n and |anbncn| ≥ n . Thus, the Pumping Lemma an b e applied;

◮ anbncn = uvwxy

fo r some u, v , w , x and y , with |uvwxy| = 3n ,

1 ≤ |vwx| ≤ n

and uviwxiy ∈ anbn n, ∀i ≥ 0 ;

◮ vwx,

due to its length limitation,
  • ntains
  • nly
  • ne
  • r
t w
  • dierent
kind
  • f
symb
  • ls;

If it
  • ntains
  • nly
  • ne
kind
  • f
symb
  • l,
then v and x a re also built
  • ut
  • f
a single symb
  • l
and the pumping
  • f v
and x will hange the numb er
  • f
a single symb
  • l,
while the numb er
  • f
the
  • ther
t w
  • remain
un hanged. Thus, the new w
  • rd
an not b elong to anbn n; Ma r us Ramos Some Appli ations Septemb er 26th, 2018 18 / 29
slide-19
SLIDE 19 Appli ations Language anbn n T ext p ro
  • f

If it
  • ntains
t w
  • dierent
kinds
  • f
symb
  • ls,
then v and x might
  • ntain
  • ne
  • r
t w
  • dierent
kinds
  • f
symb
  • ls
ea h. If b
  • th
  • ntain
  • nly
  • ne
kind
  • f
symb
  • l,
pumping will hange the numb er
  • f
at most t w
  • symb
  • ls,
while the third will remain un hanged. If v
  • r x
  • ntain
t w
  • dierent
kinds
  • f
symb
  • ls,
pumping will lead to a w
  • rd
where the
  • rder
is not resp e ted (rst as, then bs then c s). In all ases, the new w
  • rd
do es not b elong to anbn n;

Hyp
  • thesis
is false and anbn n is not
  • ntext-free.
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 19 / 29
slide-20
SLIDE 20 Appli ations Language anbn n F
  • rmalization
Indu tive terminal : Type := | a | b | . Definition anbn n : lang terminal := fun ( s : list terminal ) ⇒

x y z: list terminal ,

i : nat , s = x ++ y ++z ∧ length x = i ∧ na x = i ∧ length y = i ∧ nb y = i ∧ length z = i ∧ n z = i. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 20 / 29
slide-21
SLIDE 21 Appli ations Language anbn n F
  • rmal
p ro
  • f
Steps:

W e have to reason ab
  • ut vwx
(either vwx ∈ a∗b∗
  • r vwx ∈ b∗c∗
);

◮ v

and x might b e empt y (but not b
  • th);

W e
  • n lude
ab
  • ut |v|a, |v|b, |v|c, |x|a, |x|b
and |x|c (whether ea h is

= 0

  • r = 0
);

24 ases must b e
  • nsidered;

2 a re dis a rded;

22 ases must b e used to sho w that uv2wx2y an not b elong to anbn n;

The fo rmalization is long and tedious;

Some simpli ation an b e pursued. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 21 / 29
slide-22
SLIDE 22 Appli ations Language anbn n F
  • rmal
p ro
  • f
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 22 / 29
slide-23
SLIDE 23 Appli ations Interse tion Context-free languages a re not losed under interse tion: 1 F
  • rmalize L1 = {anbncm | n ≥ 0 ∧ m ≥ 0}
; 2 Prove L1 is
  • ntext-free;
3 F
  • rmalize L2 = {ambncn | n ≥ 0 ∧ m ≥ 0}
; 4 Prove L2 is
  • ntext-free;
5 F
  • rmalize
language interse tion; 6 Prove L1 ∩ L2 = anbncn ; 7 Re all anbncn is p reviously p roved not to b e
  • ntext-free;
Ma r us Ramos Some Appli ations Septemb er 26th, 2018 23 / 29
slide-24
SLIDE 24 Con lusions Results Languages:

squa re: straightfo rw a rd to build and easy to read;

p rime: straightfo rw a rd to build and easy to read;

anbn n: long and
  • mplex
with extensive ase analysis;

anbnanbn: longer and mo re
  • mplex;
T ak e anbnanbn , guess ab
  • ut v
and x and pump them;

ww: simila r to anbnanbn; T ak e anbnanbn , guess ab
  • ut v
and x and pump them. Why? Interse tion:

straightfo rw a rd to build and easy to read. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 24 / 29
slide-25
SLIDE 25 Con lusions Results

Size and
  • mplexit
y in p ro
  • fs
with ase analysis
  • nly;

That is,
  • nly
with languages anbn n, anbnanbn and ww;

Do es not
  • ur
with languages squa re and p rime and interse tion;

P
  • ssible
reasons:

(*) Pro
  • f
writing st yle (one ta ti p er line; no p ro
  • f
sea r hing ta ti );

(*) P a rametrization an redu e the numb er
  • f
fun tions and lemmas;

(**) Extensive ase analysis with no native supp
  • rt;

(**) T ext p ro
  • fs
hide many details that have to b e expli itly stated. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 25 / 29
slide-26
SLIDE 26 Con lusions Case analysis Case analysis with lists (examples from anbn n and anbnanbn):

Any string that is a substring
  • f a∗b∗
b elongs to a∗b∗ ;

Any string with maximum length n that is a substring
  • f anbncn
b elongs to a∗b∗ | b∗c∗ ;

Any string with maximum length n that is a substring
  • f anbnanbn
b elongs to a∗b∗ | b∗a∗ . Ma r us Ramos Some Appli ations Septemb er 26th, 2018 26 / 29
slide-27
SLIDE 27 Con lusions T ext p ro
  • fs
T ext p ro
  • fs
hide details (examples from anbn n):

due to its length limitation,
  • ntains
  • nly
  • ne
  • r
t w
  • dierent
kind
  • f
symb
  • ls;

if it
  • ntains
  • nly
  • ne
kind
  • f
symb
  • l,
then ... a re also built
  • ut
  • f
a single symb
  • l
and the pumping
  • f
... will hange the numb er
  • f
a single symb
  • l,
while the numb er
  • f
the
  • ther
t w
  • remain
un hanged;

if it
  • ntains
t w
  • dierent
kinds
  • f
symb
  • ls,
then ...might
  • ntain
  • ne
  • r
t w
  • dierent
kinds
  • f
symb
  • ls
ea h;

if b
  • th
  • ntain
  • nly
  • ne
kind
  • f
symb
  • l,
pumping will hange the numb er
  • f
at most t w
  • symb
  • ls,
while the third will remain un hanged;

if ...
  • ntain
t w
  • dierent
kinds
  • f
symb
  • ls,
pumping will lead to a w
  • rd
where the
  • rder
is not resp e ted. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 27 / 29
slide-28
SLIDE 28 Con lusions Con lusions P
  • ssible
  • nsequen es:

F uture supp
  • rt
(new lib ra ries) fo r
  • mbinato
ri s
  • f
strings (lists
  • f
symb
  • ls)
in Co q might help and simplify the fo rmalization;

Mo re detailed (and thus self-explanato ry) text p ro
  • fs
must b e
  • nsidered.
T
  • b
e used in undergraduate lasses as ase study . Ma r us Ramos Some Appli ations Septemb er 26th, 2018 28 / 29
slide-29
SLIDE 29 Con lusions Final rema rks

All s ripts a re publi ly available and an b e exe uted in Co q 8.8.1 (July 2018);

Appli ation
  • f
a p reviously fo rmalized lemma, fundamental to the language lass;

First kno wn fo rmal p ro
  • fs
that some lassi al languages a re not
  • ntext-free;

Insights involving text and fo rmal p ro
  • fs;

Helpful in tea hing fo rmal languages in a fo rmal framew
  • rk;

A dds a new losure result to p revious results
  • n erning
the lass
  • f
the
  • ntext-free
languages. Ma r us Ramos Some Appli ations Septemb er 26th, 2018 29 / 29