• Keine Ergebnisse gefunden

Meta–Interpreter 1:

N/A
N/A
Protected

Academic year: 2021

Aktie "Meta–Interpreter 1:"

Copied!
4
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Meta–Interpreter 1:

prove(true) :- !.

prove((Goal1, Goal2)) :- !, prove(Goal1), prove(Goal2).

prove(Goal) :- clause(Goal, Body), prove(Body).

Meta–Interpreter 2:

prove(true) :- !.

prove((Goal1, Goal2)) :- !, prove(Goal2), prove(Goal1).

prove(Goal) :- clause(Goal, Body), prove(Body).

Meta–Interpreter 3:

prove(true,0) :- !.

prove((Goal1,Goal2),N) :- !, prove(Goal1,N1), prove(Goal2,N2), N is N1+N2.

prove(Goal,N) :- clause(Goal, Body), prove(Body,N1),

N is N1+1.

(2)

Classic append:

append([],Ys,Ys).

append([X|Xs],Ys,[X|Zs]) :- append(Xs,Ys,Zs).

app with difference lists:

app(Xs - Ys, Ys - Zs, Xs - Zs).

(3)

Example grammar G = ( N, T, S, P )

• N = { Sentence, Nominalphrase, Verbalphrase, Article, Noun, Verb }

• T = { a, the, cat, mouse, scares, hates }

• S = Sentence

• P consists of the following rules:

Sentence → Nominalphrase Verbalphrase Nominalphrase → Article Noun

Verbalphrase → Verb

Verbalphrase → Verb Nominalphrase Articlel → a

Article → the Noun → cat Noun → mouse

Verb → scares Verb → hates

L ( G ) contains: a cat scares the mouse, the mouse hates the cat,

L ( G ) contains: a mouse scares a mouse, a mouse hates

(4)

Example grammar in Prolog

sentence --> nominalphrase, verbalphrase.

nominalphrase --> article, noun.

verbalphrase --> verb.

verbalphrase --> verb, nominalphrase.

article --> [a].

article --> [the].

noun --> [cat].

noun --> [mouse].

verb --> [scares].

verb --> [hates].

Transformation into Prolog–clauses

sentence(S, R) :- nominalphrase(S, VP), verbalphrase(VP, R) nominalphrase(NP, R) :- article(NP, N), noun(N, R).

verbalphrase(VP, R) :- verb(VP, R).

verbalphrase(VP, R) :- verb(VP, NP), nominalphrase(NP, R).

article([a | R], R).

article([the | R], R).

noun([cat | R], R).

noun([mouse | R], R).

verb([scares | R], R).

verb([hates | R], R).

Referenzen

ÄHNLICHE DOKUMENTE

Die Figur kann auch als Rollen- oder Kugellager gedeutet werden. a) Wie schnell drehen sich die rosa Kreise um die eigene Achse? Im System Son- ne-Erde entspricht dies

negatively, (i~e. not requesting the features they allow,) will save many bytes of processor memory which will be returned to the user in the form of available

• Wieviel Hilfe muss die Programmiererin und/oder die Verifiziererin geben ?.. John McCarthy, Stanford.. Robin Milner, Edinburgh.. Xavier Leroy, INRIA, Paris.. 4.2

If the keyword is the name of a region interpretation procedure (e.g. "cell"), then the text string is simultaneously declaring the region procedure to be used for

• Definiert für eine Sprache eine Repräsentation der Grammatik sowie einen.. Interpreter, der die Repräsentation nutzt, um Sätze in der Sprache zu

(These operators work independently of SUBMIT.) For fast execution of a one line, one parameter command file or a command file without parameters, the period (.)

BASIC PROGRAM, EXECUTION - Entering a RUN command, after a BASIC program has been entered into the microcomputer, will cause the current program to begin

The occupation number of a magnetically trapped Bose-Einstein condensate is limited for atoms with attractive interactions.. It has been predicted that, as this limit is approached,