CS536 Assignment 3
Due: Feb 28th, 2025
Early Bird Due: Feb 26th, 2025
(Ethics: Any behavior on any homework or exam that could be considered copying or cheating will result in an immediate zero on the assignment
for all parties involved. See the IIT Code of Academic Honesty,)
- Remember that Σ is the collection of all well-formed states, and Σ⊥ = Σ ∪ {⊥}. Decide true or false for each of
the following statements, justify your answers briefly.
a. If () =⊥, then ⊭ ¬.
b. Let ∈ Σ⊥, then ⊨ or ⊨ ¬.
c. Let Σ0 ⊆ Σ and Σ0 ⊨ , also let ⊨ ; then Σ0 ∪ {} ⊨ .
d. ∅ ⊨ and ∅ ⊨ ¬ (∅ represents an empty collection of states).
e. Let Σ0 ⊂ Σ, then Σ0 ⊨ > 1 or Σ0 ⊨ ≤ 1. - Calculate denotational semantics for the following nondeterministic programs.
a. Let ≡ > → ≔ − 1 ◻ > → ≔ + 1 ◻ + = 4 → ≔ / ◻ + = 4 → ≔
/ , and let 1 = { = 3, = 1}. Calculate (, 1) and show your work.
b. Let ≡ > → ≔ − 1 ◻ > → ≔ + 1 ◻ + = 4 → ≔ / ◻ + = 4 → ≔
/ , and let 2
() = 2
() = 1. Calculate (, 2) and show your work.
c. Let ≡ > → ≔ − 1 ◻ > → ≔ + 1 ◻ + = 4 → ≔ / ◻ + = 4 → ≔
/ , and let 1 = { = 3, = 1}. Calculate (, 1) and show your work.
d. Let ≡ > → ≔ − 1 ◻ > → ≔ + 1 ◻ + = 4 → ≔ / ◻ + = 4 → ≔
/ , and let 2
() = 2
() = 1. Calculate (, 2) and show your work. - Let be an array of size ≥ 1, and ∀0 ≤ < . [] = 0 ∨ [] = 1. Decide which number (0 1) is the
majority in without counting their quantities.
Write a program named in our language that can solve the above problem and bind the majority
among 0 and 1 to variable . You can assume that is written in the memory state; and to simplify the
question, we artificially define [] = 100, so you don’t need to worry about a possible runtime error when the
array index reaches . Your program doesn’t have to be deterministic. Be careful of the grammar in our
programming language.
Here are some hints:
1) We can use the following代写 linear-search-like algorithm: scan the array to pair up each 0 with a 1. Once we
have some 1′ left over, then 1 is the majority; once we have some 0′ left over, then 0 is the majority; if
we can pair up all numbers, then either of them can be the majority.
2) A student named Jason wrote a partial solution that could be useful to solve the above problem:
≡ [0
] = 1 → 0 ≔ 0 +1 ◻ [1
] = 0 → 1 ≔ 1 + 1
Consider 0 and 1 as pointers for number 0 and 1 respectively. What program does is to find the next
0 and 1
such that [0
] = 0 and [1
] = 1. You can use inside of your program. - Decide true or false for each of the following statements, justify your answers briefly.
a. If (, ) contains exactly one state, then is a deterministic statement.
b. If ⊭ {} {}, then ⊨ .
c. If ⊨ {} {}, then ⊭ .
d. If ⊨ {} {}, then (, ) ⊨ .
e. If ⊭ {} {}, then ⊭ {} {}. - Answer the following questions about possible values of variable in a state. Justify your answer briefly.
a. Let ⊥∉ (, ), where ≡ ∶= () / [] and () = (3, 0,−2, 4). What are the possible values
of ()?
b. Let ⊨ { ≠ 0} ≠ 0 ≔ −2 { < 0}, what are the possible values of ()?
c. Let ⊨ { ≠ 0} ≠ 0 ≔ − 2 { < 0}, what are the possible values of ()? - Let predicate function (, ) ≡
- ≤ ≤ ( + 1)
2
. For each of the following triples, decide whether it is valid
under total correctness, justify your answer briefly.
a. {(, +1)} ≔ + 1 {(, )}
b. {(, )} ≔ +1 {(, + 1)}
c. {(, ) ∧ < 0} ≔ + 1; ≔ + 1 {(, )}
d. {(, ) ∧ = } ≔ + 1 {(, )}
e. {( +1, + 1)} ≔ + 1; ≔ + 1 {(, )} - Let ⊨ {1
} {1
} and ⊨ {2
} {2
}. Decide whether necessarily satisfies the following triples under
partial correctness, justify your answer briefly.
a. {1 ∧ 2
} {1 ∧ 2
}
b. {1 ∨ 2
} {1 ∨ 2
}
c. {1 ∨ 2
} {1 ∧ 2
} - Let ⊨ {1
} {1
} and ⊨ {2
} {2
}. Decide whether the following triples are valid under total
}Hints for questions 7 and 8:
1) Remember that ⊨ ∧ means “ ⊨ and ⊨ ”; ⊨ ∨ means “ ⊨ or ⊨ ”.2) To prove ⊨ {} {}, you can prove that “if ⊨ ,then (, )−⊥ ⊨ ”.
3) To prove ⊨ {} {}, you can prove that “for any state , if ⊨ ,then(, ) ⊨ ”.