English to Predicate Logic - logic

I want to make a program to translate English sentences into predicate logic expressions. I've done a lot of searching and all I've found were explanations of how to translate specific sentences. I haven't found any tutorials on how to make an AI that does this, and translating every sentence manually seems tedious. Has this been done before? If so, how?

Related

How can TF-IDF be used for programming source code plagiarism detection?

i briefly understand how TF-IDF works, for detecting plagiarism in articles, it does make sense.
Now i was told to use it against programming source code, how can this work ? In article most words are natural language words say English, you can count these words. Now in source code, each person can define all kinds strange variable names, so this counting of the words doesn't make much sense to me.
Even if i just want to count function name, my own function name could be strange as well, while system/library function names are useful for TF.
Anyone can help to explain more ? Thanks !

Convert Processing sketch to ruby-processing sketch

Having discovered Processing, and in the middle of trying to learn ruby, I naturally installed ruby-processing for Processing 2.2 (not 3 which requires JRubyArt as the alternative to ruby-processing as I understand).
I am hoping to kill two birds with one stone and create Processing sketches whilst learning more ruby.
However it would be really useful to translate example Processing sketches into ruby so I can then play with them. At the moment I am doing it manually. Does anyone know of a script to do this?
Short answer: no.
This kind of translation is not trivial. Generally, you can't really translate the syntax of one language into the syntax of a different language. You don't go line-by-line and simply change the code one line at a time. That makes what you're asking pretty difficult, so you probably won't find many tools that do stuff like that.
Instead, to translate a program from one language to another, you have to think about the semantics, not the syntax. You have to ask yourself "what does this program do?" and then you simply write a program that does the same thing in the target language. It's not a one-to-one syntax mapping.
In fact, if you're trying to learn, that's a pretty great exercise. The examples that come with Processing are pretty small, so it should be relatively straightforward. Here is what I would do if I were you:
Take an existing example Processing sketch.
Write down in English (not pseudocode) what the program does. Be as specific as possible. Break things down into a list of small steps, and break those steps down into even smaller sub-steps whenever possible. You should be able to hand your list to somebody who has never seen the sketch, and they should be able to tell you in their own words exactly what the sketch does.
Take that list and treat that as your programming assignment, and implement it in your target language. If you get stuck on one of the specific steps, post an MCVE and we'll go from there.
So, translating code involves a middle step of translating it into English first, which is why tools like what you're asking for are much more difficult than you might first think.

software or algorithms to detect grammar units in texts

I'm not sure this is the right fit for stackoverflow but maybe you guys would suggest where to put this question otherwise but here it is anyway. Suppose I have a few sentences of a text like this:
John reads newspapers everyday. Right now he has just finished reading
one. He will read another one and might even read a small book
tomorrow.
This small extract contains the following grammar units:
present simple (reads)
present perfect (has finished)
future simple (will read)
modal verb may
Do you know of any software, algorithm or study that defines rules for identifying these grammar patterns?
Read this also if you are going to use Ruby than you can use TreeTop or find the equivalent parser in other programming language.
NTLK is a natural language parser for python, it works by tagging words. You can look at some examples here. It creates a parse-tree, which are very useful for these types of problems.
I haven't seen it distinguish between simple and perfect, but it could be modified to do so.

Prolog basic questions

First, what do you recommend as a book for learning prolog. Second, is there an easy way to load many .pl files at once? Currently just doing one at a time with ['name.pl'] but it is annoying to do over and over again. I am also using this to learn.
Thanks
First, welcome to Prolog! I think you'll find it rewarding and enjoyable.
The books I routinely see recommended are The Art of Prolog, Programming Prolog and Clause and Effect. I have Art and Programming and they're both fine books; Art is certainly more encyclopedic and Programming is more linear. I consult Art and Craft a lot lately, and some weirder ones (Logic Grammars for example). I'm hoping to buy Prolog Programming in Depth next. I don't think there are a lot of bad Prolog books out there one should try to avoid. I would probably save Craft and Practice for later though.
You can load multiple files at once by listing them:
:- [file1, file2, file3].
ALso, since 'name.pl' ends in '.pl' you can omit the quotes; single quotes are really only necessary if Prolog wouldn't take the enclosed to be an atom ordinarily.
Hope this helps and good luck on your journey. :)
If you are incline to a mathematical introduction, Logic, Programming and Prolog (2ED) is an interesting book, by Nilsson and Maluszinski.
Programming in Prolog, by Clocksin and Mellish, is the classic introductory textbook.
In SWI-Prolog, also check out:
?- make.
to automatically reload files that were modified since they were consulted.
You can check out this question. There are several nice books recommended back there.
This is a nice short little intro: http://www.soe.ucsc.edu/classes/cmps112/Spring03/languages/prolog/PrologIntro.pdf
I also want to say there's a nice swi oriented pdf out there, but I can't find it.
I won't repeat the classic choices already mentioned in other answers, but I will add a note about Prolog Programming in Depth by Michael Covington, Donald Nute, and Andrew Vellino. Two chapters I would like to highlight are the chapters on hand tracing and defeasible rules. The former shows you how to trace out a Prolog computation on pencil and paper in an efficient and helpful manner. The latter shows you how to create Prolog code that supports defeasible rules. Unlike the rules you are accustomed to in Prolog that either succeed or fail outright and are not affected by anything not stated in the rule itself, defeasible rules can succeed on the information stated in the rule yet can be undercut by other rules in the knowledge base making the expression that are generally true but have exceptions easier in a manner that is compact and easy to understand. Said better by the book "A defeasible rule, on the other hand, is a rule that cannot be applied to some cases even though those cases satisify its conditions, because some knowledge elsewhere in the knowledge base blocks it from applying."
It's an intriguing concept that I have not found in other books.

Becoming operational in Prolog quickly

My company has a project running in Prolog and I want to clarify few things about how to go about learning it. I know Prolog is different. It should not be learnt just like any other language.
Having said that, and considering the fact that I did not lay my hands on any Prolog book yet, Is there any book or online resource, where I can learn Prolog the way how we learn C/C++? What I mean is , just to be operational in C/C++, you just need to know the structure of the program, like main { } , loops, conditions, branches, and few functions that you can use to start writing basic programs in C/C++.
Just this way can I learn Prolog and is there any book that just gives me an idea how to Program in Prolog? (basics, loops, how to implement conditions, program structure, what's predicate? how to use it? how to define it? and so on...).
If you're after a single book, I can highly recommend "The Art of Prolog":
Coming to Prolog from something like C/C++ isn't just a matter of learning a programming language. It's a wholly different way of thinking about programming.
Prolog is about asking the computer questions (or 'queries' if you like). Computation is almost a side-effect of the computer trying to answer your question. There is no meaningful equivalent to loops or conditionals because a prolog programmer wouldn't think in those terms.
A good Prolog program looks like a description of the problem that you're trying to solve decomposed into recursive cases and subproblems rather than lists of instructions organised into functions or classes.
The best way to learn Prolog is to set aside all your previous programming experience. Actually thinking about C and C++ will make Prolog harder to learn and use. Try to adopt a beginner's mind and maybe an approach more like an algebraist than a programmer.
As a supplement to the Prolog tutorials and textbooks mentioned in the other answers, I would suggest having a quick look at this short document:
Prolog for Imperative Programmers
I think it's part of what you're looking for. It won't teach you Prolog, but it will help bridge the gap to understanding Prolog. It describes the basics of Prolog using terminology that experienced non-Prolog programmers would understand. For example, it shows you control structures in Prolog, i.e. sequence, selection and repetition. It does assume that you've already started learning Prolog, though.
It's good if you want to understand something new in terms of something you already know. However, armed with this knowledge/understanding, there is a risk that you could end up writing C code in Prolog syntax. Good luck!
What's wrong with Learn Prolog Now, which is usually the top recommendation each time this kind of question gets asked?
It may not give you exactly the terminology you want -- I believe it doesn't even mention "predicate" (uses "Facts, Rules, and Queries" instead) or "loops" (it just shows how to use recursion instead) -- but getting the terminology right once the concepts are clear should be simple, fast, and easy, and "Learn Prolog Now" does seem to do a good job about making the concepts clear.

Resources