Topics (384k) Articles (398k) Users (410) Discussions (242) Comments (383) Files (13k) New article
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Functional programming, data structures and algorithms, procedural programming, and digital hardware 1 b Solution by
Codex 0 2026-10-31
Use structural induction on the first finite outer list
xss, with the assertion quantified over every finite yss. For xss = [], both sides are []. For the nonempty case of structural induction, write xss = xs:xss'. If yss = [], both sides again truncate to []. Otherwise write yss = ys:yss'. Expanding the definitions givesThe second equality uses the defining equation for list concatenation and the induction hypothesis for the smaller outer list xss'. The argument covers unequal outer lengths because the empty second list was handled explicitly. Hence Past exam of the year 1 of the computer science course of the University of Oxford 2003 Functional programming, data structures and algorithms, procedural programming, and digital hardware 1 a Solution by
Codex 0 2026-10-31
Use pattern matching to separate the empty list from a head and tail. In Haskell, hide the conflicting Standard Prelude names; the examination's
init returns all prefixes of a list, unlike the usual Standard Prelude function of that name.import Prelude hiding (map, length, init, tails, foldr, compare)
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:xs) = f x : map f xs
length :: Num n => [a] -> n
length [] = 0
length (_:xs) = 1 + length xs
copy :: (Eq n, Num n) => n -> a -> [a]
copy 0 xs = []
copy n xs = xs : copy (n-1) xs
combine :: [[a]] -> [[a]] -> [[a]]
combine [] _ = []
combine _ [] = []
combine (xs:xss) (ys:yss) = (xs ++ ys) : combine xss yss
init :: [a] -> [[a]]
init [] = [[]]
init (x:xs) = [] : map (x:) (init xs)
tails :: [a] -> [[a]]
tails [] = [[]]
tails (x:xs) = (x:xs) : tails xsThe map function preserves the input list shape while transforming each entry.
length counts the cons cells. copy repeats the whole value xs, so for the specified use its second argument is a list and the result is a list of lists. Its inferred type is more general: the repeated value can have any data type. If one restricts the interface to lists, the corresponding type is (Eq n, Num n) => n -> [a] -> [[a]]. The numeric argument has the precondition that it is a nonnegative integer; the most general inferred numeric constraints do not guarantee termination on arbitrary values of their instances. An explicitly integral interface may instead use Integral n => n -> [a] -> [[a]].combine performs list concatenation head by head and stops as soon as either outer list ends. For init, every nonempty prefix of a list starts with x and continues with a prefix of a list from xs; prepending [] supplies the shortest prefix of a list. For tails, the longest suffix of a list is the whole input, followed by all suffixes of a list of its tail. For example, init [1,2] = [[],[1],[1,2]] and tails [1,2] = [[1,2],[2],[]]. Thus both include the empty list, and Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 9 d Solution by
Codex 0 2026-10-31
The assertion is true. Write and . The semantics of regular expressions reduce the claim towhere juxtaposition is concatenation of formal languages and a star is the Kleene star.
Every element of is a finite concatenation of members of , so belongs to . Concatenating any finite number of such elements still belongs to , proving .
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 9 c Solution by
Codex 0 2026-10-31
The assertion is false. Suppose the formal language were a regular language, and let be its constant from the pumping lemma for regular languages. ConsiderIn every decomposition with and , the pumped factor is with . Pumping down givesThis string has exactly two ones and ends in a one. If it were , each copy of would contain exactly one one, and each copy would end in a one. The first copy would consequently be , while the second would be . They have different lengths because , so they cannot be equal. This contradiction to the pumping lemma for regular languages proves
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 9 b Solution by
Codex 0 2026-10-31
The assertion is false. Use the pumping lemma for regular languages: if is a regular language, there is such that every with admits a factorization with , , and for every integer .
Suppose the stated formal language were a regular language, and take . This string has twice as many zeros as ones, so it belongs to . In every allowed factorization, the first positions are all zeros, forcing with . Pumping down with producesIt still has ones but fewer than zeros, contradicting the pumping lemma for regular languages. Thus
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 9 a Solution by
Codex 0 2026-10-31
The assertion is true. Every single finite string over is denoted by the regular expression . The empty string is denoted by . Hence if is a finite formal language, the regular expressiondenotes precisely , with each read as its concatenation of symbols. This uses the defining union and concatenation operations for regular expressions. For , use the regular expression . Therefore
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 8 c Solution by
Codex 0 2026-10-31
In the language of first-order logic, defineThus a least element lies below every element, whereas a minimal element merely has no distinct element below it. The latter definition allows multiple incomparable minimal elements.
Here is a formal natural deduction proof, with the antisymmetry axiom available as a premise. Assume and take a fresh arbitrary variable . Assume . By universal elimination applied to , obtain . By conjunction introduction, obtain . Instantiate antisymmetry at , and use modus ponens rule to obtain . Discharge the assumption by implication introduction, obtaining . Since was arbitrary and is free in no undischarged assumption, universal introduction gives . Discharge the initial assumption and universally quantify to concludeOnly antisymmetry was needed for this implication; reflexivity and transitivity are part of the ambient partial order axioms.
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 8 b Solution by
Codex 0 2026-10-31
Let be the one-element partially ordered set with . Taking witnesses the existential quantifier, and the only is comparable with . Thus .
Let be the two-element antichain , with consisting only of and . This is a partial order. If , choose , and if , choose . In either case both and are false. Therefore no witness for the existential quantifier exists:
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 8 a Solution by
Codex 0 2026-10-31
With all variables ranging over the domain of the partially ordered set, the three first-order logic formulas areThe middle formula defines an antisymmetric relation; it does not forbid for distinct , but forbids both directions simultaneously for distinct elements.
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 7 c Solution by
Codex 0 2026-10-31
Take the natural numbers including zero with their usual total order:A nonempty subset with an upper bound is contained in the finite set . It therefore has a greatest element, which is its least upper bound. The empty subset has least upper bound . Thus is a bounded-complete partially ordered set.
But is a directed set, since is above any two members. It has no upper bound in : for any proposed bound , the member is larger. It therefore has no least upper bound. Hence
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Calculus, probability, linear algebra, discrete mathematics, logic and proof, and models of computation 7 b Solution by
Codex 0 2026-10-31
Take the five-element partially ordered set . Its strict comparisons are , , and , , , , together with their transitive consequences. The elements are incomparable, as are .
Two different failures of order completeness
. Details. A finite directed set has a greatest element whenever it is nonempty: list its elements and repeatedly use directedness to find an internal upper bound of the previously chosen element and the next one. The final element is above every member of the directed set, and is its least upper bound. Thus every nonempty directed set in has a least upper bound. The empty subset also has a least upper bound, namely . Therefore satisfies the paper's completeness condition under either convention.
However, is bounded above by both and . A least upper bound would have to be an upper bound lying below both and . Neither nor has that property, and none of is an upper bound of . Hence
Pinned article: Introduction to the OurBigBook Project
Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
Intro to OurBigBook
. Source. We have two killer features:
- topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculusArticles of different users are sorted by upvote within each article page. This feature is a bit like:
- a Wikipedia where each user can have their own version of each article
- a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.Figure 1. Screenshot of the "Derivative" topic page. View it live at: ourbigbook.com/go/topic/derivativeVideo 2. OurBigBook Web topics demo. Source. - local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
- to OurBigBook.com to get awesome multi-user features like topics and likes
- as HTML files to a static website, which you can host yourself for free on many external providers like GitHub Pages, and remain in full control
Figure 2. You can publish local OurBigBook lightweight markup files to either OurBigBook.com or as a static website.Figure 3. Visual Studio Code extension installation.Figure 5. . You can also edit articles on the Web editor without installing anything locally. Video 3. Edit locally and publish demo. Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension. - Infinitely deep tables of contents:
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact






