What does a predicate mean in the context of computer science?

In particular, I saw how it was used in the context of text filtering. Like a predicate == filter criteria.

How true is this?

+86
computer science
Jul 12 '10 at 18:07
source share
7 answers

This is the term most commonly used in the field of mathematical logic.

From wikipedia

In mathematics, a predicate is either a relation or a logical function that is equal to the characteristic function or indicator function of such a relation.

The function P: X → {true, false} is called the predicate on X. When P is a predicate on X, we sometimes say that P is a property of X.

.

"predicate" == "filtering criteria"

+71
Jul 12 '10 at 18:11
source share

The predicate ("PRED-i-cat") is part of a sentence containing a verb and tells you something about the subject.

For example, in a sentence

"Mike eats," we have the theme "Mike" and the predicate "eat."

In the context of computer science, we are not interested in indicating a fact, but rather when testing the true / false conditions in order to decide what to do.

Person mike; if (!mike.isEating()) feedPerson(mike); 

The isEating() member mike (an instance of Person ) is a predicate. It returns true or false to state that in this case Person ( mike ) is used. The predicate is used to determine whether to feed a person.

Predicates are often found in the form of callbacks, but in the general case, we can use the term for any function that returns a bool based on an assessment of the truth of the statement.

A member function may be required for sorting.

 bool Fruit::ComesAfter(Fruit x) ... 

like our predicate. If x appears after us, our sorting algorithm will replace two fruits.

There is also the term predicate (predi-kate). In English, we use it as follows:

"The issue is based on achieving grades."

This means that one depends on the other.

In computer science, we use this form of the word to describe conditional execution.

For example, in CUDA programming, there are assembly instructions, the execution of which we can predict (KATE) from the previous result. That is, you set the predicate flag (CAT), which, if true, causes the command to execute, and if false, causes the instruction to be processed as NOP. Thus, the execution of the instruction is based on the indicated predicate sign.

Use is very similar.

Hope this helps.

+85
03 Sep '15 at 18:33
source share

The word comes from logic.

A predicate is a logical "eat" question regarding input.

"IsNull" is a predicate question.

Also a wikipedia link on Predicates in Math .

+36
Jul 12 '10 at 18:11
source share

A predicate is a statement that is either true or false.

+13
Apr 15 '14 at 8:13
source share

Sentence:

  • either definitely set to true or false
  • independent of parameter values
  • eg.
    • "x + 2 = 2x when x = -2" => true
    • "2 * 2 = 5" => false

predicate:

  • The value of truth depends on the value of the parameter.
  • eg.
    • "x + 2 = 2x" => the value of truth is unknown and depends on the value of x

Use quantifiers to convert a predicate to a sentence:

  • ∃x∈Z (x + 2 = 2x) "In the set of integers there is x such that x + 2 = 2x"
+4
Sep 07 '15 at 9:49
source share

Just to simplify things. A predicate is a function that returns true or false.

used as a "filter criterion", which means: allows you to consider an array of numbers and a predicate that returns true if the number> 0, false is different.

 function predicate(number){ return number > 0 } // array of numbers var numbers = [-2 , -1 , 0 , 1 , 2]; var newNumbers = numbers.filter(predicate); // newNumbers => [1 , 2] ; 

filter is a function that returns a new array based on a predicate (or "filter criteria".)

he filtered the array based on the value of the predicate

  • true: enable value
  • false: do not enable it
+3
Sep 08 '16 at 20:42 on
source share

Predicate is a function that takes a single element as an input parameter and returns either true or false. Predicates are used in higher-order functions applied to a certain function (aka transformer) by element to a list of elements and return a list of results. A transformer is a function applied to each element and creates one or more new elements.

+1
Apr 29 '17 at 2:15
source share



All Articles