Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.

Similar presentations


Presentation on theme: "Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D."— Presentation transcript:

1 Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.

2 Von Neumann Architecture

3 Imperative Languages Based directly on the von Neumann architecture – Variables have memory locations – Program flow of control is: sequential condition-based repeatable (e.g. loops) based on functions based on objects

4 Imperative Languages Based directly on the von Neumann architecture – Efficiency is the primary concern – Management of variables and data structures is a constant concern – Causes program complexity and therefore bugs

5 Logic Programming – Prolog Based on formal logic – Prolog is a goal-driven logic programming language – Prolog is a declarative language No flow of control....? – Apply known rules to facts to infer answers to queries Think of Prolog as an inference engine

6 Propositions A proposition is a logical statement that may or may not be true male('George'). female('Mary'). smart('Mary'). tall('George'). smart('George').

7 Propositions A proposition describes objects and their relationships – e.g. Mary is a parent of George – e.g. George is a child of Mary parent('Mary', 'George'). child('George', 'Mary').

8 Propositions A proposition is stated in one of two ways: – Fact : proposition assumed to be true – Query : truth of proposition is to be determined Facts are often organized into a knowledge base – Knowledge bases are utilized to answer queries – New knowledge is inferred via an inference engine

9 Symbolic Logic We utilize Symbolic logic to: – Express propositions – Express relationships between propositions – Describe how new propositions can be inferred from other propositions Particular form of symbolic logic used for logic programming is called first-order predicate calculus – Forms the basis for logic programming languages

10 Logical Operators NameSymbolExampleMeaning negation  a not a conjunction  a  b a and b disjunction  a  b a or b equivalence  a  b a is equivalent to b implication  a  b a  b a implies b b implies a

11 Quantifiers  X.(woman(X)  human(X))  Y.(mother('Mary', Y)  male(Y))  Z.(smarter(Z, 'Dr.G')) NameExampleMeaning universal  X.P For all X, P is true existential  X.P There exists a value of X such that P is true e.g.

12 Simplifying the Predicate Calculus To simplify a Prolog implementation, standardize propositions using the following clausal form : B 1  B 2  …  B n  A 1  A 2  …  A m The A terms represent the antecedent The B terms represent the consequent If all A s are true, then at least one B is true All propositions can be expressed using this clausal form

13 Simplifying the Predicate Calculus Simplify further using a Horn clause – Headless Horn clause : has no consequent parent('Mary', 'George'). child('George', 'Mary'). state facts

14 Simplifying the Predicate Calculus Simplify further using a Horn clause – Headed Horn clause : has a single proposition as consequent mother(X, Y)  parent(X, Y)  female(X) mother(X, Y) :- parent(X, Y), female(X). state inference rules

15 Additional Prolog Syntax In Prolog, the, operator denotes conjunction ( AND ) The ; operator denotes disjunction ( OR ) mother(X,Y) :- parent(X,Y), female(X). sibling(X,Y) :- brother(X,Y); sister(X,Y).

16 Additional Prolog Syntax Operators in Prolog – Equality is denoted using == operator – Inequality is denoted using \= operator same(X,Y) :- X == Y. mother(X,Y) :- parent(X,Y), female(X), X \= Y.

17 Additional Prolog Syntax Parentheses can be used to group logic together X is a sibling of Y if – X is a brother of Y or X is a sister of Y and – X is not the same entity as Y sibling(X,Y) :- (brother(X,Y); sister(X,Y)), X \= Y.

18 Prolog Family Tree Example Given only male(), female(), and parent(), write Prolog inference rules for the following: – mother() – father() – grandparent() – uncle() – aunt() – brother() – sister() assume that parent(X,Y) is read “ X is a parent of Y ” – cousin() – descendant()

19 Using SWI-Prolog SWI-Prolog is a free Prolog environment: Interactive Prolog interface http://www.swi-prolog.org

20 Handling Multiple Subgoals Prolog implementations use depth-first search ( dfs ) approach to finding a goal consisting of multiple subgoals – Backtracking as necessary.... Another approach is to use a breadth-first search ( bfs ), but dfs is usually preferred – to consume fewer resources—i.e. memory female(X), parent(X, 'Bob').

21 Atoms and Variables Atoms consist of symbols – Start with a lowercase letter Variables also consist of symbols – Start with an uppercase letter – An anonymous variable is the underscore character ( _ ) Use single quotes to create an atom that starts with a capital letter b dave next_solution X Y List1 P2 'Dave' 'Apple' 'Next'

22 Numbers and Arithmetic Numbers in Prolog include integers and reals – Prolog is not typically used for numeric computation – Predefined operators: – Prolog supports arithmetic evaluation via the is operator = + - * / mod X is 1 + 2. X = 1 + 2. order matters! distance(X,Y) :- speed_mph(X,Speed), time_minutes(X,Time), Y is Speed * Time / 60.

23 Using Arithmetic Expressions speed_mph(ford,100). speed_mph(chevy,105). speed_mph(dodge,95). speed_mph(volvo,80). time_minutes(ford,20). time_minutes(chevy,21). time_minutes(dodge,24). time_minutes(volvo,24). distance(X,Y) :- speed_mph(X,Speed), time_minutes(X,Time), Y is Speed * Time / 60. distance(ford,D)D = 2000distance(volvo,D)D = 1920

24 List Processing in Prolog Prolog supports list structures by using square brackets and commas: Prolog also supports list dismantling : [apple, prune, orange, grape] [ Head_of_List | Rest_of_List ] “dismantles” a list


Download ppt "Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D."

Similar presentations


Ads by Google