CS2333/Assignment 6.ipynb
2024-03-16 23:26:32 -03:00

122 lines
3.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "a90ef9f8022df10e",
"metadata": {
"collapsed": false
},
"source": [
"# Question 36\n",
"## a.\n",
"For language B which is non-regular, for example:\n",
"$$B = \\{ w \\in \\{0, 1\\}^* | w \\text{ is a palindrome} \\}$$\n",
"\n",
"A is a subset of Language B:\n",
"$$A = \\{ab, aabb, aaabbb\\}$$\n",
"\n",
"A is however regular, as it is a finite language, so not all subsets of non-regular languages must also be non-regular\n",
"\n",
"## b.\n",
"For language B which is regular:\n",
"$$B = \\{ 0^n | n \\in \\mathbb{Z}\\}$$\n",
"\n",
"Then the following language is a subset of B, but is not regular:\n",
"$$A = \\{0^n | n \\text{ is prime}\\}$$\n",
"\n",
"As all primes are a subset of set $\\mathbb{Z}$"
]
},
{
"cell_type": "markdown",
"id": "2d1690ef",
"metadata": {},
"source": [
"$\\pagebreak$"
]
},
{
"cell_type": "markdown",
"id": "9a7c595f",
"metadata": {},
"source": [
"# Question 37\n",
"Let $p \\geq 1$ be any integer \\\n",
"Choose any string $s = a^{p}b^{p}c^{2p}$. $|s|$ is $4p$ which must be greater than $p$ \\\n",
"Consider any decomposition $s = xyz$ that satisfies 1. $|y| \\geq 1$ and 2. $|xy| \\leq p$\n",
"\n",
"Because of 2, x and y must be only \"a\", and because of 1, y must have at least one \"a\"\n",
"\n",
"So for the decomposition \"xyyz\", the number of \"a\" is p+1, and the number of \"b\" is p, which violates the condition that the number of \"c\" is 2p, as the the number of \"a\" plus the number of \"b\" is 2p+1"
]
},
{
"cell_type": "markdown",
"id": "c8d0ce5a",
"metadata": {},
"source": [
"$\\pagebreak$"
]
},
{
"cell_type": "markdown",
"id": "8d439d76",
"metadata": {},
"source": [
"# Question 38\n",
"Let $p \\geq 1$ be any integer \\\n",
"Choose any string $s = a^{p}b^{3p}$. $|s|$ is $4p$ which must be greater than $p$ \\\n",
"Consider any decomposition $s = xyz$ that satisfies 1. $|y| \\geq 1$ and 2. $|xy| \\leq p$\n",
"\n",
"Because of 2, x and y must be only \"a\", and because of 1, y must have at least one \"a\"\n",
"\n",
"So for the decomposition \"xyyz\", the number of \"a\" is p+1, and the number of \"b\" is 3p, which contradicts the premise that $n_a(w) = 3n_b(w)$ as for any integers which satisfy this condtion, the $n_a(w)$ will always be 1 more than required"
]
},
{
"cell_type": "markdown",
"id": "323bea35",
"metadata": {},
"source": [
"$\\pagebreak$"
]
},
{
"cell_type": "markdown",
"id": "56466c7f",
"metadata": {},
"source": [
"# Question 41\n",
"Let $p \\geq 1$ be any integer \\\n",
"Choose any string $s = a^{p}b^{p}$. $|s|$ is $2p$ which must be greater than $p$ \\\n",
"Consider any decomposition $s = xyz$ that satisfies 1. $|y| \\geq 1$ and 2. $|xy| \\leq p$\n",
"\n",
"Because of 2, x and y must be only \"a\", and because of 1, y must have at least one \"a\"\n",
"\n",
"So for the decomposition \"xz\", the number of \"a\" is p-1, which contradicts the condition that $|x| \\geq p$"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}