assert
and asserta
.
Solution:
Memoization is the process of noting down the results of complicated
computations or inferences that might be needed again later, so that
it is not necessary to re-compute them if they are needed. In Prolog
this can be done by asserting the fact that has been computed. It is
often the case that it is necessary to use asserta
in order
to ensure that the asserted result is accessed before the
rule that would be used if the asserted result were not available.
Example:
factorial(0, 1). factorial(N, NFact) :- N > 0, Nminus1 is N - 1, factorial(Nminus1, Nminus1Fact), asserta((factorial(Nminus1, Nminus1Fact) :- !)), NFact is N * Nminus1Fact.
?- functor(owns(jim, book(author(joanna, rowling), title("Harry Potter and the Half-Blood Prince"))), FuncName, Arity).
Solution:
FuncName=owns Arity=2
likes(mary, pizza). likes(mary, curry). likes(john, beer). likes(john, pizza). is_liked(X) :- likes(_, X).what is the output of the following queries?
?- setof(X, is_liked(X), List1).
X = _G187 List1 = [beer, curry, pizza]
?- findall(X, likes(_, X), List2).
X = _G187 List2 = [pizza, curry, beer, pizza]
Solution: Π_{i=1,T} Pr(w_{i} | C_{i}) × Π_{i=1,T} Pr(C_{i} | C_{i–1})
Solution:
A Markov chain is an edge-labelled directed graph, where
each node represents a "state", e.g. a lexical category,
and the edge-labels are probabilities of moving the state
at the end of the directed arc.
Solution: An IAC network is a collection of nodes and weighted connections, normally bidirectional connections.
The nodes are divided into competitive pools. All the interconnections between nodes in any pool are inhibitory; i.e. their weights are negative.
Connections between nodes in different pools, when they exist, are excitatory connections - i.e. the weights are positive. (Nodes are unconnected iff the weights are zero.)
Output function. Denote the weight of the connection
between node i and node j by w_{ij}, and let the
current activation of node j be a_{j}. Then the
total net input of node j is:
net_{j} = Σ_{i} w_{ij} a_{i} + extinput_{j}and then the output of node j is a_{j} + Δa_{j}, where:
if (net_{j} > 0)where, max, min, decay, and rest are parameters, signifying maximum and minimum activation, decay rate in the absence of input, and the resting value to which activation will decay in the absence of input.
Δa_{j} = (max – a_{j})net_{j} – decay(a_{j} – rest)
else
Δa_{j} = (a_{j} – min)net_{j} – decay(a_{j} – rest)
CRICOS Provider Code No. 00098G