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

Lifecycle Processors Memory Leaks

The following compares 2 simple code snippets in the first one, there is a lifecycle memory leak at the (0 == read_bytes) predicate.

[Header]

/**
 * @brief A completely memory-safe not internally synchronized API that provides a dynamic
 * way of reading and writing to files without a [realloc] overhead; by delegating memory
 * allocation as a part of the pre-processor states to the caller, and the memory deallocation or further reallocation calls

Constructional Design using State Machines

Author: Pavl G.

This document establishes a constructional design for a low-level IO API that operates on filesystems of all types; the constructional design is completely based on the computational automata theory, that focuses particularly on designing machines that automate algorithms with {predefined set of states $$Q$$, initial state $$q$$, transitioning function $$\delta$$, set of input symbols $$\Sigma$$, set of final accepting states $$F$$}. Conceptually, a language $$L$$ could be accepted from these set of final accepting states (e.g., on_eof_reached and on_error_encountered); the language $$L_M$$ is a set of all strings that could be recognized by its machine $$M$$; whose alphabets are the $$\Sigma$$.

Note

In this API; the language could be all the available strings for read/write IO operations from and to a filesystem. In which, the start string (or char depending on the implementation of the state machines) is the

The following is the

Pattern Matching Algorithms

Author: Pavly G.

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):

@pavly-gerges
pavly-gerges / uniqueness-quantifier.md
Last active September 3, 2025 09:32
Instantiation of uniqueness quantifier for general use.

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

Author: Pavly G.

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!

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 September 3, 2025 09:44
Refactor a snippet taken from C How to program by Deitels to a better production code.

Specification for refactoring an example function:

Author: Pavly G.

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

Author: Pavly G.

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