Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lets say there is a function
- bool halts(const char* program, const char* input);
- which always returns true, if "program" when compiled with gcc, halts given the "input" on stdin.
- and always returns false, if "program" when compiled with gcc, runs forever.
- Let's define:
- bool invert(bool x){
- if ( x ){
- for(;;){}
- }
- return true;
- }
- Now, lets write in a file "test.c" source code for halts, and invert, and this main function:
- int main(int arg, char* argv[]){
- char* s = read_everything_from_stdin();
- invert(halts(s, s));
- return 0;
- }
- Now lets run "gcc test.c -oa.exe && a.exe <test.c"
- Now halts(s, s) evaluates if "test.c" with "<test.c" as input exits or runs forever.
- If it returns "true", then invert(true) halts, so halt was wrong.
- If it returns false, then invert(false) returns, so halt was wrong.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement