Download Formal methods

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
no text concepts found
Transcript
The road to ... PhD
• Aims:
– specify neural networks in an abstract mathematical way
– transform the specifications into executable programs
– prove the correctness of transformation
D. Dranidis - 14.06.00
1
Software Development process
• Requirements specification is
abstract:
Informal description
– Many models satify the
requirements specification
analysis
Requirements specification
• Each design decision restricts
the set of possible models
design decisions
Design specification
• ... until one reaches to the final
program which is a
representation of a unique
model.
design decisions
Program
D. Dranidis - 14.06.00
2
Formal methods
• Mathematical formalisms
– Aim: rigorously describe (software) systems
– consist of:
• Syntax
how do I write a description?
– grammatic rules for building an expression
• Semantics
what is the meaning of a description?
– mapping from expressions to a mathematical domain
– optionally:
• Methodology
procedures and processes of describing a system and deriving
an implementation
D. Dranidis - 14.06.00
3
Formalisms
•
•
•
•
•
•
Algebraic specifications
Stream processing functions
Traces semantics
CCS (calculus of communicating systems)
μCML (operational semantics of CML)
SL (stream language)
CML (concurrent ML)
D. Dranidis - 14.06.00
4
Algebraic specifications
• Formalism for the specification of
– data types (structures) and algorithms
• An algebraic specification consists of:
– syntactic interface:
• names of the types (sorts)
• names of the operations
– semantic properties:
• axioms
D. Dranidis - 14.06.00
5
Specifications
• Depending on the form of axioms one can create:
– an abstract specification: a predicative description where axioms
are logic formulas
– a concrete specification: constructive description where axioms
are restricted to conditional equations
• A concrete specification serves as a prototype of the
system (it is executable) or as the final product
(implemented in a functional language)
D. Dranidis - 14.06.00
6
Example
Term algebra = Initial model (all terms are unequal)
true
not(false)
false
not(true)
not(not(true))
not(...not(true)...)
true
not(false)
not(not(false))
not(...not(false)...)
not ( true ) = false ;
false = not(true)
not(not(true))
not(...not(true)...)
not(not(false))
not(...not(false)...)
not ( true ) = false ;
not ( not ( x ) ) = x;
true = not(false) = not(not(true)) = ...
false = not(true) = not(not(false)) = ...
true = false = not(true) = not(false) = ...
Final model (all terms are equal)
not ( true ) = false ;
-- not ( not ( x ) ) = x;
true = false;
D. Dranidis - 14.06.00
BOOL = {
-- sorts
sort Bool;
-- functions
true : Bool;
false : Bool;
not : Bool  Bool;
-- axioms
axioms
not ( true ) = false ;
not ( not ( x ) ) = x ;
endaxioms
}
7
Stream processing functions
f
x1 x2 x3 ... xr ...
• <y1 y2 y3 ... yt > = f < x1 x2 x3 ... xr >
•
•
•
•
y1 y2 y3 ... yt ...
f operates on the whole input stream and produces an output stream.
Streams can be considered as data histories (or traces)
Streams can be infinite
f can be considered as an agent receiving some inputs, processing and
sending some outputs
D. Dranidis - 14.06.00
8
Examples
• Finite streams
–
–
–
–
–
<>
is the empty stream
<0>
one element stream
1 & <2, 3> = <1,2,3>
<1,2,3> + <4,5,6> = <5,7,9>
succ <0,1,2> = <1,2,3>
(prefix operation)
(pairwise addition)
(successor function)
• Infinite streams (via recursion)
–
–
–
–
null = 0 & null
nat = 0 & ( succ nat)
squares = nat * nat
(nat1, nat2) = split nat
null = <0,0,0,...>
nat = <0,1,2,3,4,...>
squares = <0,1,4,9,16,...>
nat1 = <0,1,2,3,4,...>
nat2 = <0,2,1,3,4,...>
D. Dranidis - 14.06.00
9
CCS
• Language for the description of concurrent systems. Systems are
described as processes.
• Processes are built by actions and operators
• Actions are
– external: communication of a process with other processes
– internal: communications between the components of a process
• Communications occur on channels. There are two kinds of
communications:
– c!v
– c?x
write value v on channel c:
read value from channel c and assign to variable x:
• Handshake (synchronous) communication:
– a read or write action in a process must handshake with a complementary
action in another process (data transfer) for the processes to proceed.
D. Dranidis - 14.06.00
10
Process operators
• Prefix:
– P = a.Q
– eg.
first a then Q
P = c!0 . P
• Summation:
– P=Q+R
Q or P
– eg.
P = c?x.P + d?x.P
• Composition:
– P=Q|R
– eg.
Q parallel to R
R = c!0.R , Q = c?x.Q, P = Q | R
• Restriction:
– P = Q\c
– eg.
c is private in P
R = c!0.R , Q = c?x.Q, P = (Q | R)\c
• Recursion:
– P = fix (X = Q)
– eg.
P = fix(X = c!0 . X)
equiv. to P = c!0. P
D. Dranidis - 14.06.00
11
Examples
• The following stream
– nat = 0 & (succ nat) = μs. 0 & (succ s)
– val nat = recursion ( fn s => 0 & ( 1 +^ s) )
in the specification
in SL/CML
• is modelled (realised) by the following CCS process terms
–
–
–
–
TRANSFERi,ksucc = fix ( X = i?x . k!(succ x) . X )
PREFIXk,m0 = m!0 . fix ( X = k?x . m! x . X )
SPLITm,i,o = fix ( X = m?x . (i!x . o!x . X + o!x . i!x . X ) )
NATo = (TRANSFERi,ksucc | PREFIXk,m0 | SPLITm,i,o )\{k,m,i}
i
TRANSFERi,ksucc
k
PREFIXk,m0
D. Dranidis - 14.06.00
m
SPLITm,i,o
o
12
Specification
•
•
Networks are specified as stream
processing functions in an algebraic
specification.
Example
– unit (η, w0) (x, τ) = y
–
where (
–
y = wx
–

e = τ-y
–

w = w0 & w + Δw
–

Δw = η . e . x
–
);
•
The initial abstract specification is
transformed into a design specification:
– recursion is modeled via network
feedback and
– branched connecting lines are split
•
The semantics of the specification is
preserved (trivially).
– unit (η, w0) (x, τ) = y
–
where (
–
create yt
–

create wt
–

e = τ - yt
–
 x1, x2 = split x
–
 Δw = η . e . x1
–

w = w0 & wt + Δw
–
 w 1, w 2 = w
–

y = w 2  x2
–
 y1, y2 = split y
–

w1 wt
–

y1 yt
–
);
D. Dranidis - 14.06.00
13
Program
• The design specification is implemented as a function in
SL/CML/SML
–
–
–
–
–
–
–
–
–
–
–
–
–
–
–
fun unit (eta, w0_) (x_,
val (yt, tr2yt) =
val (wt_, tr2w_) =
val
e =
val
(x1_, x2_) =
val
Dw_ =
val
w_ =
val
(w1_, w2_) =
val
y =
val
(y1, y2) =
val
_ =
val
_ =
in
y2
end
tau) = let
createStream()
createStreamList (length x_)
tau ^-^ yt
split x_
eta *^ e ^*^ x1_
w0_ ~&~ wt_ ~+~ Dw_
splitList w_
x2_ ~**~ w2_
split y
connectList (w1_, tr2w_)
connect (y1, tr2yt)
D. Dranidis - 14.06.00
14
Correctness
syntactic transformation
stream processing function
SL/CML function
operational semantics
traces semantics
realisation
μCML process term
translation T
bisimulation
CCS process term
μCML
bisimulation process term
D. Dranidis - 14.06.00
15
Neural Networks
• Applications
– Pattern recognition
• Supervised Learning
• Reinforcement Learning
D. Dranidis - 14.06.00
16
Some Biology
• The brain








The brain is composed of nerve cells called neurons.
The number of neurons in the human brain is about 1011.
Each neuron is connected to approximately 104 neurons.
Neurons have (at least abstractly) a very simple operation.
Neurons are slow. (An operation cycle lasts some ms).
Neurons operate in parallel.
Although neurons “die” information retrieval is still possible.
Neural networks are fault-tolerant because information storage and
information processing is distributed.
D. Dranidis - 14.06.00
17
Neurons
•
A neuron consists of
–
–
–
–
•
the soma, the central part of the cell
the dendrites, junctions from other neurons
and the axon, its junction to other neurons
The axon branches and connects to other neuron’s dendrites via the synapses.
Operation
– Neurons transmit information in the form of pulses.
– This information is received at the synapses.
– Synapses produce some chemical substances that increase or decrease (depending
on the type of synapse) the electrical potential of the cell.
– The cell generates a pulse (fires) if its potential reaches a threshold value.
– The pulse is transmitted on its axon.
•
Adaptive behavior
– Neurons “store” information in their synapses.
– Synapses are plastic. Their effect changes over time. They adapt.
D. Dranidis - 14.06.00
18
Artificial Neural Networks
•
•
•
An artificial neural network is a network of simple computation elements,
called units, which operate in parallel and communicate by transmitting their
output to other units via connections.
Units compute simple functions on their inputs.
A weight is associated to each input line. The weight indicates the
significance of the connection for the computation of the unit.
Graphical representation of a unit
x1
x2
w1
w2
Σ
y
f
wn
xn
y = f (Σ wi * xi )
i
D. Dranidis - 14.06.00
19
Pattern Recognition
• Character recognition
A
it is an ‘A’ character
NN
• Sound recognition
NN
it is an ‘A’ phoneme
D. Dranidis - 14.06.00
20
Representation
• Information (data) is represented and processed numerically
49 inputs
A
0
0
0
0
0
0
1
0
0
0
1
1
1
1
0
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
0
0
0
0
0
1
1
1
1
0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1
0
0
0
0
0
0
1
it is an ‘A’ character
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
26 outputs
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
49+14+26=89 units
49*14+14*26=686+364 = 1050 connections
D. Dranidis - 14.06.00
21
Supervised Learning
• Network is initialised with random connection weights
• Repeat
–
–
–
–
present a character at the input
let network classify input
compare network output to correct class
update connection weights to minimize the error
• until all characters are correctly classified
• Learning algorithm updates weights.
• Information is stored in weights
• Information is distributed (in 1050 numerical weights)
D. Dranidis - 14.06.00
22
Reinforcement Learning
• Learning to act in an unknown environment in order to get the
maximum reward.
• Reinforcement problem:
–
–
–
–
State space S, actions A, initial state s0, final state sF
transition : S x A -> S
reward : S -> N
s0
s1
a2
a1
policy : S -> A
• Goal
r1
– find policy which maximizes the total reward: Σ ri
s2
r2
s3
a3
r3
• Example
– Games: reward = 0 in all states except the winning state where reward = 1
– Route finding: reward = -1 in all states except the last where reward = 0
D. Dranidis - 14.06.00
23
Reinforcement learning methods
• Value : S -> N
– Value of a state is the sum of rewards if one follows the optimal policy till
the goal state.
– If the value of each state is known then the optimal policy is the greedy
policy: each time take the action which leads to the maximum value state.
• Value Iteration:
– begin with a random value function (ie. a random policy)
– after each action update the value function according to:
• V(st , t+1) = V(st , t) + α ( rt + γ V(st+1 , t) - V(st , t) )
– value iteration converges to the optimal policy
• If the state space is large then the value function cannot be represented
explicitly (via a table); instead it has to be approximated
• Neural networks are used to approximate the value function
D. Dranidis - 14.06.00
24