Tally.Core

Reading settings

Look

Mode

Definitions

Proofs

Imports

Arguments

References

References open

Saved in this browser.

ModulesGuarantees

Modules

Core5Laws8Prose7
On this page

On this page

Coretallytotalappendsize
This definition

Tally.Core

Core

A tally is a list of counts. This module defines the type and the two functions the rest of the project reasons about: total and append.

A list of counts.

Inductive tally : Type :=
  | empty : tally
  | cons : nat -> tally -> tally.
References

Uses

  • nat
Declare Scope tally_scope.
Delimit Scope tally_scope with tally.
Infix "::" := cons (at level 60, right associativity) : tally_scope.
References

Uses

Open Scope tally_scope.

The sum of every count in a tally.

Arguments

t : tally
the tally summed.
Fixpoint total (t : tally) : nat :=
  match t with
  | empty => 0
  | n :: rest => n + total rest
  end.

Arguments

t : tally
the tally summed.
References

The counts of a, followed by the counts of b.

Arguments

a : tally
the counts that come first.
b : tally
the counts that come last.
Fixpoint append (a b : tally) : tally :=
  match a with
  | empty => b
  | n :: rest => n :: append rest b
  end.

Arguments

a : tally
the counts that come first.
b : tally
the counts that come last.
References

How many counts a tally holds.

Arguments

t : tally
the tally measured.
Fixpoint size (t : tally) : nat :=
  match t with
  | empty => 0
  | _ :: rest => S (size rest)
  end.

Arguments

t : tally
the tally measured.
References

Uses