What’s the correct algorithm to filter accumulating string concatenations?

I have a function that is receiving messages with the following pattern:

Example of accumulating strings

(In this picture, “string” and “message” are synonymous.)

I’m only interested in the largest messages, such as these:

Largest filtered accumulated strings

over a particular window.

Is there an algorithm that can appropriately filter the messages in the desired manner over a specified window?

Correct Turing machine representation for Rice Theorem proof

Consider the language L1. From Rice Theorem I know L1 is not decidable (i.e. undecidable).

L1 = { R(M) | R(M) is a TM and 1011 ∈ L(M)}

For example if I want to represent by diagram a TM $ M_1$ that accepts the string 1011 and a TM $ M_2$ that doesn’t accept the string 1011 (e.g., $ M_2$ accepts only the empty string), following the Rice Theorem not-trivial property, I need to use a (1) acceptance by final states or (2) acceptance by halting or (3) I can use both because I know (by theorem) they are equivalent?

With Great Weapon Fighting, is this analysis of the Double Scimitar’s damage correct?

Traditionally, the Greatsword and Greataxe are considered the strongest two-handed weapons (unless you take the Polearm Master feat, where Glaives and Halberds rock out). Barbarians and Half-Orcs benefit more from the Greataxe’s 1d12, while others prefer the Greatsword’s 2d6.

I want to compare the new Eberron’s Double Scimitar with other swords.

A double-bladed scimitar is a martial weapon, weighing 6 pounds and dealing 2d4 slashing damage on a hit. It has the two-handed property and the following special property:

  • If you attack with a double-bladed scimitar as part of the Attack action on your turn, you can use a bonus action immediately after to make a melee attack with it. This attack deals 1d4 slashing damage on a hit, instead of 2d4.

For a Fighter or a Paladin with Great Weapon Fighting, I was able to build a graph that compared the Greatsword with it. Since Fighters have ASI at levels 4 and 6, they can usually reach a +5 STR modifier very early, and the Greatsword only becomes the strongest weapon at level 20, when the Fighter does 4 attacks per turn.

enter image description here

If you accept feats, the Double Scimitar is not eligible for Great Weapon Master (no Heavy property) or Polearm Master, which could drastically change the average damage output graph of other two-handed weapons. However, without feats, is my graph correct, and does the Double Scimitar outperform other options?

Is this statement of P = NP in Agda correct?

Looking for a completely formal and self-contained statement of P = NP in type theory, I stumbled upon this short Agda formalization (a cleaned up version is reproduced below).

The statement here does seem to express the problem correctly but I’m not entirely sure as the code is not well-commented. So my question is: is this an accurate statement of P = NP and if not how would one fix it?

 open import Data.Nat                              using    (ℕ; suc; zero; _+_; _*_; _≤_; _^_) open import Data.Bool                             using    (Bool; true; false; if_then_else_; _∨_) open import Data.List                             using    (List; _∷_; []; length) open import Data.Vec                              using    (Vec; _∷_; []) open import Data.Product                          using    (Σ-syntax; _,_) open import Data.Sum                              using    (_⊎_; inj₁; inj₂) open import Data.Empty                            using    (⊥) open import Relation.Binary.PropositionalEquality using    (_≡_; refl)  iterate : {A : Set} → ℕ → A → (A → A) → A iterate zero    z s = z iterate (suc n) z s = s (iterate n z s)  is-poly : (ℕ → ℕ) → Set is-poly f = Σ[ m ∈ ℕ ] ((n : ℕ) → f n ≤ 2 ^ m)  is-inj₂ : {A B : Set} → A ⊎ B → Bool is-inj₂ (inj₁  _) = false is-inj₂ (inj₂ _) = true  data fn : ℕ → Set where     fz : {n : ℕ} → fn (suc n)     fs : {n : ℕ} → fn n → fn (suc n)  ref : {A : Set} {n : ℕ} → fn n → Vec A n → A ref fz (a ∷ _) = a ref (fs m) (_ ∷ rest) = ref m rest  subs : {A : Set} {n : ℕ} → fn n → A → Vec A n → Vec A n subs fz a (_ ∷ rest) = a ∷ rest subs (fs m) a (b ∷ rest) = b ∷ subs m a rest  replicate : {A : Set} → (n : ℕ) → A → Vec A n replicate zero a = [] replicate (suc n) a = a ∷ replicate n a  data command (stacks : ℕ) (states : ℕ) : Set where   push   : fn stacks → Bool → fn states → command stacks states   pop    : fn stacks → fn states → fn states → fn states          → command stacks states   return : Bool → command stacks states  record machine : Set where   field     stacks : ℕ     states : ℕ     commands : Vec (command stacks states) states     initial-command : fn states  command-mach : machine → Set command-mach m = command (machine.stacks m) (machine.states m)  record state (m : machine) : Set where   constructor mkState   field     stacks : Vec (List Bool) (machine.stacks m)     current : fn (machine.states m)  step : (m : machine) → state m → (state m) ⊎ Bool exec : {m : machine} → command-mach m → state m → (state m) ⊎ Bool  step m s = exec (ref (state.current s) (machine.commands m)) s exec (return b) _ = inj₂ b exec (push i b c) s =   let     prev-stack : List Bool     prev-stack = ref i (state.stacks s)   in     inj₁ (mkState (subs i (b ∷ prev-stack) (state.stacks s)) c)  exec (pop i ct cf ce) s with ref i (state.stacks s) ... | []           = inj₁ (mkState (state.stacks s) ce) ... | true  ∷ rest = inj₁ (mkState (subs i rest (state.stacks s)) ct) ... | false ∷ rest = inj₁ (mkState (subs i rest (state.stacks s)) cf)  step-or-halted : (m : machine) → (state m) ⊎ Bool → (state m) ⊎ Bool step-or-halted m (inj₂ b) = inj₂ b step-or-halted m (inj₁ s) = step m s  nsteps : {m : machine} → ℕ → state m → (state m) ⊎ Bool nsteps {m} n s = iterate n (inj₁ s) (step-or-halted m)  initial-state : (m : machine) → List Bool → state m initial-state m l =   mkState (replicate (machine.stacks m) l) (machine.initial-command m)  record poly-time-machine : Set where   inductive   field     m : machine     runtime : ℕ → ℕ     poly : is-poly runtime     is-runtime : (l : List Bool)                → (is-inj₂ (nsteps (runtime (length l)) (initial-state m l))) ≡ true  get-inj₂ : {A B : Set} → (e : A ⊎ B) → is-inj₂ e ≡ true → B get-inj₂ (inj₁ x) () get-inj₂ (inj₂ x) _ = x  run-poly-time-machine : poly-time-machine → List Bool → Bool run-poly-time-machine m inp = get-inj₂ _ (poly-time-machine.is-runtime m inp)  np-machine : Set np-machine = poly-time-machine  search : ℕ → poly-time-machine → List Bool → Bool search zero    m inp = run-poly-time-machine m inp search (suc n) m inp = search n m (false ∷ inp) ∨ search n m (true ∷ inp)  run-np-machine : np-machine → List Bool → Bool run-np-machine m inp = search (length inp) m inp  P=NP : Set P=NP =   (m-np : np-machine) →     Σ[ m-p ∈ poly-time-machine ]       (((inp : List Bool) → run-poly-time-machine m-p inp ≡ run-np-machine m-np inp)) ``` 

Is this proof of the map fusion law correct?

I am reading Functional Programming in Scala, where I have been asked to prove the map fusion law. Since Scala is what I am familiar with, I am using as my notation a kind of pseudo-Scala.

Here is the text of the question, from the book: Given map(y)(id) == y, it's a free theorem that map(map(y)(g))(f) == map(y)(f compose g). (This is sometimes called map fusion, and it can be used as an optimization - rather than spawning a separate parallel computation to compute the second mapping, we can fold it into the first mapping.) Can you prove it? You may want to read the paper "Theorems for Free!" (http://mng.bz/Z9f1) to better understand the "trick" of free theorems.

I was unable to make much headway without assistance, so I tried searching online. I haven’t been able to find anyone who has the text of the proof outlined in full, but there are several places where the proof is left as an exercise to the reader, with the useful hint to assume that y == x::xs (some List).

Here is my proof based on the assumption that y is some List:

We have to prove that map(map(y)(g))(f) == map(y)(f compose g)  searching online, it appears that an important assumption is to assume y is of the form x0::xs0  so y is of the form   x0::xs0   x0::x1::xs1   x0::x1::x2::xs2     ...   x0::x2::xs2 ... ::xsn::Nil  Proof:  First we show map(y)(g) == g(x0)::g(x1)::g(x2) ... ::g(xn)::Nil   map(y)(g)   map(x0::xs)(g)   g(x0)::map(xs0)(g)   g(x0)::g(x1)::g(x2) ... ::g(xn)::Nil  Now we prove map(map(y)(g))(f) == map(y)(f compose g) Starting from LHS, we manipulate until we have RHS   map(map(y)(g))(f)   map(g(x0)::g(x1)::g(x2) ... ::g(xn)::Nil)(f)   f(g(x0))::map(g(x1)::g(x2)::g(x3):: ... ::g(xn)::Nil)(f)   f(g(x0))::f(g(x1))::f(g(x2)):: ... ::f(g(xn))::Nil   (f compose g)(x0)::(f compose g)(x1)::(f compose g)(x2):: ... ::(f compose g)(xn)::Nil   map(x0::x1::x2 ... ::xn::Nil)(f compose g)   map(y)(f compose g) 

It occurs to me that the proof can be written in a way that uses structural induction, but I am not familiar enough with the technique to use it. Can anyone help with this? Also, can anyone recover the form of the solution that makes use of the identity law map(y)(id) == y as it is asked in the text of the problem? My answer is probably not what the authors had in mind when they posed the question.

Are these two Barons von Dammenblatz the same person? If so, which name is correct?

I read Rough Nights & Hard Days, a WFRP-4e scenarios book from Graeme Davis. In the first plot of the first story, they mention the protagonist against Gravin Maria-Ulrike von Liebewitz of Ambosstein: Baron Eberhardt von Dammenblatz of Wissenberg.

On the fourth cover of the book, they mention Baron Otto von Dammenblatz. This name is from the White Dwarf #94 of November 1987, the first iteration of this story.1

I tried to find other occurences of the name Eberhardt but even in the character list, only “Baron von Dammenblatz” is mentionned.

  • Is this an error, or are Baron Otto and Baron Eberhardt different people? Was the official name changed? Two name that Wissenlanders use ?
  • In White Dwarf #94, Baron Otto von Dammenblatz is from Wissenburg, not Wissenberg. I’m not German, so maybe this is exactly the same thing, but I’m not sure.

I’m looking for an official source.

Sources :

  • Who’s Who & What’s What in Warhammer at :
    • Franke, Bruno
    • Liebewitz of Ambosstein, Gravin Maria-Ulrike von
  • Rough nights & Hard days, WFRP-4e scenarios book from Graeme Davis, p9 -Plot summaries -Plot 1