Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
62f220c
Update README.md
katiejohnso Mar 3, 2023
902f6e0
Update README.md
katiejohnso Mar 3, 2023
8f1208b
Update README.md
katiejohnso Mar 5, 2023
5162ed5
Update README.md
katiejohnso Mar 5, 2023
8e2b08c
Update README.md
katiejohnso Mar 5, 2023
7f4809f
Update README.md
katiejohnso Mar 5, 2023
b0ad19d
Update README.md
katiejohnso Mar 5, 2023
cf01736
Update README.md
katiejohnso Mar 5, 2023
8ede7f6
Update README.md
katiejohnso Mar 5, 2023
caf6483
Update README.md
katiejohnso Mar 7, 2023
b2dbc60
Update README.md
katiejohnso Mar 8, 2023
b2f1517
Update README.md
katiejohnso Mar 8, 2023
b3f0710
Update README.md
katiejohnso Mar 8, 2023
e77cb23
Update README.md
katiejohnso Mar 8, 2023
b2e70fd
Update README.md
katiejohnso Mar 10, 2023
6202c06
Update README.md
katiejohnso Mar 10, 2023
bbc0c52
Update README.md
katiejohnso Mar 21, 2023
20005f8
Update README.md
katiejohnso Mar 21, 2023
5f18b79
Update README.md
katiejohnso Mar 21, 2023
9af64cb
Update README.md
katiejohnso Mar 21, 2023
d69a96c
Update README.md
katiejohnso Mar 21, 2023
adf64a2
Update README.md
katiejohnso Mar 23, 2023
a33c4d6
Update README.md
katiejohnso Mar 23, 2023
37bf74b
Update README.md
katiejohnso Mar 23, 2023
6ef14a4
Update README.md
katiejohnso Mar 23, 2023
ff914df
Update README.md
katiejohnso Mar 23, 2023
0e66b25
Update README.md
katiejohnso Mar 23, 2023
73044a2
Update README.md
katiejohnso Mar 27, 2023
ce3c929
Update README.md
katiejohnso Apr 2, 2023
c89148c
Update README.md
katiejohnso Apr 2, 2023
46cf57d
Update README.md
katiejohnso Apr 3, 2023
f82fbd9
Merge branch 'johnbeve:main' into main
katiejohnso Apr 3, 2023
3c3d5ce
Update Project-5.md
katiejohnso Apr 16, 2023
26da228
Update Project-5.md
katiejohnso Apr 16, 2023
e71eb16
Merge pull request #3 from katiejohnso/katiejohnso-patch-5
katiejohnso Apr 16, 2023
705413d
Update README.md
katiejohnso May 5, 2023
c3a718f
Merge pull request #2 from katiejohnso/katiejohnso-patch-3
katiejohnso May 5, 2023
477ebd6
Update README.md
katiejohnso May 8, 2023
080171b
Merge pull request #5 from katiejohnso/katiejohnso-patch-7
katiejohnso May 8, 2023
ac671c9
Update README.md
katiejohnso May 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions Project 4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,77 @@ You're probably thinking, "why would I submit a level 8 kata if they're not wort
It is your responsibility and the responsibility of your peers reviewing your submission in PR to determine whether your submission is ranked appropriately. In the event that consensus is reached that your kata is ranked inappropriately, you must work with your peers to revise the submission so that it is either more or less challenging, accordingly. You are not permitted to submit new problems with different strengths after PRs are open, but must instead revise your PRs. So, think hard about how challenging your submission is.

There is one other option for those desiring a different sort of challenge. If you provide alongside your SPARQL submission a translation of the same problem into SQL, complete with documentations, solution, etc. then you may receive half points extra at that kata level (rounded up). For example, if you submit a SPARQL problem that is kata rank 1 and also submit a SQL version of that same problem, you will receive 35+18=53 points.

1) Write a query that returns all object properties in dbpedia.

Reference solution:
select ?p

where{
?s ?p ?o
}

2) Write a SPARQL quiery that retrieves the name, birthplace, birth date, genre, latitude, longitude, label, and abstract of actors born after 1950, along with information about their birthplaces.

Hint:
This question uses four query forms:

Triple patterns to retrieve the actor's name and birthplace, as well as the birth date of each actor.
A property path to retrieve the genres of the movies each actor appeared in.
A set of triple patterns to retrieve the coordinates, label, and abstract of each birthplace.
Filter expressions to restrict the birth date to after 1950 and the birthplace label to English.

The query also uses a combination of operators and functions, including:

The LANGMATCHES function to match English-language labels.
The STRDT function to convert the birth date string to a date datatype for comparison.
The ORDER BY clause to sort the results by actor name.
Triple patterns to retrieve the actor's name and birthplace, as well as the birth date of each actor.
A property path to retrieve the genres of the movies each actor appeared in.
A set of triple patterns to retrieve the coordinates, label, and abstract of each birthplace.
Filter expressions to restrict the birth date to after 1950 and the birthplace label to English.

The query also uses a combination of operators and functions, including:

The LANGMATCHES function to match English-language labels.
The STRDT function to convert the birth date string to a date datatype for comparison.
The ORDER BY clause to sort the results by actor name.

Reference solution:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

SELECT DISTINCT ?actor ?actorName ?birthPlace ?birthDate ?genre ?latitude ?longitude ?label ?abstract
WHERE {
# Query 1: Retrieve actors and their birthplaces
?actor a dbo:Actor ;
foaf:name ?actorName ;
dbo:birthPlace ?birthPlace .

# Query 2: Retrieve the birth date of each actor
?actor dbo:birthDate ?birthDate .

# Query 3: Retrieve the genres of the movies each actor appeared in
?actor dbo:starring ?movie .
?movie dbo:genre ?genre .

# Query 4: Retrieve the coordinates, label, and abstract of each birthplace
?birthPlace geo:lat ?latitude ;
geo:long ?longitude ;
rdfs:label ?label ;
dbo:abstract ?abstract .

# Filter actors born after 1950
FILTER(STRDT(?birthDate, xsd:date) > "1950-01-01"^^xsd:date)

# Filter birthplaces with a label in English
FILTER(LANGMATCHES(LANG(?label), "en"))

} ORDER BY ?actorName






210 changes: 208 additions & 2 deletions Project-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,164 @@ Note: The standard interpretation of the logical symbols - "∨", "∧", "→",
(b) (A→B)∧(A→¬B)
(c) (A→(B∨C))∨(C→¬A)
(d) ((A→B)∧C)∨(A∧D)

(a) (¬A→B)∨((A∧¬C)→B), Tautology
A B C ((¬A → B) ∨ ((A ∧ ¬C) → B))
F F F T
F F T T
F T F T
F T T T
T F F T
T F T T
T T F T
T T T T
(b) (A→B)∧(A→¬B), Contingent
A B ((A → B) ∧ (A → ¬B))
F F T
F T T
T F F
T T F
(c) (A→(B∨C))∨(C→¬A), Tautology
A B C ((A → (B ∨ C)) ∨ (C → ¬A))
F F F T
F F T T
F T F T
F T T T
T F F T
T F T T
T T F T
T T T T
(d) ((A→B)∧C)∨(A∧D), Contingent
A B C D (((A → B) ∧ C) ∨ (A ∧ D))
F F F F F
F F F T F
F F T F T
F F T T T
F T F F F
F T F T F
F T T F T
F T T T T
T F F F F
T F F T T
T F T F F
T F T T T
T T F F F
T T F T T
T T T F T
T T T T T
```

2. A _literal_ is an atomic formula or the negation of an atomic formula. We say a formula is in _conjunctive normal form_ (CNF) if it is the conjunction of the disjunction of literals. Find propositional logic formulas in CNF equivalent to each of the following:
```
(a) (A→B)→C
(b) (A→(B∨C))∨(C→¬A)
(c) (¬A∧¬B∧C)∨(¬A∧¬C)∨(B∧C)∨A

(A→B)→C, CNF: (A∨C)∧(¬B∨C)
(1) ¬(A→B)∨C
(2) ¬(¬A→B)∨C
(3) ¬(A→ ¬B)∨C
(4) (A∨C)∧ (¬B∨C)

(b) (A→(B∨C))∨(C→¬A), CNF: B ∨ ¬B (tautology)

(c) (¬A∧¬B∧C)∨(¬A∧¬C)∨(B∧C)∨A, CNF: B ∨ ¬B (tautology)

```

3. Let V be the vocabulary of first-order logic consisting of a binary relation P and a unary relation F. Interpret P(x,y) as “x is a parent of y” and F(x) as “x is female.” Where possible define the following formulas in this vocabulary; where not possible, explain why:

```
(a) B(x,y) that says that x is a brother of y

B(x,y) <--> ∃z((Pzx ∧ Pzy) ∧ x ≠ y ∧ ~Fx)

(b) A(x,y) that says that x is an aunt of y
(c) C(x,y) that says that x and y are cousins

A(x,y) <--> ∃z((Fx ∧ Pzy ∧ ∃w(Pwx ∧ Pwz ∧ x ≠ z))

(c) C(x,y) that says that x and y are cousins

C(x,y) <--> ∃z∃w∃r(Pzx ∧ Pwy ∧ Prz ∧ Prw ∧ z ≠ w ∧ x ≠ y)


(d) O(x) that says that x is an only child

O(x) <--> ∃y∀z(Pyx ∧ (Pyz --> z = x))

(e) T(x) that says that x has exactly two brothers

∃y∃z∃w(¬(w=z)∧¬(x=w)∧¬(x=z)∧P(y,x)∧P(y,z)∧P(y,w)∧¬F(z)∧¬F(w))∧∀r(P(y,r)∧¬F(r)→ r=x ∨ r=z ∨ r=w)

```

4. Let V be a vocabulary of the attribute (concept) language with complements (ALC) consisting of a role name "parent_of" and a concept name "Male". Interpret parent_of as "x is a parent of y" and M as "x is male". Where possible define the following formulas in this vocabulary; where not possible, explain why:
```
(a) B that says that x is a brother of y

p2 (parent of at least 2 children) ≡ ≥2 ∃parent_of.Person
B ≡ M ⊓ ∃p2¯.Person

(b) A that says that x is an aunt of y

A ≡ ¬M ⊓ (∃p2¯.(≥ 2 parent_of. (∃parent_of. Person)) ⊔ ¬∃parent_of. Person)

(c) C that says that x and y are cousins

C ≡ gp2¯. Person

Cousins cannot be defined in description logic, therefore, this statement only describes on of the two cousins (i.e. "being a cousin of someone.") Thank you Karl for the clarification.

(d) O that says that x is an only child

parent_only (be a parent of exactly one child) ≡ (≥1 parent_of. Person) ⊓ (≤1 parent_of. Person)
O ≡ ∃parent_only¯.Person

(e) T that says that x has exactly two brothers

p3m (be a parent of exactly three male children) ≡ (≥3 parent_of. Male) ⊓ (≤3 parent_of. Male)
p1 (be a parent of at least one child) ≡ ≥1 parent_of. Person -- the inverse of p1 is just "be a child of"!
T ≡ ∃p3m¯.Person ⊔ (¬M ⊓ ∃p1¯. (≥2 parent_of. Male ⊓ ≤2 parent_of. Male))

```


5. Select two formulas defined in ALC from question 4 to form the basis of a T-Box. Supplement this T-box with whatever other axioms you like, as well as an A-box, so that you ultimately construct a knowledge base K = (T,A). Provide a _model_ of K. This may be graphical or symbolic or both.
5. Select two formulas defined in ALC from question 4 to form the basis of a T-Box. Supplement this T-box with whatever other axioms you like, as well as an A-box, so that you ultimately construct a knowledge base K = (T,A). Provide a _model_ of K. This may be graphical or symbolic or both.

B ≡ M ⊓ ∃p2¯.Person
O= parent_of (∃parent_of=1)

Tom: B
Joe: B
Jill: O
(Jill, Tom): parent_of
(Jill, Joe): parent_of

6. Explain the difference - using natural language - between the first-order prefixes:
```
(a) ∃x∀y and ∀x∃y
∃x∀y = there exists some x such that for all y
∀x∃y = for all x there exists some y

(b) ∃x∀y∃z and ∀x∃y∀z
∃x∀y∃z = there exists some x such that for all y there exists some z
∀x∃y∀z = for all x there exists some y such that for all z

(c) ∀x∃y∀z∃w and ∃x∀y∃z∀w
∀x∃y∀z∃w = for all x there exists some y such that for all z there exists some w
∃x∀y∃z∀w = there exists some x for all y such that for some z there exists all w
```

7. Show that the following sentences are not equivalent by exhibiting a graph that models one but not both of these sentences:
```
∀x∃y∀z(R(x,y) ∧ R(x,z) ∧ R(y,z))
for all x there exists some y such that for all z
x > y, x > z < y

∃x∀y∃z(R(x,y) ∧ R(x,z) ∧ R(y,z))
there exists some x for all y such that for all z
x > y, x > z > y

```

8. Using an online tableau proof generator - such as the one found here `https://www.umsu.de/trees/` - provide tree proofs of the following entailments, which are known as the De Morgan's laws:
Expand All @@ -67,9 +183,99 @@ Note: The standard interpretation of the logical symbols - "∨", "∧", "→",
(b) ∀x∀y(¬(Px ∨ Qx) → (¬Px ∧ ¬Qx))
(c) ∀x∀y((¬Px ∨ ¬Qx) → ¬(Px ∧ Qx))
(d) ∀x∀y((¬Px ∧ ¬Qx) → ¬(Px ∨ Qx))

(a) ∀x∀y(¬(Px ∧ Qx) → (¬Px ∨ ¬Qx))

(1) ¬∀x∀y(¬(Px ∧ Qx) → (¬Px ∨ ¬Qx))
(2) ¬∀y(¬(Pa ∧ Qa) → (¬Pa ∨ ¬Qa))
(3) ¬(¬(Pa ∧ Qa) → (¬Pa ∨ ¬Qa))
(4)¬(Pa ∧ Qa)
(5)¬(¬Pa ∨ ¬Qa)
(6).¬¬Pa
(7)¬¬Qa
(8)Qa
(9) Pa
(10) ¬Pa (11) ¬Qa
x x

(b) ∀x∀y(¬(Px ∨ Qx) → (¬Px ∧ ¬Qx))

(1) ¬∀x∀y(¬(Px ∧ Qx) → (¬Px ∨ ¬Qx))
(2) ¬∀y(¬(Pa ∧ Qa) → (¬Pa ∨ ¬Qa))
(3) ¬(¬(Pa ∧ Qa) → (¬Pa ∨ ¬Qa))
(4) ¬(Pa ∧ Qa)
(5) ¬(¬Pa ∨ ¬Qa)
(6) ¬¬Pa
(7) ¬¬Qa
(8) Qa
(9) Pa
(10) ¬Pa (11) ¬Qa
x x

(c) ∀x∀y((¬Px ∨ ¬Qx) → ¬(Px ∧ Qx))

(1) ¬∀x∀y((¬Px ∨ ¬Qx) → ¬(Px ∧ Qx))
(2) ¬∀y((¬Pa ∨ ¬Qa) → ¬(Pa ∧ Qa))
(3) ¬((¬Pa ∨ ¬Qa) → ¬(Pa ∧ Qa))
(4) ¬Pa ∨ ¬Qa
(5) ¬¬(Pa ∧ Qa)
(6) Pa ∧ Qa
(7) Pa
(8) Qa
(9) ¬Pa (10) ¬Qa
x x

(d) ∀x∀y((¬Px ∧ ¬Qx) → ¬(Px ∨ Qx))

(1) ¬∀x∀y((¬Px ∧ ¬Qx) → ¬(Px ∨ Qx))
(2) ¬∀y((¬Pa ∧ ¬Qa) → ¬(Pa ∨ Qa))
(3) ¬((¬Pa ∧ ¬Qa) → ¬(Pa ∨ Qa))
(4) ¬Pa ∧ ¬Qa
(5) ¬¬(Pa ∨ Qa)
(6) Pa ∨ Qa
(7) ¬Pa
(8) ¬Qa
(9) Pa (10) Qa
x x

```

9. Using a natural deduction proof generator - such as the one found here `https://proofs.openlogicproject.org/` - provide natural deduction proofs for each of De Morgan's laws.

¬∀x∀y(¬(Px ∧ Qx) → (¬Px ∨ ¬Qx))
(1) ¬(Px ∧ Qx) assumption
(2) ¬(¬Px ∨ ¬Qx) assumption
(3) (Px ∧ Qx) 2, negated disjunction
(4) ¬(Px ∧ Qx) 1,3 contradiction

∀x∀y(¬(Px ∨ Qx) → (¬Px ∧ ¬Qx))
(1) ¬(Px ∨ Qx) assumption
(2) (¬Px ∧ ¬Qx) assumption
(3) (Px ∨ Qx) 2, negated conjunction
(4) ¬(Px ∨ Qx) 1,3 contradiction

∀x∀y((¬Px ∨ ¬Qx) → ¬(Px ∧ Qx))
(1) (¬Px ∨ ¬Qx) assumption
(2) ¬¬(Px ∧ Qx) assumption
(3) (Px ∧ Qx) 2, double negation
(4) Px 3, conjunction
(5) Qx 3, conjunction
(6) (¬Px ∨ ¬Qx) 4,5,6 contradiction

∀x∀y((¬Px ∧ ¬Qx) → ¬(Px ∨ Qx))
(1) (¬Px ∧ ¬Qx) assumption
(2) ¬¬(Px ∨ Qx) assumption
(3) (Px ∨ Qx) 2, double negation
(4) ¬Px 1, conjunction
(5) ¬Qx 1, conjunction
(6) Px 3, disjunction
(7) ¬Qx 3, disjunction
(8) ¬Px 3, disjunction
(9) Qx 3, disjunction
(10) (¬Px ∧ ¬Qx) 6,7,8,9 contradiction

10. Compare and contrast the proofs provided for (a) in your answers to questions 8 and 9. Explain the different assumptions, strategies, etc. exhibited in tree proofs vs natural deduction proofs.

Both proofs deduce some kind of contradiction, but in different ways. 8a is a longer proof than 9a. Feedback from Josh (thank you!) also states that 9a does not require us to go down to the atomic parts of the formula, and stops at more complex contradictions.


Loading