ArticleslgStudy

mathematics

Rewriting

Rewriting is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Rewriting rather than just read about it. In short: In mathematics, linguistics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduction systems).

Rewriting — main illustration
Rewriting — illustration

Key takeaways

  • Rewriting belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Rewriting to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Rewriting from memory before moving on to harder problems.

Reference excerpt

In mathematics, linguistics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduction systems). In their most basic form, they consist of a set of objects, plus relations on how to transform those objects. Rewriting can be non-deterministic. One rule to rewrite a term could be applied in many different ways to that term, or more than one rule could be applicable. Rewriting systems then do not provide an algorithm for changing one term to another, but a set of possible rule applications. When combined with an appropriate algorithm, however, rewrite systems can be viewed as computer programs, and several theorem provers and declarative programming languages are based on term rewriting.

Example cases

Logic In logic, the procedure for obtaining the conjunctive normal form (CNF) of a formula can be implemented as a rewriting system. For example, the rules of such a system would be:

¬ ¬ A → A {\displaystyle \neg \neg A\to A} (double negation elimination)

¬ ( A ∧ B ) → ¬ A ∨ ¬ B {\displaystyle \neg (A\land B)\to \neg A\lor \neg B} (De Morgan's laws)

¬ ( A ∨ B ) → ¬ A ∧ ¬ B {\displaystyle \neg (A\lor B)\to \neg A\land \neg B}

( A ∧ B ) ∨ C → ( A ∨ C ) ∧ ( B ∨ C ) {\displaystyle (A\land B)\lor C\to (A\lor C)\land (B\lor C)} (distributivity)

A ∨ ( B ∧ C ) → ( A ∨ B ) ∧ ( A ∨ C ) , {\displaystyle A\lor (B\land C)\to (A\lor B)\land (A\lor C),}

For each rule, each variable denotes a subexpression, and the symbol ( → {\displaystyle \to } ) indicates that an expression matching the left hand side of it can be rewritten to one matching the right hand side of it. In such a system, each rule is a logical equivalence, so performing a rewrite on an expression by these rules does not change the truth value of it. Other useful rewriting systems in logic may not preserve truth values, see e.g. equisatisfiability.

Arithmetic Term rewriting systems can be employed to compute arithmetic operations on natural numbers. To this end, each such number has to be encoded as a term. The simplest encoding is the one used in the Peano axioms, based on the constant 0 (zero) and the successor function S. For example, the numbers 0, 1, 2, and 3 are represented by the terms 0, S(0), S(S(0)), and S(S(S(0))), respectively. The following term rewriting system can then be used to compute sum and product of given natural numbers.

A + 0 → A (1) , A + S ( B ) → S ( A + B ) (2) , A ⋅ 0 → 0 (3) , A ⋅ S ( B ) → A + ( A ⋅ B ) (4) . {\displaystyle {\begin{aligned}A+0&\to A&{\textrm {(1)}},\\A+S(B)&\to S(A+B)&{\textrm {(2)}},\\A\cdot 0&\to 0&{\textrm {(3)}},\\A\cdot S(B)&\to A+(A\cdot B)&{\textrm {(4)}}.\end{aligned}}}

For example, the computation of 2+2 to result in 4 can be duplicated by term rewriting as follows:

… excerpt ends here. Continue reading the full article.

Illustrations

Rewriting: Pic.2: Rule lhs term 
  
    
      
        x
        ∗
        (
        y
        ∗
        z
        )
      
    
    {\displaystyle x*(y*z)}
  
 matching in term 
  
    
      
        
          
            
              a
              ∗
              (
              (
              a
              +
              1
              )
              ∗
              (
              a
              +
              2
              )
              )
            
            
              1
              ∗
              (
              2
              ∗
              3
              )
            
          
        
      
    
    {\displaystyle {\frac {a*((a+1)*(a+2))}{1*(2*3)}}}
Pic.2: Rule lhs term x ∗ ( y ∗ z ) {\displaystyle x*(y*z)} matching in term a ∗ ( ( a + 1 ) ∗ ( a + 2 ) ) 1 ∗ ( 2 ∗ 3 ) {\displaystyle {\frac {a*((a+1)*(a+2))}{1*(2*3)}}}

Worked examples

Example 1 — a first encounter with Rewriting

Start with the simplest possible case. Write down what Rewriting claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Rewriting before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Rewriting ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Rewriting

In research
Rewriting appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Rewriting in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Rewriting is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formal languages, Logic in computer science, Mathematical logic, so understanding it makes those chapters shorter.
In everyday life
Look for Rewriting outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Rewriting in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Rewriting means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Rewriting out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Rewriting in simple terms?

In mathematics, linguistics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduction systems).

Why does Rewriting matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Rewriting?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Rewriting.

Tags

  • Formal languages
  • Logic in computer science
  • Mathematical logic
  • Rewriting systems

Keep exploring