Documentation

GaudisCrypt.Lib.EC.List

EasyCrypt's list library, on int (theories/datatypes/List.ec) #

EasyCrypt's list operations take and return ints (size, nth, take, drop, nseq, index, find, mkseq). To keep EasyCrypt statements as they are, they are mirrored here on ℤ, with EasyCrypt's behaviour on negative arguments: a negative count is 0. The operations that EasyCrypt shares with Lean (map, rev, flatten, ++, ∈) are Lean's.

Only what ported developments use is here. Names are EasyCrypt's.

def GaudisCrypt.EC.size {α : Type u_1} (s : List α) :

size s, as an int.

Equations
Instances For
    theorem GaudisCrypt.EC.size_ge0 {α : Type u_1} (s : List α) :
    0 ≤ size s

    EC's size_ge0.

    def GaudisCrypt.EC.nseq {α : Type u_1} (n : ℤ) (x : α) :
    List α

    nseq n x: n copies of x (none for n ≤ 0).

    Equations
    Instances For
      def GaudisCrypt.EC.take {α : Type u_1} (n : ℤ) (s : List α) :
      List α

      take n s: the first n elements (none for n ≤ 0).

      Equations
      Instances For
        def GaudisCrypt.EC.drop {α : Type u_1} (n : ℤ) (s : List α) :
        List α

        drop n s: all but the first n elements (all for n ≤ 0).

        Equations
        Instances For
          def GaudisCrypt.EC.nth {α : Type u_1} (x0 : α) (s : List α) (n : ℤ) :
          α

          nth x0 s n: the n-th element, x0 out of range.

          Equations
          Instances For
            def GaudisCrypt.EC.head {α : Type u_1} (x0 : α) (s : List α) :
            α

            head x0 s.

            Equations
            Instances For
              def GaudisCrypt.EC.behead {α : Type u_1} (s : List α) :
              List α

              behead s: s without its head.

              Equations
              Instances For
                def GaudisCrypt.EC.last {α : Type u_1} (x0 : α) (s : List α) :
                α

                last x0 s: the last element, x0 for the empty list.

                Equations
                Instances For
                  def GaudisCrypt.EC.rcons {α : Type u_1} (s : List α) (x : α) :
                  List α

                  rcons s x: s with x appended.

                  Equations
                  Instances For
                    def GaudisCrypt.EC.index {α : Type u_1} [BEq α] (x : α) (s : List α) :

                    index x s: the position of the first x in s, size s if there is none.

                    Equations
                    Instances For
                      def GaudisCrypt.EC.find {α : Type u_1} (p : α → Bool) (s : List α) :

                      find p s: the position of the first element satisfying p, size s if there is none.

                      Equations
                      Instances For

                        iota_ i n: [i; i + 1; …; i + n - 1].

                        Equations
                        Instances For
                          def GaudisCrypt.EC.mkseq {α : Type u_1} (f : ℤ → α) (n : ℤ) :
                          List α

                          mkseq f n: [f 0; …; f (n - 1)].

                          Equations
                          Instances For

                            range m n: the integers from m (included) to n (excluded).

                            Equations
                            Instances For
                              theorem GaudisCrypt.EC.mkseq0 {α : Type u_1} (f : ℤ → α) :
                              mkseq f 0 = []

                              lemma mkseq0.

                              theorem GaudisCrypt.EC.mkseqSr {α : Type u_1} (f : ℤ → α) (n : ℤ) (hn : 0 ≤ n) :
                              mkseq f (n + 1) = f 0 :: mkseq (fun (i : ℤ) => f (1 + i)) n

                              lemma mkseqSr: mkseq f (n + 1) = f 0 :: mkseq (f \o (+) 1) n, for 0 ≤ n.

                              theorem GaudisCrypt.EC.eq_in_mkseq {α : Type u_1} {f g : ℤ → α} {n : ℤ} (h : ∀ (i : ℤ), 0 ≤ i → i < n → f i = g i) :
                              mkseq f n = mkseq g n

                              lemma eq_in_mkseq: mkseq reads its function only on 0 ≤ i < n.

                              theorem GaudisCrypt.EC.size_mkseq {α : Type u_1} (f : ℤ → α) (n : ℤ) :
                              size (mkseq f n) = max 0 n

                              lemma size_mkseq: size (mkseq f n) = max 0 n.

                              theorem GaudisCrypt.EC.mem_mkseq {α : Type u_1} {f : ℤ → α} {n : ℤ} {x : α} :
                              x ∈ mkseq f n ↔ ∃ (i : ℤ), 0 ≤ i ∧ i < n ∧ f i = x

                              lemma mkseqP-style membership: an element of mkseq f n is f i for some 0 ≤ i < n.

                              theorem GaudisCrypt.EC.take_size {α : Type u_1} (s : List α) :
                              take (size s) s = s

                              lemma take_size: take (size s) s = s.

                              theorem GaudisCrypt.EC.take_clamp {α : Type u_1} (i : ℤ) (s : List α) :
                              take i s = take (min (max i 0) (size s)) s

                              take i s is a take of s at a position in [0, size s].

                              theorem GaudisCrypt.EC.cat_take_drop {α : Type u_1} (n : ℤ) (s : List α) :
                              take n s ++ drop n s = s

                              lemma cat_take_drop: take n s ++ drop n s = s.

                              Function properties (theories/core and theories/prelude) #

                              def GaudisCrypt.EC.cancel {α : Type u_1} {β : Type u_2} (f : α → β) (g : β → α) :

                              cancel f g: g is a left inverse of f.

                              Equations
                              Instances For
                                def GaudisCrypt.EC.pcancel {α : Type u_1} {β : Type u_2} (f : α → β) (g : β → Option α) :

                                pcancel f g: g is a partial left inverse of f.

                                Equations
                                Instances For
                                  def GaudisCrypt.EC.ocancel {α : Type u_1} {β : Type u_2} (g : β → Option α) (f : α → β) :

                                  ocancel g f: f undoes g wherever g succeeds.

                                  Equations
                                  Instances For
                                    def GaudisCrypt.EC.oget {α : Type u_1} [Inhabited α] (o : Option α) :
                                    α

                                    oget: the content of an option, default for none.

                                    Equations
                                    Instances For
                                      theorem GaudisCrypt.EC.oget_some {α : Type u_1} [Inhabited α] (a : α) :
                                      oget (some a) = a
                                      theorem GaudisCrypt.EC.nth_rcons {α : Type u_1} (x0 : α) (s : List α) (z : α) (i : ℤ) :
                                      nth x0 (rcons s z) i = if i < size s then nth x0 s i else if i = size s then z else x0

                                      lemma nth_rcons.

                                      theorem GaudisCrypt.EC.nth_cat {α : Type u_1} (x0 : α) (s₁ s₂ : List α) (n : ℤ) :
                                      nth x0 (s₁ ++ s₂) n = if n < size s₁ then nth x0 s₁ n else nth x0 s₂ (n - size s₁)

                                      lemma nth_cat.

                                      theorem GaudisCrypt.EC.set_nth_default {α : Type u_1} (x1 x2 : α) (s : List α) (n : ℤ) (h : 0 ≤ n ∧ n < size s) :
                                      nth x1 s n = nth x2 s n

                                      lemma set_nth_default: in range, the default does not matter.

                                      theorem GaudisCrypt.EC.take_nth {α : Type u_1} (x0 : α) (n : ℤ) (s : List α) (h : 0 ≤ n ∧ n < size s) :
                                      take (n + 1) s = rcons (take n s) (nth x0 s n)

                                      lemma take_nth.