Answers.Body: <p>This suggestion is, I'm afraid, highly speculative and untried. But I'd be tempted at least to give out an assignment of the following form, perhaps using a structure like that suggested by @BenI. here. </p>
  
  <p>Prepare a numbered list of exercises from quite simple (in your estimation) to quite complex. The numbers correlate directly to the difficulty. Tell the students that they can do any number of them (say at least three) that they wish and that the grade will depend only on the most difficult one they get correct. </p>
  
  <p>The justification for the structure is that the students who get these easy will just work on a few of the harder ones and the ones that struggle will start farther down your list and work until they feel a bit confident. The students who need the most work will, hopefully, get the most practice. The rating by difficulty can also help them get "into the flow." </p>
  
  <p>In the exercises I'd also stress a variety of vocabulary for things so that they get some practice in matching human language to the technical forms. You could even try to state each exercise two different ways to help students with the correlations, but you need to be careful that your explanations of the requirements really are equivalent. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T22:30:32.503Z
Answers.Text: This would drive my students crazy.  Many of them are grade-driven to a fault, and they would either cheat on the last one in order to get a 100%, or complain bitterly when they got stuck at an earlier example.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T22:32:07.090Z
Answers.Text: The intent was more to help the strugglers, but I see your point. Maybe you have a different sort of issue. Not every scheme works with every student or every group, of course.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T22:26:26.790Z
Answers.LastActivityDate: 2017-11-09T22:26:26.790Z
Answers.UserDisplayName: Buffy
Answers.Body: <p>This is the stuff of math teachers' nightmares. The problems here, from my experience teaching about grammars<sup><strong>1</strong></sup>, are two-fold:</p>
  
  <ol>
  <li><p>You said that syntax is probably not the culprit here. Students may be able to follow a grammar that has been presented to them, but may not be able to generate an appropriate grammar for a given series of test cases.</p></li>
  <li><p>Students may not be able to generate appropriate test cases from the word problem itself.</p></li>
  </ol>
  
  <p>The good news is that, by breaking it down into these two steps instead of one, you can actually help to isolate the problem that your students are having.  </p>
  
  <p>If you see your students frequently (as I do), here's a fix-up strategy that you can do in about 30 minutes of class time over three days.  Create a worksheet with a series of word problems, and ask the students, as homework, to generate test cases for these hypothetical machines.  They are <em>not</em> to create the grammars themselves, only create a series of test cases that should be accepted or not accepted.  Emphasize that redundancy is not a goal; you want a minimal set of test cases that could guarantee that some grammar is entirely correct.</p>
  
  <p>The next day, spend about 15 minutes going over two of the problems, round-robin style, at the board.  Ask a student to write a test case for the first problem. Turn to the second student, and ask them to write another test on the board that could potentially uncover new ground.  On to the third student, fourth student, etc., until you are satisfied that you have a good testing set.  Ask if anyone else has any important tests remaining.</p>
  
  <p>Do the same for the second problem, and then discuss the importance (in general) of creating good test sets upon encountering a word problem.  Point out that they will receive word problems on their assessment at the end of the unit, and you expect them to be able to figure out a good set of test cases with which to design a grammar at that time.</p>
  
  <p>Their homework for that second day is to fix up their tests (if they need more work), and to create the appropriate grammars.  I suspect that when you get this homework back on day 3, you'll have much stronger results.</p>
  
  <p><sup><strong>1</strong> - I am using "grammar" as a stand in for "grammars, regexes, FSAs, or whatever type of expression/machine you are trying to get them to create at some particular moment."</sup></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T16:14:47.023Z
Answers.LastActivityDate: 2017-11-09T16:14:47.023Z
Answers.UserDisplayName: Ben I.
Body: <p>I'm currently helping teach a unit about languages as a part of a discrete math course -- we're currently focusing on regular expressions, NFAs, DFAs, CFGs, grammars, and the like. </p>
  
  <p>One of the skills we'd like students to be able to acquire is the ability to translate English into equivalent regular expressions -- e.g. translate phrases like "match all strings containing an even number of the character 'a'" or "match all binary strings that do not contain the string '1001'".</p>
  
  <p>Some students seem to easily pick up the "knack" of performing these sorts of translations, but many more of them seem to struggle.</p>
  
  <p>Unfortunately, I'm not sure how to best help these students. Constructing regular expressions isn't usually something I find particularly difficult, so I've been finding it difficult to "get into the mindset" of the students who find writing regular expressions to be less obvious. </p>
  
  <p>I've spent some time introspecting and trying to pick apart what strategies I subconsciously tend to use when faced with a new problem, but that's mostly yielded a list of ad-hoc strategies rather then anything fundamental.</p>
  
  <hr>
  
  <p>Something I feel I should note is that I don't think unfamiliarity with syntax is likely to be the culprit. We're starting by studying specifically regular expressions (not regex) and have restricted ourselves to using a very minimal toolset: union, concatenation, the Kleene star, and epsilons -- so, no backreferences, no captures, nothing like that. </p>
  
  <p>Rather, it seems what students find most difficult is the inherent act of interpreting and translating an English sentence and formalizing it into some logical form.</p>
  
  <p>I've seen this same sort difficulty of manifest appear in other scenarios: for example, earlier this quarter, we asked students to translate English into propositional or predicate logic: I also found it difficult to teach students how to do this in any kind of systematic way. As another example, in other courses, I've observed many students find it challenging to translate English into SQL queries (and here I have some more sympathy, since I also find constructing certain kinds of SQL queries to be challenging).</p>
  
  <p>The best I've been able to do so far is just have students do a bunch of practice/walk through a bunch of examples, but that doesn't strike me as being a particularly efficient strategy (though I don't dispute that practice is essential).</p>
  
  <hr>
  
  <p>This brings me to the core of my question: <strong>How can I more effectively help students master the meta-skill of "translation"/"formalization"?</strong> I'd welcome both answers focusing on strategies for helping students more effectively construct regular expressions as well as answers focusing on helping students acquire this meta-skill in a more general sense. Answers that can give me more nuanced insight what sorts of things students find difficult about these types of problems would also be welcome.</p>
  
  <p>Note: somebody asked a similar question to this one about <a href="https://cseducators.stackexchange.com/questions/3132/effective-ways-of-teaching-regex-to-students-who-know-java">helping students who are familiar with Java learn regex</a>. However, that question seems to focus more on how to best teach the nuts and bolts of regex-the-language; my question is more about how to teach the meta-skill of "translation/formalization".</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-09T06:04:43.043Z
Comments.Text: Note: as you can probably tell, I'm having some difficulty articulating the exact issue I'm facing, so please let me know if there's anything I can do to improve the question/if it's too broad. Also, tags are hard, so suggestions there are also welcome.
Comments.UserDisplayName: Michael0x2a
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-09T07:26:08.167Z
Comments.Text: I can't stress just how much I like the question
Comments.UserDisplayName: ItamarG3
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-16T09:22:15.620Z
Comments.Text: I've been using regex'es since 1980, and still have problems translating requirements into them. The problems are that the syntax was organically grown over years,  different implementations have different syntax and levels of support for "standards",  and the commands are not human readable. In the end, i have found that constructing any regex beyond the trivial requires ready access to google.
Comments.UserDisplayName: pojo-guy
Tags: <lesson-ideas><regex><discrete-math>
Title: Teaching students how to construct regular expressions (and other "translation" style problems)
ThreadText: # Teaching students how to construct regular expressions (and other "translation" style problems)
  
  (Asked by: username_0 on 2017-11-09)
  
  I'm currently helping teach a unit about languages as a part of a discrete math course -- we're currently focusing on regular expressions, NFAs, DFAs, CFGs, grammars, and the like.
  
  One of the skills we'd like students to be able to acquire is the ability to translate English into equivalent regular expressions -- e.g. translate phrases like "match all strings containing an even number of the character 'a'" or "match all binary strings that do not contain the string '1001'".
  
  Some students seem to easily pick up the "knack" of performing these sorts of translations, but many more of them seem to struggle.
  
  Unfortunately, I'm not sure how to best help these students. Constructing regular expressions isn't usually something I find particularly difficult, so I've been finding it difficult to "get into the mindset" of the students who find writing regular expressions to be less obvious.
  
  I've spent some time introspecting and trying to pick apart what strategies I subconsciously tend to use when faced with a new problem, but that's mostly yielded a list of ad-hoc strategies rather then anything fundamental.
  
  ---
  
  Something I feel I should note is that I don't think unfamiliarity with syntax is likely to be the culprit. We're starting by studying specifically regular expressions (not regex) and have restricted ourselves to using a very minimal toolset: union, concatenation, the Kleene star, and epsilons -- so, no backreferences, no captures, nothing like that.
  
  Rather, it seems what students find most difficult is the inherent act of interpreting and translating an English sentence and formalizing it into some logical form.
  
  I've seen this same sort difficulty of manifest appear in other scenarios: for example, earlier this quarter, we asked students to translate English into propositional or predicate logic: I also found it difficult to teach students how to do this in any kind of systematic way. As another example, in other courses, I've observed many students find it challenging to translate English into SQL queries (and here I have some more sympathy, since I also find constructing certain kinds of SQL queries to be challenging).
  
  The best I've been able to do so far is just have students do a bunch of practice/walk through a bunch of examples, but that doesn't strike me as being a particularly efficient strategy (though I don't dispute that practice is essential).
  
  ---
  
  This brings me to the core of my question: **How can I more effectively help students master the meta-skill of "translation"/"formalization"?** I'd welcome both answers focusing on strategies for helping students more effectively construct regular expressions as well as answers focusing on helping students acquire this meta-skill in a more general sense. Answers that can give me more nuanced insight what sorts of things students find difficult about these types of problems would also be welcome.
  
  Note: somebody asked a similar question to this one about [helping students who are familiar with Java learn regex](https://cseducators.stackexchange.com/questions/3132/effective-ways-of-teaching-regex-to-students-who-know-java). However, that question seems to focus more on how to best teach the nuts and bolts of regex-the-language; my question is more about how to teach the meta-skill of "translation/formalization".
  
  **Tags:** lesson-ideas, regex, discrete-math
  
  > **Comments:**
  > **username_0**: Note: as you can probably tell, I'm having some difficulty articulating the exact issue I'm facing, so please let me know if there's anything I can do to improve the question/if it's too broad. Also, tags are hard, so suggestions there are also welcome.  
  > **username_1**: I can't stress just how much I like the question  
  > **username_2**: I've been using regex'es since 1980, and still have problems translating requirements into them. The problems are that the syntax was organically grown over years,  different implementations have different syntax and levels of support for "standards",  and the commands are not human readable. In the end, i have found that constructing any regex beyond the trivial requires ready access to google.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2017-11-09. Score: 3
  
  This is the stuff of math teachers' nightmares. The problems here, from my experience teaching about grammars**1**, are two-fold:
  
  1. You said that syntax is probably not the culprit here. Students may be able to follow a grammar that has been presented to them, but may not be able to generate an appropriate grammar for a given series of test cases.
  2. Students may not be able to generate appropriate test cases from the word problem itself.
  
  The good news is that, by breaking it down into these two steps instead of one, you can actually help to isolate the problem that your students are having.
  
  If you see your students frequently (as I do), here's a fix-up strategy that you can do in about 30 minutes of class time over three days. Create a worksheet with a series of word problems, and ask the students, as homework, to generate test cases for these hypothetical machines. They are *not* to create the grammars themselves, only create a series of test cases that should be accepted or not accepted. Emphasize that redundancy is not a goal; you want a minimal set of test cases that could guarantee that some grammar is entirely correct.
  
  The next day, spend about 15 minutes going over two of the problems, round-robin style, at the board. Ask a student to write a test case for the first problem. Turn to the second student, and ask them to write another test on the board that could potentially uncover new ground. On to the third student, fourth student, etc., until you are satisfied that you have a good testing set. Ask if anyone else has any important tests remaining.
  
  Do the same for the second problem, and then discuss the importance (in general) of creating good test sets upon encountering a word problem. Point out that they will receive word problems on their assessment at the end of the unit, and you expect them to be able to figure out a good set of test cases with which to design a grammar at that time.
  
  Their homework for that second day is to fix up their tests (if they need more work), and to create the appropriate grammars. I suspect that when you get this homework back on day 3, you'll have much stronger results.
  
  **1** - I am using "grammar" as a stand in for "grammars, regexes, FSAs, or whatever type of expression/machine you are trying to get them to create at some particular moment."
  
  
  ---
  
  ### Answer by username_3 on 2017-11-09. Score: 1
  
  This suggestion is, I'm afraid, highly speculative and untried. But I'd be tempted at least to give out an assignment of the following form, perhaps using a structure like that suggested by @BenI. here.
  
  Prepare a numbered list of exercises from quite simple (in your estimation) to quite complex. The numbers correlate directly to the difficulty. Tell the students that they can do any number of them (say at least three) that they wish and that the grade will depend only on the most difficult one they get correct.
  
  The justification for the structure is that the students who get these easy will just work on a few of the harder ones and the ones that struggle will start farther down your list and work until they feel a bit confident. The students who need the most work will, hopefully, get the most practice. The rating by difficulty can also help them get "into the flow."
  
  In the exercises I'd also stress a variety of vocabulary for things so that they get some practice in matching human language to the technical forms. You could even try to state each exercise two different ways to help students with the correlations, but you need to be careful that your explanations of the requirements really are equivalent.
  
  > **Comments:**
  > **username_4**: This would drive my students crazy.  Many of them are grade-driven to a fault, and they would either cheat on the last one in order to get a 100%, or complain bitterly when they got stuck at an earlier example.  
  > **username_3**: The intent was more to help the strugglers, but I see your point. Maybe you have a different sort of issue. Not every scheme works with every student or every group, of course.  
  
  ---
  
  