/* Vowel strings in Picat. From SNOBOL4 mailing list """ http://uk.answers.yahoo.com/question/index?qid=20100420025400AANtXA1 Question about Backus-Naur notation? I'm studying Computer science and one of the questions for a research project is on Backus-Naur notation. (See below) I think that both the character strings are valid, but I would like some confirmation on this as it seems unlikely that both are correct. Please note I'm not asking you to do my homework here, just a little guidance. A vowel-string in a high level programming language has its syntax described in Backus Naur Form as follows: ::= | aa | ee | ii | oo | uu ::= a | e | i | o | u State with reasons, whether each of the following character strings is a valid vowel-string: i) aea ii) eae Your productions should probably be ::= | aa | ee | ii | oo | uu ::= a | e | i | o | u (otherwise, is undefined in the grammar) And, according to this grammar, both aea and eae are correct aa ee Now, aea also matches . """ This model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import v3_utils. % import util. % import cp. main => go. go ?=> vowel_string("aea",[]), % ok println(ok1), vowel_string("eae",[]), % ok println(ok2), nl, bp.length(X,3), vowel_string(X,[]), % ok as generator println(x=X), fail, nl. go => true. % Simpler rule. go2 ?=> vowel_string2("aea",[]), % ok println(ok), vowel_string2("eae",[]), % ok println(ok2), % nl, bp.length(X,6), vowel_string2(X,[]), % ok as generator println(x=X), fail, nl. go2 => true. vowel_string --> [a],vowel_string,[a] ; [e],vowel_string,[e] ; [i],vowel_string,[i] ; [o],vowel_string,[o] ; [u],vowel_string,[u] ; vowel. % vowel_string --> []. vowel --> [a] ; [e] ; [i] ; [o] ; [u]. % Simplifing the rule. vowel_string2 --> vowel. vowel_string2 --> [X],{member(X,"aeiou")},vowel_string2,[X]. vowel_string2 --> [].