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”
turn computational problem into decision problem
by giving the TM two strings v and w and ask whether the TM on input v will produce output w
language acceptance
about decidability
language acceptance
about decidability
recursively enumerable languages
languages that are accepted by Turing machines
recursive language
like r.e. language but guaranteed to stop in a non-accepting state
when is a problem decidable?
the languages that encode the problem must be recursive for the problem itself to be decidable
if language is r.e. then the TM might not stop for a given input w and then we would not know whether w is a solution to the problem or not or whether we had just not waited long enough
intractable
(also called “NP-hard”)
is a problem to which an algorithm solving the
problem does exist, but it is so inefficient that it is considered as practically useless
i.e. it takes so much time for bigger instances of the problem that it’s useless
-> also called beyond-polynomial-time algorithms
tractable
- polynomial-time algorithms are perceived as tractable
- beyond-polynomial-time algorithms are perceived as intractable
diagonalization language
no TM accepts it
acceptance by a TM
such a language L is recursive
the TM always stops
pseudo/partial algorithm
could run forever
–> for recursively enumerable languages
reduction
- a reduction is an algorithm for transforming one problem into another problem
- a reduction from one problem to another may be used to show that the second problem is at least as difficult as the first
- is a transformation from one input alphabet to another input alphabet such that this transformation must be computable
- > there is a TM that always stops and does the transformation
if the complement of a language L is not RE
then the language L is not recursive only RE
L_u’s complement is not RE
by reduction from L_d
partial algorithm vs algorithm
may run forever vs always stops
a partial algorithm = a strategy that may be successful or may not, if successful we can trust the outcome, otherwise we cannot because it may never say yes or no