Skip to main content

Logic and Reasoning in AI + programming




After I finished any undertaken work, I always ask myself; “what did I learn? What was the main point about this?” for example about university, end of this year I asked myself what did I learn from my second year in university? And specific about a module which is our main subject “Formal aspect of computer science” (http://scom.hud.ac.uk/scomtlm/cia2326/) with Professor Lee McCluskey. Although I know that I learnt a lot from this module and I almost understand all subjects in this module, but it’s hard to show because all are formula and mathematical, here we are talking about “First Order Logic”, “Clausal Form and Unification”, “Resolution and the Refutation Method”, “Algebraic Specifications” and etc.. A few weeks back, while I was programming I found some logic which seems to be hard, it was a page which only user and admin could access that page. If I need to allow all user access that page, I could write something like this; by assuming I know $user from the session $user=$_SESSION[‘user’] $admin=$_SESSION[‘admin’] Now we could write something like this(picture below) But I have a restriction here(for some reasons); I cannot use else statement, how do we solve this issue? According to what I learnt from "Formal aspect of computer science" module, I can use these formula; These are some well known equivalent FORMS in FOL called laws ( De Morgans laws etc) ¬ ( P & Q ) = ¬P V ¬Q ¬ ( P V Q ) = ¬P & ¬Q P=>Q = ¬P V Q ¬ ¬ P = P P <=> Q = (P=>Q)&(Q=>P) etc Logic and Reasoning in AI So I can easily use above fomula and solve the problem, I know that this example is obvious but my main point here is; to say that when I reached where I had to think about solving this problem, the first thing came in my mind was this module. I also used this logic(above laws) in retrieving data from database(using MySQL code). You are welcome to leave a comment and share your thought.

Comments

Popular posts from this blog

Why I don't have social media account?

Just to be clear, I do not have any social media accounts except LinkedIn. No Facebook, Twitter, Instagram etc. 
I used to use some of them but I dropped them all before 2013 and now I am clean for over 4 years. I kept LinkedIn because I use for business contact only.
Today, I came cross this video and found quite interesting as I agree with what he says. 

I always said, the social media website/app specially Facebook and Instagram are just a game. It's funny how some users write the fake status which they don't believe it themselves but other believe it and vice versa. 
If you are making money or adding value to your life by using these apps, then use it otherwise don't kid yourself and just get rid of them, simply. I know it's hard in the beginning but trust me, it worth it, you are not alone. 


I solved GCHQ puzzle and this is how I did it

Today, I was reading the BBC news and I stumbled upon this GCHQ puzzle:
Take the digits 1,2,3 up to 9 in numerical order and put either a plus sign or a minus sign or neither between the digits to make a sum that adds up to 100. For example, one way of achieving this is:
1 + 2 + 34 - 5 + 67 - 8 + 9 = 100, which uses six plusses and minuses. What is the fewest number of plusses and minuses you need to do this? I love to challenge myself with these kind of puzzles, so I solved this and here is how:
We have 9 numbers [1 to 9] and also we have three possible separators [+, - and nothing] which to fill the gap between numbers we have 8 combinations of separators, e.g. we have 1+2+3+4+5+6+7-89 which in this case we have six times plus, one minus and one time nothing. 
So, I need to find all possibilities of combination which total is: 6561

Then, hook the possible combinations into numbers and check the total, easy enough. Now print the solution.
I have written this algorithm in PHP but ea…

Laptop touchpad issue on Linux

I installed Linux (Ubuntu 16.4 LTS) on my new laptop, Fujitsu E series, all went well apart from touchpad which did not work at all. I spend few hours searching (AKA Googling) but could not find any hope. That was embarrassing for me who called himself professional Linux user but cannot fix touchpad issue, what about typical Linux user? there must be way, so I kept searching and reading until finally I found the fix and all is working now. Here is the fix if anyone has similar issue:

In cammed line, run:
sudo modprobe -r psmouse

It should work fine for now but only for current session, it may not work after restarting your laptop, so to add permanent fix, do:sudo vim /etc/modprobe.d/psmouse.conf

And add following, then save and exit.

options psmouse proto=imps


I used vim, you can use your favourite text editor such as gedit, vi etc. I hope this helps someone and save their time. Read more on modprobe.


Thank you for reading this, as always happy to hear from you.