Definition. 大小与深度

对 词项的集合 的有限语法树, 大小 size( 𝑡 ) 数节点, 深度 depth( 𝑡 ) 数从根到最远叶子的路径上的边. 两个函数按 直接子项与真子项 的直接子项递归定义:

size( true  )=size( false  )=size( 0 )=1size( succ 𝑡 1 )=size( pred 𝑡 1 )=size( iszero 𝑡 1 )=size( 𝑡 1 )+1size( if 𝑡 1 then 𝑡 2 else 𝑡 3 )=size( 𝑡 1 )+size( 𝑡 2 )+size( 𝑡 3 )+1

深度数的是从根到最远叶子的路径上的边数(区别于节点数),完整定义为:

depth( true  )=depth( false  )=depth( 0 )=0depth( succ 𝑡 1 )=depth( pred 𝑡 1 )=depth( iszero 𝑡 1 )=depth( 𝑡 1 )+1depth( if 𝑡 1 then 𝑡 2 else 𝑡 3 )=max( depth( 𝑡 1 ),depth( 𝑡 2 ),depth( 𝑡 3 ) )+1

例如 pred ( succ 0 ) 有三个节点、两条边,所以大小是 3,深度是 2. if  true  then 0 else ( succ 0 ) 的大小是 5,深度也是 2: 大小把三个分支都算进去,深度只取最长的那条路径.