逻辑是一切思考的基础。
# Propositional logic(zeroth order logic)
Propositional logic does NOT deal with non-logical objects, predicates or quantifiers.
For example, the following simple axiom system is an instance of propositional logic:
L ( A , Ω , Z , I ) \mathcal{L}(A,\Omega,Z,I) L ( A , Ω , Z , I ) :
A = { p , q , r , s , t , . . . } A=\{p,q,r,s,t,...\} A = { p , q , r , s , t , . . . } serves to represent logic propositions.
Ω = { ¬ , → } \Omega=\{\neg,\rightarrow\} Ω = { ¬ , → } is the set of logic operators.
Z Z Z is the set of transformation rule. Here it contains only one rule named modus ponens :
p → q , p ⊢ q p\rightarrow q,p\vdash q
p → q , p ⊢ q
I I I is the set of axioms. The axioms are all substitution instances of:
⊢ p → ( q → p ) ⊢ ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ⊢ ( ¬ p → ¬ q ) → ( q → p ) \begin{aligned}
&\vdash p\rightarrow(q\rightarrow p)\\
&\vdash (p\rightarrow(q\rightarrow r))\rightarrow((p\rightarrow q)\rightarrow(p\rightarrow r))\\
&\vdash (\neg p\rightarrow\neg q)\rightarrow(q\rightarrow p)
\end{aligned}
⊢ p → ( q → p ) ⊢ ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ⊢ ( ¬ p → ¬ q ) → ( q → p )
Example : the proof of ¬ ¬ p ⊢ p \neg\neg p\vdash p ¬ ¬ p ⊢ p :
Lemma 1. ⊢ p → p \vdash p\rightarrow p ⊢ p → p .
Proof .
(1) By axiom 1, substitute q q q with p → p p\rightarrow p p → p , we have
p → ( ( p → p ) → p ) p\rightarrow((p\rightarrow p)\rightarrow p)
p → ( ( p → p ) → p )
(2) By axiom 2, substitute q q q with p → p p\rightarrow p p → p and substitute r r r with p p p :
( p → ( ( p → p ) → p ) → ( ( p → ( p → p ) ) → ( p → p ) ) (p\rightarrow((p\rightarrow p)\rightarrow p)\rightarrow((p\rightarrow(p\rightarrow p))\rightarrow (p\rightarrow p))
( p → ( ( p → p ) → p ) → ( ( p → ( p → p ) ) → ( p → p ) )
(3) By Modus ponens and (1), (2):
( p → ( p → p ) ) → ( p → p ) (p\rightarrow(p\rightarrow p))\rightarrow(p\rightarrow p)
( p → ( p → p ) ) → ( p → p )
(4) By axiom 1, substitute q q q with p p p :
p → ( p → p ) p\rightarrow(p\rightarrow p)
p → ( p → p )
(5) By Modus ponens and (3), (4):
p → p p\rightarrow p
p → p
Lemma 2. p → q , q → r ⊢ p → r p\rightarrow q,q\rightarrow r\vdash p\rightarrow r p → q , q → r ⊢ p → r .
Proof .
(1) p → q p\rightarrow q p → q premise
(2) q → r q\rightarrow r q → r premise
(3) By axiom 1,
( q → r ) → ( p → ( q → r ) ) (q\rightarrow r)\rightarrow(p\rightarrow(q\rightarrow r))
( q → r ) → ( p → ( q → r ) )
(4) By Modus ponens and (2), (3):
p → ( q → r ) p\rightarrow (q\rightarrow r)
p → ( q → r )
(5) By axiom 2,
( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) (p\rightarrow(q\rightarrow r))\rightarrow((p\rightarrow q)\rightarrow(p\rightarrow r))
( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) )
(6) By Modus ponens and (4), (5):
( p → q ) → ( p → r ) (p\rightarrow q)\rightarrow(p\rightarrow r)
( p → q ) → ( p → r )
(7) By Modus ponens and (1), (6):
p → r p\rightarrow r
p → r
Lemma 3. ( q → r ) → ( ( p → q ) → ( p → r ) ) (q\rightarrow r)\rightarrow((p\rightarrow q)\rightarrow(p\rightarrow r)) ( q → r ) → ( ( p → q ) → ( p → r ) ) .
Proof .
(1) By axiom 1, substitute p p p with ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) (p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r)) ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ,
( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) → ( [ q → r ] → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) ) ((p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r)))\rightarrow ([q\rightarrow r]\rightarrow ((p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r))))
( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) → ( [ q → r ] → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) )
(2) By axiom 2,
( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) (p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r))
( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) )
(3) By Modus ponens and (1), (2),
( q → r ) → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) (q\rightarrow r)\rightarrow ((p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r)))
( q → r ) → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) )
(4) By axiom 2,
[ ( q → r ) → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) ] → [ ( q → r ) → ( p → ( q → r ) ) → ( ( q → r ) → ( ( p → q ) → ( p → r ) ) ) ] [(q\rightarrow r)\rightarrow ((p\rightarrow (q\rightarrow r))\rightarrow ((p\rightarrow q)\rightarrow (p\rightarrow r)))]\rightarrow[(q\rightarrow r)\rightarrow(p\rightarrow(q\rightarrow r))\rightarrow ((q\rightarrow r)\rightarrow ((p\rightarrow q)\rightarrow(p\rightarrow r)))]
[ ( q → r ) → ( ( p → ( q → r ) ) → ( ( p → q ) → ( p → r ) ) ) ] → [ ( q → r ) → ( p → ( q → r ) ) → ( ( q → r ) → ( ( p → q ) → ( p → r ) ) ) ]
(5) By Modus ponens and (3) (4),
[ ( q → r ) → ( p → ( q → r ) ) ] → ( ( q → r ) → ( ( p → q ) → ( p → r ) ) ) [(q\rightarrow r)\rightarrow (p\rightarrow(q\rightarrow r))]\rightarrow ((q\rightarrow r)\rightarrow((p\rightarrow q)\rightarrow(p\rightarrow r)))
[ ( q → r ) → ( p → ( q → r ) ) ] → ( ( q → r ) → ( ( p → q ) → ( p → r ) ) )
(6) By axiom 1,
( q → r ) → ( p → ( q → r ) ) (q\rightarrow r)\rightarrow(p\rightarrow(q\rightarrow r))
( q → r ) → ( p → ( q → r ) )
(7) By Modus ponens and (5), (6),
( q → r ) → ( ( p → q ) → ( p → r ) ) (q\rightarrow r)\rightarrow((p\rightarrow q)\rightarrow(p\rightarrow r))
( q → r ) → ( ( p → q ) → ( p → r ) )
Lemma 4. ⊢ p → ( ( p → q ) → q ) \vdash p\rightarrow((p\rightarrow q)\rightarrow q) ⊢ p → ( ( p → q ) → q ) .
Proof .
(1) By axiom 3,
( ( p → q ) → ( p → q ) ) → ( ( ( p → q ) → p ) → ( ( p → q ) → q ) ) ((p\rightarrow q)\rightarrow(p\rightarrow q))\rightarrow(((p\rightarrow q)\rightarrow p)\rightarrow((p\rightarrow q)\rightarrow q))
( ( p → q ) → ( p → q ) ) → ( ( ( p → q ) → p ) → ( ( p → q ) → q ) )
(2) By Lemma 1,
( p → q ) → ( p → q ) (p\rightarrow q)\rightarrow(p\rightarrow q)
( p → q ) → ( p → q )
(3) By Modus ponens and (1) (2),
( ( p → q ) → p ) → ( ( p → q ) → q ) ((p\rightarrow q)\rightarrow p)\rightarrow((p\rightarrow q)\rightarrow q)
( ( p → q ) → p ) → ( ( p → q ) → q )
(4) By Lemma 3,
( ( ( p → q ) → p ) → ( ( p → q ) → q ) ) → ( ( p → ( ( p → q ) → p ) ) → ( p → ( ( p → q ) → q ) ) ) (((p\rightarrow q)\rightarrow p)\rightarrow((p\rightarrow q)\rightarrow q))\rightarrow ((p\rightarrow ((p\rightarrow q)\rightarrow p))\rightarrow (p\rightarrow ((p\rightarrow q)\rightarrow q)))
( ( ( p → q ) → p ) → ( ( p → q ) → q ) ) → ( ( p → ( ( p → q ) → p ) ) → ( p → ( ( p → q ) → q ) ) )
(5) By Modus ponens and (3) (4),
( p → ( ( p → q ) → p ) ) → ( p → ( ( p → q ) → q ) ) (p\rightarrow((p\rightarrow q)\rightarrow p))\rightarrow (p\rightarrow ((p\rightarrow q)\rightarrow q))
( p → ( ( p → q ) → p ) ) → ( p → ( ( p → q ) → q ) )
(6) By axiom 1,
p → ( ( p → q ) → p ) p\rightarrow ((p\rightarrow q)\rightarrow p)
p → ( ( p → q ) → p )
(7) By Modus ponens, (5) (6),
p → ( ( p → q ) → q ) p\rightarrow((p\rightarrow q)\rightarrow q)
p → ( ( p → q ) → q )
Proposition ⊢ ¬ ¬ p → p \vdash \neg\neg p\rightarrow p ⊢ ¬ ¬ p → p .
Proof .
(1) By axiom 1, ϕ : : = ( r → ( s → t ) ) \phi::=(r\rightarrow (s\rightarrow t)) ϕ : : = ( r → ( s → t ) ) .
(2) By axiom 3,
( ¬ ¬ ϕ → ¬ ¬ p ) → ( ¬ p → ¬ ϕ ) (\neg\neg\phi\rightarrow \neg\neg p)\rightarrow(\neg p\rightarrow \neg \phi)
( ¬ ¬ ϕ → ¬ ¬ p ) → ( ¬ p → ¬ ϕ )
(3) By axiom 3,
( ¬ p → ¬ ϕ ) → ( ϕ → p ) (\neg p\rightarrow\neg \phi)\rightarrow(\phi\rightarrow p)
( ¬ p → ¬ ϕ ) → ( ϕ → p )
(4) By axiom 1,
¬ ¬ p → ( ¬ ¬ ϕ → ¬ ¬ p ) \neg\neg p\rightarrow(\neg\neg\phi\rightarrow\neg\neg p)
¬ ¬ p → ( ¬ ¬ ϕ → ¬ ¬ p )
(5) By Modus ponens, (3)(4),
¬ ¬ p → ( ϕ → p ) \neg\neg p\rightarrow(\phi\rightarrow p)
¬ ¬ p → ( ϕ → p )
(6) By Lemma 4,
ϕ → ( ( ϕ → p ) → p ) \phi\rightarrow((\phi\rightarrow p)\rightarrow p)
ϕ → ( ( ϕ → p ) → p )
(7) By axiom 1,
ϕ \phi
ϕ
(8) By Modus ponens, (6), (7),
( ϕ → p ) → p (\phi\rightarrow p)\rightarrow p
( ϕ → p ) → p
(9) By Lemma 2, (5), (8),
¬ ¬ p → p \neg\neg p\rightarrow p
¬ ¬ p → p
□ \square □ .
# First-order logic
Consider such an example, there are two propositions:
John is male.
Mike is male.
In propositional logic, we could only to describe with two symbols, that is:
p = John is male q = Mike is male p=\text{John is male}\\
q=\text{Mike is male}
p = John is male q = Mike is male
But “is male” seems to be duplicated part, so we develop a new logic system with predicate and variables.
Let P ( x ) = x is male P(x)=\text{x is male} P ( x ) = x is male , and the two propositions could be interpreted as P ( John ) P(\text{John}) P ( John ) and P ( Mike ) P(\text{Mike}) P ( Mike ) .
First-order logic uses quantified variables over non-logical objects, and allows the use of sentences that contain variables, so that rather than propositions such as “Socrates is a man”, one can have expressions in the form “there exists x such that x is Socrates and x is a man”, where “there exists*”* is a quantifier, while x is a variable.[1] This distinguishes it from propositional logic , which does not use quantifiers or relations ;[2] in this sense, propositional logic is the foundation of first-order logic.
For example, the following formula is a proposition of first order logic
∀ x ∀ y ( P ( f ( x ) ) ) → ¬ ( P ( x ) → Q ( f ( x ) , x , z ) ) ) \forall x\forall y(P(f(x)))\rightarrow\neg(P(x)\rightarrow Q(f(x),x,z)))
∀ x ∀ y ( P ( f ( x ) ) ) → ¬ ( P ( x ) → Q ( f ( x ) , x , z ) ) )
# Second/Higher order logic
First-order logic can quantify over individuals, but not over properties. But in Higher order logic, the following proposition is legitimate:
∀ x ∀ P ( P ( x ) ) \forall x\forall P(P(x))
∀ x ∀ P ( P ( x ) )
while it’s forbidden in first order logic to ∀ P \forall P ∀ P since P P P is a predicate.
In higher order logic, you could almost quantifier over any thing, that is
∀ f , ∃ f \forall f,\exists f
∀ f , ∃ f
where f f f is a function, or predicate, or variables…