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

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.
@pavly-gerges
pavly-gerges / dijkstra-formalism.md
Last active January 24, 2025 20:00
A formalization of the Dijkstra's algorithm

Formalization of Dijkstra's Path finder

Natural English Definition:

Overview: The formal definition describes how to compute the shortest path between two vertices in a graph using a systematic approach. It formalizes the idea of Dijkstra's algorithm, where each vertex is processed step-by-step, and distances are updated to find the shortest path from a starting vertex to a terminal vertex.

Graph Representation: The graph consists of a set of vertices (๐‘‰) and edges (๐ธ). Each edge has a weight that represents the distance between two connected vertices. These distances are stored in a matrix (๐‘€), where the value at position $$๐‘š_๐‘–๐‘—$$ represents the distance from vertex ๐‘– to vertex ๐‘—.

The Shortest Path Problem:

Fix NTFS Mounting problems

Screenshot from 2025-01-24 10-37-41

pavl-x86-machine@pavl-g:~$ sudo mkdir -p /media/pavl-x86-machine/pavl-g && \ # create a directory for mount
                           sudo mount /dev/sdb2 /media/pavl-x86-machine/pavl-g # mount manually