q2K BHP
Black History Portal
THE BHP WIRE —
HIDDEN TRUTHS
What's New!
THE JOURNEY THROUGH TIME

Explore Black History

Explore the people, places, events, achievements, struggles and stories that shaped our journey.

✊🏾

Civil Rights

Movements, leaders, victories and the continuing fight for equality.

⚙️

Black Inventors

Innovation, patents, science, technology and world-changing contributions.

🏆

Sports

Pioneers, champions, Negro Leagues, records, activism and excellence.

♟️

People

Meet the people whose lives, choices and achievements shaped the journey.

📍

Places

Black towns, communities, institutions and places where history happened.

📜

Events

Moments that changed communities, movements, institutions and the nation.

Enter a person, place, event, or topic.
MY'STORY

The MOVE Fire

This is a personal recollection on the Move fire on May 13, 1985 Philadelphia police fired thousands of rounds at the MOVE house, city officials approved dropping an explosive device on the roof, the resulting fire was allowed to burn, 11 people—including five children—died, and 61 homes were destroyed. Philadelphia City Council later called it a “brutal attack carried out by the City of Philadelphia on its own citizens” and acknowledged that no individual faced criminal consequences for the bombing. One timeline correction worth preserving for the BHP record: the major previous MOVE-police confrontation was August 8, 1978, about seven years before the bombing, not a year or two earlier. Officer James Ramp was killed, other police and firefighters were wounded, nine MOVE members were later convicted, and television cameras recorded police beating Delbert Africa during his arrest. The 1985 MOVE Commission later specifically criticized city planners for failing to adequately use lessons from that 1978 confrontation. And that actually strengthens the point you’re making: 1985 did not happen without precedent or institutional memory. There had already been a deadly confrontation with MOVE, years of conflict, negotiations and police involvement before Osage Avenue.

MORE →
BLACK FACTS
The Truths They Never Taught You...

Wilmington 1898 — An American Coup

Wilmington, North Carolina once had a thriving Black middle class and an elected interracial government. In 1898 white supremacists used violence to overthrow that government, kill Black residents and drive many others from the city.

MORE →
BHP gathered finds from its connected research sources. Showing the 4 strongest Black History matches.
← BACK TO RESULTS
Wikipedia

Liskov substitution principle

Portrait of Barbara Liskov
Liskov substitution was introduced by Barbara Liskov.

The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address titled Data abstraction and hierarchy. It is based on the concept of "substitutability" – a principle in object-oriented programming stating that an object of a superclass may be replaced by an object of a subclass without breaking the program. It is a semantic rather than merely syntactic relation, because it intends to guarantee semantic interoperability of types in a hierarchy, object types in particular. Barbara Liskov and Jeannette Wing described the principle succinctly in a 1994 paper as follows:[1]

Subtype Requirement: Let ⁠⁠ be a property provable about objects ⁠⁠ of type T. Then ⁠⁠ should be true for objects ⁠⁠ of type S where S is a subtype of T.

Symbolically: That is, if S subtypes T, what holds for T-objects holds for S-objects. In the same paper, Liskov and Wing detailed their notion of behavioral subtyping in an extension of Hoare logic, which bears a certain resemblance to Bertrand Meyer's design by contract in that it considers the interaction of subtyping with preconditions, postconditions and invariants.

Principle

[edit]

Liskov's notion of a behavioural subtype defines a notion of substitutability for objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g., correctness).

Behavioural subtyping is a stronger notion than typical subtyping of functions defined in type theory, which relies only on the contravariance of parameter types and covariance of the return type. Behavioural subtyping is undecidable in general: if q is the property "method for x always terminates", then it is impossible for a program (e.g., a compiler) to verify that it holds true for some subtype S of T, even if q does hold for T. Nonetheless, the principle is useful in reasoning about the design of class hierarchy.

Liskov substitution principle imposes some standard requirements on signatures that have been adopted in newer object-oriented programming languages (usually at the level of classes rather than types; see nominal vs. structural subtyping for the distinction):

  • Contravariance of method parameter types in the subtype.
  • Covariance of method return types in the subtype.
  • New exceptions cannot be thrown by the methods in the subtype, except if they are subtypes of exceptions thrown by the methods of the supertype.

Along with signature requirements, the subtype must meet several behavioural conditions. These are detailed in a terminology resembling that of design by contract methodology, leading to some restrictions on how contracts can interact with inheritance:

  • Preconditions cannot be strengthened in the subtype.
  • Postconditions cannot be weakened in the subtype.
  • Invariants cannot be weakened in the subtype.
  • History constraint (the "history rule"). Objects are regarded as being modifiable only through their methods (encapsulation). Because subtypes may introduce methods that are not present in the supertype, the introduction of these methods may allow state changes in the subtype that are not permissible in the supertype. The history constraint prohibits this. It was the novel element introduced by Liskov and Wing. A violation of this constraint is, for example, defining a mutable point as a subtype of an immutable point.[2] This is a violation of the history constraint, because in the history of the immutable point, the state is always the same after creation, so it cannot include the history of a mutable point in general. Fields added to the subtype may, however, be safely modified because they are not observable through the supertype methods. Thus, one can define a circle with immutable center and mutable radius as a subtype of an immutable point without violating the history constraint.

Origins

[edit]

The rules on pre- and postconditions are identical to those introduced by Bertrand Meyer in his 1988 book Object-Oriented Software Construction. Both Meyer, and later Pierre America, who was the first to use the term behavioral subtyping, gave proof-theoretic definitions of some behavioral subtyping notions, but their definitions did not take into account aliasing that may occur in programming languages that support references or pointers. Taking aliasing into account was the major improvement made by Liskov and Wing (1994), and a key ingredient is the history constraint. Under the definitions of Meyer and America, a mutable point would be a behavioral subtype of an immutable point, whereas Liskov substitution principle forbids this.

Violation

[edit]

Liskov substitution principle explains a property, "If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T,".[3]

Here is an example of violation of LSP:

class Rectangle {
private:
    double width;
    double height;
public:
    Rectangle(double width, double height):
        width{width}, height{height} {}

    // declared virtual for subclass Square
    virtual void setWidth(double width) noexcept {
        this->width = width;
    }

    // declared virtual for subclass Square
    virtual void setHeight(double height) noexcept {
        this->height = height;
    }

    [[nodiscard]]
    double getWidth() const noexcept {
        return width;
    }

    [[nodiscard]]
    double getHeight() const noexcept {
        return height;
    }

    [[nodiscard]]
    double getArea() const noexcept {
        return width * height;
    }
};

From a programming point of view, the Square class may be defined as extending the Rectangle class.

class Square : public Rectangle {
public:
    void setWidth(double width) noexcept override {
        Rectangle::setWidth(width);
        Rectangle::setHeight(width);
    }

    void setHeight(double height) noexcept override {
        Rectangle::setHeight(height);
        Rectangle::setWidth(height);
    }
};

However, this violates LSP even though the is-a relationship holds between Rectangle and Square.

Consider the following example, where function g does not work if a Square is passed in, and so the open-closed principle might be considered to have been violated.

void g(Rectangle& r) {
    r.setWidth(5); r.setHeight(4);
    assert(r.getArea() == 20); // assertion will fail
}

Conversely, if one considers that the type of a shape should only be a constraint on the relationship of its dimensions, then the assumption in g() that setHeight() will change height, and area, but not width is invalid. This assumption is invalid not only for squares, but even potentially for other rectangles that might be coded to preserve area or aspect ratio when height changes.[4]

See also

[edit]

References

[edit]
  1. ^ Liskov, Barbara; Wing, Jeannette (1994-11-01). "A behavioral notion of subtyping". ACM Transactions on Programming Languages and Systems. 16 (6): 1811–41. doi:10.1145/197320.197383. S2CID 999172.
  2. ^ Kinsbruner, Elad; Itzhaky, Shachar; Peleg, Hila (2024). "Constrictor: Immutability as a Design Concept". 38th European Conference on Object-Oriented Programming (ECOOP 2024). Leibniz International Proceedings in Informatics (LIPIcs). 313. Schloss Dagstuhl – Leibniz-Zentrum für Informatik: 22:1–22:29. doi:10.4230/LIPIcs.ECOOP.2024.22. ISBN 978-3-95977-341-6.{{cite journal}}: CS1 maint: periodical has ISBN (link)
  3. ^ Liskov, Barbara (May 1988). Data Abstraction and Hierarchy (PDF). SIGPLAN Notices. Archived from the original on Jun 21, 2020.
  4. ^ "The Liskov Substitution Principle" (PDF). Robert C. Martin, 1996. Archived from the original (PDF) on 5 September 2015. Retrieved 2 October 2012.

Bibliography

[edit]

Specific references

[edit]

General reference

[edit]
[edit]

Source: Wikipedia. Article content is retrieved live through the MediaWiki API.

Wikipedia

Liskov substitution principle

The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address titled Data abstraction and hierarchy. It is based on the concept of "substitutability" – a principle in object-oriented programming stating that an object of a superclass may be replaced by an object of a subclass without breaking the program. It is a semantic rather than merely syntactic relation, because it intends to guarantee semantic interoperability of types in a hierarchy, object types in particular. Barbara Liskov and Jeannette Wing described the principle succinctly in a 1994 paper as follows: Subtype Requirement: Let ⁠ ϕ ( x ) {\displaystyle \phi (x)} ⁠ be a property provable about objects ⁠ x {\displaystyle x} ⁠ of type T. Then ⁠ ϕ ( y ) {\displaystyle \phi (y)} ⁠ should be true for objects ⁠ y {\displaystyle y} ⁠ of type S where S is a subtype of T. Symbolically: S ≤ T → ( ∀ x : T . ϕ ( x ) → ∀ y : S . ϕ ( y ) ) {\displaystyle {\texttt {S}}\leq {\texttt {T}}\to (\forall x{:}{\texttt {T}}.\phi (x)\to \forall y{:}{\texttt {S}}.\phi (y))} That is, if S subtypes T, what holds for T-objects holds for S-objects. In the same paper, Liskov and Wing detailed their notion of behavioral subtyping in an extension of Hoare logic, which bears a certain resemblance to Bertrand Meyer's design by contract in that it considers the interaction of subtyping with preconditions, postconditions and invariants.

MORE →
No preview image
Wikipedia

Word Grammar

Word Grammar is a theory of linguistics, developed by Richard Hudson since the 1980s. It started as a model of syntax, whose most distinctive characteristic is its use of dependency grammar, an approach to syntax in which the sentence's structure is almost entirely contained in the information about individual words, and syntax is seen as consisting primarily of principles for combining words. The central syntactic relation is that of dependency between words; constituent structure is not recognized except in the special case of coordinate structures. However an even more important claim of Word Grammar is that statements about words and their properties form a complex network of propositions. More recent work on Word Grammar cites neurocognitive linguistics as a source of inspiration for the idea that language is nothing but a network. One of the attractions of the network view is the possibility of analysing language in the same way as other kinds of knowledge, given that knowledge, or long-term memory, is widely considered to be a network. Word grammar is an example of cognitive linguistics, which models language as part of general knowledge and not as a specialised mental faculty. This is in contrast to the nativism of Noam Chomsky and his students.

MORE →
No preview image
Wikipedia

Parsing

Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term parsing comes from Latin pars (orationis), meaning part (of speech). The term has slightly different meanings in different branches of linguistics and computer science. Traditional sentence parsing is often performed as a method of understanding the exact meaning of a sentence or word, sometimes with the aid of devices such as sentence diagrams. It usually emphasizes the importance of grammatical divisions such as subject and predicate. Within computational linguistics the term is used to refer to the formal analysis by a computer of a sentence or other string of words into its constituents, resulting in a parse tree showing their syntactic relation to each other, which may also contain semantic information. Some parsing algorithms generate a parse forest or list of parse trees from a string that is syntactically ambiguous. The term is also used in psycholinguistics when describing language comprehension. In this context, parsing refers to the way that human beings analyze a sentence or phrase (in spoken language or text) "in terms of grammatical constituents, identifying the parts of speech, syntactic relations, etc." This term is especially common when discussing which linguistic cues help speakers interpret garden-path sentences. Within computer science, the term is used in the analysis of computer languages, referring to the syntactic analysis of the input code into its component parts in order to facilitate the writing of compilers and interpreters. The term may also be used to describe a split or separation. In data analysis, the term is often used to refer to a process extracting desired information from data, e.g., creating a time series signal from a XML document.

MORE →
No preview image
Wikipedia

Government and binding theory

Government and binding (GB, GBT) is a theory of syntax and a phrase structure grammar in the tradition of transformational grammar developed principally by Noam Chomsky in the 1980s. This theory is a radical revision of his earlier theories and was later revised in The Minimalist Program (1995) and several subsequent papers, the latest being Three Factors in Language Design (2005). Although there is a large literature on government and binding theory which is not written by Chomsky, Chomsky's papers have been foundational in setting the research agenda. The name refers to two central subtheories of the theory: government, which is an abstract syntactic relation applicable, among other things, to the assignment of case; and binding, which deals chiefly with the relationships between pronouns and the expressions with which they are co-referential. GB was the first theory to be based on the principles and parameters model of language, which also underlies the later developments of the minimalist program.

MORE →
TOPIC OF THE DAY

Greenwood / Black Wall Street

Before the 1921 destruction of Tulsa’s Greenwood District, Black residents had created a remarkable center of business and community life. The district included stores, professional offices, entertainment venues and homes owned by Black citizens. Understanding Greenwood means learning what was built—not only what was burned.

MORE →
TRIVIA QUESTION OF THE DAY

Who became the first Black woman to travel into space?

Mae Jemison, aboard Space Shuttle Endeavour in 1992.