亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? electrnc.clp

?? 介紹ANTLR使用的JAVA程序例子
?? CLP
字號:
;;;======================================================
;;;   Circuit Input/Output Simplification Expert System
;;;
;;;     This program simplifies the boolean decision 
;;;     table for a circuit consisting of inputs (SOURCES) 
;;;     and outputs (LEDs). 
;;;
;;;     The simplification procedure works as follows:
;;;     1) The connections between components of the
;;;        circuit are initialized.
;;;     2) The response of the circuit when all SOURCEs
;;;        are set to zero is determined.
;;;     3) Source input values are changed one at a time
;;;        and the response of the circuit is determined.
;;;        All possible input combinations are iterated
;;;        through using a gray code (a number representation
;;;        system using binary digits in which successive
;;;        integers differ by exactly one binary digit).
;;;        For example, the gray code for the numbers 0 to 7
;;;        is 0 = 000, 1 = 001, 2 = 011, 3 = 010, 4 = 110,
;;;        5 = 111, 6 = 101, 7 = 100. By using a gray code,
;;;        only one SOURCE has to be changed at a time to
;;;        determine the next response in the decision 
;;;        table (minimizing execution time).
;;;     4) As responses are determined, a rule checks to
;;;        see if any two sets of inputs with the same
;;;        response differ if a single input. If so, then
;;;        the single input can be replaced with a * 
;;;        (indicating that it does not matter what the
;;;        value of the input is given the other inputs).
;;;        For example,  if the input 0 1 0 gave a response
;;;        of 1 0 and the input 0 0 0 gave the same response,
;;;        then the decision table can be simplified by
;;;        indicating that 0 * 0 gives a response of 1 0.
;;;     5) Once all responses and simplifications have been
;;;        determined, the decision table for the circuit is
;;;        printed.
;;;        
;;;     This example illustrates the use of most of the
;;;     constructs available in CLIPS 6.0 and also shows how
;;;     COOL can be effectively integrated with rules.
;;;     Generic functions are used to connect the components
;;;     of the circuit during initialization. Classes,
;;;     message-handlers, and deffunctions are used to
;;;     determine the response of the circuit to a set of
;;;     inputs. Rules, deffunctions, and global variables
;;;     are used to control execution, iterate through all
;;;     possible input combinations, simplify the boolean
;;;     decision tree, and print out the simplified decision
;;;     tree.
;;;
;;;     CLIPS Version 6.0 Example
;;; 
;;;     To execute, load this file, load one of the circuit
;;;     files (circuit1.clp, circuit2.clp, or circuit3.clp), 
;;;     reset, and run.
;;;======================================================


;;;***********
;;; DEFCLASSES
;;;***********

(defclass COMPONENT
  (is-a USER)
  (slot ID# (create-accessor write)))

(defclass NO-OUTPUT
  (is-a USER)
  (slot number-of-outputs (access read-only) 
                          (default 0)
                          (create-accessor read)))

(defmessage-handler NO-OUTPUT compute-output ())

(defclass ONE-OUTPUT
  (is-a NO-OUTPUT)
  (slot number-of-outputs (access read-only) 
                          (default 1)
                          (create-accessor read))
  (slot output-1 (default UNDEFINED) (create-accessor write))
  (slot output-1-link (default GROUND) (create-accessor write))
  (slot output-1-link-pin (default 1) (create-accessor write)))

(defmessage-handler ONE-OUTPUT put-output-1 after (?value)
   (send ?self:output-1-link 
         (sym-cat put-input- ?self:output-1-link-pin)
         ?value))

(defclass TWO-OUTPUT
  (is-a ONE-OUTPUT)
  (slot number-of-outputs (access read-only) 
                          (default 2)
                          (create-accessor read))
  (slot output-2 (default UNDEFINED) (create-accessor write))
  (slot output-2-link (default GROUND) (create-accessor write))
  (slot output-2-link-pin (default 1) (create-accessor write)))

(defmessage-handler TWO-OUTPUT put-output-1 after (?value)
   (send ?self:output-2-link 
         (sym-cat put-input- ?self:output-2-link-pin)
         ?value))

(defclass NO-INPUT
  (is-a USER)
  (slot number-of-inputs (access read-only) 
                         (default 0)
                         (create-accessor read)))

(defclass ONE-INPUT
  (is-a NO-INPUT)
  (slot number-of-inputs (access read-only) 
                         (default 1)
                         (create-accessor read))
  (slot input-1 (default UNDEFINED) 
                (visibility public)
                (create-accessor read-write))
  (slot input-1-link (default GROUND) (create-accessor write))
  (slot input-1-link-pin (default 1) (create-accessor write)))

(defmessage-handler ONE-INPUT put-input-1 after (?value)
   (send ?self compute-output))

(defclass TWO-INPUT
  (is-a ONE-INPUT)
  (slot number-of-inputs (access read-only) 
                         (default 2)
                         (create-accessor read))
  (slot input-2 (default UNDEFINED) 
                (visibility public)
                (create-accessor write))
  (slot input-2-link (default GROUND) (create-accessor write))
  (slot input-2-link-pin (default 1) (create-accessor write)))

(defmessage-handler TWO-INPUT put-input-2 after (?value)
   (send ?self compute-output))
 
(defclass SOURCE
  (is-a NO-INPUT ONE-OUTPUT COMPONENT)
  (role concrete)
  (slot output-1 (default UNDEFINED) (create-accessor write)))

(defclass SINK
  (is-a ONE-INPUT NO-OUTPUT COMPONENT)
  (role concrete)
  (slot input-1 (default UNDEFINED) (create-accessor read-write)))

;;;*******************
;;; NOT GATE COMPONENT
;;;*******************

(defclass NOT-GATE
  (is-a ONE-INPUT ONE-OUTPUT COMPONENT)
  (role concrete))

(deffunction not# (?x) (- 1 ?x))

(defmessage-handler NOT-GATE compute-output ()
   (if (integerp ?self:input-1) then
       (send ?self put-output-1 (not# ?self:input-1))))

;;;*******************
;;; AND GATE COMPONENT
;;;*******************

(defclass AND-GATE
  (is-a TWO-INPUT ONE-OUTPUT COMPONENT)
  (role concrete))

(deffunction and# (?x ?y) 
  (if (and (!= ?x 0) (!= ?y 0)) then 1 else 0))

(defmessage-handler AND-GATE compute-output ()
   (if (and (integerp ?self:input-1) 
            (integerp ?self:input-2)) then
       (send ?self put-output-1 (and# ?self:input-1 ?self:input-2))))

;;;******************
;;; OR GATE COMPONENT
;;;******************

(defclass OR-GATE
  (is-a TWO-INPUT ONE-OUTPUT COMPONENT)
  (role concrete))

(deffunction or# (?x ?y) 
  (if (or (!= ?x 0) (!= ?y 0)) then 1 else 0))

(defmessage-handler OR-GATE compute-output ()
   (if (and (integerp ?self:input-1) 
            (integerp ?self:input-2)) then
       (send ?self put-output-1 (or# ?self:input-1 ?self:input-2))))

;;;********************
;;; NAND GATE COMPONENT
;;;********************

(defclass NAND-GATE
  (is-a TWO-INPUT ONE-OUTPUT COMPONENT)
  (role concrete))

(deffunction nand# (?x ?y) 
  (if (not (and (!= ?x 0) (!= ?y 0))) then 1 else 0))

(defmessage-handler NAND-GATE compute-output ()
   (if (and (integerp ?self:input-1) 
            (integerp ?self:input-2)) then
       (send ?self put-output-1 (nand# ?self:input-1 ?self:input-2))))

;;;*******************
;;; XOR GATE COMPONENT
;;;*******************

(defclass XOR-GATE
  (is-a TWO-INPUT ONE-OUTPUT COMPONENT)
  (role concrete))

(deffunction xor# (?x ?y) 
  (if (or (and (= ?x 1) (= ?y 0))
          (and (= ?x 0) (= ?y 1))) then 1 else 0))

(defmessage-handler XOR-GATE compute-output ()
   (if (and (integerp ?self:input-1) 
            (integerp ?self:input-2)) then
       (send ?self put-output-1 (xor# ?self:input-1 ?self:input-2))))

;;;*******************
;;; SPLITTER COMPONENT
;;;*******************

(defclass SPLITTER
  (is-a ONE-INPUT TWO-OUTPUT COMPONENT)
  (role concrete))

(defmessage-handler SPLITTER compute-output ()
   (if (integerp ?self:input-1) then
       (send ?self put-output-1 ?self:input-1)
       (send ?self put-output-2 ?self:input-1)))

;;;**************
;;; LED COMPONENT
;;;**************

(defclass LED
  (is-a ONE-INPUT NO-OUTPUT COMPONENT)
  (role concrete))

;;; Returns the current value of each LED 
;;; instance in a multifield value.
(deffunction LED-response ()
   (bind ?response (create$))
   (do-for-all-instances ((?led LED)) TRUE
      (bind ?response (create$ ?response (send ?led get-input-1))))
   ?response)

;;;***************************
;;; DEFGENERICS AND DEFMETHODS
;;;***************************

(defgeneric connect)

;;; Connects a one output component to a one input component.
(defmethod connect ((?out ONE-OUTPUT) (?in ONE-INPUT)) 
   (send ?out put-output-1-link ?in) 
   (send ?out put-output-1-link-pin 1)
   (send ?in  put-input-1-link ?out)
   (send ?in  put-input-1-link-pin 1))

;;; Connects a one output component to one pin of a two input component.
(defmethod connect ((?out ONE-OUTPUT) (?in TWO-INPUT) (?in-pin INTEGER)) 
   (send ?out put-output-1-link ?in)
   (send ?out put-output-1-link-pin ?in-pin)
   (send ?in  (sym-cat put-input- ?in-pin -link) ?out)
   (send ?in  (sym-cat put-input- ?in-pin -link-pin) 1))

;;; Connects one pin of a two output component to a one input component.
(defmethod connect ((?out TWO-OUTPUT) (?out-pin INTEGER) (?in ONE-INPUT)) 
   (send ?out (sym-cat put-output- ?out-pin -link) ?in)
   (send ?out (sym-cat put-output- ?out-pin -link-pin) 1)
   (send ?in put-input-1-link ?out)
   (send ?in put-input-1-link-pin ?out-pin))

;;; Connects one pin of a two output component 
;;; to one pin of a two input component.
(defmethod connect ((?out TWO-OUTPUT) (?out-pin INTEGER)
                    (?in TWO-INPUT) (?in-pin INTEGER)) 
   (send ?out (sym-cat put-output- ?out-pin -link) ?in)
   (send ?out (sym-cat put-output- ?out-pin -link-pin) ?in-pin)
   (send ?in  (sym-cat put-input- ?in-pin -link) ?out)
   (send ?in  (sym-cat put-input- ?in-pin -link-pin) ?out-pin))

;;;****************************
;;; DEFGLOBALS AND DEFFUNCTIONS 
;;;****************************

(defglobal ?*gray-code* = (create$)
           ?*sources* = (create$)
           ?*max-iterations* = 0)

;;; Given the current iteration, determines the next 
;;; bit in the gray code to change. 
;;; Algorithm courtesy of John R. Kennedy (The BitMan).
(deffunction change-which-bit (?x)
   (bind ?i 1)
   (while (and (evenp ?x) (!= ?x 0)) do 
      (bind ?x (div ?x 2))
      (bind ?i (+ ?i 1)))
   ?i)

;;; Forward declaration since the initial configuration
;;; is stored in a separate file.
(deffunction connect-circuit ())

;;;*********
;;; DEFRULES
;;;*********

(defrule startup
  =>
  ;; Initialize the circuit by connecting the components
  (connect-circuit) 
  ;; Setup the globals. 
  (bind ?*sources* (find-all-instances ((?x SOURCE)) TRUE))
  (do-for-all-instances ((?x SOURCE)) TRUE
     (bind ?*gray-code* (create$ ?*gray-code* 0)))
  (bind ?*max-iterations* (round (** 2 (length ?*sources*))))
  ;; Do the first response.
  (assert (current-iteration 0)))

(defrule compute-response-1st-time
   ?f <- (current-iteration 0)
   =>
   ;; Set all of the sources to zero.
   (do-for-all-instances ((?source SOURCE)) TRUE (send ?source put-output-1 0))
   ;; Determine the initial LED response.
   (assert (result ?*gray-code* =(str-implode (LED-response))))
   ;; Begin the iteration process of looping through the gray code combinations.
   (retract ?f)
   (assert (current-iteration 1)))

(defrule compute-response-other-times
   ?f <- (current-iteration ?n&~0&:(< ?n ?*max-iterations*))
   =>
   ;; Change the gray code, saving the changed bit value.
   (bind ?pos (change-which-bit ?n))
   (bind ?nv (- 1 (nth ?pos ?*gray-code*)))
   (bind ?*gray-code* (replace$ ?*gray-code* ?pos ?pos ?nv))
   ;; Change the single changed source
   (send (nth ?pos ?*sources*) put-output-1 ?nv)   
   ;; Determine the LED response to the input.
   (assert (result ?*gray-code* =(str-implode (LED-response))))
   ;; Assert the new iteration fact
   (retract ?f)
   (assert (current-iteration =(+ ?n 1))))

(defrule merge-responses
   (declare (salience 10))
   ?f1 <- (result $?b  ?x $?e ?response)
   ?f2 <- (result $?b ~?x $?e ?response)
   =>
   (retract ?f1 ?f2)
   (assert (result $?b * $?e ?response)))

(defrule print-header
   (declare (salience -10))
   =>
   (assert (print-results))
   (do-for-all-instances ((?x SOURCE)) TRUE (format t " %3s " (sym-cat ?x)))
   (printout t " | ")
   (do-for-all-instances ((?x LED)) TRUE (format t " %3s " (sym-cat ?x)))
   (format t "%n")
   (do-for-all-instances ((?x SOURCE)) TRUE (printout t "-----"))
   (printout t "-+-")
   (do-for-all-instances ((?x LED)) TRUE (printout t "-----"))
   (format t "%n"))
      
(defrule print-result
   (print-results)
   ?f <- (result $?input ?response)
   (not (result $?input-2 ?response-2&:(< (str-compare ?response-2 ?response) 0)))
   =>
   (retract ?f)
   ;; Print the input from the sources.
   (while (neq ?input (create$)) do
      (printout t "  " (nth 1 ?input) "  ")
      (bind ?input (rest$ ?input)))
   ;; Print the output from the LEDs.
   (printout t " | ")
   (bind ?response (str-explode ?response))
   (while (neq ?response (create$)) do
      (printout t "  " (nth 1 ?response) "  ")
      (bind ?response (rest$ ?response)))
   (printout t crlf))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美唯美清纯偷拍| 日本亚洲免费观看| 久久久综合精品| 欧美一级在线免费| 欧美日韩一区二区三区高清| 不卡av电影在线播放| 久久国产福利国产秒拍| 日韩影院免费视频| 免费成人在线视频观看| 天天影视涩香欲综合网| 亚洲电影一级黄| 亚洲一区二区三区国产| 午夜伊人狠狠久久| 免费的成人av| 国产乱色国产精品免费视频| 国产电影一区在线| 99精品欧美一区二区三区小说| 成人免费电影视频| 91小视频免费观看| 欧美日韩国产另类一区| 日韩欧美一区二区久久婷婷| 精品国产露脸精彩对白| 国产午夜精品美女毛片视频| 欧美激情一区在线观看| 亚洲人成网站在线| 天堂资源在线中文精品| 黑人精品欧美一区二区蜜桃| 成人一区二区三区视频在线观看 | 亚洲裸体xxx| 亚洲综合成人网| 麻豆极品一区二区三区| 国产成+人+日韩+欧美+亚洲| 北岛玲一区二区三区四区| 日本道在线观看一区二区| 欧美一区二区在线免费播放| 精品国产污污免费网站入口 | 欧美日韩专区在线| 欧美成人三级在线| 综合色中文字幕| 蜜桃久久精品一区二区| 成人av电影在线观看| 欧美日韩一区不卡| 中文字幕不卡三区| 五月天激情综合网| 成人av网站大全| 日韩欧美一级精品久久| 一区在线中文字幕| 九色综合狠狠综合久久| 91黄色免费版| 久久综合久色欧美综合狠狠| 亚洲特黄一级片| 国产一区二区在线影院| 91免费观看视频| 欧美精品一区二区三区很污很色的 | 国产精品成人在线观看| 蜜桃久久av一区| 91行情网站电视在线观看高清版| 久久综合九色综合97_久久久| 亚洲免费在线电影| 国产69精品久久久久777| 欧美一区三区二区| 亚洲福利一二三区| 99re成人在线| 国产调教视频一区| 国内不卡的二区三区中文字幕| 在线观看一区不卡| 国产精品不卡在线观看| 国产成人午夜片在线观看高清观看| 在线观看91精品国产入口| 国产精品嫩草99a| 国产成人在线看| wwww国产精品欧美| 五月天一区二区三区| 欧美日韩免费在线视频| 亚洲综合激情网| 99r国产精品| 亚洲欧美一区二区视频| 高潮精品一区videoshd| 久久色在线视频| 日本不卡123| 欧美一级在线免费| 久久成人免费网站| 久久久91精品国产一区二区精品| 免费精品视频最新在线| 欧美大黄免费观看| 国产精品一二三在| 中文字幕欧美日韩一区| 成人av网站免费| 亚洲乱码精品一二三四区日韩在线 | 久久综合精品国产一区二区三区 | 亚洲v精品v日韩v欧美v专区| 欧美日韩专区在线| 日韩电影在线一区二区三区| 欧美一区二区三区视频免费 | 综合欧美亚洲日本| 在线区一区二视频| 午夜精品久久久久影视| 欧美肥妇bbw| 麻豆91免费看| 久久综合九色综合欧美亚洲| 高清视频一区二区| 亚洲美女一区二区三区| 欧美日韩高清不卡| 国产美女精品一区二区三区| 欧美精品一区二| 丁香桃色午夜亚洲一区二区三区| 国产精品福利影院| 色素色在线综合| 日韩电影在线观看电影| 国产亚洲一二三区| 色偷偷一区二区三区| 日韩成人精品在线观看| 国产欧美一区二区三区鸳鸯浴 | 成人黄色片在线观看| 亚洲综合激情另类小说区| 91精品国产品国语在线不卡| 国产综合色精品一区二区三区| 中文字幕不卡三区| 337p亚洲精品色噜噜狠狠| 丁香婷婷综合五月| 午夜成人在线视频| 欧美激情在线免费观看| 欧美精品aⅴ在线视频| 大尺度一区二区| 亚洲一区二区四区蜜桃| 久久久一区二区三区| 欧美日韩一区二区在线观看 | 欧美性三三影院| 国模无码大尺度一区二区三区| 一区二区三区在线影院| 精品国产亚洲在线| 日本精品一级二级| 黄页视频在线91| 亚洲一区二区在线免费观看视频| 精品免费一区二区三区| 在线免费av一区| 成人av在线电影| 日本不卡在线视频| 一区二区三区成人| 国产精品天美传媒沈樵| 日韩免费看网站| 欧美日韩国产大片| 色综合欧美在线| 风流少妇一区二区| 日韩av中文在线观看| 亚洲综合视频网| 日韩码欧中文字| 国产精品国产三级国产| 国产视频在线观看一区二区三区| 欧美精品xxxxbbbb| 欧美中文字幕一二三区视频| 国产乱子伦一区二区三区国色天香| 日韩精品1区2区3区| 亚洲综合色区另类av| 国产欧美日本一区二区三区| 日韩欧美一级二级三级久久久| 成人久久视频在线观看| 亚洲午夜电影在线观看| 亚洲线精品一区二区三区八戒| 国产精品久久久久久久岛一牛影视 | 日本一二三不卡| 精品免费日韩av| 精品国产乱码久久久久久图片| 日韩一区二区三区高清免费看看| 在线观看成人免费视频| 欧美精品一二三四| 欧美日韩国产综合一区二区 | 91精品蜜臀在线一区尤物| 欧美精品自拍偷拍| 日韩欧美在线一区二区三区| 欧美xingq一区二区| 精品国产区一区| 国产免费观看久久| 亚洲精品自拍动漫在线| 亚洲第一综合色| 韩国三级电影一区二区| 成人福利电影精品一区二区在线观看| 成人深夜福利app| 成人一区二区三区在线观看| 成人一二三区视频| 欧美午夜不卡在线观看免费| 8x8x8国产精品| 2017欧美狠狠色| 中文字幕一区二区在线播放| 亚洲一区精品在线| 国产综合色产在线精品| 不卡一区二区三区四区| 99精品桃花视频在线观看| 欧美偷拍一区二区| 26uuu国产电影一区二区| 欧美高清在线一区二区| 亚洲福利一二三区| 国产精品自拍av| 欧美网站一区二区| 欧美高清一级片在线观看| 亚洲高清中文字幕| 国产91丝袜在线播放九色| 精品污污网站免费看| 国产丝袜在线精品| 青青草97国产精品免费观看无弹窗版 |