Skip to content

Instantly share code, notes, and snippets.

View pavly-gerges's full-sized avatar
🤖
Electrostat Lab.

Pavly Gerges (pavl_g) pavly-gerges

🤖
Electrostat Lab.
View GitHub Profile

Pattern Matching Algorithms

Algorithmic techniques that involve matching a pattern (or domain elements) against another domain (or co-domain) or an argument of domains; therefore, a pattern is a repeated set of some elements (e.g., symbols, characters, or other patterns) in other domains in the same order or in different order.

Normal Forms Technique:

  • A not well-known technique is using predicate and quantificational logic to match a pattern against a domain. Normal Forms (CNF, DNF & PNF) could be utilized for this benefit.
  • Pattern matching can be crossed and used in other algorithmic structures (for example: path finding algorithms by matching some metadata and distance formulas when comparing edges from an adjacency matrix.

Start by an example (i.e., A Miniaturized Scientific Model):

Match ("Word" in "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789!=><"):

  • Starts by initializing a domain.
@pavly-gerges
pavly-gerges / uniqueness-quantifier.md
Last active May 29, 2025 08:24
Instantiation of uniqueness quantifier for general use.

Building digital logic ICs using Quantificational Logic: An Exclusive Uniqueness Existential Quantifier (Quantificational Logic)

Keywords: Discrete Mathematics - Quantificational Logic - Predicate Logic - Model Theory - Digital Logic Design - KiCad - Formal Languages.

Warning

  • This an early-version article, and is still subjected to core changes.
  • This article is not written using one of the fancy AI tools; therefore, pay respect to time spent to deliver this true knowledge.
  • Unlike fake content, this is true knowledge!
  • AI (ChatGPT) is used to derive the notation for the Semantical Definition section.

Here is an example of a non-null terminated list:

#include <stdio.h>
#include <stddef.h>

typedef struct buffer (buffer);

struct buffer {
    void *start_address;
 void *end_address;
@pavly-gerges
pavly-gerges / refactor-tree.md
Last active April 10, 2025 10:13
Refactor a snippet taken from C How to program by Deitels to a better production code.

Specification for refactoring an example function:

Important

Functions Declarations and Type Defintions Definition
image image

The main quest is to find problems in this code, classify them, and refactor them accordingly. Follow the software specification to understand what are the problems of this code, why they are problems, and whether there is a refactor.

@pavly-gerges
pavly-gerges / states-and-invariants.md
Last active March 27, 2025 19:14
States and invariance in discrete mathematical structures and computing.

States and Invariants

  • State: A state describes discrete change in the activity of a system on the physical electrical or the quantum level or the virtual level.
  • Invariant: A predicate (or property) that is perserved for each state across the states chain under all state transitions; that is P(v) is true for all the members of the set of labeled arcs or in Automata Theory the set of delta functions $$\Delta$$ representing the state transitions in an Automaton.

Important

Theorems required to prove:

  1. image

  2. image

Inclusive OR V.S. Exclusive OR: A deeper look

This guide establishes a deeper proof-based look into the inclusive OR (i.e., Logical Disjunction) and the exclusive OR (i.e., Mutually Exclusive or Mutually Imparted Events).

Note

Before getting started, here is a very quick whiteboard into the intuitionism behind the inclusive operations and the exclusive operations, and logical equivalences for each of them; notice the use of the intermediary formulas (e.g., Disjunctive and Conjunctive Normal Forms):

Inclusive OR Exclusive OR
inclusive-or exclusive-or

Formal derivation of combinations

Important

Theorems required to prove:

image image

@pavly-gerges
pavly-gerges / counting.md
Last active March 1, 2025 13:03
A formal derivation of the permutations as a principle of counting selected objects into sequences.

Derivation of the permutation formula

Important

Theorems required to prove:

image image

Proof Methodologies:

  • Mathematical Induction and Recursion for theorem.01.
  • Direct deductive proof for theorem.02.

Logical Equivalencies

Preface:

The compound propositions $$p$$ and $$q$$ are said to be logically equivalent if $$p \iff q$$ is a tautology (i.e., all their respective enteries in their truth table are congruent). Example, the compound proposition $$p \iff q$$ is logically equivalent to $$(p \implies q) \land (q \implies p)$$; because both the $$p \implies q$$ and $$q \implies p$$ have the same values in their respective enteries, and $$(p \iff q) \iff ((p \implies q) \land (q \implies p))$$ is a tautology.

Note

  • A compound proposition that is always true, no matter what the truth values of the propositional variables that occur in it, is called a tautology.
  • A compound proposition that is always false, no matter what the truth values of the propositional variables that occur in it, is called a contradication.
  • A compound proposition that is neither a tautology nor a contradiction, is a contingency.