Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CA 208 Logic Logic Prof. Josef van Genabith Textbooks:  The Essence of Logic, John Kelly, Prentice Hall, 1997  Prolog Programming, Third Edition, Ivan.

Similar presentations


Presentation on theme: "1 CA 208 Logic Logic Prof. Josef van Genabith Textbooks:  The Essence of Logic, John Kelly, Prentice Hall, 1997  Prolog Programming, Third Edition, Ivan."— Presentation transcript:

1 1 CA 208 Logic Logic Prof. Josef van Genabith Textbooks:  The Essence of Logic, John Kelly, Prentice Hall, 1997  Prolog Programming, Third Edition, Ivan Bratko, Addision-Wesley, 2001 Lecture Wednesday Tutorials/Labs Friday

2 2 CA 208 Logic Course Structure Propositional Logic First-Order Predicate Logic Prolog (Programming in Logic) Assessment 50% Continuous assessment (~ week 8) 50% Final Exam

3 3 CA 208 Logic Why Logic? What is Logic used for? Computers (Hardware/chips/CPUs etc.) are made of Logic (nand/nor gates etc.) You can program in Logic: Prolog (one of the main programming paradigms:  Procedural/imperative: Basic, Fortran, Pascal, C,...  Object oriented: C++, Java,...  Logic: Prolog  Functional: Lisp, Miranda, Haskell,... Artificial Intelligence AI  Intelligence = learn and reason (Machine learning and logic) Deep connection between abstract models of computation and logic/proofs: Curry-Howard correspondence Logic is foundation of maths People use logic... …

4 4 CA 208 Logic Logic Today: Intuitions... Jargon... If you get these right, Logic is easy!!! Formalisation comes after intuitions...! Not so well covered in the text books

5 5 CA 208 Logic What is logic? Logic is the science of reasoning / inferencing / drawing conclusions We do this all the time... What is involved in reasoning? Premises and Conclusions Premises: what you hold to be true Conclusions: what you derive from the premises

6 6 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. We say that “P entails C”, “C logically follows from P”, “C is derived from P”, “C is inferred from P”, etc. We write “P |= C” or “P|- C” ((double) turnstile)

7 7 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. There are many types of Logic... Classical Logic, intuitionistic logic, linear logic, non- monotonic logic, defeasible logic, fuzzy logic,... There is a whole zoo of logics!

8 8 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. There are many types of Logic... In this course we look at classical Logic(s) only ! (In AI, KR you may come across some of the other logics).

9 9 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. What is classical Logic? Classical Logic studies/characterises/defines valid reasoning Valid reasoning is a very strict type of reasoning where truth of the premises guarantees truth of the conclusions (if you use the rules of classical logic to do the reasoning, i.e. to derive the conclusion!)

10 10 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. Our example is a valid inference! Why? Well, if the premisses are true, then the conclusion is true In other words: it cannot be the case that all the premisses are true and the conclusion is false

11 11 CA 208 Logic An example: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. Our example is a valid inference! Why? In all the situations where the premisses are true, the conclusion is true as well In other words: it cannot be the case that there is a situation where all the premisses are true and the conclusion is false

12 12 CA 208 Logic Another example: P: If John goes to the party then Mary goes to the party. Mary goes to the party. C: John goes to the party. Is this a valid inference? I.e. does truth of premisses guarantee truth of conclusion? Can you come up with a situation where P is true and C is false? ?

13 13 CA 208 Logic Another example: P: If John goes to the party then Mary goes to the party. Mary goes to the party. C: John goes to the party. Is this a valid inference? I.e. does truth of premisses guarantee truth of conclusion? Can you come up with a situation where P is true and C is false? Yes... !!!!

14 14 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. Logicians (like mathematicians, computer scientists/programmers, engineers) are lazy... They don’t like to write very much... They like abstraction and generalisation... They don’t like specific cases... So how do they/can we generalise this logic stuff?? We express that reasoning stuff as formulas ;-)

15 15 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. Premisses and conclusions are made up of complex and elementary “propositions” or ”statements” What are propositions/statements? Sentences that are true or false

16 16 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party.

17 17 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party.

18 18 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party.

19 19 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party.

20 20 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party.

21 21 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. How: look at the components of the premisses and conclusion Special symbols (if __ then __ ) Component propositions/statements: John goes to the party = A Mary goes to the party = B

22 22 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. P: {If A then B, A} C: B A = John goes to the party B = Mary goes to the party

23 23 CA 208 Logic Formalisation: P: If John goes to the party then Mary goes to the party. John goes to the party. C: Mary goes to the party. P: {If A then B, A} P |= C C: B {If A then B, A} |= B A = John goes to the party B = Mary goes to the party

24 24 CA 208 Logic And now sth. absolutely amazing happens: P: {If A then B, A} C: B A = John goes to the party, B = Mary goes to the party A = Kate is a CA2 student, B = Kate does Logic P: If Kate is a CA2 student, then Kate does Logic. Kate is a CA2 student. C: Kate does Logic. Is that a valid inference?

25 25 CA 208 Logic And now sth. absolutely amazing happens: P: {If A then B, A} C: B A = John goes to the party, B = Mary goes to the party A = Kate is a CA2 student, B = Kate does Logic P: If Kate is a CA2 student, then Kate does Logic. Kate is a CA2 student. C: Kate does Logic. Is that a valid inference? YES!!!!

26 26 CA 208 Logic And now sth. amazing happens: P: {If A then B, A} C: B A = John goes to the party, B = Mary goes to the party A = Kate is a CA2 student, B = Kate does Logic You get another valid inference! In fact you get loads of valid inferences from the abstract {If A then B, A} |- B schema above by replacing the propositional variables with actual propositions... The old Greeks copped on to that some 2500 years ago... Aristotle, rules/mathematics of inference, syllogisms,..., rules that guarantee that if you apply them to true premises you get true conclusions !!! (Aside the Greeks didn’t get all of them right)

27 27 CA 208 Logic And now another amazing thing happens: Logic is not just about the “real” world! You can consider premises that are not true in real world: P: {If A then B, A} C: B A = Kate is a CA2 student, B = Kate does Formal Languages P: If Kate is a CA2 student, then Kate does Formal Languages. Kate is a CA2 student. C: Kate does Formal Languages. P |- C, i.e. this is a vaild inference but: but C not true in “real” world. Kate could be CAIS student! So Logic allows us to explore hypothetical scenarios: for the sake of the inference, imagine situations where all of the premises in P are true...

28 28 CA 208 Logic Another example... P: John likes soccer and John likes Kate. C: John likes Kate. Is that vaild? Formalise: P: { A and B } P |- C C: B { A and B } |- B Another one... A = Kate is a student, B = Kate likes the bar What about { A and B } |- A ? Is that valid?

29 29 CA 208 Logic Another example... P: John likes soccer. John likes Kate. C: John likes soccer and John likes Kate. Formalise: P: { A, B } C: A and B P |- C { A, B } |- A and B A = Kate is a student, B = Kate likes the bar What about { A, B } |- B and A ? Is that valid?

30 30 CA 208 Logic What are propositions/statements? Statements/Propositions are sentences that are either true or false!  John likes soccer.  Kate is a CA student. Not all sentences are propositions/statements: Questions/Interrogatives:  Is Kate a CA student? Commands/Imperatives:  Give John a copy of the exam! Classical logic is only about statements/propositions!!! The only thing you can have in the premises and conclusions are statements and special connection words (like if _ then _, and..)

31 31 CA 208 Logic What are the special connection words? _ and _ (A and B) _ or _ (A or B) if _ then _ (if A then B) _ if and only if _ (A iff B) not _ (not A)

32 32 CA 208 Logic You have seen this before: Logicians are lazy... A and B A  B A or B A  B if A then B A  B (P implies Q) A iff B A  B not A  A Note that different books may use different symbols, e.g. & for ,  for  and the like... That is just to confuse you...

33 33 CA 208 Logic So with this we can write {A  B, A} |- B {A  B } |- A {A  B } |- B {A, B} |- A  B And the like...

34 34 CA 208 Logic What is the “meaning” of the logical connectives      ? We’ll define the meaning of the connectives in two ways: Truth tables (Semantics, |= ) Proofs (Syntax, |- ) Meaning of the logical connectives is not exactly like the meaning of not, and, or, implies etc. in English (natural language)... We’ll see examples of that!

35 35 CA 208 Logic What’s a truth table? A truth table shows all possible situations in which the proposional arguments of a logical connective are true or false and defines the truth value of the complex proposition in terms of these. Intutively the complex proposition John likes football and Mary likes the bar is true in all situations where ‘John likes football’ is true and where ‘Mary likes the bar’ is true, and false in all other situations. P  Q is true in all situations where P is true and where Q is true, and false in all other situations. There can be infinitely many situations in which P, Q are true – we don’t want to look at all of them...! Truth tables cluster them together and capture what is essential about them.

36 36 CA 208 Logic We capture this in a truth table. We write ‘1’ for true and ‘0’ for false (or T, F) Truth table for  PQ PQPQ 11 10 01 00

37 37 CA 208 Logic We capture this in a truth table. We write ‘1’ for true and ‘0’ for false (or T, F) Truth table for  PQ PQPQ 111 100 010 000

38 38 CA 208 Logic Question: Is P  Q = Q  P ? Logical equivalence, same meaning Use truth table... PQ PQPQQPQP 111 100 010 000

39 39 CA 208 Logic Question: Is P  Q = Q  P ? Logical equivalence, same meaning Use truth table... Hence P  Q = Q  P We say that P  Q and Q  P are logically equivalent, i.e. They have the same truth value (i.e. meaning) under each interpretation (situation) We write (P  Q)  (Q  P) Temporal aspect of natural language ‘and’... PQ PQPQQPQP 1111 1000 0100 0000

40 40 CA 208 Logic PQ PQPQ 111 101 011 000 PQ PQPQQPQP 1111 1011 0111 0000 Sometimes exclusive aspect of meaning of natural language ‘or’... Logical or is inclusive...

41 41 CA 208 Logic PQ PQPQ 111 100 011 001 PQ P  QQ  P 1111 1001 0110 0011 Natural language implication has often element of causality... Logical implication doesn’t... !!!!

42 42 CA 208 Logic PQ PQPQ 111 100 010 001

43 43 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 11 10 01 00

44 44 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 111 100 010 000

45 45 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 1111 1001 0101 0000

46 46 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 11111 10010 01011 00001

47 47 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 111111 100100 010110 000011

48 48 CA 208 Logic P PP 10 01 P PP   P 101 010

49 49 CA 208 Logic PQ PQPQPQPQPQPQPQPQ 111111 100100 010110 000011

50 50 CA 208 Logic A (Boolean) algebra of Logic Commutativity Associativity Distributivity Idempotency Absorption... PQ PQPQPQPQPQPQPQPQ 111111 100100 010110 000011


Download ppt "1 CA 208 Logic Logic Prof. Josef van Genabith Textbooks:  The Essence of Logic, John Kelly, Prentice Hall, 1997  Prolog Programming, Third Edition, Ivan."

Similar presentations


Ads by Google