Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
laborator [2020/09/08 18:28] pdmatei |
laborator [2020/09/10 17:57] (current) pdmatei |
||
---|---|---|---|
Line 3: | Line 3: | ||
===== Part 1 - Decidability - 4 labs ===== | ===== Part 1 - Decidability - 4 labs ===== | ||
- | ==== Masina Turing ==== | + | ==== 1. Turing Machine ==== |
Key concepts: | Key concepts: | ||
Line 50: | Line 50: | ||
- | ==== Turing Machines and Solvability ==== | + | ==== 2. Turing Machines and Solvability ==== |
Key concepts: | Key concepts: | ||
Line 62: | Line 62: | ||
* If a problem is **decided** by some TM, can its complement also be decided? | * If a problem is **decided** by some TM, can its complement also be decided? | ||
* Write a TM which accepts //is-odd// problem but which does not decide it. | * Write a TM which accepts //is-odd// problem but which does not decide it. | ||
- | * Is the following a suitable pseudocode for a TM? | ||
- | * a) suitable example | ||
- | * b) unsuitable example (testing some behavioural property) | ||
* Which of the following problems you **think** can be **accepted** and which can be **decided**? Use pseudocode instead of writing a TM. | * Which of the following problems you **think** can be **accepted** and which can be **decided**? Use pseudocode instead of writing a TM. | ||
- | * a) [[Link|https://arxiv.org/pdf/1902.10188.pdf]] | + | * a) V [[https://arxiv.org/pdf/1902.10188.pdf | Undecidable example 1]] |
- | * b) | + | * b) V [[https://en.wikipedia.org/wiki/Hilbert%27s_tenth_problem | Hilbert undecidable ]] |
- | * c) | + | * c) V [[https://en.wikipedia.org/wiki/Wang_tile | Wang Tile]] |
+ | * e) k-color | ||
+ | * f) Linear Integer Programming | ||
- | ==== The Universal Turing Machine ==== | + | ==== 3. The Universal Turing Machine ==== |
Key concepts: | Key concepts: | ||
Line 82: | Line 81: | ||
* Write a TM pseudocode which accepts if **there exists** a word which is accepted by a given TM in **k steps**. | * Write a TM pseudocode which accepts if **there exists** a word which is accepted by a given TM in **k steps**. | ||
Discussion on the pseudocode | Discussion on the pseudocode | ||
+ | * Which of the following is a suitable pseudocode for a TM: | ||
+ | <code> | ||
+ | Algoritm(M,w){ | ||
+ | if size(w) > 10 | ||
+ | then if M halts for w in k steps | ||
+ | accept. | ||
+ | } | ||
+ | </code> | ||
+ | <code> | ||
+ | Algoritm(M1,M2,w){ | ||
+ | k = 0 | ||
+ | while true | ||
+ | if M1(w) has the same behaviour as M2(w) after k steps | ||
+ | then accept | ||
+ | else k = k + 1 | ||
+ | } | ||
+ | </code> | ||
+ | <code> | ||
+ | Algorithm(M,A) { | ||
+ | // A is a finite set of words | ||
+ | for each w in A | ||
+ | if M(w) halts //undecidable! Pseudocode is ok, but this machine may not terminate | ||
+ | then accept | ||
+ | } | ||
+ | </code> | ||
+ | <code> | ||
+ | Algorithm(M,w) { | ||
+ | build the machine M' such that M(x) accepts iff M'(x) does not accept, for all words x | ||
+ | if M'(w) in 1000 steps | ||
+ | accept | ||
+ | } | ||
+ | </code> | ||
+ | <code> | ||
+ | Algorithm(M1,M2) { | ||
+ | if M1 always halts then //we know of no procedure, terminating or not, which can achieve this. This is not a proper TM/algorithm. | ||
+ | if M2 always halts then | ||
+ | accept | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | * Write the problem which is accepted by each of the above machines. | ||
* Write a TM pseudocode which accepts if a **given** word is accepted by two given TMs. Explain the dovetailing technique. | * Write a TM pseudocode which accepts if a **given** word is accepted by two given TMs. Explain the dovetailing technique. | ||
Line 93: | Line 133: | ||
[[https://www.bbc.co.uk/bitesize/guides/zhppfcw/revision/3#:~:text=Von%20Neumann%20architecture%20is%20the,both%20stored%20in%20primary%20storage | Von Newmann Model]] | [[https://www.bbc.co.uk/bitesize/guides/zhppfcw/revision/3#:~:text=Von%20Neumann%20architecture%20is%20the,both%20stored%20in%20primary%20storage | Von Newmann Model]] | ||
- | ==== Undecidable problems ==== | + | ==== 4. Undecidable problems ==== |
Key concept: | Key concept: | ||
Line 104: | Line 144: | ||
==== Notatii asimptotice ==== | ==== Notatii asimptotice ==== | ||
- | * Implementari care sa ilustreze faptul ca constanta conteaza/nuconteaza | + | * (Homework) Implement mergesort and insertionsort in python. Use a large dataset (provided by us) to test your implementation. Plot the execution times together with the functions $math[n^2] and $math[n\cdot \log{n}] using ''gnuplot''. What do you observe? Adjust the constants for the previous functions so that the rate of growth can be better observed. |
- | * Implementari care sa ilustreze faptul ca log n >> n >> n2 >>> n3 | + | |
- | * Grafice (in ?!) | + | |
* Exercitii clasice | * Exercitii clasice | ||
==== Recurente ==== | ==== Recurente ==== | ||
* Cativa algoritmi si recurentele lor | * Cativa algoritmi si recurentele lor | ||
+ | * Merge-sort, | ||
+ | * Quick-sort (curs) | ||
+ | * Exemplul cu sqrt(n) al lui Sebi. | ||
* Exercitii clasice | * Exercitii clasice | ||
+ | |||
+ | ==== Ammortised Analysis ==== | ||
+ | * Classical exercises | ||
===== Part 3 - Algorithm complexity (4 labs) ===== | ===== Part 3 - Algorithm complexity (4 labs) ===== | ||
==== NP completitudine ==== | ==== NP completitudine ==== | ||
- | * Implementare care sa ilustreze exponentiala (backtracking); legatura cu MTN. | + | * Implement a SAT solver which encodes formulae as matrices and iterates over interpretations treating them as binary counters. Plot execution times. |
- | * Reduceri pentru SAT solvere | + | * Implement a better SAT solver which uses BDDs to encode a formula. The variable ordering is known in advance. Plot execution times. |
- | * Exercitii clasice cu reduceri | + | * Implement a k-Vertex-Cover solver using a reduction from SAT, and any of the above solvers. |
+ | * Exercitii clasice cu choice si reduceri | ||
- | ===== Part 4 - Abstract Datatypes (3 labs) ===== | + | ===== Part 4 - Abstract Datatypes (2 labs) ===== |
==== TDA-uri ==== | ==== TDA-uri ==== | ||
* Conceptul de operator vs cel de functie (exercitiu in C, exercitiu in Haskell, pe Liste) | * Conceptul de operator vs cel de functie (exercitiu in C, exercitiu in Haskell, pe Liste) | ||
+ | * (Homework) Implementare LinkedList si ArrayList in Python, impreuna cu operatii. Implementare Haskell a operatiilor, dupa o discutie la curs despre acestea. | ||
* Exercitii clasice | * Exercitii clasice | ||