此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.2)
Mathematica HowTo
How to | Use Logical Operators
Mathematica supports logical operators not only for programming, but for mathematical operations as well.
The infix operators && and || stand for conjunction (And) and disjunction (Or), while ! is the prefix operator for negation (Not). The next two inputs are equivalent:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
You can use symbols instead of True and False. BooleanConvert symbolically evaluates many logical expressions. We expect (a∧b)∨(¬a∧b) to be b:
In[3]:=
Click for copyable input
Out[3]=
Use Resolve to find truth values of quantified logical statements:
In[4]:=
Click for copyable input
Out[4]=
You can also use the existential quantifier to check that  forall _a exists _b((a∧b)∨(¬a∧b)):
In[5]:=
Click for copyable input
Out[5]=
Mathematica also recognizes the logical operator Implies; you can use it to show a∧bb:
In[6]:=
Click for copyable input
Out[6]=
    
Use SatisfiableQ to check if a and b satisfy (a∧b)∧(¬a∨¬b):
In[7]:=
Click for copyable input
Out[7]=