Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Math::Kleene.3
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "KLEENE 1"
.TH KLEENE 1 "2001-12-12" "perl v5.8.0" "User Contributed Perl Documentation"
.SH "NAME"
Kleene's Algorithm \- the theory behind it
.PP
brief introduction
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
.Sh "\fBSemi-Rings\fP"
.IX Subsection "Semi-Rings"
A Semi-Ring (S, +, ., 0, 1) is characterized by the following properties:
.IP "1)" 4
a) \f(CW\*(C`(S, +, 0) is a Semi\-Group with neutral element 0\*(C'\fR
.Sp
b) \f(CW\*(C`(S, ., 1) is a Semi\-Group with neutral element 1\*(C'\fR
.Sp
c) \f(CW\*(C`0 . a = a . 0 = 0 for all a in S\*(C'\fR
.IP "2)" 4
\&\f(CW"+"\fR is commutative and \fBidempotent\fR, i.e., \f(CW\*(C`a + a = a\*(C'\fR
.IP "3)" 4
Distributivity holds, i.e.,
.Sp
a) \f(CW\*(C`a . ( b + c ) = a . b + a . c for all a,b,c in S\*(C'\fR
.Sp
b) \f(CW\*(C`( a + b ) . c = a . c + b . c for all a,b,c in S\*(C'\fR
.IP "4)" 4
\&\f(CW\*(C`SUM_{i=0}^{+infinity} ( a[i] )\*(C'\fR
.Sp
exists, is well-defined and unique
.Sp
\&\f(CW\*(C`for all a[i] in S\*(C'\fR
.Sp
and associativity, commutativity and idempotency hold
.IP "5)" 4
Distributivity for infinite series also holds, i.e.,
.Sp
.Vb 2
\& ( SUM_{i=0}^{+infty} a[i] ) . ( SUM_{j=0}^{+infty} b[j] )
\& = SUM_{i=0}^{+infty} ( SUM_{j=0}^{+infty} ( a[i] . b[j] ) )
.Ve
.PP
\&\s-1EXAMPLES:\s0
.IP "\(bu" 4
\&\f(CW\*(C`S1 = ({0,1}, |, &, 0, 1)\*(C'\fR
.Sp
Boolean Algebra
.Sp
See also \fIMath::MatrixBool\fR\|(3)
.IP "\(bu" 4
\&\f(CW\*(C`S2 = (pos. reals with 0 and +infty, min, +, +infty, 0)\*(C'\fR
.Sp
Positive real numbers including zero and plus infinity
.Sp
See also \fIMath::MatrixReal\fR\|(3)
.IP "\(bu" 4
\&\f(CW\*(C`S3 = (Pot(Sigma*), union, concat, {}, {''})\*(C'\fR
.Sp
Formal languages over Sigma (= alphabet)
.Sp
See also \fIDFA::Kleene\fR\|(3)
.Sh "\fBOperator '*'\fP"
.IX Subsection "Operator '*'"
(reflexive and transitive closure)
.PP
Define an operator called \*(L"*\*(R" as follows:
.PP
.Vb 1
\& a in S ==> a* := SUM_{i=0}^{+infty} a^i
.Ve
.PP
where
.PP
.Vb 1
\& a^0 = 1, a^(i+1) = a . a^i
.Ve
.PP
Then, also
.PP
.Vb 1
\& a* = 1 + a . a*, 0* = 1* = 1
.Ve
.PP
hold.
.Sh "\fBKleene's Algorithm\fP"
.IX Subsection "Kleene's Algorithm"
In its general form, Kleene's algorithm goes as follows:
.PP
.Vb 14
\& for i := 1 to n do
\& for j := 1 to n do
\& begin
\& C^0[i,j] := m(v[i],v[j]);
\& if (i = j) then C^0[i,j] := C^0[i,j] + 1
\& end
\& for k := 1 to n do
\& for i := 1 to n do
\& for j := 1 to n do
\& C^k[i,j] := C^k-1[i,j] +
\& C^k-1[i,k] . ( C^k-1[k,k] )* . C^k-1[k,j]
\& for i := 1 to n do
\& for j := 1 to n do
\& c(v[i],v[j]) := C^n[i,j]
.Ve
.Sh "\fBKleene's Algorithm and Semi-Rings\fP"
.IX Subsection "Kleene's Algorithm and Semi-Rings"
Kleene's algorithm can be applied to any Semi-Ring having the properties
listed previously (above). (!)
.PP
\&\s-1EXAMPLES:\s0
.IP "\(bu" 4
\&\f(CW\*(C`S1 = ({0,1}, |, &, 0, 1)\*(C'\fR
.Sp
\&\f(CW\*(C`G(V,E)\*(C'\fR be a graph with set of vortices V and set of edges E:
.Sp
\&\f(CW\*(C`m(v[i],v[j]) := ( (v[i],v[j]) in E ) ? 1 : 0\*(C'\fR
.Sp
Kleene's algorithm then calculates
.Sp
\&\f(CW\*(C`c^{n}_{i,j} = ( path from v[i] to v[j] exists ) ? 1 : 0\*(C'\fR
.Sp
using
.Sp
\&\f(CW\*(C`C^k[i,j] = C^k\-1[i,j] | C^k\-1[i,k] & C^k\-1[k,j]\*(C'\fR
.Sp
(remember \f(CW\*(C` 0* = 1* = 1 \*(C'\fR)
.IP "\(bu" 4
\&\f(CW\*(C`S2 = (pos. reals with 0 and +infty, min, +, +infty, 0)\*(C'\fR
.Sp
\&\f(CW\*(C`G(V,E)\*(C'\fR be a graph with set of vortices V and set of edges E, with
costs \f(CW\*(C`m(v[i],v[j])\*(C'\fR associated with each edge \f(CW\*(C`(v[i],v[j])\*(C'\fR in E:
.Sp
\&\f(CW\*(C`m(v[i],v[j]) := costs of (v[i],v[j])\*(C'\fR
.Sp
\&\f(CW\*(C`for all (v[i],v[j]) in E\*(C'\fR
.Sp
Set \f(CW\*(C`m(v[i],v[j]) := +infinity\*(C'\fR if an edge (v[i],v[j]) is not in E.
.Sp
\&\f(CW\*(C` ==> a* = 0 for all a in S2\*(C'\fR
.Sp
\&\f(CW\*(C` ==> C^k[i,j] = min( C^k\-1[i,j] ,\*(C'\fR
.Sp
\&\f(CW\*(C` C^k\-1[i,k] + C^k\-1[k,j] )\*(C'\fR
.Sp
Kleene's algorithm then calculates the costs of the \*(L"shortest\*(R" path
from any \f(CW\*(C`v[i]\*(C'\fR to any other \f(CW\*(C`v[j]\*(C'\fR:
.Sp
\&\f(CW\*(C`C^n[i,j] = costs of "shortest" path from v[i] to v[j]\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`S3 = (Pot(Sigma*), union, concat, {}, {''})\*(C'\fR
.Sp
\&\f(CW\*(C`M in DFA(Sigma)\*(C'\fR be a Deterministic Finite Automaton with a set of
states \f(CW\*(C`Q\*(C'\fR, a subset \f(CW\*(C`F\*(C'\fR of \f(CW\*(C`Q\*(C'\fR of accepting states and a transition
function \f(CW\*(C`delta : Q x Sigma \-\-> Q\*(C'\fR.
.Sp
Define
.Sp
\&\f(CW\*(C`m(v[i],v[j]) :=\*(C'\fR
.Sp
\&\f(CW\*(C` { a in Sigma | delta( q[i] , a ) = q[j] }\*(C'\fR
.Sp
and
.Sp
\&\f(CW\*(C`C^0[i,j] := m(v[i],v[j]);\*(C'\fR
.Sp
\&\f(CW\*(C`if (i = j) then C^0[i,j] := C^0[i,j] union {''}\*(C'\fR
.Sp
(\f(CW\*(C`{''}\*(C'\fR is the set containing the empty string, whereas \f(CW\*(C`{}\*(C'\fR is the
empty set!)
.Sp
Then Kleene's algorithm calculates the language accepted by Deterministic
Finite Automaton M using
.Sp
\&\f(CW\*(C`C^k[i,j] = C^k\-1[i,j] union\*(C'\fR
.Sp
\&\f(CW\*(C` C^k\-1[i,k] concat ( C^k\-1[k,k] )* concat C^k\-1[k,j]\*(C'\fR
.Sp
and
.Sp
\&\f(CW\*(C`L(M) = UNION_{ q[j] in F } C^n[1,j]\*(C'\fR
.Sp
(state \f(CW\*(C`q[1]\*(C'\fR is assumed to be the \*(L"start\*(R" state)
.Sp
finally being the language recognized by Deterministic Finite Automaton M.
.PP
Note that instead of using Kleene's algorithm, you can also use the \*(L"*\*(R"
operator on the associated matrix:
.PP
Define \f(CW\*(C`A[i,j] := m(v[i],v[j])\*(C'\fR
.PP
\&\f(CW\*(C` ==> A*[i,j] = c(v[i],v[j])\*(C'\fR
.PP
Proof:
.PP
\&\f(CW\*(C`A* = SUM_{i=0}^{+infty} A^i\*(C'\fR
.PP
where \f(CW\*(C`A^0 = E_{n}\*(C'\fR
.PP
(matrix with one's in its main diagonal and zero's elsewhere)
.PP
and \f(CW\*(C`A^(i+1) = A . A^i\*(C'\fR
.PP
Induction over k yields:
.PP
\&\f(CW\*(C`A^k[i,j] = c_{k}(v[i],v[j])\*(C'\fR
.ie n .IP """k = 0:""" 10
.el .IP "\f(CWk = 0:\fR" 10
.IX Item "k = 0:"
\&\f(CW\*(C`c_{0}(v[i],v[j]) = d_{i,j}\*(C'\fR
.Sp
with \f(CW\*(C`d_{i,j} := (i = j) ? 1 : 0\*(C'\fR
.Sp
and \f(CW\*(C`A^0 = E_{n} = [d_{i,j}]\*(C'\fR
.ie n .IP """k\-1 \-> k:""" 10
.el .IP "\f(CWk\-1 \-> k:\fR" 10
.IX Item "k-1 -> k:"
\&\f(CW\*(C`c_{k}(v[i],v[j])\*(C'\fR
.Sp
\&\f(CW\*(C`= SUM_{l=1}^{n} m(v[i],v[l]) . c_{k\-1}(v[l],v[j])\*(C'\fR
.Sp
\&\f(CW\*(C`= SUM_{l=1}^{n} ( a[i,l] . a[l,j] )\*(C'\fR
.Sp
\&\f(CW\*(C`= [a^{k}_{i,j}] = A^1 . A^(k\-1) = A^k\*(C'\fR
.PP
qed
.PP
In other words, the complexity of calculating the closure and doing
matrix multiplications is of the same order \f(CW\*(C`O(\ n^3\ )\*(C'\fR in Semi\-Rings!
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIMath::MatrixBool\fR\|(3), \fIMath::MatrixReal\fR\|(3), \fIDFA::Kleene\fR\|(3).
.PP
(All contained in the distribution of the \*(L"Set::IntegerFast\*(R" module)
.PP
Dijkstra's algorithm for shortest paths.
.SH "AUTHOR"
.IX Header "AUTHOR"
This document is based on lecture notes and has been put into
\&\s-1POD\s0 format by Steffen Beyer <sb@engelschall.com>.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 1997 by Steffen Beyer. All rights reserved.