sky.hoon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /- *sock
  2. /+ ska
  3. |%
  4. :: mask axes in a noun to make a sock
  5. ++ dope
  6. |= [mask=(list @) non=noun]
  7. ^- boot
  8. =/ sack=boot [%safe %know non]
  9. |-
  10. ^- boot
  11. ?~ mask sack
  12. $(sack (welt:ska i.mask [%safe %toss ~] sack), mask t.mask)
  13. :: turn a hoon type into a boot
  14. ++ wove
  15. |= kine=type
  16. ^- boot
  17. =| gil=(set type)
  18. ?@ kine
  19. ?- kine
  20. %noun [%risk %toss ~]
  21. %void [%boom ~]
  22. ==
  23. ?- -.kine
  24. %atom
  25. ?~ q.kine
  26. [%risk %dice ~]
  27. [%risk %know u.q.kine]
  28. ::
  29. %cell
  30. (cobb:ska $(kine p.kine) $(kine q.kine))
  31. ::
  32. %core
  33. %+ cobb:ska
  34. (spry p.r.q.kine) :: compiled battery
  35. $(kine p.kine) :: current payload
  36. ::
  37. %face
  38. $(kine q.kine)
  39. ::
  40. %fork
  41. =/ tins ~(tap in p.kine)
  42. ?~ tins [%boom ~]
  43. =/ hypo $(kine i.tins)
  44. =/ tons t.tins
  45. |-
  46. ^- boot
  47. ?~ tons hypo
  48. $(hypo (gnaw:ska ^$(kine i.tons) hypo), tons t.tons)
  49. ::
  50. %hint
  51. $(kine q.kine)
  52. ::
  53. %hold
  54. ?: (~(has in gil) kine)
  55. [%risk %toss ~]
  56. $(gil (~(put in gil) kine), kine ~(repo ut kine))
  57. ==
  58. :: turn a seminoun into a sock
  59. ++ spry
  60. |= seminoun
  61. ^- boot
  62. ?- -.mask
  63. %half
  64. ?> ?=(^ data)
  65. (cobb:ska $(mask left.mask, data -.data) $(mask rite.mask, data +.data))
  66. ::
  67. %full
  68. ?~ blocks.mask
  69. [%risk %know data]
  70. [%risk %toss ~]
  71. ::
  72. %lazy
  73. [%risk %toss ~]
  74. ==
  75. :: for a stateful core, figure out what we can assume across all state
  76. :: transitions
  77. ::
  78. :: step is a list of arm axes and result axes which are expected to produce gates
  79. :: the gates will be simul-slammed with %toss
  80. :: then the result axis will be intersected with the stateful core
  81. :: knowledge
  82. ::
  83. :: fixed point termination argument: we can only know the same or less
  84. :: than what we knew last time (intersection cannot add knowledge)
  85. :: if we know the same, we stop now. We can only subtract finitely many
  86. :: axes of knowledge from the tree before we know [%boom ~] or
  87. :: [%risk %toss ~] at which point we will learn the same thing twice
  88. :: and terminate
  89. ++ arid
  90. |= [muck=boot step=(list [@ @])]
  91. ^- boot
  92. =/ yuck muck
  93. =/ stop step
  94. ?: ?=(%boom -.muck)
  95. [%boom ~]
  96. |-
  97. ^- boot
  98. ?~ stop
  99. ?: =(yuck muck)
  100. yuck
  101. ^$(muck yuck)
  102. =/ erm (yank:ska -.i.stop muck)
  103. ?: ?=(%boom -.erm)
  104. $(stop t.stop, yuck (gnaw:ska [%boom ~] yuck))
  105. =/ arm (trip:ska erm)
  106. ?~ arm
  107. $(stop t.stop, yuck (gnaw:ska [%risk %toss ~] yuck))
  108. =/ cor
  109. ?- -.muck
  110. %safe sure.muck
  111. %risk hope.muck
  112. ==
  113. =/ mat (wash:ska cor u.arm)
  114. ?: ?=(%boom -.mat)
  115. $(stop t.stop, yuck (gnaw:ska [%boom ~] yuck))
  116. =/ ear (yank:ska 2 mat)
  117. ?: ?=(%boom -.ear)
  118. $(stop t.stop, yuck (gnaw:ska [%boom ~] yuck))
  119. =/ gar (trip:ska ear)
  120. ?~ gar
  121. $(stop t.stop, yuck (gnaw:ska [%risk %toss ~] yuck))
  122. =/ mar (welt:ska 6 [%risk %toss ~] mat)
  123. ?: ?=(%boom -.mar)
  124. $(stop t.stop, yuck (gnaw:ska [%boom ~] yuck))
  125. =/ gor
  126. ?- -.mar
  127. %safe sure.mar
  128. %risk hope.mar
  129. ==
  130. =/ beg (wash:ska gor u.gar)
  131. $(stop t.stop, yuck (gnaw:ska (yank:ska +.i.stop beg) yuck))
  132. --