CS 541 Lecture -*- Outline -*- * Formal Model of Equational Reasoning ** equations ------------------------------------------ EQUATIONS 5 = 4 + 1 x = tl(x:xs) FORMAL MODEL a triple, all X . P = Q where X a set of vars, P and Q terms with free vars from X interpret as all X . P(X) = Q(X) def: a term with free variables from Y, written T_{OP}(Y), is given by the grammar: t ::= y | f(t1,...,tn) where y \in Y, n >= 0, t1,...,tn \in T_{OP}(Y) OP is a set of given operator symbols. ------------------------------------------ universally quantified formla of the form P(X) = Q(X) where P(X) and Q(X) are terms over X (T_{OP}(X)) formed from some operations and the vars X valid if holds in all environments (for all X) ** equational rule |- e1, ..., |- en [x] ----------------- |- e means if e1 and ... and en are valid, then so is e ** equational calculus ------------------------------------------ EQUATIONAL CALCULUS [refl] |- all X . t1 = t1 |- all X . t1 = t2 [sym] ------------------ |- all X . t2 = t1 |- all X . t1= t2, |- all X . t2=t3 [trans]----------------------------------- |- all X . t1 = t3 |- all X . t1 = t2 [subst]----------------------------------- |- all (X \cup Y) . h(t1) = h(t2) for h: X -> T_{OP}(Y) |- all X . t1 = t2 [equals]---------------------------------- |- all (X \cup Y) . h_1(t) = h_2(t) for h_i: Y -> T_{OP} where for i=1,2, and given var y0 h_i(y) = ti if y = y0, otherwise y |- all X . t1 = t2 [dropvar]------------------------------ |- all X0 . t1 = t2 for X0 \subseteq X such that: (1) free vars of t1 and t2 in X0 (2) if X has variable of a type s then T_{OP}(X0) has terms of type s (for all types s) ------------------------------------------ examples of deductions |- all . 0 = 0+0 [equals] ---------------------- |- all a,y0 . a*0 = a*(0+0) |- all a,b,c . a*0 = 0 [drapvar] ------------------------- |- all a . a*0 = 0