ContextFree Languages and Grammars: A Deeper Look

Elegant fractal tree visually explains context-free grammar rules, showcasing derivations with vibrant leaves & geometric nodes

Unravel the mysteries of the mathematical universe! Here at Mathematical Concepts, we're dedicated to making complex ideas clear and captivating. Ready to dive into the fascinating world of formal language theory? Our exploration of context-free grammar examples explained provides a clear and concise introduction to this powerful tool. Prepare to unlock a deeper understanding of ContextFree Languages and Grammars—your journey starts now!

Table

Understanding Context-Free Grammars (CFG) and their Applications

Context-free grammars (CFGs) are a fundamental concept in theoretical computer science and formal language theory. They provide a powerful and elegant framework for describing the syntax of programming languages, defining the structure of data formats like XML, and analyzing the grammatical structure of natural languages. This article delves into the intricacies of CFGs, providing a clear and comprehensive explanation of their formal definition, illustrating them with practical examples, and exploring their significant applications in various fields.

We'll focus on making these powerful tools accessible, clarifying the often-complex terminology and demonstrating their utility through relatable examples, ultimately aiming to equip you with a solid understanding of context-free grammar examples explained. Understanding CFGs is crucial for anyone seeking a deeper comprehension of how computers process and interpret structured data, making this a cornerstone topic in advanced mathematics, specifically within the realm of discrete mathematics.

Defining Context-Free Grammars: Formal Definition and Backus-Naur Form

A context-free grammar is formally defined as a quadruple G = (V, Σ, R, S), where:

  • V: is a finite set of variables (also called non-terminals), representing syntactic categories.
  • Σ: is a finite set of terminals, representing the basic symbols of the language.
  • R: is a finite set of production rules, each of the form A → α, where A ∈ V and α ∈ (V ∪ Σ)*. This means a variable A can be replaced by a string α consisting of variables and/or terminals.
  • S: is the start symbol, a designated variable in V that initiates the derivation process.

The Backus-Naur Form (BNF) is a widely used notation for representing CFGs. It uses the following conventions:

  • Variables are enclosed in angle brackets:<variable>.
  • Terminals are written as they are (e.g., +, -, *, /, =).
  • The production rule A → α is written as <A> ::= α.
  • The symbol "|" represents "or".

For example, a simple grammar for arithmetic expressions might look like this in BNF:

<expression> ::= <term> | <expression> + <term> | <expression> - <term>
<term> ::= <factor> | <term> * <factor> | <term> / <factor>
<factor> ::= ( <expression> ) | number

This grammar defines how arithmetic expressions are constructed, starting from the <expression> variable and using recursive rules to build more complex structures from simpler ones. Note the use of recursion to allow for arbitrarily long expressions. Understanding this recursive structure is key to grasping the power and flexibility of CFGs. We will further explore this with more detailed examples in the following sections.

Context-Free Grammar Examples Explained: Arithmetic Expressions and Boolean Logic

Let's illustrate CFGs with concrete examples. We'll start with a more detailed look at arithmetic expressions, then expand to Boolean logic.

Arithmetic Expressions:

Consider a slightly more complex grammar for arithmetic expressions, including parentheses for grouping:

<expr> ::= <term> | <expr> + <term> | <expr> - <term>
<term> ::= <factor> | <term> * <factor> | <term> / <factor>
<factor> ::= ( <expr> ) | number

This grammar allows for expressions like (3 + 4) * 5 or 10 - 2 * 3. The parentheses ensure correct order of operations. The derivation of an expression like "3 + 4 * 2" would involve multiple steps, systematically applying the production rules to transform the start symbol <expr> into the target string.

Boolean Logic:

CFGs can also describe Boolean expressions. Here's a simple grammar:

<bool_expr> ::= <bool_term> | <bool_expr> OR <bool_term>
<bool_term> ::= <bool_factor> | <bool_term> AND <bool_factor>
<bool_factor> ::= TRUE | FALSE | NOT <bool_factor> | ( <bool_expr> )

This grammar allows for expressions like TRUE AND (FALSE OR NOT TRUE). The parentheses again ensure correct operator precedence. The use of NOT demonstrates the handling of unary operators within the CFG framework. The systematic application of rules allows for the parsing and evaluation of complex Boolean expressions. The number of possible derivations increases exponentially with the complexity of the expression, highlighting the power and complexity of CFGs.

Practical Applications of CFGs: Programming Language Syntax and XML Parsing

Context-free grammars are not merely theoretical constructs; they have crucial practical applications. Their primary use lies in defining and parsing the syntax of programming languages and data formats.

Programming Language Syntax: Most programming languages are defined using CFGs. Compilers and interpreters use these grammars to parse the source code, ensuring that the code conforms to the language's syntax rules. Errors in syntax are detected by the parser, which uses the grammar to determine if the code can be derived from the start symbol. This ensures that the code is valid and can be processed by the compiler or interpreter.

XML Parsing: The Extensible Markup Language (XML) uses a CFG-like structure to define its syntax. XML parsers utilize this structure to validate and parse XML documents, ensuring that the documents are well-formed and adhere to the specified schema. The structure of XML documents, with their nested tags, lends itself naturally to a CFG representation, making parsing efficient and reliable. The robustness of XML parsing is directly related to the rigorous definition provided by the underlying CFG. The ability to parse XML documents accurately is integral to many data processing and exchange systems.

Key Concepts in Context-Free Language Theory

This section delves into the core principles underpinning context-free languages (CFLs) and their associated grammars. Understanding these concepts is crucial for comprehending how CFLs are defined, analyzed, and applied in various fields, including compiler design and natural language processing. We'll focus on practical aspects and illustrative examples to solidify your understanding of "Contextfree grammar examples explained".

Derivation Trees and Parse Trees: Visualizing Arithmetic Expression Grammars

Derivation trees and parse trees provide a visual representation of the derivation process in a context-free grammar. They are invaluable tools for understanding how a string is generated from a grammar and for debugging grammar ambiguities. Let's consider a simple arithmetic expression grammar:

E -> E + T | E - T | T
T -> T * F | T / F | F
F -> ( E ) | id

where id represents an identifier (a variable).

Consider the string "id + id * id". A possible derivation tree would look like this:

      E
     /|\
    E  +  T
   / \    |
  E   -  T
 / \    |
id  -  T
       / \
      T   *  F
     |     |
     F     F
     |     |
     id    id

This tree illustrates one way the string can be derived. Note that this grammar is ambiguous because the string "id + id * id" can have multiple derivation trees, leading to different interpretations of the arithmetic expression. The parse tree, on the other hand, represents the unique interpretation of a string according to a given grammar and parsing algorithm.

Different parsing algorithms (e.g., top-down, bottom-up) might produce different parse trees, even for unambiguous grammars, highlighting the importance of choosing an appropriate parser for your application. Understanding these visual representations is key to grasping the nuances of context-free grammar analysis. For instance, analyzing derivation trees helps identify potential ambiguities and inform the design of unambiguous grammars.

Ambiguity in Context-Free Grammars: Dangling Else and Arithmetic Expression Ambiguity

Ambiguity in a context-free grammar means that a single string in the language can be derived in multiple ways. This leads to multiple parse trees, making it difficult for a parser to determine the intended interpretation. Two classic examples illustrate this problem: the "dangling else" problem in programming languages and ambiguity in arithmetic expressions.

The dangling else problem arises in programming languages that use if-then-else statements without explicit block delimiters. Consider the grammar:

S -> if C then S | if C then S else S | other

The string "if C1 then if C2 then S1 else S2" has two possible parse trees, leading to different interpretations of which if statement the else clause belongs to. This ambiguity is typically resolved by associating an else clause with the nearest preceding if statement.

As previously shown with the arithmetic expression grammar, the lack of operator precedence and associativity rules can create ambiguity. The string "id + id * id" can be interpreted as "(id + id) * id" or "id + (id * id)", depending on the parsing strategy. This is resolved by introducing precedence rules (multiplication before addition) and associativity rules (left-to-right associativity for addition and multiplication) either explicitly in the grammar or implicitly in the parsing algorithm.

Careful grammar design and parser implementation are crucial for avoiding or resolving ambiguities and ensuring correct program execution or language understanding. The consequences of ambiguity can range from unexpected program behavior to complete parsing failure. Therefore, understanding and addressing ambiguity is a fundamental aspect of working with context-free grammars.

Chomsky Normal Form (CNF): Conversion Algorithm and Parsing Efficiency

Chomsky Normal Form (CNF) is a restricted form of context-free grammar where every production rule is of the form A → BC or A → a, where A, B, and C are non-terminal symbols and a is a terminal symbol. The significance of CNF lies in its application to efficient parsing algorithms like the CYK algorithm. Converting a grammar to CNF involves several steps:

  1. Eliminating ε-productions: Remove rules that produce the empty string (ε). This often requires careful analysis of reachable non-terminals.
  2. Eliminating unit productions: Remove rules of the form A → B, where A and B are non-terminals.
  3. Converting remaining productions: Transform all remaining productions into the CNF format. This might involve introducing new non-terminal symbols to represent intermediate steps.

The conversion process, while algorithmic, can be complex for large grammars. However, the benefits of using a CNF grammar are substantial, particularly for parsing efficiency. The CYK algorithm, for instance, operates directly on CNF grammars providing a dynamic programming approach with a time complexity of O(n³), where n is the length of the input string. This efficiency makes CNF a valuable tool in practical applications where parsing speed is crucial.

The conversion to CNF is a preprocessing step that significantly improves the performance of parsing algorithms. Therefore, understanding and applying the CNF conversion algorithm is essential for optimizing the efficiency of context-free language processing. While the conversion algorithm itself can be computationally intensive, the resulting parsing speedup often outweighs the initial cost, especially when dealing with large input strings or frequent parsing operations.

Analyzing Context-Free Languages

This section delves into the intricacies of context-free languages (CFLs), focusing on practical applications and theoretical proofs to solidify your understanding of context-free grammar examples explained. We'll explore key algorithms, the pumping lemma, and closure properties, providing concrete examples to illustrate each concept. Understanding these aspects is crucial for anyone working with formal languages and compilers.

Membership Problem: CYK Algorithm and Earley Parsing

Determining whether a given string belongs to a context-free language is a fundamental problem. Two prominent algorithms address this: the Cocke-Younger-Kasami (CYK) algorithm and Earley parsing.

The CYK algorithm is a dynamic programming approach that efficiently checks membership for a string in a context-free grammar in Chomsky Normal Form (CNF). It works by constructing a table where each entry (i,j,A) indicates whether the substring from position i to j can be derived from non-terminal A. The algorithm proceeds bottom-up, filling the table based on the grammar's production rules. For example, consider the grammar:

S → AB | a
A → a | Aa
B → b

Let's check if the string "aab" is in the language generated by this grammar. The CYK algorithm would systematically build a table, eventually determining if S can generate "aab". The algorithm's time complexity is O(n³|G|), where n is the length of the string and |G| is the size of the grammar. This makes it suitable for many practical applications, but its reliance on CNF can be a limitation.

Earley parsing, on the other hand, is a more general algorithm that doesn't require the grammar to be in CNF. It uses a dynamic programming approach with items of the form [A → α ⋅ β, i], indicating that non-terminal A can produce αβ, and the derivation of α has been completed at position i. The algorithm iteratively builds a parse chart, effectively exploring all possible derivations.

While generally more complex than CYK, its ability to handle arbitrary context-free grammars makes it a powerful tool for language processing. Earley parsing's time complexity is typically O(n³), making it less efficient than CYK for grammars in CNF but more versatile. The choice between CYK and Earley parsing often depends on the specific grammar and application requirements.

Pumping Lemma for Context-Free Languages: Proving Non-Context-Free Languages

The pumping lemma is a powerful tool for proving that a language is not context-free. It states that for any context-free language L, there exists a pumping length p such that any string w in L with length |w| ≥ p can be written as uvwxy, satisfying several conditions:

  1. |vwx| ≤ p
  2. |vx| ≥ 1
  3. For all i ≥ 0, uviwxiy is in L.

These conditions allow us to "pump" the string w by repeating v and x, and the resulting string must still be in L. To prove a language is not context-free, we assume the pumping lemma holds and derive a contradiction by finding a string that violates the conditions when pumped.

For example, let's consider the language L = {a n b n c n | n ≥ 0}. We can use the pumping lemma to show that L is not context-free. Assume the pumping length is p. Consider the string w = a p b p c p . If we apply the pumping lemma, any decomposition uvwxy will inevitably lead to a string that violates the a n b n c n structure when pumped. This contradiction proves that L is not context-free. This illustrates the power of the pumping lemma in classifying languages.

Closure Properties of Context-Free Languages: Union, Concatenation, and Kleene Star

Context-free languages exhibit several important closure properties, meaning that certain operations on CFLs will always result in another CFL. This is crucial for building more complex languages from simpler ones. Key closure properties include:

  • Union: If L 1 and L 2 are CFLs, then L 1 ∪ L 2 is also a CFL. This is relatively straightforward to prove by constructing a new grammar that combines the productions of the grammars for L 1 and L 2 , introducing a new start symbol that can derive from either.
  • Concatenation: If L 1 and L 2 are CFLs, then L 1 L 2 (the concatenation of L 1 and L 2 ) is also a CFL. A new grammar can be constructed by modifying the production rules to allow derivations from the start symbol of L 1 to transition to the start symbol of L 2 .
  • Kleene Star: If L is a CFL, then L* (the Kleene star of L, representing zero or more concatenations of strings from L) is also a CFL. We can construct a new grammar with a new start symbol that can either produce the empty string (ε) or concatenate strings derived from the original grammar's start symbol recursively.

These closure properties are fundamental to the theory of context-free languages and are frequently used in compiler design and formal language theory. They allow the construction of complex grammars by combining simpler ones, greatly simplifying the design and analysis of programming languages and other formal systems. Understanding these properties is essential for anyone working with context-free grammars and their applications.

Advanced Topics in Context-Free Grammars

Elegant, swirling nebula illustrates context-free grammar's recursive structure

This section delves into more complex aspects of context-free grammars (CFGs), moving beyond the fundamental definitions and exploring practical applications and advanced parsing techniques. We will examine how CFGs are used in real-world scenarios and the sophisticated algorithms employed to process them efficiently. Understanding these advanced topics is crucial for anyone seeking a deeper understanding of formal language theory and its applications in computer science. The examples provided will solidify your understanding of "contextfree grammar examples explained".

Context-Free Grammar Examples Explained: Recursive Descent Parsers and LL(1) Grammars

Recursive descent parsing is a top-down parsing technique that directly implements the grammar rules as recursive procedures. Each non-terminal symbol in the grammar corresponds to a function that attempts to match the corresponding production rules. This approach is intuitive and relatively easy to understand, making it a popular choice for educational purposes and smaller-scale applications.

Let's consider a simple arithmetic expression grammar:

E -> E + T | T
T -> T * F | F
F -> (E) | id

where id represents an identifier (variable). A recursive descent parser for this grammar would consist of functions parseE, parseT, and parseF, each recursively calling others to match the production rules. For example, parseE would first attempt to match E + T, and if unsuccessful, it would fall back to T.

However, recursive descent parsers are not suitable for all CFGs. They work best with LL(1) grammars, which are a subset of CFGs that satisfy specific conditions ensuring that the next input symbol uniquely determines which production rule to apply. This "look-ahead" capability (the "1" in LL(1)) is vital for avoiding backtracking and ensuring efficient parsing.

Not all context-free grammars are LL(1), which limits the applicability of this simple yet elegant parsing method. The process of transforming a CFG into an LL(1) grammar, if possible, often involves techniques like left factoring and eliminating left recursion. This transformation process itself is a significant area of study within compiler design.

Parsing Algorithms for Context-Free Languages: Predictive Parsing and LR Parsing

While recursive descent parsing is effective for LL(1) grammars, more powerful algorithms are needed to handle the broader class of CFGs. Predictive parsing is a form of top-down parsing that uses a parsing table to guide the parsing process, eliminating the need for backtracking. The parsing table is constructed based on the grammar's structure, indicating the appropriate production rule to apply based on the current non-terminal and the next input symbol. Predictive parsing is more general than recursive descent but still has limitations; it cannot handle grammars with left recursion or ambiguous grammars.

LR parsing, on the other hand, is a bottom-up parsing technique that uses a stack to keep track of the parsed input. LR parsers are significantly more powerful than LL parsers, capable of handling a wider range of CFGs including those with left recursion and some ambiguous grammars. Different variations of LR parsing exist, such as SLR(1), LR(1), and LALR(1), each offering a trade-off between parsing power and the complexity of constructing the parsing table.

LR(1) parsers are the most powerful but also the most complex to build, while LALR(1) parsers offer a good balance between power and efficiency, and are commonly used in compiler construction. The choice of parsing algorithm depends heavily on the specific grammar and the requirements of the application. For instance, LALR(1) is a widely used compromise offering a good balance between power and efficiency.

Applications of Context-Free Grammars in Compiler Design: Lexical Analysis and Syntax Analysis

Context-free grammars are fundamental to compiler design, playing a crucial role in both lexical analysis (scanning) and syntax analysis (parsing). In lexical analysis, regular expressions and finite automata are often used to identify tokens (keywords, identifiers, operators, etc.) in the source code. However, CFGs are essential for the syntax analysis phase, where the structure of the program is verified according to the programming language's grammar.

The compiler uses a CFG that formally defines the syntax of the programming language. The parser, often an LR parser or a variant, then takes the stream of tokens produced by the lexical analyzer and attempts to construct a parse tree according to the grammar. If the input conforms to the grammar, the parser successfully creates a parse tree, allowing the subsequent phases of the compilation process (semantic analysis, code generation, etc.) to proceed.

If the input violates the grammar, the parser reports a syntax error, providing crucial feedback to the programmer. This process is vital for ensuring that the source code is syntactically correct before code generation and execution. The robustness and efficiency of the parser directly impact the compiler's overall performance and reliability. Therefore, understanding CFGs is paramount for anyone working on compiler development or language design.

Beyond Context-Free Grammars: A Look at Other Language Classes

Context-free grammars (CFGs) are powerful tools for describing the syntax of programming languages and other formal systems. However, they are not the only game in town. Understanding their limitations and the existence of other grammar classes is crucial for a complete grasp of formal language theory.

This section delves into language classes beyond CFGs, highlighting their characteristics and comparing them to the familiar context-free framework. We'll explore how different classes of grammars correspond to different computational models, illustrating the inherent trade-offs between expressive power and computational complexity. This exploration will further solidify your understanding of "contextfree grammar examples explained," by providing a broader perspective on the landscape of formal languages.

Regular Languages and Finite Automata: A Comparison with CFGs Using Examples

Regular languages represent the simplest class of formal languages. They can be described by regular expressions or recognized by finite automata – simple computational models with a finite number of states. This contrasts sharply with CFGs, which are recognized by pushdown automata (PDAs), machines with a stack for storing information. The key difference lies in memory capacity: finite automata have limited memory, while PDAs have unbounded memory (the stack).

Let's illustrate this with examples:

  • Regular Language Example: The language of all strings over the alphabet {a, b} containing an even number of 'a's is regular. A finite automaton can easily track whether the number of 'a's seen so far is even or odd. It doesn't need a stack to remember the entire history of 'a's.
  • Context-Free Language Example (not regular): The language of all strings of balanced parentheses, like "()()", "(()())", etc., is context-free but not regular. A PDA can use its stack to keep track of opening parentheses and match them with closing parentheses. A finite automaton cannot do this because it lacks the memory to remember the nesting depth of parentheses. This is a classic example that helps clarify the distinction and aids in understanding "contextfree grammar examples explained".

The following table summarizes the key differences:

Feature Regular Languages Context-Free Languages
Defining Tool Regular expressions, Finite Automata Context-Free Grammars, Pushdown Automata
Memory Finite Unbounded (stack)
Expressive Power Less powerful than CFGs More powerful than Regular Languages
Computational Complexity Easier to process; efficient algorithms exist Can be more computationally expensive

This comparison highlights the increased expressive power of CFGs compared to regular languages, but also hints at the increased computational complexity that comes with this power.

Context-Sensitive Grammars and Beyond: Turing Machines and Undecidability

Beyond context-free grammars lie context-sensitive grammars (CSGs) and, ultimately, recursively enumerable languages recognized by Turing machines. Context-sensitive grammars allow for productions where the context of a non-terminal influences its replacement. This provides even greater expressive power, but at a significant computational cost.

Turing machines represent the most powerful computational model, capable of recognizing recursively enumerable languages. These languages, however, are not always decidable. This means there's no algorithm that can determine, for every input string, whether it belongs to the language or not. This undecidability is a fundamental limitation of computation. The inherent complexity in analyzing context-sensitive grammars and beyond sharply contrasts with the relative simplicity of working with context-free grammar examples explained in previous sections.

The hierarchy of language classes can be visualized as follows:

Regular Languages ⊂ Context-Free Languages ⊂ Context-Sensitive Languages ⊂ Recursively Enumerable Languages

Understanding this hierarchy is crucial for appreciating the limitations and capabilities of different formal language classes and their associated computational models. The move beyond CFGs reveals a world of increased expressive power but also increased computational complexity and, ultimately, undecidability. This broader perspective enhances your understanding of the nuances involved in "contextfree grammar examples explained" and the broader field of formal language theory.

Frequently Asked Questions

What is a context-free grammar (CFG)?

A context-free grammar is a formal system used to define a context-free language. It consists of rules that describe how to generate strings of symbols, allowing for the creation of complex structures like those found in programming languages. These grammars are crucial in compiler design and natural language processing.

Can you provide a simple example of a CFG?

Yes. Consider the grammar with rules like S → aSb | ε. This generates strings like "ab", "aabb", "aaabbb", etc. The symbol 'S' is the start symbol, 'a' and 'b' are terminals, and the '|' represents alternative productions.

How do context-free grammars differ from regular grammars?

Context-free grammars can generate languages that regular grammars cannot. Regular grammars only allow for rules of the form A → a or A → aB, where A and B are variables and 'a' is a terminal. CFGs allow for more complex rules, enabling the creation of nested structures.

What is the significance of the Chomsky hierarchy in relation to CFGs?

The Chomsky hierarchy classifies formal grammars into four types. Context-free grammars occupy the second level, sitting between regular grammars (type 3) and context-sensitive grammars (type 1). This hierarchy helps us understand the expressive power of different grammar types.

Where are context-free grammars used in practice?

Context-free grammars find widespread application in compiler construction (parsing programming languages), natural language processing (modeling sentence structures), and formal verification. They are essential for analyzing and manipulating structured data.

Final Reflection: The Enduring Power of Context-Free Grammars

Understanding context-free grammars isn't just an academic exercise; it's the bedrock of how we build and interact with the digital world. The ability to formally define and manipulate language, as CFGs allow, remains crucial in a world increasingly reliant on sophisticated software and communication systems. From the compilers that translate our code to the parsers that understand our natural language queries, the impact of CFGs is profound and pervasive.

The elegance and power of context-free grammars continue to shape our technological landscape, influencing everything from programming language design to the sophisticated algorithms that power search engines and artificial intelligence. The limits of my language mean the limits of my world. - Ludwig Wittgenstein. This quote, while not directly about CFGs, speaks to the fundamental truth that our ability to define and understand language directly impacts our understanding of the world around us. The formalisms provided by CFGs offer a powerful tool to expand those limits, allowing us to build more complex and expressive systems.

Consider the implications of this knowledge. You now possess a deeper understanding of the underlying structures that govern much of the digital world. Go forth and explore! Challenge yourself to analyze the grammars behind your favorite programming languages, or delve into the fascinating world of natural language processing. The principles you've learned here are not just theoretical; they are the building blocks of innovation, and by understanding them, you hold the key to participating in shaping the future of technology.

Unveil the Power of Context-Free Languages Today!

Thank you for exploring the fascinating world of context-free languages and grammars! We appreciate your interest in this complex but rewarding topic and hope we've provided valuable insights.

Now, let's build on your newfound knowledge. Here are some ways to apply what you've learned:

  • Participate in a coding challenge on platforms like LeetCode or HackerRank that focuses on parsing and applying context-free grammars.
  • Form a study group with peers to delve deeper into context-free languages—collaborative learning offers unique perspectives.
  • Continue your learning by exploring advanced resources such as online courses or in-depth texts on formal language theory and its practical applications.

What aspect of context-free languages most captivated you, and how will you continue to explore it? Let's discuss in the comments!

Portrait of Sarah Rodriguez

Sarah Rodriguez

Sarah Rodriguez is a recent mathematics graduate with a strong passion for making math understandable and engaging for her peers. Her fresh perspective and understanding of contemporary mathematical tools and technologies make her a valuable asset in explaining modern concepts. Having recently navigated the challenges of higher education in mathematics, Sarah possesses a relatable understanding of the difficulties students face and is adept at explaining complex ideas in a clear and concise way. She is particularly interested in the practical applications of statistics and probability in today's data-driven world and is keen on exploring the capabilities of modern mathematical software.

Go up