#lang racket ;; You cannot run this file. These are not Racket expressions. ;;;;;;;;;; ;; 4.55 ;; ;;;;;;;;;; ;; a. all people supervised by ben bitdiddle (supervisor ?person (Bitdiddle Ben)) ;; b. the names and jobs of all people in accounting (job ?person (accounting . ?job)) ;; c. the names and adresses of all people who live in slumerville (address ?person (Slumerville . ?address)) ;;;;;;;;;; ;; 4.56 ;; ;;;;;;;;;; ;; a. the names of all people supervised by ben bitdiddle with addresses (and (supervisor ?person (Bitdiddle Ben)) (address ?person ?address)) ;; b. all people with salary < ben's salary plus their salary plus ben's salary (and (salary ?person ?amount) (salary (Bitdiddle Ben) ?ben-salary) (lisp-value < ?amount ?ben-salary)) ;; c. all people supervised by person not in computer plus supervisor's name and job (and (supervisor ?person1 ?person2) (not (job ?person2 (computer . ?type))) (job ?person2 ?job)) ;;;;;;;;;; ;; 4.57 ;; ;;;;;;;;;; (rule (can-replace ?person1 ?person2) (and (job ?person1 ?job1) (job ?person2 ?job2) (or (same ?job1 ?job2) (can-do-job ?job1 ?job2)) (not (same ?person1 ?person2)))) (can-replace ?person (Fect Cy D)) (and (salary ?person1 ?amount1) (salary ?person2 ?amount2) (can-replace ?person1 ?person2) (lisp-value < ?amount1 ?amount2)) ;;;;;;;;;; ;; 4.58 ;; ;;;;;;;;;; (rule (has-supervisor-in-department ?person ?department) (and (job ?person (?department . ?type)) (job ?person2 (?department . ?type2)) (supervisor ?person ?person2))) (rule (big-shot ?person ?department) (and (job ?person (?department . ?type)) (not (has-supervisor-in-department ?person ?department)))) ;;;;;;;;;; ;; 4.59 ;; ;;;;;;;;;; (meeting ?who (Friday . ?when)) (rule (meeting-time ?person ?day-and-time) (and (job ?person (?department . ?type)) (meeting ?who ?day-and-time2) (or (same ?who ?department) (same ?who whole-company)))) (meeting-time (Hacker Alyssa P) (Wednesday . ?time)) ;;;;;;;;;; ;; 4.60 ;; ;;;;;;;;;; ;; Impose a total ordering on people and accept only ordered pairs. (define (comes-before? name1 name2) ; names are lists of symbols (define last-name1 (symbol->string (first name1))) (define first-name1 (symbol->string (second name1))) (define last-name2 (symbol->string (first name2))) (define first-name2 (symbol->string (second name2))) (or (string