Rock It 《ML》JupyterLab 【丁】Code《七》語義【六】解讀‧四‧Redex 四

三足鳥

180px-Processed_SAM_loki

斷頭台

人類的思維如果一旦不『審慎』,很容易邏輯『混亂』,以至於言論多所『謬誤』,有時或許『巧說詭辯』。比方說公孫龍子的『雞三足』之詭論︰…牛羊有毛,雞有羽。謂雞足一,數足二;二而一,故三。謂牛羊足一,數足四;四而一,故五。羊牛足五,雞足三,故曰:『牛合羊非雞』。非,有以非雞也。…裡頭的『謂雞足一』之『雞足』和『一』是什麼?『數足二』的『足』與『二』又是什麼?卻能相加,彷彿『一雞 + 二足』可以得到『三 \biguplus 』的一般?!已經完全不像他的『白馬非馬論』了。

洛基的賭注 Loki’s Wager
洛基乃北歐神話中以『詐騙』著名之神。傳說他曾與矮人打賭卻輸了。當矮人們依約來『提頭』時,洛基說︰沒問題』,但是必須依照『約定』,只能取走『他的頭』,而不能動著『他的脖子。於是彼此開始『爭論』該如何的『切割』:有哪些部分雙方同意『是頭』;又有哪些部分認同『是脖子只是脖子的『結束點』和頭之『開始點』究竟『是哪裡』,互相一直無法『取得共識』。於是洛基終於保住著了他的頭

因此『語言學家』在『定義』他們的『術語』時,通常採取數學家和邏輯學家的『方式』,舉例說,集合 V 代表一個『形式語言』中的『字彙』集合,也就是說 V 的元素是某種『抽象』語言的語詞。假使 v_1, v_2, v_3 \in V,『序連』 concatenation 是指像『v_1v_2v_3』這樣的把語詞串接成『字串』,那麼要如何表達『任意多個字彙序連的字串論域 V^* 』呢?他們使用著美國數學家 Stephen Cole Kleene 的『Kleene star』Kleene之星遞迴的表示成︰

V_0 = \{ \varepsilon \},『空字串』的集合,
V_1 = V
V_{i +1} = \{ wv | w \in V_i  \ \wedge \ v \in V \}

V^* = \bigcup_{i \in N } V_i = \{\varepsilon\} \cup V \cup V_2 \cup V_3 \cup V_4 \cup \ldots

雖然這樣作有點『麻煩』,作的好處就是『清晰可驗證』。此處的『 N 』是包含零的『自然數系』,而『 N \setminus \{0\}』是不包含零的自然數系,假使所指的論域不包含空字串,一般會記成︰

V^+=\bigcup_{i \in N \setminus \{0\}} V_i = V_1 \cup V_2 \cup V_3 \cup \ldots

比方英國的哲學家  Antony Garrard Newton Flew 於 1975 年在一本名為『 Thinking About Thinking:  Do I sincerely want to be right? 』書中講到︰

【沒有真正的蘇格蘭人 No true Scotsman】

想像一位名叫 Hamish McDonald 的蘇格蘭人,坐下打開他的《格拉斯哥先驅晨報》,看見一則新聞『布萊頓 ── 位於英格蘭南部 ──色魔再度犯案!』他震驚地說:『沒有蘇格蘭人會 幹這種事!』隔天他又打開報紙,看見新聞描述一位亞伯丁人 ── 該城位於蘇格蘭 ── 更殘暴的行為,相較之下布萊頓色魔還算是個紳士。這顯示 Hamish 的想法是 錯的,但他會承認嗎?似乎不會。這次他說:『沒有【真正的】蘇格蘭人會作這種事。』

今天這稱之為『訴諸純正』appeal to purity 的謬誤,是指在原先的普遍性宣稱遭遇反例時,隨即提出一個更『理想』的『標準』作為他辯護之依據。大概沒人知道這個 { □ |  □是純正蘇格蘭人} 到底有哪些元素?難到它不會是個 \phi  嗎??

就讓我們『正式的』formal  將『 Thue 改寫系統』定義如下︰

semi-Thue 改寫系統是一個有序元組 ( \Sigma, R ),其中 \Sigma 是一個有限的『字母』alphabet 集合,它之Kleene之星是 \Sigma^*  ,包含空字串、有限字串或稱作字詞。R 是一個建構於 \Sigma^*  的二元關係,也就是說 R \subseteq \Sigma^* \times \Sigma^* 。每一個 R 中的元素 (u,v) \in R 叫做一個『改寫規則』rewriting  rule,通常寫成 u \rightarrow v 。假使關係 R 具有『對稱性』,這個系統便稱作『Thue 改寫系統』。

─── 《THUE 之改寫系統《二》

 

回想起有人寫了個

/mlc

MarioLANG Compiler

MarioLANG Compiler

MarioLANG Compiler (mlc) will compile programs from MarioLANG into C.

Usage

./mlc.py <program name> gcc ml.c
./a.out</pre> <h1><span style="color: #ff9900;">Internals</span></h1> <span style="color: #ff9900;">mlc walks the MarioLANG program and constructs a finite state machine, performs some optimizations to reduce the size of the graph, then turns that graph into a C program.</span> <h1><a id="user-content-known-problems" class="anchor" href="https://github.com/nickodell/mlc#known-problems"></a><span style="color: #008080;">Known problems</span></h1> <ul>  	<li><span style="color: #008080;">Input is line-buffered, unlike many mariolang implementations.</span></li>  	<li><span style="color: #008080;">Memory is statically allocated, and no over/underflow checks are made.</span></li> </ul> <span style="color: #808080;">※ 測試︰</span> <pre class="lang:default decode:true ">rock64@rock64:~/mlc cat example.ml 
++++:       >       >  +:+:+:+:+:+:+:::::
====+      >^===    """=================
    +:-):(:^=   =                       !
    =========    =                      #
                  = !             .+.,:-<
                   =###           ======"
rock64@rock64:~/mlc./mlc.py example.ml  Done in 66 steps rock64@rock64:~/mlc ./a.out 
4 6 0 5 6 7 8 9 10 11 12 12 12 12 12 11 h
hirock64@rock64:~/mlcrock64@rock64:~/mlc

 

能將

MarioLANG → FSM !

那麼這是可能的嗎?

Finite-state machine

Classes of automata

A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. The FSM can change from one state to another in response to some external inputs; the change from one state to another is called a transition. An FSM is defined by a list of its states, its initial state, and the conditions for each transition. Finite state machines are of two types – deterministic finite state machines and non-deterministic finite state machines.[1] A deterministic finite-state machine can be constructed equivalent to any non-deterministic one.

The behavior of state machines can be observed in many devices in modern society that perform a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples are vending machines, which dispense products when the proper combination of coins is deposited, elevators, whose sequence of stops is determined by the floors requested by riders, traffic lights, which change sequence when cars are waiting, and combination locks, which require the input of combination numbers in the proper order.

The finite state machine has less computational power than some other models of computation such as the Turing machine.[2] The computational power distinction means there are computational tasks that a Turing machine can do but a FSM cannot. This is because a FSM’s memory is limited by the number of states it has. FSMs are studied in the more general field of automata theory.

 

不過有限行 MarioLANG 『程式』,可有無窮多『狀態』嗎??

恐論理嚴謹無趣!!

故想求之以『真理機器』矣☆

The Truth Machine

The Truth Machine (1996) is a science fiction novel by James L. Halperin about a genius who invents an infallible lie detector. Soon, every citizen must pass a thorough test under a Truth Machine to get a job or receive any sort of license. Eventually, people begin wearing them all the time, thus eliminating dishonesty in all parts of human interaction, and eliminating crime, terrorism and a great deal of general social problems.

Plot

The novel primarily focuses on the life story of Randall Peterson “Pete” Armstrong, a child prodigy with total recall memory, whose entire life’s outlook has been defined by the tragic murder of his younger brother, Leonard, by an ex-convict who was believed to be capable of committing violent crimes again, but could not be imprisoned any longer under the current law structure. Pete is committed to making a difference for humanity that will atone for his brother’s death and help millions of others, too. In his first year at Harvard at the age 13, Pete is recruited to enroll in a small, but exclusive, class of the brightest and most agile students on campus. In that class, he meets people and establishes friendships that will further his identity. It is there that the idea of a ‘truth machine’ is conceived and Pete realizes that its existence is possible and that he could do it. The ‘truth machine’ would be a mechanism that would be 100% accurate in determining if a person was lying or telling the truth. It could help eliminate crime and dishonesty in general. As long as it is employed universally (and not just by government officials), the ‘truth machine’ could revolutionize humanity and take it to that next evolutionary step which would help it avert its coming self-destruction.

The protagonist places a back door in the book’s otherwise infallible lie detector, allowing him to avoid detection when he repeats fragments of Walt Whitman’s poem “O Captain! My Captain!” in his mind.

 

果能斷乎?☺

Poolala (talk) 18:41, 22 September 2013 (UTC)

Weird! I am also working on a truth machine!

This version only accepts 1 and 0 as input, otherwise it starts again.

      <
 ====="
   >-[!+>:<
   "==#====
>;[!: Truth
===#=Machine

 

rock64@rock64:~/mlccat Truth.ml        <  ====="    >-[!+>:<    "==#==== >;[!: Truth ===#=Machine rock64@rock64:~/mlc ./a.out 
x
0 rock64@rock64:~/mlcrock64@rock64:~/mlc ./a.out 
1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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