Several common logic operations
One, logical operators
A proposition composed of one or more propositions is called a compound proposition , and the symbols used to combine the propositions are called logical operators or connectives . Commonly used are ┐, ∧, ∨, ⊕, →, ↔, etc.
2. Definition 1: Negation (not)
If there is a proposition p, then the negation of p is denoted as ┐p (or denoted as ), which means taking the opposite side of the proposition p (or the case other than p).
Example 1: Let the proposition p be: Xiao Zhang’s laptop has at least 2G of memory.
Then the proposition ┐p: It is not that Xiao Zhang’s laptop has at least 2G of memory. It can also be said that Xiao Zhang’s laptop has less than 2G of memory.
Truth table
3. Definition 2: Conjunction (and)
Suppose there are two propositions p and q, then the conjunction of p and q is "p and q", denoted as p∧q , which means that when p and q are satisfied at the same time, it is true (the truth value is T), otherwise both It is deemed not true (the truth value is F).
Example 2: This recruitment is only for those who have more than 2 years of work experience and graduated in computer science.
p is: have more than 2 years of work experience; q is: graduated from computer major, then p∧q is a person who meets these two conditions at the same time.
Truth table:
4. Definition 3: Disjunction (or--concurrently)
Suppose there are two propositions p and q, then the disjunction of p and q is "p or q", denoted as p ∨ q , which means that as long as one or both of p and q are satisfied , it holds (true The value is T), otherwise it is deemed invalid (the true value is F).
Example 2: Students who have studied Advanced Mathematics or Discrete Mathematics can participate in this training.
p is: learned "Advanced Mathematics"; q is: learned "Discrete Mathematics", then p ∨ q is a student who satisfies one or both of these two conditions.
Truth table:
5. Definition 4: Exclusive OR (xor)
There are two propositions p, q, then p and q, i.e., the exclusive-OR "p or q" (only choose one), referred to as p ⊕ q , meaning that p and q satisfy only happens in a time, it It is true (the truth value is T), otherwise it is deemed not true (the truth value is F).
Example 2: You can choose to use C++ or JAVA to implement this program.
p is: implemented using C++; q is: implemented using JAVA, then p ⊕ q can only meet one of these two conditions.
Truth table:
^-^ I have written here today, and I will record the remaining symbols next time. ^-^