IN.5021 Formal Methods Flashcards
Hoare triple
{P} S {Q}
P = a precondition, assumed to be true before execution of S
S = a sequence of statements
Q = a postcondition, will be true after execution of S
indicate: if P is true, then executing S will make Q true
primed notation: x’
x’ refers to the value after the execution of a program and its unprimed notation x refers to its value before the program execution
primed notation: x’
x’ refers to the value after the execution of a program and its unprimed notation x refers to its value before the program execution
program annotation
a predicate, an assertion
it states what is assumed to be true when the program reaches that point of execution
partial correctness
a desired result is achieved
program verification
in general impossible to do
partial correctness
a desired result is achieved (after a loop has come to an end)
termination
when a loop definitely will come to an end
total correctness
= partial correctness + termination
partial correctness: (loop) invariant
a loop invariant is a logical formula that is true
- before the loop
- before each execution of the loop body
- after each execution of the loop body
- after the loop
-> you have to invent an invariant!
(loop) variant
- an integer-valued expression
- value that can change over time
- is decreased at least by 1 in each execution of the loop body
- cannot go below 0
invariant inv
an invariant is something you have to find, invent
- true after initialization
- precondition to the loop body
- true after execution of loop body
interpretation I
is a truth-value assignment to propositional variables P, Q, …
satisfiability
F is satisfiable iff notF is not valid
- > there is some interpretation I that makes F true
- > I makes notF false
- > not all interpretations make notF true (because I doesn’t)
validity
F is valid iff notF is not satisfiable
- > all interpretations make F true
- > no interpretation makes F not true (false)
- > no interpretation makes notF true
negation normal-form
if and only if negations appear only directly in front of variables, i.e. they appear only in literals, and the formulas contain only disjunctions and conjunctions
domain and range
incl. negation normal form
cf. 2-Proposi…pdf slide 14
disjunctive normal form
A formula F is in disjunctive normal-form, if and only if it is in negation normal-form and it is the disjunction (OR) of conjunctions (AND).
-> incl. negation normal form
resolution
aims at deciding satisfiability
deciding satisfiability
- via truth table (but O(2^n) space)
- SAT algorithm (only O(n) space)
SAT algorithm
capable of checking the satisifability of a formula
- recursive
- tries out truth table but sequentially
busy beaver
just a TM that can write a sequence of 1’s on the tape
- > when it stops: the output is the number of 1’s it wrote on the tape
- > is non-computable because …
busy beaver function
given a number n, what is the MAXIMAL output such a busy beaver can produce when the BB has n+1 states
decision problem
TM only says “yes” or “no”