Model BNF Formally in mathematical terms












1












$begingroup$


Usually, a language is formally defined as some subset $L$ of the Kleene-closure $Sigma^*$ of some "alphabet" (i.e. finite set) $Sigma$, where by Kleene closure we mean the infinite union $$Sigma^* = bigcup_{k=0}^infty Sigma^k$$ where $Sigma^0 := {epsilon}$, and $Sigma^k$ for $kgeqslant 1$ denotes the Cartesian product of sets. In view of this definition, it is more convenient to model strings of length $k$ (i.e. $k$-tuples) here as functions $fcolon{1,dots,k}to Sigma$ so that $(a_1, dots, a_n)$ becomes $(f(1), dots, f(n))$ as opposed to the usual definition with nesting of pairs (this avoids discomfort about tuples of length zero or one, so that $epsilon$ is just $fcolonvarnothingtovarnothing$, and also tuples of length one are distinguished structurally as functions and cannot be confused with members of the alphabet; i.e. $Sigma^1 neq Sigma$).



Coming from a mathematical background to the subject of formal languages, I am used to the comfortable notion that the machinery underlying everything is built on the ZF(C) axioms. So far, these definitions are satisfactory and nicely describe the idea of languages in a mathematical framework.



But then when Backus–Naur form is used, the mathematical rigour starts slacking a bit, I can't seem to find any books/resources which formally define how BNF's construct languages as sets. I'd appreciate some guidance as to how BNFs can be studied in a formal setting which continues in the spirit of the definitions above.










share|cite|improve this question











$endgroup$












  • $begingroup$
    I'm not sure what is your confusion.
    $endgroup$
    – Asaf Karagila
    Dec 27 '18 at 8:17










  • $begingroup$
    @AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 13:06










  • $begingroup$
    you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
    $endgroup$
    – tp1
    Dec 27 '18 at 14:22












  • $begingroup$
    I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 14:26
















1












$begingroup$


Usually, a language is formally defined as some subset $L$ of the Kleene-closure $Sigma^*$ of some "alphabet" (i.e. finite set) $Sigma$, where by Kleene closure we mean the infinite union $$Sigma^* = bigcup_{k=0}^infty Sigma^k$$ where $Sigma^0 := {epsilon}$, and $Sigma^k$ for $kgeqslant 1$ denotes the Cartesian product of sets. In view of this definition, it is more convenient to model strings of length $k$ (i.e. $k$-tuples) here as functions $fcolon{1,dots,k}to Sigma$ so that $(a_1, dots, a_n)$ becomes $(f(1), dots, f(n))$ as opposed to the usual definition with nesting of pairs (this avoids discomfort about tuples of length zero or one, so that $epsilon$ is just $fcolonvarnothingtovarnothing$, and also tuples of length one are distinguished structurally as functions and cannot be confused with members of the alphabet; i.e. $Sigma^1 neq Sigma$).



Coming from a mathematical background to the subject of formal languages, I am used to the comfortable notion that the machinery underlying everything is built on the ZF(C) axioms. So far, these definitions are satisfactory and nicely describe the idea of languages in a mathematical framework.



But then when Backus–Naur form is used, the mathematical rigour starts slacking a bit, I can't seem to find any books/resources which formally define how BNF's construct languages as sets. I'd appreciate some guidance as to how BNFs can be studied in a formal setting which continues in the spirit of the definitions above.










share|cite|improve this question











$endgroup$












  • $begingroup$
    I'm not sure what is your confusion.
    $endgroup$
    – Asaf Karagila
    Dec 27 '18 at 8:17










  • $begingroup$
    @AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 13:06










  • $begingroup$
    you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
    $endgroup$
    – tp1
    Dec 27 '18 at 14:22












  • $begingroup$
    I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 14:26














1












1








1





$begingroup$


Usually, a language is formally defined as some subset $L$ of the Kleene-closure $Sigma^*$ of some "alphabet" (i.e. finite set) $Sigma$, where by Kleene closure we mean the infinite union $$Sigma^* = bigcup_{k=0}^infty Sigma^k$$ where $Sigma^0 := {epsilon}$, and $Sigma^k$ for $kgeqslant 1$ denotes the Cartesian product of sets. In view of this definition, it is more convenient to model strings of length $k$ (i.e. $k$-tuples) here as functions $fcolon{1,dots,k}to Sigma$ so that $(a_1, dots, a_n)$ becomes $(f(1), dots, f(n))$ as opposed to the usual definition with nesting of pairs (this avoids discomfort about tuples of length zero or one, so that $epsilon$ is just $fcolonvarnothingtovarnothing$, and also tuples of length one are distinguished structurally as functions and cannot be confused with members of the alphabet; i.e. $Sigma^1 neq Sigma$).



Coming from a mathematical background to the subject of formal languages, I am used to the comfortable notion that the machinery underlying everything is built on the ZF(C) axioms. So far, these definitions are satisfactory and nicely describe the idea of languages in a mathematical framework.



But then when Backus–Naur form is used, the mathematical rigour starts slacking a bit, I can't seem to find any books/resources which formally define how BNF's construct languages as sets. I'd appreciate some guidance as to how BNFs can be studied in a formal setting which continues in the spirit of the definitions above.










share|cite|improve this question











$endgroup$




Usually, a language is formally defined as some subset $L$ of the Kleene-closure $Sigma^*$ of some "alphabet" (i.e. finite set) $Sigma$, where by Kleene closure we mean the infinite union $$Sigma^* = bigcup_{k=0}^infty Sigma^k$$ where $Sigma^0 := {epsilon}$, and $Sigma^k$ for $kgeqslant 1$ denotes the Cartesian product of sets. In view of this definition, it is more convenient to model strings of length $k$ (i.e. $k$-tuples) here as functions $fcolon{1,dots,k}to Sigma$ so that $(a_1, dots, a_n)$ becomes $(f(1), dots, f(n))$ as opposed to the usual definition with nesting of pairs (this avoids discomfort about tuples of length zero or one, so that $epsilon$ is just $fcolonvarnothingtovarnothing$, and also tuples of length one are distinguished structurally as functions and cannot be confused with members of the alphabet; i.e. $Sigma^1 neq Sigma$).



Coming from a mathematical background to the subject of formal languages, I am used to the comfortable notion that the machinery underlying everything is built on the ZF(C) axioms. So far, these definitions are satisfactory and nicely describe the idea of languages in a mathematical framework.



But then when Backus–Naur form is used, the mathematical rigour starts slacking a bit, I can't seem to find any books/resources which formally define how BNF's construct languages as sets. I'd appreciate some guidance as to how BNFs can be studied in a formal setting which continues in the spirit of the definitions above.







computer-science context-free-grammar






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 27 '18 at 13:24









Asaf Karagila

306k33438769




306k33438769










asked Dec 27 '18 at 1:29









Luke CollinsLuke Collins

754419




754419












  • $begingroup$
    I'm not sure what is your confusion.
    $endgroup$
    – Asaf Karagila
    Dec 27 '18 at 8:17










  • $begingroup$
    @AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 13:06










  • $begingroup$
    you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
    $endgroup$
    – tp1
    Dec 27 '18 at 14:22












  • $begingroup$
    I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 14:26


















  • $begingroup$
    I'm not sure what is your confusion.
    $endgroup$
    – Asaf Karagila
    Dec 27 '18 at 8:17










  • $begingroup$
    @AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 13:06










  • $begingroup$
    you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
    $endgroup$
    – tp1
    Dec 27 '18 at 14:22












  • $begingroup$
    I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
    $endgroup$
    – Luke Collins
    Dec 27 '18 at 14:26
















$begingroup$
I'm not sure what is your confusion.
$endgroup$
– Asaf Karagila
Dec 27 '18 at 8:17




$begingroup$
I'm not sure what is your confusion.
$endgroup$
– Asaf Karagila
Dec 27 '18 at 8:17












$begingroup$
@AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
$endgroup$
– Luke Collins
Dec 27 '18 at 13:06




$begingroup$
@AsafKaragila What is BNF? How does it formally define languages? I want a description of BNF's which highlights the underlying set structure.
$endgroup$
– Luke Collins
Dec 27 '18 at 13:06












$begingroup$
you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
$endgroup$
– tp1
Dec 27 '18 at 14:22






$begingroup$
you already mentioned the main feature, i.e. the language is a subset of all letter combinations taken from the alphabet. I.e. good way to handle this is via $f : Sigma^*rightarrow 2$ functions which are characteristic function of the subset.
$endgroup$
– tp1
Dec 27 '18 at 14:22














$begingroup$
I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
$endgroup$
– Luke Collins
Dec 27 '18 at 14:26




$begingroup$
I think I'm after something along the lines of "A BNF is a set of production rules", where production rules are as described here.
$endgroup$
– Luke Collins
Dec 27 '18 at 14:26










1 Answer
1






active

oldest

votes


















1












$begingroup$

For simplicity, assume each non-terminal occurs exactly once as the left hand side of a BNF rule. (This just means that all the rules are joined together with alternation.) Let $N$ be the set of non-terminals and identify the terminals with the alphabet $Sigma$. Define a set function $g:mathcal P(Sigma^*)^Ntomathcal P(Sigma^*)^N$ by setting $g(S)(n)$ to the following interpretation of the right hand side of the rule for the non-terminal, $n$. Interpret each terminal (i.e. letter) as a singleton set of that letter. Interpret juxtaposition as language concatenation. Interpret alternation as union. Finally, interpret the non-terminal $m$ via as $S(m)$. Let $sin N$ be the starting non-terminal. The language recognized by the BNF is the least (pre-)fixed point of $g$ evaluated at $s$ where the ordering is the pointwise subset ordering.



This is just the straightforward set-theoretic rendition of a collection of mutually inductively defined sets. Sure enough, if we use the BNF: $s ::= 0 mid 1 s$ with alphabet ${0,1}$, the least (pre-)fixed point property of the resulting language is essentially (the set-theoretic variant of) mathematical induction (of natural numbers). Call the resulting language $L$. The least pre-fixed point property states that for any set $S$ such that ${0}cup({1}frown S)subseteq S$ where $frown$ is language concatenation, $Lsubseteq S$.






share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3053496%2fmodel-bnf-formally-in-mathematical-terms%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$

    For simplicity, assume each non-terminal occurs exactly once as the left hand side of a BNF rule. (This just means that all the rules are joined together with alternation.) Let $N$ be the set of non-terminals and identify the terminals with the alphabet $Sigma$. Define a set function $g:mathcal P(Sigma^*)^Ntomathcal P(Sigma^*)^N$ by setting $g(S)(n)$ to the following interpretation of the right hand side of the rule for the non-terminal, $n$. Interpret each terminal (i.e. letter) as a singleton set of that letter. Interpret juxtaposition as language concatenation. Interpret alternation as union. Finally, interpret the non-terminal $m$ via as $S(m)$. Let $sin N$ be the starting non-terminal. The language recognized by the BNF is the least (pre-)fixed point of $g$ evaluated at $s$ where the ordering is the pointwise subset ordering.



    This is just the straightforward set-theoretic rendition of a collection of mutually inductively defined sets. Sure enough, if we use the BNF: $s ::= 0 mid 1 s$ with alphabet ${0,1}$, the least (pre-)fixed point property of the resulting language is essentially (the set-theoretic variant of) mathematical induction (of natural numbers). Call the resulting language $L$. The least pre-fixed point property states that for any set $S$ such that ${0}cup({1}frown S)subseteq S$ where $frown$ is language concatenation, $Lsubseteq S$.






    share|cite|improve this answer









    $endgroup$


















      1












      $begingroup$

      For simplicity, assume each non-terminal occurs exactly once as the left hand side of a BNF rule. (This just means that all the rules are joined together with alternation.) Let $N$ be the set of non-terminals and identify the terminals with the alphabet $Sigma$. Define a set function $g:mathcal P(Sigma^*)^Ntomathcal P(Sigma^*)^N$ by setting $g(S)(n)$ to the following interpretation of the right hand side of the rule for the non-terminal, $n$. Interpret each terminal (i.e. letter) as a singleton set of that letter. Interpret juxtaposition as language concatenation. Interpret alternation as union. Finally, interpret the non-terminal $m$ via as $S(m)$. Let $sin N$ be the starting non-terminal. The language recognized by the BNF is the least (pre-)fixed point of $g$ evaluated at $s$ where the ordering is the pointwise subset ordering.



      This is just the straightforward set-theoretic rendition of a collection of mutually inductively defined sets. Sure enough, if we use the BNF: $s ::= 0 mid 1 s$ with alphabet ${0,1}$, the least (pre-)fixed point property of the resulting language is essentially (the set-theoretic variant of) mathematical induction (of natural numbers). Call the resulting language $L$. The least pre-fixed point property states that for any set $S$ such that ${0}cup({1}frown S)subseteq S$ where $frown$ is language concatenation, $Lsubseteq S$.






      share|cite|improve this answer









      $endgroup$
















        1












        1








        1





        $begingroup$

        For simplicity, assume each non-terminal occurs exactly once as the left hand side of a BNF rule. (This just means that all the rules are joined together with alternation.) Let $N$ be the set of non-terminals and identify the terminals with the alphabet $Sigma$. Define a set function $g:mathcal P(Sigma^*)^Ntomathcal P(Sigma^*)^N$ by setting $g(S)(n)$ to the following interpretation of the right hand side of the rule for the non-terminal, $n$. Interpret each terminal (i.e. letter) as a singleton set of that letter. Interpret juxtaposition as language concatenation. Interpret alternation as union. Finally, interpret the non-terminal $m$ via as $S(m)$. Let $sin N$ be the starting non-terminal. The language recognized by the BNF is the least (pre-)fixed point of $g$ evaluated at $s$ where the ordering is the pointwise subset ordering.



        This is just the straightforward set-theoretic rendition of a collection of mutually inductively defined sets. Sure enough, if we use the BNF: $s ::= 0 mid 1 s$ with alphabet ${0,1}$, the least (pre-)fixed point property of the resulting language is essentially (the set-theoretic variant of) mathematical induction (of natural numbers). Call the resulting language $L$. The least pre-fixed point property states that for any set $S$ such that ${0}cup({1}frown S)subseteq S$ where $frown$ is language concatenation, $Lsubseteq S$.






        share|cite|improve this answer









        $endgroup$



        For simplicity, assume each non-terminal occurs exactly once as the left hand side of a BNF rule. (This just means that all the rules are joined together with alternation.) Let $N$ be the set of non-terminals and identify the terminals with the alphabet $Sigma$. Define a set function $g:mathcal P(Sigma^*)^Ntomathcal P(Sigma^*)^N$ by setting $g(S)(n)$ to the following interpretation of the right hand side of the rule for the non-terminal, $n$. Interpret each terminal (i.e. letter) as a singleton set of that letter. Interpret juxtaposition as language concatenation. Interpret alternation as union. Finally, interpret the non-terminal $m$ via as $S(m)$. Let $sin N$ be the starting non-terminal. The language recognized by the BNF is the least (pre-)fixed point of $g$ evaluated at $s$ where the ordering is the pointwise subset ordering.



        This is just the straightforward set-theoretic rendition of a collection of mutually inductively defined sets. Sure enough, if we use the BNF: $s ::= 0 mid 1 s$ with alphabet ${0,1}$, the least (pre-)fixed point property of the resulting language is essentially (the set-theoretic variant of) mathematical induction (of natural numbers). Call the resulting language $L$. The least pre-fixed point property states that for any set $S$ such that ${0}cup({1}frown S)subseteq S$ where $frown$ is language concatenation, $Lsubseteq S$.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 29 '18 at 12:32









        Derek ElkinsDerek Elkins

        17.2k11437




        17.2k11437






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3053496%2fmodel-bnf-formally-in-mathematical-terms%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen