Code Monkey home page Code Monkey logo

automata-and-mutual-recursion's Introduction

automata-and-mutual-recursion

Code from the Tutorial Thursday hangout of 2 May 2013 on using mutual-recursion to represent automata.

The Scheme files in this repository:

recursion-refresher.scm refresher examples of recursion, mutual-recursion, and Scheme's 'letrec'

automata.scm three Scheme implementations of the deterministic finite automaton (DFA) from the Wikipedia page: http://en.wikipedia.org/wiki/Deterministic_finite_automaton

automata-mk.scm translation of the second DFA implementation from automata.scm into the miniKanren relational language

automata-mk2.scm translation of the third DFA implementation from automata.scm into the miniKanren relational language

Support files:

pmatch.scm a simple pattern matcher

test-check.scm a simple test macro

mk.scm an implementation of miniKanren

The YouTube video of hangout is at: https://www.youtube.com/watch?v=yrf1AYtrKm0

In the video I demonstrate an old functional programming trick: how to encode a deterministic finite state automata using mutually recursive procedures in Scheme and miniKanren. I begin with a gentle introduction to recursion, mutual recursion, and Scheme's letrec construct, which experienced functional programmers may wish to skip.

If you find this interesting, you might want to read Shriram Krishnamurthi's 2006 Journal of Functional Programming paper, 'Automata via Macros': http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/

Michael Sipser's overpriced but excellent 'Introduction to the Theory of Computation, third edition' contains the clearest explanation of finite automata I have seen.

CHALLENGE:

Translate fsm-ho2 from automata.scm to miniKanren, without using project. (See the comment at the top of automata-mk2.scm) This should be possible by using a meta-circular interpreter that can run miniKanren inside miniKanren. This interpreter would also need to handle the subset of Scheme used in the code, such as letrec.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.