【问题标题】:FIX UNKNOWN facts keep being asserted implicitly in CLIPSFIX UNKNOWN 事实不断在 CLIPS 中被隐式断言
【发布时间】:2021-04-08 19:34:54
【问题描述】:

修正隐含的事实断言

deftemplate 和 defrules

(deftemplate Fuels  "Identifying characteristics"
   (slot appearance
      (type SYMBOL)
      (allowed-symbols clear amber brownish-red yellow-tint brown-with-green-tint yellowish-green)
   )
   (slot smell
      (type SYMBOL)
      (allowed-symbols strong-odour strong-lingering-odour  cooking-oil  burnt-popcorn)
   )
   (slot touch
      (type SYMBOL)
      (allowed-symbols oily-feel waxy  cold  slippery)
   )
)

(defrule Petrol  "Identifying characteristics"
   (Fuels (appearance brownish-red|yellow-tint)
          (smell strong-odour)
          (touch cold)
   )  
   =>
   (printout t "It's petrol that is leaking" crlf
               "If leak is caused by something other than over filling the tank, do NOT drive the car." crlf
               "Fuel leaks are very dangerous and potentially explosive."crlf
               "Call a mechanic if you find a fuel leak in your car"crlf
   )
)

(defrule Diesel "Identifying characteristics"
   (Fuels (appearance brown-with-green-tint|yellowish-green)
          (smell strong-lingering-odour)  
          (touch oily-feel|waxy)
   )
   =>
   (printout t "It's diesel that is leaking" crlf
               "If leak is caused by something other than overfilling the tank, do NOT drive the car." crlf
               "Fuel leaks are very dangerous and potentially explosive."crlf
               "Call a mechanic if you find a fuel leak in your car"crlf
              
   )
)

(defrule Bio-fuel  "Identifying characteristics"
   (Fuels (appearance clear|amber) 
          (smell cooking-oil|burnt-popcorn)
          (touch slippery) 
   )
   =>
   (printout t crlf 
             "It's bio-fuel that is leaking" crlf
             "If leak is caused by something other than overfilling the tank,DO NOT! drive the car." crlf 
             "Fuel leaks are very dangerous and potentially explosive."crlf 
             "Call a mechanic if you find a fuel leak in your car."crlf
   )
)

当使用facts命令时返回

f-1     (Fuels (appearance brownish-red) (smell strong-odor) (touch oily-feel))
f-2     (Fuels (appearance clear) (smell strong-odor) (touch oily-feel))
f-3     (Fuels (appearance clear) (smell strong-odor) (touch cold))

即使这是断言:

(Fuels (appearance brownish-red) (smell strong-odour) (touch cold))

帮助解决这个问题

【问题讨论】:

  • 您发布的代码不可能产生此结果。你在描述你的问题时遗漏了一些东西。
  • 这是完整的知识库
  • 使用匹配时,汽油、柴油或生物燃料均未激活

标签: clips


【解决方案1】:

此代码没有任何问题,但它也无法产生您在问题中显示的事实 f-2 和 f-3。

         CLIPS (6.31 6/12/19)
CLIPS> 
(deftemplate Fuels  "Identifying characteristics"
   (slot appearance
      (type SYMBOL)
      (allowed-symbols clear amber brownish-red yellow-tint brown-with-green-tint yellowish-green)
   )
   (slot smell
      (type SYMBOL)
      (allowed-symbols strong-odour strong-lingering-odour  cooking-oil  burnt-popcorn)
   )
   (slot touch
      (type SYMBOL)
      (allowed-symbols oily-feel waxy  cold  slippery)
   )
)
CLIPS> 
(defrule Petrol  "Identifying characteristics"
   (Fuels (appearance brownish-red|yellow-tint)
          (smell strong-odour)
          (touch cold)
   )  
   =>
   (printout t "It's petrol that is leaking" crlf
               "If leak is caused by something other than over filling the tank, do NOT drive the car." crlf
               "Fuel leaks are very dangerous and potentially explosive."crlf
               "Call a mechanic if you find a fuel leak in your car"crlf
   )
)
CLIPS> 
(defrule Diesel "Identifying characteristics"
   (Fuels (appearance brown-with-green-tint|yellowish-green)
          (smell strong-lingering-odour)  
          (touch oily-feel|waxy)
   )
   =>
   (printout t "It's diesel that is leaking" crlf
               "If leak is caused by something other than overfilling the tank, do NOT drive the car." crlf
               "Fuel leaks are very dangerous and potentially explosive."crlf
               "Call a mechanic if you find a fuel leak in your car"crlf
              
   )
)
CLIPS> 
(defrule Bio-fuel  "Identifying characteristics"
   (Fuels (appearance clear|amber) 
          (smell cooking-oil|burnt-popcorn)
          (touch slippery) 
   )
   =>
   (printout t crlf 
             "It's bio-fuel that is leaking" crlf
             "If leak is caused by something other than overfilling the tank,DO NOT! drive the car." crlf 
             "Fuel leaks are very dangerous and potentially explosive."crlf 
             "Call a mechanic if you find a fuel leak in your car."crlf
   )
)
CLIPS> (assert (Fuels (appearance brownish-red) (smell strong-odour) (touch cold)))
<Fact-1>
CLIPS> (agenda)
0      Petrol: f-1
For a total of 1 activation.
CLIPS> (run)
It's petrol that is leaking
If leak is caused by something other than over filling the tank, do NOT drive the car.
Fuel leaks are very dangerous and potentially explosive.
Call a mechanic if you find a fuel leak in your car
CLIPS> (facts)
f-0     (initial-fact)
f-1     (Fuels (appearance brownish-red) (smell strong-odour) (touch cold))
For a total of 2 facts.
CLIPS> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-15
    • 1970-01-01
    • 2014-12-03
    • 1970-01-01
    • 2010-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多