1 / 18

Predicate Logic for software Engineers

Predicate Logic for software Engineers. Sagnik Bhattacharya Siddharth Dalal. Why logic in software engineering?. Engineers need mathematical tools. Theoretical, yet quantitative study of software. Parnas says so….

mea
Download Presentation

Predicate Logic for software Engineers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Predicate Logic for software Engineers Sagnik Bhattacharya Siddharth Dalal

  2. Why logic in software engineering? • Engineers need mathematical tools. • Theoretical, yet quantitative study of software. • Parnas says so…. From a drop of water a logician could infer the possibility of an Atlantic or a Niagara without having seen or heard of one or the other. - Sir Arthur Conan Doyle

  3. Problems with existing logic • Logicians are conservative? • Lacks precise meaning for logical expression. (* values) • Complexity of expressions. • Assumption of total functions. There can never be surprises in logic.

  4. Parnas Proposes…. • Get rid of *(maybe) values. • Use partial functions. • Make use of bounded quantification optional. 'Contrariwise', continued Tweedledee, 'if it was so, it might be, and if it were so, it would be; but as it isn't, it ain't. That's logic!' - Lewis Carroll - Alice in Wonderland

  5. Basics • Predicate – A predicate is a feature which we can use to make a statement about something. “Peter is tall” • The property that an animal is a dog can be expressed by the predicate: dog(x) This predicate holds for all animals x which are dogs. For other animals, the predicate is false Logic is the art of going wrong with confidence.

  6. Propositional Logic • A proposition  is a language construct which can be assigned a truth value • More complex propositions can be formed by applying the logical operators (¬, , , etc..) • Propositional logic formula • Eg. ¬((a  b)  c) Against logic there is no armor like ignorance.

  7. Predicate Logic • Predicate logic  is a more powerful formalism which is obtained by extending propositional logic with • “Predicates”  which describe properties or relations of objects in a certain domain ; • “variables”  ranging over arbitrary domains; • the possibility to quantify over “variables”. Logic: The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding.

  8. Quantifiers • We distinguish two quantifiers: • universal quantifier:  • existential quantifier:  The grand aim of all science is to cover the greatest number of empirical facts by logical deduction from the smallest number of hypotheses or axioms.

  9. Quantifiers • We distinguish two quantifiers: • universal quantifier:  • existential quantifier:  • Example: • There exists an integer x divisible by 5. x | divisible_by(x,5) • All integers y are divisible by 1. y | divisible_by(y,1) The grand aim of all science is to cover the greatest number of empirical facts by logical deduction from the smallest number of hypotheses or axioms.

  10. Tuples • U = {true, false} • Simple n-tuple • Ordered list of n members of U Eg. <true, false, true, true> • n-tuple • Ordered list of n simple tuples • Eg. <<true, false>, true, <false, true>> Logic works, metaphysics contemplates.

  11. Exercise • <<true, false, <true, false>>, true, <true, <false, true>>> • 3-tuple (not simple) • “true”, “<true>”, “<<true>>” • Equivalent simple 1-tuple!! The fact that logic cannot satisfy us awakens an almost insatiable hunger for the irrational.

  12. Relations and Functions • Difference? • Function can’t be one-to-many. • Partial vs. Total Functions • Partial functions not defined for all values in domain e.g. Division over integer domain not defined for 0 The want of logic annoys. Too much logic bores. Life eludes logic, and everything that logic alone constructs remains artificial and forced.

  13. Predicates Revisited • Predicate – function whose range contains no member other than true and false • Characteristic Predicate (R) • X=set of simple tuples • Sk=set of all simple k-tuples • S=S1S2 …….. Su • u=length of largest tuple in X • R is a predicate whose domain is S and for every b  X the value of R is true There can never be surprises in logic.

  14. Primitive Expressions • Primitive Expression is a string of the form R(V) • R is a characteristic predicate • V is a list of comma separated terms (called arguments) e.g. divisible_by(x, 5) Logic is like the sword--those who appeal to it, shall perish by it.

  15. Predicate Expressions • All primitive expressions are predicate expressions. • If P, Q: predicate expressions, x: variable, then following are also predicate expressions: • (x , P) – (P) • (P)  (Q) – (P)  (Q) • ¬(P) • There are no other predicate expressions. • What about (x , P) ??? Logic is neither a science or an art, but a dodge.

  16. Use in Documentation Logic merely enables one to be wrong with authority.

  17. Use in Documentation • What next after simple search? • Palindrome • (m, (i, 0<=i<n  B[m+i]=N[m+n-1-i])) • A7E?? • Where in Documentation? • What about non-inspection operations? Logic, like whiskey, loses its beneficial effect when taken in too large quantities.

  18. Conclusion • Keep it Simple • Was the use of this type of logic useful? • What about more complicated programs? • Was it more precise? • Was it easier to understand? You can only find truth with logic if you have already found truth without it.

More Related