[Solved] Lang Racket Relational Reverse Function Minikanren Goal Project Write Relational Reverseo Q37200630
#lang racket
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; A relational reverse function in miniKanren
;
; The goal of this project is to write a relational reverseofunction that can be run
; forwards *or* backwards to produce a reversed list, or that canbe used to find many
; palindrome lists by asking for lists that reverse tothemselves!
; E.g., (run 7 (lst) (reverseo lst lst))
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide reverseo)
(require “mk.rkt”)
;; Example: an appendo function for relational list append
;; (You might even try making use of appendo to define reverseo!)
(define (appendo lst0 lst1 full)
(conde ; conde is disjunction: either case in square brackets mustbe true
; Base case:
[(== lst0 ‘())
; this case says: lst0 is unified (matched) with ‘(),
; and full is unified with lst1
(== full lst1)]
; Recursive case:
[(fresh (first rest tail)
; we introduce three new fresh (initially unconstrainedvariables)
; this case says: lst0 deomposes into (cons firstrest),
(== lst0 (cons first rest))
; full decomposes into (const first tail)
(== full (cons first tail))
; and rest appended to lst1 matches tail
(appendo rest lst1 tail))]))
; Your job is to write a similar (relational) reverseofunction
(define (reverseo lst0 lst1)
(conde
; TODO: what cases are involved? What must be true in eachcase?
))
Expert Answer
Answer to #lang racket ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; A relational reverse function in miniKanren ; ; The goal o… . . .
OR

