Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prob-teaching-notebooks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
prob-teaching-notebooks
Commits
0cf1097d
Commit
0cf1097d
authored
5 years ago
by
Michael Leuschel
Browse files
Options
Downloads
Patches
Plain Diff
add descriptions and convert to Unicode
parent
588b9e29
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
info4/kapitel-3/CYK_Algorithmus.ipynb
+88
-42
88 additions, 42 deletions
info4/kapitel-3/CYK_Algorithmus.ipynb
with
88 additions
and
42 deletions
info4/kapitel-3/CYK_Algorithmus.ipynb
+
88
−
42
View file @
0cf1097d
...
...
@@ -9,52 +9,60 @@
},
{
"cell_type": "code",
"execution_count":
1
4,
"execution_count":
7
4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Loaded machine:
GrammarChomskyNormalForm_
CYK"
"Loaded machine: CYK"
]
},
"execution_count":
1
4,
"execution_count":
7
4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"::load\n",
"MACHINE
GrammarChomskyNormalForm_
CYK\n",
"MACHINE CYK\n",
"/* An encoding of the CYK Algorithm in B */\n",
"SETS\n",
" Σ = {a,b, S,A,B,C}\n",
" Σ
N
= {a,b, S,A,B,C}\n",
"DEFINITIONS\n",
" ANIMATION_FUNCTION_DEFAULT == {r,c,i| r=-1 ∧ c↦i ∈
target
};\n",
" ANIMATION_FUNCTION_DEFAULT == {r,c,i| r=-1 ∧ c↦i ∈
x
};\n",
" ANIMATION_FUNCTION == {r,c,i | c↦r ∈ dom(T) ∧ i=(T(c,r))}\n",
"CONSTANTS
Terminals, NonTerminals, Productions, target
, n\n",
"CONSTANTS
Σ, N, P, x
, n\n",
"PROPERTIES\n",
"
Terminals = {a,b} ∧
\n",
"
Terminals ∩ NonTerminals
= ∅ ∧\n",
"
Terminals ∪ NonTerminals
= Σ ∧\n",
" /*
the following is the CFG from Example 6.7 illustrating CYK in
Hopcroft/Ullman */\n",
" P
roductions = {
\n",
"
Σ = {a,b} ∧ // Terminalsymbole
\n",
"
Σ ∩ N
= ∅ ∧\n",
"
Σ ∪ N
= Σ
N
∧\n",
" /*
eine kfG in Chomsky Normalform, Example 6.7 aus
Hopcroft/Ullman */\n",
" P
= { // die Regeln
\n",
" [S] ↦ [A,B], [S] ↦ [B,C],\n",
" [A] ↦ [B,A], [A] ↦ [a],\n",
" [B] ↦ [C,C], [B] ↦ [b],\n",
" [C] ↦ [A,B], [C] ↦ [a]\n",
" } ∧\n",
"target ∈ seq(Σ) ∧ n = size(target) ∧ target = [b,a,a,b,a]\n",
"x ∈ seq(ΣN) ∧ n = size(x) ∧ \n",
"x = [b,a,a,b,a]\n",
"VARIABLES T, i,j\n",
"INVARIANT T ∈ ((1..n)*(0..n)) ⇸ ℙ(N
onTerminals
) ∧ j∈1..n ∧ i∈1..n-1\n",
"INVARIANT T ∈ ((1..n)*(0..n)) ⇸ ℙ(N) ∧ j∈1..n ∧ i∈1..n-1\n",
"INITIALISATION \n",
" T := λ(i,j).(i∈1..n ∧ j=0 | {A| A∈NonTerminals ∧ [A] ↦ [target(i)] ∈ Productions}) ||\n",
" j := 1 || i := 1\n",
" T := λ(i,j).(i∈1..n ∧ j=0 | {A| A∈N ∧ [A] ↦ [x(i)] ∈ P}) \n",
" // for(i =1,2,...,n){T(i,0)={A∈N | A→x(i) ist Regel in P}; }\n",
" ||\n",
" j := 1 \n",
" || \n",
" i := 1\n",
"OPERATIONS\n",
" For_k_loop(ii,jj,Tij) = PRE j<n ∧ ii=i ∧ jj=j ∧\n",
" Tij = { A | A∈NonTerminals ∧\n",
" ∃(B,C,k).( [A] ↦ [B,C] ∈ Productions ∧ k∈0..j-1 ∧\n",
" B∈T(i,k) ∧ C∈T(i+k+1,j-k-1)) } THEN\n",
" For_k_loop(ii,jj,Tij) = // führt eine Iteration der for(k=0,1,...j-1) Schleife aus\n",
" PRE j<n ∧ ii=i ∧ jj=j ∧\n",
" Tij = { A | A∈N ∧\n",
" ∃(B,C,k).( [A] ↦ [B,C] ∈ P ∧ \n",
" k∈0..j-1 ∧\n",
" B∈T(i,k) ∧\n",
" C∈T(i+k+1,j-k-1)) } THEN\n",
" T(i,j) := Tij ||\n",
" IF i<n-j THEN\n",
" i := i+1\n",
...
...
@@ -71,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count":
1
5,
"execution_count":
7
5,
"metadata": {},
"outputs": [
{
...
...
@@ -80,7 +88,7 @@
"Machine constants set up using operation 0: $setup_constants()"
]
},
"execution_count":
1
5,
"execution_count":
7
5,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -91,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count":
1
6,
"execution_count":
7
6,
"metadata": {},
"outputs": [
{
...
...
@@ -100,7 +108,7 @@
"Machine initialised using operation 1: $initialise_machine()"
]
},
"execution_count":
1
6,
"execution_count":
7
6,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -109,9 +117,47 @@
":init"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Wir lassen den Algorithmus für folgendes Wort $x$ laufen (und wollen prüfen ob die Grammatik das Wort generieren kann):"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$\\{(1\\mapsto \\mathit{b}),(2\\mapsto \\mathit{a}),(3\\mapsto \\mathit{a}),(4\\mapsto \\mathit{b}),(5\\mapsto \\mathit{a})\\}$"
],
"text/plain": [
"{(1↦b),(2↦a),(3↦a),(4↦b),(5↦a)}"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Am Anfang werden die Werte für T(i,0) in der INITIALISATION der Maschine berechnet:\n",
"* for(i =1,2,...,n){T(i,0)={A∈N | A→x(i) ist Regel in P};"
]
},
{
"cell_type": "code",
"execution_count":
1
7,
"execution_count": 7
8
,
"metadata": {},
"outputs": [
{
...
...
@@ -138,7 +184,7 @@
"<Animation function visualisation>"
]
},
"execution_count":
1
7,
"execution_count": 7
8
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -149,71 +195,71 @@
},
{
"cell_type": "code",
"execution_count":
18
,
"execution_count":
79
,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$\\{
(1\\mapsto 0\\mapsto\\{\\mathit{B}\\}),(2\\mapsto 0\\mapsto\\{\\mathit{A},\\mathit{C}\\}),(3\\mapsto 0\\mapsto\\{\\mathit{A},\\mathit{C}\\}),(4\\mapsto 0\\mapsto\\{\\mathit{B}\\}),(5\\mapsto 0\\mapsto\\{\\mathit{A
},\\mathit{C}\\}
)\\}
$"
"$\\{
\\mathit{S},\\mathit{A},\\mathit{B
},\\mathit{C}\\}$"
],
"text/plain": [
"{
(1↦0↦{B}),(2↦0↦{A,C}),(3↦0↦{A,C}),(4↦0↦{B}),(5↦0↦{A,C})
}"
"{
S,A,B,C
}"
]
},
"execution_count":
18
,
"execution_count":
79
,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"
T
"
"
N
"
]
},
{
"cell_type": "code",
"execution_count":
1
9,
"execution_count":
5
9,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$
1
$"
"$
\\{(\\{(1\\mapsto \\mathit{S})\\}\\mapsto\\{(1\\mapsto \\mathit{A}),(2\\mapsto \\mathit{B})\\}),(\\{(1\\mapsto \\mathit{S})\\}\\mapsto\\{(1\\mapsto \\mathit{B}),(2\\mapsto \\mathit{C})\\}),(\\{(1\\mapsto \\mathit{A})\\}\\mapsto\\{(1\\mapsto \\mathit{a})\\}),(\\{(1\\mapsto \\mathit{A})\\}\\mapsto\\{(1\\mapsto \\mathit{B}),(2\\mapsto \\mathit{A})\\}),(\\{(1\\mapsto \\mathit{B})\\}\\mapsto\\{(1\\mapsto \\mathit{b})\\}),(\\{(1\\mapsto \\mathit{B})\\}\\mapsto\\{(1\\mapsto \\mathit{C}),(2\\mapsto \\mathit{C})\\}),(\\{(1\\mapsto \\mathit{C})\\}\\mapsto\\{(1\\mapsto \\mathit{a})\\}),(\\{(1\\mapsto \\mathit{C})\\}\\mapsto\\{(1\\mapsto \\mathit{A}),(2\\mapsto \\mathit{B})\\})\\}
$"
],
"text/plain": [
"
1
"
"
{({(1↦S)}↦{(1↦A),(2↦B)}),({(1↦S)}↦{(1↦B),(2↦C)}),({(1↦A)}↦{(1↦a)}),({(1↦A)}↦{(1↦B),(2↦A)}),({(1↦B)}↦{(1↦b)}),({(1↦B)}↦{(1↦C),(2↦C)}),({(1↦C)}↦{(1↦a)}),({(1↦C)}↦{(1↦A),(2↦B)})}
"
]
},
"execution_count":
1
9,
"execution_count":
5
9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"
i
"
"
P
"
]
},
{
"cell_type": "code",
"execution_count":
20
,
"execution_count":
56
,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$
1
$"
"$
(1\\mapsto 1)
$"
],
"text/plain": [
"
1
"
"
(1↦1)
"
]
},
"execution_count":
20
,
"execution_count":
56
,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"
j
"
"
(i,j)
"
]
},
{
...
...
%% Cell type:markdown id: tags:
# CYK Algorithmus
%% Cell type:code id: tags:
```
prob
::load
MACHINE
GrammarChomskyNormalForm_
CYK
MACHINE CYK
/* An encoding of the CYK Algorithm in B */
SETS
Σ = {a,b, S,A,B,C}
Σ
N
= {a,b, S,A,B,C}
DEFINITIONS
ANIMATION_FUNCTION_DEFAULT == {r,c,i| r=-1 ∧ c↦i ∈
target
};
ANIMATION_FUNCTION_DEFAULT == {r,c,i| r=-1 ∧ c↦i ∈
x
};
ANIMATION_FUNCTION == {r,c,i | c↦r ∈ dom(T) ∧ i=(T(c,r))}
CONSTANTS
Terminals, NonTerminals, Productions, target
, n
CONSTANTS
Σ, N, P, x
, n
PROPERTIES
Terminals = {a,b} ∧
Terminals ∩ NonTerminals
= ∅ ∧
Terminals ∪ NonTerminals
= Σ ∧
/*
the following is the CFG from Example 6.7 illustrating CYK in
Hopcroft/Ullman */
P
roductions = {
Σ = {a,b} ∧ // Terminalsymbole
Σ ∩ N
= ∅ ∧
Σ ∪ N
= Σ
N
∧
/*
eine kfG in Chomsky Normalform, Example 6.7 aus
Hopcroft/Ullman */
P
= { // die Regeln
[S] ↦ [A,B], [S] ↦ [B,C],
[A] ↦ [B,A], [A] ↦ [a],
[B] ↦ [C,C], [B] ↦ [b],
[C] ↦ [A,B], [C] ↦ [a]
} ∧
target ∈ seq(Σ) ∧ n = size(target) ∧ target = [b,a,a,b,a]
} ∧
x ∈ seq(ΣN) ∧ n = size(x) ∧
x = [b,a,a,b,a]
VARIABLES T, i,j
INVARIANT T ∈ ((1..n)*(0..n)) ⇸ ℙ(N
onTerminals
) ∧ j∈1..n ∧ i∈1..n-1
INVARIANT T ∈ ((1..n)*(0..n)) ⇸ ℙ(N) ∧ j∈1..n ∧ i∈1..n-1
INITIALISATION
T := λ(i,j).(i∈1..n ∧ j=0 | {A| A∈NonTerminals ∧ [A] ↦ [target(i)] ∈ Productions}) ||
j := 1 || i := 1
T := λ(i,j).(i∈1..n ∧ j=0 | {A| A∈N ∧ [A] ↦ [x(i)] ∈ P})
// for(i =1,2,...,n){T(i,0)={A∈N | A→x(i) ist Regel in P}; }
||
j := 1
||
i := 1
OPERATIONS
For_k_loop(ii,jj,Tij) = PRE j<n ∧ ii=i ∧ jj=j ∧
Tij = { A | A∈NonTerminals ∧
∃(B,C,k).( [A] ↦ [B,C] ∈ Productions ∧ k∈0..j-1 ∧
B∈T(i,k) ∧ C∈T(i+k+1,j-k-1)) } THEN
For_k_loop(ii,jj,Tij) = // führt eine Iteration der for(k=0,1,...j-1) Schleife aus
PRE j<n ∧ ii=i ∧ jj=j ∧
Tij = { A | A∈N ∧
∃(B,C,k).( [A] ↦ [B,C] ∈ P ∧
k∈0..j-1 ∧
B∈T(i,k) ∧
C∈T(i+k+1,j-k-1)) } THEN
T(i,j) := Tij ||
IF i<n-j THEN
i := i+1
ELSE
i := 1 || j := j+1
END
END;
r <-- Accept = PRE j=n THEN r := bool(S∈ T(1,n-1)) END
END
```
%% Output
Loaded machine:
GrammarChomskyNormalForm_
CYK
Loaded machine: CYK
%% Cell type:code id: tags:
```
prob
:constants
```
%% Output
Machine constants set up using operation 0: $setup_constants()
%% Cell type:code id: tags:
```
prob
:init
```
%% Output
Machine initialised using operation 1: $initialise_machine()
%% Cell type:markdown id: tags:
Wir lassen den Algorithmus für folgendes Wort $x$ laufen (und wollen prüfen ob die Grammatik das Wort generieren kann):
%% Cell type:code id: tags:
```
prob
x
```
%% Output
$\{(1\mapsto \mathit{b}),(2\mapsto \mathit{a}),(3\mapsto \mathit{a}),(4\mapsto \mathit{b}),(5\mapsto \mathit{a})\}$
{(1↦b),(2↦a),(3↦a),(4↦b),(5↦a)}
%% Cell type:markdown id: tags:
Am Anfang werden die Werte für T(i,0) in der INITIALISATION der Maschine berechnet:
*
for(i =1,2,...,n){T(i,0)={A∈N | A→x(i) ist Regel in P};
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
T
N
```
%% Output
$\{
(1\mapsto 0\mapsto\{\mathit{B}\}),(2\mapsto 0\mapsto\{\mathit{A},\mathit{C}\}),(3\mapsto 0\mapsto\{\mathit{A},\mathit{C}\}),(4\mapsto 0\mapsto\{\mathit{B}\}),(5\mapsto 0\mapsto\{\mathit{A
},\mathit{C}\}
)\}
$
{
(1↦0↦{B}),(2↦0↦{A,C}),(3↦0↦{A,C}),(4↦0↦{B}),(5↦0↦{A
,C}
)}
$\{
\mathit{S},\mathit{A},\mathit{B
},\mathit{C}\}$
{
S,A,B
,C}
%% Cell type:code id: tags:
```
prob
i
P
```
%% Output
$
1
$
1
$
\{(\{(1\mapsto \mathit{S})\}\mapsto\{(1\mapsto \mathit{A}),(2\mapsto \mathit{B})\}),(\{(1\mapsto \mathit{S})\}\mapsto\{(1\mapsto \mathit{B}),(2\mapsto \mathit{C})\}),(\{(1\mapsto \mathit{A})\}\mapsto\{(1\mapsto \mathit{a})\}),(\{(1\mapsto \mathit{A})\}\mapsto\{(1\mapsto \mathit{B}),(2\mapsto \mathit{A})\}),(\{(1\mapsto \mathit{B})\}\mapsto\{(1\mapsto \mathit{b})\}),(\{(1\mapsto \mathit{B})\}\mapsto\{(1\mapsto \mathit{C}),(2\mapsto \mathit{C})\}),(\{(1\mapsto \mathit{C})\}\mapsto\{(1\mapsto \mathit{a})\}),(\{(1\mapsto \mathit{C})\}\mapsto\{(1\mapsto \mathit{A}),(2\mapsto \mathit{B})\})\}
$
{({(1↦S)}↦{(1↦A),(2↦B)}),({(1↦S)}↦{(1↦B),(2↦C)}),({(1↦A)}↦{(1↦a)}),({(1↦A)}↦{(1↦B),(2↦A)}),({(1↦B)}↦{(1↦b)}),({(1↦B)}↦{(1↦C),(2↦C)}),({(1↦C)}↦{(1↦a)}),({(1↦C)}↦{(1↦A),(2↦B)})}
%% Cell type:code id: tags:
```
prob
j
(i,j)
```
%% Output
$
1
$
1
$
(1\mapsto 1)
$
(1↦1)
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(1,1,{S,A})
%% Cell type:code id: tags:
```
prob
(i,j)
```
%% Output
$(2\mapsto 1)$
(2↦1)
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(2,1,{B})
%% Cell type:code id: tags:
```
prob
(i,j)
```
%% Output
$(3\mapsto 1)$
(3↦1)
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
T
```
%% Output
$\{(1\mapsto 0\mapsto\{\mathit{B}\}),(1\mapsto 1\mapsto\{\mathit{S},\mathit{A}\}),(2\mapsto 0\mapsto\{\mathit{A},\mathit{C}\}),(2\mapsto 1\mapsto\{\mathit{B}\}),(3\mapsto 0\mapsto\{\mathit{A},\mathit{C}\}),(4\mapsto 0\mapsto\{\mathit{B}\}),(5\mapsto 0\mapsto\{\mathit{A},\mathit{C}\})\}$
{(1↦0↦{B}),(1↦1↦{S,A}),(2↦0↦{A,C}),(2↦1↦{B}),(3↦0↦{A,C}),(4↦0↦{B}),(5↦0↦{A,C})}
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(3,1,{S,C})
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(4,1,{S,A})
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(1,2,{})
%% Cell type:code id: tags:
```
prob
(i,j)
```
%% Output
$(2\mapsto 2)$
(2↦2)
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(2,2,{B})
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(3,2,{B})
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{B}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(1,3,{})
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{B}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(2,3,{S,A,C})
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{B}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{S,A,C}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
:exec For_k_loop
```
%% Output
Executed operation: For_k_loop(1,4,{S,A,C})
%% Cell type:code id: tags:
```
prob
:show
```
%% Output
<table style="font-family:monospace"><tbody>
<tr>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
<td style="padding:10px">a</td>
<td style="padding:10px">b</td>
<td style="padding:10px">a</td>
</tr>
<tr>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{A,C}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{A,C}</td>
</tr>
<tr>
<td style="padding:10px">{S,A}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{S,C}</td>
<td style="padding:10px">{S,A}</td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{B}</td>
<td style="padding:10px">{B}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{}</td>
<td style="padding:10px">{S,A,C}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
<tr>
<td style="padding:10px">{S,A,C}</td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
<td style="padding:0px"></td>
</tr>
</tbody></table>
<Animation function visualisation>
%% Cell type:code id: tags:
```
prob
S : T(1,n-1)
```
%% Output
$\mathit{TRUE}$
TRUE
%% Cell type:code id: tags:
```
prob
:exec Accept
```
%% Output
Executed operation: TRUE <-- Accept()
%% Cell type:code id: tags:
```
prob
(i,j,n)
```
%% Output
$(1\mapsto 5\mapsto 5)$
(1↦5↦5)
%% Cell type:code id: tags:
```
prob
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment