Anadi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # JP Kolokwium ## Lista 2 Zadanie 5 Reguły małych kroków: $$ \frac{}{false \texttt{ AND } t_2 \rightarrow false} $$ $$ \frac{}{true \texttt{ AND } t_2 \rightarrow t_2} $$ $$ \frac{t_1 \rightarrow t_1'}{t_1 \texttt{ AND } t_2 \rightarrow t_1' \texttt{ AND } t_2} $$ Reguły dużych kroków: $$ \frac{t_1 \Downarrow false}{t_1 \texttt{ AND } t_2 \Downarrow false} $$ $$ \frac{t_1 \Downarrow true \hspace{20pt} t_2 \Downarrow v_2 }{t_1 \texttt{ AND } t_2 \Downarrow v_2} $$ ### Lemat o determinizmie małych kroków Jeśli $t \rightarrow t'$ i $t \rightarrow t''$ to $t'= t''$. **Dowód** -- Dla każdej postaci termu $t$ jest on w postaci normalnej, bądź pasuje dokładnie jedna reguła redukcji. **Postać normalna termu** - wartość albo stuck term ### Lemat o determinizmie dużych kroków Jeśli $t \Downarrow t'$ i $t \Downarrow t''$, to $t' = t''$. **Dowód** -- Analogiczny jak dla małych kroków. ### Dowód ($\Rightarrow$) Jeśli $t \rightarrow^{*} v$, to $t \Downarrow v$ Indukcja po strukturze termu $t$. * Dla $t = v$, teza jest oczywista * Dla $t = t_1 \texttt{ AND } t_2$, to z zał. indukcyjnego jeśli $t_1 \rightarrow^{*} v_1$, to $t_1 \Downarrow v_1$, analogicznie dla $t_2$ i $v_2$: * Jeśli $v_1 = false$, to dla małych kroków otrzymujemy $t \rightarrow^{*} false \texttt{ AND } t_2 \rightarrow false$, analogicznie dla dużych kroków z pierwszej reguły. Warto wspomnieć o tym, że możemy tak iterować $t$ (np. osobny lemat). * Wpp. $v_1 = true$, to dla małych kroków otrzymujemy $t \rightarrow^{*} (true \texttt{ AND } t_2) \rightarrow t_2 \rightarrow^{*} v_2$, analogicznie wychodzi dla dużych kroków z drugiej reguły. ($\Leftarrow$) Jeśli $t \Downarrow v$, to $t \rightarrow^{*} v$ Indukcja po strukturze termu $t$. * Dla $t = v$ teza jest oczywista * Dla $t = t_1 \texttt{ AND } t_2$, to z zał. indukcyjnego jeśli $t_1 \Downarrow v_1$, to $t_1 \rightarrow^{*} v_1$, analogicznie dla $t_2$ i $v_2$ * Jeśli $v_1 = false$, to dla małych kroków otrzymujemy $t \rightarrow^{*} false \texttt{ AND } t_2 \rightarrow false$, analogicznie dla dużych kroków z pierwszej reguły. * Wpp. $v_1 = true$, to dla małych kroków otrzymujemy $t \rightarrow^{*} (true \texttt{ AND } t_2) \rightarrow t_2 \rightarrow^{*} v_2$, analogicznie wychodzi dla dużych kroków z drugiej reguły. ## 5.1 ![](https://i.imgur.com/WhXvebb.png) ![](https://i.imgur.com/H1Pj0Wi.png) ![](https://i.imgur.com/KtS5TDw.png) $$ t ::= \texttt{ true } | \texttt{ false } | \, x \, | \, \lambda (x:T).t \, | \, t \, t \, | \, \texttt{if } t \texttt{ then } t \texttt{ else } t $$ $$ v ::= \texttt{true } | \texttt{ false } | \, \lambda (x:T).t $$ ### Indukcja strukturalna (Progress): * $t ::= \texttt{true } | \texttt{ false } | \, \lambda (x : T).t$ $t$ jest wartością o konkretnym typie $T$ (typuje się do Bool albo $T\rightarrow T'$) * $t = \texttt{if } t_1 \texttt{ then } t_2 \texttt{ else } t_3$ $t_1 : \texttt{Bool}$, $t_2 : T$, $t_3 : T$ -- bo $t$ jest dobrze otypowane Z założenia indukcyjnego $t_1$ musi być wartością bądź $t_1$ redukuje się (jest progres). W przypadku gdy $t_1$ jest wartością (z otypowania jest to $\texttt{true}$ bądź $\texttt{false}$), możemy zastosować jedną z dwóch zasad redukcji ifa -- redukcja do $t_2$ bądź redukcja do $t_3$. * $t = x$ (przypadek nie może wystąpić -- brak zmiennych wolnych) * $t = t_1 \, t_2$ Z otypowania mamy, że $t_1 : T_1 \rightarrow T_2$, a $t_2 : T_1$. * Jeśli $t_1$ bądź $t_2$ nie jest wartością, to z założenia indukcyjnego możemy wykonać progres na $t_1$ bądź $t_2$. * W przeciwnym przypadku, $t_1, t_2$ są wartościami, z otypowania $t_1$ wiemy więc, że jest to $\lambda$ (lemat o postaciach kanonicznych), więc możemy wykonać podstawienie. ### Indukcja strukturalna (Preservation): #### Lemat o prezerwacji typów przy podstawieniu $\Gamma, x : S \vdash t : T \, \land \, \Gamma \vdash s : S \implies \Gamma \vdash [x \rightarrow s]t : T$ * $t = x$, stąd typ $S$ i typ $T$ są takie same. $[x \rightarrow s]t=s$, a więc po podstawieniu uzyskujemy typ $S$, a z poprzedniego faktu wiemy, że jest on równy typowi $T$. * $t = z \neq x$, po podstawieniu nie zmienimy $t$, więc typ pozostanie niezmieniony. * $t : T = \lambda z:T_2.t_1$, zgodnie z konwencją zakładamy, że $z$ jest nową zmienną różną od $x$ i $z \notin FV(s)$. Zauważmy, że po rozszerzeniu kontekstu przez $z : T_2$, nie zmieni to otypowania $s$, więc możemy z założenia indukcyjnego skorzystać dla $t_1$. $\Gamma, z:T_2 , x : S \vdash t_1 : T_1 \, \land \, \Gamma, z:T_2 \vdash s : S \implies \Gamma, z:T_2 \vdash [x \rightarrow s]t_1 : T_1$ * $t = \texttt{true } | \texttt{ false}$ (patrz punkt $2$) * $t = t_1 \, t_2$, z indukcji pokazujemy, że $t_1$ i $t_2$ zachowują typy, więc $t$ również zachowuje typ. * $t = \texttt{if } t_1 \texttt{ then } t_2 \texttt{ else } t_3$, z indukcji pokazyjemy, że $t_1, t_2, t_3$ zachowują typy, więc $t$ również zachowuje typ. Dokładnie tak samo, jak progres (przy aplikacji korzystamy z lematu). * $t ::= \texttt{true } | \texttt{ false } | \, \lambda (x : T).t$ Nieważne, bo nie ma kroku * $t = \texttt{if } t_1 \texttt{ then } t_2 \texttt{ else } t_3$ $t_1 : \texttt{Bool}$, $t_2 : T$, $t_3 : T$ -- bo $t$ jest dobrze otypowane Jeśli $t_1$ robi krok, to z zał. indukcyjnego ok. Jeśli znikamy ifa, to $t_2:T, t_3:T$, więc typ wyrażenia zostaje taki sam * $t = x$ (przypadek nie może wystąpić -- brak zmiennych wolnych) * $t = t_1 \, t_2$ Jeśli $t_1, t_2$ robi krok, to z zał. ind. typ zostaje. Jeśli $t_1, t_2$ to wartości, to $t_1 = \lambda x:T_2. t_3 : T_2 \rightarrow T$ z inwersji, bo $t$ był dobrze otypowany. Z dobrego otypowania lambdy wiemy, że $x:T_2 \vdash t_3:T$. A z dobrego otypowania $t_2$ wiemy, że $\vdash t_2:T_2$. Mamy załozenia lematu o prezerwacji typów. Więc $\vdash [x \rightarrow t_2]t_3 : T$. ## Lista rzeczy o które chcemy dopytać: - inwersja vs postać kanoniczna - zapytać o feedback jakiegoś dowodu progress i preservation - zad. 5.4 ## Zadania z konsów powtórkowych ### Progress/preservation (zadanie 9.3) Najważniejsze rzeczy o których trzeba pamiętać: - odpowiednio skwantyfikowane obiekty (np. jak powołujemy się na założenie indukcyjne, i rozważamy jakąś gammę/mi/cokolwiek) - lemat o postaciach kanonicznych/inwersja: one działają w inne strony, stosujemy je zależnie od kierunku rozumowania; nie trzeba ich dowodzić, ale trzeba się powołać tam gdzie ich używamy. Lemat o postaciach kanonicznych mówi o tym jak mogą wyglądać postacie normalne danych typów, a inwersja mówi jaki typ musi mieć term który wygląda w dany sposób. - ma być niby tylko kawałek dowodu do zrobienia, więc liczy się żeby to co napiszemy było jasne i precyzyjne (można pisać ze coś jest analogiczne, jeśli się już w jednym przypadku to rozpisało dokładnie) ### Rachunek lambda z możliwością leniwej ewaluacji wybranych termów Jakie są nowe regły? Składnia: $$ t :=\ ... | Lt $$ Reguły: $$ \frac{t \rightarrow_L t'}{Lt \rightarrow_G Lt'} $$ $$ \frac{}{Lv \rightarrow_G v} $$ $$ \frac{}{Lt \rightarrow_L t} $$ ### Izomorfizm typów (zadanie 8.5) Musimy dokładnie powiedzieć co pokazujemy i jak zachowują się definicje dla pojawiających się u nas typów (np. jak definiujemy ekstensjonalną równość par), a następnie wskazać odpowiednie funkcje $forth$ i $back$. Pewnie też wypada uzasadnić dlaczego ich złożenia dają to co chcemy jeśli nie jest to oczywiste (my tego nie robiliśmy, ale rozważyliśmy tylko pierwszy przykład, gdzie było to widać). ### Generalne uwagi - piszemy od 10 do 12, ale ma być jakiś dodatkowy czas na wysłanie (chyba 15 min) - będzie prawdopodobnie wspólne dla obu grup spotkanie na teamsie, gdzie będzie można zadawać pytania do zadań itd. - mają być 4 zadania: jedno trudniejsze, trzy standardowe - trudnością ma być czas oraz klarowne zapisanie wszystkiego, dobrze sobie rozplanować jakoś na początku na co ile czasu chcemy wstępnie poświęcić - zadania należy pisać ręcznie na kartce i wrzucić zdjęcia/skany/itp. na skosa

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully