M♪o 之學習筆記本《辰》組元︰【䷀】萬象一原

派生碼訊

辰 龍

胡兒騎馬走長安,
開闢中原海境寬;
洪水乍平洪水起,

清光宜向漢中看。

辰龍《 文 》文說︰辰,震也。三月,陽气動,靁電振,民農時也。物皆生,从乙、匕,象芒達;厂,聲也。辰,房星,天時也 。从二,二,古文 上 上字。凡辰之屬皆从辰。或言 辰 辰之古意為手持石锄,日出而作。 龍 龍,鱗蟲之長。能幽,能明,能細,能巨,能短,能長;春分而登天,秋分而潛淵。从肉,飛之形,童省聲。凡龍之屬皆从龍。

 

派︰說到此龍的來歷,

200px-28_xiu.svg 二十八宿裡有,

,實是『青龍』之星象也。《 易 》易《乾》䷀ 卦講︰

乾:元,亨,利,貞。

初九:潛龍,勿用。
九二:見龍再田,利見大人。
九三:君子終日乾乾,夕惕若,厲無咎。
九四:或躍在淵,無咎。
九五:飛龍在天,利見大人。
上九:亢龍有悔。
用九:見群龍無首,吉。

彖曰:大哉乾元,萬物資始,乃統天。云行雨施,品物流形。大明始終,六位時成,時乘六龍以御天。乾道變化,各正性命,保合大和,乃利貞。首出庶物,萬國咸寧。

象曰:天行健,君子以自強不息。潛龍勿用,陽在下也。 見龍再田 ,德施普也。 終日乾乾,反復道也。 或躍在淵,進無咎也。飛龍在天,大人造也。 亢龍有悔,盈不可久也。 用九,天德不可為首也。

文言曰:「元者,善之長也,亨者,嘉之會也,利者,義之和也,貞者,事之干也。 君子體仁,足以長人﹔嘉會,足以合禮﹔利物,足以和義﹔貞固,足以干事。 君子行此四者,故曰:乾:元亨利貞。」

自『雷龍』啟春,震動四時,大地萬象更新,皆此一龍所始也。故而《 易 》易《坤》䷁ 卦又講︰

坤:元,亨,利牝馬之貞。 君子有攸往,先迷后得主,利西南得朋 ,東北喪朋。 安貞,吉。

彖曰:至哉坤元,萬物資生,乃順承天。 坤厚載物,德合無疆。 含弘光大,品物咸亨。 牝馬地類,行地無疆,柔順利貞。 君子攸行,先迷失道,后順得常。 西南得朋,乃與類行﹔東北喪朋,乃終有慶 。安貞之吉,應地無疆。

象曰:地勢坤,君子以厚德載物。

初六:履霜,堅冰至。
象曰:履霜堅冰,陰始凝也。 馴致其道,至堅冰也。

六二:直,方,大,不習無不利。
象曰:六二之動,直以方也。 不習無不利,地道光也。

六三:含章可貞。 或從王事,無成有終。
象曰:含章可貞﹔以時發也。 或從王事,知光大也。

六四:括囊﹔無咎,無譽。
象曰:括囊無咎,慎不害也。

六五:黃裳,元吉。
象曰:黃裳元吉,文在中也。

上六:戰龍於野,其血玄黃。
象曰:戰龍於野,其道窮也。

用六:利永貞。
象曰:用六永貞,以大終也。

文言曰:坤至柔,而動也剛,至靜而德方,后得主而有常,含萬物而化光。坤其道順乎? 承天而時行。積善之家,必有餘慶﹔積不善之家,必有餘殃。 臣弒其君,子弒其父,非一朝一夕之故,其所由來者漸矣,由辯之不早辯也。 易曰:「履霜堅冰至。」 蓋言順也。直其正也,方其義也。 君子敬以直內,義以方外,敬義立,而德不孤。 「直,方,大,不習無不利」﹔則不疑其所行也。陰雖有美,含之﹔以從王事,弗敢成也。 地道也,妻道也,臣道也。 地道無成 ,而代有終也。天地變化,草木蕃﹔ 天地閉,賢人隱。 易曰:「括囊﹔無咎,無譽。」 蓋言謹也。君子黃中通理,正位居體,美在其中,而暢於四支,發於事業,美之至也。陰疑於陽,必戰。為其嫌於無陽也,故稱龍焉。猶未離其類也,故稱血焉。 夫玄黃者,天地之雜也,天玄而地黃。

后土乘『牝馬』順天載物,行地無疆,終至品物咸亨。所謂『龍馬精神 』蓋此之謂耶!!

乾坤萬象自有它之內蘊機理,好似程序能將系統的輸入轉成輸出,或許這正是科學所追求之『萬物理論』的吧??

 

生 ︰西方英國有學者,名作『史蒂芬‧沃爾夫勒姆』 Stephen Wolfram 創造『 Mathematica 』,曾寫

一種新科學》 A New Kind of Science

,分類『細胞自動機』, 欲究事物之本原。

Cellular automaton

Gospers_glider_gun

Oscillator

A cellular automaton (pl. cellular automata, abbrev. CA) is a discrete model studied in computability theory, mathematics, physics, complexity science, theoretical biology and microstructure modeling. Cellular automata are also called cellular spaces, tessellation automata, homogeneous structures, cellular structures, tessellation structures, and iterative arrays.[2]

A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off (in contrast to a coupled map lattice). The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined relative to the specified cell. An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created (advancing t by 1), according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in terms of the current state of the cell and the states of the cells in its neighborhood. Typically, the rule for updating the state of cells is the same for each cell and does not change over time, and is applied to the whole grid simultaneously, though exceptions are known, such as the stochastic cellular automaton and asynchronous cellular automaton.

The concept was originally discovered in the 1940s by Stanislaw Ulam and John von Neumann while they were contemporaries at Los Alamos National Laboratory. While studied by some throughout the 1950s and 1960s, it was not until the 1970s and Conway’s Game of Life, a two-dimensional cellular automaton, that interest in the subject expanded beyond academia. In the 1980s, Stephen Wolfram engaged in a systematic study of one-dimensional cellular automata, or what he calls elementary cellular automata; his research assistant Matthew Cook showed that one of these rules is Turing-complete. Wolfram published A New Kind of Science in 2002, claiming that cellular automata have applications in many fields of science. These include computer processors and cryptography.

The primary classifications of cellular automata, as outlined by Wolfram, are numbered one to four. They are, in order, automata in which patterns generally stabilize into homogeneity, automata in which patterns evolve into mostly stable or oscillating structures, automata in which patterns evolve in a seemingly chaotic fashion, and automata in which patterns become extremely complex and may last for a long time, with stable local structures. This last class are thought to be computationally universal, or capable of simulating a Turing machine. Special types of cellular automata are reversible, where only a single configuration leads directly to a subsequent one, and totalistic, in which the future value of individual cells depend on the total value of a group of neighboring cells. Cellular automata can simulate a variety of real-world systems, including biological and chemical ones.

Elementary cellular automata

The simplest nontrivial cellular automaton would be one-dimensional, with two possible states per cell, and a cell’s neighbors defined as the adjacent cells on either side of it. A cell and its two neighbors form a neighborhood of 3 cells, so there are 23 = 8 possible patterns for a neighborhood. A rule consists of deciding, for each pattern, whether the cell will be a 1 or a 0 in the next generation. There are then 28 = 256 possible rules.[4] These 256 cellular automata are generally referred to by their Wolfram code, a standard naming convention invented by Wolfram that gives each rule a number from 0 to 255. A number of papers have analyzed and compared these 256 cellular automata. The rule 30 and rule 110 cellular automata are particularly interesting. The images below show the history of each when the starting configuration consists of a 1 (at the top of each image) surrounded by 0s. Each row of pixels represents a generation in the history of the automaton, with t=0 being the top row. Each pixel is colored white for 0 and black for 1.

Rule 30 cellular automaton

current pattern 111 110 101 100 011 010 001 000
new state for center cell 0 0 0 1 1 1 1 0
220px-CA_rule30s
Rule 30

Rule 110 cellular automaton

current pattern 111 110 101 100 011 010 001 000
new state for center cell 0 1 1 0 1 1 1 0

CA_rule110s

Rule 110

Rule 30 exhibits class 3 behavior, meaning even simple input patterns such as that shown lead to chaotic, seemingly random histories.

Rule 110, like the Game of Life, exhibits what Wolfram calls class 4 behavior, which is neither completely random nor completely repetitive. Localized structures appear and interact in various complicated-looking ways. In the course of the development of A New Kind of Science, as a research assistant to Wolfram in 1994, Matthew Cook proved that some of these structures were rich enough to support universality. This result is interesting because rule 110 is an extremely simple one-dimensional system, and difficult to engineer to perform specific behavior. This result therefore provides significant support for Wolfram’s view that class 4 systems are inherently likely to be universal. Cook presented his proof at a Santa Fe Institute conference on Cellular Automata in 1998, but Wolfram blocked the proof from being included in the conference proceedings, as Wolfram did not want the proof announced before the publication of A New Kind of Science.[56] In 2004, Cook’s proof was finally published in Wolfram’s journal Complex Systems (Vol. 15, No. 1), over ten years after Cook came up with it. Rule 110 has been the basis for some of the smallest universal Turing machines.[57]

△ 倘願求其詳,或可從元胞自動機始。

 

碼 ︰有 習 。試用實習 機 機板上的八顆 LED ,寫一 Rule 30 之『格子自動機』的派生程式。假設此八個 LED 循序不斷,如是『首』之『左格』為『尾』;『尾』之『右格』為『首』。試問此『格子時空』是否有『黑暗』的一天?

☿  答︰此程式可編碼如下︰

 

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# 加載所需程式庫
import RPi.GPIO as GPIO
from time import sleep

# 選擇 BCM 編號制
GPIO.setmode(GPIO.BCM)

# 採用負邏輯

四位數碼管位選一 = 17
四位數碼管位選二 = 27
四位數碼管位選三 = 22
四位數碼管位選四 = 10
滅 = 關 = GPIO.HIGH
亮 = 開 = GPIO.LOW

# 

藍一 = 5
藍二 = 6
藍三 = 13
藍四 = 19
綠一 = 0
綠二 = 1
黃 = 7
紅 = 8

# 初始態
GPIO.setup(四位數碼管位選一, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選二, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選三, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選四, GPIO.OUT, initial=關)

GPIO.setup(藍一, GPIO.OUT, initial=滅)
GPIO.setup(藍二, GPIO.OUT, initial=滅)
GPIO.setup(藍三, GPIO.OUT, initial=滅)
GPIO.setup(藍四, GPIO.OUT, initial=滅)
GPIO.setup(綠一, GPIO.OUT, initial=滅)
GPIO.setup(綠二, GPIO.OUT, initial=滅)
GPIO.setup(黃, GPIO.OUT, initial=滅)
GPIO.setup(紅, GPIO.OUT, initial=滅)

格子自動機 = [藍一, 藍二, 藍三, 藍四, 綠一, 綠二, 黃, 紅]
當下狀態 = [滅, 滅, 滅, 亮, 滅, 滅, 滅, 滅]
格子 = 0

GPIO.output(藍四, 亮)
sleep(3)

while True:
    新設狀態 =  [滅,滅,滅,滅,滅,滅,滅,滅]

    for 格子 in range(8) :

        左格 = 格子 - 1
        if 左格 < 0 :
            左格 = 7

        右格 = 格子 + 1
        if 右格 > 7 :
            右格 = 0

        當下樣態 = [當下狀態[左格], 當下狀態[格子], 當下狀態[右格]]

        print(格子, 當下狀態, 當下樣態, 新設狀態)

        if 當下樣態 == [亮, 亮, 亮] :
           新設狀態[格子] = 滅
            GPIO.output(格子自動機[格子], 滅)

        elif 當下樣態 == [亮, 亮, 滅] :
            新設狀態[格子] = 滅
            GPIO.output(格子自動機[格子], 滅)

        elif 當下樣態 == [亮, 滅, 亮] :
            新設狀態[格子] = 滅
            GPIO.output(格子自動機[格子], 滅)

        elif 當下樣態 == [亮, 滅, 滅] :
            新設狀態[格子] = 亮
            GPIO.output(格子自動機[格子], 亮)

        elif 當下樣態 == [滅, 亮, 亮] :
            新設狀態[格子] = 亮
            GPIO.output(格子自動機[格子], 亮)

        elif 當下樣態 == [滅, 亮, 滅] :
            新設狀態[格子] = 亮
            GPIO.output(格子自動機[格子], 亮)

        elif 當下樣態 == [滅, 滅, 亮] :
            新設狀態[格子] = 亮
            GPIO.output(格子自動機[格子], 亮)

        else:
            新設狀態[格子] = 滅
            GPIO.output(格子自動機[格子], 滅)

    當下狀態 = 新設狀態
    sleep(0.5)


GPIO.cleanup()

 

若問『黑暗日』,倒推說分明。若此真發生,除卻『暗黑態』── [,,,,,,, ──,或是『光明態』 ── [亮, 亮, 亮, 亮, 亮, 亮, 亮, 亮] ── ,必得是從『它態』來,狀態餘有二百五十四 ,若是『無』狀態能夠一步達抵『暗黑態』或者『光明態』,那就是『不可能』。此可驗之以『窮舉法』。

#!/usr/bin/python3
# -*- coding: utf-8 -*-
 
 
def 黑暗測試() :
    亮 = 0
    滅 = 1
    計次 = 1
    for 狀態一 in [亮, 滅]:
        for 狀態二 in [亮, 滅]:
            for 狀態三 in [亮, 滅]:
                for 狀態四 in [亮, 滅]:
                    for 狀態五 in [亮, 滅]:
                        for 狀態六 in [亮, 滅]:
                            for 狀態七 in [亮, 滅]:
                                for 狀態八 in [亮, 滅]:
 
                                    新設狀態 =  [滅,滅,滅,滅,滅,滅,滅,滅]
                                    測試狀態 = [狀態一, 狀態二, 狀態三, 狀態四, 狀態五, 狀態六, 狀態七, 狀態八]
 
 
                                    if 測試狀態 == [亮, 亮, 亮, 亮, 亮, 亮, 亮, 亮] or 測試狀態 == [滅, 滅, 滅, 滅, 滅, 滅, 滅, 滅] :
                                        continue
 
                                    for 格子 in range(8) :
 
                                        左格 = 格子 - 1
                                        if 左格 < 0 :
                                            左格 = 7
 
                                        右格 = 格子 + 1
                                        if 右格 > 7 :
                                            右格 = 0
 
                                        下一樣態 = [測試狀態[左格], 測試狀態[格子], 測試狀態[右格]]
 
                                        if 下一樣態 == [亮, 亮, 亮] :
                                            新設狀態[格子] = 滅
 
                                        elif 下一樣態 == [亮, 亮, 滅] :
                                            新設狀態[格子] = 滅
 
                                        elif 下一樣態 == [亮, 滅, 亮] :
                                            新設狀態[格子] = 滅
 
                                        elif 下一樣態 == [亮, 滅, 滅] :
                                            新設狀態[格子] = 亮
 
                                        elif 下一樣態 == [滅, 亮, 亮] :
                                            新設狀態[格子] = 亮
 
                                        elif 下一樣態 == [滅, 亮, 滅] :
                                            新設狀態[格子] = 亮
                                        elif 下一樣態 == [滅, 滅, 亮] :
                                            新設狀態[格子] = 亮
 
                                        else:
                                            新設狀態[格子] = 滅
 
                                    if 新設狀態 == [滅, 滅, 滅, 滅, 滅, 滅, 滅, 滅] or 新設狀態 == [亮, 亮, 亮, 亮, 亮, 亮, 亮, 亮] :
                                        return "有"
 
                                    print(計次, 測試狀態, 新設狀態)
                                    計次 +=1
    return "無"
 
 
print(黑暗測試())

 

訊 ︰☿ ☆☆