Programming Assignment 1 (CLIPS)

DUE: Feb 4 by midnight


You are to complete as many of the following as you can. You have 10 days from the date of assignment. This is individual work BUT you may discuss it in general terms (NOT lines of code)

E-mail your answers to me (drkriggs ...) by the due date.

POSTING: I will post all submitted code solutions by the 5th (no late work allowed!)

CRITIQUE: You will then have six days (Midnight 11th)  to look for errors / shortcomings in the code of others (for extra credit for each significant error reported by e-mail!)


  1. Report (a version of "control break processing")
    Given facts of the sort:      
    	STORE FACT ::= '(' 'store' NAME ( ('sale' AMOUNT) | ('expense' AMOUNT) ) + ')'
                                where
    	AMOUNT ::= number
                    NAME ::= identifier
    Calculate and printout:
    1. The profit for each store  (å sales -å expenses) 
    2. The profit for all stores

  2. Matrix Addition
    Given facts of the sort:
          	MATELE ::= '(' 'ele' MAT ROW COL VAL ')'
                   	  where
                 	MAT ::= 'A' | 'B' | 'C'            // "A[r][c] . ($B[r][c]  Ù $C[r][c] .C[r][c] = A[r][c]+B[r][c])
    	ROW ::= integer
                   	COL ::= integer
                   	VAL ::= number
    Find and Printout the array C in the normal rectangular display:

  3. Parsing  ( a form of sentential logic called "postfix")
    Given facts of the sort 		"(value $?anything)"  
     
    Determine if the 'anything' is valid by the following grammar:      
                                                 
    	PROP ::= ATOM |   PROP NOT | PROP PROP BINOP
                   	ATOM ::= 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
                   	NOT ::= 'not'
                    BINOP ::= 'and' | 'or' | 'if' | 'iff'
    Printout t "valid" or "in-valid" as the case may be

  4. Path Cost ('distance' in a directed graph (i.e. a digraph))
Given facts of the sorts:
      	START ::= '(' 'start' NAME)
	GOAL ::= '(' 'end' NAME ')'			
	NODE ::= '(' 'node' NAME ')'		// 1 per graph node
          	EDGE ::= '(' 'edge' SRC TRGT COST ')'	// edge 'goes' SRC to TRGT at COST
                 	where 
	SRC, TRGT ::= NAME			 
               	NAME  ::= symbol
               	COST ::= number
If there is a path from start to end 												
     then print "path " <start> " to " <end> " costs " <cost>  
     else print "no path" <start> " to " <end>