import Base import ./defs.bend as D import ./halves.bend as H import ./LAWS.bend as L import ./proof_force.bend as F import ./proof_run.bend as R import ./proof_count.bend as C import ./proof_tree.bend as T import ./proof_all.bend as A # Proofs of the laws: `def L.name` proves `law name` of LAWS.bend. # # A list or tree of values used once (a task list is one) serves one walk # only, in proofs too. So the proofs walk once and hand out what they walked # over with the facts they need about it (Sigmas): T.tb hands out tree(xs) # with its leaves and its balance, R.lp a tree's leaves with what running it # gives, F.fa_p a list with force_append, A.afb the tasks with all_force. # Running tasks # ============= def L.all_force(b, B, ts): A.all_force(b, B, ts) def L.all_force_back(b, B, ts): A.afb(b, B, ts) def L.all_tree(b, B, ts): {==} def L.run_leaves(b, B, t): R.run_leaves(b, B, t) def L.run_shape(b, B, t): R.run_shape(b, B, t) def L.all_append(b, B, ts, us): A.all_append(b, B, ts, us) def L.all_length(b, B, ts): A.all_length(b, B, ts) # The tree # ======== def tree_leaves.k(a, -A: Kind(a), -xs: List, s: T.TB(a, A, xs)) -> {D.leaves(a, A, H.tree(a, A, xs)) == xs : List}: (t, e) = s (e1, g) = e (e2, e3) = g %e1 : {D.leaves(a, A, _) == xs : List} e2 def tree_balanced.k(a, -A: Kind(a), -xs: List, s: T.TB(a, A, xs)) -> {D.balanced(D.shape(a, A, H.tree(a, A, xs))) == True{} : Bool}: (t, e) = s (e1, g) = e (e2, e3) = g %e1 : {D.balanced(D.shape(a, A, _)) == True{} : Bool} e3 def L.tree_leaves(a, A, xs): tree_leaves.k(a, A, xs, T.tb(a, A, xs)) def L.tree_balanced(a, A, xs): tree_balanced.k(a, A, xs, T.tb(a, A, xs)) def L.count_leaves(a, A, t): C.count_leaves(a, A, t) # Forcing # ======= def L.force_append(b, B, ts, us): F.force_append(b, B, ts, us, F.fa_p(b, B, ts, us)) def L.force_length(b, B, ts): F.force_length(b, B, ts)