Qcert.DNNRC.Lang.DatasetSize


Section size.


  Context {fruntime:foreign_runtime}.
  Context {ftype: foreign_type}.

  Fixpoint column_size (c:column)
    := match c with
       | CCol _ ⇒ 1
       | CDot _ c0S (column_size c0)
       | CLit _ ⇒ 1
       | CPlus c1 c2S (column_size c1 + column_size c2)
       | CEq c1 c2S (column_size c1 + column_size c2)
       | CLessThan c1 c2S (column_size c1 + column_size c2)
       | CNeg c0S (column_size c0)
       
       | CToString c0S (column_size c0)
       | CSConcat c1 c2S (column_size c1 + column_size c2)
       | CUDFCast _ c0S (column_size c0)
       | CUDFUnbrand _ c0S (column_size c0)
       end.

  Fixpoint dataset_size (d:dataset)
    := match d with
       | DSVar _ ⇒ 1
       | DSSelect scl d0S (
                                (fold_left (fun acc sccolumn_size (snd sc) + acc) scl 0)
                                  + dataset_size d0)
       | DSFilter c0 d0S (column_size c0 + dataset_size d0)
       | DSCartesian d1 d2S (dataset_size d1 + dataset_size d2)
       | DSExplode _ d0S (dataset_size d0)
       end.

  Lemma column_size_nzero (c:column) : column_size c 0.

    Lemma dataset_size_nzero (d:dataset) : dataset_size d 0.

End size.