[DeleteMe] °è¼Ó Ãß°¡ µË´Ï´Ù. --[ÀÛÀº³ª¹«] [[TableOfContents]] Âü°í¹®Çå * ''List in TeX's Mouth'', Alan Jeffrey * ''THE COMPUTER SCIENCE OF TeX AND LaTeX'', Victor Eijkhout == Logic == === Áø¸®°ª°ú ±× ¿¬»êÀÚµé === °£´ÜÇÏÁö¸¸ À¯¿ëÇÑ ¸ÅÅ©·ÎºÎÅÍ Á¤ÀÇÇÑ´Ù. {{{#!vim tex \def\Ignore#1{} \def\Identity#1{#1} \def\First#1#2{#1} \def\Second#1#2{#2} }}} »ç¿ë·Ê {{{ Taking first argument: input : \First {first}{second} output : first Taking second argument: input : \Second {first}{second} output : second }}} Áø¸®°ªÀ» Á¤ÀÇÇÑ´Ù. {{{#!vim tex \let\True=\First \let\False=\Second }}} À§ÀÇ Á¤ÀÇ´ë·Î¶ó¸é, Âü(\True)Àº µÎ°³ÀÇ ÀÎÀÚÁß Ã¹¹ø° ÀÎÀÚÀÇ °ªÀÌ°í, °ÅÁþ(\False)Àº µÎ¹ø° ÀÎÀÚÀÇ °ªÀÌ´Ù. ÀÌ°ÍÀÌ Àǹ̰¡ ÀÖÀ¸·Á¸é, ±× µÎ°³ÀÇ ÀÎÀÚ´Â T¿Í F À̾î¾ß ÇÑ´Ù. Áï \True¿Í \False°¡ ¶æÇÏ´Â Àǹ̴ ´ÙÀ½°ú °°´Ù. {{{#!vim tex input : \True TF output: T input : \False TF output: F }}} µû¶ó¼­ ¾ÕÀ¸·Î ³ª¿À´Â ¸ðµç ³í¸®¹® ´ÙÀ½¿¡´Â ¾ðÁ¦³ª µÎ°³ÀÇ ÀÎÀÚ TF°¡ ÀÖ´Â °ÍÀ¸·Î °£ÁÖÇÑ´Ù. ³í¸® ¿¬»êÀÚµéÀ» Á¤ÀÇÇÑ´Ù. {{{#!vim tex \def\And#1#2{#1{#2}\False} \def\Or#1#2{#1\True{#2}} \def\Twiddle#1#2#3{#1{#3}{#2}} \let\Not=\Twiddle }}} ¼³¸í: \And x y ÀÇ °ªÀº x°¡ ÂüÀ̸é, yÀÇ °ªÀÌ°í, x°¡ °ÅÁþÀ̸é, y °ª¿¡ °ü°è¾øÀÌ °ÅÁþÀÌ´Ù. Áï ÂüÀº ù¹ø° ÀÎÀÚ¸¦ °ÅÁþÀ» µÎ¹ø° ÀÎÀÚ¸¦ ÃëÇÑ´Ù´Â °Í¿¡ Âø¾ÈÇϸé \AndÀÇ Á¤ÀÇ´Â À§¿Í °°Àº °ÍÀÌ°í, \Orµµ ¸¶Âù°¡ÁöÀÌ´Ù. Áø¸®°ªµé°ú ¿¬»êÀÚµéÀ» Å×½ºÆ® Çغ¸ÀÚ. {{{ True takes first of TF: input : \True TF output : T False takes second of TF: input : \False TF output : F Not true is false: input : \Not \True TF output : F And truth table TrueTrue: input : \And \True \True TF output : T And truth table TrueFalse: input : \And \True \False TF output : F And truth table FalseTrue: input : \And \False \True TF output : F And truth table FalseFalse: input : \And \False \False TF output : F Or truth table TrueTrue: input : \Or \True \True TF output : T Or truth table TrueFalse: input : \Or \True \False TF output : T Or truth table FalseTrue: input : \Or \False \True TF output : T Or truth table FalseFalse: input : \Or \False \False TF output : F }}} '''¿¹''') * \And \True \False TF, \ANDÀÇ Á¤ÀÇ´ë·Î Àü°³Çϸé, {{{ \And \True \False TF ==> \True{\False}\False TF ==> \False TF ==> F }}} * \Not \True TF, \NOTÀÇ Á¤ÀÇ´ë·Î Àü°³Çϸé, {{{ \Not \True TF ==> \True{F}{T} ==> F }}} === Á¶°Ç¹® === ±âº» ¸ÅÅ©·ÎµéÀ» Á¤ÀÇÇÑ´Ù. {{{#!vim tex \def\gobblefalse\else\gobbletrue\fi#1#2{\fi#1} \def\gobbletrue\fi#1#2{\fi#2} \def\TeXIf#1#2{#1#2 \gobblefalse\else\gobbletrue\fi} }}} »ç¿ë ¹®¹ý {{{#!vim tex \TeXIf }}} Å×½ºÆ® ÇÑ´Ù: {{{ \def\IfIsPositive{\TeXIf{\ifnum0<}} Numerical test: input : \IfIsPositive {3} TF output : T Numerical test: input : \IfIsPositive {-2} TF output : F }}} '''¼³¸í''') * \IfIsPositive { 3 } TF¸¦ Á¤ÀÇ´ë·Î Àü°³Çϸé, {{{ \IfIsPositive {3} TF ==> \TeXIf{\ifnum0<}{3}TF ==> \ifnum0<3\gobblefalse\else\gobbletrue\fi TF ==> \ifnum0<3\fi T ==> T }}} == ¸®½ºÆ® == ¸®½ºÆ®´Â ¸Ó¸®(head)¿Í ²¿¸®(tail)·Î Á¤ÀÇ µÇ´Âµ¥, ¸Ó¸®´Â ÇÑ ±¸¼º¿ä¼Ò(element) ÀÌ°í, ²¿¸®´Â ¶Ç´Ù¸¥ ¸®½ºÆ®ÀÌ´Ù. Áï ¸®½ºÆ®´Â ±× Á¤ÀÇ°¡ Àç±ÍÀûÀÌ´Ù. ºó ¸®½ºÆ®(empty list)¸¦ Nil·Î Ç¥±âÇÑ´Ù. {{{#!vim tex \let\Nil=\False }}} À§ÀÇ ¸®½ºÆ®ÀÇ Á¤ÀǸ¦ µÎ°³ÀÇ ÀÎÀÚ¸¦ °¡Áø ¿¬»êÀÚ·Î ±¸ÇöÇÑ´Ù: * ¸¸¾à ¸®½ºÆ®°¡ ºñ¾îÀÖÁö ¾Ê´Ù¸é, ù¹ø° ÀÎÀÚ´Â ¸Ó¸®¿¡ Àû¿ëµÇ°í, ²¿¸®°¡ ±× ¸®½ºÆ®ÀÇ °ªÀÌ µÈ´Ù. * ¸¸¾à ¸®½ºÆ®°¡ ºñ¾îÀÖ´Ù¸é, µÎ¹ø° ÀÎÀÚ°¡ ¸®½ºÆ®ÀÌ °ªÀÌ µÈ´Ù. {{{#!latex \[ La_1a_2 = \left\{ \begin{array}{ll} a_2 & \mbox{if $L=()$} \\ a_1(x)Y & \mbox{if $L=(x,Y)$} \end{array} \right. \] }}} ---- DeleteMe. ÆäÀÌÁö À̸§À» ¹Ù²Ù¾ú½À´Ï´Ù.