Presentation is loading. Please wait.

Presentation is loading. Please wait.

Predicate Logic for software Engineers Sagnik Bhattacharya Siddharth Dalal.

Similar presentations


Presentation on theme: "Predicate Logic for software Engineers Sagnik Bhattacharya Siddharth Dalal."— 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 1.“Predicates” which describe properties or relations of objects in a certain domain ; 2.“variables” ranging over arbitrary domains; 3.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. n-tuple –Ordered list of n simple tuples –Eg., true, > Logic works, metaphysics contemplates.

11 Exercise >, true, >> –3-tuple (not simple) “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 –S k =set of all simple k-tuples –S=S 1  S 2  ……..  S u 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 B[j]=xtrue false (  i, B[i]=x)¬(  i, B[i]=x) j| present= 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.


Download ppt "Predicate Logic for software Engineers Sagnik Bhattacharya Siddharth Dalal."

Similar presentations


Ads by Google