ããããŒã°ã¯ãŠããŒã¯ã§ãã ããã¯ã宣èšåããã°ã©ãã³ã°ãã©ãã€ã ãè¡šãå¯äžã®èšèªã§ãã ããã¯äœçŸãã®ç°ãªãå®è£ ãæã€èšèªã§ããããããã¯äŸç¶ãšããŠPrologãšåŒã°ããååã«æ¥é èŸãšæ¥å°ŸèŸã®ã¿ãè¿œå ããŸãã ããã¯ã20幎以äžã«ããã£ãŠå€§ããªå€åãçããŠããªãçããèšèªã§ãã ããã¯ãããããå®éã®ããã°ã©ãã³ã°ã§ã¯åœ¹ã«ç«ããªãå¯äžã®äººæ°ã®ããããã°ã©ãã³ã°èšèªã§ãã ãªãããããŒã°ãªã®ãïŒ
ããããŒã°ã¯æ¬è³ªçã«ãŠããŒã¯ã§ã幞ããªå¶ç¶ïŒ
ãã®èšäºã§ã¯ãäžè¬çãªè«ççãªåé¡ã解決ããããã®ããŒã«ãšããŠã®Prologã«ã€ããŠã話ããŸãã ãã®ãããã¯ã¯ãPrologæ§æãæ¢ã«ææããŠãããå éšããç解ããã人ããèšèªæ§æããŸã£ããç¥ããªãããæ§ææ§ç¯ã®å匷ã«æéããããã«ããã€ã©ã€ãããç解ããã人ã«ãšã£ãŠèå³æ·±ããã®ã§ãã
Prologã®äž»ãªæ©èœã¯èªã¿ãããããšã§ãããæžãã®ã¯éåžžã«å°é£ã§ããããã¯ããã¹ãŠã®äž»æµèšèªãšã¯æ ¹æ¬çã«ç°ãªããããã«ç°¡åã«ãªã
ããããŒã°ããã°ã©ã ãæ£ããèªãæ¹æ³
èšèªã«ã¯ç¹æ®æåãšããŒã¯ãŒããã»ãšãã©ãªããèªç¶èšèªã«ç°¡åã«ç¿»èš³ããããããããã°ã©ã ã®èªã¿åãã¯éåžžã«ç°¡åã§ãã ããã°ã©ããŒã®äž»ãªééãã¯ãããã°ã©ã ãã©ã®ããã«æ©èœããããããã«æ³åããããšããããšã§ãããããã°ã©ã ã®èª¬æãèªãã§ããªããããæ®éã®äººã®é§ã®è³ãèšç·Žããããšã¯ããã°ã©ããŒãããã¯ããã«ç°¡åã§ãã
ã³ã³ã»ãã
ãã®èšèªã«ã¯ã è¿°èª ïŒæ¡ä»¶ïŒãšãªããžã§ã¯ã ïŒå€æ°ãšçšèªããããŸã ïŒã®2ã€ã®æŠå¿µããããŸãã è¿°èªã¯æ¡ä»¶ãè¡šããŸããããšãã°ããªããžã§ã¯ããç·ãŸãã¯çŽ æ°ã§ããå Žåãæ¡ä»¶ã«å ¥åãã©ã¡ãŒã¿ãŒãããããšã¯èªç¶ã§ãã ããšãã°ã green_objectïŒObjectïŒ ã prime_numberïŒNumberïŒ ã è¿°èªã«å«ãŸãããã©ã¡ãŒã¿ãŒã®æ°ãããã¯ãè¿°èªã®ã¢ãªãã£ã§ãã ãªããžã§ã¯ãã¯ãçšèªãå®æ°ãå€æ°ã§ãã å®æ° -ãããã¯æ°åãšæååã å€æ°ã§ã -æªç¥ã®ãªããžã§ã¯ããè¡šããããããæ€çŽ¢ããã倧æåã®æååãšããŠæå®ãããŸãã ä»ã®ãšããæ¡ä»¶ããã®ãŸãŸã«ããŠãæãåçŽãªããã°ã©ã ãæ€èšããŠãã ããã
ããã°ã©ã
ããã°ã©ã ã¯ã If condition1 and condition2 and ...ãšãã圢åŒã®äžé£ã®ã«ãŒã«ã§ããæ¡ä»¶ã¯trueã§ãã æ£åŒã«ã¯ããããã®ã«ãŒã«ã¯ANDãä»ããŠçµåãããŸãããPrologã«ã¯è«çåŠå®ããªããToãªã³ã¯ã«ã¯è¿°èªïŒæ¡ä»¶ïŒã1ã€ããååšããªããããççŸãååŸããããšã¯ã§ããŸããã
A :- B_1, B_2. % : B_1 B_2, A
_() :- (), ().
% "" - , "" - _
ã芧ã®ãšãããå€æ°ã®ååã«ã¯ã¹ã³ãŒãããããŸã-ãããã«ãŒã«ã§ãã æ°åŠçã«ã¯ãã«ãŒã«ãèãããŸããä»»æã®å€æ°-ãæ°å€ãã«ã€ããŠããããåçŽã§å¥åŠãªå Žåãããã¯simple_ oddã§ãã åæ§ã«ããããèšãæããããšãã§ããŸãããNumberããå¥æ°ã§åçŽãªå Žåãããã¯odd_simpleã§ãã ãããã£ãŠãå€æ°ã®ååã¯éåžžã«éèŠã§ãïŒ å·ŠåŽïŒåïŒ-ïŒã§NumberãNumber2ã«çœ®ãæãããšãã«ãŒã«ã®æå³ãå€ãããŸããNumber2ãšNumberã«ã€ããŠãNumberãçŽ æ°ã§å¥æ°ã®å ŽåãNumber2ã¯åçŽãªå¥æ°ã§ãã ãã¹ãŠã®æ°åã¯åçŽãªå¥æ°ã§ãïŒ ããã¯ãPrologã®æãäžè¬çãªééãã§ãã
A :- B_1, B_2. % : B_1 B_2, A _() :- (), (). % "" - , "" - _
A :- B_1, B_2. % : B_1 B_2, A _() :- (), (). % "" - , "" - _
äŸ-å®å šãªæ°å
_() :- (), ___(, ), (, ). _(1). (, ). ___(1, 1). ___(, ) :- _(, ), ____(, , ). ____(, 1, 1). ____(, , ) :- _(, ), _(, ), ____(, , ), (, , ). ____(, , ) :- __(, ), _(, ), ____(, , ).
_() :- (), ___(, ), (, ). _(1). (, ). ___(1, 1). ___(, ) :- _(, ), ____(, , ). ____(, 1, 1). ____(, , ) :- _(, ), _(, ), ____(, , ), (, , ). ____(, , ) :- __(, ), _(, ), ____(, , ).
æåã«ãèŠåã®æå³ãæ£åŒã«èªã¿ãŸãã
- ãHããæ°å€ã§ããããHãããã³ãSum of Dividersãã®å Žåãæ¡ä»¶ã¯sum_divisers_without_numberã§ããã€ãŸããSum of Divisorsã¯æ°å€ãHãã®é€ç®åšã®åèšã§ããããHãã¯ãSum of Divisorsãã«çããããããChãã¯å®å šãªæ°å€ã§ãã
- 1ã¯å®å šãªæ°ã§ãã ã«ãŒã«ã«ã¯æ¡ä»¶ããªãå Žåãããããã®å Žåã¯ã«ãŒã«ãšåŒã°ããŸãã
- ãã¹ãŠã®ãªããžã§ã¯ããOãã¯ãOãã«çããã ååãšããŠãæšæºçãªè¿°èªã=ãããããŸãããå®å šã«ç¬èªã®è¿°èªã«çœ®ãæããããšãã§ããŸãã
- sum_deleters_ without_number 1ã®äºå®ã¯1ã§ãã
- ä»åãã®ãæ°ãã®åã®æ°ãæ°ãã«å¯Ÿããåèšããåèšãã«çããå Žåãããã¯ãæ°ãé€ããä»åãã®åèšã§ãã ãããã£ãŠãXãXã§é€ç®ãããããXã®çŽæ°ã®åèšã¯Y以äžã§ãããããã£ãŠãY = X-1ã«ãªããŸãã
- 次ã«ã3ã€ã®è¿°èªãé€æ°ã®åèšã決å®ããŸããæ°å€ã¯YïŒååšåšïŒä»¥äžã1çªç®ã®ã±ãŒã¹Yã¯1ã2çªç®ã®å Žåã¯æ°å€ãYã§é€ç®ããé€ç®åšã®åèšïŒXãYïŒ=é€ç®åšã®åèšïŒXãY-1ïŒ+ Y ãããã³3çªç®ã®ã±ãŒã¹ã§ã¯ãæ°å€ã¯Yã§å²ãåããŸããã次ã«ãsum_ofé€ç®åšïŒXãYïŒ= sum_ofé€ç®åšïŒXãY-1ïŒã
ããã°ã©ã -å®çŸ©ã®ã»ãããšããŠ
ãå®çŸ©ãã«åºã¥ããŠããããã®èŠåãèªã¿åãããã®2çªç®ã®æ¹æ³ããããŸãã ããããŒã°ã§ã¯ãå·ŠåŽã®ãã¹ãŠã®ã«ãŒã«ïŒäžéšïŒã«å«ãŸããæ¡ä»¶ã¯1ã€ã®ã¿ã§ãããæ¬è³ªçã«ã¯ãã®æ¡ä»¶ã®ãå®çŸ©ãã§ããããšãããããŸãã
ããšãã°ãæåã®ã«ãŒã«ã¯å®å šæ°ã®å®çŸ©ã§ãã ãHããæ°ã§ããããHãã®çŽæ°ã®åèšããHãã«çããå ŽåããHãã¯å®å šãªæ°ã§ãã åäžã®è¿°èªã¯ãååã«ãã£ãŠã°ã«ãŒãåãããããŸãã¯ãæ¡ä»¶ã«ãã£ãŠçµåãããŸãã ã€ãŸããå®çŸ©ã«è¿œå ã§ããŸãããHãã¯ã..ãŸãã¯ãHãã1ã®ãšãã«å®å šãªæ°ã§ãã
ãã®èªã¿åãæ¹æ³ã¯ãè¿°èªãåçš®ã®ã°ã«ãŒãã«çµåã§ããã€ã³ã¿ãŒããªã¿ãŒãè¿°èªãå·»ãæ»ãé åºãç解ããã®ã«åœ¹ç«ã€ãããåºã䜿çšãããŠããŸã
声æã®çå®ãæ€èšŒããã ããšãã°ãè¿°èªã«å®çŸ©ããªãå Žåãããã䜿çšããŠæã®ççã蚌æããããšã¯äžå¯èœã§ããããšã¯æããã§ãã äŸ1ã§ã¯ãè¿°èªãdivides_onãã«ã¯å®çŸ©ããããŸããã
èå³æ·±ãäºå®ã¯ãPrologã«ã¯ã«ãŒããå€æ°ã®å²ãåœãŠãå宣èšããªããçšèªãšã¯ãªããã³ã°ãæãåºãã°ãèšèªã¯ã¢ã«ãŽãªãºã çã«å®å šã«ãªããšããããšã§ãã
èŠçŽ
çšèªã«ã¯ããªããžã§ã¯ãã®ååä»ãã³ã¬ã¯ã·ã§ã³ãšããŠååž°çãªå®çŸ©ããããŸãã çšèª= 'name'ïŒãªããžã§ã¯ãããªããžã§ã¯ãã...ïŒããµã³ãã«personïŒ 'Name'ã 'Surname'ïŒã '+'ïŒ1ã2ïŒãpersonïŒaddressïŒ 'Some address'ïŒãsurnameïŒ 'Last name 'ïŒãphoneïŒ' Phone 'ïŒïŒ ã çšèªãæ°åŠçæŠå¿µãšã¿ãªãå Žåãçšèªã¯é¢æ°ããŸãã¯ãã¡ã³ã¯ã¿ãŒãã€ãŸãã+ãïŒ1ã2ïŒ-1 + 2ã«çãããªããžã§ã¯ããååšããããšãæå³ããŸãã ããã¯çµ¶å¯Ÿã«ãPrologã§1 + 2 = 3ãæå³ããããã§ã¯ãããŸããã2ãæ³ãšããæ®åºã®ã°ã«ãŒãã®ããã«ããã®åŒã¯æ£ãããããŸããã3ã¯ãŸã£ããååšããŸããã ç¹°ãè¿ããŸãããæ°åŠçãªèŠ³ç¹ãããå€æ°ã¯For Everyoneãšããåèªã§æ¥ç¶ãããŠãããã¹ããŒãã¡ã³ããåèªã®ååšãå¿ èŠãšããå Žåã¯ããã®ç®çã§çšèªïŒãã¡ã³ã¯ã¿ãŒïŒã䜿çšãããŸãã ä»»æã®æ°ã«ã€ããŠãéä¹æ°ããããŸãã-éä¹ïŒXããã¡ã¯ãïŒXïŒïŒã
ããã°ã©ãã³ã°ã®èŠ³ç¹ããèŠããšãçšèªã¯ãã£ãšç°¡åã«èª¬æã§ããŸããçšèªã¯å±æ§ã®ã»ãããæã€ãªããžã§ã¯ãã§ãããå±æ§ã¯ä»ã®çšèªãŸãã¯å®æ°ãŸãã¯å€æ°ïŒã€ãŸããå®çŸ©ãããŠããªãïŒã§ãã äž»ãªéãã¯ãPrologã®ãã¹ãŠã®ãªããžã§ã¯ãã¯äžå€ã§ãããšããããšã§ããã€ãŸãããããã®å±æ§ãå€æŽããããšã¯ã§ããŸããããç¹å¥ãªç¶æ -å€æ°ããããŸãã
äŸ-æŽæ°æŒç®
(0). (()) :- (). (0, , ). ((1), 2, ()) :- (1, 2, ). (0, , 0). ((1), 2, 2) :- (1, 2, ), (, 2, 2).
(0). (()) :- (). (0, , ). ((1), 2, ()) :- (1, 2, ). (0, , 0). ((1), 2, 2) :- (1, 2, ), (, 2, 2).
- natïŒèªç¶æ°ïŒã®ããããã£ã®æ±ºå®ã 0ã¯èªç¶æ°ã§ããNumberãèªç¶ã®å Žåããªããžã§ã¯ãçªå·ïŒNumberïŒãããããããèªç¶ã§ãã æ°åŠçã«ã¯ããæ°å€ããšããçšèªã¯é¢æ°+1ãè¡šããŸããããã°ã©ãã³ã°ã®èŠ³ç¹ããããæ°å€ãã¯ååž°çãªããŒã¿æ§é ã§ãããã®èŠçŽ ã¯æ¬¡ã®ãšããã§ããæ°å€ïŒ0ïŒãæ°å€ïŒæ°å€ïŒ0ïŒïŒãæ°å€ïŒæ°å€ïŒæ°å€ïŒ0ïŒïŒïŒã
- æ¯çã®ãã©ã¹ã¯0 +æ°å€=æ°å€ã§ãã Ch1 + Ch2 = Resã®å ŽåãïŒCh1 + 1ïŒ+ Ch2 =ïŒRes + 1ïŒã
- æ¯çãä¹ç®ãããŸã-0 *æ°=0ãR1* R2 = Resããã³Res + R2 = Res2ã®å ŽåãïŒR1 + 1ïŒ* R2 = Res2ã
æããã«ããããã®ã¹ããŒãã¡ã³ãã¯éåžžã®ç®è¡æŒç®ã«åœãŠã¯ãŸããŸããããªãNumber + 0 = Numberãšåãæçœãªã¹ããŒãã¡ã³ããå«ããªãã£ãã®ã§ããã çãã¯ç°¡åã§ããåé·æ§ã¯ã©ã®å®çŸ©ã§ãéåžžã«æªãã§ãã ã¯ããããã¯èšç®ãäžçš®ã®ææå°æ©ãªæé©åã«åœ¹ç«ã¡ãŸãããå¯äœçšã¯å®çŸ©ã®ççŸãã¹ããŒãã¡ã³ãã®ææ§ãªçµè«ãã€ã³ã¿ãŒããªã¿ãŒã®ã«ãŒãã«ãªãå¯èœæ§ããããŸãã
Prologãè¿°èªãã©ã®ããã«ç解ããã©ã®ããã«ã¹ããŒãã¡ã³ãã蚌æããã
ãã¡ãããããã°ã©ã ãèªãããšã¯ãPrologã¹ã¿ã€ã«ãæããã®ã«åœ¹ç«ã¡ãŸããããããã®å®çŸ©ã䜿çšã§ããçç±ãšæ¹æ³ãæ確ã«ããŸããã ååãªãšã³ããªãã€ã³ãããªããããäžèšã®äŸã®ãããªæ¬æ Œçãªããã°ã©ã ãåŒã³åºãããšã¯ã§ããŸããã Prologãžã®ãšã³ããªãã€ã³ãã¯ãã¯ãšãªãSQLããŒã¿ããŒã¹ãžã®ã¯ãšãªã®é¡äŒŒç©ããŸãã¯é¢æ°åããã°ã©ãã³ã°ã®ã¡ã€ã³é¢æ°ã®åŒã³åºãã®é¡äŒŒç©ã§ãã ã¯ãšãªã®äŸïŒnatïŒæ°å€ïŒ-èªç¶æ°ã®æ€çŽ¢ããã©ã¹ïŒ0ã0ãçµæïŒ-å€æ°Resultã«0ãš0ãè¿œå ããçµæã®æ€çŽ¢ãnatïŒ0ïŒ-0ãèªç¶æ°ãã©ããã®ç¢ºèªãªã©
ãã¡ãããè«ççãªçç±ã§ã¯ãšãªçµæãäºæž¬ããããšã¯é£ãããããŸããããããã°ã©ã ããããåãåã£ãæ¹æ³ãç解ããããšã¯éåžžã«éèŠã§ãã ããã§ããPrologã¯ãã©ãã¯ããã¯ã¹ã§ã¯ãªãããã°ã©ãã³ã°èšèªã§ãããSQLãã©ã³ãæ§ç¯ãããã¯ãšãªãç°ãªãããŒã¿ããŒã¹ã§ç°ãªãæ¹æ³ã§å®è¡ã§ããããŒã¿ããŒã¹ãšã¯ç°ãªããPrologã«ã¯éåžžã«å ·äœçãªå®è¡é åºããããŸãã å®éãããŒã¿ããŒã¹ã§ã¯ãããŒãã«å ã®ããŒã¿ã«åºã¥ããŠã©ã®åçãååŸãããããããããã£ãŠããŸããæ®å¿µãªãããPrologããã°ã©ã ãèŠããšãã©ã®ã¹ããŒãã¡ã³ããè«ççã«æšè«ãããŠããããèšãã®ã¯é£ãããããPrologã€ã³ã¿ãŒããªã¿ãŒã®ä»çµã¿ãç解ããã®ã¯ã¯ããã«ç°¡åã§ãã
äŸã®ã¯ãšãªplusïŒ0ã0ãResultïŒãèããŠãã ããïŒ
1.ã«ãŒã«ã®å·Šéšåãšãã®ãªã¯ãšã¹ãã®äžèŽïŒãã¿ãŒã³ãããã³ã°ã®äžçš®ã解決ïŒãèŠã€ããŸãã ãã®ãªã¯ãšã¹ãã®å Žåããã©ã¹ïŒ0ãæ°å€ãæ°å€ïŒã ãã¹ãŠã®ãªã¯ãšã¹ãåŒæ°ãã«ãŒã«ãš1ã€ãã€é¢é£ä»ããŠååŸããŸãïŒ0 = 0ã0 =æ°å€ãçµæ=æ°å€ã ãããã®æ¹çšåŒã«ã¯2ã€ã®å€æ°ïŒæ°å€ãšçµæïŒãé¢ä¿ããŠããããããã解ããšãæ°å€=çµæ= 0ã«ãªããŸãããã®ã«ãŒã«ã«ã¯æ¡ä»¶ããªãããã質åã«å¯ŸããçããåŸãããŸããã åçïŒã¯ããçµæ= 0ã
ãªã¯ãšã¹ãnatïŒçªå·ïŒ ïŒ
1.ã«ãŒã«ãšã®æåã®äžèŽã§ããnatïŒ0ïŒã«ãŒã«ãèŠã€ãã察å¿é¢ä¿ã§æ¹çšåŒã解ããã€ãŸã解å床ãèŠã€ãããšãNumber = 0ãåŸãããŸããçãïŒyesããã³Number = 0ã
ãªã¯ãšã¹ããã©ã¹ïŒçµæã0ãæ°å€ïŒ0ïŒïŒ ïŒ
1.ã«ãŒã«ãã©ã¹ïŒ0ãæ°å€ãæ°å€ïŒã§è§£æ±ºçãèŠã€ããŸãïŒçµæ= 0ã0 =æ°å€ãæ°å€ïŒ0ïŒ=æ°å€ã§ãããïŒïŒïŒæ°å€= 0 =æ°å€ïŒ0ïŒ-0ã¯æ°å€ãšäžèŽããããäžå¯èœã§ãïŒ0ïŒã ãã®ããã次ã®ã«ãŒã«ã§è§£æ±ºçãæ¢ããŠããŸãã
2.ã«ãŒã«ãã©ã¹ïŒæ°å€ïŒR1ïŒãR2ãæ°å€ïŒResïŒïŒã§è§£æ±ºçãèŠã€ããæ°å€ïŒR1ïŒ=çµæãR2 = 0ãæ°å€ïŒResïŒ=æ°å€ïŒ0ïŒããããã£ãŠRes = 0ãååŸããŸããã«ãŒã«ã§ã¯ã解決ã®çµæïŒå€æ°ã®å€ïŒããã©ã¹ïŒP1ãP2ãResïŒ->ãã©ã¹ïŒP1ã0ã0ïŒãèæ ®ããŠããã§ãã¯ããå¿ èŠãããæ¡ä»¶ããããŸãã ã¹ã¿ãã¯äžã®å€æ°ã®å€ãèšæ¶ããæ°ãããªã¯ãšã¹ãã«ïŒplus1ã0ã0ïŒãå ãããã®ãäœæããŸã
3 *ã ãã©ã¹ïŒCh1ã0ã0ïŒãªã¯ãšã¹ãã解ããšããã©ã¹ïŒ0ãæ°å€ãæ°å€ïŒã§è§£æ±ºçãèŠã€ãããCh1 = 0ãšæ°å€= 0ãåŸãããŸãã
4.ã¹ã¿ãã¯äžã§åã®å€æ°ã«æ»ããŸãçµæ=æ°å€ïŒ1ïŒ=æ°å€ïŒ0ïŒã çãã¯èŠã€ãã£ãçªå·ïŒ0ïŒã§ãã ãããã£ãŠãããããŒã°ãã·ã³ã¯åŒX + 0 = 1ã解ããŸããã
Prologèšèªã§ã«ãŒã«ãé©åã«ã³ã³ãã€ã«ããããšã¯éåžžã«è€éã§ãããããããã³ã³ãã¯ãã«æ§æãããšãçŽæ¥çãªçããšè§£æ±ºçã ãã§ãªããéã®è§£æ±ºçãåŸãããŸãã
ãªã¯ãšã¹ãäŸïŒïŒNumberãNumberãNumberïŒïŒ ïŒyesãšçããNumber = 0ã
ãªã¯ãšã¹ãäŸplusïŒ0ã0ã0ïŒ ïŒå¿çãªããæåã®è©Šè¡ã§ã¯ããã¹ãŠã®è§£æ±ºã¯å®è¡ãããŸããã
ãªã¯ãšã¹ãäŸplusïŒNumberãNumberãNumberïŒNumberïŒïŒ ïŒyesãšçããNumber =1ãæ¹çšåŒX + X = X + 1ã解ã
ä¹ç®ïŒæ°å€ãæ°å€ïŒ0ïŒãæ°å€ïŒ0ïŒïŒã®åºåãæç»ããŠã¿ãŠãã ãããããã«ã¯ãå€æ°ãã¹ã¿ãã¯ã«2åããã·ã¥ããŠãæ°ããã¯ãšãªãèšç®ããå¿ èŠããããŸãã ãã·ã³ã®ããããŒã°ã®æ¬è³ªã¯ãæåã®çµæãæåŠã§ããããšã§ãããã®åŸãããããŒã°ã¯åã®ç¶æ ã«æ»ããèšç®ãç¶è¡ããŸãã ããšãã°ãã¯ãšãªnatïŒNumberïŒ ãæåã«1çªç®ã®ã«ãŒã«ãé©çšããŠ0ãäžãã次ã«2çªç®ã®ã«ãŒã«+ 1çªç®ã®ã«ãŒã«ãé©çšããŠæ°ïŒ0ïŒãäžãããšããã¹ãŠã®èªç¶æ°ã®ç¡éã·ãŒã±ã³ã¹ãç¹°ãè¿ãååŸã§ããŸãã å¥ã®äŸãã¯ãšãªplusïŒNumberãnumberïŒ0ïŒãNumber2ïŒã¯ãæ¹çšåŒX + 1 = Yã«å¯Ÿãããã¹ãŠã®è§£ã®ãã¢ã®ã·ãŒã±ã³ã¹ãçæããŸãã
ãããã«
æ®å¿µãªããããããã¯ã®åççãªãµã€ãºã§ã¯ãã¡ã€ã³ãããã¯ãã€ãŸããPrologèšèªã®è€éãªè«çåé¡ã解決ããããã®æŠç¥ããªããŠãããããã解決ããããšã¯ã§ããŸããã§ããã Prologã³ãŒãã®å€§ããªå¡ã¯ãåå¿è ã ãã§ãªããçµéšè±å¯ãªããã°ã©ããŒãããæããããããšãã§ããŸãã ãã®èšäºã®ç®çã¯ãPrologããã°ã©ã ãç°¡åãªæ¹æ³ã§èªç¶èšèªã§èªã¿åããããšãããã³åçŽãªã€ã³ã¿ãŒããªã¿ãŒã«ãã£ãŠå®è¡ãããããšã瀺ãããšã§ãã
Prologã®äž»ãªæ©èœã¯ããã©ãã¯ããã¯ã¹ãè€éãªè«çåé¡ã解決ããã©ã€ãã©ãªã§ã¯ãããŸããMathematicaã§ã¯ã代æ°æ¹çšåŒãå ¥åããŠè§£ãæ±ããããšãã§ããŸãããã¹ãããã®ã·ãŒã±ã³ã¹ã¯äžæã§ãã ããããŒã°ã¯ãäžè¬çãªè«ççãªåé¡ã解決ã§ããŸããïŒè«ççãªããŸãã¯ãããã³ãåŠå®ãã¯ãããŸããïŒãããã§ãªãå Žåããã®çµè«ã¯ç·åœ¢è§£å床ãšããŠé決å®çã§ãã ããããŒã°ã¯ãåçŽãªéèš³è ãšå®çã蚌æããããã®æ©æ¢°ãšã®éã®é»éã®å¹³åã§ãããä»»æã®æ¹åãžã®ã·ããã¯ç¹æ§ã®1ã€ã倱ãããšã«ã€ãªãããŸãã
次ã®èšäºã§ã¯ããœãŒãã£ã³ã°ã®åé¡ãã©ã®ããã«è§£æ±ºããããã茞è¡ã®æµãããã¹ã»ãããŒããã®ä»ã®ããç¥ãããŠããè«ççãªåé¡ã«ã€ããŠã話ããããšæããŸãã äžæºãæãã人ã®ããã«ãç§ã¯æ¬¡ã®åé¡ãæäŸããããšæããŸã ïŒèª°ãæåã«è³ã解決ããã ïŒïŒ
3ã§å§ãŸãèªç¶æ°ã®ç¡éã·ãŒã±ã³ã¹ãçæããè¿°èªãèšè¿°ããŸãããããã¯Prologã®æšæºæ°ã§ãããisè¿°èªã䜿çšããŠå®è¡ãããæäœã¯æ¬¡ã®ãšããã§ããXã¯3 + 1 => X = 4ã§ãã