summaryrefslogtreecommitdiff
path: root/tests/lean/misc-polonius_list/PoloniusList.lean
blob: d679230d33a35d1f6241b9c36766a79aecdee3ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [polonius_list]
import Base.Primitives

structure OpaqueDefs where
  
  /- [polonius_list::List] -/
  inductive list_t (T : Type) :=
  | ListCons : T -> list_t T -> list_t T
  | ListNil : list_t T
  
  /- [polonius_list::get_list_at_x] -/
  def get_list_at_x_fwd
    (ls : list_t UInt32) (x : UInt32) : Result (list_t UInt32) :=
    match h: ls with
    | list_t.ListCons hd tl =>
      if h: hd = x
      then Result.ret (list_t.ListCons hd tl)
      else get_list_at_x_fwd tl x
    | list_t.ListNil => Result.ret list_t.ListNil
  
  /- [polonius_list::get_list_at_x] -/
  def get_list_at_x_back
    (ls : list_t UInt32) (x : UInt32) (ret0 : list_t UInt32) :
    Result (list_t UInt32)
    :=
    match h: ls with
    | list_t.ListCons hd tl =>
      if h: hd = x
      then Result.ret ret0
      else
        do
          let tl0  get_list_at_x_back tl x ret0
          Result.ret (list_t.ListCons hd tl0)
    | list_t.ListNil => Result.ret ret0