Although tactics are usually employed in theorem proving, 
they encode a more general notion of goal-directed programming. 
This directory contains a simple example: differentiating 
expressions using tactics. 

	Expressions
	------------

Expressions are generated by the grammar 

	<exp> ::= <exp> + <exp> 
     		| <exp> - <exp> 
     		| <exp> * <exp> 
     		| <exp> / <exp> 
     		| ~<exp> 
     		| <exp> ^ <exp> 
     		| e <exp> 
     		| sin <exp> 
     		| cos <exp> 
     		| ( <exp> )
     		| <term>(<term>)

	<term> ::= <variable> | <number> 

	
	Differentiation rules
	-----------------------

Rules for derivatives (w.r.t variable "x"). 

Constant : c' = 0 
                    
variable : x' = 1 

exponent: (x^a)' = a*x^(a-1)

Sine : (sin(x))' = -cos(x) 

Cosine : (cos(x))' = sin(x) 

Addition : (f + g)' = f' + g' 

Subtraction : (f - g)' = f' - g' 

Product : (f * g)' = f * g' + g * f' 

Division : (f/g)' = (g * f' - f * g')/g^2      

Chain : (f(g(x))' = f'(g(x)) * g'(x)

e : (e^f)' = f'*e^f


	Using tactics to differentiate expressions
	-------------------------------------------
Both goals and events are expressions. Expression g achieves f 
if g is the derivative of f, that is if g = f'
For example 

	x^7 * cos sin x

is achieved by 

	((7*(x^6))*(cos(sinx)))+(((sin(~(cosx)\n))*(~(cosx)))*(x^7)). 

We can use the differentiation rules above to define tactics. 
A tactic T will be defined here by a scheme 

	f		[f'] 
	by T 
          f1		[f1']
          . 
	  . 
	  fn		[fn']

where f1',...fn' are are variables representing expressions that 
achieve the subgoals f1,...fn.

sinTac. 
	sin(x) 		[-cos(x)] 
        by sinTac

cosTac. 
	cos(x) 		[sin(x)] 
        by cosTac

constantTac. 
	c		[0]
	by constantTac

expTac.
	x^a		[a*x^(a-1)] 
	by expTac
	  
addTac. 
	f + g	        [f' + g']
	by addTac
	  f		[f'] 
	  g             [g']

productTac. 
	f * g	        [f * g' + g * f']
	by addTac
	  f		[f'] 
	  g             [g']

chainTac. 
	f(g(x))		[f'(g(x)) * g'(x)] 
	by chainTac
	  f		[f']
	  g		[g']

eTac. 
	e^f		[f'*e^f]
	by eTac
	  f		[f']

 
The example above was extracted from this tactic tree: 

|(x^7)*(cos(sinx))
|
|by productTac
||x^7
||
||by expTac
||cos(sinx)
||
||by chainTac
|||cosx
|||
|||by cosTac
|||sinx
|||
|||by sinTac
