s 1 ,s 2 (s 1 = s 2 )

advertisement
‫ייצוג מידע ודרכי החלטה‬
Logic in general
• Logics are formal languages for representing information
such that conclusions can be drawn
• Syntax defines the sentences in the language
• Semantics define the “meaning” of sentences;
– i.e., define truth of a sentence in a world
• E.g., the language of arithmetic
– x+2 ≥ y is a sentence; x2+y > is not a sentence
2
Propositional logic: Syntax
• Propositional logic is the simplest logic – illustrates
basic ideas
• The proposition symbols P1, P2, etc. are sentences
–
–
–
–
If S is a sentence, S is a sentence (negation)
If S1 and S2 are sentences, S1  S2 is a sentence (conjunction)
If S1 and S2 are sentences, S1  S2 is a sentence (disjunction)
If S1 and S2 are sentences, S1  S2 is a sentence (implication)
• Implication also is Not S1  S2
– If S1 and S2 are sentences, S1  S2 is a sentence
(biconditional)
–
3
Propositional logic: Semantics
Rules for evaluating truth with respect to a model m:
S
is true iff S is false
S1  S2 is true iff
S1 is true and S2 is true
S1  S2 is true iff
S1is true or S2 is true
S1  S2 is true iff
S1 is false or S2 is true
i.e., is false iff
S1 is true and S2 is false
S1  S2 is true iff
S1S2 is true and S2S1 is true
Simple recursive process evaluates an arbitrary sentence, e.g.,
P1,2  (P2,2  P3,1) = true  (false  true) = true  true =
true
4
Truth tables for connectives
5
More examples
• Show that A  B ≡ (A → B) Λ (B → A)
• Show that: [(t → w) Λ ~ w] → ~ t
• Show that: [(p → q) Λ (q → r) ] → (p → r)
Law of Modus Tollens
Given:
t →w
w
Prove:  t
t →w
~w
~t
or [(t → w) Λ ~ w] → ~ t
Set up a truth table to prove!
Prove [(t → w) Λ ~ w] → ~ t]
t
w ~t ~w t → w
(t → w) Λ ~ w
[(t → w) Λ ~ w ]→ ~ t
Prove [(t → w) Λ ~ w] → ~ t
t
w ~t ~w t → w
T
T
F
F
T
F
F
F
T
F
F
(t → w) Λ ~ w
(t → w) Λ ~ w → ~ t
T
F
T
T
F
F
T
T
F
T
F
T
T
T
T
T
T
[(t → w) Λ ~ w] → ~ t is a Tautology therefore a valid argument!
Chain Rule (Law of Syllogism)
[(p → q) Λ (q → r) ] → (p → r)
p q r
p →q
q →r
(p → q) Λ (q → r)
p →r
See
above
Chain Rule (Law of Syllogism)
[(p → q) Λ (q → r) ] → (p → r)
p q r
T
T
T
T
F
F
F
F
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
p →q
q →r
(p → q) Λ (q → r)
p →r
See
above
Chain Rule (Law of Syllogism)
[(p → q) Λ (q → r) ] → (p → r)
p q r
p →q
q →r
T
T
T
T
F
F
F
F
T
T
F
F
T
T
T
T
T
F
T
T
T
F
T
T
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
(p → q) Λ (q → r)
T
F
F
F
T
F
T
T
p →r
T
F
T
F
T
T
T
T
See
above
T
T
T
T
T
T
T
T
Chain Rule
Example
p : You study
q : You pass
r : You get a surprise
P1:
P2:
pq
qr
If you study, then you will pass.
If you pass, then you will get a surprise.
Logical equivalence
• Two sentences are logically equivalent iff true in same
models: α ≡ β iff α╞ β and β╞ α
•
•
14
Satisfiability
• A sentence is satisfiable if it is true in some model
e.g., A  B, C
• A sentence is unsatisfiable if it is true in no models
e.g., A A
• Disjunction normal form (DNF) : Only “Or” between Logic
statements
– (A1  B1)  (A2  B2)  (A3  B3)
• Conjunction normal form (CNF) : Only “And” between Logic
statements
– (A1  B1)  (A2  B2)  (A3  B3)
15
Hard satisfiability problems
• Consider random 3-CNF sentences (randomly selected
3 distinct symbols, each negated with 50%
probability), e.g.,
(D  B  C)  (B  A  C)  (C  B  E)  (E 
D  B)  (B  E  C)
m = number of clauses
n = number of symbols (overall, in the KB)
– Hard problems seem to cluster near m/n = 4.3 (critical point)
– Lower ratio is less constrained, higher ratio is more
constrained
16
Hard satisfiability problems
Graph showing probability that a random 3-CNF sentence with n=50 symbols is
satisfiable, as a function of the clause/symbol ratio m/n
17
Other Logics…
18
First Order Logic
•
•
•
•
•
•
•
Constants
Predicates
Functions
Variables
Connectives
Equality
Quantifiers
KingJohn, 2, HU, ...
Brother, >, ...
Sqrt, LeftLegOf, ...
x, y, a, b, ...
, , , , 
=
, 
19
Universal quantification
• <variables> <sentence>
Everyone at HU is smart:
x At(x, HU)  Smart(x)
• x P is true in a model m iff P is true with x being each
possible object in the model
• Roughly speaking, equivalent to the conjunction of
instantiations of P


 ...
At(KingJohn, HU)  Smart(KingJohn)
At(Richard, HU)  Smart(Richard)
At(HU, HU)  Smart(HU)
20
Existential quantification
<variables> <sentence>
Someone at TAU is smart:
x At(x, TAU)  Smart(x)
x P is true in a model m iff P is true with x being
some possible object in the model
• Roughly speaking, equivalent to the disjunction of
instantiations of P
•
•
•
•
At(KingJohn, TAU)  Smart(KingJohn)
 At(Richard, TAU)  Smart(Richard)
 At(TAU, TAU)  Smart(TAU)
 ...
21
Fun with sentences
• Brothers are siblings
x y Brother(x, y)  Sibling(x, y)
• “Sibling” is symmetric
x y Sibling(x, y)  Sibling(y, x)
• One’s mother is one’s female parent
x y Mother(x, y)  (Female(x)  Parent(x, y))
• A first cousin is a child of a parent’s sibling
x y FirstCousin(x, y)  p ps Parent(p, x) 
Sibling(ps, p)  Parent(ps, y)
22
Using FOL
The set domain:
• s Set(s)  (s = {} )  (x,s2 Set(s2)  s = {x|s2})
• x,s {x|s} = {}
• x,s x  s  s = {x|s}
• x,s x  s  [ y,s2} (s = {y|s2}  (x = y  x  s2))]
• s1,s2 s1  s2  (x x  s1  x  s2)
• s1,s2 (s1 = s2)  (s1  s2  s2  s1)
• x,s1,s2 x  (s1  s2)  (x  s1  x  s2)
• x,s1,s2 x  (s1  s2)  (x  s1  x  s2)
23
Examples
• http://people.umass.edu/partee/NZ_2006/M
ore%20Answers%20for%20Practice%20in%20
Logic%20and%20HW%201.pdf
Using FOL
The set domain:
• s Set(s)  (s = {} )  (x,s2 Set(s2)  s = {x|s2})
• x,s {x|s} = {}
• x,s x  s  s = {x|s}
• x,s x  s  [ y,s2} (s = {y|s2}  (x = y  x  s2))]
• s1,s2 s1  s2  (x x  s1  x  s2)
• s1,s2 (s1 = s2)  (s1  s2  s2  s1)
• x,s1,s2 x  (s1  s2)  (x  s1  x  s2)
• x,s1,s2 x  (s1  s2)  (x  s1  x  s2)
25
‫דרכים להחליט בפועל‬
• Fuzzy Logic
• MDP
• Game Theory
Applications of MDPs
This extends the search algorithms of your first lectures
to the case of probabilistic next states.
Many important problems are MDPs….
…
…
…
…
…
…
…
Copyright © 2002, 2004,
Andrew W. Moore
Robot path planning
Travel route planning
Elevator scheduling
Bank customer retention
Autonomous aircraft navigation
Manufacturing processes
Network switching & routing
The “Standard” Approach – MDP
MDP model is a 4-tuple
where:
• S is the set of all possible environment states.
• N is a group of agents.
• Ai is the set of all possible joint actions applicable in the
environment by agent i.
• Pr models dynamics
– S x A x S  [0, 1] with Pr(si, a, sj) denotes the probability that
action a executed in state si, will transition to state sj .
• R is the reward function for agents’ possible actions.
Markov Decision Processes
An MDP has…
• A set of states {s1 ··· sN}
• A set of actions {a1 ··· aM}
• A set of rewards {r1 ··· rN} (one for each state)
• A transition probability function
Pijk  ProbNext  j This  i and I use action k 
At each step:
0. Call current state Si
1. Receive reward ri
2. Choose action  {a1 ··· aM}
3. If you choose action ak you’ll move to state Sj with probability
4. All future rewards are discounted by g
Copyright © 2002, 2004, Andrew W.
Moore
Pijk
John Nash, the person portrayed in “A
Beautiful Mind”
Game theory: Payoff matrix
Person 2
Action C
Person 1
Action D
Action A 10, 2
8, 3
Action B 12, 4
10, 1
• A payoff
matrix
shows the
payout to
each player,
given the
decision of
each player
How do we find Nash equilibrium
(NE)?
• Step 1: Pretend you are one of the players
• Step 2: Assume that your “opponent” picks a particular action
• Step 3: Determine your best strategy (strategies), given your
opponent’s action
– Underline any best choice in the payoff matrix
• Step 4: Repeat Steps 2 & 3 for any other opponent strategies
• Step 5: Repeat Steps 1 through 4 for the other player
• Step 6: Any entry with all numbers underlined is NE
Decision tree in a sequential game:
Person 1 chooses first
Person 1
chooses
yes
B
A
Person 1
chooses
no
C
Person 2
chooses
yes
Person 2
chooses no
Person 2
chooses
yes
20, 20
5, 10
10, 5
Person 2
chooses no
10, 10
2 player zero-sum finite NONdeterministic
games of perfect information
The search tree now includes states where neither player makes
a choice, but instead a random decision is made according to a
known set of outcome probabilities.
( )-a
( )-chance
p=0.5
p=0.5
( )-b
( )-b
+4
-20
( )-b
( )-chance
p=0.8
p=0.2
( )-a
( )-a
( )-a
-5
+10
+3
Game theory value of a state is the expected final value if both players
are optimal.
Let’s compute a matrix form of this!
Slide 34
Minimax with Matrix Forms
A can decide from this matrix which strategy is
“best”. For each strategy, A considers the
worst-case counter strategy by B. A chooses
the row with the maximum minimum value.
For A, the value of the game is this value.
In this example A chooses A-II, and says game has value 3.
B-I
B-II
B-III
A-I
7
3
-1
A-II
7
3
4
A-III
2
2
2
A-IV
2
2
2
When B decides which strategy is best, B
searches for which column has the minimum
maximum value.
In this example, B chooses B-II, and says game has value 3.
Fundamental game theory result (proved by von Neumann):
In a 2-player, zero-sum game of perfect information,
Maximin==Minimax. And there always exists an optimal
pure strategy for each player.
Slide 35
Fuzzy Logic

What is Fuzzy Logic?
 Problem-solving control system methodology
 Linguistic or "fuzzy" variables
 Example:
IF (process is too hot)
AND (process is heating rapidly)
THEN (cool the process quickly)
Approach

The Rule Matrix
 Error (Columns)
 Error-dot (Rows)
 Input conditions (Error
and Error-dot)
 Output Response
Conclusion (Intersection
of Row and Column)
-ve
Error
Zero
Error
-ve
Errordot
Zero
Errordot
+ve
Errordot
No
change
+ve
Error
Download