3. Proofs and Counterexamples. You can use the Tarski\'s World and Fitch program
ID: 3599771 • Letter: 3
Question
3. Proofs and Counterexamples. You can use the Tarski's World and Fitch programs where appro- priate, and print pictures for submission if you wish. However, if you design a counterexample in Tarski's World and submit a picture, explain briefly but carefully why the sentences you're consid- ering are true/false respectively in the world depicted. And for pictures of Fitch proofs, make sure you have line numbering switched on. Of course, it is perfectly acceptable to do counterexamples and proofs without using the programs. With proofs, make sure you give the justifications next to the lines (12.5) (a) Explain which step in the alleged proof set out in exercise 6.17 (p. 168) of the book is fallacious. In addition, set out a Tarski's World counterexample which shows that the conclusion cannot be proved from the premises. (b) As you can easily check, the statement (20) is a tautology. Give a proof of it in Fitch from no premises without using either Ana Con, (17.5) (c) Do question 6.40 from the textbook (p. 177). In giving a proof, do not use either Ana (12.5) (d) Do question 8.47 from the textbook (p. 224). (If you do a proof, give one without using (12.5) (e) Do question 8.48 from the textbook (p. 224). (If you do a proof, give one without using Taut Con or FO Con. Con, Taut Con or FO Con as justifications. Ana Con, Taut Con or FO Con.) Ana Con, Taut Con or FO Con.)Explanation / Answer
package com;
public class DList<T> {
private DNode<T> header, trailer;
private int size;
public DList() {
size = 0;
header = new DNode<T>(null, null, null);
trailer = new DNode<T>(null, header, null);
header.setNext(trailer);
}
// utility methods
public int size() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
// give clients access to nodes, but not to the header or trailer
public DNode<T> getFirst() throws Exception {
if (isEmpty())
throw new Exception("Empty");
return header.getNext();
}
public DNode<T> getLast() throws Exception {
if (isEmpty())
throw new Exception("Empty");
return trailer.getPrev();
}
public DNode<T> getNext(DNode<T> v) throws Exception {
DNode<T> ans = v.getNext();
if (ans == null || ans == trailer)
throw new Exception("No such node");
return ans;
}
public DNode<T> getPrev(DNode<T> v) throws Exception {
DNode<T> ans = v.getPrev();
if (ans == null || ans == header)
throw new Exception("No such node");
return ans;
}
// methods to change the list
public void addBefore(T d, DNode<T> v) {
DNode<T> u = v.getPrev();
DNode<T> x = new DNode<T>(d, u, v);
u.setNext(x);
v.setPrev(x);
size++;
}
public void addAfter(T d, DNode<T> v) {
DNode<T> w = v.getNext();
DNode<T> x = new DNode<T>(d, v, w);
v.setNext(x);
w.setPrev(x);
size++;
}
public void addFirst(T d) {
addAfter(d, header);
}
public void addLast(T d) {
addBefore(d, trailer);
}
public T remove(DNode<T> v) throws Exception {
if (v == header || v == trailer)
throw new Exception("Sentinel");
DNode<T> u = v.getPrev();
DNode<T> w = v.getNext();
w.setPrev(u);
u.setNext(w);
size--;
return v.getData();
}
// LinkedList testing methods:
public String toString() {
String ans = "";
DNode<T> n = header;
ans += "(H)<-->";
do {
n = n.getNext();
if (n == trailer)
ans += "(T)";
else
ans += (n.getData() + "<-->");
} while (n != trailer);
return ans;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.