Algorithm transformation



Hello,

I'm wondering if there a methodological way to solve the following kind
of problems. I'm going to give an example:

The start could be the set of logical rules that defines whatis/how to
add an integer in a list and the rules to decide if a list is sorted
(sorry if the syntax is prolog like, but it is the programming language
I use usually):

#addition in a list
add(Q,I,[I|Q]).
add([H|Q],I,[H|QR]) <- add(Q,I,QR).

#check is a sorted list
sorted([]).
sorted([_]).
sorted([A,B,|Q]) <- A <= B && sorted([B|Q]).

And the target is to obtain the set of rules for the addition of one
element in a sorted list. That is, the rules of a "sorted_add" that
match the following condition:

sorted_add(A,B,C) <- add(A,B,C) && sorted(C), with precondition
sorted(A).

The rules must match some quality criterias. An example of correct
answer is:

sorted_add([],I,[I]).
sorted_add([H|Q],I,[I,H|Q]) <- I <= H.
sorted_add([H|Q],I,[H|QR]) <- I >= H && sorted_add(Q,I,QR).

Please, has someone references about? Probably is something well known,
but it is far from my usual working area.

Kind regards.

.



Relevant Pages

  • Re: PSP
    ... I'd be interested in your opinions on syntax of PSP... ... Furthermore, if a query fails, it does not ... > look like it allows the programmer to directly mix the Prolog and HTML. ... Another downside is that predicates cannot be ...
    (comp.lang.prolog)
  • Re: If you got to choose the syntax, what would you do?
    ... from one computer to another and get them to execute what syntax would ... This is the simple 'remote execute' problem. ... This is sufficient to let the host examine target memory, ...
    (comp.lang.forth)
  • Re: Is Prolog good for AI? (was: Minsky still posting)
    ... >> widely viewed as a failure. ... programming language was "a version of Prolog". ...
    (comp.lang.prolog)
  • Re: If you got to choose the syntax, what would you do?
    ... from one computer to another and get them to execute what syntax would ... This is the simple 'remote execute' problem. ... This is sufficient to let the host examine target memory, download compiled code, and execute that code. ...
    (comp.lang.forth)
  • Re: C# 3.0 with pseudorelational extensions
    ... >> convinced that unifying the capabilities of the dbms and the ... >> general purpose programming language will lead to some great ... > prolog appeared within months of RM, and was based on just that premise. ... >> mostly about throwing out relational functionality and putting ...
    (comp.databases.theory)

Loading