I'm studying Turing Machines and I've already showed how Turing-Decidable is closed for the operations of Union, Intersection, Concatenation, Complement and Kleene Star. Next I did some demonstrations to show how T-Recognizable languages are closed for Union, Intersection, Concatenation and Kleene Star.
Now I'm trying to answer a question to show why the classe of T-Recognizable languages are not closed for the operation of Complementation, but I cannot understand it. Could someone please explain this?
Thanks
T-recog corresponds to semi-decidable (r.e.).
Convince yourself that a language is exaclty then decidable, when both, the language itself and its relative complement are r.e.
Convince yourself that there are r.e. languages that are not decidable (e.g. Halteproblem)
Assume that the class of r.e. languages is closed under complementation and derive a contradiction to the facts mentioned in 2. and 3.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
As far as I know, it is almost true that any code that can be represented in the LLVM intermediate language, can also be represented in C, with two important exceptions:
Exceptions. (No pun intended.)
Signed integer arithmetic with well-defined behavior on overflow.
Is there anything else that can be represented in LLVM but not in C?
In addition to exception handling, other big features are garbage collection and out-of-the-box coroutines. Going to a lower level, there are trampoline intrinsics, patch points for JITs, and direct support for Obj-C ARC Runtime intrinsics.
C is Turing complete, so all of these things can be introduced to C with libraries and so on, but I put them as they are part of the LLVM language.
Metadata for example, including LLVM's branch-weight and debugloc metadata.
Except that they can if you're willing to be tortuous enough about the C you write. I think that's general: IF you're willing to write really tortuous, unidiomatic C, THEN you can write anything. So I vote to close this as unclear.
EDIT: Most things probably are expressible in C given enough discipline, verbosity and preprocessing directives, but I wonder about aliasing.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a project where I will create a truth table, and the user will input propositions and its operator and my program will output the truth values providing with a truth table.
I have following questions:
can I use parsing techniques using turbo c?
how should I parse this expression in turbo c? Ex. (p ^ q) -> r
Once I have the expression parsed, how should I go about generating the truth table? Each section of the expression needs to be divided up into its smallest components and re-built from the left side of the table to the right. How would I evaluate something like that?
Can anyone provide me with tips (or links) concerning the parsing of these arbitrary expressions and eventually evaluating the parsed expression?
Let me try to answer your questions.
Yes. There is no reason why you can't.
You need to write some sort of lexer to turn the expression into tokens. Then you can use the shunting yard algorithm to turn the expression into something you can easily evaluate.
Use the result from (2) and evaluate it in a little stack machine. Set each free variable to all possible combinations to generate a truth table.
Parsing arbitrary languages is not possible in general. A good introduction into compiler construction (which is the subfield you are interested in) is found in the Dragon Book (Compilers: Principles, Techniques, and Tools). It's a large field though, I recommed you to take a compiler construction class.
Also, consider ditching Turbo C for something recent. Turbo C is ancient and full of weird quirks.
This question already has answers here:
C/C++ Bit Array or Bit Vector
(5 answers)
Closed 9 years ago.
I looked online for a good while now, and can't seem to find a good example of what a bit vector actually is.
I have an assignment to do for college which is to add, remove, union of 2 vectors and the intersection too. But I am struggling to comprehend what an actual bit vector is. I am using C to write this.
Could someone please help me on this, it would be a massive help.
Bit vector is a structure which purpose is an accessability of individual bits. Implementation-wise it can be an integer array with some function provided for addressing and manipulation of individual bits of the array. To the final user the array has to look as a "string" of bits, and the functions have to be able to access arbitrary nth bit of the "string".
There is a bitset class in the standard library of C++ which represent this concept, but I am not aware of some option in C language.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
So, across my programming experience I have come across two types of type annotations for statically typed languages: I call them 'before' and 'after'. C-Style languages use the format
int i = 5
While most non-c-family languages use the format
var c:int = 5
Examples of the former category would be C, C++, Java; examples of the latter category would be Scala, Haxe, Go.
This may seem to some to be superficial, but my question is: what are the advantages of each style? Why use one over the other? Why did C adopt that style in the first place?
The machine doesn't care - it's just that people who designed certain languages felt that some types of syntax are better or more easily readable than the others. Modern compilers usually have several stages of processing, and almost all of this syntactic differences are usually lost after the first stage, which parses text and converts then into compiler internal structures (AST - abstract syntax tree).
There are some historical precedences, e.g. the "prefix" vs "infix" vs "postfix" notation (http://en.wikipedia.org/wiki/Polish_notation, http://en.wikipedia.org/wiki/Infix_notation, http://en.wikipedia.org/wiki/Reverse_Polish_notation) which in the context of computer engineering history were used in edge cases - e.g. the "infix" notation is usually harder to parse and requires more memory than the postfix/RPN notation so it was not used where resources were really scarce (several KiB of memory or less), but most of those reasons are now obsolete as hardware is powerful enough.
Today, when designing a language, the choice of such syntax details is influenced by trying to make the language similar to some other popular language or group of languages for which there are already existing programmers, to avoid making a "language from Mars" which few people will use.
tl;dr: Depends on the person who created the language and what he though is more readable or "the right thing to do").
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am fascinated by the way people obfuscate their code (mostly, C) (examples here : http://ioccc.org/) and would like to learn the various techniques for the same. I have been told of a book, "Obfuscated C and other Mysteries", but I am not able to get that book.
Are there any tutorials or books that give hints on this topic?
Thank you.
The best you can do is read the comments of the author of the programs on IOCCC. They describe how they manage to obfuscate their code. Here are a few pointers:
Short and meaningless identifiers
Because a=aaa*aa; will always be more obfuscated than result = value * factor;
In order to have short identifiers, obfuscators tend to even #define many things.
Reversed array indexing
You just have to remember that var[3] and 3[var] are equivalent.
Digraphs and trigraphs
if(a< <:b+aa??))??<f();%>
should be less readable than:
if (a < (b+aa)) { f(); }
Look-alike characters
Sometimes, it's hard to tell appart l, 1 and I or o, 0 and O. For example, if you write 10l, I bet everyone will read 101 instead.
Coding style guidelines
Generally speaking, just try to find good coding guidelines and to try to violate them all. Those documents that you could find anywhere on the web could help you more than most things and would allow you not to buy anything.
Here are some links:
How to write unmaintainable code.
Morwenn's answer nicely covers obfuscation of syntax. But there is another level, and that is semantic obfuscation. Consider that the oft-mentioned Turing Machine has the same computational power as any other programming language (ignoring considerations of input and output). In fact all of the various models of computation have sibling models with equivalent power.
For example, a string char s[N] can be considered a mapping from indices to characters, so any string can be represented instead by a function which always delivers the appropriate character when called with a specified index char f(int i). Now read this. Crazy, right?