{"id":3948,"date":"2021-02-28T16:32:18","date_gmt":"2021-02-28T16:32:18","guid":{"rendered":"https:\/\/danielschlegel.org\/wp\/?page_id=3948"},"modified":"2021-02-28T16:32:20","modified_gmt":"2021-02-28T16:32:20","slug":"assignment-2","status":"publish","type":"page","link":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/","title":{"rendered":"Assignment 2"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Microproject<\/h2>\n\n\n\n<p>Examine the below main project. Write one or more Clojure functions which perform symbolic simplification on (un-nested) expressions using the <tt>and<\/tt> logical connective. Be sure to generalize to all possible variables and valid numbers of arguments to <code>and<\/code>. For example:\u00a0<\/p>\n\n\n\n<pre>mp=> (and-simplify '(and true))\ntrue\nmp=> (and-simplify '(and x true))\nx\nmp=> (and-simplify '(and true false x))\nfalse\nmp=> (and-simplify '(and x y z true))\n(and x y z)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Main Project<\/h2>\n\n\n\n<p>Write a set of Clojure functions that perform symbolic simplification and evaluation of boolean expressions using <tt>and<\/tt>, <tt>or<\/tt>, and <tt>not<\/tt>. <tt>not<\/tt> will be assumed to take one argument, while <tt>and<\/tt> and <tt>or<\/tt> will take one or more. You should use <tt>false<\/tt> for False and <tt>true<\/tt> for True.<\/p>\n\n\n\n<p>Expressions are created as unevaluated lists. Three sample expressions could be defined as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> (def p1 '(and x (or x (and y (not z)))))\n (def p2 '(and (and z false) (or x true)))\n (def p3 '(or true a))<\/pre>\n\n\n\n<p>You could also define functions to build unevaluated lists for for you, such as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> (defn andexp [e1 e2] (list 'and e1 e2))\n (defn orexp  [e1 e2] (list 'or e1 e2))\n (defn notexp [e1] (list 'not e1))<\/pre>\n\n\n\n<p>Using these, <tt>p3<\/tt> could have been created using<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(def p3 (orexp true 'a))<\/pre>\n\n\n\n<p>If you wish to use these in your project, you will need to modify <tt>andexp<\/tt> and <tt>orexp<\/tt> to allow for one or more arguments.<\/p>\n\n\n\n<p>The main function to write, <tt>evalexp<\/tt>, entails calling functions that simplify, bind, and evaluate these expressions.<\/p>\n\n\n\n<p>Simplification consists of replacing particular forms with equivalent functions, including the following:<\/p>\n\n\n\n<pre>\n;; Length 1 Pattern Examples\n(or true) => true\n(or false) => false\n(or x) => x\n(and true) => true\n(and false) => false\n(and x) => x\n(not false) => true\n(not true) => false\n(not (and x y)) => (or (not x) (not y))\n(not (or x y)) => (and (not x) (not y))\n(not (not x)) => x\n;; Length 2 Pattern Examples\n(or x false) => x\n(or false x) => x\n(or true x) => true\n(or x true) => true\n(and x false) => false\n(and false x) => false\n(and x true) => x\n(and true x) => x\n;; Length 3 Pattern Examples\n(or x y true) => true\n(or x false y) => (or x y)\n(and false x y) => false\n(and x true y) => (and x y)\n[... and so on ...]\n<\/pre>\n\n\n\n<p>You should generalize for any length expression based on these patterns. Your program must work for any arbitrary variables used. As in the microproject, you may wish to write functions to handle certain kinds of cases, and handle the non-recursive case before you handle the recursive one.<\/p>\n\n\n\n<p>Binding consists of replacing some or all of the variables in expressions with provided constants (<tt>true<\/tt> or <tt>false<\/tt>), and then returning the partially evaluated form.<\/p>\n\n\n\n<p>The <code>evalexp <\/code>function should take a symbolic expression and a binding map and return the simplest form (that might just be a constant). One way to define this is<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  (defn evalexp [exp bindings] (simplify (bind-values bindings exp)))<\/pre>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(evalexp p1 '{x false, z true})<\/pre>\n\n\n\n<p>binds <code>x<\/code> and <code>z<\/code> (but not <code>y<\/code>) in <code>p1<\/code>, leading to <tt>(and false (or false (and y (not true))))<\/tt> and then further simplifies to just <code>false<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"lead\">Microproject Examine the below main project. Write one or more Clojure functions which perform symbolic simplification on (un-nested) expressions using the and logical connective. Be sure to generalize to all possible variables and valid numbers of arguments to and. For example:\u00a0 mp=> (and-simplify &#8216;(and true)) true mp=> (and-simplify &#8216;(and x true)) x mp=> (and-simplify &#8216;(and true false x)) false mp=>&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-warning\" href=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3862,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"class_list":["post-3948","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Assignment 2 - Daniel R. Schlegel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Assignment 2 - Daniel R. Schlegel\" \/>\n<meta property=\"og:description\" content=\"Microproject Examine the below main project. Write one or more Clojure functions which perform symbolic simplification on (un-nested) expressions using the and logical connective. Be sure to generalize to all possible variables and valid numbers of arguments to and. For example:\u00a0 mp=&gt; (and-simplify &#039;(and true)) true mp=&gt; (and-simplify &#039;(and x true)) x mp=&gt; (and-simplify &#039;(and true false x)) false mp=&gt;&hellip;Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Daniel R. Schlegel\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-28T16:32:20+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/assignment-2\\\/\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/assignment-2\\\/\",\"name\":\"Assignment 2 - Daniel R. Schlegel\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/#website\"},\"datePublished\":\"2021-02-28T16:32:18+00:00\",\"dateModified\":\"2021-02-28T16:32:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/assignment-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/assignment-2\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/assignment-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Teaching\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSC344 &#8211; Spring 2021\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc344-spring-2021\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Assignment 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/\",\"name\":\"Daniel R. Schlegel\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Assignment 2 - Daniel R. Schlegel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/","og_locale":"en_US","og_type":"article","og_title":"Assignment 2 - Daniel R. Schlegel","og_description":"Microproject Examine the below main project. Write one or more Clojure functions which perform symbolic simplification on (un-nested) expressions using the and logical connective. Be sure to generalize to all possible variables and valid numbers of arguments to and. For example:\u00a0 mp=> (and-simplify '(and true)) true mp=> (and-simplify '(and x true)) x mp=> (and-simplify '(and true false x)) false mp=>&hellip;Read more","og_url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/","og_site_name":"Daniel R. Schlegel","article_modified_time":"2021-02-28T16:32:20+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/","url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/","name":"Assignment 2 - Daniel R. Schlegel","isPartOf":{"@id":"https:\/\/danielschlegel.org\/wp\/#website"},"datePublished":"2021-02-28T16:32:18+00:00","dateModified":"2021-02-28T16:32:20+00:00","breadcrumb":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/assignment-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/danielschlegel.org\/wp\/"},{"@type":"ListItem","position":2,"name":"Teaching","item":"https:\/\/danielschlegel.org\/wp\/teaching\/"},{"@type":"ListItem","position":3,"name":"CSC344 &#8211; Spring 2021","item":"https:\/\/danielschlegel.org\/wp\/teaching\/csc344-spring-2021\/"},{"@type":"ListItem","position":4,"name":"Assignment 2"}]},{"@type":"WebSite","@id":"https:\/\/danielschlegel.org\/wp\/#website","url":"https:\/\/danielschlegel.org\/wp\/","name":"Daniel R. Schlegel","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/danielschlegel.org\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P83Tb6-11G","_links":{"self":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/3948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/comments?post=3948"}],"version-history":[{"count":6,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/3948\/revisions"}],"predecessor-version":[{"id":3954,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/3948\/revisions\/3954"}],"up":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/3862"}],"wp:attachment":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/media?parent=3948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}