Artificial Intelligence CS370D

Slides:



Advertisements
Similar presentations
Department of Computer Science. Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations.
Advertisements

Notes for CS3310 Artificial Intelligence Part 5: Prolog arithmetic and lists Prof. Neil C. Rowe Naval Postgraduate School Version of July 2009.
7.1Variable Notation.
Solving Linear Inequalities
Simplifying a Variable Expression
1.1 Lesson – Evaluating Algebraic Expressions
Presents Section 1.3 Inequalities and Absolute Value MB1 Track This section is prepared by M. Zalzali.
Lesson Objective: I can…
Solving and Graphing Inequalities on a Number Line
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
Sets and Expressions Number Sets
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Objective- To recognize symbols, variables, and types of sentences used in algebra. Equalities Inequalities = Equals- is the same as Congruent- same size.
Chapter 4 Inequalities 4.1 Inequalities and Their Graphs.
Solving Inequalities Solving Inequalities Objective: SWBAT solve and graph compound inequalities.
Declarative Programming Arithmetic in PROLOG Autumn 2014.
Lesson - 7. Operators There are three types of operators: Arithmetic Operators Relational and Equality Operators Logical Operators.
Ch 1.4 – Equations & Inequalities
BATCH: BRANCH:- CSE 2 ND SEM. SUBMITTED BY:- GINNI.
Holt Algebra Graphing and Writing Inequalities Warm Up Compare. Write, or =. 1. − < > > = Tell whether the inequality x
Day Problems For each solution write and graph an inequality.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Lesson 1.4 Equations and Inequalities Goal: To learn how to solve equations and check solutions of equations and inequalities.
3.4 Solving Equations with Variables on Both Sides Objective: Solve equations that have variables on both sides.
Operators.
Intro to Inequalities Unit 4 Section 4.1. Definition A statement that a mathematical expression is greater than or less than another expression.
1 Artificial Intelligence CS370D Prolog programming List operations.
Expressing inequalities using interval notation Click here to begin the lesson Click here to begin the lesson.
TestScore < 80 testScore * 2 >= < w / (h * h) x + y != 2 * (a + b) 2 * Math.PI * radius
1 Artificial Intelligence CS370D Prolog programming Declarative meaning of Prolog programs and Lists representation.
VARIABLES AND EXPRESSIONS VARIABLES are symbols used to represent unspecified numbers or values. EXAMPLES 3m 5x + 2 3ab + 7c An ALGEBRAIC EXPRESSION consists.
Review of Equations and Inequalities An equation is a mathematical statement that two qualities are equal. Linear Equation in one variable can be written.
Lesson 22 Review of Numerical & Algebraic Expressions-Statements & Sentences-Conditional Equations Numerical expressions consist of a meaningful arrrangement.
Inequality Notation.
Operators & Expressions
Operators And Expressions
Exponents and Order of Operations
INSPIRING CREATIVE AND INNOVATIVE MINDS
Sequence, Selection, Iteration The IF Statement
Data Types, Identifiers, and Expressions
Equations with Variables on Both Sides
The Selection Structure
Bell Work 9/15/17 Solve the Inequalities for x and give two possible solutions. (what are some numbers that would work for x?) 1. 2
Introduction to Algebra
Tests, Backtracking, and Recursion
Artificial Intelligence CS370D
Equalities Inequalities < Is less than = Equals- is the same as
Data Types, Identifiers, and Expressions
Artificial Intelligence CS370D
Winter 2018 CISC101 11/22/2018 CISC101 Reminders
Relational Operators Operator Meaning < Less than > Greater than
Expressions, Equations, and Inequalities
Equations and Inequalities
3-1 Inequalities and Their Graphs
3-1 Inequalities and their Graphs
Chapter 3: Prolog (Lists, Arithmetic, Operators)
Expressions.
Essential Question: How do you use inequalities and interval notation to describe the domain and range of a graph?
Relational Operators.
Objectives: Graph (and write) inequalities on a number line.
SIMPLE INEQUALITIES.
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
15.2 Mathematical Functions
Symbols, Variables, and Types of Sentences used in Algebra.
3-1 Inequalities and Their Graphs
Solution Sets for Equations and Inequalities
Evaluating Functions and Operations on Functions
Boolean Expressions September 1, 2019 ICS102: The course.
Algebra 1 Glencoe McGraw-Hill JoAnn Evans
Evaluating an expression with one variable
Presentation transcript:

Artificial Intelligence CS370D Prolog programming Arithmetic in Prolog.

Outline: Arithmetic in Prolog. Arithmetic Operators and Functions. Arithmetic Operator Examples. Arithmetic Function Examples. Operator Precedence in Arithmetic Expressions. Relational Operators. Relational Operator Examples. Equality Operators. Arithmetic Expression Equality. Arithmetic Expression Inequality. Terms Identical.

Arithmetic in Prolog: Prolog provides facilities for doing arithmetic using a notation similar to that which will already be familiar to many users from basic algebra. This is achieved using the built-in predicate is Any variables appearing in an arithmetic expression must already be bound (as a result of evaluating a previous goal) and their values must be numerical. Examples: ?- X is 10.5+4.7*2.X = 19.9. ?- Y is 10,Z is Y+1.Y = 10,Z = 11.

Arithmetic Operators and Functions: The table below shows some of the arithmetic operators(+,-,* .etc) and arithmetic functions(abs,sin..etc) available in Prolog.

Arithmetic Operator Examples: ?- X is 10/4. X = 2.5. ?- X is 10//4. X= 2. ?- X is 10,Y is -X-2. X = 10,Y= -12. ?- X is 30,Y is 5,Z is X+Y+X*Y. X = 30,Y = 5,Z = 185.

Arithmetic Operator Examples: (cont) ?- X is 7,X is 6+1.X=7. ?- 10 is 7+13-11+9. false. ?- 18 is 7+13-11+9. true. ?- X is 10,X is X+1. false. ?- X = 1 + 2. X = 1+2. ?- 1+2 = 2+1.false. ?- 1+A = B+2.A = 2,B = 1.

Arithmetic Function Examples: ?- X is sqrt(36). X=6.0. ?- Y is max(4,5) . Y=5. ?- 9 is max(9,11). false.

Operator Precedence in Arithmetic Expressions: Operators with relatively high precedence such as * and / are applied before those with lower precedence such as + and -. Operators with the same precedence (e.g. + and -, * and /) are applied from left to right. Bracketed expressions () are always evaluated first.

Relational Operators: The operators =:=,=\=,<,=<,>,>= are a special type known as relational operators. They are used to compare the value of two arithmetic expressions. The goal succeeds if the value of the first expression is equal to, not equal to, greater than, greater than or equal to, less than or less than or equal to the value of the second expression, respectively.

Relational Operator Examples: ?- 90=<9. false. ?- 88+15-3>110-5*2.

Equality Operators: There are three types of relational operator for testing equality and inequality available in Prolog: Arithmetic Expression Equality =:= Arithmetic Expression Inequality =\= Terms Identical ==

Arithmetic Expression Equality: E1=:=E2 succeeds if the arithmetic expressions E1 and E2 evaluate to the same value. Examples: ?- 6+4=:=6*3-8. true. ?- sqrt(36)+4=:=5*11-4.false. ?- 1+2 =:= 2+1.true. ?- 2+2 =:= 1+3. true.

Arithmetic Expression Inequality: E1=\=E2 succeeds if the arithmetic expressions E1 and E2 don’t evaluate to the same value. Example: ?- 10=\=8+3. true. ?- 3+4=\=3+4. false.

Terms Identical: The goal Term1==Term2 succeeds if and only if Term1 is identical to Term2. Examples: ?- likes(X,prolog)==likes(X,prolog). true. ?- likes(X,prolog)==likes(Y,prolog).false. (X and Y are different variables) ?- X is 10,pred1(X)==pred1(10). X=10. ?- X==0.false. ?- 6+4==3+7.false.