dylanshong226
    • 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
    # Lab: Assumptions in Proofs ## Problem 1: Narrowing down the possibilities ~~~racket (define f1 (lambda (name) (cond [(equal? name "Alice") 0] ; Point A [(equal? name "Bob") 1] ; Point B [(equal? name "Carol") 2] ; Point C [(not (equal? name "Daniel")) 3] ; Point D [(not (equal? name "Emily")) 4]))) ; Point E (define f2 (lambda (x y) (cond [(>= y 1) 0] ; Point A [(or (>= x 1)) 1] ; Point B [(== x -1) 2] ; Point C [(or (<= x -5) (>= y 3)) 3] ; Point D [(== x 0) 4] ; Point E [(== x y) 5]))) ; Point F ~~~ 1. In f1 name is a string and in f2 x y are real numbers. 2. f1: Point A: When `(equal? name "Alice")== #t` then name is "Alice" Point B: When `(equal? name "Bob")== #t` then name is "Bob" Point C: When `(equal? name "Carol")== #t` then name is "Carol" Point D: When `(not(equal? name "Daniel"))== #t` then name is not "Daniel" or the previously named strings above. Point E: When `(not(equal? name "Emily"))== #t` then name has to be "Daniel" f2: Point A: When `(>= y 1) == #t` then y is greater than or equal to 1. Point B: When `(or (>= x 1)) == #t` then x is greater than or equal to 1 and y is less than 1. Point C: When `(== x -1) == #t` then x is equal to -1 and y is less than 1. Point D: When `(or (<= x -5) (>= y 3)) == #t` then x is less than or equal to -5 and y is less than 1. Point E: When `(== x 0) == #t` then x is equal to 0 and y is less than 1. Point F: When `(== x y) == #t` then x is equal to y and are between the values 1 and -5, but not 0 and -1. 3. f1 is exhaustive because when the guards are evaluated, every string will evaluate to true under one of the guards. f2 is not exhaustive because there are cases that won't evaluate to true: when x and y are not equal, x is between 1 and -5, y is less than 1, and x is not 0 and -1 ## Problem 2: Capture ~~~racket (define report (lambda (hw-avg quiz1 quiz2 quiz3) (cond [(and (> hw-avg 90) (> quiz1 90) (> quiz2 90) (> quiz3 90)) "excelling"] [(and (> hw-avg 75) (<= quiz1 quiz2) (<= quiz2 quiz3)) "progressing"] [(or (< hw-avg 60) (< quiz1 60) (< quiz2 60) (< quiz2 60)) "needs help"] [else "just fine"]))) ~~~ 1. Preconditions: `hw-avg` is a non-negative real numbers between 0 and 100. `quiz 1` is a non-negative real numbers between 0 and 100. `quiz 2` is a non-negative real numbers between 0 and 100. `quiz 3` is a non-negative real numbers between 0 and 100. 2. `(report hw-avg quiz1 quiz2 quiz3)` will return `"just fine"` when all parameters are above 60 and below 90, and either `hw-avg` is below 75, or `quiz 1` is greater than `quiz 2`, or `quiz 2` is greater than `quiz 3`. 3. We don't think there would be any case in which the function will return an inappropriate string, given that the input satisfy the preconditions. In the case that the input doesn't satisfy the preconditions, the function will either return an error message (for string type input for example), or progress as usually, deceived by integer type input. ## Problem 3: Looking Ahead ~~~racket (define append (lambda (l1 l2) (if (null? l1) l2 (cons (car l1) (append (cdr l1) l2))))) ~~~ **Claim 1** (Nil Is An Identity on the Left): for any list`l`, `(append '() l)` ≡ `l` *Proof*: Evaluating the left hand side: for `l` is any list: ~~~racket -->(append `() l) -->(if (null? `()) l (cons (car `()) (append (cdr `()) l))) -->(if #t l (cons (car `()) (append (cdr `()) l))) -->l -->l ≡ l ~~~ *Conclusion*: The Left hand side evaluates to `l` which is exactly equivelent to the right and therefore the claim holds. **Claim 2** (Append is Not Commutative): there exists lists `l1` and `l2` such that `(append l1 l2)` ≡ `(append l2 l1)`. *Proof*: Evaluating the left hand side and right hand side for `l1` and `l2` with different content. `l1 = '(a b c)` `l2 = '(x y z)` * Evaluating the left hand side: ~~~racket --> (append l1 l2) --> (if (null? l1) l2 (cons (car l1) (append (cdr l1) l2))) --> (cons (car l1) (append cdr l1) l2) --> (cons a (append '(b c) '(x y z))) --> (cons a (if (null? '(b c)) '(x y z) (cons (car '(b c)) (append (cdr '(b c)) '(x y z))))) --> (cons a (cons b (if (null? '(c)) '(x y z) (cons (car '(c)) (append (cdr '(c)) '(x y z)))))) --> (cons a (cons b (cons c (if (null? '()) '(x y z) (cons (car '()) (append (cdr '()) '(x y z))))))) --> (cons a (cons b (cons c '(x y z)))) --> (cons a (cons b '(c x y z))) --> (cons a '(b c x y z)) --> '(a b c x y z) ~~~ * Evaluating the right hand side: ~~~racket --> (append l2 l1) --> (if (null? l2) l1 (cons (car l2) (append (cdr l2) l1))) --> (cons (car l2) (append cdr l2) l1) --> (cons x (append '(y z) '(a b c))) --> (cons x (if (null? '(y z)) '(a b c) (cons (car '(y z)) (append (cdr '(y z)) '(a b c))))) --> (cons x (cons y (if (null? '(z)) '(a b c) (cons (car '(z)) (append (cdr '(z)) '(a b c)))))) --> (cons x (cons y (cons z (if (null? '()) '(a b c) (cons (car '()) (append (cdr '()) '(a b c))))))) --> (cons x (cons y (cons z '(a b c)))) --> (cons x (cons y '(z a b c))) --> (cons x '(y z a b c)) --> '(x y z a b c) ~~~ *Conclusion*: Since `'(a b c x y z) =! '(x y z a b c)`, it is safe to conlude that there exists `l1`, `l2` such that `(append l1 l2) =! (append l2 l1)`. **Claim 3** (Nil Is An Identity on the Right): for any list `l`, `(append l '())` ≡ `l` *Proof*: Evaluating the left hand side for `l` is any list. ~~~racket -->(append l '()) -->(if (null? l) '() (cons (car l) (append (cdr l) '()))) -->(cons (car l) (append (cdr l) '())) -->(cons (car l ) (if (null? (cdr l)) '() (cons (car (cdr l) (append (cdr (cdr l)) '()))))) ~~~ *Conclusion*: Since we are assuming `l` is any list we have no way to prove that this function will return an output since we don't know the length of the list. **4:** * *Why were you able to directly prove the left-identity claim?* We were able to directly prove the left-identity claim because the first input was null `append` can evaluate it immediately. Here, `(null? '())` will evaluate to `#t`, `append` returns `l2` and terminates the loop. * *Why is the right-identity claim more difficult to prove?* Assuming `l` is an unspecified list, the right-identity claim is more difficult to prove because `append` will evaluate the list `l` first and `cons` elements of `l` and continuously loop itself with `(cdr l)` as input. Since `l` is not specified, its content and length is also unknown, meaning arbitrary evaluation could go on infinitely. * *What information do you need in order to break the chain of infinite reason that you found in the previous proof?* If we're given specified length or content, the chain of infinite reason will be broken. However, we're not sure if specifications will allow us to prove universal claim. Another option we have is that we can assume that the list is going to end at some point.

    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