timothy235

sicp-4-4-1-deductive-information-retrieval

Mar 25th, 2017 (edited)
4,966
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 3.68 KB | None | 0 0
  1. #lang racket
  2.  
  3. ;; You cannot run this file.  These are not Racket expressions.
  4.  
  5. ;;;;;;;;;;
  6. ;; 4.55 ;;
  7. ;;;;;;;;;;
  8.  
  9. ;; a. all people supervised by ben bitdiddle
  10. (supervisor ?person (Bitdiddle Ben))
  11.  
  12. ;; b. the names and jobs of all people in accounting
  13. (job ?person (accounting . ?job))
  14.  
  15. ;; c. the names and adresses of all people who live in slumerville
  16. (address ?person (Slumerville . ?address))
  17.  
  18. ;;;;;;;;;;
  19. ;; 4.56 ;;
  20. ;;;;;;;;;;
  21.  
  22. ;; a. the names of all people supervised by ben bitdiddle with addresses
  23. (and (supervisor ?person (Bitdiddle Ben))
  24.      (address ?person ?address))
  25.  
  26. ;; b. all people with salary < ben's salary plus their salary plus ben's salary
  27. (and (salary ?person ?amount)
  28.      (salary (Bitdiddle Ben) ?ben-salary)
  29.      (lisp-value < ?amount ?ben-salary))
  30.  
  31. ;; c. all people supervised by person not in computer plus supervisor's name and job
  32. (and (supervisor ?person1 ?person2)
  33.      (not (job ?person2 (computer . ?type)))
  34.      (job ?person2 ?job))
  35.  
  36. ;;;;;;;;;;
  37. ;; 4.57 ;;
  38. ;;;;;;;;;;
  39.  
  40. (rule (can-replace ?person1 ?person2)
  41.       (and (job ?person1 ?job1)
  42.            (job ?person2 ?job2)
  43.            (or (same ?job1 ?job2)
  44.                (can-do-job ?job1 ?job2))
  45.            (not (same ?person1 ?person2))))
  46.  
  47. (can-replace ?person (Fect Cy D))
  48.  
  49. (and (salary ?person1 ?amount1)
  50.      (salary ?person2 ?amount2)
  51.      (can-replace ?person1 ?person2)
  52.      (lisp-value < ?amount1 ?amount2))
  53.  
  54. ;;;;;;;;;;
  55. ;; 4.58 ;;
  56. ;;;;;;;;;;
  57.  
  58. (rule (has-supervisor-in-department ?person ?department)
  59.       (and (job ?person (?department . ?type))
  60.            (job ?person2 (?department . ?type2))
  61.            (supervisor ?person ?person2)))
  62.  
  63. (rule (big-shot ?person ?department)
  64.       (and (job ?person (?department . ?type))
  65.            (not (has-supervisor-in-department ?person ?department))))
  66.  
  67. ;;;;;;;;;;
  68. ;; 4.59 ;;
  69. ;;;;;;;;;;
  70.  
  71. (meeting ?who (Friday . ?when))
  72.  
  73. (rule (meeting-time ?person ?day-and-time)
  74.       (and (job ?person (?department . ?type))
  75.            (meeting ?who ?day-and-time2)
  76.            (or (same ?who ?department)
  77.                (same ?who whole-company))))
  78.  
  79. (meeting-time (Hacker Alyssa P) (Wednesday . ?time))
  80.  
  81. ;;;;;;;;;;
  82. ;; 4.60 ;;
  83. ;;;;;;;;;;
  84.  
  85. ;; Impose a total ordering on people and accept only ordered pairs.
  86.  
  87. (define (comes-before? name1 name2) ; names are lists of symbols
  88.   (define last-name1 (symbol->string (first name1)))
  89.   (define first-name1 (symbol->string (second name1)))
  90.   (define last-name2 (symbol->string (first name2)))
  91.   (define first-name2 (symbol->string (second name2)))
  92.   (or (string<? last-name1 last-name2)
  93.       (and (string=? last-name1 last-name2)
  94.            (string<? first-name1 first-name2))))
  95.  
  96. (rule (lives-near2 ?person1 ?person2)
  97.       (and (lives-near ?person1 ?person2)
  98.            (lisp-value comes-before? ?person1 ?person2)))
  99.  
  100. ;;;;;;;;;;
  101. ;; 4.61 ;;
  102. ;;;;;;;;;;
  103.  
  104. ;; (?x next-to ?y in (1 (2 3) 4))
  105. (1 next-to (2 3) in (1 (2 3) 4))
  106. ((2 3) next-to 4 in (1 (2 3) 4))
  107.  
  108. ;; (?x next-to 1 in (2 1 3 1))
  109. (2 next-to 1 in (2 1 3 1))
  110. (3 next-to 1 in (2 1 3 1))
  111.  
  112. ;;;;;;;;;;
  113. ;; 4.62 ;;
  114. ;;;;;;;;;;
  115.  
  116. ;; my-last-pair is specified by two properties:
  117. ;; 1. a single element list is its own last pair
  118. ;; 2. the last pair of a list is the last pair of its non-empty cdr
  119.  
  120. (rule (my-last-pair (?x) (?x)))
  121. (rule (my-last-pair (?y . ?x))
  122.       (and (my-last-pair ?x)
  123.            (not (same ?x '()))))
  124.  
  125. ;;;;;;;;;;
  126. ;; 4.63 ;;
  127. ;;;;;;;;;;
  128.  
  129. (rule (grandson ?grandfather ?grandson)
  130.       (and (son ?father ?grandson)
  131.            (son ?grandfather ?father)))
  132.  
  133. (rule (father ?son ?father)
  134.       (and (wife ?father ?wife)
  135.            (son ?wife ?son)))
  136.  
  137. (grandson Cain ?x)
  138.  
  139. (father ?x Lamech)
  140.  
  141. (grandson Methushael ?x)
Advertisement
Comments
  • Larwavyn
    49 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • Nexgamor
    42 days
    # CSS 0.06 KB | 0 0
    1. We just shared HQ data on our channel: https://t.me/theprotocolone
Add Comment
Please, Sign In to add comment