docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,231 @@
|
||||
---
|
||||
id: wiki-2026-0508-compcert
|
||||
title: CompCert (Verified C Compiler)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [CompCert, verified compiler, formal verification, Coq, Xavier Leroy, safety-critical]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.93
|
||||
verification_status: applied
|
||||
tags: [formal-verification, compiler, coq, compcert, safety-critical, sel4, full-stack-verification]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: Coq / OCaml
|
||||
framework: Coq Proof Assistant
|
||||
---
|
||||
|
||||
# CompCert
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 compiler 의 mathematically proven correct"**. Xavier Leroy 등 의 INRIA. 매 source-to-binary 의 의미 보존 의 Coq 의 증명. 매 safety-critical (avionics, medical, nuclear) 의 standard. 매 full-stack verification (seL4) 의 inspiration.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 verification target
|
||||
- 매 매 compilation pass 의 semantic preservation.
|
||||
- 매 source code 의 behavior = 매 compiled binary 의 behavior.
|
||||
- 매 over all valid input.
|
||||
|
||||
### 매 trust chain
|
||||
1. **Specification correctness** (C semantics).
|
||||
2. **Coq kernel** (small, audited).
|
||||
3. **Compiler proof** (in Coq).
|
||||
4. **Code extraction** (Coq → OCaml, audited).
|
||||
5. **OCaml runtime + assembler** (트러스트 base).
|
||||
|
||||
### 매 시간 history
|
||||
- 2003 Project start.
|
||||
- 2005 First version.
|
||||
- 2009 Version 1.6 (more passes verified).
|
||||
- 2024+ active development (Cs, Verasco extension).
|
||||
|
||||
### 매 application
|
||||
- **Avionics**: 매 Airbus, 매 ASTREE.
|
||||
- **Medical devices** (some).
|
||||
- **Automotive** (research).
|
||||
- **Nuclear**.
|
||||
- **Crypto / financial**: 매 critical.
|
||||
|
||||
### 매 alternative / related
|
||||
- **CakeML**: 매 ML 의 verified.
|
||||
- **CertiKOS**: 매 OS 의 verified.
|
||||
- **seL4**: 매 micro-kernel 의 verified.
|
||||
- **Vellvm**: 매 LLVM 의 verified.
|
||||
- **HACL\***: 매 verified crypto library.
|
||||
|
||||
### 매 limitation
|
||||
- 매 narrow C subset (no concurrency some).
|
||||
- 매 slower compile time.
|
||||
- 매 GCC 의 -O2 만큼 가, 매 -O3 의 lose.
|
||||
- 매 high investment of formal expert.
|
||||
- 매 license (mostly proprietary, dual).
|
||||
|
||||
### 매 modern relevance
|
||||
- **Software supply chain**: 매 trust 의 chain.
|
||||
- **AI safety**: 매 verifiable property.
|
||||
- **Formal methods 의 renaissance**: 매 rust borrow checker, TLA+ 의 popularization.
|
||||
|
||||
### 매 trust 의 critique (Ken Thompson)
|
||||
- "Reflections on Trusting Trust" (1984).
|
||||
- 매 compiler 의 self-reproduce + 매 backdoor.
|
||||
- 매 CompCert 의 partial answer.
|
||||
- 매 Diverse Double-Compilation (DDC).
|
||||
|
||||
## 💻 패턴 (응용 — formal verification)
|
||||
|
||||
### CompCert install + use
|
||||
```bash
|
||||
# 매 OPAM
|
||||
opam install coq=8.18 coq-flocq menhir
|
||||
git clone https://github.com/AbsInt/CompCert.git
|
||||
cd CompCert
|
||||
./configure x86_64-linux
|
||||
make -j8
|
||||
sudo make install
|
||||
|
||||
# 매 compile
|
||||
ccomp -O2 hello.c -o hello
|
||||
```
|
||||
|
||||
### 매 verified pass example (in Coq)
|
||||
```coq
|
||||
(* 매 매 transformation 의 simulation 의 prove *)
|
||||
Theorem transf_program_correct:
|
||||
forall p tp,
|
||||
transf_program p = OK tp ->
|
||||
forward_simulation (semantics p) (semantics tp).
|
||||
Proof.
|
||||
intros. apply forward_simulation_step with match_states; simpl; intros; eauto.
|
||||
- apply senv_preserved.
|
||||
- eapply transf_initial_states; eauto.
|
||||
- eapply transf_final_states; eauto.
|
||||
- eapply step_simulation; eauto.
|
||||
Qed.
|
||||
```
|
||||
|
||||
### Lean 4 (modern alternative)
|
||||
```lean
|
||||
-- 매 Lean 4: 매 mainstream alternative
|
||||
def add_then_double (n : Nat) : Nat := (n + 1) * 2
|
||||
|
||||
theorem add_then_double_eq : ∀ n, add_then_double n = 2 * n + 2 := by
|
||||
intro n
|
||||
unfold add_then_double
|
||||
ring
|
||||
```
|
||||
|
||||
### TLA+ (distributed protocol verification)
|
||||
```tla
|
||||
EXTENDS Naturals
|
||||
VARIABLE counter
|
||||
|
||||
Init == counter = 0
|
||||
|
||||
Increment == counter' = counter + 1
|
||||
|
||||
Spec == Init /\ [][Increment]_counter
|
||||
|
||||
Invariant == counter >= 0
|
||||
|
||||
THEOREM Spec => []Invariant
|
||||
```
|
||||
|
||||
### Z3 + property check
|
||||
```python
|
||||
from z3 import *
|
||||
|
||||
# 매 prove: 매 transformation 의 preserve property
|
||||
x = Int('x')
|
||||
y = Int('y')
|
||||
|
||||
solver = Solver()
|
||||
solver.add(Not(Implies(x > 0, x * 2 > 0))) # 매 negation
|
||||
result = solver.check()
|
||||
if result == unsat:
|
||||
print('Property holds.')
|
||||
```
|
||||
|
||||
### Verified compiler in modern Rust (research)
|
||||
```rust
|
||||
// 매 RustBelt-like — 매 Rust 의 borrow checker 의 verify
|
||||
// 매 unsafe code 의 contained correctness 의 prove
|
||||
```
|
||||
|
||||
### Property-based testing (poor man's verification)
|
||||
```python
|
||||
from hypothesis import given, strategies as st
|
||||
|
||||
@given(st.integers(min_value=-1000, max_value=1000))
|
||||
def test_compiler_optimization_preserves_meaning(x):
|
||||
naive_result = unoptimized_compile_and_run(x)
|
||||
opt_result = optimized_compile_and_run(x)
|
||||
assert naive_result == opt_result
|
||||
```
|
||||
|
||||
→ 매 formal verify 의 X 가, 매 thousand random input 의 invariant check.
|
||||
|
||||
### Trusted base 의 minimize
|
||||
```
|
||||
Trust:
|
||||
- Coq kernel (~10K LOC).
|
||||
- Specification of C (PEER-reviewed).
|
||||
- OCaml extractor.
|
||||
- OCaml runtime + assembler.
|
||||
|
||||
Don't trust:
|
||||
- The compiler itself (proven against spec).
|
||||
- Optimization passes (each verified).
|
||||
```
|
||||
|
||||
### CI integration (verified build)
|
||||
```yaml
|
||||
- name: Verified C compile
|
||||
run: |
|
||||
ccomp -O2 -fall src/safety_critical.c -o build/output.o
|
||||
cosign sign --key cosign.key build/output.o
|
||||
```
|
||||
|
||||
## 🤔 결정 기준
|
||||
| 상황 | Tool |
|
||||
|---|---|
|
||||
| Avionics / medical | CompCert |
|
||||
| OS kernel | seL4 / Coq |
|
||||
| Crypto | HACL\* / F\* |
|
||||
| Distributed protocol | TLA+ |
|
||||
| Math research | Lean 4 |
|
||||
| Quick property | Hypothesis / Z3 |
|
||||
| General compile | GCC / Clang + tests |
|
||||
| Rust safety | borrow checker + Miri |
|
||||
|
||||
**기본값**: 매 safety-critical = CompCert + Coq. 매 일반 = GCC + tests + sanitize.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Formal Methods]] · [[Automated-Theorem-Proving]]
|
||||
- Tool: [[Coq]]
|
||||
- Adjacent: [[Reliability]] · [[Antifragility]] · [[CI_CD 파이프라인 및 IDE 통합 보안]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 safety-critical compile. 매 formal verification reference. 매 trust chain 설계.
|
||||
**언제 X**: 매 일반 web app (over-engineering). 매 fast iteration.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **모든 software 의 verified**: 매 ROI X.
|
||||
- **CompCert 의 -O3 expectation**: 매 performance gap.
|
||||
- **No specification**: 매 wrong thing 의 prove.
|
||||
- **Trust base 의 over-extend**: 매 verification 가치 X.
|
||||
- **Unverified passes 의 add**: 매 chain 의 break.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Leroy CompCert papers, Pierce "Software Foundations", seL4 paper).
|
||||
- 신뢰도 A.
|
||||
- Related: [[Automated-Theorem-Proving]] · [[Software-Supply-Chain-Security]] · [[CI_CD 파이프라인 및 IDE 통합 보안]] · [[Antifragility]].
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — verification target + trust chain + 매 Coq / Lean / TLA+ / Z3 code |
|
||||
Reference in New Issue
Block a user