1) Set B is the finite set of all rules for a particular programming language.

2) Set A is the infinite set of all valid strings of that language and is defined by Set B.

I'm having a problem defining expressing that mathematically.

My so far unsuccessful idea:

  • Define a set C - the set of all possible strings.
  • set A is a finite union between infinite sets A_i such that for every rule B_i

$B_i ( C ) = A_i$

can It be defined with an implication ? for every rule B_i of B applied to every string c_i of C, if $B_i ( c_j ) \implies c_j$

  • 1
    $\begingroup$ To make this easier to read use latex formatting around your functions( put a dollar sign on each side of the function A_i becomes $A_i$ ) $\endgroup$ – lPlant Jun 27 '14 at 15:38
  • 1
    $\begingroup$ Also initially you say $A$ is the set of rules and $B$ is a set of strings, but then refer to rule $B_i$ applying a string to it to get a new rule which does not make sense. $\endgroup$ – lPlant Jun 27 '14 at 15:48
  • 1
    $\begingroup$ Can you explain in words the meaning of what you write formally. What are your rules supposed to look like and be used. What does it mean and/or produce when you apply a rule to a string. What is the meaning of defining something with an implication. Math is to some extent a Lego game, but you have to understand the shapes of the bricks to fit them together meaningfully. I am asking what shape you see to the bricks you propose to use, and how you propose to assemble them. $\endgroup$ – babou Jun 27 '14 at 17:44

The standard approach to formalize the syntax of a programming language involves using context-free grammars and context-free languages. I suggest reading a standard compilers textbook; it will discuss how to express the syntax of the programming language using techniques like context-free grammars, and that will provide you a lot of helpful context.

In particular, programming language syntax is typically formalized not by a set of "rules", but rather by a context-free grammar/language. The source code of a program must be in that language to be syntactically valid; if it isn't in the context-free language, it has a syntax error. See also Backus-Naur notation.

Take you a little while to read the material, and then I suspect you'll be in a better position either to make sense of this, or to pose a more specific question.

| cite | improve this answer | |
  • $\begingroup$ That is incorrect sir. From "Engineering a compiler, 2nd edition" - Mathematically, the source language is a set, usually infinite, of strings defined by some finite set of rules, called a grammar $\endgroup$ – SdSdsdsd Jun 28 '14 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.