This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
RecursionRecall: grandparent(Pers, Gpar) :-
parent(Pers, Par), parent(Par, Gpar).
How to define greatgrandparents? grandparent(Pers, GGpar) :- parent(Pers, Par), parent(Par, Gpar),
parrent(Gpar, GGPar).
How to define ancestor? ancestor(Pers, A) :-parent(Pers, A).
ancestor(Pers, A) :-
parent(Pers, X1), parent(X1, A).
...
ancestor(Pers, A) :-
parent(Pers, X1), parent(X1, X2),
…parent(Pers,X2, A).
...
Better: use Recursionancestor(P, Anc) :- parent(P, Anc).
As described in: G.A. Ringwood, “Predicates and Pixels”,New Generation Computing 7 (1989): 59-80
...visualizes data (terms) and program (predicate) structurein one homogeneous form...
•as graphs•execution semantics defined as sub-graph substitution
The system in “Predicates and Pixels” is actually defined for a related logic programming language called FGDC (“Flat Guarded Definite Clauses”) defined in G.A. Ringwood, “A comparative Exploration of Concurrent Logic Languages”,Knowledge Engineering Review 4(1989):305-332.
For the purpose of our discussion we can ignore the differences.
Example: Quicksort (with Difference Lists)
we will illustrate “Predicates and Pixels” with a quicksort programthat uses difference lists.
Difference lists are a standard programming technique in logicprogramming that utilizes unification in a “tricky” form to avoid appending (because appending is a costly operation).
The meaning of a difference list written “Xs\Ys” is “the list Xs disregarding the tail Ys”, e.g.[a,b,c,d,e] \ [c,d,e] = [a,b]
in the following we use:list(X, Xs) for [X | Xs] and diff(Xs, Ys) for Xs \ Ys.
Quicksort with Difference Lists (2)
Quicksort with Difference Lists (3)
Quicksort with Difference Lists (4)
Quicksort with Difference Lists (5)
Quicksort with Difference Lists (6)
Quicksort with Difference Lists (7)
Quicksort with Difference Lists (8)
Quicksort with Difference Lists (9)
Quicksort with Difference Lists (10)
Quicksort with Difference Lists (11)
Quicksort with Difference Lists (12)
Quicksort with Difference Lists (13)
Quicksort with Difference Lists (14)
Quicksort with Difference Lists (15)
Quicksort with Difference Lists (16)
Domain-Specific Data Visualization in VPLs
Data Visualization only visualizes the terms used in a logic program as application specific / domain specific notations.
Such programs can easily be translated into standard textual logic programs.
Example: MPL (Matrix Programming Language) which incorporates a particular array notation. [6]
General Heterogeneous VPLs
A Generic Schema for Data Visualization: Arbitrary Visualizations for terms can be coded into a translation module which translates the visual notation to a textual standard term.
This makes domain-specific visual logic programming languages for arbitrary domains possible.
Example: Finite State Automatons
Exercise: Code the execution of state automatons in standard Prologand compare to this program.
Execution of Heterogeneous VPLsExecution is achieved in three steps:
(1) A preprocessor splits the program into pictures and textual program (with gaps for the pictures),
(2) A customized picture parser translates the visual terms into
their textual equivalents(3) The textual program and the translation of the visual
terms are recombined by a standard parser, resultingin a standard (Prolog) program.
(4) This program can be executed by a standard compiler.
For detailed information see: Heterogeneous Visual Languages. M. Erwig and B. MeyerInternational IEEE Workshop on Visual Languages 1995, Darmstadt, Germany.