pgarn
    • 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
    # BD 30.03.2021 ## zad.1 ### Piotr Piesiak Z wykładu wiemy, że jeśli zapytanie koniunkcyjne jest spełnione w danej bazie danych, to równoważnie kanoniczna baza danych (indukowana przez to zapytanie) jest homomorficzna do tej bazy danych. Tzn. $D |= Q \iff \exists h: D^Q \rightarrow D$. Stwórzmy zatem zapytanie koniunkcyjne zawierające wszystkie krawędzie z grafu G. Wtedy $D^Q = G$. Będzie ono miało postać $Q(x_1, x_2, ... , x_n) :- E(x_1, x_i),E(x_j,x_z)\ldots$. Z zadania 5 listy 3, wiemy że istnienie homomorfizmu między grafem G, a kliką 3 wierzchołkową jest równoważne 3- kolorowalności grafu G. Wystarczy zatem sprawdzić czy zapytanie Q będzie spełnione w bazie danych postaci $K_3$. Wtedy z lematu i poprzedniej listy, graf G będzie 3-kolorowalny. Czas ewaluacji takiego zapytania to $O(3^n)$, gdzie n to rozmiar zapytania (ograniczony). ### Maurycy Borkowski Stwórzmy zapytanie $Q$ biorąc krawędzie z grafu $G$ jako składowe zapytania. Oczywiście kanoniczna baza zapytania $Q$ to będzie $G$: $G = D^Q$ A bazę weźmy $D = K_3$ Z lematu z wykładu wiemy, że $Q$ jest spełnione w $D$ wtw. gdy istnieje homomorfizm $h: D^Q \rightarrow D$ Dodatkowo wiemy z L3Z5, że stwierdzenie czy graf jest 3 kolorowalny jest równoważne stwierdzeniu czy istnieje homomorfizm w klikę $K_3$ z badanego grafu. $Q$ spełnione w $D (= K_3)$ $\overset{lemat}{\iff}$ istnieje $h: D^Q \rightarrow D = K_3$ $\overset{L3Z5}{\iff}$ $D^Q = G$ 3-kolorowalny ## zad.2 ![](https://i.imgur.com/eHGR6io.png) dla $2^i$ nie jest to prawda, ale dla $2^{i-1}$ już tak ### Jonatan Hrynko Teza indukcyjna $T^n$ = $E \cup E^2 \cup \dots \cup E^{2^{n-1}}$ baza indukcji n = 1: $T^1 = E$, czyli ścieżki długości $1 = 2^0 = 2^{1-1}$ krok indukcji: dla każdego i < n mamy, że $T^i$ = $E \cup E^2 \cup \dots \cup E^{2^{i-1}}$ T(X, Y) :- T(X, Z), T(Z, Y) zatem $T^n = \{(x, y) : E(x, y) ∨ \exists z (T^{n-1}(x, z) ∧ T^{n-1}(z, y))\}$ czyli w $T^n$ mamy wszystkie ścieżki długości 1, oraz ścieżki długości od 2 do $2\cdot2^{n-2} = 2^{n-1}$ ### Michał Hetnar $T^{n+1}=((a,b): E(a,b) \lor \exists z(T^n(a,z) \land T^n(z,b)) )$ $T^1$=E(a,b)=ściezka dł 1 dla n =1 2^n-1 =2^0 = 1 $B^n$-ścieżka dł n $$T^n= B^{2pow(n-1)} \lor ... \lor B^1 $$ $T^{n+1}=((a,b): E(a,b) \lor \exists z((B(a,z)^{2pow(n-1)} \lor ... \lor B^1 ) )\land( B(z,b)^{2pow(n-1)} \lor ... \lor B^1) )$ $T^{n+1}=((a,b): E(a,b) \lor (B(a,b)^{2pow(n)} \lor ... \lor B^2 )$ $T^{n+1}=((a,b): B(a,b)^{n} \lor B(a,b)^{2pow(n)} \lor ... \lor B^2 \lor B^1)$ ## zad.3.1 Maciej Zientara T(x,y) = E(x,y) T(x,y) = E(x,z), T(z,y) WWSS = wszystkie wierzchołki spójnej składowej dom(T(n,x)) $\cup$ dom(T(m,x)) WWSS zawierającej n zsumowane z WWSS zawierającej m Krzysztof Wiśniewski ![](https://i.imgur.com/ZwAIsTA.png) ## zad.3.2 Krzysztof Łyskawa $Q() :- T(x)$ $T(x) :- R(x), S(x)$ $S(x) :- E(n, x)$ $S(x) :- E(y, x), S(y)$ $R(x) :- E(m, x)$ $R(x) :- E(y, x), R(y)$ Adam Turowski $T(y)$ - do wierzchołka $y$ istnieje ścieżka z $n$ i $m$ $T(y)$ $:-$ $E(n, y), E(m, y)$ $T(y)$ $:-$ $E(n, y), E(m, z), N(z, y)$ $T(y)$ $:-$ $E(n, z), E(m, y), N(z, y)$ $T(y)$ $:-$ $E(n, z), E(m, x), N(z, y), N(x, y)$ $N(x, y)$ - istnieje ścieżka z $x$ do $y$ $N(x, y)$ $:-$ $E(x, y)$ $N(x, y)$ $:-$ $E(x, z), N(z, y)$ ## zad.3.3 **Treść:** Zwróć pary wierzchołków, do których można dojść z wierzchołka n ścieżkami o tej samej długości. ------ Karol Machoś **$T(x,y)$ - do wierzchołków $x$ i $y$ prowadzą równej długości ścieżki z $n$** $T(x, y)$ $:-$ $E(n, x), E(n, y)$ $T(x, y)$ $:-$ $E(n, z), E(n, w), N(z, x, w, y)$ **$N(u,v,p,q)$ - z wierzchołka $u$ istnieje ścieżka do wierzchołka $v$, oraz z wierzchołka $p$ istnieje ścieżka do $q$ i są one równej długośći.** $N(u, v, p, q)$ $:-$ $E(u, v), E(p, q)$ $N(u, v, p, q)$ $:-$ $E(u, a), E(p, b), N(a, v, b, q)$ ----------- Martyna Firgolska SAME(X, Y) :- E(n, X), E(n, Y) SAME(X, Y) :- SAME(A, B), E(A, X), E(B, Y) ## zad.3.4 #### Filip Komorowski $T(x,y):-E(n,x),E(n,b),P(b,y)$ $T(x,y):-E(n,y),E(n,b),P(b,x)$ $T(x,y):-E(a,x),E(b,y),T(a,b)$ $P(u,w):-E(u,w)$ $P(u,w):-E(u,x),P(x,w)$ #### Łukasz Stasiak zad4(X,Y) :- edge(n,X), temp(n,Y). zad4(X,Y) :- edge(U,X), edge(V,Y),zad4(U,V). temp(A,B) :- edge(A,C), edge(C,B). temp(A,B) :- edge(A,C), temp(C,B). ![](https://i.imgur.com/XNs2x99.png) ![](https://i.imgur.com/q7ynGbN.png) ![](https://i.imgur.com/GMmM8H1.png) ## zad.4 **Treść:** Wiadomo, że graf jest 2-kolorowalny wtedy i tylko wtedy gdy nie zawiera cyklu o nieparzystej długości. Napisz zapytanie datalogowe Q() spenione w grafach, które nie są 2-kolorowalne. ---------------------- Martyna Firgolska ODD(X, Y) :- E(X, Y) EVEN(X, Y) :- ODD(X, Z), E(Z, Y) ODD(X, Y) :- EVEN(X, Z), E(Z, Y) ODDCYCLE() :- ODD(X, X) ------------------------ Karol Machoś $Q(x)$ $:-$ $N(x, x)$ <- istnieje ściezka o nieparzystej długości z x do x (cykl o nieparzystej długości) $N(x, y)$ $:-$ $E(x, y)$ $N(x, y)$ $:-$ $E(x, z), P(z, y)$ $P(x, y)$ $:-$ $E(x, z), N(z, y)$ ====== szukamy cyklu nieparzystej długości T(x,y) = E(x,y) T(x,y) = E(x,a), T(a,b), E(b,y) uruchamiamy z T(x,x) ## zad.5 **Treść:** 1. Czy można napisać zapytanie datalogowe spełnione wtw gdy w grafie nie ma ścieżki pomiędzy wyróżnionymi wierzchołkami n i m ? 2. Czy można napisać zapytanie datalogowe speanione wtw gdy graf zawiera parzystą liczbę wierzchołków? ### Jonatan Hrynko 1. NIE Ta własność nie jest zachowywana dla rozszerzenia grafu. Możemy zrobić zapytanie, które nam zwróci wierzchołki na ścieżce z n do m, ale nie możemy odwrócić tego zapytania. 2. NIE Załóżmy, że istnieje takie zapytanie Datalogowe, które nam zwraca prawdę wtw. gdy graf zawiera parzystą liczbę wierzchołków. Zapytanie to korzysta z bazy danych krawędzi E(X, Y), zatem jeśli do grafu dodamy wierzchołek izolowany, to zapytanie zwróci taki sam wynik, co dla grafu bez tego dodanego wierzchołka izolowanego, zatem zwraca taki sam wyniki niezależnie od parzystości. ### Maciej Zientara 1) T(x,y) = E(x,y) T(x,y) = E(x,z), T(z,y) dom(T(n,x)) \ dom(T(m,x)) (dostaniemy zbiór pusty, jeżeli jest ścieżka z n do m, wpp dostaniemy zbiór wierzchołków spójnej składowej z n) 2) NIE można sprawdzać parzystość ścieżki, ale graf może mieć rozgałęzienia nie wchodzące w skład rozpatrywanej ścieżki np dla drzewa, gdzie mamy korzeń i 5 wierzchołków z nim połączonych najdłuższa ścieżka ma długość 2 krawędzi ale nie uwzględni przy jej przechodzeniu pozostałych 4 wierzchołków ## zad.6 -

    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