The term ‘stochastic’ in this note will refer to two types of probability:
or, simply
stochastic = probabilistic + quantum
The guarded Horn clause (GHC)
From Wikipedia:Concurrent_logic_programming:
H :- G1, …, Gm | B1, …, Bn.
The conjunction G1, … , Gm is called the guard of the clause, the conjunction B1, …, Bn. the body of the clause and | is the commitment operator.
However, procedurally, when there are several clauses whose heads H match a given goal, then all of the clauses are executed in parallel, checking whether their guards hold. If the guards of more than one clause hold, then a committed choice is made to one of the clauses, and execution proceeds with the subgoals [the body] of the chosen clause. These subgoals can also be executed in parallel. Thus concurrent logic programming implements a form of “don’t care nondeterminism”, rather than “don’t know nondeterminism”.
The probabilistic guarded Horn clause (PGHC)
H :- G1, …, Gm : P | B1, …, Bn.
Final term of the guard is a positive number or logical variable that is bound to a nonnegative number at the completion of the other guard terms. j may be 0.
The quantum guarded Horn clause (QGHC)
H1 :- G1,1, …, G1,m_1 : Q1; …; Hk :- Gk,1, …; Gk,m_k : Qk | B1, …, Bn.
Head is a disjunction separated by semicolon character ‘;’. (Priority of operators: ‘|’, ‘;’, ‘:-‘.) of PGHC-type head+guards EXCEPT final term of each guard is a complex number or logical variable that is bound to a complex number at the completion of the other guard terms.
The disjunctive head+guards are called ‘superpositions’., and their resultant probability is determined by the Feynman ‘sum over histories’ rule:
Q = Q1 + … + Qk
P = |Q|
Superpositional bindings (unifications) are undone
Example:
a(1, Q) :- Q1 is Q×(1.0+1.0i) : Q1; a(2, Q) :- Q1 is Q×(1.0-1.0i) : Q1 | print(‘A’).
a(1, Q) :- Q1 is Q×(-1.0+1.0i) : Q1; a(2, Q) :- Q1 is Q×(-1.0-1.0i) : Q1 | print(‘B’).
:- Q is 2.0-3.0i, a(X,Q).
(X not bound at resolution.)
Read-only logical variables in QGHCs
to be added
cf. https://codicalist.wordpress.com/2018/04/08/cp-stochastic-concurrent-prolog/
examples …
measure(a,1,Q) :- nth1(Q,1, Qa1) : Qa1;
measure(a,2,Q) :- nth1(Q,2, Qa2) : Qa2
| print(a).
measure(b,1,Q) :- nth1(Q,3, Qb1) : Qb1;
measure(b,2,Q) :- nth1(Q,4, Qb2)) : Qb2
| print(b)