Posts

Showing posts with the label computation theory

On computing all patterns matched by a regular expression

Image
[Code/código: regexPrinter ] A regular expression , without much rigor, is a very compact way of representing several different strings. One common use of regular expressions is to look for strings that have a certain structure in a bigger string (say a text). As an example, the regular expression abc(d|e) can be used to look for the strings "abcd" and "abce", where the character | denotes we have to make a choice. Thus cat|dog would match the strings "cat" and "dog". There are other special symbols that have meanings and purposes. One very interesting question that arises is: given a regular expression, what are the strings matched by it? To answer that question I wrote a small Python program, that I called regexPrinter , that prints all strings matched by a given regular expression! In order to manage that task, I chose a subset of the regex syntax that I wanted to be able to print and also decided that whenever a piece of a pattern was inf...

On recursive functions and Kleene's approach

In Computation Theory it is of interest to study properties about functions, and what functions satisfy said properties. We then consider the set of all functions that satisfy those properties. One of those sets is the set of recursive functions R as defined by Kleene. To define R, Kleene gives a series of different primitive functions that are known to be in R, and then defines some operations that preserve functions in R. For the purposes of what I will be sharing next, I will just enumerate said primitive functions and constructions, so that the reader is aware of what will be used (notice that what comes below is almost identical to what you can see here ). The primitive functions are: The constant functions of arity 0, one for each natural number; The zero function of arity 1, that always returns 0; The successor function of arity 1, that sends x to x+1 ; The projection{a,b} of arity a, that returns the b-th argument unchanged. For example, projection{3,2}(a,b,c) = b . After tha...