Past exam of the computer science course of the University of Oxford 2015 Object oriented programming 1 a Solution by
Codex 0 2026-10-31
An immutable object has no changeable observable state after its object constructor finishes. Two clients may hold references to the same immutable object, but neither can change what the other observes. Thus sharing an immutable object avoids the interference normally associated with reference aliasing: for example, sharing a Java
String is safe because a text-changing operation returns another software object rather than modifying that String data type value.A
final reference alone does not establish an immutable object: it prevents reassignment of that reference, but its referent could still be mutable. An immutable object must also protect any reachable mutable state, for instance through defensive copying. With that qualification, the essential answer is Past exam of the computer science course of the University of Oxford 2015 Models of computation 3 a Solution by
Codex 0 2026-10-31
Fix a deterministic, single-tape Turing machine with tape cells indexed by the integers. A precise definition is the tupleHere is a nonempty finite set of control states, a finite tape alphabet with a designated blank symbol , the input alphabet, the initial control state, and distinct halting control states. The transition function is total on the displayed domain. The Turing machine instruction means to write over the scanned , enter control state , and move the head one cell in direction .
A Turing machine configuration is , where , is the head position, and is the tape-content function, equal to outside a finite set. Its next-configuration relation isif , with for and for , andThere is no successor to either halting Turing machine configuration.
For input , the initial Turing machine configuration is , where for and is blank elsewhere. In particular, the initial tape for the empty word is entirely blank. The recognized formal language isThe relation permits any finite number of transitions. An input outside may reach the rejecting control state or run forever; recognition does not require halting on every input.
Past exam of the computer science course of the University of Oxford 2015 Models of computation 2 c Solution by
Codex 0 2026-10-31
is a co-recursively enumerable language, is not a recursively enumerable language, and is not a decidable language. The stipulated order on halting times includes .
First, failure has a finite witness. For valid machine descriptions,Indeed, a strict inequality forces the first halting time to be finite. The second can be either a larger finite time or infinity. Whether the displayed condition holds for fixed is decidable by a finite simulation, including the initial configurations when .
Enumerate all pairs and perform these finite tests by dovetailing, accepting the complement of a set of on finding a witness. Equivalently, at stage , inspect all inputs of length at most through transitions. A genuine violation eventually appears; if there is no violation, the procedure never accepts. Malformed descriptions or differing input alphabets can be recognized and accepted as nonmembers immediately. Thus the complement is a recursively enumerable language, proving that is a co-recursively enumerable language.
For non-enumerability, use the standard result that the complement of a set of the halting problemis not a recursively enumerable language. Given , effectively construct two Turing machines over the same fixed input alphabet. On every input , let ignore and simulate on the fixed word , halting precisely when that simulation halts. Let loop forever on every input.
If does not halt on , both halting times are infinity for every , so the pair belongs to . If halts on , the first halting time is finite while the second is infinity, so the pair does not belong to . ThereforeThis is a many-one reduction from non-halting to the pointwise running-time domination problem. Were a recursively enumerable language, constructing the pair and running its recognizer would recognize non-halting, contradicting the stated result. Hence is not a recursively enumerable language. Since every decidable language is a recursively enumerable language, is also undecidable.
Past exam of the computer science course of the University of Oxford 2015 Models of computation 2 a Solution by
Codex 0 2026-10-31
A nondeterministic pushdown automaton is a tupleHere is a nonempty finite set of control states, a finite input alphabet, a finite stack alphabet, the initial control state, the initial stack symbol, and the final control states. The notation requires each transition to have only finitely many choices. Since the domain is finite, the whole transition specification is finite.
A pushdown automaton configuration is , recording the control state, unread input word, and stack contents. Write the top of the stack on the left. For , the one-step relation isAn epsilon transition instead hasThus a move replaces the top stack symbol by the word , whose leftmost symbol becomes the new top. It consumes one input symbol or no input symbol. Under this convention there is no move from an empty stack.
For acceptance by final state, the recognized formal language isHere allows any finite number of moves, including zero. The entire input must have been consumed; the final stack need not be empty. Acceptance requires at least one such run of the nondeterministic pushdown automaton.
Past exam of the computer science course of the University of Oxford 2015 Models of computation 1 d Solution by
Codex 0 2026-10-31
No: regular languages are not closed under countably infinite intersection. Let and putThe first term in has regular expression , where the fixed power means copies. The second term is a finite language, a finite union of single words. Their union is therefore a regular language.
If , then for each either or belongs to the second term, so . If , choose . It belongs to neither term of . ConsequentlyThe formal language is not a regular language. Indeed, for a proposed pumping length , the pumping lemma for regular languages applied to must pump a nonempty block consisting only of zeros. Repeating that block increases the number of zeros without increasing the number of ones, leaving . This contradiction proves the counterexample. Finite intersection closure does not extend to this infinite intersection of regular languages.
Past exam of the computer science course of the University of Oxford 2015 Models of computation 1 c Solution by
Codex 0 2026-10-31
Let be a deterministic finite automaton recognizing . Construct a nondeterministic finite automaton with automaton state set . Its second coordinate records whether the extra zero has already been consumed. Start at and make exactly the automaton states in accepting.
For each , , and , include the ordinary automaton transitionAlso include the extra automaton transitionThis consumes the inserted zero without changing the simulated automaton state of . At a zero in layer zero, both the ordinary and extra choices are available. There are no automaton transitions from layer one back to layer zero.
If , run on in layer zero, consume the extra zero by the displayed automaton transition, and run on in layer one. The resulting run accepts in .
Conversely, every accepting run of starts in layer zero and finishes in layer one, so it uses exactly one extra automaton transition. Split its input as at that move. Removing that consumed zero leaves precisely a run of on , ending in . Hence . The construction also permits an insertion at either end, including insertion into the empty word.
Therefore . Since has automaton states, is a regular language. This is a single-symbol insertion into a regular language.
Past exam of the computer science course of the University of Oxford 2015 Models of computation 1 a Solution by
Codex 0 2026-10-31
A nondeterministic finite automaton, allowing the epsilon transitions used in this paper, is a tupleHere is a nonempty finite set of automaton states, is a finite alphabet, is the power set of , is the initial automaton state, and is the set of accepting automaton states. The symbol denotes the empty word. Membership permits an automaton transition from to consuming when , or consuming nothing when .
The recognized formal language isThe label of a graph path is the concatenation of its labels with all occurrences of omitted. Thus acceptance requires consuming the entire input word; a single successful choice of automaton transitions suffices. A path of length zero is allowed, so the empty word is accepted whenever , or an accepting automaton state is reachable by epsilon transitions. If epsilon transitions are excluded from the definition of a nondeterministic finite automaton, the displayed version is called an Epsilon-NFA.
Past exam of the computer science course of the University of Oxford 2015 Logic and proof 3 e Solution by
Codex 0 2026-10-31
Use a first-order signature with a constant and unary predicates , and setThe displayed first-order clause has two positive atoms, so it is not a Horn clause. There is a Herbrand model with true and false, and another with the opposite values. Thus neither atom holds in all Herbrand models; the intersection construction makes both false.
Every first-order model of has a nonempty domain, and any element witnesses , so . Nevertheless . ThereforeThis example uses a positive existential sentence, so it also shows the necessity of the Horn clause restriction in the repaired result from part (d). Without that restriction, the intersection of Herbrand models need not itself be a first-order model of : here it fails the very disjunction that all the original Herbrand models satisfy.
There are unlisted articles, also show them or only show them.