ECM2418 Computer Languages and Representation Flashcards

1
Q

Haskell inbuilt functions to use

A

filter
foldr
map
even
odd
(++)
sel
not

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

polymorphic type of conditional functor (even, odd) haskell

A

(a -> Bool)

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

polymorphism syntax haskell

A

function :: a..

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

list split haskell

A

(x:xs)

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

list split Prolog

A

([A|AS])

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

Prolog predicates to remember

A

reverse
between
findall
permutations

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

(EXAMPLE) what’s stopping this predicate from working

alpha(XS).

A

it’s missing base cases:
alpha([]).
alpha([_]).

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

Functional programming

A
  • Programs are represented by expressions
  • Computation is implemented by reduction
  • The foundation is the lambda calculus
  • Functions akin to mathematics functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Logic Programming

A
  • Programs are represented by clauses
  • Computation is represented by proof
  • The foundation is the first-order logic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Finite State Machines

A

Simple idea occurring throughout computer science
- 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
11
Q

tuples in haskell

A

(a1,a2,a3)
can have different types in one tuple

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

Recursive definitions in haskell

A

Contains a base case that can act as a halt for the function to return a value

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

Guards in Haskell

A

|

a boolean expression that must be true for the equation to apply

acts similarly to if and else

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

guard keywords

A

where
otherwise

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

generate-and-select design pattern

A

the generator constructs a large number of values that might be solutions to a problem

the 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
16
Q

explanations of the productivity paradox

A

1) Uneven/concentrated gains
2) Implementation lags
3) Mismeasurements

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

uneven/concentrated gains

A

One explanation of the productivity paradox is an uneven/concentrated distribution of gains - the gains are in few productive firms and sectors with limited weight int the overall economy

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

Implementation lags

A

Another explanation of the productivity paradox is implementation lags - it takes considerable time for new technologies to achieve critical mass, or for necessary complementary ones appear. There are gains, but it takes a long time time

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

Mismeasurement

A

adopting new technologies can lead workers to move 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
20
Q

Behind the scenes, Artificial Neural Networks (ANNs) work as follows:

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 ANN 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 in the core ANN so that its outputs are even more 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
21
Q

Among the concerns when using Large Language Models are:

A
  • copyright
  • education
  • code quality
  • code security
  • not an expert
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Copyright and LLMs

A

although the code produced is the melding of that form many sources, there may still be some licensing problems

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

Education and LLMs

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
24
Q

code quality and LLMs

A

There is 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
25
Q

Code security and LLMs

A

There is no guarantee of code security when using a LLM, 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
26
Q

LLMs are not experts

A

it does not know that it does not know, able to confabulate is necessary, mixing high-quality text with low-quality rubbish

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

List comprehensions

A

[ | ]

used to test and transform a list

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

conditionals in haskell

A

case _ of _ ->

or

if _ then _ else

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

cody copying is

A

error-prone
inefficient

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

Backtracking in Prolog

A

If any goal fails, the Prolog system tries to find another way of satisfying the most recently satisfied previous goal

Alternative proofs are requested with NEXT, forcing backtracking

Successive permutations of a clause can be achieved via backtracking

31
Q

atoms in Prolog

A

An atom is a constant that does not have a numerical value. It begins with a lowercase letter, or is quoted

It is possible to split atoms into lists of ASCII codes, and to make atoms from lists of ASCII codes

This makes Prolog and other logical languages a great fit for Natural Language Processing

32
Q

Prolog’s Closed World Assumption (CWA)

A

Anything that cannot be proven to be true based on the facts and rules in the program is assumed to be false

For example, if a fact likes(mary, pizza) exists but likes(mary, sushi) does not, Prolog assumes likes(mary, sushi) is false.

33
Q

Declarative Semantics in Prolog

A

Logic programs describe what is true, not necessarily how to compute it.

Example: Writing
ascending([X, Y | XYS]) :-
X =< Y,
ascending([Y | XYS]).
specifies the property of an ascending list, not how to iterate through the list procedurally.

34
Q

Horn Clauses Prolog

A

Programs are expressed as a set of Horn clauses, which are a type of logical implication:

Facts: Unconditionally true statements, e.g., parent(john, mary).
Rules: Conditional statements, e.g., ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
35
Q

Resolution Prolog

A

The main inference mechanism, where Prolog tries to resolve goals by matching them against facts or rules.

36
Q

Unification Prolog

A

Prolog matches variables with constants or other variables to make clauses work. It ensures terms are syntactically compatible.

37
Q

Why might one discourage the use of the assert and retract predicates in prolog

A

Assert adds a predicate to the running program, and the retract predicate removes.

They make reasoning about the program harder

The program being run changes over time

Perhaps less efficient

code gets created and destroyed on program run-time

38
Q

Unlike Haskell programs, Prolog programs are not strongly typed. What does this mean, and why might it cause problems?

A

This means that due to programmer misunderstandings or errors, predicates may be applied to arguments of unexpected types, predicate calls may fail due to unification errors, incorrect results. This failure will be silent and hard to debug

39
Q

X // Y vs X / Y

A

X // Y represents the integer quotient of X and Y, while X / Y can compute a floating point result

40
Q

arithmetic functions
abs(N, X)
sin(N, X)
cos(N, X)
log(N, X)
sqrt(N, X)

A

absolute value of N
sine of N in radians
cosine of N in radians
natural logarithm of N
square root of N

41
Q

Relational operators
X =:= Y
X == Y
X > Y
X >= Y
X < Y
X =< Y

A

X and Y are same value
X and Y are not same value
X is greater than Y
X is greater than or equal to Y
X is less than Y
X is less than or equal to Y

42
Q

Unification operators
X = Y
X = Y

A

X and Y can be unified
X and Y cannot be unified

43
Q

Which of these terms unifies:
* 42 and [42];
* anna and X;
* woman(anna) and woman(X);
* [’A’,’B’,’C’] and [P, Q, R];
* loves(X, jo) and loves(jim, X)

A
  • anna and X;
  • woman(anna) and woman(X)
  • [’A’, ’B’, ’C’] and [P, Q, R]
  • loves(X, jo) and loves(jim, X)
44
Q

logical negation operator

A

+ X means Not X
Note the closed-word assumption — what is stated is true; what is not stated is false.
Also note negation as failure — anything that cannot be proved true is false

45
Q

The Cut Predicate, ‘!’, in Prolog

A

prevents backtracking

Although backtracking is a fundamental part of the process by
which goals are satisfied, it can sometimes be too powerful.

46
Q

Classical Expert System

A

a database of elementary facts about the domain;
some domain rules for knowledge acquisition;
some inference rules for reasoning from data;
a facility for generating explanations;

47
Q

examples of classical expert system

A

Dendral
MYCIN
PROSPECTOR
SHRDLU

48
Q

Dendral, 1965

A

generates all possible arrangements of a set of
atoms, and searches through it for likely ones, consistent with the rules of chemical valence.

The heuristics employed are based on judgment and chemical knowledge — experience and intuition.

49
Q

MYCIN, 1972

A

designed to assist physicians in the diagnosis of bacterial infections.
Knowledge is encoded as 350 decision rules which embody the clinical decision criteria of infectious disease experts

50
Q

PROSPECTOR, 1976

A

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

The Prolog database readily supports this architecture.

51
Q

Static Predicates

A

cannot be modified as the program runs —
by default, predicates are static ones.

52
Q

Dynamic Predicates

A

can be modified as the program runs —
predicates may be declared as dynamic ones.

dynamic(droid/1).

53
Q

Adding clauses to the database

A

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.

54
Q

Deleting clauses from the database

A

retract(X) — remove clause X from the database;

retractall(X) — remove all facts/clauses that unify with X from the database

55
Q

The Fifth Generation Project

A

The Fifth generation Project was intended to:
- make Japan a leader in the computer industry by developing knowledge information processing systems built using logic programming
- stimulate original research, making the results widely available, so refuting accusations that Japan exploits knowledge from abroad without contributing any of its own,

56
Q

Logic programming was chosen for the Fifth Generation Project because it unifies innovations in:

A

1 software engineering;
2 databases;
3 artificial intelligence;
4 computer architecture.

57
Q

Software Engineering and Logic programming

A

In the field of software engineering, logic programs can serve as executable specifications, that can be made more efficient by program transformation

58
Q

databases and logic programming

A

In the field of databases, logic programs have been shown to be adequate both as a query language, and for describing integrity constraints

59
Q

Artificial Intelligence and Logic programming

A

In the field of artificial intelligence, logic programs naturally implement rules of the form

A if B1 and . . . and Bn

60
Q

Computer Architecture and Logic Programming

A

Logic programs provide a way to overcome the Von Neumann Bottleneck through single assignment

61
Q

Inference Machines

A

Several hundred Personal Sequential Inference Machine (PSI) workstations were built and installed.

The largest Parallel Inference Machine (PIM), PIM/p had 64 × 8 processing elements

62
Q

Three “classical forms of parallelism in Prolog”

A

unification-parallelism
or-parallelism
and-parallelism

63
Q

Unification Parallelism

A

Unification parallelism arises during the unification of the arguments of a goal with the arguments of a clause head with the same name and arity.

Unification parallelism unifies the arguments of complex structures in parallel.

64
Q

Or-parallelism

A

Or-Parallelism arises when a goal may be unified with more than one clause in parallel.

Or-Parallelism explores the search space generated by the presence of multiple clauses in parallel

65
Q

regular expression algebra uses 3 different operations

A

closure
concatenation
union

66
Q

Closure, L∗

A

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

has the highest precedence, applying to the smallest sequence of symbols to its left

67
Q

Concatenation, LM

A

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

second highest priority - expressions that are juxtaposed are grouped together

68
Q

Union, L + M

A

set of strings either in L or M or both

lowest priority - expressions may be grouped by unions in any order.

69
Q

0* + 1

A

any number of 0s or a 1

70
Q

101*

A

10 and any number of 1s

71
Q

10 + 01

A

10 or 01

72
Q

0(10)*

A

0 and any number of 10s

73
Q

Five advantages that the Japanese Fifth Generation Project saw in using
Prolog programs as specifications were:

A

(i) specifications are naturally described by logical relation-
ships [1 mark];
(ii) logical relationships are naturally described by Prolog pro-
grams [1 mark];
(iii) specifications and Prolog programs are therefore always consis-
tent [1 mark];
(iv) Prolog specifications/programs are executable, albeit rather ineffi-
ciently [1 mark].
(v) Prolog specifications/programs can be transformed into more
efficient ones with machine assistance [1 mark].