Three days of interesting talks & workshops from industry experts across Australia Explore new computing topics Network with students & employers in Brisbane Price: $25 (incl. T-Shirt, morning tea and lunch) Visit: https://compcon.net.au/2016/
Assignment 1 } Due tonight!!! } Submit to turnitin via blackboard
COMP3702/7702 Artificial Intelligence Week 5: Search in Continuous Space A Bit More Details (Cont.) Hanna Kurniawati
Almost done with the first part } Assumptions on class environment: } Discrete vs. continuous. } Fully observable vs. partially observable. } Deterministic vs. non-deterministic. } Static vs. dynamic.
Last (2) weeks Intro to Motion Planning Simplest case: Point robot in a 2D world Formulating the problem as a search problem and solving it More general case Formulating the problem Solving the problem using Probabilistic Roadmap (PRM): A better way to search in continuous space More details on PRM Sampling strategy (adding vertices). Check if a configuration is valid or not. Check if a line segment in C-space is valid or not. Connection strategy (adding edges).
Today } Why sampling based method works?
Why Sampling-based Approaches work? (Intuitively) } Abundant solutions. } To solve the problem, we only need to find one of the solutions C-space G I
Why Sampling-based Approaches work? } In most free spaces of real world problems, every configuration sees a significant fraction of the free space } A configuration q sees another configuration q whenever the straight line segment between q & q lies entirely in the free space. } A relatively small number of vertices & edges are sufficient to cover most free spaces with high probability, and hence solve the given queries. C-space
Slightly more formal C-space F 1 F 2 } The lookout of a subset F 1 of the free space is the set of all configurations in F 1 from which it is possible to see a significant fraction of the free space outside F 1. } β-lookout(f 1 ): The set of configurations in F 1 from which it is possible to see β fraction of the free space outside F 1.
Slightly more formal C-space F 1 F 2 } The free space F is expansive if all of its subsets have a large lookout } F is αβ-expansive if for any connected subset F i of F, Vol(β-lookout(F i )) αvol(f i ). } The number of samples to capture the correct connectivity of the free space with probability at least P is inversely proportional to α, β, and (1-P). } PRM (and its variants) performs well when the free space of the problem has large α and β.
Which one is easier to solve by samplingbased approaches? C-space C-space
Slightly more formal Notes } If we know α and β of the free space, we can compute the number of samples to solve a given problem with high probability. } But, to compute α and β, we need the geometry of the free space. } PRM is successful exactly because it s not computing the geometry of the free space. } Practically, we don t know α&β, nor the exact #samples to use. } So, why bother? } Sometimes, we can guess α and β from the workspace à know when to use PRM and when not. } Guarantees that we will eventually get a solution (if a solution exists).
Today Why sampling based method works? With this, you can do Assignment 2 J Premiere: Monday, 29 Aug
COMP3702/7702 Artificial Intelligence Week 5: Logic (Russell & Norvig ch. 6) Last topic in our AI part-1 Hanna Kurniawati
Today } What is logic? } Propositional logic: Syntax & Semantics } Example of using logic to represent a problem } Two types of problems: } Validity } Satisfiability
What is logic? } A formal language to represent sets of states } A convenient abstraction for dealing with many states. } Recall in PRM: We can view a vertex in a roadmap to represent a set of nearby states. } Regardless of whether there s a natural notion of near or not (i.e., not a metric space), we can use logic to group different states together. } Ex.: I have a laptop. à Includes any brand & model There is a laptop on the table. à Can be at any position on the table
Where is Logic used? } Action planning (since the first general purpose mobile robot, Shakey 69) } IC design } Esp. after Pentium FDIV (Floating-point Division) bug in 94. } Karnaugh map (K-map) } Database, e.g., SQL } Debugging } Game player
A formal language } Defined by 2 things: Syntax & Semantics } Syntax } What expressions are legal. } Example: for (j = 0; j < 3; j++) { } Coloring books sleep furiously. } Semantics } Meaning of the legal expression.
Many types of logic } Propositional logic. } Predicate / first order logic. } High order logic.
Today What is logic? } Propositional logic: Syntax & Semantics } Example of using logic to represent a problem } Two types of problems: } Validity } Satisfiability
Propositional logic Syntax } Atomic sentence. } An expression that is known to either be true or false. } Are these propositions? } What is the distance between Mars and Earth? } x + 2 = 2x. } x + 2 = 2x when x = 1. } 2x < 3x. } Often represented with a symbol called propositional variable, e.g., P, Q.
Propositional logic Syntax } Complex sentences } Constructed from atomic sentences and logical connectives: bracket ( () ), negation (~), and ( ), or ( ), implication (à), biconditional ( ). } If S is a sentence, (S) is a sentence. } If S is a sentence, ~S is a sentence (negation). } If S 1 and S 2 are sentences, S 1 S 2 is a sentence (conjunction). } If S 1 and S 2 are sentences, S 1 S 2 is a sentence (disjunction). } If S 1 and S 2 are sentences, S 1 à S 2 is a sentence (implication). } If S 1 and S 2 are sentences, S 1 S 2 is a sentence (biconditional).
Propositional logic Semantics } Meaning of a sentence: Truth values {True, False}. } The truth value of a complex sentence can be derived from the truth values of logical connectives for the given interpretation. P Q ~P P Q P Q PàQ P Q F F T F F T T F T T F T T F T F F F T F F T T F T T T T
Propositional logic Semantics } Interpretation: Assignment of truth values to propositional variables. } A model of a sentence: An interpretation that makes the sentence to be true. } A sentence A entails another sentence B (denoted as A = B) iff every model of A is also a model of B (A à B is true) All models of A All models of sentence B All possible interpretations
Entailment } Relation between sentences are based on relation between their interpretations A entails B semantics Interpretations Models of A subset semantics Interpretations Models of B
Some terminology } A sentence is valid: Its truth value is T for all possible interpretations. Ex.: P ~P } A sentence is satisfiable: Its truth value is T for at least one of the possible interpretations. Ex.: ~P Everything that s valid is also satisfiable. } A sentence is unsatisfiable: Its truth value is F for all possible interpretations. Ex.: P ~P } For propositional logic, we can always decide if a sentence is valid/satisfiable/unsatisfiable in finite time (decidable).
Today What is logic? Propositional logic: Syntax & Semantics } Example of using logic to represent a problem } Two types of problems: } Validity } Satisfiability
An example on how logic is used to represent a problem } Formulate information as propositional logic sentences } Create a knowledge base (KB). } KB: a set of sentences, such that KB is false in models that contradict what the agent knows } Example: The Wumpus World
Example: Wumpus world Representing the problem
Example: Wumpus world Representing the problem } Suppose: } P x,y is true iff there s a pit in (x, y). } B x,y is true iff the agent perceives a breeze in (x, y). } W x,y is true iff there s Wumpus in (x, y). } S x,y is true iff the agent perceives a smell in (x, y). } Go x,y is true iff there s gold in (x,y). } G x,y is true iff the agent perceives glitter in (x,y). } Initial knowledge base: } Rules of the environment, e.g.: } S 1 : B 1,1 <-> (P 1,2 P 2,1 ). } S 2 : B 2,1 <-> (P 1,1 P 2,2 P 3,1 ). } :
Example: Wumpus world Representing the problem } Results of perception up to the current time can be added to KB } Ex.: Suppose the agent has only visited (1,1) and perceives: } P 1,1 = F ; B 1,1 = F ; W 1,1 = F ; S 1,1 = F ; Go 1,1 = F ; G 1,1 = F. } Then, we can add the following sentences to the initial KB: ~P 1,1, ~B 1,1, ~W 1,1, ~S 1,1, ~Go 1,1, ~G 1,1
Example: Wumpus world What can we use KB for? } Deduce new information: Sentences entailed by the current KB can be added to the KB } Answering questions such as can we conclude there s no pit in (1, 2)? Formally: } Given the knowledge base: S 1, S 2, S 3,., S n } Does KB entails ~P 1,2? } Meaning: Is the sentence S 1 S 2 S 3 S n à ~P 1,2 valid?
Today What is logic? Propositional logic: Syntax & Semantics Example of using logic to represent a problem } Two types of problems: } Validity } Satisfiability
Validity Problems } Is a given sentence valid? } The sentence is true under all interpretations
Example: Wumpus world Representing the problem } Question: Can we conclude there s no pit in (1, 2)? } Formally: Does the sentence valid? } Two ways: } Model checking. S 1 S 2 S 3 S 52 à ~P 1,2 } Check validity by checking all models. } Theorem proving } Check validity without checking all models.
(Simple) Model checking } KB: } R 1 : ~P 1,1 } R 2 : B 1,1 (P 1,2 V P 2,1 ) } R 3 : B 2,1 (P 1,1 V P 2,2 V P 3,1 ) } R 4 : ~B 1,1 } R 5 : B 2,1 } Check if ~P 1,2 is entailed by KB.
(Simple) Model checking } Enumerate the models. } All true/false values for P 1,1, B 1,1, P 1,2, P 2,1, B 2,1, P 2,2, P 3,1. } Check if ~P 1,2 is true in all models where the knowledge base (R 1 R 2 R 3 R 4 R 5 ) is true.
(Simple) Model checking } Sound. } The result is correct. } Complete } It always gives an answer. } Complexity: } Time: O(2 n ). } Space: O(n). } n is #propositional variables.
} Question: Can we conclude there s no pit in (1, 2)? } Easy for us to see, but how to enable computers see it, too? } Formally: Does the sentence valid? } Two ways: } Model checking. S 1 S 2 S 3 S 4 S 5 à ~P 1,2 } Check validity by checking all models. } Theorem proving } Check validity without checking all models.
Logical equivalences α, β: Sentence (atomic or complex).
Inference rules } Transformation for logical expressions. } Modus ponens αàβ α β } Modus tollens αàβ ~β ~α } And-elimination α β α
Theorem proving Natural deduction } Use inference rules to deduce a sentence from the set of sentences in the knowledge base. } Example: } KB: } S 1 : ~P 1,1 } S 2 : B 1,1 (P 1,2 V P 2,1 ) } S 3 : B 2,1 (P 1,1 V P 2,2 V P 3,1 ) } S 4 : ~B 1,1 } S 5 : B 2,1 } Check if ~P 1,2 is entailed by KB.
Example } S 1 : ~P 1,1 } S 2 : B 1,1 (P 1,2 V P 2,1 ) } S 3 : B 2,1 (P 1,1 V P 2,2 V P 3,1 ) } S 4 : ~B 1,1 } S 5 : B 2,1 } S 6 : Biconditional elimination to S 2 : (B 1,1 à (P 1,2 P 2,1 )) ((P 1,2 P 2,1 ) à B 1,1 ) } S 7 : And-elimination to S 6: (P 1,2 P 2,1 ) à B 1,1 } S 8 : Modus tollens on S 4 and S 7 : ~(P 1,2 P 2,1 ) } S 9 : De Morgan to S 8 : ~P 1,2 ~P 2,1. } S 10 : And elimination to S 9 : ~P 1,2
Theorem proving Natural deduction Using Search } State space: } All possible set of sentences. } Action space: } All inference rules. } World dynamics: } Apply the inference rule to all sentences that match the above the line part of the inference rule. Become the sentence that lies below the line of the inference rule. } Initial state: } Initial knowledge base. } Goal state: } The state contains the sentence we re trying to prove.
Theorem proving Natural deduction } Sound. } May not be complete. } Depend on whether we can provide a complete list of inference rules. } When we can, the branching factor can be very high.
Resolution } A single inference rule. α β ~β γ α γ α, β: Sentence (atomic or complex). } But, the single inference rule is sound & complete only when applied to propositional logic sentences written in Conjunctive Normal Form (CNF).
Conjunctive Normal Form (CNF) } Conjunctions of disjunctions. } Example: (~A B) (C D) (E F). } Some terminologies } Clause: A disjunctions of literals, e.g., (~A B). } Literals: variables or the negation of variables, e.g., ~A and B. } CNF is quite useful for model checking and for solving satisfiability problems too.
Converting to CNF } Every sentence in propositional logic can be written in CNF. } Three steps conversion: } Eliminate arrows using definitions. } Drive in negations using De Morgan s Laws. } Distribute OR over AND.
Example } Convert (A B) à (C à D) to CNF } Eliminate arrows: ~(A B) (~C D) } Drive in negations: (~A ~B) (~C D) } Distribute OR over AND: (~A ~C D) (~B ~C D)
Theorem proving -- Resolution refutation } Three steps: } Convert all sentences into CNF. } Negate the desired conclusion. } Apply resolution rule until } Derive false (a contradiction). } Can t apply the rule anymore. } Sound & complete (for propositional logic). } If we derive a contradiction, the conclusion follows from the axioms. } If we can t apply any more, the conclusion cannot be proved from the axioms.
Example } Knowledge base: (P Q) (P à R) (Q à R). } Does the knowledge base entails R? } Knowledge base: P ~P } Does the knowledge base entails R?
Today What is logic? Propositional logic: Syntax & Semantics Example of using logic to represent a problem } Two types of problems: Validity } Satisfiability
Satisfiability Problems } Is a given sentence satisfiable? } There is at least one interpretation that makes the sentence to be True. } Various applications } Many problems can be phrase as a list of constraints, and a solution is an assignment that satisfies all constraints. } Verify air-traffic controller } Write the rules as a set of logical sentences. } Check whether the set of sentences and the sentence two airplanes on the same runway at the same time is satisfiable? } When the rules are followed and two airplanes is satisfiable: DANGER. L
Satisfiability Problems } Satisfiability for propositional logic (also called boolean satisfiability) is a particular type of Constraint Satisfaction Problem (CSP) } CSP } Given: Variables X 1,, X n where the domain for the variables are D 1,, D n respectively. Constraints C 1,, C m. Each constraint defines a subset of valid combination of the values for the variables. } Find: A value for each variable such that all constraints are satisfied. } Boolean satisfiability is CSP where the variables are binary variables, each D 1 to D n are the same (i.e., T/F). } Some methods for boolean satisfiability can be extended to CSP
Model Checking for Satisfiability Problem (SAT Solvers) } Assign & simplify strategy } Consider a search tree where at each level we consider the possible assignments to one variable, say V. } On one branch, we assume V is False and on the other that it is True. } Given an assignment for a variable, we can simplify the sentence and then repeat the process for another variable. } Ex.: Davis Putnam Logeman Loveland (DPLL) } Random assignment of all variables in the sentence
Davis Putnam Logeman Loveland (DPLL) } DPLL(Sentence S) } If S is empty, return True } If S has an empty clause, return False } If S has a unit clause U, return DPLL(S(U)) } Unit clause: Consists of only 1 literal } S(U) means a simplified S after a value is assigned to U } If S has a pure clause U, DPLL(S(U)) } Pure clause: Appear as positive only or negative only in S } Pick a variable v, } If DPLL(S(v)) then return true Else return DPLL(S(~v)) } Heuristic to pick the variable: Max #occurences, Min size clauses. Basically, pick the most constrained variable first (if it s going to fail, better fail early).
Example } (A B) (~C V A) (C V B) } (P Q) (P ~Q R) (T ~R) (~P ~T) (P S) (T R S) (~S T )
DPLL } Sound } Complete } Speed & memory consumption depend a lot on: } Which symbol is being assigned first } Which assignment is being followed first } A lot of methods have been proposed.
Model Checking for Satisfiability Problem (SAT Solvers) } Assign & simplify strategy } Random assignment of all variables in the sentence } Ex.: GSAT
GSAT } GSAT(Sentence S) } Loop n times } Randomly choose assignment for all variables, say A } Loop m times Flip the variable that results in lowest cost Cost(assignment) = number of unsatisfied clauses Return True if cost is zero } Sound but not complete } Cannot be used to generate all satisfiable assignments
DPLL vs GSAT } For a moment, performs much better than DPLL } Now, } Weakly constrained problems (large proportion of the assignments is satisfiable): } Easy for DPLL J & Easy for GSAT J } Highly constrained problems (very few satisfiable assignments, sometimes only 1): } Easy for DPLL J, but Hard for GSAT L } Problems in the middle: } Hard for DPLL L & Hard for GSAT L
Today What is logic? Propositional logic: Syntax & Semantics Example of using logic to represent a problem Two types of problems: Validity Satisfiability
Next week Second part of the class: Making decisions when information are inaccurate & limited Please review your probability (Resources part of the class website)