From 3f82e236d603445e8ec2dd22bb3ccb18416ceeb7 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Sat, 10 Feb 2024 18:41:16 -0400 Subject: [PATCH] Add A3 --- Assignment 3.ipynb | 539 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 525 insertions(+), 14 deletions(-) diff --git a/Assignment 3.ipynb b/Assignment 3.ipynb index ac56172..6118951 100644 --- a/Assignment 3.ipynb +++ b/Assignment 3.ipynb @@ -1,30 +1,541 @@ { "cells": [ { - "cell_type": "code", - "execution_count": null, - "id": "initial_id", + "cell_type": "markdown", + "source": [ + "# Question 15\n", + "\n", + "Draw a DFA that accepts the language:\n", + "\n", + "$$L = \\{ w \\in \\{0,1\\}^* | n_0(w) \\text{ and } n_1(w) \\text { are both odd } \\}$$" + ], "metadata": { - "collapsed": true + "collapsed": false }, - "outputs": [], + "id": "47055e509be0224e" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\n66ce28c0-3b81-4457-a1f2-6585ac09c24e\n\n\n\n\n\n\n\nA\n\nA\n\n\n\n66ce28c0-3b81-4457-a1f2-6585ac09c24e->A\n\n\n\n\n\n\n\n\nB\n\nB\n\n\n\nA->B\n\n\n1\n\n\n\nC\n\nC\n\n\n\nA->C\n\n\n0\n\n\n\nB->A\n\n\n1\n\n\n\nD\n\n\nD\n\n\n\nB->D\n\n\n0\n\n\n\nC->A\n\n\n0\n\n\n\nC->D\n\n\n1\n\n\n\nD->B\n\n\n0\n\n\n\nD->C\n\n\n1\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from automata.fa.dfa import DFA\n", "\n", - "# DFA which matches all binary strings ending in an odd number of '1's\n", - "my_dfa = DFA(\n", - "\tstates={'q0', 'q1', 'q2'},\n", + "q15 = DFA(\n", + "\tstates={'A', 'B', 'C', 'D'},\n", "\tinput_symbols={'0', '1'},\n", "\ttransitions={\n", - "\t\t'q0': {'0': 'q0', '1': 'q1'},\n", - "\t\t'q1': {'0': 'q0', '1': 'q2'},\n", - "\t\t'q2': {'0': 'q2', '1': 'q1'}\n", + "\t\t'A': {'0': 'C', '1': 'B'},\n", + "\t\t'B': {'0': 'D', '1': 'A'},\n", + "\t\t'C': {'0': 'A', '1': 'D'},\n", + "\t\t'D': {'0': 'B', '1': 'C'}\n", + "\t},\n", + "\tinitial_state='A',\n", + "\tfinal_states={'D'}\n", + ")\n", + "t = [\n", + "\tq15.accepts_input(\"010101\"),\n", + "\tq15.accepts_input(\"000111\"),\n", + "\tq15.accepts_input(\"01\"),\n", + "]\n", + "f = [\n", + "\tq15.accepts_input(\"\"),\n", + "\tq15.accepts_input(\"010\"),\n", + "\tq15.accepts_input(\"0011\")\n", + "]\n", + "\n", + "# print(t)\n", + "# print(f)\n", + "q15.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.684624Z", + "start_time": "2024-02-10T22:40:20.444666600Z" + } + }, + "id": "42f912166acd276e", + "execution_count": 1 + }, + { + "cell_type": "markdown", + "source": [ + "
\n", + "$\\pagebreak$" + ], + "metadata": { + "collapsed": false + }, + "id": "cf53db9d4fcae2c9" + }, + { + "cell_type": "markdown", + "source": [ + "# Question 16\n", + "\n", + "Draw a state diagram with the given formal definition the finite automata" + ], + "metadata": { + "collapsed": false + }, + "id": "bfa5270ba2970a9" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\ndba868d3-1c04-46ca-b078-ab22380f1c61\n\n\n\n\n\n\n\nq0\n\nq0\n\n\n\ndba868d3-1c04-46ca-b078-ab22380f1c61->q0\n\n\n\n\n\n\n\n\nq0->q0\n\n\na,c\n\n\n\nq1\n\nq1\n\n\n\nq0->q1\n\n\nb\n\n\n\nq1->q1\n\n\na,c\n\n\n\nq2\n\n\nq2\n\n\n\nq1->q2\n\n\nb\n\n\n\nq2->q2\n\n\na,c\n\n\n\nq3\n\nq3\n\n\n\nq2->q3\n\n\nb\n\n\n\nq3->q3\n\n\na,c\n\n\n\nq4\n\n\nq4\n\n\n\nq3->q4\n\n\nb\n\n\n\nq5\n\nq5\n\n\n\nq5->q5\n\n\na,b,c\n\n\n\nq4->q5\n\n\nb\n\n\n\nq4->q4\n\n\na,c\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "q16 = DFA(\n", + "\tstates={'q0', 'q1', 'q2', 'q3', 'q4', 'q5'},\n", + "\tinput_symbols={'a', 'b', 'c'},\n", + "\ttransitions={\n", + "\t\t'q0': {'a': 'q0', 'b': 'q1', 'c': 'q0'},\n", + "\t\t'q1': {'a': 'q1', 'b': 'q2', 'c': 'q1'},\n", + "\t\t'q2': {'a': 'q2', 'b': 'q3', 'c': 'q2'},\n", + "\t\t'q3': {'a': 'q3', 'b': 'q4', 'c': 'q3'},\n", + "\t\t'q4': {'a': 'q4', 'b': 'q5', 'c': 'q4'},\n", + "\t\t'q5': {'a': 'q5', 'b': 'q5', 'c': 'q5'},\n", "\t},\n", "\tinitial_state='q0',\n", - "\tfinal_states={'q1'}\n", + "\tfinal_states={'q2','q4'}\n", ")\n", - "my_dfa.show_diagram()" - ] + "\n", + "t = [\n", + "\tq16.accepts_input(\"abbccccc\"),\n", + "\tq16.accepts_input(\"abbcccbbcc\"),\n", + "\tq16.accepts_input(\"abcccbcc\"),\n", + "]\n", + "f = [\n", + "\tq16.accepts_input(\"abc\"),\n", + "\tq16.accepts_input(\"\"),\n", + "\tq16.accepts_input(\"abbccbbcccb\")\n", + "]\n", + "# print(t)\n", + "# print(f)\n", + "q16.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.685624300Z", + "start_time": "2024-02-10T22:40:20.684624Z" + } + }, + "id": "4050347d7a21fc36", + "execution_count": 2 + }, + { + "cell_type": "markdown", + "source": [ + "The language accepted by this DFA is:\n", + "\n", + "$$L = \\{ w \\in \\{a,b,c\\}^* | n_b(w) = 2 \\text{ or } n_b(w) = 4 \\}$$" + ], + "metadata": { + "collapsed": false + }, + "id": "3e0bab1534a434b6" + }, + { + "cell_type": "markdown", + "source": [ + "
\n", + "$\\pagebreak$" + ], + "metadata": { + "collapsed": false + }, + "id": "e2fc5655fb27610e" + }, + { + "cell_type": "markdown", + "source": [ + "# Question 17\n", + "\n", + "(c) $L = \\{ w \\in \\{a,b\\}^* | w \\text{ contains the substring ba exactly once } \\}$" + ], + "metadata": { + "collapsed": false + }, + "id": "3ff27392d5e09f18" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\na6cadb2b-07b1-4892-b4cf-723e983c33aa\n\n\n\n\n\n\n\nq0\n\nq0\n\n\n\na6cadb2b-07b1-4892-b4cf-723e983c33aa->q0\n\n\n\n\n\n\n\n\nq0->q0\n\n\na\n\n\n\nq1\n\nq1\n\n\n\nq0->q1\n\n\nb\n\n\n\nq1->q1\n\n\nb\n\n\n\nq2\n\n\nq2\n\n\n\nq1->q2\n\n\na\n\n\n\nq4\n\n\nq4\n\n\n\nq2->q4\n\n\nb\n\n\n\nq3\n\n\nq3\n\n\n\nq2->q3\n\n\na\n\n\n\nq4->q4\n\n\nb\n\n\n\nq5\n\nq5\n\n\n\nq4->q5\n\n\na\n\n\n\nq3->q4\n\n\nb\n\n\n\nq3->q3\n\n\na\n\n\n\nq5->q5\n\n\na,b\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "q17c = DFA(\n", + "\tstates={'q0', 'q1', 'q2', 'q3', 'q4', 'q5'},\n", + "\tinput_symbols={'a', 'b'},\n", + "\ttransitions={\n", + "\t\t'q0': {'a': 'q0', 'b': 'q1'},\n", + "\t\t'q1': {'a': 'q2', 'b': 'q1'},\n", + "\t\t'q2': {'a': 'q3', 'b': 'q4'},\n", + "\t\t'q3': {'a': 'q3', 'b': 'q4'},\n", + "\t\t'q4': {'a': 'q5', 'b': 'q4'},\n", + "\t\t'q5': {'a': 'q5', 'b': 'q5'},\n", + "\t},\n", + "\tinitial_state='q0',\n", + "\tfinal_states={'q2', 'q3', 'q4'}\n", + ")\n", + "t = [\n", + "\tq17c.accepts_input(\"ba\"),\n", + "\tq17c.accepts_input(\"aaaaaba\"),\n", + "\tq17c.accepts_input(\"baaaaab\"),\n", + "\tq17c.accepts_input(\"baaaaa\"),\n", + "\tq17c.accepts_input(\"aaaabaaaaa\"),\n", + "\tq17c.accepts_input(\"bab\"),\n", + "\tq17c.accepts_input(\"bbbbbbbbbbbba\"),\n", + "\tq17c.accepts_input(\"bbbbbbbbbbbbbab\"),\n", + "]\n", + "f = [\n", + "\tq17c.accepts_input(\"baaaaaba\"),\n", + "\tq17c.accepts_input(\"baba\"),\n", + "\tq17c.accepts_input(\"aababa\"),\n", + "\tq17c.accepts_input(\"baaabaab\"),\n", + "\tq17c.accepts_input(\"bbbbbbbbbbbbaba\"),\n", + "]\n", + "# print(t)\n", + "# print(f)\n", + "q17c.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.689625400Z", + "start_time": "2024-02-10T22:40:20.684624Z" + } + }, + "id": "373a99c58af8b2b6", + "execution_count": 3 + }, + { + "cell_type": "markdown", + "source": [ + "(d) $L = \\{ ab^ma^n | m,n \\in \\mathbb{Z}, m \\geq 2, n \\geq 1 \\}$" + ], + "metadata": { + "collapsed": false + }, + "id": "5e343e46b83de317" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\nd6c8a5b1-b4ac-4dc0-9418-6ef0b18b35c4\n\n\n\n\n\n\n\nq0\n\nq0\n\n\n\nd6c8a5b1-b4ac-4dc0-9418-6ef0b18b35c4->q0\n\n\n\n\n\n\n\n\nq1\n\nq1\n\n\n\nq0->q1\n\n\na\n\n\n\nq5\n\nq5\n\n\n\nq0->q5\n\n\nb\n\n\n\nq1->q5\n\n\na\n\n\n\nq2\n\nq2\n\n\n\nq1->q2\n\n\nb\n\n\n\nq5->q5\n\n\na,b\n\n\n\nq2->q5\n\n\na\n\n\n\nq3\n\nq3\n\n\n\nq2->q3\n\n\nb\n\n\n\nq3->q3\n\n\nb\n\n\n\nq4\n\n\nq4\n\n\n\nq3->q4\n\n\na\n\n\n\nq4->q5\n\n\nb\n\n\n\nq4->q4\n\n\na\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "q17d = DFA(\n", + "\tstates={'q0', 'q1', 'q2', 'q3', 'q4', 'q5'},\n", + "\tinput_symbols={'a', 'b'},\n", + "\ttransitions={\n", + "\t\t'q0': {'a': 'q1', 'b': 'q5'},\n", + "\t\t'q1': {'a': 'q5', 'b': 'q2'},\n", + "\t\t'q2': {'a': 'q5', 'b': 'q3'},\n", + "\t\t'q3': {'a': 'q4', 'b': 'q3'},\n", + "\t\t'q4': {'a': 'q4', 'b': 'q5'},\n", + "\t\t'q5': {'a': 'q5', 'b': 'q5'},\n", + "\t},\n", + "\tinitial_state='q0',\n", + "\tfinal_states={'q4'}\n", + ")\n", + "t = [\n", + "\tq17d.accepts_input(\"abba\"),\n", + "\tq17d.accepts_input(\"abbbba\"),\n", + "\tq17d.accepts_input(\"abbaaaaaa\"),\n", + "\tq17d.accepts_input(\"abbbbbaaaaa\"),\n", + "]\n", + "f = [\n", + "\tq17d.accepts_input(\"\"),\n", + "\tq17d.accepts_input(\"bba\"),\n", + "\tq17d.accepts_input(\"a\"),\n", + "\tq17d.accepts_input(\"aba\"),\n", + "\tq17d.accepts_input(\"abbab\"),\n", + "\tq17d.accepts_input(\"abbbbaaab\"),\n", + "\tq17d.accepts_input(\"abb\"),\n", + "]\n", + "# print(t)\n", + "# print(f)\n", + "q17d.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.722624Z", + "start_time": "2024-02-10T22:40:20.694623600Z" + } + }, + "id": "435890c731b913c1", + "execution_count": 4 + }, + { + "cell_type": "markdown", + "source": [ + "
\n", + "$\\pagebreak$" + ], + "metadata": { + "collapsed": false + }, + "id": "8b04d737ea5c7587" + }, + { + "cell_type": "markdown", + "source": [ + "# Question 18\n", + "\n", + "$$L = \\{ w \\in \\{0,1\\}^* | n_0(w) \\text{ is not a multiple of 5 } \\}$$" + ], + "metadata": { + "collapsed": false + }, + "id": "be6ef3b25e4d501a" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\n5a7b8517-28a8-430d-9994-0215c01dd1eb\n\n\n\n\n\n\n\nq0\n\nq0\n\n\n\n5a7b8517-28a8-430d-9994-0215c01dd1eb->q0\n\n\n\n\n\n\n\n\nq0->q0\n\n\n1\n\n\n\nq1\n\n\nq1\n\n\n\nq0->q1\n\n\n0\n\n\n\nq1->q1\n\n\n1\n\n\n\nq2\n\n\nq2\n\n\n\nq1->q2\n\n\n0\n\n\n\nq2->q2\n\n\n1\n\n\n\nq3\n\n\nq3\n\n\n\nq2->q3\n\n\n0\n\n\n\nq3->q3\n\n\n1\n\n\n\nq4\n\n\nq4\n\n\n\nq3->q4\n\n\n0\n\n\n\nq5\n\nq5\n\n\n\nq5->q1\n\n\n0\n\n\n\nq5->q5\n\n\n1\n\n\n\nq4->q5\n\n\n0\n\n\n\nq4->q4\n\n\n1\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "q18 = DFA(\n", + "\tstates={'q0', 'q1', 'q2', 'q3', 'q4', 'q5'},\n", + "\tinput_symbols={'0', '1'},\n", + "\ttransitions={\n", + "\t\t'q0': {'0': 'q1', '1': 'q0'},\n", + "\t\t'q1': {'0': 'q2', '1': 'q1'},\n", + "\t\t'q2': {'0': 'q3', '1': 'q2'},\n", + "\t\t'q3': {'0': 'q4', '1': 'q3'},\n", + "\t\t'q4': {'0': 'q5', '1': 'q4'},\n", + "\t\t'q5': {'0': 'q1', '1': 'q5'},\n", + "\t},\n", + "\tinitial_state='q0',\n", + "\tfinal_states={'q1', 'q2', 'q3', 'q4'}\n", + ")\n", + "t = [\n", + "\tq18.accepts_input(\"0\"),\n", + "\tq18.accepts_input(\"00\"),\n", + "\tq18.accepts_input(\"000\"),\n", + "\tq18.accepts_input(\"0000\"),\n", + "\tq18.accepts_input(\"000000\"),\n", + "\tq18.accepts_input(\"0000100\"),\n", + "\tq18.accepts_input(\"10000001\"),\n", + "\tq18.accepts_input(\"010\"),\n", + "\tq18.accepts_input(\"01\"),\n", + "]\n", + "f = [\n", + "\tq18.accepts_input(\"\"),\n", + "\tq18.accepts_input(\"1\"),\n", + "\tq18.accepts_input(\"00000\"),\n", + "\tq18.accepts_input(\"1000001\"),\n", + "\tq18.accepts_input(\"001000\"),\n", + "\tq18.accepts_input(\"0000000000\"),\n", + "]\n", + "# print(t)\n", + "# print(f)\n", + "q18.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.776624700Z", + "start_time": "2024-02-10T22:40:20.724626600Z" + } + }, + "id": "e0757dc4f0eae75b", + "execution_count": 5 + }, + { + "cell_type": "markdown", + "source": [ + "
\n", + "$\\pagebreak$" + ], + "metadata": { + "collapsed": false + }, + "id": "5298da4937a41c" + }, + { + "cell_type": "markdown", + "source": [ + "# Question 20\n", + "\n", + "$$L = \\{ w \\in \\{a,b\\}^* | n_a(w) \\leq 1 \\text{ or } n_b(w) \\geq 2 \\}$$" + ], + "metadata": { + "collapsed": false + }, + "id": "82014e661a375124" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "image/svg+xml": "\n\n\n\n\n\n\n\n\n6018d69b-d8b3-424d-9738-9d238e454881\n\n\n\n\n\n\n\nq0\n\n\nq0\n\n\n\n6018d69b-d8b3-424d-9738-9d238e454881->q0\n\n\n\n\n\n\n\n\nq1\n\n\nq1\n\n\n\nq0->q1\n\n\n0\n\n\n\nq3\n\n\nq3\n\n\n\nq0->q3\n\n\n1\n\n\n\nq4\n\n\nq4\n\n\n\nq1->q4\n\n\n1\n\n\n\nq2\n\n\nq2\n\n\n\nq1->q2\n\n\n0\n\n\n\nq3->q4\n\n\n0\n\n\n\nq6\n\nq6\n\n\n\nq3->q6\n\n\n1\n\n\n\nq7\n\nq7\n\n\n\nq4->q7\n\n\n1\n\n\n\nq5\n\n\nq5\n\n\n\nq4->q5\n\n\n0\n\n\n\nq2->q2\n\n\n0\n\n\n\nq2->q5\n\n\n1\n\n\n\nq6->q6\n\n\n1\n\n\n\nq6->q7\n\n\n0\n\n\n\nq7->q7\n\n\n1\n\n\n\nq8\n\n\nq8\n\n\n\nq7->q8\n\n\n0\n\n\n\nq5->q5\n\n\n0\n\n\n\nq5->q8\n\n\n1\n\n\n\nq8->q8\n\n\n0,1\n\n\n\n", + "text/plain": ">" + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "q20 = DFA(\n", + "\tstates={'q0', 'q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8'},\n", + "\tinput_symbols={'0', '1'},\n", + "\ttransitions={\n", + "\t\t'q0': {'0': 'q1', '1': 'q3'},\n", + "\t\t'q1': {'0': 'q2', '1': 'q4'},\n", + "\t\t'q2': {'0': 'q2', '1': 'q5'},\n", + "\t\t'q3': {'0': 'q4', '1': 'q6'},\n", + "\t\t'q4': {'0': 'q5', '1': 'q7'},\n", + "\t\t'q5': {'0': 'q5', '1': 'q8'},\n", + "\t\t'q6': {'0': 'q7', '1': 'q6'},\n", + "\t\t'q7': {'0': 'q8', '1': 'q7'},\n", + "\t\t'q8': {'0': 'q8', '1': 'q8'},\n", + "\t},\n", + "\tinitial_state='q0',\n", + "\tfinal_states={'q0', 'q1', 'q2', 'q3', 'q4', 'q5', 'q8'}\n", + ")\n", + "t = [\n", + "\tq20.accepts_input(\"\"),\n", + "\tq20.accepts_input(\"1\"),\n", + "\tq20.accepts_input(\"0\"),\n", + "\tq20.accepts_input(\"1100\"),\n", + "\tq20.accepts_input(\"00\"),\n", + "\tq20.accepts_input(\"000000\"),\n", + "\tq20.accepts_input(\"0000001\"),\n", + "\tq20.accepts_input(\"00000011\"),\n", + "\tq20.accepts_input(\"1010\"),\n", + "\tq20.accepts_input(\"0101\"),\n", + "]\n", + "f = [\n", + "\tq20.accepts_input(\"11\"),\n", + "\tq20.accepts_input(\"11111\"),\n", + "\tq20.accepts_input(\"1110\"),\n", + "\tq20.accepts_input(\"1011\"),\n", + "\tq20.accepts_input(\"0111\"),\n", + "\tq20.accepts_input(\"011\"),\n", + "\tq20.accepts_input(\"110\"),\n", + "]\n", + "# print(t)\n", + "# print(f)\n", + "q20.show_diagram()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-02-10T22:40:20.825624600Z", + "start_time": "2024-02-10T22:40:20.774622800Z" + } + }, + "id": "d38eeb22a7a3122d", + "execution_count": 6 + }, + { + "cell_type": "markdown", + "source": [ + "
\n", + "$\\pagebreak$" + ], + "metadata": { + "collapsed": false + }, + "id": "f3714817ea911d3" + }, + { + "cell_type": "markdown", + "source": [ + "# Question 21\n", + "\n", + "To make it easier to identify the language, it can be helpful to look for patterns in strings that are in the accepted language\n", + "\n", + "(c)\n", + "\n", + "Example Accepted Strings:\n", + "10100,\n", + "10111100,\n", + "101111010100,\n", + "10100100\n", + "\n", + "Looking at these strings for patterns and the DFA, I can see that the things in common are that all strings must start with $101$ and end with $00$\n", + "\n", + "The formal language definition for this would be:\n", + "\n", + "$$L = \\{ w \\in \\{0,1\\}^* | w \\text{ starts with } 101 \\text{ and } w \\text{ ends with } 00 \\}$$\n", + "\n", + "(d)\n", + "\n", + "Example Accepted Strings:\n", + "abb,\n", + "bab,\n", + "bba\n", + "\n", + "Looking at these strings and looking at the DFA, I can see that the DFA only accepts strings with 1 $a$ and 2 $b$\n", + "\n", + "The formal language definition for this would be:\n", + "\n", + "$$L = \\{ w \\in \\{a,b\\}^* | n_a(w) = 1 \\text{ and } n_b(w) = 2 \\}$$" + ], + "metadata": { + "collapsed": false + }, + "id": "7b9207cb562c37c6" } ], "metadata": {