Computer Languages and Representations Flashcards

1
Q

What is a factor of the Software crisis and when did the Software crisis begin?

A

Began - 1960s

High cost of producing software - software costs have been rising as hardware costs have been falling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How are Programs represented and Computation implemented in:

  1. Functional Programming
  2. Logic Programming
  3. Finite State Machines
A
  1. Programs are represented by expressions. Computation is represented by reduction
  2. Programs are represented by clauses
    Computation is represented by proof
  3. Programs are represented by state machines
    Computation is represented by transitions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the foundations in Functional and Logic programming?

A

Functional Programming - lambda calculus

Logic Programming - first-order logic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define a Function

A

A function transforms information recieved by inputs to information transmitted by output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are arguments and results in functions?

A

Argument = Inputs
Results = Outputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a must for an equation to apply?

A

Argument must match the pattern for an equation

(Any argument matches a variable pattern)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Pattern?

A

A pattern may describe the structure of the argument and name its components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Guard?

A

A guard is a Boolean expression that must be true for the equation to apply.

(Guards often work with patterns)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define “otherwise”

A

A special final guard that is always true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are functions written in programming?

A

The function f to an argument x is written as f x.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Type?

A

Set of values with the same usage and behaviour.

(All of the values in one of these sets are the same kind of thing such as an integer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Type System?

A

The fundamental purpose of a type system is to prevent errors during the execution of the programs, by ensuring types match correctly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Type Checking?

A

Ensures types are used consistently, and that these errors are avoided.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define Static Type Checking

A

Happens before program execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define Dynamic Type Checking

A

Happens during program execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a negative of Local Defintions?

A

Having all function at the top level of a script can lead to name space pollution - clashes caused by reuse of the same name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a Where Definition?

A

A where definition allows one to name a value, and to use it in an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a Let Definition?

A

A let definition allows one to name a value, and to use it in an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the steps for Polya’s heuristic strategies?

A
  1. Understand the problem
  2. Devise a plan
  3. Carry out the plan
  4. Look back and reflect
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Explain Understanding the problem in Polya’s heuristic strategies.

A

Involves careful study. May seem obvious, but failure to understand the problem often explains a failure to solve it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Explain Devising a plan in Polya’s heuristic strategies.

A

Involves identifying calclulations, computations or constructions that may be performed in order to obtain the solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are 3 key questions when Devising a plan?

A
  • Did you use all the data?
  • Did you use the whole condition?
  • Could you use a related problem, solved before?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Explain Carrying out the plan in Polya’s heuristic strategies.

A

Involves performing the steps in sequence to give the solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are 2 key questions when Carrying out the plan?

A
  • Can you see each step is correct?
  • Can you prove each step is correct?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Explain Reflecting in Polya’s heuristic strategies.

A

Taking time to consider what worked and what didn’t. The insights gained may make it easier to find solutions to future problems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What are 3 key questions when Reflecting?

A
  • Can you check the result?
  • Can you check the argument?
  • Can you use the result/method for some other problem?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is a design pattern?

A

It captures the idea of a good solution to a common design problem

They can make novices look like experts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the Generate-and-select design pattern?

A

Generator construct a large number of values that might be solutions to a problem.

Selector filters out those values that are solutions to the problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is the productivity paradox?

A

You can see computer age everywhere but in the productivity statistics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What are the three explanations of the productivity paradox?

A
  1. Uneven/concentrated gains
  2. Implementation lags
  3. Mismeasurement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Explain Uneven/concentrated gains in relation to the productivity paradox.

A

The gains are in few productive firms and sectors with limited weight in the overall economy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Explain Implementation lags in relation to the productivity paradox.

A

It takes considerable time for a new technologies to achieve critical mass, or for necessary complementary ones to appear.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Explain Mismeasurements in relation to the productivity paradox.

A

Adopting new technologies can lead workers to move on from more productive adopting sectors to less productive ones, and so to negligible aggregate productivity growth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

How do Artificial Neural Networks (ANNs) work behind the scenes?

A
  1. The core ANN is trained on text from the Internet to respond to a prompt with a list of most probable next words after the prompt
  2. The core ANN is tweaked by scoring its responses to sample queries. A second NN is trained on these scores to predict the most likely one to be assigned to a prompt.
  3. The second ANN is used in reinforcement learning to adjust the weights iin the core ANN so that its outputs are even most likely to satisfy humans
  4. Sometimes, data from user responses to LLM responses is fed back to fine-tune for still better results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What are the concerns when using the large language models?

A
  1. Copyright
  2. Education
  3. Code quality
  4. Code security
  5. Not an expert
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What is the Education concern when using large language models?

A

Good solutions to many assignments can be completed directly, reducing their challenge and worth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What is the Code quality concern when using large language models?

A

No guarantee of code quality when using a large language model, and a code review will need to be conducted before code is deployed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What is the Code security concern when using large language models?

A

No guarantee of code security when using a large language, and a security audit will need to be conducted before code is deployed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What is the information concern when using large lanuage models?

A

It is not an expert - doesn’t know and will confabulate if necessary, mixing high-quality text with low quality rubbish

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Define List Processing

A

Is naturally recursive. The result of a computation on a list is often most easily described in terms of its head and a recursive computation on its tail, until a base case list is reached

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Define the Head of a list

A

First item of list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Define the Tail of a list

A

The rest of the items (not including the first)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What is a List Comprehension?

A

Items generated from one list are transformed or tested to give items of another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What is a Conditional Expression?

A

A conditional expression evaluates to one expression or the other, depending on the value of a Boolean expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

What is a Case Expression?

A

A case expression evaluates to the expression for a given case
- A case expression may have a base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

What is nub used for in Haskell?

A

Removes duplicate elements from a list.
- Only keeps the first occurrence of each element, preserving the order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

What is Lit used for in Haskell?

A

Refers to literals which represent basic constant values like numbers, characters or strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

Why is Code Copying bad?

A

Error-prone
- Errors must be fixed in every copy

Inefficient
- Space must be allocated for each copy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What are the 5 types of Data Objects?

A
  1. Numbers
  2. Atoms
  3. Variables
  4. Compound terms
  5. Lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Define a Number

A

Either an integer or floating point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Define an Atom

A

A constant that does not have a numerical value. It begins with a lowercase letter, or its quoted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

Define a Variable

A

A variable stands for a term that is to be determined. It begins with an uppercase letter or underscore

53
Q

Define a Compound Term

A

Consists of a functor followed by a sequence argument terms in brackets

54
Q

Define a List

A

made up of elements (possibly of different type) enclosed in square brackets and separated by commas

55
Q

What does the rule mean:

                                              h :- t1, t2, ... tk.
A

Has a declarative reading: h is true if t1, t2, … tk are all true

Has a procedural reading: to compute h compute t1, t2, … tk

56
Q

How does a logic programming language work?

A

Will generate one permutation at a time, on demand from the tester, backtracking to consider further permutations.

57
Q

How does an Sum predicate work?

A

The sum predicate adds up the items in a list

58
Q

How does a Member predicate work?

A

The member predicate is true when an element is a member of a list

59
Q

How does an Append predicate work?

A

An append predicate appends two lists

60
Q

How does a Reverse predicate?

A

A reverse predicate reverses a list

61
Q

How does Next row computations work?

A

A next row may be computed from the current one by adding adjacent integers

62
Q

How do Funnel Computations work?

A

The result of a funnel computation with a top row of numbers is recursively that of a funnel computation with a next row of numbers, until a row with just one number is reached, and the result is that number.

63
Q

How does Binary Digit Computations work?

A

A number can be converted into a sequence of binary digits by recursively dividing by two and writing remainders as binary digits in reverse.

64
Q

What is padding with zeros?

A

Before a number can be run through a funnel, it must be padded to the right number of digits

65
Q

How is Arithmetic carried out?

A

By the infix “is” operator
- if the left argument is an unbound variable, bind it to the result of the right argument and succeed
- if the left argument is a number, or a bound variable with a numerical value, succeed if the right argument has the same numerical value

66
Q

What are the 7 arithmetic operators for prolog?

A

X+Y = sum of X and Y
X-Y = difference of X and Y
X*Y = product of X and Y
X/Y = quotient of X and Y
X//Y = integer quotient of X and Y
X mod Y = remainder when X is divided by Y
X^Y = X to the power of Y

67
Q

What are the 5 arithmetic functions for prolog?

A

abs(N, X) = absolute value of N
sin(N, X) = sine of N (in radians)
cos(N, X) = cosine of N (in radians)
log(N, X) = natural logarithm of N
sqrt(N, X) = square root of N

68
Q

What are the 4 relational operators for prolog?

A

X =:= Y = X and Y are same value
X == Y = X and Y aren’t same value
X > Y = X is greater than Y
X =< = X is less than or equal to Y

69
Q

What is the unification algorithm used for and what does it consider?

A

Unification Algorithm is used for matching

The algorithm considers:
1. Numbers
2. Atoms
3. Variables
4. Compound terms
5. Lists

70
Q

What is Unification in prolog?

A

Making two terms the same by finding a substitution for variables.

Checks if constants, variables, or structures can match and fills in blanks with values or terms that make two terms identical

71
Q

How do two numbers unify in prolog?

A

Two numbers unify if and only if they are the same

72
Q

How do two atoms unify in prolog?

A

Two atoms unify if and only if they are the same

73
Q

How do two variables unify in prolog?

A

Two unbound variables always unify, with the variables bound to each other.
An unbound variable and a term that is not a variable always unify, with the variable bound to the term.

74
Q

How do two compound terms unify in prolog?

A

Two compound terms unify if and only if they have the same functor and the same arity, and their arguments can be unified pairwise, working from left to right

75
Q

How do two lists unify in prolog?

A

Two lists unify if and only if they have the same number of elements and their elements can be unified pairwise, working from left to right.

76
Q

What is the only logical negation operator in prolog?

A

”+ X” which is equal to not X

77
Q

What is the closed-word assumption (CWA)?

A

What is stated is true; what is not stated is false

78
Q

What is note negation as failure (NAF)?

A

Anything that cannot be proved is false

79
Q

What is Backtracking in prolog?

A

If any goal fails, system tries to find another way of reaching the most recently reached previous goal

80
Q

How would you split an atom?

A

Its possible (but difficult) to split atoms into lists of ASCII codes, and to make atoms from lists of ASCII codes

81
Q

Why are lists of atoms preferred over concatenated strings in Prolog?

A

Lists of atoms are easier to read, more flexible to manipulate, better suited for pattern matching, and more efficient.

82
Q

Explain List Construction in prolog

A

The | notation divides a list into a head and a tail. Lists are recursively built by adding elements to the head, with the empty list [] as the base case.
Example: [H | T] = [1, 2, 3] gives H = 1 and T = [2, 3].

83
Q

Explain Pattern Matching in prolog

A

Pattern matching is the process of making two terms identical by aligning their structure and content using unification, which assigns values to variables. It’s key for handling lists, resolving queries, and applying rules, often using backtracking to explore multiple possibilities.

Example:

Query: [H | T] = [a, b, c]
Result: H = a (head), T = [b, c] (tail).

84
Q

What does the cut predicate do in prolog?

A

Despite backtracking being a fundamental part of the process to satisfy goals, it can sometimes be too powerful.

The cut predicate ‘!’, prevents backtracking

85
Q

What does a Classical Expert System include?

A
  1. A database of elementary facts about the domain
  2. Some domain rules for knowledge acquisition
  3. Some interface rules for reasoning from data
  4. A facility for generating explanations
86
Q

What are 4 examples of classical expert systems?

A
  1. Dendral
  2. MYCIN
  3. PROSPECTOR
  4. SHRDLU
87
Q

What is Dendral?

A

Generates all possible arrangements of a set of atoms and looks through it for likely ones.

(The heuristics are based on judgement and chemical knowledge - experience and intuition)

88
Q

What is MYCIN?

A

Designed to help physicians in the diagnosis of bacterial infections

(Its knowledge is encoded as 350 decision rules which embody the clinical decision criteria of infectious disease experts)

89
Q

What is PROSPECTOR?

A

Was made for decision-making problems in mineral exploration. It helps geologists in evaluating exploration sites or regions for ore deposits of certain types.

90
Q

What is SHRDLU?

A

Allowed the user to communicate with the computer in natural language, moving objects and querying the state of a simplified “blocks world”

91
Q

What is a Dynamic predicate?

A

Can be changed as the program runs

(can be declared as)

91
Q

What is Blackboard Architecture?

A

In expert systems, a blackboard architecture is where there is a shared “blackboard” that is iteratively updated by a diverse group of knowledge sources, starting with a problem specification and ending up with a solution

91
Q

What is a Static predicate?

A

Cannot be changed as the program runs

(by default)

92
Q

What are the 3 commands that can be used to add clauses to the database?

A

A clause can be added to the database with:
- asserta(X) - add a clause X at the beginning of the database
- assertz(X) - add a clause X at the end of the database
- assert(X) - add a clause X at the beginning of the database

93
Q

What are the 2 commands that can be used to delete clauses from a database?

A

A clause can be removed from the database with:
- retract(X) - remove clause X from the database
- retractall(X) - remove all facts/clauses that unify with X from the database

94
Q

What was the Fifth Generation Project intended to do?

A
  • Make Japan best in computer industry at developing knowledge information processing systems built on logic programming
  • Stimulate original research, making results widely available, so refusing accusations that Japan exploits knowledge from abroad without contributing its own
  • Redo the entire of the industry based on logic programming
    - (everyone else followed after they were successful)
95
Q

Why use Logic Programming?

A

Was chosen because it unifies innovations in:
1. Software engineering
2. Databases
3. AI
4. Computer Architecture

96
Q

What is the use of logic programming in Software Engineering?

A

Logic programs can serve as executable specifications; can be made more efficient by program transformation.

97
Q

What is the use of logic programming in Databases?

A

Logic programs have been shown to be decent both as a query language, and for describing integrity constraints.

98
Q

What is the use of logic programming in Computer Architecture?

A

Logic programs provide a way to overcome the von Neumann bottleneck through single assignment

Prolog frees us from the von Neumann constraints - all the programming languages we use such as python, java , C, reflect von Neumann architecture (a 1945 computer design).

99
Q

What are Personal Sequential Inference Machines?

A

Tools that make decisions step-by-step, learning data over time.

Uses: healthcare, robotics etc.

Example: Netflix suggesting movies based on what you have watched

100
Q

What are Parallel Inference Machines?

A

Systems that perform multiple inference tasks simultaneously to speed up processing

These machines handle multiple tasks at once, making them fast and effective for complex decision-making.

101
Q

What are the 3 classical forms of parallelism in prolog?

A
  1. unification parallelism
  2. or-parallelism
  3. and-parallelism
102
Q

What is Unification Parallelism?

A

When the arguments of a goal matches the arguments of a clause that has the same name and arity

103
Q

What is Or Parallelism?

A
  • When a goal may be reached with more than one clause in parallel
  • Explores the search space generated by the presence of multiple clauses in parallel
104
Q

What is And Parallelism?

A
  • When more than one sub goal may be satisfied in parallel
  • Exploits the presence of more than one sub goal that may be satisfied in parallel
105
Q

What is Finite Stata Automata?

A

A model of computation based on a system changing state due to inputs supplied to it, until reaching a final or acceptor state

106
Q

What are the uses of Finite Stata Automata?

A

Finite Automata are a useful model for many important kinds of hardware and software

107
Q

What are the central concepts of automata theory?

A
  1. Alphabets
  2. Strings
  3. Languages
108
Q

Define an Alphabet

A

An alphabet, Σ, is a finite, nonempty set of symbols.

Example: Σ = a, b, . . . z

109
Q

Define a string

A
  • A string is a finite sequence of symbols chosen from some alphabet
  • The set of all possible strings over an alphabet
110
Q

Define a language

A

If Σ is an alphabet, and L ⊆ Σ∗, then L is a language over Σ.

Example: {abc, def, ghi} is a language drawn from Σ∗, where Σ = a, b, . . . z.

111
Q

What does Deterministic Finite Automata consist of?

A
  1. A finite set of states
  2. A finite set of input symbols
  3. A transition function
  4. A start state
  5. A set of accepting or final states
112
Q

How are states represented?

A

The finite set of states is often denoted Q.

Each set may be drawn as a circle

113
Q

How are input symbols represented?

A

The finite set of input symbols is often denoted Σ.

Each symbol may be drawn as a label of a transition arrow.

114
Q

How are transition functions represented?

A

The transition function may be described by a number of cases, δ(p, a) = q.

Each case, δ(p, a) = q, may be drawn as an arrow from the circle for p to the circle for q, labelled a.

115
Q

How is the start state represented?

A

The start state, q0, is one of the states in Q.

The arrow drawn into the start state q0 is labelled Start.

116
Q

Explain accepting and final states

A

The accepting or final states are a subset of Q. Machine may halt in accepting states provided no input left.

All other states become rejecting states if no input left.

Final or accepting states are marked by double circles.

117
Q

What are the two kinds of automaton?

A

Deterministic automaton
Nondeterministic automaton

118
Q

What is Nondeterministic and Deterministic automaton?

A

On each input, a deterministic automaton can transition from its current state to another state;
On each input (or on no input), a nondeterministic automata can transition from its current state to several states

119
Q

What is the general form of an email address?

A

a@b.c

120
Q

What are regular expressions?

A

A regular expression gives an algebraic description of a deterministic/nondeterministic finite state automaton

121
Q

How would you build regular expressions?

A

The algebra of regular expressions combines constants and variables denoting languages using three operations:
1. Closure
2. Concatenation
3. Union

122
Q

What is Closure?

A

Closure of a language L is denoted L*

It represents the set of strings that can be formed by taking strings from L, and concatenating them

The “*” operator has the highest precedence — it applies to the smallest sequence of symbols to its left

123
Q

What is Concatenation?

A

Concatenation of languages L and M is denoted LM

Its the set of strings that can be formed by taking any string in L and appending any string in M.

Concatenation has the next highest priority behind closure — expressions that are juxtaposed are grouped together.

124
Q

What is Union?

A

Union of two languages L and M are denoted L + M

Its the set of strings that are either in L or M, or both

The ‘+’ operator has the lowest priority - expressions may be grouped by unions in any order

125
Q

How would you write:

a) any number of 0s or a 1
b) 10 and any number of 1s
c) 10 or 01
d) 0 and any number of 10s

A

a) 0* + 1
b) 101*
c) 10 + 01
d) 0(10)*

126
Q
A