Kaynağa Gözat

Added artificial intelligence lesson 9 and 10 and data bases exe 1

Federico Amedeo Izzo 9 yıl önce
ebeveyn
işleme
0d7db4a352

+ 92 - 0
Artificial Intelligence/lesson_09.md

@@ -0,0 +1,92 @@
+# AI - lesson 08
+#### Francesco Arrigoni
+###### 2 December 2015
+## First Order Logic
+
+### Inference prodecures for first order logic
+
+- __substitution__ $\theta = \{variable / ground term\}$
+
+- __unification__ $UNIFY(\alpha,\beta)=\theta \alpha\theta=\beta\theta$
+
+|$\alpha$|$\beta$|$\theta|
+|---|---|---|
+|knows(John,x)|knows(John,Jane)|{x|Jane\}|
+|knows(John,x)|knows(y,oj)|{x/oj,y/John}|
+|knows(John,x)|knows(y,Mother(y))|{y/John,x/Mother(John)}|
+|#knows(John,x)|#knows(x,oj)||
+|knows(John,x)|knows(x,y)|{x/John,y/John}|
+|knows(John,x)|knows(y,x)|{y/John}{y/John,x/Jane}|
+
+__Unification__ is about finding the values that make $\alpha$ and $\beta$ the same for a given row.
+
+An example algorithm that does this is comparing character per character the various strings.
+In the $\theta$ column we find the associations resulting from the comparison.
+For the # formulas there is no substitution that unifies the formulas.
+The last formulas represents a genereal cases that admits more substitutions as solutions.
+
+__MGU__ are the substitutions that are more *general*.
+
+If we have a __knowledge base__
+$$KB\iff\alpha$$
+$$KB\iff$$
+
+In the case of FOL if a substitution is possible, then the right $\theta$ value is returned.
+
+- __forward chaining__ 
+1. $king(John)$
+2. $(\forall y)Greedy(Y)$
+3. $(\forall x)king(x)\capGreedy(x)\rightarrow Evil(x)$
+4. $Evil(John)$
+
+1-2 are called __facts__ while 3-4 are called __rules__
+
+We can only derive new facts, not rules.
+In FOL it is possible to apply the same rule more than one time, while in Propositional Logic it was useless.
+In the case we have nested functions rules, we can apply them infinite times, this leads to *semi-decidability*.
+
+The quantifiers are needed for every variables to have a __Well Formed Formula__
+
+$\not king(Jane)$ this is not a definite clause and it is not WFF
+$king(John)\cup Greedy(John$ is also not a definite clause because it is not a conjunction of definite clauses.
+
+The main *inference rule* in FOL is called __Modus Ponens_
+$\quotient{p_1'p_2'...p_n' \; p_1\cap p_2\cap ... \cap p_n \rightarrow q}{q\theta}$
+##### example:
+$\quotient{kong(John)\; Greedy(y) \; king(x)\cap Greedy(x) \rightarrow Evil(x)}{Evil(John)}$
+
+#### Exercize
+Demonstrate that colonel West is guilty
+$\exists x \; Missile(x) \cap Owns (Nono,x)$
+$Missile(M)\cap Owns(Nono,M)$
+
+It is possible to prove that these two formulas are not *logically equivalent* (are not the same thing)
+But they are *inferentially equivalent* because you can infere the same results with each of them.
+
+1. $American(x)\cap Weapon(y) \cap Hostile(z) \cap Sells(x,y,z) \rightarrow Criminal(X)$
+2. $Missile(M)$
+3. $Owns(Nono,M)$
+4. $Missile(x)\cap Owns(Nono,x)\rightarrow Sells(West,x,Nono)$
+5. $American(West)$
+6. $Enemy(Nono,America)$
+7. $Missile(x)\rightarrow Weapon(x)$
+8. $Enemy(x,America)\rightarrow Hostile(x)$
+
+I can change the name of the *x* variable with another one because it is *universally quantified*
+Now we would like to prove the following formula.
+
+$\alpha : Criminal(West)$
+
+If we are using forward chaining, we have to apply the rules, as many times as possible.
+
+9. $Sells(West,M,Nono) \; MP(2,3,4) \; \theta ={x/M}$
+10. $Weapon(M) \; MP(2,7) \; \theta ={x/M}$
+11. $Hostile(Nono) \; MP(6,8) \; \theta ={x/Nono}$
+12. $Criminal(West) \; MP(5,10,11,9,1) \; \theta ={x/West, y/M, z/Nono}$
+
+### Algorithm
+Given the goal $\alpha:Criminal(West)$
+- Checks if the goal is already present in the set of rules
+- Then it applies Modus Ponens in a reverse order:
+	- the leafs of the goal node are all the rules required for the father node, and they are considered goals as well.
+- When all the leafs are satisfied i can say that i have 

+ 32 - 0
Artificial Intelligence/lesson_10.md

@@ -0,0 +1,32 @@
+# AI - lesson 10
+#### Francesco Arrigoni
+###### 4 December 2015
+## First Order Logic
+
+### Inference prodecures for first order logic
+
+- __Resolution__
+
+### Missing Part
+
+#### example
+
+1. $\not American(x)\cup \not Weapon(y) \cup \not Hostile(z)\cup \not Sells(x,y,z)\cup Criminal(x)$
+2. $American(West)$
+3. $\not Missile(x)\cup Weapon(x)
+4. $Missile(M)$
+5. $\not Missile(x)\cup \not Owns(Nono,x)\cup Sells(West,x,Nono)$
+6. $Owns(Nono,M)$
+7. $\not Enemy(x,America)\cup Hostile(x)$
+8. $Enemy(Nono,America)$
+9. $\not Criminal(West)$
+---
+10. $\not American(West)\cup \not Weapon(y)\cup \not Hostile(x) \cup \not Sells(West,y,z)$
+11. $\not Weapon(y)\cup \not Hostile(z)\not Sells(West,y,z) R(2,10)$
+12. $\not Missile(y)\cup \not Hostile(z) \cup \not Sells(West,y,z) R(3,11)$
+13. $\not Hostile(z)\cup \not Sells(West,M,z) R(4,12) \theta=\{Y/M\}$
+14. $\not Missile(M)\cup \not Owns(Nono,M)\cup \not Hostile(Nono) R(5,13)$
+15. $\not Owns(Nono,M)\cup \not Hostile(Nono) R(4,14) \theta=\{x|M,z|Nono\}$
+16. $\not Hostile(Nono) R(6,15)$
+17. $\not Enemy(Nono,America) R(7,16) \theta=\{x|Nono\}$
+18. $\eset$

+ 29 - 0
Data Bases 2/exe_01.md

@@ -0,0 +1,29 @@
+# DB2 - exercize session 01
+##### 27 October 2015
+## Concurrency Control
+
+### View-Serializability VSR
+
+Material on cs.unibg.it/mutti/
+
+If we have the same __final writes__ and __read from__ of a serial schedule
+
+- A __read-from__ means that the same object x was already written by another transaction,
+different from the one whic is now reading x.
+- A __final-write__ means that the object x is written and there are no others transaction
+
+#### Exercize:
+Classify the following schedules as non-vsr, vsr or csr.
+```
+r1(x) r2(y) w3(y) r5(x) w5(u) w3(s) w2(u) w3(x) w1(u) r4(y) w5(z) r5(z)
+```
+x|r1|r5
+---|---|---
+y|r2|w3
+u|w5|w2
+s|w3|
+z||
+
+### Blind writes
+
+A write is said to be __blind__ if it is not the last action of resource X and the following action on X is a write wj(x)