1-- Shared list facts. The sole List datatype and executable operations live in Data.2-- Part of the Grace17 proof assistant for mathematics based on set theory.3-- Copyright (c) 2026 Grant Passmore. Apache License 2.0; see LICENSE.4-- Authors: Grant Passmore56module Grace.Core.List7import Grace.Core.Data8exportopen Grace.Core.Data910theorem List.cases (A : Set) (xs : List(A))11shows xs = List.nil ∨∃ x ∈ A, ∃ tail, List(A, tail) ∧ xs = x :: tail12proof13induction xs14| List.nil =>15left16rfl17| List.cons(x, tail) using ih =>18right19refine⟨x, assumption, tail, assumption, rfl⟩202122theorem length.nil (A : Set)23shows length{A}([]) =024proof25simp [length]2627theorem length.cons (A x : Set) (xs : List(A))28requires element : x ∈ A29shows length{A}(x :: xs) = succ(length{A}(xs))30proof31simp [length]3233-- append(ys, xs) traverses xs and places ys after it (the existing API).34theorem append.left_unit {A : Set} (ys : List(A))35shows append(ys, []) = ys36proof37simp [append]3839theorem append.associative {A : Set} (zs ys xs : List(A))40shows append(zs, append(ys, xs)) = append(append(zs, ys), xs)41proof42induction xs43| List.nil =>simp [append]44| List.cons(x, tail) using ih =>simp [append, ih]45