Procesamiento de Lenguaje Natural en Prolog

Download Report

Transcript Procesamiento de Lenguaje Natural en Prolog

Formal Semantics for
Natural Language
Dr. Rogelio Dávila Pérez
[email protected]
Predicate Logic
I. Syntax
1. Vocabulary
(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
Logical constants: 
Logical connectors: , , , , =
Logical quantifiers: , 
Punctuation symbols: ‘(’ , ‘)’ , ‘,’
Predicate symbols: Rn, Pm, Qs, …
Functional symbols: fn, gm, rs, …
Constant symbols: a, b, c, …
Individual variables: x, y, z
Predicate Logic
2. Terms
(i) A constant symbol is a term.
(ii) An individual variable is a term.
(iii) If fn is an n-ary function symbol and, t1,
…, tn are terms then
fn (t1, …, tn ) is a
term.
Predicate Logic
3. Well-formed formulas (wffs)
(a)
(b)
(c)
(d)
(e)
 is called contradiction an is a wff.
If Rn is an n-ary predicate symbol, and t1, …, tn
are terms then Rn (t1, …, tn ) is a wff.
If  and  are wffs, then , ,  and 
are also wffs.
If  is a formula and x is a variable, then x.(x)
and
 x.(x) are also wffs.
Nothing else is a wff.
Rules of Inference
II. Rules of Inference
(a)
All inference rules from the propositional logic hold in predicate
logic.
(b)
Universal quantifier rules
 -Intro
 -Elim (Universal Instantiation)
(a)
x.(x)
…
(a)
(a)
x.((x) (x))
Just in the case (a) and
(a) are not premises,
and there are no occurrences of ‘a’ in the premises.
Rules of Inference
(a)
Existential quantifier rules
-Intro
-Elim
(a)
y. (y)
(a)
…
y.  (y)



Just in case ‘a’ does not occur in ‘ ’.
Important concepts
Def. A first order theory consist of an alphabet, a first order
language, a set of axioms and a set of inference rules.
Def. A first order language given by an alphabet consists of the
set of all well form formulas constructed from the symbols of
the alphabet.
Def. The scope of x (resp. x), in x.
 (resp. x. ) is .
Def. A bound occurrence of a variable in a formula is an
occurrence immediately following a quantifier or an
occurrence within the scope of a quantifier, which has the
same variable immediately after the quantifier. Any other
occurrence of a variable is free.
Def. A closed formula is a formula with no free occurrences of
any variable.
Important concepts
Def. If  is a formula, then () denotes de universal closure of ,
which is the closed formula obtained by adding a universal
quantifier for every variable having a free occurrence in .
Def. Similarly, () denotes the existential closure of , which is
obtained by adding an existential quantifier for every variable
having a free occurrence in .
Logical Identities
(a)       v 
(b) Contraposition Law:         
(c) Distributive Laws:
(i)  v (  )  ( v )  ( v )
(ii)   ( v )  (  ) v (  )
(e) DeMorgan’s Laws:
(i)  ( v )      
(ii)  (  )    v  
 x.  (x)
(g)  x. (x)  x.  (x)
(f)  x. (x)
Some exercises

Translate English into Predicate Logic1
(a) Monica likes some of her students.
(b) Monica likes all her students.
(c) All men are created equal.
(d) Roses are red; violets are blue.
(e) Some freshmen are intelligent.
(f) All freshmen are intelligent.
(g) No freshmen are intelligent.
(h) One of the coats in the closet belongs to Sarah.
(i) Some Juniors date only Seniors.
(j) Not all birds can fly.
Notes
1 All sentences were taken from Dra. Monica Noguera’s notes on CS4320 .
Some exercises

Translate English into Predicate Logic1
(a) Every elephant has a trunk.
(b) Adams is not married to anyone.
(c) No freshmen are not serious.
(d) Someone profited from the great depression.
(e) All fish except sharks are kind to children.
(f) Anyone with two or more spouses is a bigamist.
(g) John married Mary and she got pregnant.
(h) If all sophomores like Greek, then some freshmen do.
(i) Everyone loves somebody and no one loves everybody,
or somebody loves everybody and someone loves nobody.
Notes
1 All sentences were taken from Dra. Monica Noguera’s notes on CS4320.
Predicate Logic Semantics
Definition. An interpretation of a term consists in a non
empty domain E, and an assignment function F:
(i)
(ii)
(iii)
To each constant symbol, it is assigned an
individual from the domain.
To each n-ary function symbol, it is assigned a
mapping from E n E.
To each n-ary predicate symbol, it is assigned a
subset from E n.
Predicate Logic Semantics
Definition. An interpretation of a wff  consists of an
mapping I: wffs {0,1} as follows:
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
I(Pi(t1, t2,…,tn)) = 1
Pi),
iff <F(t1), F(t2), …,F( tn) >  F(
0 otherwise.
I(  ) = min(I(),I())
I(  ) = max(I(),I())
I( ) = 0 if I()=1 and I()=0, 1
otherwise
I() = 1-I()
I(x.(x)) = 1 if for all a  E, I((a))=1
I(x.(x)) = 1 if there is an F(a)  E such
that
I((a))=1.
Predicate Logic Semantics
Definition. An interpretation of a set of well-formed formulas , is called a
MODEL of , if and only if, every wff in  is true under that
interpretation.
Definition. A wff  is called a logical consequence of a set of wffs , if and
only if,  is true in al models of  ( |= ).
Definition. A wff  is satisfiable if it has a model, otherwise it is unsatisfiable.
Predicate Logic Semantics
Example
Lets define a simple language:
Basic expressions:
(i)
Constant symbols: m, j, d and n.
(ii)
Predicate symbols: M1, B1, K2, L2.
Sentences:
M(d), B(j), K(j,n) and L(n,m)
Evaluate the truth of the previous sentences according to the interpretations
shown bellow.
Predicate Logic Semantics
a).
M1=<A1,F1>
A1 = {x | x is a country in America}
F1(m) =peru, F1(j)=chile, F1(d)= honduras, F1(n)= argentina
F1(M)={colombia, belice, argentina, canada, nicaragua}
F1(B)={x  A1| x borders the pacific ocean}
F1(K)={<x,y>| <x,y>  A1xA1 , x borders y}
F1(L)={<x,y>| <x,y>  A1xA1 , x is bigger than y}
b). M2=<A2,F2>
A2 = {x | x is an integer}
F2 (m) =0, F1(j)=2, F1(d)= 9, F1(n)= -1
F2 (M)={x  A2| x is odd}
F2 (B)={x  A| x is a perfect square}
F2 (K)={<x,y>| <x,y>  A2xA2 , and x > y}
F2 (L)={<x,y>|< x,y>  A2x A2 , x = y2}
Predicate Logic Examples
Examples of arguments
(a)
(b)
(c)
(d)
The mother will die unless the doctor kills the child. If the doctor kills
the child, the doctor will be taking life. If the mother dies, the doctor
will be taking life. Therefore, the doctor will be taking life.
If the soil is suitable for carrots, then it is deep, sandy and free of
stones. The soil is not suitable for linseed if it is sandy or a heavy clay.
Therefore the soil is not suitable for both carrots and linseed.
Bank-notes all carry a metal strip. Anything with a metal strip can be
detected by X-rays. Therefore, bank-notes can be detected by X-rays.
All the birds are either chiff-chaffs or willow warblers. The birds are
singing near the ground. Chiff-chaffs don’t sing near the ground.
Therefore the birds are all willow-warblers.
Formal Semantics for Natural Language
Examples of arguments
(a)
(b)
(c)
(d)
The mother will die unless the doctor kills the child. If the doctor kills
the child, the doctor will be taking life. If the mother dies, the doctor
will be taking life. Therefore, the doctor will be taking life.
If the soil is suitable for carrots, then it is deep, sandy and free of
stones. The soil is not suitable for linseed if it is sandy or a heavy clay.
Therefore the soil is not suitable for both carrots and linseed.
Bank-notes all carry a metal strip. Anything with a metal strip can be
detected by X-rays. Therefore, bank-notes can be detected by X-rays.
All the birds are either chiff-chaffs or willow warblers. The birds are
singing near the ground. Chiff-chaffs don’t sing near the ground.
Therefore the birds are all willow-warblers.