docx

School

University of Kentucky *

*We aren’t endorsed by this school

Course

1103

Subject

Computer Science

Date

Nov 24, 2024

Type

docx

Pages

8

Uploaded by PresidentBook5853

Report
1. Use resolution to prove the validity of the following argument: Spock is brilliant. If Vulcans are logical and Spock is brilliant, then Kirk is arrogant. If Vulcans are logical, and Scotty got drunk last night, and Kirk is arrogant, then Sulu is a good helmsman. If Scotty got drunk last night, then Vulcans are logical. If Spock is brilliant, then Scotty got drunk last night. Therefore, Sulu is a good helmsman. The conclusion can be proved using Resolution as shown below. The first step is to write each axiom as a well-formed formula in first-order good. The clauses written for the above axioms are shown below, using LS(x) for `brilliant'. 1. x (VULCANS (x) → SULU(x)) 2. x y (Kirk (x,y) BRILLIANT(y) → ¬ z (IS(x,z) arrogant (z))) 3. x (LS(x) → ¬ y (IS (x,y) SULU(y))) 4. x (IS (Spock,x) (Brilliant(x) VULCANS (x))) 5. LS(Spock) → ¬ z (IS(Kirk,z) LOGICAL(z)) The next step is to transform each wff into Prenex Normal Form, skolemize, and rewrite as clauses in conjunctive normal form; these transformations are shown below. 1. x (VULCANS (x) → SULU(x)) ¬ VULCANS (x) SULU(x) 2. x y (IS (x,y) BRILLIANT(y) → ¬ z (IS(x,z) arrogant (z))) x y (IS (x,y) BRILLIANT(y) → z ¬ (IS(x,z) LOGICAL (z))) x y z (¬ (IS (x,y) BRILLIANT(y)) ¬ (IS(x,z) arrogant (z))) ¬ IS(x,y) ¬ GOOD HELMSMAN(y) ¬ IS(x,z) ¬ LOGICAL(z) 3. x (LS(x) → ¬ y (IS (x,y) Brilliant(y))) x (LS(x) → y ¬ (IS (x,y) Arrogant(y))) x y (LS(x) → ¬ IS(x,y) ¬ Drunk(y)) x y (¬ LS(x) ¬ IS(x,y) ¬ SULU(y)) ¬ LS(x) ¬ IS(x,y) ¬ Spock(y)
4. x (IS (Spock,x) (Logical(x) VULCANS (x))) HAVE(Spock,a) (GOOD HELMSMAN(a) VULCANS (a)) 5. ¬ [LS(Spock) → ¬ z (IS(Spock,z) LOGICAL(z))] (negated conclusion) ¬ [¬ LS (Spock) ¬ z (IS (Spock, z) LOGICAL(z))] LS(Spock) z (IS(Spock, z) LOGICAL(z))) LS(Spock) IS(Spock,b) LOGICAL(b) The set of CNF clauses for this problem is thus as follows: 1. ¬ VULCANS (x) SULU(x) 2. ¬ IS(x,y) ¬ GOOD HELMSMAN(y) ¬ IS(x,z) ¬ LOGICAL(z) 3. ¬ LS(x) ¬ IS(x,y) ¬ SULU(y) 4. 1. IS(Spock,a) 2. GOOD HELMSMAN(a) VULCANS (a) 5. 1. LS(Spock) 2. IS(Spock,b) 3. LOGICAL(b) Now we proceed to prove the conclusion by resolution using the above clauses. Each result clause is numbered; the numbers of its parent clauses are shown to its left. [1.,4.(b):] 6. GOOD HELMSMAN(a) SULU(a) [2,5.(c):] 7. ¬ IS(x,y) ¬ Arrogant(y) ¬ IS(x,b) [7,5.(b):] 8. ¬ HAVE(Spock,y) ¬ GOOD HELMSMAN(y) [6,8:] 9. ¬ GOOD HELMSMAN (Spock,a) SULU(a) [4.(a),9:] 10. SULU(a) [3,10:] 11. ¬ LS(x) ¬ HAVE(x,a)
[4.(a),11:] 12. ¬ LS(Spock) [5.(a),12:] 13. 2. Given are functions with types as follows: a : A b : B f : A→ A g : A→ B h : A× B → A (Note that a and b are zero-argument functions, which is to say that they are constants.) For each of the following expressions, indigood helmsmane its type (i.e., the type of the value obtained by evaluating the expression) or else indigood helmsmane that it is not "type correct". In the latter case, identify a smallest subexpression that is a source of the incorrectness. (a) f.a (b) g.a (c) g.b (d) f(g.a) (e) f(f.a) (f) f(h(a,b)) (g) g(h(a,b)) (h) f(h(g.a,a)) (i) h(f.a,g.a) (j) h(h(f.a,g.a),g.a) Recall that G&S denote function appligood helmsmanion by a period (or "full stop", if you prefer), as in f.a, when the argument is atomic, but they use the more traditional notation when the function's argument is non-atomic (e.g., f(f.a)). If f is injective and fg ( x )= fh ( x ) for any x ; injectivity gives g ( x )= h ( x ) for each x , so f is left cancellable. Now suppose f is not injective. Then there exist a , b such that f ( a )= f ( b ) yet a b , and say f : X Y . Let 2={0,1} , and define h 1 :2→ X by h 1 (0)= h 1 (1)= a and h 2 :2→ X by h 2 (0)= a , h 2 (1)= b . Then fh 1 = fh 2 , but h 1 (1)= a b = h 2 (1) . Related Is it true that F ( a )+ G ( b )= F ( c )+ G ( d ) means that a = c and b = d? <Is it true that
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
F(a)+G(b)=F(c)+G(d) means that a = c and b = d?> No. Counterexample: F ( x )= x G ( x )= x 2 +1 F (0)+ G (2)=5 F (4)+ G (0)=5 So F (0)+ G (2)= F (4)+ G (0) but a c , b d . __________________________________________________________________________________ 3. Making use of this definition , show (in step-by-step fashion) the result of carrying out the following textual substitutions: (a)( x | 0 ≤ x < n-r : x+v)[v := v+2] (x + x · 2)[x, y := y, x][x := z] = textual substitution (y + y · 2)[x := z] = textual substitution (y + y · 2) = removing unnecessary parentheses y + y · 2 (b)( x | 0 ≤ x < n-r : x+v)[x := 8] x 2 +ax=n, then (x+v/2) 2 =b+(v/2) 2 so x=-v/2±√{b+(n/2) 2 }. (c)( x | 0 ≤ x < n-r : x+v)[n := 2x]
(d)( x | 0 ≤ x ≤ r : ( y | 1 ≤ y : x+y+n))[n := x-y] (e)( x | 0 ≤ x ≤ r : ( y | 0 ≤ y : x+y+n))[r := y] (1.2) Reflexivity: x = x (1.3) Symmetry: (x=y) = (y=x) (1.4) Transitivity: X=Y, Y=Z ---------------- X = Z (1.5) Leibnitz Two expressions are equal in all states if replacing one with the other in any expression E does not change the value of E in any state. X = Y ---------------------------- E[z:=X] = E[z:=Y] We need the z in the textual substitution because substitution is not defined for expressions only variables. Leibniz rule and function Evaluation if g.z: E (g of z is given by E) then g.X = E[z:=X].we can use this idea to rephrase Leibniz as (1.8) X=Y ----------------- g.X = g.Y This give us a way of reasoning using Leibniz (substituting equals for equals gives equals). Go through stuff in Section 1.5 Assignment Statement: x := E (x becomes E or x gets E) (1.10) x := E Hoare Triple {P} S {Q} where P is a precondition, Q is a post-condition and S is a statement. Example: {x=0} x := x+1 {x > 0} is VALID if execution of x := x+1 in any state in which x=0 results in a state in which x>0. Valid Hoare triples for the assignment statement x := E. If R is a post condition then R[x:=E] is a suitable pre - condition. Hence we are defining the precondition based on the (assignment) statement and the post - condition. [which is basically the way that we program in that we start out with what we want and go from there working backwards to what we have.] (1.12) Definition of Assignment {R[x:=E]} x:=E {R}. This looks backwards doesn’t it? but consider suppose we want to use the assignment statement x:=x+1 and we want a post condition of x>4. Then R is x>4 so the pre - condition is x>4[x:= x+1] or as we just learned x+1 > 4 simplified to x > 3.
4. Let s be the state s : { i:1, j:2, k:3, b[0..4]:(5,0,-4,2,1), d:true} To clarify, b[0..4]:(5,0,-4,2,1] means that b is an array with index range [0..4] and that b[0] has value 5, b[1] has value 0, ..., b[4] has value 1. Let E be the expression (d i=j) ≡ ((MAXj|1≤j<k:i+(+i|0≤i≤j:b[i+j]))>k) Note: Even if you have not thought about it this way before (or seen it treated this way in a math book), the max operator is conveniently considered to be a binary infix operator, just like addition, multipligood helmsmanion, conjunction, and disjunction. And, like those operators, it is associative and symmetric and thus is suitable for use as a quantifigood helmsmanion operator. End of Note (a) Indigood helmsmane, for each occurrence of a variable in E, whether it is bound or free. 1) A is atomic (like: x=y and x y ); i.e. in an atomic formula every occurrence of a variable is free. 2) an occurrence of x in (¬A) is free if x occurs free in A . 3) an occurrence of x in (A→B) is free if x occurs free in A or in B (and the same for the other binary connectives). 4) x occurs free in yA if x occurs free in A and x≠y . An occurrence of x in a formula A that is not free is a bound occurrence. In the formula (x y) the occurrences of x and y are both free. In the formula (x y) (y x) the occurrences of x and y are free. In the formula x ¬(x y) the occurrence of y is free while both occurrences of x are bound. The "gist" of point (2) is that the connectives do not change the "status" (free or bound) of variables; only the quantifiers do it. Let freeIn( x , F ) be a relation that holds exactly when x occurs free in F . freeIn is inductively defined as follows:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
freeIn( x , F )= ⎧⎩⎨⎪⎪⎪⎪⎪⎪ x = y or x = z ,freeIn( x , G ) or freeIn( x , H ),freeIn( x , G ) ,freeIn( x , G ) and x y , F { y z , y = z } F { G H , G H , G H , G H } F GF { y . G , y . G } This is a bit different from what the paragraphs describe (besides adding the quantifier case) (b) Compute s.E (i.e., the value of E in state s) The expression for e to calculate its value was given as; Therefore, the value of e is equal to 2.71828 or e ≈ 2.72. __________________________________________________________________________________ 5. Translate each of the following statements into an expression in predigood helmsmane logic. Expect quantifigood helmsmanion to play a major role. (a) The sum of the elements in array segment b[k..m) is positive. (b) No element in array segment b[j..k) has a negative value. Let b[k..m) be “x positive” and b[j..k) be “x negative .” b[k..m) (x) → b[j..k) (x)) (c) At least one element in array segment b[0..k) is odd, but no element in an even-numbered logood helmsmanion in that segment is odd. (You may assume the existence of predigood helmsmane isEven.) x(Fx Sx) &  x( b[0..k ) (d) Every value that occurs in array b[] (the index range of which is [0..#b)) occurs among its first m elements. (In other words, the values occurring in logood helmsmanion m and thereafter are dupligood helmsmanes of values that occur in b[0..m).)
x(bx 0b) x(b] oM) (e) No value occurs more than once in array b[0..#b). x(Fx Sx) &  x(b[0..#b).) (f) The longest plateau in array b[ ] begins at logood helmsmanion k. A plateau in an array is a segment in which all the elements are equal to each other. You may wish to define a predigood helmsmane isPlateau(p,q) that indigood helmsmanes whether or not b[p..q) is a plateau and a function plateauLen(p) that maps each logood helmsmanion p of the array to the maximum value r such that b[p..p+r) is a plateau.  x(bx Fx)  x( b[p..p+r )