5

What are the requirements a computer function/procedure/predicate must meet to be considerd "monotonic"?

Let A be some thing ,
Let B be some thing ,
Let R be a monotonic relationship between A and B ,
Let R_ be a non-monotonic relationship between A and B ,
Let R become false if R_ is true ,
Let R_ become true if R is false ,
Let C be a constraint in consideration of R ,
Let C become false if R_ is true ,
Let D be the collection of constraints C (upon relationship R) .

**What is D ?**

I have reviewed some literature, e.g. a Wikipedia article "monotonic function". I am most interested in a practical set of criteria I can apply when pragmatically involved with computer programming. What are some tips and best practices I should follow when creating and designing my functions, such that they are more likely to be "monotonic"?

s0nata
  • 194
  • 1
  • 7
Kintalken
  • 763
  • 5
  • 9
  • funny , I had "haskell" as a tag but it got removed , perhaps such a consideration as this is of no interest to a Haskell programmer ? – Kintalken Apr 10 '17 at 04:56
  • 1
    perhaps this question would be a better fit on http://softwareengineering.stackexchange.com ? – cypherabe Apr 10 '17 at 15:06
  • 1
    What is the context here? Where do all of those "let"s come from? "Monotonic" and "non-monotonic" don't really make sense unless you have an ordering on the items in/of type `A` and in `B`. So, at the very least, this question cannot be answered in a specific way without that information. Also, unless I'm mistaken, it sounds like you think monotonic functions are "better" than non-monotonic functions which is not true. It is just a certain mathematical property that some functions have (and some don't). – David Young Apr 10 '17 at 20:05
  • Oh, this sounds like it might be very logic programming specific, since this is tagged "prolog." Incidentally, that would be a good reason for the `haskell` tag to have been removed if that is the case... I don't know much about logic programming, but I can imagine there is probably a specific kind of monotonicity that is important there (unless I'm totally missing the mark on what you're asking). – David Young Apr 10 '17 at 20:27

1 Answers1

6

In logic programming, and also in logic, the classification "monotonic" almost invariably refers to monotonicity of entailment.

This fundamental property is encountered for example in classical first-order logic: When you are able to derive a consequence from a set of clauses, then you can also derive the consequence when you extend the set of clauses. Conversely, removing a clause does not entail consequences that were previously not the case.

In the pure subset of Prolog, this property also holds, from a declarative perspective. We therefore sometimes call it the pure monotonic subset of Prolog, since impurities do not completely coincide with constructs that destroy monotonicity.

Monotonicity of entailment is the basis and sometimes even necessary condition for several approaches that reason over logic programs, notably declarative debugging.

Note that Prolog has several language constructs that may prevent such reasoning in general. Consider for example the following Prolog program:

f(a).
f(b).
f(c).

And the following query:

?- setof(., f(X), [_,_]).
false.

Now I remove one of the facts from the program, which I indicate by strikethrough text:

f(a) :- false.
f(b).
f(c).

If Prolog programs were monotonic, then every query that previously failed would definitely now fail all the more, since I have removed something that was previously the case.

However, we now have:

?- setof(X, f(X), [_,_]).
true.

So, setof/3 is an example of a predicate that violates monotonicity!

mat
  • 40,498
  • 3
  • 51
  • 78
  • A very excellent answer ! Thank-you very much , @mat . Unfortunately the "accept this answer" checkmark button is dysfunctionl , dkw . I question the use of `setof` in such a manner to prove your point . Yer exmpl is equivalent to ``` (setof(__X__,f(__X__),__Y__)) , __Y__ = [_,_] .``` , I believe it is the `=` thus not the `setof` that causes the violation of monotonicity . – Kintalken Apr 19 '17 at 10:25
  • In the example above , are "a" , "b" , "c" the names of other functions ? They are barewords so I assume they are keywords or function names ? – Kintalken Apr 19 '17 at 10:28
  • Sorry , formatting problem in my comment above , it seems hard to use `_` underscore in stackoverflow comments . s/b : :- ((setof(X,f(X),Y)) , Y = [`_`,`_`]) – Kintalken Apr 19 '17 at 10:48
  • 1
    @Kintalken: if you have formatting problems in comments, write the comment a 2nd time, then delete the preceding malformed one. – false May 08 '17 at 21:35
  • 1
    The very same `setof/3` does not violate monotonicity as long as one only uses partial lists with anonymous variables, like `setof(X, f(X), [_,_|_])` – false May 08 '17 at 21:36
  • @mat I added a follow-up question to the main topic as-if it was another "answer" . – Kintalken May 10 '17 at 14:52
  • 1
    ... the follow-up question was subsequently deleted by "brad" . Not sure how to facilate discussion on stackoverflow . Seem's to be oriented as some kind of american-style service industry . In exchange for revealing to the world that you are stupid , a servant will answer your question for you . In return , the servant must demonstrate they are a master , by providing the answer , and is benefited the tremendous feeling they gain by being an expert in a world , and the receipt of some shiny stackoverflow gold stars . Absolutely forbidden : the "tangential" .i.e. "off-topic" . – Kintalken May 10 '17 at 17:13
  • follow-up question : http://stackoverflow.com/questions/43901559/is-this-pogram-entailedmonotonically/44100451#44100451 – Kintalken May 21 '17 at 18:37