Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
aa:lab:sol:4 [2025/10/27 22:54] rares_stefan.balcan |
aa:lab:sol:4 [2025/10/27 23:23] (current) rares_stefan.balcan |
||
|---|---|---|---|
| Line 343: | Line 343: | ||
| Pentru \((i + 1) \bmod \mathsf{size}(\mathsf{Push}(e, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))))\), știind că \(\mathsf{size}(\mathsf{move}(r)) = \mathsf{size}(r)\) (din exercițiul 2), avem: | Pentru \((i + 1) \bmod \mathsf{size}(\mathsf{Push}(e, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))))\), știind că \(\mathsf{size}(\mathsf{move}(r)) = \mathsf{size}(r)\) (din exercițiul 2), avem: | ||
| \[ | \[ | ||
| - | \mathsf{size}(\mathsf{Push}(e, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r))))) = 1 + \mathsf{size}(\mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))) = 1 + (2 + \mathsf{size}(r)) | + | \mathsf{size}(\mathsf{Push}(e, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r))))) = 1 + \mathsf{size}(\mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))) = 3 + \mathsf{size}(r) |
| \] | \] | ||
| - | Distingem din nou după paritatea lui \(i\): | + | Notăm \(n = 3 + \mathsf{size}(r)\). |
| - | - Dacă \((i + 1) \bmod (3 + \mathsf{size}(r)) = 0\), atunci \(\mathsf{elm}(0, \mathsf{Push}(e, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r))))) = e\). | + | Dacă \((i + 1) \bmod n = 0\), atunci: |
| - | - În caz contrar, folosim \(\text{ELM2}\) și reducem la \(\mathsf{elm}((i + 1 - 1) \bmod (\mathsf{size}(r) + 2), \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r))))\). | + | \[ |
| + | \mathsf{element}(i + 1, \mathsf{move}(...)) = \mathsf{elm}(0, \mathsf{Push}(e, ...)) = e | ||
| + | \] | ||
| - | Calculul complet al acestui caz devine extrem de tehnic, dar principiul este același ca mai sus: folosim ipotezele de inducție și proprietățile modulo pentru a arăta că ambele părți sunt egale. | + | \[ |
| + | \begin{aligned} | ||
| + | \mathsf{element}(i + 2, \mathsf{Push}(x, \mathsf{Push}(e, \mathsf{Push}(f, r)))) | ||
| + | &\overset{(\text{ELEM})}{=} | ||
| + | \mathsf{elm}((i + 2) \bmod n, \mathsf{Push}(x, ...)) \\ | ||
| + | &\overset{(\text{ELM2})}{=} | ||
| + | \mathsf{elm}((i + 1) \bmod (n-1), \mathsf{Push}(e, \mathsf{Push}(f, r))) \\ | ||
| + | &= \mathsf{elm}(0, \mathsf{Push}(e, ...)) = e | ||
| + | \end{aligned} | ||
| + | \] | ||
| + | |||
| + | Dacă \((i+1) \bmod n \neq 0\), folosim axioma ELM2 și reducem problema: | ||
| + | \[ | ||
| + | \begin{aligned} | ||
| + | \mathsf{element}(i + 1, \mathsf{move}(...)) | ||
| + | &= \mathsf{elm}((i+1) \bmod n, \mathsf{Push}(e, \mathsf{move}(...))) \\ | ||
| + | &\overset{(\text{ELM2})}{=} | ||
| + | \mathsf{elm}(i \bmod (n-1), \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))) \\ | ||
| + | &= \mathsf{element}(i, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r)))) | ||
| + | \end{aligned} | ||
| + | \] | ||
| + | |||
| + | Prin ipoteza de inducție pe \(i\): | ||
| + | \[ | ||
| + | \mathsf{element}(i, \mathsf{move}(\mathsf{Push}(x, \mathsf{Push}(f, r))))) = \mathsf{element}(i+1, \mathsf{Push}(x, \mathsf{Push}(f, r))) | ||
| + | \] | ||
| + | |||
| + | Partea dreaptă: | ||
| + | \[ | ||
| + | \mathsf{element}(i + 2, \mathsf{Push}(x, \mathsf{Push}(e, \mathsf{Push}(f, r))))) | ||
| + | \overset{(\text{ELM2})}{=} | ||
| + | \mathsf{element}(i + 1, \mathsf{Push}(e, \mathsf{Push}(f, r))) | ||
| + | \] | ||
| + | |||
| + | Prin ipoteza de inducție structurală: | ||
| + | \[ | ||
| + | \mathsf{element}(i + 1, \mathsf{move}(\mathsf{Push}(e, \mathsf{Push}(f, r))))) = \mathsf{element}(i + 2, \mathsf{Push}(e, \mathsf{Push}(f, r))) | ||
| + | \] | ||
| - | **Prin urmare, prin inducție matematică pe \(i\), avem că proprietatea este adevărată pentru toate valorile \(i \in \mathbb{N}\).** | + | obținem că ambele părți sunt egale. |
| + | **Prin urmare, prin inducție matematică pe \(i\) și inducție structurală pe \(r\), avem că proprietatea este adevărată pentru toate valorile \(i \in \mathbb{N}\).** | ||