As the title says, how can I verify the function below with the Hoare Triple? I read various lectures about it but I can't figure out how to do it.
int uguaglianza_insiemi(elem_lista_t *insieme_A,
elem_lista_t *insieme_B)
{
int esito;
if ((insieme_A == NULL) &&
(insieme_B == NULL))
esito = 1;
else if (insieme_A == NULL ||
insieme_B == NULL)
esito = 0;
else if (insieme_A->valore != insieme_B->valore)
esito = 0;
else esito = uguaglianza_insiemi(insieme_A->succ_p,
insieme_B->succ_p);
return (esito);
}
To prevent a long discussion in comments, I'll try to write some pre- and post conditions.
As it is not possible to test inside the function whether it is called with pointers to valid list objects, that falls to the parent/the caller:
I hope this is something that you and you professor can work with.
Inside the function, this continues with the
ifstatement using the rule of composition.