CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.
-
Upload
emory-maxwell -
Category
Documents
-
view
214 -
download
1
Transcript of CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.
![Page 1: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/1.jpg)
CSE 3341.03 Winter 2008Introduction to Program Verification
January 24
tautology checking,
take 2
![Page 2: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/2.jpg)
terms -- review
due date for exercise set 1: Feb. 11 term = labelled tree
all these are terms:P implies Q, -w, z(1,q)!, 2+6*z
a or f(b), x ≤ y - z
true, ‘true’, ‘this is true’
label of the root = functor
![Page 3: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/3.jpg)
term notation
any term can be written in functional notation: f(arg1, . .) root = function name subtrees = args
if the functor is a logical or arithmetic operation, the term can be written with operator notation. Example:+(+(a, b), c) = a + b + c
![Page 4: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/4.jpg)
interpreting terms
terms, in general, are uninterpreted; they have no values
but some terms can be interpreted as a function and evaluatede. g. the term 1+ 1 can be evaluated to 2
A+A can be evaluated if A is given a value
![Page 5: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/5.jpg)
tautology program requires logical variables to be actual Prolog variables which are assigned truth-values in the testing for falsity.
• variable name begins with upper-case letter
wang requires logical variables to be terms
• name begins with lower-case letter, or is quoted
![Page 6: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/6.jpg)
semantics vs syntax
the tautology algorithm (checking the truth table) operates on the semantics of Boolean logic what the Boolen functions evaluate to
wang operates syntactically, which allows greater expressivity in the input
![Page 7: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/7.jpg)
Exercise 3.2: English to logic againLet A B represent “If the car has gas, then I can go to the store.”; B C D represents “If I can go to the store and I have money,
then I can buy food.”; (D (E F)) G represents “If I have food and either the sun is
shining or I have an umbrella, then today I can go on a picnic.”
If the above formulae are true, and the car has gas, and I have money and an umbrella, can I go on a picnic?
(('the car has gas' implies 'I can go to the store') and ('I can go to the store' and 'I have money' implies 'I can buy food') and ( . . . implies 'I can go on a picnic') and 'the car has gas' and 'I have money' and 'I have an umbrella'
implies
'I can go on a picnic'.
![Page 8: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/8.jpg)
exercises 3.1, 3.4
3.1: x equals 0 if it is not less than 0 , unless it is greater than 0.
3.4: "Portia's caskets" • two caskets; one of gold and one of silver. Which
contains Portia's portrait?
On the Gold casket: "The portrait is not in here."
Silver: "Exactly one of the inscriptions is true."
![Page 9: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/9.jpg)
convert to terms
'Silver inscription is true' 'Gold inscription is true' 'portrait is in Gold' 'portrait is in Silver'.
![Page 10: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/10.jpg)
tie the facts together with logic
premises? Describe what is known about the situation :
• 'Gold inscription is true' iff not 'portrait is in Gold' and• 'Silver inscription is true' iff (('Silver inscription is
true' or 'Gold inscription is true') and
not ('Silver inscription is true' and 'Gold inscription is true') and
• 'portrait is in Gold' xor 'portrait is in Silver'.
All this implies 'portrait is in Gold'.
![Page 11: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/11.jpg)
sequents to understand Wang's algorithm, we need
another way of structuring propositions sequent: represent an implication L implies R by
a pair of lists: L >> RL and R are sets of terms.
L represents the conjunction of its elements
R represents the disjunction of its elements
![Page 12: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/12.jpg)
examples
p and q implies r or psequent: {p, q} >> {r, p}
what's the sequent for an arbitrary proposition P ?
sequent: {true} >> {P}
= {} >> {P} — why?(what is the truth-value of the empty conjunct?)
![Page 13: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/13.jpg)
{P} >> {false} = P implies false = not P
why is {P} >> {false} = {P} >> {}?(what is the truth-value of the empty disjunct?)
![Page 14: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/14.jpg)
testing a sequent
when is a sequent a tautology?when left-side and right-side overlap
(p and . . .) implies (p or . . .)
![Page 15: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/15.jpg)
how wang works
use rewrite rules (p.29) to eliminate logical operators from the sequent, or split sequent into 2 shorter sequents
any sequent (input) or generated with left-right overlap is a tautology
any sequent with no logical operators and no overlap is not a tautology (why?)
• hint: treat non-logical terms as Boolean variables
![Page 16: CSE 3341.03 Winter 2008 Introduction to Program Verification January 24 tautology checking, take 2.](https://reader035.fdocuments.in/reader035/viewer/2022081821/56649ce05503460f949a9511/html5/thumbnails/16.jpg)
so Wang's algorithm is data-driven, and rule-based why is termination guaranteed? why is it correct ? I. e., why does computing a
valid/invalid sequent guarantee that the input proposition is valid or invalid?