Datatype Rules: Difference between revisions
imported>Nicolas |
imported>Nicolas |
||
Line 67: | Line 67: | ||
we can free variable l then apply Distinct Case on it: | we can free variable l then apply Distinct Case on it: | ||
<math>\frac{ l=\operatorname{nil} \;\vdash \; \exists x \qdot \operatorname{member}(x,\operatorname{nil}) \land (\forall y \qdot \operatorname{member}(y,\operatorname{nil}) \limp y \leq x) \qquad l=\operatorname{cons}(head0, tail1) \;\vdash \; \exists x \qdot \operatorname{member}(x,\operatorname{cons}(head0, tail1)) \land (\forall y \qdot \operatorname{member}(y,\operatorname{cons}(head0, tail1)) \limp y \leq x) }{ \;\;\vdash\;\; \exists x \qdot \operatorname{member}(x,l) \land (\forall y \qdot \operatorname{member}(y,l) \limp y \leq x) }</math> | |||
The left antecedent shows that the case of the nil list has been forgotten when writing the theorem. | |||
=== Application to trees === | === Application to trees === |
Revision as of 17:02, 6 September 2010
Datatype rules may seem a bit difficult to understand at first sight. Here are a few examples intended to make them clearer.
Datatypes used
The rules will be applied to the following datatypes:
Directions:
direction ::= north | east | south | west
Let us have a function
first two arguments are a start position, third is a direction, result is the end position.
Lists:
list(T) ::= nil | cons( head : T, tail : list(T) )
Let us have a predicate
meaning that the first argument is a member of the list.
Trees:
tree(T) ::= empty | node( left : tree(T), value : T, right : tree(T) )
Let us have a function
defining the height of a tree
Distinct Case
The rule states
Application to directions
Starting from goal
we can free variables x,y,d then apply Distinct Case:
The resulting proof step is
further simplifications depend on the existence of rules about move and the various directions.
Application to lists
Starting from goal
we can free variable l then apply Distinct Case on it:
The left antecedent shows that the case of the nil list has been forgotten when writing the theorem.
Application to trees
TODO
!l,v,r. t = node(l,v,r) => height(l) < height(t)
Induction
TODO