123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- sentence(sentence(NP, VP)) --> np(Num, NP), vp(Num, _, VP).
- np(Num, np(D, N)) --> det(D), noun(Num, N).
- np(Num, np(D, N, Rel)) --> det(D), noun(Num, N), relcl(Num, Rel).
- np(Num, np(D, A, N)) --> det(D), adj(A), noun(Num, N).
- np(Num, np(D, A, N, Rel)) --> det(D), adj(A), noun(Num, N), relcl(Num, Rel).
- np(Num, np(N)) --> noun(Num, N).
- np(Num, np(N, Rel)) --> noun(Num, N), relcl(Num, Rel).
- relcl(_, rel(R, NP, VP)) --> rel(obj, R), np(Num, NP), vp(Num, _, VP, obj).
- relcl(Num, rel(R, VP)) --> rel(subj, R), vp(Num, _, VP, subj).
- vp(Num, be, vp(V, A)) --> verb(Num, be, V), adj(A).
- vp(Num, tr, vp(V, NP)) --> verb(Num, tr, V), np(_, NP).
- vp(Num, intr, vp(V)) --> verb(Num, intr, V).
- vp(Num, tr, vp(V), obj) --> verb(Num, tr, V).
- vp(Num, tr, vp(V, NP), subj) --> verb(Num, tr, V), np(_, NP).
- vp(Num, intr, vp(V), subj) --> verb(Num, intr, V).
- vp(Num, be, vp(V, A), subj) --> verb(Num, be, V), adj(A).
- det(det(D)) --> [D], {is_det(D)}.
- noun(Num, noun(N)) --> [N], {is_noun(Num, N)}.
- rel(Obj, rel(Rel)) --> [Rel], {is_rel(Obj, Rel)}.
- verb(Num, Tr, verb(V)) --> [V], {is_verb(Num, Tr, V)}.
- adj(adj(A)) --> [A], {is_adj(A)}.
- is_noun(sg, apple).
- is_noun(sg, boy).
- is_noun(sg, girl).
- is_noun(sg, government).
- is_noun(sg, watermelon).
- is_noun(sg, flavor).
- is_noun(sg, person).
- is_noun(pl, people).
- is_noun(pl, Np) :- is_noun(sg, N), atom_chars(N, A), atom_chars(Np, B), append(A, [s], B).
- is_det(a).
- is_det(an).
- is_det(the).
- is_det(all).
- is_det(some).
- is_verb(pl, tr, conscript).
- is_verb(pl, tr, eat).
- is_verb(pl, tr, like).
- is_verb(pl, intr, run).
- is_verb(sg, be, is).
- is_verb(pl, be, are).
- is_verb(pl, tr, contain).
- is_verb(sg, Tr, Vs) :- is_verb(pl, Tr, V), atom_chars(V, A), atom_chars(Vs, B), append(A, [s], B).
- is_adj(evil).
- is_adj(divine).
- is_adj(big).
- is_adj(tasty).
- is_adj(pacifist).
- is_rel(obj, that).
- is_rel(obj, whom).
- is_rel(subj, who).
- is_rel(subj, which).
- ?- op(500,xfy,&).
- ?- op(600,xfy,=>).
- np(Var, np(DET, NOUN), P3) :-
- n(Var, NOUN, P1),
- det(Var, DET, P1, P3).
- np(Var,np(DET,ADJ,NOUN),P3) :-
- adj(Var,ADJ,P1),
- n(Var,NOUN,P2),
- det(Var,DET,P1,P2,P3).
- np(Var, np(DET, NOUN, REL), P3) :-
- n(Var, NOUN, P1),
- det(Var, DET, P1, P2),
- rel(Var, REL, P2, P3).
- np(Var, np(DET, ADJ, NOUN, REL), P4) :-
- n(Var, NOUN, P2),
- adj(Var, ADJ, P1),
- det(Var, DET, P1, P2, P3),
- rel(Var, REL, P3, P4).
- det(Var,DET,P1,P2,P3) :- % noun-adj, universal
- DET =.. [det, all],
- P3 =.. [all, Var, (P2 & P1)].
- det(Var, DET, P1, P2) :- % noun, universal
- DET =.. [det, all],
- P2 =.. [all, Var, P1].
- det(Var, DET, P1, P2, P3) :- % noun-adj, existential
- DET =.. [det, some],
- P3 =.. [exists, Var, (P2 & P1)].
- det(Var, DET, P1, P2) :- % noun, existential
- DET =.. [det, some],
- P2 =.. [exists, Var, P1].
- adj(Var,ADJ,P) :-
- ADJ =.. [adj, A],
- P =.. [A,Var].
- n(Var,NOUN,P) :-
- NOUN =.. [noun, N],
- P =.. [N,Var].
- rel(Var, rel(_, VP), DET, P3) :-
- vp(Var, DET, VP, true, P3).
- vp(Var, all(A, B), vp(BE, ADJ), P3) :- % 'to be' verb w/ adj
- BE =.. [verb, BB],
- is_verb(_, be, BB),
- adj(Var, ADJ, C),
- P3 =.. [all, A, (B => C)].
- vp(Var, all(A, B), vp(VERB), P3) :- % intransitive verb
- VERB =..[verb, V],
- C =.. [V, Var],
- P3 =.. [all, A, (B => C)].
- vp(Var, all(A, B), vp(VERB, NP), P3) :- % transitive verb w/ object
- VERB =.. [verb, V],
- gensym(x, Var2),
- np(Var2, NP, C),
- D =.. [V, Var, C],
- P3 =.. [all, A, (B => D)].
- vp(Var, exists(A, B), vp(BE, ADJ), P3) :-
- BE =.. [verb, BB],
- is_verb(_, be, BB),
- adj(Var, ADJ, C),
- P3 =.. [exists, A, B, C].
- vp(Var, exists(A, B), vp(VERB), P3) :-
- VERB =.. [verb, V],
- C =.. [V, Var],
- P3 =.. [exists, A, B, C].
- vp(Var, exists(A, B), vp(VERB, NP), P3) :-
- VERB =.. [verb, V],
- gensym(x, Var2),
- np(Var2, NP, C),
- D =.. [V, Var, C],
- P3 =.. [exists, A, B, D].
- vp(Var, all(A, B), vp(BE, ADJ), true, P3) :- % 'to be' verb w/ adj
- BE =.. [verb, BB],
- is_verb(_, be, BB),
- adj(Var, ADJ, C),
- P3 =.. [all, A, (B & C)].
- vp(Var, all(A, B), vp(VERB), true, P3) :- % intransitive verb
- VERB =..[verb, V],
- C =.. [V, Var],
- P3 =.. [all, A, (B & C)].
- vp(Var, all(A, B), vp(VERB, NP), true, P3) :- % transitive verb w/ object
- VERB =.. [verb, V],
- gensym(x, Var2),
- np(Var2, NP, C),
- D =.. [V, Var, C],
- P3 =.. [all, A, (B & D)].
- vp(Var, exists(A, B), VP, true, P3) :-
- vp(Var, exists(A, B), VP, P3).
- s(sentence(NP,VP),F) :-
- gensym(x,X),
- np(X,NP,T), vp(X,T,VP,F).
- prlogic(English, Logic) :- sentence(T, English, []), s(T, Logic).
|