predicate logic for software engineering david lorge parnas mcmaster university, ontario, canada

48
Predicate Logic Predicate Logic for Software for Software Engineering Engineering David Lorge Parnas David Lorge Parnas McMaster University, Ontario, Canada McMaster University, Ontario, Canada

Post on 19-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Predicate Logic for Predicate Logic for Software EngineeringSoftware Engineering

David Lorge ParnasDavid Lorge Parnas

McMaster University, Ontario, CanadaMcMaster University, Ontario, Canada

SPentapati
David Parnas is considered to be the father of software engg. He is a pioneer who has scores of papers written in this field.

Presentation for SwE Presentation for SwE Readings ClassReadings Class

By: Sridhar PentapatiBy: Sridhar Pentapati

03/21/03 Sri03/21/03 SriProgress in a scientific discipline can be measured by how quickly its founders are forgoProgress in a scientific discipline can be measured by how quickly its founders are forgottentten

33

About Dave ParnasAbout Dave Parnas

His insights have changed the way that we His insights have changed the way that we specify, design, document, build, and specify, design, document, build, and maintain softwaremaintain software

His techniques have changed modern His techniques have changed modern programming languagesprogramming languages

His wisdom has steered software His wisdom has steered software engineering fieldengineering field

03/21/03 Sri03/21/03 Sri Logic is in the eye of the logician. *Gloria Steinem Logic is in the eye of the logician. *Gloria Steinem 44

AbstractAbstract

Conventional interpretations of expressions Conventional interpretations of expressions that describe predicates are not suitable for that describe predicates are not suitable for use in software engineering because they use in software engineering because they do not deal with partial functions. Parnas’ do not deal with partial functions. Parnas’ team defines an interpretation for predicate team defines an interpretation for predicate expressions that is suitable for use in expressions that is suitable for use in software documentationsoftware documentation

03/21/03 03/21/03 'Contrariwise', continued Tweedledee, 'if it was so, it might be, and if it were so, it would'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 be; but as it isn't, it ain't. That's logic!' . *Lewis Carroll

55

IntroductionIntroduction

Predicate logic is a development of propositional logic, which we’re all well acquainted with

Sentences in predicate calculus are built up from atomic sentences

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 66

Introduction contd...Introduction contd...

Why logic in SwE?Why logic in SwE?1.1. Engineers need mathematical toolsEngineers need mathematical tools

1.1. for the description and analysis of their productsfor the description and analysis of their products

2.2. Mathematical logicMathematical logic is the basis of all proposed is the basis of all proposed toolstools

1.1. A solid foundation of logic notation will be essential A solid foundation of logic notation will be essential for anyone who hopes to be recognized as a software for anyone who hopes to be recognized as a software engineerengineer

03/21/03 Sri03/21/03 SriLogic is one thing, the human animal another. You can quite easily propose a logical solLogic is one thing, the human animal another. You can quite easily propose a logical solution to something and at the same time hope in your heart of hearts it won't work out. * ution to something and at the same time hope in your heart of hearts it won't work out. * Luigi Pirandello Luigi Pirandello

77

Introduction Contd...Introduction Contd...

FocusFocus It is essential to have a precise meanings for It is essential to have a precise meanings for

logical expressions, one that unambiguously logical expressions, one that unambiguously yields a value of yields a value of true true or or false false for every for every statement of values to the variables that appear statement of values to the variables that appear in an expressionin an expression

03/21/03 Sri03/21/03 SriLogic: The art of thinking and reasoning in strict accordance with the limitations and incLogic: The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding. *Ambrose Bierceapacities of the human misunderstanding. *Ambrose Bierce

88

Problems with Existing LogicProblems with Existing Logic

1. Logicians are conservative? Believes Martin Van Emden

2. Lacks precise meaning for logical expression (* values)

3. Complexity of expressions

4. Assumption of total functions

03/21/03 Sri03/21/03 SriThe want of logic annoys. Too much logic bores. Life eludes logic, and everything that lThe want of logic annoys. Too much logic bores. Life eludes logic, and everything that logic alone constructs remains artificial and forced. * André Gide ogic alone constructs remains artificial and forced. * André Gide

99

Parnas Says:Parnas Says:

1.1. Change predicate logic to allow functions Change predicate logic to allow functions to be partialto be partial

2.2. To do away with the resulting truth value To do away with the resulting truth value “undefined”“undefined”

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1010

Structure of The PaperStructure of The Paper

1.1. IntroductionIntroduction

2.2. Basic definitionsBasic definitions

3.3. Syntax of Logic ExpressionsSyntax of Logic Expressions

4.4. Meanings of Logical ExpressionsMeanings of Logical Expressions

5.5. Examples of the Use of This Logic in Examples of the Use of This Logic in Software DocumentationSoftware Documentation

6.6. ConclusionsConclusions

7.7. ReferencesReferences

03/21/03 Sri03/21/03 SriThe fact that logic cannot satisfy us awakens an almost insatiable hunger for the irrationThe fact that logic cannot satisfy us awakens an almost insatiable hunger for the irrational. * A. N. Wilson al. * A. N. Wilson

1111

Reasons and GoalReasons and Goal

Since practitioners do not want to use Since practitioners do not want to use methods that require them to use many methods that require them to use many symbols to say simple thingssymbols to say simple things

They will not read expressions that are They will not read expressions that are lengthy or deeply nestedlengthy or deeply nested

A full, formal definition of a logic that A full, formal definition of a logic that permits concise expressions is a permits concise expressions is a prerequisite for practical useprerequisite for practical use

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1212

Introduction contd…Introduction contd…

In one of his earlier papers’ Parnas In one of his earlier papers’ Parnas reminded us thatreminded us that1.1. functions and relations can be viewed as sets of functions and relations can be viewed as sets of

ordered pairs,ordered pairs,

2.2. sets can be characterized by predicates and sets can be characterized by predicates and described by logical expressions,described by logical expressions,

3.3. predicates can be represented in more readable predicates can be represented in more readable way using multidimensional expressions, andway using multidimensional expressions, and

4.4. the meaning of these tables can be defined by the meaning of these tables can be defined by rules for translating those tables into more rules for translating those tables into more conventional expressionsconventional expressions

SPentapati
The tables mentioned here are the multidimensional expressions

03/21/03 Sri03/21/03 SriFrom a drop of water a logician could infer the possibility of an Atlantic or a Niagara witFrom 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 hout having seen or heard of one or the other. * Sir Arthur Conan Doyle

1313

Introduction Contd…Introduction Contd…

Many researchers are developing Many researchers are developing mathematical methods for use by software mathematical methods for use by software developers. It is hoped that these methods developers. It is hoped that these methods would do for SwE, what differential and would do for SwE, what differential and integral calculus did for other areas of integral calculus did for other areas of engineeringengineering

SPentapati
Areas of math we were exposed to in High school and Bachelors.

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1414

Introduction contd…Introduction contd…Crux of the problemCrux of the problem

1.1. Conventional formal interpretations of logical Conventional formal interpretations of logical expressions (e.g. [Mendelson]) assume that expressions (e.g. [Mendelson]) assume that all functions are all functions are totaltotal, i.e. defined on a , i.e. defined on a domain that includes all possible values of domain that includes all possible values of their argumentstheir arguments

2.2. Those interpretations are not intended to Those interpretations are not intended to deal with partial functions, functions whose deal with partial functions, functions whose value has not been defined for certain value has not been defined for certain values of the argumentvalues of the argument

SPentapati
What is total?

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1515

BasicsBasics

A partial function ƒ from a set A to a set B is an assignment to each element a in a subset of A, called the domain of definition of ƒ, of a unique element b in B

The sets A and B are called the domain and codomain of ƒ, respectively

03/21/03 Sri03/21/03 Sri Logic is like the sword--those who appeal to it, shall perish by it. * Samuel Butler Logic is like the sword--those who appeal to it, shall perish by it. * Samuel Butler 1616

Basics Contd…Basics Contd…

We say that ƒ is undefined for elements in A that are not in the domain of definition of ƒ

We write ƒ : A B to denote that ƒ is a partial function from A to B

When the domain of definitions equals A, we say that ƒ is a total function

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1717

Another interpretation of Predicate Another interpretation of Predicate Expressions!!! Expressions!!!

But why?But why? Since under conventional interpretations a logical Since under conventional interpretations a logical

expression that includes partial functions will have a expression that includes partial functions will have a defined value only when the values assigned to all function defined value only when the values assigned to all function arguments are within functions’ domains. Such arguments are within functions’ domains. Such interpretations are of limited usefulness when describing interpretations are of limited usefulness when describing software because we frequently use partial functions to software because we frequently use partial functions to describe the behavior of programsdescribe the behavior of programs

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1818

Motivating ExampleMotivating Example

Assume that Assume that represents a function that is defined on represents a function that is defined on a domain containing only non-negative real numbers. a domain containing only non-negative real numbers. A s/w designer may write a boolean expression such A s/w designer may write a boolean expression such as: as:

((x > 0) ((x > 0) (y = (y = x)) x)) ((x ((x 0) 0) (y = (y = -x)) (1) -x)) (1)

to describe the behavior of a computer programto describe the behavior of a computer program

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 1919

The writer’s intent seems to be to write an expression The writer’s intent seems to be to write an expression that is equivalent to: that is equivalent to:

y = y = |x| (2)|x| (2) the usual rules for evaluating such expressions require the usual rules for evaluating such expressions require evaluation of all of the functions and relational operators evaluation of all of the functions and relational operators before application of the logical operators to the truth-before application of the logical operators to the truth-values that result. For every value of x other than 0, values that result. For every value of x other than 0, some component of expression (1) is undefined. With some component of expression (1) is undefined. With the standard interpretation of logical operators, which the standard interpretation of logical operators, which are defined only for two-value logics, the value of (1) is are defined only for two-value logics, the value of (1) is not defined except when x is assigned the value 0not defined except when x is assigned the value 0

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2020

Comparison with Other WorkComparison with Other Work

There is a huge and complex literature on the There is a huge and complex literature on the subject of logic with partial functionssubject of logic with partial functions

This paper presents a specific proposal and its This paper presents a specific proposal and its illustrated useillustrated use

Confined to software engineeringConfined to software engineering Dijsktra’s Dijsktra’s candcand The interpretation for predicate expressions The interpretation for predicate expressions

proposed here neither specifies the order of proposed here neither specifies the order of evaluation nor introduces new symbols into logicevaluation nor introduces new symbols into logic

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2121

Basic DefinitionsBasic Definitions

PredicatePredicate – – A predicate is a characteristic or attribute A predicate is a characteristic or attribute or property that the subject of the statement can haveor property that the subject of the statement can have ““No lawyers are shysters ”No lawyers are shysters ”

A function that returns true or false. Conceptually it A function that returns true or false. Conceptually it tests for a conditiontests for a condition

The property that a bird is an eagle can be expressed The property that a bird is an eagle can be expressed by the predicate: by the predicate: eagle(x)eagle(x)

• This predicate holds for all birds x which are eagles. For other This predicate holds for all birds x which are eagles. For other birds, the predicate is false birds, the predicate is false

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2222

Propositional Logic Propositional Logic

Proposition: A proposition  is a statement that is Proposition: A proposition  is a statement that is either true or false, but not botheither true or false, but not both

1.1. Washington, D.C., is the capital of the United Washington, D.C., is the capital of the United States of AmericaStates of America

2.2. 2 + 2 = 3 2 + 2 = 3 Proposition 1 is true, whereas 2 is falseProposition 1 is true, whereas 2 is false

More complex propositions can be formed by More complex propositions can be formed by applying the logical operators (¬, applying the logical operators (¬, , , , etc..), etc..)

Propositional logic formulaPropositional logic formula Eg. ((p Eg. ((p q) q) ¬¬c) c)

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2323

Predicate Logic Predicate Logic

Predicate logic allows us to represent fairly Predicate logic allows us to represent fairly complex facts about the world, and to complex facts about the world, and to derive new facts in a way that guarantees derive new facts in a way that guarantees that, if the initial facts were true then so that, if the initial facts were true then so are the conclusions. It is a well understood are the conclusions. It is a well understood formal language, with well-defined syntax, formal language, with well-defined syntax, semantics and rules of inferencesemantics and rules of inference

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2424

Predicate Logic contd…Predicate Logic contd…

Predicate logic is obtained by extending Predicate logic is obtained by extending propositional logic by using:propositional logic by using:

1.1. PredicatesPredicates

2.2. VariablesVariables

3.3. QuantifiersQuantifiers

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2525

QuantifiersQuantifiers

Two types of Quantification:Two types of Quantification:1.1. Universal quantificationUniversal quantification

x P(x) - P(x) is true for every xx P(x) - P(x) is true for every x

2.2. Existential quantificationExistential quantification

x P(x) – There is an x for which P(x) is truex P(x) – There is an x for which P(x) is true

03/21/03 Sri03/21/03 Sri You can only find truth with logic if you have already found truth without itYou can only find truth with logic if you have already found truth without it 2626

TuplesTuples

A tuple is an ordered list of one or more simple A tuple is an ordered list of one or more simple tuplestuples           U = {true, false}U = {true, false}           Simple n-tuple Simple n-tuple –   –   Ordered list of n members of UOrdered list of n members of U Eg. <true, false, true, false>Eg. <true, false, true, false>       n-tuplen-tuple –   –   Ordered list of n simple tuplesOrdered list of n simple tuples

Eg. <<true, false>, true, false> Eg. <<true, false>, true, false>

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2727

Tuples Contd…Tuples Contd…

When representing specific tuples, we separate When representing specific tuples, we separate the elements with commas and enclose tuples in the elements with commas and enclose tuples in <brackets> to make their structure clear<brackets> to make their structure clear E.G. <True, false, true, false> represents a simple 4-E.G. <True, false, true, false> represents a simple 4-

tuple and <<true, false>, true, false> represents a 3-tuple and <<true, false>, true, false> represents a 3-tuple that is not a simple 3-tupletuple that is not a simple 3-tuple

SSk k is the set of all simple k-tuples: Sis the set of all simple k-tuples: S11 is U. S is the is U. S is the union of Sunion of S11, S, S22,…,,…, SSuu ; u is the length of the longest ; u is the length of the longest tuple needed to apply the semantic model developed tuple needed to apply the semantic model developed belowbelow

TTk k is the set of all k-tuples. Tis the set of all k-tuples. T11 is S. T is S. Tkk includes S includes Sk k . T is . T is the union of Tthe union of T11, T, T22, …, T, …, Tuu

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2828

Relations, FunctionsRelations, Functions

Binary relations represent relationships Binary relations represent relationships between the elements of two setsbetween the elements of two sets

Relations Relations could be from one-to-many, could be from one-to-many, whereas whereas functions functions can’t be from one-to-can’t be from one-to-manymany

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 2929

Functions and Characteristic Functions and Characteristic PredicatePredicate

We refer to two types:We refer to two types: Partial functions: functions whose domain is a proper Partial functions: functions whose domain is a proper

subset of Ssubset of S Total functions: functions whose domain includes all Total functions: functions whose domain includes all

the members of Sthe members of S

Characteristic predicate:Characteristic predicate: For any set of simple tuples, X, the characteristic For any set of simple tuples, X, the characteristic

predicate of that set is a predicate whose domain is S, predicate of that set is a predicate whose domain is S, and whose value, for a simple tuple b, is true if and and whose value, for a simple tuple b, is true if and only if b is a member of Xonly if b is a member of X

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3030

The Syntax of Logical ExpressionsThe Syntax of Logical Expressions

1.1. Built-in functions and Predicates:Built-in functions and Predicates: the strings fthe strings f11, ………., f, ………., fkk are the names of are the names of

functionsfunctions View functions as set of pairsView functions as set of pairs

RR11, …….., R, …….., Rm m are the names of are the names of

characterizing sets of simple tuplescharacterizing sets of simple tuples View predicates as characterizing sets of simple View predicates as characterizing sets of simple

tuplestuples

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3131

Syntax contd…Syntax contd…

2.2. Terms:Terms: A function application is a string of the form A function application is a string of the form

ffjj(V). Nothing else is a function(V). Nothing else is a function A term is either a member of U, a variable, A term is either a member of U, a variable,

or a function application. Nothing else is a or a function application. Nothing else is a termterm

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3232

Syntax contd…Syntax contd…

3.3. Primitive ExpressionsPrimitive Expressions:: Primitive Expression is a string of the form Primitive Expression is a string of the form

RRjj(V)(V) RRjj is a characteristic predicate is a characteristic predicate

V is comma separated list of terms (called V is comma separated list of terms (called arguments)arguments)

03/21/03 Sri03/21/03 Sri There can never be surprises in logicThere can never be surprises in logic 3333

Syntax contd…Syntax contd…

4.4. Predicate ExpressionsPredicate Expressions All primitive expressions are predicate All primitive expressions are predicate

expressions.expressions. If P, Q: predicate expressions, x: variable, If P, Q: predicate expressions, x: variable,

then following are also predicate then following are also predicate expressions:expressions:

(x , P), (P), (P) (x , P), (P), (P) (Q), (P) (Q), (P) (Q), ¬(P) (Q), ¬(P)

03/21/03 Sri03/21/03 Sri The mind has its own logic but does not often let others in on it. *Bernard DevotoThe mind has its own logic but does not often let others in on it. *Bernard Devoto 3434

The Meaning of Logical The Meaning of Logical ExpressionsExpressions

DenotationDenotation each predicate expression is denoted as a each predicate expression is denoted as a

setset subset of Ssubset of Suu, where u is the number of , where u is the number of

variables that may appear in the variables that may appear in the expressions whose meaning is defined.expressions whose meaning is defined.

AssignmentAssignment simple u-tuplesimple u-tuple

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3535

Meaning contd…Meaning contd…

1.1. Evaluating terms for a given assignment:Evaluating terms for a given assignment:Mapping val for a term, t, and assignment, A:Mapping val for a term, t, and assignment, A:

1.1. If t is a constant representing tIf t is a constant representing t ’’, val(t, A) is t, val(t, A) is t ’’

2.2. If t is a variable, xIf t is a variable, xkk, val(t, A) is the kth , val(t, A) is the kth

element of the assignment Aelement of the assignment A

3.3. If t is a function application, If t is a function application, ƒk(V), let

1. n be the length of V,

2. if VV’’ is in the domain of is in the domain of ƒk, val(t, A) is val(t, A) is ƒk(V’)

3. if VV’’ is not in the domain of is not in the domain of ƒk, val(t, A) is *val(t, A) is *

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3636

Meaning contd…Meaning contd…

2.2. Evaluating primitive expressions for a Evaluating primitive expressions for a given assignment:given assignment:

For a primitive expression RFor a primitive expression Rjj(V), and (V), and

assignment Aassignment A Let XLet Xj j be the set of simple tuples characterized by be the set of simple tuples characterized by

RRjj

n be the length of V,be the length of V, VVii be the i be the ithth element of V, and V element of V, and V ’’ be simple tuple be simple tuple

If VIf V’’ is in X is in Xjj, tval(R, tval(Rjj(V), A) is true(V), A) is true

If VIf V’’ is not in X is not in Xjj, tval(R, tval(Rjj(V), A) is false(V), A) is false

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 3737

Meaning contd…Meaning contd…

3.3. The denotation of primitive expressions:The denotation of primitive expressions: tval(p, A) is truetval(p, A) is true

4.4. The denotation of predicate expressions:The denotation of predicate expressions: If P and Q are predicate expressions:If P and Q are predicate expressions:

1.1. (x(xkk , P), is the set of all assignments, A, , P), is the set of all assignments, A, if c is if c is any value in U, A[k any value in U, A[k c] is in the denotation of P c] is in the denotation of P

2.2. (P) (P) (Q) is the union of P and Q (Q) is the union of P and Q3.3. (P) (P) (Q) is the intersection of P and Q, and (Q) is the intersection of P and Q, and4.4. ¬(P) is the set of all members of S¬(P) is the set of all members of Su u that are not in that are not in

PP

03/21/03 Sri03/21/03 Sri Logic is a poor guide compared with custom. *Winston ChurchillLogic is a poor guide compared with custom. *Winston Churchill 3838

Meaning contd…Meaning contd…

5.5. Satisfaction of an expressionSatisfaction of an expression Expressions that denote empty set are said Expressions that denote empty set are said

to be falseto be false Expressions that denote all of SExpressions that denote all of Su u are said to are said to

be truebe true An expression, e, is said to be satisfied by An expression, e, is said to be satisfied by

an assignment, A, if A is a member of the an assignment, A, if A is a member of the denotation of edenotation of e

03/21/03 Sri03/21/03 SriMan has such a predilection for systems and abstract deductions that he is ready to distorMan has such a predilection for systems and abstract deductions that he is ready to distort the truth intentionally, he is ready to deny the evidence of his senses only to justify his lt the truth intentionally, he is ready to deny the evidence of his senses only to justify his logic. * Fyodor Mikhailovich Dostoyevsky ogic. * Fyodor Mikhailovich Dostoyevsky

3939

Meaning contd…Meaning contd…

6.6. Notational conveniences:Notational conveniences: Specify values for some and not for othersSpecify values for some and not for others

e.g. A list such as “xe.g. A list such as “x22 : x : x2424” represents all ” represents all

assignments in which the second element is 4 assignments in which the second element is 4 and the 24and the 24thth element is 96 element is 96

03/21/03 Sri03/21/03 SriLogic, like whiskey, loses its beneficial effect when taken in very large quantities. Logic, like whiskey, loses its beneficial effect when taken in very large quantities. * Lord Dunsany * Lord Dunsany

4040

Use in DocumentationUse in Documentation

PalindromePalindrome ((i, 0 ≤ I < n i, 0 ≤ I < n (B[l+i]=B[l+n-1-i])) (B[l+i]=B[l+n-1-i]))

• This expression gives the desired results even This expression gives the desired results even though the implication is evaluated outside the though the implication is evaluated outside the domain of B; the domain is characterized by the domain of B; the domain is characterized by the left-hand implicationleft-hand implication

03/21/03 Sri03/21/03 Sri Relational description of a program that searches B for the value of xRelational description of a program that searches B for the value of x 4141

j|j|

present=present=

((i, B[i] = x)i, B[i] = x) ¬¬((i, B[i] = x)i, B[i] = x)

B[j] = xB[j] = x truetrue

truetrue falsefalse

Use in DocumentationUse in Documentation

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 4242

Use in Documentation contd…Use in Documentation contd…

((i, B[i] = C[i])i, B[i] = C[i]) Here we are looking for matching elements in Here we are looking for matching elements in

two arraystwo arrays When the value of i is outside the index set of When the value of i is outside the index set of

either B or C, the value of B[i] = C[i] is falseeither B or C, the value of B[i] = C[i] is false This is the logic which has been basically This is the logic which has been basically

presented in this paperpresented in this paper

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 4343

ConclusionsConclusions

1.1. Not necessary to introduce either a third Not necessary to introduce either a third variable or conditional operators in order variable or conditional operators in order to deal with partial functionsto deal with partial functions

2.2. Not only is the “motivating example”, eq Not only is the “motivating example”, eq (1), fully defined using the set-theoretic (1), fully defined using the set-theoretic operations but also greatly simplified:operations but also greatly simplified:

(y = (y = x) x) (y = (y = -x) -x)

03/21/03 Sri03/21/03 SriA mind all logic is like a knife all blade. It makes the hand bleed that uses it. *RabindraA mind all logic is like a knife all blade. It makes the hand bleed that uses it. *Rabindranath Tagorenath Tagore

4444

Conclusions contd…Conclusions contd…

3.3. Compact readable formulation is crucialCompact readable formulation is crucial

4.4. Easier to comprehendEasier to comprehend

5.5. Drawbacks with some complementary Drawbacks with some complementary predicates – price for allowing partial functionspredicates – price for allowing partial functions

1.1. x > x > y would not denote the complement y would not denote the complement x ≤ x ≤ y. y. both evaluate to false if either x or y is assigned both evaluate to false if either x or y is assigned negative valuenegative value

2.2. a = a = a cannot be assigned a value of true if U a cannot be assigned a value of true if U includes negative valuesincludes negative values

03/21/03 Sri03/21/03 Sri Logic is the art of going wrong with confidenceLogic is the art of going wrong with confidence 4545

Conclusions contd…Conclusions contd…

6.6. The properties of the functions used The properties of the functions used should be stated precisely should be stated precisely

7.7. Axiom of reflection does not hold in this Axiom of reflection does not hold in this interpretationinterpretation

8.8. Simplification is obtained by making Simplification is obtained by making primitive predicates evaluate to false primitive predicates evaluate to false whenever one or more of their whenever one or more of their arguments are undefinedarguments are undefined

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 4646

Conclusions contd…Conclusions contd…

Parnas believes that these are properParnas believes that these are proper

decisions because:decisions because:1.1. Keeping logic simple is essential to practical Keeping logic simple is essential to practical

applicationapplication

2.2. The assigned meanings are consistent with The assigned meanings are consistent with intuitive interpretations, andintuitive interpretations, and

3.3. The formulae that results are relatively The formulae that results are relatively simple for cases arising frequently simple for cases arising frequently

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 4747

Questions And Suggestions!!!!!!!Questions And Suggestions!!!!!!!

03/21/03 Sri03/21/03 Sri Predicate Logic For Software Engineering Predicate Logic For Software Engineering 4848

ReferencesReferences

http://www.cee.hw.ac.uk/~alison/ai3noteshttp://www.cee.hw.ac.uk/~alison/ai3notes Discrete Mathematics and Its ApplicationsDiscrete Mathematics and Its Applications

- Kenneth Rosen, Fourth Edition- Kenneth Rosen, Fourth Edition Software FundamentalsSoftware Fundamentals

- Collected Papers by David L. Parnas- Collected Papers by David L. Parnas