Closures and Context Free Grammars

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I'm looking over my syllabus for my theoretical computer science class and within the heading of Context Free Grammars it lists "closure properties". I have looked through my textbook on this subject and found quite little. The little it does have is a bit above my head at the moment (I haven't taken the course yet) but I understand a little.

I was wondering if this idea of closures within context free grammars is the same as or related to the idea of closures within functional programming. It talks about combining grammars and resolving overlaps as far as I can tell. There are a lot of parts to the section within the book I don't understand yet, so I'm unsure about whether these ideas are the same.

(A little more context: I'm writing an email to the professor asking if the course can be switched to Ruby or Python from Perl. If these concepts are related, that could be another reason we should use Ruby over Perl.)

profilepic.png
manpreet 2 years ago

The term "closure" is used an a variety of ways, mostly tracking back to a Mathematical concept of completion, in some sense.

  • An operator is "closed over" a set of values if applying that operator to values from the set always produces a value from the given set. For example, addition is closed over the integers, but division isn't (4 / 2 is integral, but 5 / 2 isn't). So addition of integers is somehow "complete" in a sense that division isn't.

  • The "transitive" closure of a relation "completes" the relation by following (all possible) multiple applications. In everyday terms, the concept of "is a descendent of" is the transitive closure of the relation "is a child of".

  • A functional "closure" is "completed" by e.g. specifying how the free variables are to be resolved. In the pseudo-code expression:

    bump = function(x) (x + y)
    

    x is the argument to bump, but the definition seems to leave "open" the question of resolving y. On the other hand, if we define:

    bumper = function(y) (function(x) (x + y))
    

    then invoking bumper returns a function which adds the original argument of bumper to the created function's argument, so that:

    add3 = bumper(3)
    

    is equivalent to defining:

    add3 = function(x) (x + 3)
    

    The nested definition is "closed over" (or completed by) the variables available at the point of its definition.

So, in effect, the uses of "closure" above all have different specific meanings, and at first glance seem unrelated, but there's a subtle underlying relationship.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.