Search for element in tree in Isabelle -


I have tested this function whether or not an element is in a binary tree:

  Funny Lookup :: "int ⇒bst⇒bool" where "Lookup X_ = False" | "Explorer X BST = (If X = Root (BST)) is true and if xroot (BST) then Expose Axle (BST) and Lookup X Right (BST)"  

The error message type integration has failed: The conflict of type "BST" and "int"

Datatype BST

  is defined as datatype bst = Leaf. Node int BST BST  

What's wrong with this?

It seems that your datatype declaration does not mention any associated value for any leaf. So, it may seem like

  datatype_nui bst = leaf int Node int bst bst  

The function only checks all the constructors of the current node:

  funny look :: "int ⇒ bst ⇒ bool" where "Lookup X (Leaf y) = x = y" | "Look up x (node ​​y left left daembust) = (if x = y is true (if x ≤ y then lookup x leftbst else lookup x rightbst))"  

Comments