Download PPT

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Axiom of reducibility wikipedia , lookup

Mathematical logic wikipedia , lookup

Argument wikipedia , lookup

Law of thought wikipedia , lookup

Inquiry wikipedia , lookup

Intuitionistic logic wikipedia , lookup

Laws of Form wikipedia , lookup

Interpretation (logic) wikipedia , lookup

Combinatory logic wikipedia , lookup

Type-2 fuzzy sets and systems wikipedia , lookup

History of the function concept wikipedia , lookup

Junction Grammar wikipedia , lookup

Unification (computer science) wikipedia , lookup

Principia Mathematica wikipedia , lookup

Fuzzy concept wikipedia , lookup

Fuzzy logic wikipedia , lookup

Transcript
Intelligent systems
Lecture 9
Main concepts of fuzzy logic and
linguistic variables, LISP
Fuzzy logic is based on fuzzy sets
B
A
0
1
1
In classical set theory
any element can to be
member of set or not.
Is(a, A) = 1 or 0, true or false
0
0.5
1
In fuzzy set theory
any element can to be
member of set with any uncertainty
or confidence
Is(a,A) = 0 or 1 or 0.5 or 0.126 or …
from interval (0,1)
This uncertainty is determined by
membership function 0≤μA(a)≤1
Main logical operations in fuzzy logic
• Conjunction - μA&B(x) = min(μA (x), μB (y))
• Disjunction - μA/\B(x) = max(μA (x), μB (y))
• Negation – μ¬A(x) = 1 - μA(x)
Linguistic variable
Definition of linguistic variable
When we consider a variable, in general,
it takes numbers as its value. If the variable takes linguistic
terms, it is called “linguistic variable”.
Definition(Linguistic variable) The linguistic variable is defined by
the following quintuple.
Linguistic variable = (x, T(x), U, G, M) x:
• x - name of variable
• T(x): set of linguistic terms which can be a value of the variable
• U: set of universe of discourse which defines the characteristics of the
Variable
• G: syntactic grammar which produces terms in T(x)
• M: semantic rules which map terms in T(x) to fuzzy sets in U
Example of linguistic variable
Example of linguistic variable
During inference it is needed to execute
two operations:
1.Fuzzification
Transformation from number to symbol
value of linguistic variable and
corresponding value of membership
function
2. Defuzzification
Transformation from symbol value to number
Features of fuzzy logic
• In fuzzy logic, exact reasoning is viewed as a
limiting case of approximate reasoning
• In fuzzy logic, everything is a matter of degree
• In fuzzy logic, knowledge is interpreted a
collection of elastic or, equivalently, fuzzy
constraint on a collection of variables
• Inference is viewed as a process of propagation
of elastic constraints
• Any logical system can be fuzzified
Features of language LISP
• Program – S-expression and consists of Sexpressions, e.g. (A (B C …) (S (G H …) K))
– The basic elements of s-expressions are lists and atoms.
– S-expression may be interpreted as list (data structure)
– Or function with arguments, e.g. (ADD (SUB 4 3) 6) return 7. Sexpression may be evaluated and return value.
• Some Info About Lisp Primitives
– Atoms: evaluate to themselves.
– Symbols: they are just names. They can evaluate to other
values, Function arguments.
– Lists: evaluate to a function call
Predicates
– Predicates are functions
– Predicates return T or NIL (generally)
– NIL is considered false
Main functions for processing of lists
• (CAR L) returns first element of list L
– (CAR ‘(a b c)) returns atom a
• (CDR L) returns tail of list L
– (CDR ‘(a b c)) returns list (b c)
• (CONS L1 L2) returns list including as first
element L1 and tail L2
– (CONS ‘a ‘(b c)) returns (a b c)
– (CONS ‘(a b) ‘(c d)) returns ((a b) c d)
• (LIST a1 a2 …) returns list from a1, a2 …
– (list ‘a 1 (+ 2 3)) returns (a 1 5)
Similar to case of:
Execution of sequence of operations:
> (prog1 (setq x 2) (setq x (* x 2)) (setq x (* x 2)) (setq x (* x 2)))
2
> (prog2 (setq x 2) (setq x (* x 2)) (setq x (* x 2)) (setq x (* x 2)))
4
> (progn (setq x 2) (setq x (* x 2)) (setq x (* x 2)) (setq x (* x 2)))
16
Example – calculation of sum from
0 to n
Description of function:
>(defun count (n)
(do ((result n))
;;initial value
((= n 0) result) ;;condition of finishing of loop
(setq n (- n 1))
(setq result (+ result n))
)
)
COUNT
Call:
>(count 5)
15
Example – recursive program of
copy of list
Description of function:
>(defun listcopy (list)
(cond ((null list) nil)
;;Condition of finishing of recursion
(t (cons (car list) (listcopy (cdr list)))))) ;;recursion
LISTCOPY
Call:
>(listcopy ‘(a b c))
(A B C)
Trace
>(trace listcopy)
(LISTCOPY)
>(listcopy '(a b))
Entering: LISTCOPY, Argument list: ((A B))
Entering: LISTCOPY, Argument list: ((B))
Entering: LISTCOPY, Argument list: (NIL)
Exiting: LISTCOPY, Value: NIL
Exiting: LISTCOPY, Value: (B)
Exiting: LISTCOPY, Value: (A B)
(A B)
(defun play() ;{{{
(init)
(setq hm-comment "\n")
(setq hmstr "No shots")
(ships)
(do ()
((or (= (car (aref ships 0)) 0)
(= (cadr (aref ships 0)) 0)))
(cls)
(show)
(princ "\n") (princ "Your shot: ")
(princ hmstr) (princ "\n")
(princ hm-comment)(princ "\n")
(if (not hit)
(if (hm-shot)
()
(progn
(setq hm-comment '"That's wrong!\n")
(setq kill t)
)
)
(progn (setq hit nil)
(princ "You are skipping this turn.")
(get-key)
)
)
(if (not hit)(al-shot)(setq hit nil))
)
(cls)
(show)
(if (= (car (aref ships 0)) 0)
(princ "You're winner!!!")
(princ "You're loser!!!")
)
t
);}}}