Extensional Equality

Recall the class of <#69993#><#56967#>posn<#56967#><#69993#> structures from part~#partbasic#56968>. A <#69994#><#56969#>posn<#56969#><#69994#> combines two numbers; its fields are called <#69995#><#56970#>x<#56970#><#69995#> and <#69996#><#56971#>y<#56971#><#69996#>. Here are two examples:
<#56976#>(make-posn<#56976#> <#56977#>3<#56977#> <#56978#>4)<#56978#>
<#56984#>(make-posn<#56984#> <#56985#>8<#56985#> <#56986#>6)<#56986#>
They are obviously distinct. In contrast, the following two
<#56994#>(make-posn<#56994#> <#56995#>12<#56995#> <#56996#>1)<#56996#>
<#57002#>(make-posn<#57002#> <#57003#>12<#57003#> <#57004#>1)<#57004#>
are equal. They both contain <#69997#><#57008#>12<#57008#><#69997#> in the <#69998#><#57009#>x<#57009#><#69998#>-field and <#69999#><#57010#>1<#57010#><#69999#> in the <#70000#><#57011#>y<#57011#><#70000#>-field. More generally, we consider two structures as equal if they contain equal components. This assumes that we know how to compare the components, but that's not surprising. It just reminds us that processing structures follows the data definition that comes with the structure definition. Philosophers refer to this notion of equality as <#70001#><#57012#>EXTENSIONAL EQUALITY<#57012#><#70001#>. Section~#secequaltest#57013> introduced extensional equality and discussed its use for building tests. As a reminder, let's consider a function for determining the extensional equality of <#70002#><#57014#>posn<#57014#><#70002#> structures:
<#72045#>;; <#70003#><#57019#>equal-posn?<#57019#> <#57020#>:<#57020#> <#57021#>posn<#57021#> <#57022#>posn<#57022#> <#57023#><#57023#><#57024#>-;SPMgt;<#57024#><#57025#><#57025#> <#57026#>boolean<#57026#><#70003#><#72045#>
<#72046#>;; to determine whether two <#70004#><#57027#>posn<#57027#><#70004#>s are extensionally equal <#72046#> 
<#57028#>(d<#57028#><#57029#>efine<#57029#> <#57030#>(equal-posn<#57030#> <#57031#>p1<#57031#> <#57032#>p2)<#57032#> 
  <#57033#>(and<#57033#> <#57034#>(=<#57034#> <#57035#>(posn-x<#57035#> <#57036#>p1)<#57036#> <#57037#>(posn-x<#57037#> <#57038#>p2))<#57038#> 
       <#57039#>(=<#57039#> <#57040#>(posn-y<#57040#> <#57041#>p1)<#57041#> <#57042#>(posn-y<#57042#> <#57043#>p2))))<#57043#> 
The function consumes two <#70005#><#57047#>posn<#57047#><#70005#> structures, extracts their field values, and then compares the corresponding field values using <#70006#><#57048#>=<#57048#><#70006#>, the predicate for comparing numbers. Its organization matches that of the data definition for <#70007#><#57049#>posn<#57049#><#70007#> structures; its design is standard. This implies that for recursive classes of data, we naturally need recursive equality functions.
<#57052#>Exercise 42.1.1<#57052#> Develop an extensional equality function for the class of <#70008#><#57054#>child<#57054#><#70008#> structures from exercise~#exftss1#57055>. If <#70009#><#57056#>ft1<#57056#><#70009#> and <#70010#><#57057#>ft2<#57057#><#70010#> are family tree nodes, how long is the maximal abstract running time of the function?~ external Solution<#70011#><#70011#> <#57063#>Exercise 42.1.2<#57063#> Use exercise~#exeqextensional1#57065> to abstract <#70012#><#57066#>equal-posn<#57066#><#70012#> so that its instances can test the intensional equality of any given class of structures.~ external Solution<#70013#><#70013#>