从 1962 年《编程语言》第一章的引用书目中,我找到了 this intriguingly concise description of a forward-Polish (Lukasiewicz) Logic Machine 。我想我已经完成了逻辑函数F的这一部分:
(2a) 是什么意思?这是一个怎样的函数?
这是我对该部分之前所有内容的实现(在 PostScript 中)( completed Postscript 、 C version ):
%http://www.ams.org/journals/mcom/1954-08-046/
/L{length}def % length of string
/T{ % i D tail(i) of string
2 copy L le{ % i<=L(D)
dup length 2 index sub % i D L(D)-i
3 2 roll getinterval % D[L-i.*i]
}{ % i>L(D)
exch pop % D
}ifelse
}def
/H{ % i D head(i) of string
2 copy L le{ % i<=L(D)
0 % i D 0
3 2 roll getinterval % D[0.*i]
}{
exch pop % D
}ifelse
}def
/Wtab 1 dict def
1 0 1 255{Wtab exch 2 index put}for pop
0 (N) {Wtab exch 2 index put}forall pop
-1 (KA) {Wtab exch 2 index put}forall pop
/W{ % weight of string or char
dup type /integertype eq {
Wtab exch get
}{
0 exch { W add } forall
}ifelse
}def
%Wtab{exch =only( )=only =}forall
%(KAxyz)W =
/D{ % D(d) = 1 - W(d)
1 exch W sub
}def
/Wmax{ % Wmax(D) = Max(W[T_i(D)]) for i > 0
[ exch
0 1 2 index L { % [ ... D i
1 index T % [ ... D T(i,D)
W
exch % [ ... W(T(i,D)) D
} for
pop % [ ... W(T(i,D))
counttomark 0 eq { pop 0 }{
{
counttomark 1 eq { exch pop exit } if
2 copy lt { exch } if pop
}loop
}ifelse
}def
/Wmin{ % Wmin(D) = Min(W[T_i(D)]) for i > 0
[ exch
0 1 2 index L { % [ ... D i
1 index T % [ ... D T(i,D)
W
exch % [ ... W(T(i,D)) D
} for
pop % [ ... W(T(i,D))
counttomark 0 eq { pop 0 }{
{
counttomark 1 eq { exch pop exit } if
2 copy gt { exch } if pop
} loop
}ifelse
}def
%(KAxyz) Wmax =
%(KAxyz) Wmin =
/PF{ % D is positive formula
Wmin 0 gt
}def
/WFF{ % D is well-formed formula
dup PF exch W 1 eq and
}def
/P(01)def
P{
W 1 ne {ERROR:W_p!=1} if
}forall
/Ptab <<
P {
dup
} forall
>>def
/F{
dup D 0 gt {
}{
}ifelse
}def
最佳答案
嗯。好的。我想我开始明白了。 P 是数据字母表,只有 0
和 1
。忽略他们定义它的奇怪方式,"K"
的度数函数 D
得到 2。所以这个 (2a) 只是表示从输入字符串捕获的变量,小三角洲。换句话说,输入字符串little-delta被隐式划分为一个新的little-delta(在示例中,这是字符K
)及其2个( Degree = 2,对吧?)参数, πD(δ) .. π1,它被定义为这个列表,因此它可以扩展到任何数量。 εP 部分仅意味着 F 必须产生 0
或 1
,或者更一般地说,P 的一个元素
F 本身是整个事物的一个参数。它就在顶部。我忘了。
这里是函数 K
、A
和 N
的实现。 F 控制何时调用它们,但它们必须从字符串中破解自己的参数。
/P(01)def
P{
W 1 ne {ERROR:W_p!=1} if
}forall
/Ptab <<
P {
dup
} forall
>>def
/iP{ % i <- P
P exch search pop length exch pop exch pop
}def
/Pi{ % P <- i
P exch 1 getinterval
}def
/F{
dup 0 get
D 0 gt { % ie. an operator
dup 0 get % (...) K|A|N
exch % K|A|N (...)
1 1 index length 1 sub getinterval % kan (..)
exch Ftab exch get exec % F(d,..)
}{ % leave it alone. F(p)=p
}ifelse
}def
/Ftab <<
(K)0 get { % crack 2 args from string and convert to indices
dup 0 1 getinterval iP
exch 1 1 getinterval iP
and
Pi % convert result back to alphabet P
}
(A)0 get {
dup 0 1 getinterval iP
exch 1 1 getinterval iP
xor
Pi
}
(N)0 get {
0 1 getinterval iP
1 add 2 mod
Pi
}
>>def
(K00) F =
(K01) F =
(K10) F =
(K11) F =
幽灵脚本输出:
0
0
0
1
噢。谢什。他们在下一页上说了同样的话。
关于history - 如何理解 Burks/Warren/Wright 的 Lukasiewicz 逻辑机中的 F 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22366141/